diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 922d70a..cb193e6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -50,6 +50,7 @@
+
diff --git a/app/src/main/java/com/zjgsu/jianshu/Activity/BookInformationActivity.kt b/app/src/main/java/com/zjgsu/jianshu/Activity/BookInformationActivity.kt
index 93f65d3..cb1c4d6 100644
--- a/app/src/main/java/com/zjgsu/jianshu/Activity/BookInformationActivity.kt
+++ b/app/src/main/java/com/zjgsu/jianshu/Activity/BookInformationActivity.kt
@@ -9,20 +9,27 @@ import cn.bmob.v3.exception.BmobException
import cn.bmob.v3.listener.FindListener
import cn.bmob.v3.listener.UpdateListener
import android.os.Bundle
+import android.view.View
+import android.widget.Button
+import android.widget.TextView
import android.widget.Toast
+import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import cn.bmob.v3.listener.SaveListener
import com.bumptech.glide.Glide
-import com.zjgsu.jianshu.Adapter.GoodsuibiAdapter
+import com.zjgsu.jianshu.Adapter.GoodperceptionAdapter
import com.zjgsu.jianshu.Bmob.BookShelf
import com.zjgsu.jianshu.Bmob.Book_info_bmob
import com.zjgsu.jianshu.Bmob.Perception_bmob
import kotlinx.android.synthetic.main.activity_book_info.*
+import kotlinx.android.synthetic.main.activity_sendspecific.*
import kotlinx.android.synthetic.main.bookinfo_title.*
class BookInformationActivity : AppCompatActivity() {
+ private lateinit var adapter: GoodperceptionAdapter
private val perceptionList = ArrayList()
private var isCommented = false
private lateinit var bookName: String
@@ -30,11 +37,16 @@ class BookInformationActivity : AppCompatActivity() {
private lateinit var userId:String
private lateinit var picurl:String
private var sourceActivityClass: Class<*>? = null
+ private lateinit var bookInfoTextView: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_book_info)
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
+ bookinfo_swipeRefresh.setOnRefreshListener {
+ loadBookInfo() //下拉刷新
+ }
bookName = intent.getStringExtra("Book_name") ?: ""
+ bookInfoTextView = findViewById(R.id.bookinfo_introduce)
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
sourceActivityClass = intent.getSerializableExtra("Source_Activity") as? Class<*>
loadPerceptions()
@@ -42,16 +54,18 @@ class BookInformationActivity : AppCompatActivity() {
loadBookInfo()
judgeInBookshelf()
setClickListeners()
+ judgeComment()
}
private fun loadPerceptions() {
val queryPerception = BmobQuery()
- queryPerception.addWhereEqualTo("b_name", bookName)
+ queryPerception.addWhereEqualTo("b_name", bookName) //查询指定书名的精彩点评
queryPerception.findObjects(object : FindListener() {
override fun done(list: List, e: BmobException?) {
if (e == null) {
+ bookinfo_swipeRefresh.isRefreshing = false
list.forEach { perceptionList.add(Perception(it.objectId)) }
- bookinfo_recyclerView.adapter?.notifyDataSetChanged()
+ adapter.notifyDataSetChanged()
} else {
Log.e("BookInfo", "Error loading perceptions: ${e.message}")
}
@@ -60,9 +74,10 @@ class BookInformationActivity : AppCompatActivity() {
}
private fun setupRecyclerView() {
- val layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.HORIZONTAL)
+ val layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
bookinfo_recyclerView.layoutManager = layoutManager
- bookinfo_recyclerView.adapter = GoodsuibiAdapter(perceptionList)
+ adapter=GoodperceptionAdapter(perceptionList)
+ bookinfo_recyclerView.adapter = adapter
}
private fun loadBookInfo() {
@@ -71,6 +86,7 @@ class BookInformationActivity : AppCompatActivity() {
queryBook.findObjects(object : FindListener() {
override fun done(books: MutableList?, e: BmobException?) {
if (e == null && books != null && books.isNotEmpty()) {
+ bookinfo_swipeRefresh.isRefreshing = false
val book = books[0]
loadBookCover(book.picture.url)
picurl=book.picture.url
@@ -87,9 +103,11 @@ class BookInformationActivity : AppCompatActivity() {
textView10.text = "简书推荐值 " + str + "%"
}
updateBookRankings(book)
- Book_name_View.text = book.name
- book_authorname.text = book.author_name
+ bookinfo_bookname.text = book.name
+ bookinfo_authorname.text = book.author_name
+ bookinfo_introduce.text=book.introduce
authorName = book.author_name
+ bookInfoTextView.text=book.introduce
} else {
Log.e("BookInfo", "Error loading book info: ${e?.message}")
}
@@ -105,13 +123,25 @@ class BookInformationActivity : AppCompatActivity() {
override fun done(bookshelfItems: MutableList?, e: BmobException?) {
if (e == null && bookshelfItems != null && bookshelfItems.isNotEmpty()) {
bookinfo_addBook.setImageResource(R.drawable.alreadyin)
+ bookinfo_mess.text="已加入"
}
}
})
}
+ private fun showBookIntroDialog(bookIntroContent: String) {
+ val builder = AlertDialog.Builder(this)
+ val dialogView = layoutInflater.inflate(R.layout.bookintro_dialog, null)
+ builder.setView(dialogView)
+ val dialog = builder.create()
+ dialogView.findViewById(R.id.book_intro_content)?.text = bookIntroContent
+ dialogView.findViewById