2024.5.12基本AI功能基本完善,但是非流式回答

This commit is contained in:
zhangsan 2024-05-12 15:34:48 +08:00
parent 33828f0d38
commit cb924f28b9
44 changed files with 357 additions and 341 deletions

View File

@ -24,18 +24,18 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Jianshu" android:theme="@style/Theme.Jianshu"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity android:name=".GoodBookActivity" /> <activity android:name="com.zjgsu.jianshu.GoodBookActivity" />
<activity android:name=".HotBookActivity" /> <activity android:name="com.zjgsu.jianshu.HotBookActivity" />
<activity android:name=".BookInformationActivity" /> <activity android:name="com.zjgsu.jianshu.BookInformationActivity" />
<activity android:name=".PerceptionActivity" /> <activity android:name="com.zjgsu.jianshu.PerceptionActivity" />
<activity android:name=".FindpwdActivity" /> <activity android:name="com.zjgsu.jianshu.FindpwdActivity" />
<activity android:name=".LiteratureActivity" /> <activity android:name="com.zjgsu.jianshu.LiteratureActivity" />
<activity android:name=".PsychologyActivity" /> <activity android:name="com.zjgsu.jianshu.PsychologyActivity" />
<activity android:name=".ManagementActivity" /> <activity android:name="com.zjgsu.jianshu.ManagementActivity" />
<activity android:name=".PhilosophyActivity" /> <activity android:name="com.zjgsu.jianshu.PhilosophyActivity" />
<!-- <activity android:name=".BookShelfActivity"/>--> <!-- <activity android:name=".BookShelfActivity"/>-->
<activity android:name=".ScienceActivity" /> <activity android:name="com.zjgsu.jianshu.ScienceActivity" />
<activity android:name=".Author_introductionActivity" /> <activity android:name="com.zjgsu.jianshu.Author_introductionActivity" />
<!-- <activity android:name=".MainActivity"--> <!-- <activity android:name=".MainActivity"-->
<!-- android:exported="true"--> <!-- android:exported="true"-->
<!-- android:label="@string/app_name"--> <!-- android:label="@string/app_name"-->
@ -46,26 +46,27 @@
<!-- <category android:name="android.intent.category.LAUNCHER" />--> <!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>--> <!-- </intent-filter>-->
<!-- </activity>--> <!-- </activity>-->
<activity android:name=".SendSpecificActivity" /> <activity android:name="com.zjgsu.jianshu.SendSpecificActivity" />
<activity android:name=".BookIntroActivity" /> <activity android:name="com.zjgsu.jianshu.BookIntroActivity" />
<activity android:name=".MainActivity" <activity android:name="com.zjgsu.jianshu.MainActivity"
android:configChanges="orientation|keyboard|keyboardHidden|navigation" /> android:configChanges="orientation|keyboard|keyboardHidden|navigation"
<activity android:name=".RegisterActivity" /> />
<activity android:name=".BookShelfActivity" /> <activity android:name="com.zjgsu.jianshu.RegisterActivity" />
<activity android:name=".Activity.Perception_informationActivity" /> <activity android:name="com.zjgsu.jianshu.BookShelfActivity" />
<activity android:name=".Activity.sendPerceptionActivity" /> <activity android:name="com.zjgsu.jianshu.Activity.Perception_informationActivity" />
<activity android:name=".MyActivity" /> <activity android:name="com.zjgsu.jianshu.Activity.sendPerceptionActivity" />
<activity android:name=".Activity.MyPostActivity" /> <activity android:name="com.zjgsu.jianshu.MyActivity" />
<activity android:name=".ReEmailActivity" /> <activity android:name="com.zjgsu.jianshu.Activity.MyPostActivity" />
<activity android:name=".RePhoneActivity" /> <activity android:name="com.zjgsu.jianshu.ReEmailActivity" />
<activity android:name=".ReMyinfoActivity" /> <activity android:name="com.zjgsu.jianshu.RePhoneActivity" />
<activity android:name=".ReNameActivity" /> <activity android:name="com.zjgsu.jianshu.ReMyinfoActivity" />
<activity android:name=".ReSexActivity" /> <activity android:name="com.zjgsu.jianshu.ReNameActivity" />
<activity android:name=".ReSignatureActivity" /> <activity android:name="com.zjgsu.jianshu.ReSexActivity" />
<activity android:name=".Activity.AccountManagerActivity" /> <activity android:name="com.zjgsu.jianshu.ReSignatureActivity" />
<activity android:name=".ReAddressActivity"/> <activity android:name="com.zjgsu.jianshu.Activity.AccountManagerActivity" />
<activity android:name="com.zjgsu.jianshu.ReAddressActivity"/>
<activity <activity
android:name=".LoginActivity" android:name="com.zjgsu.jianshu.LoginActivity"
android:exported="true" android:exported="true"
android:label="Jianshu"> android:label="Jianshu">
<intent-filter> <intent-filter>

View File

@ -1,11 +1,9 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.StaggeredGridLayoutManager import androidx.recyclerview.widget.StaggeredGridLayoutManager
import cn.bmob.v3.Bmob import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
@ -15,7 +13,6 @@ import com.bumptech.glide.Glide
import com.zjgsu.jianshu.Bmob.Author_bmob import com.zjgsu.jianshu.Bmob.Author_bmob
import com.zjgsu.jianshu.Bmob.Book_info_bmob import com.zjgsu.jianshu.Bmob.Book_info_bmob
import kotlinx.android.synthetic.main.activity_anthor_introduction.* import kotlinx.android.synthetic.main.activity_anthor_introduction.*
import kotlinx.android.synthetic.main.activity_book_info.*
class Author_introductionActivity : AppCompatActivity() { class Author_introductionActivity : AppCompatActivity() {
private var authorworkList = ArrayList<AuthorWork>() private var authorworkList = ArrayList<AuthorWork>()

View File

@ -7,7 +7,6 @@ import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.UpdateListener
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.Button import android.widget.Button
@ -26,7 +25,6 @@ import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.Bmob.Bookcontent_bmob import com.zjgsu.jianshu.Bmob.Bookcontent_bmob
import com.zjgsu.jianshu.Bmob.Perception_bmob import com.zjgsu.jianshu.Bmob.Perception_bmob
import kotlinx.android.synthetic.main.activity_book_info.* import kotlinx.android.synthetic.main.activity_book_info.*
import kotlinx.android.synthetic.main.activity_sendspecific.*
import kotlinx.android.synthetic.main.bookinfo_title.* import kotlinx.android.synthetic.main.bookinfo_title.*
import okhttp3.* import okhttp3.*
import java.io.File import java.io.File

View File

@ -8,8 +8,6 @@ import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Bmob.Book_info_bmob import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.R
import kotlinx.android.synthetic.main.activity_book_info.*
import kotlinx.android.synthetic.main.activity_bookintro.* import kotlinx.android.synthetic.main.activity_bookintro.*
import kotlinx.android.synthetic.main.expandable3.* import kotlinx.android.synthetic.main.expandable3.*
import kotlinx.android.synthetic.main.expandable4.* import kotlinx.android.synthetic.main.expandable4.*

View File

@ -1,11 +1,8 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -16,23 +13,9 @@ import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Bmob.BookShelf import com.zjgsu.jianshu.Bmob.BookShelf
import kotlinx.android.synthetic.main.activity_bookshelf.* import kotlinx.android.synthetic.main.activity_bookshelf.*
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_perception.*
import kotlinx.android.synthetic.main.bookshelf_item.*
import kotlinx.android.synthetic.main.expandable.*
import kotlin.concurrent.thread
import com.google.android.material.snackbar.Snackbar
import android.view.LayoutInflater
import android.view.View.OnLongClickListener
import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import android.view.MotionEvent
import android.view.View.OnTouchListener
import android.widget.Button import android.widget.Button
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import cn.bmob.v3.listener.UpdateListener import cn.bmob.v3.listener.UpdateListener

View File

@ -3,8 +3,6 @@ package com.zjgsu.jianshu
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.PersistableBundle
import android.os.Process
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
@ -17,58 +15,64 @@ import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_findpwd.* import kotlinx.android.synthetic.main.activity_findpwd.*
import kotlinx.android.synthetic.main.activity_findpwd.image_findpwd_backtoLogin import kotlinx.android.synthetic.main.activity_findpwd.image_findpwd_backtoLogin
import kotlinx.android.synthetic.main.activity_register.*
class FindpwdActivity:AppCompatActivity() { class FindpwdActivity : AppCompatActivity() {
private var msg:String="" private var msg: String = ""
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_findpwd) setContentView(R.layout.activity_findpwd)
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
image_findpwd_backtoLogin.setOnClickListener{ image_findpwd_backtoLogin.setOnClickListener {
val intent=Intent(this,LoginActivity::class.java) val intent = Intent(this, LoginActivity::class.java)
startActivity(intent) startActivity(intent)
finish() finish()
} }
inits() inits()
} }
private val click2 = DialogInterface.OnClickListener { arg0, arg1 -> arg0.cancel()
val intent=Intent(this,LoginActivity::class.java) private val click2 = DialogInterface.OnClickListener { arg0, arg1 ->
arg0.cancel()
val intent = Intent(this, LoginActivity::class.java)
startActivity(intent) startActivity(intent)
finish() finish()
} }
public fun showdialog(view:View){
val alertdialog:AlertDialog.Builder=AlertDialog.Builder(this) public fun showdialog(view: View) {
val alertdialog: AlertDialog.Builder = AlertDialog.Builder(this)
alertdialog.setMessage(msg) alertdialog.setMessage(msg)
alertdialog.setNegativeButton("确认", click2); alertdialog.setNegativeButton("确认", click2);
val alertdialog1:AlertDialog=alertdialog.create(); val alertdialog1: AlertDialog = alertdialog.create();
alertdialog1.show(); alertdialog1.show();
} }
public fun inits(){
bt_find_nextstep.setOnClickListener{ public fun inits() {
var flag:Boolean=false bt_find_nextstep.setOnClickListener {
var flag: Boolean = false
val user_account: String = et_find_account.text.toString() val user_account: String = et_find_account.text.toString()
val user_email:String=et_find_mail.text.toString() val user_email: String = et_find_mail.text.toString()
if(user_account.isEmpty()||user_email.isEmpty()) { if (user_account.isEmpty() || user_email.isEmpty()) {
Toast.makeText(this, "账号或邮箱不能为空!", Toast.LENGTH_SHORT).show() Toast.makeText(this, "账号或邮箱不能为空!", Toast.LENGTH_SHORT).show()
Log.d("zy",user_account) Log.d("zy", user_account)
} } else {
else{
val bmobQuery = BmobQuery<User_bmob>() val bmobQuery = BmobQuery<User_bmob>()
var tempPwd:String="" var tempPwd: String = ""
bmobQuery.findObjects(object :FindListener<User_bmob>(){ bmobQuery.findObjects(object : FindListener<User_bmob>() {
override fun done(list: List<User_bmob>, e: BmobException?) { override fun done(list: List<User_bmob>, e: BmobException?) {
if (e == null) { if (e == null) {
for (i in list) { for (i in list) {
if (user_account.equals(i.account)&&user_email.equals(i.email)) { if (user_account.equals(i.account) && user_email.equals(i.email)) {
flag = true flag = true
tempPwd=i.password tempPwd = i.password
msg="您的密码为: "+tempPwd msg = "您的密码为: " + tempPwd
showdialog(bt_find_nextstep) showdialog(bt_find_nextstep)
} }
} }
if(flag!=true) if (flag != true)
Toast.makeText(this@FindpwdActivity,"账号不存在,请重新输入!",Toast.LENGTH_SHORT).show() Toast.makeText(
this@FindpwdActivity,
"账号不存在,请重新输入!",
Toast.LENGTH_SHORT
).show()
} }
} }
}) })

View File

@ -1,7 +1,6 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -12,10 +11,6 @@ import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Adapter.BookRankAdapter import com.zjgsu.jianshu.Adapter.BookRankAdapter
import com.zjgsu.jianshu.Bmob.Book_info_bmob import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.Book_rank
import com.zjgsu.jianshu.MainActivity
import com.zjgsu.jianshu.NavigationHelper
import com.zjgsu.jianshu.R
import kotlinx.android.synthetic.main.activity_bookrank.* import kotlinx.android.synthetic.main.activity_bookrank.*
class GoodBookActivity : AppCompatActivity() { class GoodBookActivity : AppCompatActivity() {

View File

@ -1,24 +1,16 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.widget.SearchView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager import androidx.recyclerview.widget.StaggeredGridLayoutManager
import cn.bmob.v3.Bmob import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.*
import com.zjgsu.jianshu.Adapter.BillboardAdapter
import com.zjgsu.jianshu.Adapter.BookRankAdapter import com.zjgsu.jianshu.Adapter.BookRankAdapter
import com.zjgsu.jianshu.Bmob.Book_info_bmob import com.zjgsu.jianshu.Bmob.Book_info_bmob
import kotlinx.android.synthetic.main.activity_bookrank.* import kotlinx.android.synthetic.main.activity_bookrank.*
import kotlinx.android.synthetic.main.activity_main.*
class HotBookActivity: AppCompatActivity() { class HotBookActivity: AppCompatActivity() {
private var hotbookList=ArrayList<Book_rank>() private var hotbookList=ArrayList<Book_rank>()

View File

@ -1,10 +1,11 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import android.view.inputmethod.InputMethodManager
import android.widget.SearchView import android.widget.SearchView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -83,6 +84,7 @@ class MainActivity : AppCompatActivity() {
setupBottomNavigation() setupBottomNavigation()
} }
private fun loadBooks() { private fun loadBooks() {
val query = BmobQuery<Book_bmob>() val query = BmobQuery<Book_bmob>()
query.findObjects(object : FindListener<Book_bmob>() { query.findObjects(object : FindListener<Book_bmob>() {

View File

@ -1,6 +1,5 @@
package com.zjgsu.jianshu.Activity; package com.zjgsu.jianshu.Activity;
import android.app.Activity; import android.app.Activity;
import android.app.LocalActivityManager;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.os.Bundle; import android.os.Bundle;
@ -9,11 +8,9 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.TranslateAnimation; import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.VideoView;
import com.zjgsu.jianshu.R; import com.zjgsu.jianshu.R;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;

View File

@ -6,7 +6,6 @@ import android.graphics.Bitmap
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.util.Log
import cn.bmob.v3.Bmob import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
@ -14,7 +13,6 @@ import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Activity.AccountManagerActivity import com.zjgsu.jianshu.Activity.AccountManagerActivity
import com.zjgsu.jianshu.Activity.MyPostActivity import com.zjgsu.jianshu.Activity.MyPostActivity
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_my.* import kotlinx.android.synthetic.main.activity_my.*
import kotlinx.android.synthetic.main.layout_bottom_navigation.* import kotlinx.android.synthetic.main.layout_bottom_navigation.*
import java.io.InputStream import java.io.InputStream

View File

@ -1,22 +1,18 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import cn.bmob.v3.Bmob import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Activity.sendPerceptionActivity import com.zjgsu.jianshu.Activity.sendPerceptionActivity
import com.zjgsu.jianshu.Adapter.GoodperceptionAdapter
import com.zjgsu.jianshu.Bmob.Perception_bmob import com.zjgsu.jianshu.Bmob.Perception_bmob
import kotlinx.android.synthetic.main.activity_perception.* import kotlinx.android.synthetic.main.activity_perception.*
import kotlinx.android.synthetic.main.layout_bottom_navigation.* import kotlinx.android.synthetic.main.layout_bottom_navigation.*
import kotlin.concurrent.thread
class PerceptionActivity : AppCompatActivity() { class PerceptionActivity : AppCompatActivity() {
private val PerceptionList = ArrayList<Perception>() private val PerceptionList = ArrayList<Perception>()

View File

@ -1,18 +1,14 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.R.attr
import android.content.Intent import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import androidx.appcompat.view.menu.MenuAdapter
import cn.bmob.v3.Bmob import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import kotlinx.android.synthetic.main.activity_my.*
import kotlinx.android.synthetic.main.activity_re_myinfo.* import kotlinx.android.synthetic.main.activity_re_myinfo.*
import android.R.attr.data
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob

View File

@ -10,11 +10,8 @@ import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.UpdateListener import cn.bmob.v3.listener.UpdateListener
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_findpwd.*
import kotlinx.android.synthetic.main.activity_re_myinfo.*
import kotlinx.android.synthetic.main.activity_re_name.* import kotlinx.android.synthetic.main.activity_re_name.*
import kotlinx.android.synthetic.main.activity_re_name.back2my import kotlinx.android.synthetic.main.activity_re_name.back2my
import kotlinx.android.synthetic.main.activity_register.*
class ReNameActivity : AppCompatActivity() { class ReNameActivity : AppCompatActivity() {

View File

@ -4,15 +4,12 @@ import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.widget.ArrayAdapter
import android.widget.Toast import android.widget.Toast
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.UpdateListener import cn.bmob.v3.listener.UpdateListener
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_re_name.*
import kotlinx.android.synthetic.main.activity_re_sex.*
import kotlinx.android.synthetic.main.activity_re_sex.back2my import kotlinx.android.synthetic.main.activity_re_sex.back2my
import kotlinx.android.synthetic.main.activity_re_sex.btnOk import kotlinx.android.synthetic.main.activity_re_sex.btnOk
import kotlinx.android.synthetic.main.activity_re_sex.et_account import kotlinx.android.synthetic.main.activity_re_sex.et_account

View File

@ -11,7 +11,6 @@ import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.UpdateListener import cn.bmob.v3.listener.UpdateListener
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_re_myinfo.*
import kotlinx.android.synthetic.main.activity_re_name.* import kotlinx.android.synthetic.main.activity_re_name.*
class ReSignatureActivity : AppCompatActivity() { class ReSignatureActivity : AppCompatActivity() {

View File

@ -9,11 +9,8 @@ import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.QueryListListener
import cn.bmob.v3.listener.SaveListener import cn.bmob.v3.listener.SaveListener
import cn.bmob.v3.listener.UpdateListener
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_register.* import kotlinx.android.synthetic.main.activity_register.*
class RegisterActivity : AppCompatActivity() { class RegisterActivity : AppCompatActivity() {

View File

@ -9,14 +9,9 @@ import android.view.inputmethod.InputMethodManager
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import cn.bmob.v3.Bmob import cn.bmob.v3.Bmob
import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.SaveListener import cn.bmob.v3.listener.SaveListener
import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.Bmob.Perception_bmob import com.zjgsu.jianshu.Bmob.Perception_bmob
import com.zjgsu.jianshu.Book_Shelf
import com.zjgsu.jianshu.R
import kotlinx.android.synthetic.main.activity_sendspecific.* import kotlinx.android.synthetic.main.activity_sendspecific.*
class SendSpecificActivity: AppCompatActivity() { class SendSpecificActivity: AppCompatActivity() {

View File

@ -2,8 +2,6 @@ package com.zjgsu.jianshu.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.WindowManager import android.view.WindowManager
@ -22,12 +20,7 @@ import com.zjgsu.jianshu.*
import com.zjgsu.jianshu.Bmob.Book_info_bmob import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.Bmob.Perception_bmob import com.zjgsu.jianshu.Bmob.Perception_bmob
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_book_info.*
import kotlinx.android.synthetic.main.activity_sendperception.* import kotlinx.android.synthetic.main.activity_sendperception.*
import kotlinx.android.synthetic.main.activity_sendspecific.*
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class sendPerceptionActivity:AppCompatActivity() { class sendPerceptionActivity:AppCompatActivity() {
private var bookList = ArrayList<Book_Shelf>() private var bookList = ArrayList<Book_Shelf>()
@ -51,8 +44,8 @@ class sendPerceptionActivity:AppCompatActivity() {
send_recyclerview.adapter = adapter send_recyclerview.adapter = adapter
inits() inits()
send_return.setOnClickListener { send_return.setOnClickListener {
val intent= Intent(this,PerceptionActivity::class.java) // val intent= Intent(this,PerceptionActivity::class.java)
startActivity(intent) // startActivity(intent)
finish() finish()
} }
submit.setOnClickListener { submit.setOnClickListener {

View File

@ -1,10 +1,6 @@
package com.zjgsu.jianshu.Adapter package com.zjgsu.jianshu.Adapter
import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.drawable.Drawable
import android.transition.Transition
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,12 +8,8 @@ import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.zjgsu.jianshu.* import com.zjgsu.jianshu.*
class BillboardAdapter(var listOfbookRankList: List<List<Book_rank>>) : RecyclerView.Adapter<BillboardAdapter.ViewHolder>() { class BillboardAdapter(var listOfbookRankList: List<List<Book_rank>>) : RecyclerView.Adapter<BillboardAdapter.ViewHolder>() {

View File

@ -1,9 +1,6 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -12,14 +9,7 @@ import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.zjgsu.jianshu.Bmob.Book_bmob
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class BookAdapter(var bookList: List<Book>) : RecyclerView.Adapter<BookAdapter.ViewHolder>() { class BookAdapter(var bookList: List<Book>) : RecyclerView.Adapter<BookAdapter.ViewHolder>() {

View File

@ -1,29 +1,16 @@
package com.zjgsu.jianshu.Adapter package com.zjgsu.jianshu.Adapter
import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.ActivityChooserView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import cn.bmob.v3.BmobQuery
import cn.bmob.v3.datatype.BmobFile
import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.zjgsu.jianshu.* import com.zjgsu.jianshu.*
import com.zjgsu.jianshu.Bmob.Book_bmob
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class BookAdapter2(val bookList: List<Book>,val categoryId:Int) : RecyclerView.Adapter<BookAdapter2.ViewHolder>() { class BookAdapter2(val bookList: List<Book>,val categoryId:Int) : RecyclerView.Adapter<BookAdapter2.ViewHolder>() {

View File

@ -2,7 +2,6 @@ package com.zjgsu.jianshu.Adapter
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.media.Image
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -20,9 +19,13 @@ import cn.bmob.v3.listener.SaveListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.zjgsu.jianshu.* import com.zjgsu.jianshu.*
import com.zjgsu.jianshu.Bmob.BookShelf import com.zjgsu.jianshu.Bmob.BookShelf
import kotlinx.android.synthetic.main.bookinfo_title.*
class BookRankAdapter(private val context: Context,var bookList: List<Book_rank>, val isHotList: Boolean, val userId: String) : class BookRankAdapter(
private val context: Context,
var bookList: List<Book_rank>,
val isHotList: Boolean,
val userId: String
) :
RecyclerView.Adapter<BookRankAdapter.ViewHolder>() { RecyclerView.Adapter<BookRankAdapter.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val bookrank_pic: ImageView = view.findViewById(R.id.bookrank_pic) val bookrank_pic: ImageView = view.findViewById(R.id.bookrank_pic)
@ -34,7 +37,7 @@ class BookRankAdapter(private val context: Context,var bookList: List<Book_rank>
val bookrank_author: TextView = view.findViewById(R.id.bookrank_author) val bookrank_author: TextView = view.findViewById(R.id.bookrank_author)
val bookrank_icon: ImageView = view.findViewById(R.id.bookrank_icon) val bookrank_icon: ImageView = view.findViewById(R.id.bookrank_icon)
val bookrank_addbook: ImageView = view.findViewById(R.id.bookrank_addbook) val bookrank_addbook: ImageView = view.findViewById(R.id.bookrank_addbook)
val bookrank_add:TextView=view.findViewById(R.id.bookrank_add) val bookrank_add: TextView = view.findViewById(R.id.bookrank_add)
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
@ -47,6 +50,9 @@ class BookRankAdapter(private val context: Context,var bookList: List<Book_rank>
val book = bookList[position] val book = bookList[position]
holder.bookrank_name.text = book.name holder.bookrank_name.text = book.name
holder.bookrank_intro.text = book.intro holder.bookrank_intro.text = book.intro
// 设置默认状态
holder.bookrank_addbook.setImageResource(R.drawable.addbook)
holder.bookrank_add.text = "加入书架"
val backgrounds = arrayOf( val backgrounds = arrayOf(
R.drawable.color_lightpurple, R.drawable.color_lightblue, R.drawable.color_lightpurple, R.drawable.color_lightblue,
R.drawable.color_lightgreen, R.drawable.color_flesh R.drawable.color_lightgreen, R.drawable.color_flesh
@ -83,7 +89,7 @@ class BookRankAdapter(private val context: Context,var bookList: List<Book_rank>
holder.outerLinearLayout.setOnClickListener { holder.outerLinearLayout.setOnClickListener {
val intent = Intent(holder.itemView.context, BookInformationActivity::class.java) val intent = Intent(holder.itemView.context, BookInformationActivity::class.java)
intent.putExtra("Book_name", book.name) intent.putExtra("Book_name", book.name)
if(isHotList) if (isHotList)
intent.putExtra("Source_Activity", HotBookActivity::class.java) intent.putExtra("Source_Activity", HotBookActivity::class.java)
else else
intent.putExtra("Source_Activity", GoodBookActivity::class.java) intent.putExtra("Source_Activity", GoodBookActivity::class.java)
@ -103,7 +109,8 @@ class BookRankAdapter(private val context: Context,var bookList: List<Book_rank>
bookshelfRecord.save(object : SaveListener<String>() { bookshelfRecord.save(object : SaveListener<String>() {
override fun done(objectId: String?, saveException: BmobException?) { override fun done(objectId: String?, saveException: BmobException?) {
if (saveException == null) { if (saveException == null) {
holder.bookrank_addbook.setImageResource(R.drawable.bookshelf2) holder.bookrank_addbook.setImageResource(R.drawable.alreadyin)
holder.bookrank_add.text = "已加入"
Toast.makeText( Toast.makeText(
context, context,
"添加成功", "添加成功",
@ -124,20 +131,17 @@ class BookRankAdapter(private val context: Context,var bookList: List<Book_rank>
} }
}) })
} }
fun judgeInBookshelf() { val queryBookshelf = BmobQuery<BookShelf>()
val queryBookshelf = BmobQuery<BookShelf>() queryBookshelf.addWhereEqualTo("userid", userId)
queryBookshelf.addWhereEqualTo("userid", userId) queryBookshelf.addWhereEqualTo("b_name", book.name)
queryBookshelf.addWhereEqualTo("b_name", book.name) queryBookshelf.findObjects(object : FindListener<BookShelf>() {
queryBookshelf.findObjects(object : FindListener<BookShelf>() { override fun done(bookshelfItems: MutableList<BookShelf>?, e: BmobException?) {
override fun done(bookshelfItems: MutableList<BookShelf>?, e: BmobException?) { if (e == null && bookshelfItems != null && bookshelfItems.isNotEmpty()) {
if (e == null && bookshelfItems != null && bookshelfItems.isNotEmpty()) { holder.bookrank_addbook.setImageResource(R.drawable.alreadyin)
holder.bookrank_addbook.setImageResource(R.drawable.alreadyin) holder.bookrank_add.text = "已加入"
holder.bookrank_add.text="已加入"
}
} }
}) }
} })
judgeInBookshelf()
} }
override fun getItemCount() = bookList.size override fun getItemCount() = bookList.size

View File

@ -1,14 +1,10 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.* import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import cn.bmob.v3.BmobQuery import cn.bmob.v3.BmobQuery
@ -17,12 +13,6 @@ import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.SaveListener import cn.bmob.v3.listener.SaveListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.zjgsu.jianshu.Bmob.BookShelf import com.zjgsu.jianshu.Bmob.BookShelf
import com.zjgsu.jianshu.Bmob.Book_bmob
import kotlinx.android.synthetic.main.activity_main.view.*
import kotlinx.android.synthetic.main.book_author_item.*
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class Book_authorAdapter(val authorworkList:List<AuthorWork>,val userId: String):RecyclerView.Adapter<Book_authorAdapter.ViewHolder>() { class Book_authorAdapter(val authorworkList:List<AuthorWork>,val userId: String):RecyclerView.Adapter<Book_authorAdapter.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {

View File

@ -5,7 +5,6 @@ import android.content.Intent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat

View File

@ -6,7 +6,6 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -15,7 +14,6 @@ import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener import cn.bmob.v3.listener.FindListener
import com.zjgsu.jianshu.Bmob.Comment_bmob import com.zjgsu.jianshu.Bmob.Comment_bmob
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import com.zjgsu.jianshu.Book_authorAdapter
import com.zjgsu.jianshu.Comment import com.zjgsu.jianshu.Comment
import com.zjgsu.jianshu.R import com.zjgsu.jianshu.R
import java.io.InputStream import java.io.InputStream

View File

@ -1,7 +1,5 @@
package com.zjgsu.jianshu.Adapter package com.zjgsu.jianshu.Adapter
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import com.zjgsu.jianshu.Perception import com.zjgsu.jianshu.Perception
import com.zjgsu.jianshu.R import com.zjgsu.jianshu.R
import android.view.LayoutInflater import android.view.LayoutInflater
@ -16,10 +14,6 @@ import cn.bmob.v3.listener.FindListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.zjgsu.jianshu.Bmob.Perception_bmob import com.zjgsu.jianshu.Bmob.Perception_bmob
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import kotlinx.android.synthetic.main.activity_book_info.*
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class GoodperceptionAdapter(val perceptionList: List<Perception>) : RecyclerView.Adapter<GoodperceptionAdapter.ViewHolder>() { class GoodperceptionAdapter(val perceptionList: List<Perception>) : RecyclerView.Adapter<GoodperceptionAdapter.ViewHolder>() {

View File

@ -1,8 +1,6 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -19,9 +17,6 @@ import com.zjgsu.jianshu.Activity.Perception_informationActivity
import com.zjgsu.jianshu.Bmob.Book_info_bmob import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.Bmob.Perception_bmob import com.zjgsu.jianshu.Bmob.Perception_bmob
import com.zjgsu.jianshu.Bmob.User_bmob import com.zjgsu.jianshu.Bmob.User_bmob
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
class PerceptionAdapter(val perceptionList: List<Perception>) : class PerceptionAdapter(val perceptionList: List<Perception>) :

View File

@ -1,30 +1,13 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color import android.graphics.Color
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.* import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import cn.bmob.v3.BmobQuery
import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.SaveListener
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.zjgsu.jianshu.Activity.sendPerceptionActivity
import com.zjgsu.jianshu.Bmob.BookShelf
import com.zjgsu.jianshu.Bmob.Book_bmob
import kotlinx.android.synthetic.main.activity_main.view.*
import kotlinx.android.synthetic.main.book_author_item.*
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
lateinit var selectedBook:String lateinit var selectedBook:String
class send_perceptionAdapter(val bookList:List<Book_Shelf>):RecyclerView.Adapter<send_perceptionAdapter.ViewHolder>() { class send_perceptionAdapter(val bookList:List<Book_Shelf>):RecyclerView.Adapter<send_perceptionAdapter.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {

View File

@ -1,5 +1,3 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import cn.bmob.v3.datatype.BmobFile
class Book_Shelf(val bkname:String,val picurl:String) class Book_Shelf(val bkname:String,val picurl:String)

View File

@ -5,5 +5,5 @@ class Book_rank(var name: String,
var score:String, var score:String,
var courtOfReaders:Int, var courtOfReaders:Int,
var author:String, var author:String,
var intro:String var intro:String,
) )

View File

@ -1,6 +1,5 @@
package com.zjgsu.jianshu.Fragment package com.zjgsu.jianshu.Fragment
import android.graphics.Typeface
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View

View File

@ -3,7 +3,6 @@ package com.zjgsu.jianshu;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Display; import android.view.Display;

View File

@ -2,7 +2,6 @@ package com.zjgsu.jianshu
import android.content.Intent import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
object NavigationHelper { object NavigationHelper {
fun <T> navigateTo(activity: AppCompatActivity, destinationClass: Class<T>) { fun <T> navigateTo(activity: AppCompatActivity, destinationClass: Class<T>) {

View File

@ -1,5 +1,3 @@
package com.zjgsu.jianshu package com.zjgsu.jianshu
import cn.bmob.v3.datatype.BmobFile
class Perception(val perceptionid:String) class Perception(val perceptionid:String)

View File

@ -3,7 +3,6 @@ package com.zjgsu.jianshu
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import android.widget.TextView import android.widget.TextView
import com.zjgsu.jianshu.R
class TypeView(itemView: View) : RecyclerView.ViewHolder(itemView) { class TypeView(itemView: View) : RecyclerView.ViewHolder(itemView) {
var textView: TextView var textView: TextView

View File

@ -58,6 +58,10 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageV
Message message = messages.get(position); Message message = messages.get(position);
if (message.getIsuser() == 1) { // user if (message.getIsuser() == 1) { // user
holder.textViewMessage.setText(message.getContent()); holder.textViewMessage.setText(message.getContent());
if(message.getCite()!=""){
holder.messageUser_Cite.setVisibility(View.VISIBLE);
holder.messageUser_Cite.setText(message.getCite());
}
} else { // bot } else { // bot
holder.textViewMessage.setText(message.getContent()); holder.textViewMessage.setText(message.getContent());
// 检查是否为最后一条机器人消息 // 检查是否为最后一条机器人消息
@ -105,13 +109,13 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageV
} }
static class MessageViewHolder extends RecyclerView.ViewHolder { static class MessageViewHolder extends RecyclerView.ViewHolder {
TextView textViewMessage; TextView textViewMessage,messageUser_Cite;
ImageView imageViewCopy; ImageView imageViewCopy,imageViewRegenerate;
ImageView imageViewRegenerate;
MessageViewHolder(View itemView, int viewType) { MessageViewHolder(View itemView, int viewType) {
super(itemView); super(itemView);
if (viewType == 1) { // 假设 1 是用户消息 if (viewType == 1) { // 假设 1 是用户消息
textViewMessage = itemView.findViewById(R.id.textViewMessageUser); textViewMessage = itemView.findViewById(R.id.textViewMessageUser);
messageUser_Cite=itemView.findViewById(R.id.MessageUser_Cite);
} else { // 1 即机器人消息 } else { // 1 即机器人消息
textViewMessage = itemView.findViewById(R.id.textViewMessageBot); textViewMessage = itemView.findViewById(R.id.textViewMessageBot);
imageViewCopy = itemView.findViewById(R.id.imageViewCopy); imageViewCopy = itemView.findViewById(R.id.imageViewCopy);

View File

@ -7,6 +7,7 @@ public class ChatMessage_bmob extends BmobObject {
private Integer isuser; private Integer isuser;
private String relatedBook; private String relatedBook;
private String userid; private String userid;
private String cite;
public ChatMessage_bmob() { public ChatMessage_bmob() {
@ -44,10 +45,19 @@ public class ChatMessage_bmob extends BmobObject {
this.userid = userid; this.userid = userid;
} }
public ChatMessage_bmob(String content, Integer isuser, String relatedBook, String userid) { public ChatMessage_bmob(String content, Integer isuser, String relatedBook, String userid, String cite) {
this.content = content; this.content = content;
this.isuser = isuser; this.isuser = isuser;
this.relatedBook = relatedBook; this.relatedBook = relatedBook;
this.userid = userid; this.userid = userid;
this.cite = cite;
}
public String getCite() {
return cite;
}
public void setCite(String cite) {
this.cite = cite;
} }
} }

View File

@ -3,6 +3,7 @@ package com.bifan.txtreaderlib.bean;
public class Message { public class Message {
private String content; private String content;
private Integer isuser; private Integer isuser;
private String cite;
public String getContent() { public String getContent() {
return content; return content;
@ -20,8 +21,17 @@ public class Message {
this.isuser = isuser; this.isuser = isuser;
} }
public Message(String content, Integer isuser) { public Message(String content, Integer isuser, String cite) {
this.content = content; this.content = content;
this.isuser = isuser; this.isuser = isuser;
this.cite = cite;
}
public String getCite() {
return cite;
}
public void setCite(String cite) {
this.cite = cite;
} }
} }

View File

@ -6,13 +6,17 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.LongDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.NestedScrollView; import androidx.core.widget.NestedScrollView;
@ -52,24 +56,33 @@ import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
public class ChatWithGptActivity extends AppCompatActivity implements MessageAdapter.OnRegenerateClickListener { public class ChatWithGptActivity extends AppCompatActivity implements MessageAdapter.OnRegenerateClickListener {
private Boolean isStop=false;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private MessageAdapter messageAdapter; private MessageAdapter messageAdapter;
private EditText editTextMessage; private EditText editTextMessage;
private TextView chatbot_title; private TextView chatbot_title;
private ImageView buttonSend,chat_return; private ImageView buttonSend, chat_return;
private String bookName = ""; private String bookName = "";
private String userid = ""; private String userid = "";
private String cite = "";
private String lastUserQuestion = ""; // 全局变量来存储最后一条用户消息 private String lastUserQuestion = ""; // 全局变量来存储最后一条用户消息
private Call<ChatResponse> currentCall = null;
private ArrayList<Message> messageList = new ArrayList<>(); private ArrayList<Message> messageList = new ArrayList<>();
private TextView questionView1, questionView2, questionView3; private TextView questionView1, questionView2, questionView3, textView_Cite;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chatwithgpt); setContentView(R.layout.activity_chatwithgpt);
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754"); Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754");
if (getIntent() != null && getIntent().hasExtra("book_name")) { if (getIntent() != null) {
bookName = getIntent().getStringExtra("book_name"); if (getIntent().hasExtra("book_name")) {
bookName = getIntent().getStringExtra("book_name");
}
if (getIntent().hasExtra("cite")) {
cite = getIntent().getStringExtra("cite");
}
} }
SharedPreferences sharedPreferences = getSharedPreferences("userinf", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences("userinf", Context.MODE_PRIVATE);
String userIdFromPrefs = sharedPreferences.getString("user_id", ""); String userIdFromPrefs = sharedPreferences.getString("user_id", "");
@ -82,15 +95,25 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
} }
private void setupListeners() { private void setupListeners() {
buttonSend.setOnClickListener(v -> sendandStoreMessage(editTextMessage.getText().toString())); buttonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 检查是否存在活跃的请求,有的话再点击一次则取消本次请求
if (currentCall != null) {
isStop=true;
currentCall.cancel();
} else {
// 没有活跃的请求或请求已完成发送新的请求
String message = editTextMessage.getText().toString();
sendandStoreMessage(message); // 发送并存储消息的函数需要你自行实现
}
}
});
View.OnClickListener questionClickListener = view -> { View.OnClickListener questionClickListener = view -> {
TextView questionView = (TextView) view; TextView questionView = (TextView) view;
String message = questionView.getText().toString(); String message = questionView.getText().toString();
clearQuestionsVisibility();
sendandStoreMessage(message); sendandStoreMessage(message);
}; };
questionView1.setOnClickListener(questionClickListener); questionView1.setOnClickListener(questionClickListener);
questionView2.setOnClickListener(questionClickListener); questionView2.setOnClickListener(questionClickListener);
questionView3.setOnClickListener(questionClickListener); questionView3.setOnClickListener(questionClickListener);
@ -109,15 +132,25 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
} }
private void sendandStoreMessage(String text) { private void sendandStoreMessage(String text) {
messageList.add(new Message(text, 1)); // User message clearQuestionsVisibility();
messageList.add(new Message(text, 1, cite)); // User message
messageAdapter.notifyItemInserted(messageList.size() - 1); messageAdapter.notifyItemInserted(messageList.size() - 1);
editTextMessage.setText(""); editTextMessage.setText("");
sendMessageToChatGPT(text); sendMessageToChatGPT(text);
lastUserQuestion=text; storeMessage(text, 1);
storeMessage(text,1); hideKeyboard();
} }
private void storeMessage(String text,int isuser){ //隐藏软键盘
ChatMessage_bmob chatMessage_bmob = new ChatMessage_bmob(text, isuser, bookName, userid); private void hideKeyboard() {
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
View view = getCurrentFocus();
if (view != null) {
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
//存储到bmob
private void storeMessage(String text, int isuser) {
ChatMessage_bmob chatMessage_bmob = new ChatMessage_bmob(text, isuser, bookName, userid, cite);
chatMessage_bmob.save(new SaveListener<String>() { chatMessage_bmob.save(new SaveListener<String>() {
@Override @Override
public void done(String objectId, BmobException e) { public void done(String objectId, BmobException e) {
@ -138,11 +171,29 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
questionView1 = findViewById(R.id.question1); questionView1 = findViewById(R.id.question1);
questionView2 = findViewById(R.id.question2); questionView2 = findViewById(R.id.question2);
questionView3 = findViewById(R.id.question3); questionView3 = findViewById(R.id.question3);
chat_return=findViewById(R.id.chat_return); textView_Cite = findViewById(R.id.textView_Cite);
chat_return = findViewById(R.id.chat_return);
messageAdapter = new MessageAdapter(messageList, this); messageAdapter = new MessageAdapter(messageList, this);
messageAdapter.setOnRegenerateClickListener(this); messageAdapter.setOnRegenerateClickListener(this);
recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(messageAdapter); recyclerView.setAdapter(messageAdapter);
chatbot_title.setText(bookName);
editTextMessage.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// 根据输入框是否有文本来禁用或启用按钮
buttonSend.setEnabled(s.toString().trim().length() > 0);
}
@Override
public void afterTextChanged(Editable s) {
}
});
buttonSend.setEnabled(false);
} }
private void loadLastUserMessage() { private void loadLastUserMessage() {
@ -165,9 +216,13 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
} }
}); });
} }
//从数据库加载数据
private void init() { private void init() {
chatbot_title.setText(bookName); if (cite != "") {
cite = "引用:" + cite;
textView_Cite.setVisibility(View.VISIBLE);
textView_Cite.setText(cite);
}
BmobQuery<ChatMessage_bmob> bmobQuery = new BmobQuery<>(); BmobQuery<ChatMessage_bmob> bmobQuery = new BmobQuery<>();
bmobQuery.addWhereEqualTo("relatedBook", bookName); bmobQuery.addWhereEqualTo("relatedBook", bookName);
bmobQuery.addWhereEqualTo("userid", userid); bmobQuery.addWhereEqualTo("userid", userid);
@ -179,16 +234,16 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
for (ChatMessage_bmob item : messages) { for (ChatMessage_bmob item : messages) {
if (item.getContent() == null) { if (item.getContent() == null) {
String content = "出现未知错误!"; String content = "出现未知错误!";
messageList.add(new Message(content, item.getIsuser())); messageList.add(new Message(content, item.getIsuser(), ""));
} else { } else {
messageList.add(new Message(item.getContent(), item.getIsuser())); messageList.add(new Message(item.getContent(), item.getIsuser(), item.getCite()));
} }
} }
} else { } else {
// 如果没有消息添加一条 bot 的欢迎消息 // 如果没有消息添加一条 bot 的欢迎消息
String welcomeMessage = "你好!我是你的阅读助手。我可以帮助你解答关于书籍的各种问题,比如内容概述、作者信息、主要主题和角色分析等。请随时向我提问,现在,你有什么关于《" + bookName + "》的问题吗?"; String welcomeMessage = "你好!我是你的阅读助手。我可以帮助你解答关于书籍的各种问题,比如内容概述、作者信息、主要主题和角色分析等。请随时向我提问,现在,你有什么关于《" + bookName + "》的问题吗?";
messageList.add(new Message(welcomeMessage, 0)); // 假设 0 表示系统或助手消息 messageList.add(new Message(welcomeMessage, 0, "")); // 假设 0 表示系统或助手消息
ChatMessage_bmob chatMessage_bmob = new ChatMessage_bmob(welcomeMessage, 0, bookName, userid); ChatMessage_bmob chatMessage_bmob = new ChatMessage_bmob(welcomeMessage, 0, bookName, userid, "");
chatMessage_bmob.save(new SaveListener<String>() { chatMessage_bmob.save(new SaveListener<String>() {
@Override @Override
public void done(String objectId, BmobException e) { public void done(String objectId, BmobException e) {
@ -208,7 +263,7 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
} }
}); });
} }
//加载模拟用户评论
private void initgenerateUserQuestions() { private void initgenerateUserQuestions() {
BmobQuery<ChatMessage_bmob> bmobQuery = new BmobQuery<>(); BmobQuery<ChatMessage_bmob> bmobQuery = new BmobQuery<>();
bmobQuery.addWhereEqualTo("relatedBook", bookName); bmobQuery.addWhereEqualTo("relatedBook", bookName);
@ -289,7 +344,13 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
} }
private void sendMessageToChatGPT(String messageText) { private void sendMessageToChatGPT(String messageText) {
moveToNewest();
buttonSend.setImageResource(R.drawable.ic_loading); buttonSend.setImageResource(R.drawable.ic_loading);
if (cite != "") {
textView_Cite.setVisibility(View.GONE);
messageText = "请你根据《" + bookName + "》书中的这段内容:" + cite + ",回答我这个提问:" + messageText;
}
lastUserQuestion = messageText;
OkHttpClient client = new OkHttpClient.Builder() OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS) .connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS) .readTimeout(60, TimeUnit.SECONDS)
@ -302,7 +363,7 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
.build(); .build();
ChatGPTService service = retrofit.create(ChatGPTService.class); ChatGPTService service = retrofit.create(ChatGPTService.class);
List<ChatRequest.Message> messages = new ArrayList<>(); List<ChatRequest.Message> messages = new ArrayList<>();
String prompt = "你好!我是你的阅读助手。"; String prompt = "你好!我是你的阅读助手。请确保你的回答准确而精炼。";
if (messageText.equals("请告诉我更多内容。") && !lastUserQuestion.isEmpty()) { if (messageText.equals("请告诉我更多内容。") && !lastUserQuestion.isEmpty()) {
// 特别关注用户的上一个问题 // 特别关注用户的上一个问题
@ -317,69 +378,82 @@ public class ChatWithGptActivity extends AppCompatActivity implements MessageAda
messages.add(new ChatRequest.Message("system", prompt)); messages.add(new ChatRequest.Message("system", prompt));
messages.addAll(loadMessagesFromDatabase(bookName, userid)); messages.addAll(loadMessagesFromDatabase(bookName, userid));
messages.add(new ChatRequest.Message("user", messageText)); // 添加用户消息 messages.add(new ChatRequest.Message("user", messageText)); // 添加用户消息
Log.d("zytest", messageText);
ChatRequest request = new ChatRequest(messages); // 使用消息列表创建请求 ChatRequest request = new ChatRequest(messages); // 使用消息列表创建请求
request.setModel("gpt-4-turbo"); // 根据需要选择不同的模型 request.setModel("gpt-4-turbo"); // 根据需要选择不同的模型
request.setMaxTokens(50); // 设置最大 token 根据需要调整 request.setMaxTokens(50); // 设置最大 token 根据需要调整
request.setTemperature(0.5); // 设置适当的温度 request.setTemperature(0.5); // 设置适当的温度
service.postMessage(request).enqueue(new Callback<ChatResponse>() { currentCall = service.postMessage(request);
currentCall.enqueue(new Callback<ChatResponse>() {
@Override @Override
public void onResponse(Call<ChatResponse> call, Response<ChatResponse> response) { public void onResponse(Call<ChatResponse> call, Response<ChatResponse> response) {
if (response.isSuccessful() && response.body() != null) {
ChatResponse chatResponse = response.body(); if (response.isSuccessful() && response.body() != null) {
if (chatResponse.choices != null && !chatResponse.choices.isEmpty()) { ChatResponse chatResponse = response.body();
ChatResponse.Message message = chatResponse.choices.get(0).message; if (chatResponse.choices != null && !chatResponse.choices.isEmpty()) {
String reply = message.content; // 这是从 GPT-3.5 响应中提取的内容 ChatResponse.Message message = chatResponse.choices.get(0).message;
runOnUiThread(() -> { String reply = message.content; // 这是从 GPT-3.5 响应中提取的内容
messageList.add(new Message(reply, 0)); runOnUiThread(() -> {
messageAdapter.notifyDataSetChanged(); cite = "";
moveToNewest(); messageList.add(new Message(reply, 0, ""));
buttonSend.setImageResource(R.drawable.ic_send); messageAdapter.notifyDataSetChanged();
generateUserQuestions(reply); moveToNewest();
storeMessage(reply,0); buttonSend.setImageResource(R.drawable.ic_send);
}); generateUserQuestions(reply);
storeMessage(reply, 0);
});
}
currentCall = null; // 请求失败后清空引用
} else {
try {
String errorBody = response.errorBody() != null ? response.errorBody().string() : "Unknown error";
Log.e("ChatGPT", "Error: " + errorBody);
} catch (IOException e) {
Log.e("ChatGPT", "Error reading error body", e);
}
} }
} else {
try {
String errorBody = response.errorBody() != null ? response.errorBody().string() : "Unknown error";
Log.e("ChatGPT", "Error: " + errorBody);
} catch (IOException e) {
Log.e("ChatGPT", "Error reading error body", e);
}
}
} }
@Override @Override
public void onFailure(Call<ChatResponse> call, Throwable t) { public void onFailure(Call<ChatResponse> call, Throwable t) {
String content="机器人响应超时,请重新生成回答!"; if(isStop==true){
buttonSend.setImageResource(R.drawable.ic_send); buttonSend.setImageResource(R.drawable.ic_send);
messageList.add(new Message(content, 0)); isStop=false;
messageAdapter.notifyDataSetChanged(); }
moveToNewest(); else {
storeMessage(content,0); String content = "机器人响应超时,请重新生成回答!";
Log.e("ChatGPT", "Failure: " + t.getMessage()); buttonSend.setImageResource(R.drawable.ic_send);
messageList.add(new Message(content, 0, ""));
messageAdapter.notifyDataSetChanged();
moveToNewest();
currentCall = null; // 请求失败后清空引用
storeMessage(content, 0);
Log.e("ChatGPT", "Failure: " + t.getMessage());
}
} }
}); });
} }
//自动移动至最新回答 //自动移动至最新回答
private void moveToNewest(){ private void moveToNewest() {
NestedScrollView nestedScrollView = findViewById(R.id.nestedScrollView); NestedScrollView nestedScrollView = findViewById(R.id.nestedScrollView);
recyclerView.post(() -> { recyclerView.post(() -> {
// 确保最后一条消息可见 // 确保最后一条消息可见
if (messageList.size() > 0) { if (messageList.size() > 0) {
recyclerView.scrollToPosition(messageList.size() - 1); recyclerView.scrollToPosition(messageList.size() - 1);
recyclerView.post(() -> { recyclerView.post(() -> {
// 获取最后一个视图的引用 // 获取最后一个视图的引用
View lastChild = recyclerView.getChildAt(recyclerView.getChildCount() - 1); View lastChild = recyclerView.getChildAt(recyclerView.getChildCount() - 1);
int bottom = lastChild.getBottom() + recyclerView.getPaddingBottom(); int bottom = lastChild.getBottom() + recyclerView.getPaddingBottom();
int sy = nestedScrollView.getScrollY(); int sy = nestedScrollView.getScrollY();
int sh = nestedScrollView.getHeight(); int sh = nestedScrollView.getHeight();
int delta = bottom - (sy + sh); int delta = bottom - (sy + sh);
nestedScrollView.smoothScrollBy(0, delta); nestedScrollView.smoothScrollBy(0, delta);
}); });
} }
}); });
} }
//回调函数重新生成回答 //回调函数重新生成回答
@Override @Override
public void onRegenerateClick(int position) { public void onRegenerateClick(int position) {
@ -477,7 +551,7 @@ private void moveToNewest(){
// 提取问题 // 提取问题
private List<String> extractQuestions(ChatResponse response) { private List<String> extractQuestions(ChatResponse response) {
GenerateQue_bmob generateQue_bmob = new GenerateQue_bmob(); GenerateQue_bmob generateQue_bmob = new GenerateQue_bmob();
generateQue_bmob.setQues1("请告诉我更多"); generateQue_bmob.setQues1("请告诉我更多内容");
generateQue_bmob.setUserid(userid); generateQue_bmob.setUserid(userid);
generateQue_bmob.setRelatedBook(bookName); generateQue_bmob.setRelatedBook(bookName);
List<String> questions = new ArrayList<>(); List<String> questions = new ArrayList<>();

View File

@ -764,6 +764,13 @@ public class HwTxtPlayActivity extends AppCompatActivity {
mTxtReaderView.releaseSelectedState(); mTxtReaderView.releaseSelectedState();
Gone(ClipboardView); Gone(ClipboardView);
} }
public void onChatbot(View view){
String bookName = FileName.substring(0, FileName.lastIndexOf("."));
Intent intent = new Intent(HwTxtPlayActivity.this,ChatWithGptActivity.class);
intent.putExtra("book_name", bookName);
intent.putExtra("cite", CurrentSelectedText);
startActivity(intent);
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {

View File

@ -9,7 +9,7 @@
android:id="@+id/nestedScrollView" android:id="@+id/nestedScrollView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/inputEditText" app:layout_constraintBottom_toTopOf="@id/chatbot_bottom"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/chatbot_title"> app:layout_constraintTop_toBottomOf="@id/chatbot_title">
@ -82,6 +82,7 @@
android:id="@+id/chat_return" android:id="@+id/chat_return"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:padding="4dp"
android:src="@drawable/ic_return" android:src="@drawable/ic_return"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/chatbot_title" app:layout_constraintEnd_toStartOf="@id/chatbot_title"
@ -89,38 +90,63 @@
app:layout_constraintBottom_toBottomOf="@id/chatbot_title" /> app:layout_constraintBottom_toBottomOf="@id/chatbot_title" />
<!-- 标题栏 --> <!-- 标题栏 -->
<TextView <TextView
android:id="@+id/chatbot_title" android:id="@+id/chatbot_title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="6dp"
android:gravity="center"
android:text="书名" android:text="书名"
android:textSize="22sp" android:textSize="22sp"
android:gravity="center"
app:layout_constraintStart_toEndOf="@id/chat_return"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/chat_return"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<!-- 输入框 --> <LinearLayout
<EditText android:id="@+id/chatbot_bottom"
android:id="@+id/inputEditText" android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:orientation="vertical"
android:layout_marginRight="8dp" android:layout_marginBottom="8dp"
android:layout_marginBottom="16dp"
android:hint="输入消息..."
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/sendButton" /> app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- 输入框 -->
<EditText
android:id="@+id/inputEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="8dp"
android:hint="与阅读小助手交谈..." />
<ImageView
android:id="@+id/sendButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="16dp"
android:src="@drawable/ic_send"
android:layout_gravity="right|bottom" />
</LinearLayout>
<TextView
android:id="@+id/textView_Cite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="引用:"
android:textSize="14sp"
android:ellipsize="end"
android:maxLines="1"
android:visibility="gone"
android:layout_marginLeft="16dp"
android:layout_marginTop="6dp"
android:layout_marginRight="40dp" />
</LinearLayout>
<ImageView
android:id="@+id/sendButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"></ImageView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -109,30 +109,43 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/s_dp_10" android:layout_marginLeft="@dimen/s_dp_10"
android:paddingBottom="@dimen/s_dp_10" android:layout_marginStart="@dimen/s_dp_10"
android:paddingTop="@dimen/s_dp_10" android:paddingTop="@dimen/s_dp_10"
android:paddingBottom="@dimen/s_dp_10"
android:text="@string/selected_0_num_text" android:text="@string/selected_0_num_text"
android:textColor="@color/color_aaffffff" android:textColor="@color/color_aaffffff" />
android:layout_marginStart="@dimen/s_dp_10" />
<TextView <TextView
android:id="@+id/activity_hwTxtPlay_ClipBoar_click" android:id="@+id/activity_hwTxtPlay_ClipBoar_click"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/s_dp_5" android:layout_marginRight="@dimen/s_dp_5"
android:layout_marginEnd="@dimen/s_dp_5"
android:clickable="true" android:clickable="true"
android:onClick="onCopyText" android:onClick="onCopyText"
android:paddingBottom="@dimen/s_dp_10" android:focusable="true"
android:paddingTop="@dimen/s_dp_10" android:paddingTop="@dimen/s_dp_10"
android:paddingBottom="@dimen/s_dp_10"
android:text="@string/copy" android:text="@string/copy"
android:textColor="@color/color_withe" android:textColor="@color/color_withe" />
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/s_dp_5" <ImageView
android:focusable="true" /> android:id="@+id/chatbot_bottom"
android:layout_width="32dp"
android:layout_height="32dp"
android:onClick="onChatbot"
android:layout_marginRight="@dimen/s_dp_10"
android:layout_toLeftOf="@id/activity_hwTxtPlay_ClipBoar_click"
android:layout_toStartOf="@id/activity_hwTxtPlay_ClipBoar_click"
android:paddingTop="@dimen/s_dp_10"
android:src="@drawable/chatbot" />
</RelativeLayout> </RelativeLayout>
<View <View
android:id="@+id/activity_hwTxtPlay_cover" android:id="@+id/activity_hwTxtPlay_cover"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -2,10 +2,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical"
android:padding="8dp" android:padding="8dp"
android:layout_margin="8dp" android:layout_margin="8dp"
android:gravity="right"> android:gravity="right">
<TextView <TextView
android:id="@+id/textViewMessageUser" android:id="@+id/textViewMessageUser"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -14,4 +15,16 @@
android:padding="10dp" android:padding="10dp"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:text="User message here"/> android:text="User message here"/>
<TextView
android:id="@+id/MessageUser_Cite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="引用:"
android:textSize="14sp"
android:ellipsize="end"
android:visibility="gone"
android:maxLines="1"
android:layout_marginTop="6dp"
android:layout_marginLeft="25dp" />
</LinearLayout> </LinearLayout>