评论、点赞、收藏功能完善
This commit is contained in:
parent
30a466968e
commit
61fe13b37d
@ -46,8 +46,7 @@
|
|||||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||||
<!-- </intent-filter>-->
|
<!-- </intent-filter>-->
|
||||||
<!-- </activity>-->
|
<!-- </activity>-->
|
||||||
<activity android:name="edu.whut.jianshu.Activity.SendSpecificActivity" />
|
<activity android:name="edu.whut.jianshu.Activity.SendMarkingActivity" />
|
||||||
<activity android:name="edu.whut.jianshu.Activity.BookIntroActivity" />
|
|
||||||
<activity android:name="edu.whut.jianshu.Activity.MainActivity"
|
<activity android:name="edu.whut.jianshu.Activity.MainActivity"
|
||||||
android:configChanges="orientation|keyboard|keyboardHidden|navigation"
|
android:configChanges="orientation|keyboard|keyboardHidden|navigation"
|
||||||
/>
|
/>
|
||||||
|
@ -3,7 +3,6 @@ package edu.whut.jianshu.Activity
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
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
|
||||||
@ -19,12 +18,9 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
|||||||
import cn.bmob.v3.listener.SaveListener
|
import cn.bmob.v3.listener.SaveListener
|
||||||
import com.bifan.txtreaderlib.ui.HwTxtPlayActivity
|
import com.bifan.txtreaderlib.ui.HwTxtPlayActivity
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import edu.whut.jianshu.Adapter.GoodperceptionAdapter
|
import edu.whut.jianshu.Adapter.MarkingAdapter
|
||||||
import edu.whut.jianshu.Data.entity.BookShelf
|
import edu.whut.jianshu.Data.entity.*
|
||||||
import edu.whut.jianshu.Data.entity.Book_info_bmob
|
import edu.whut.jianshu.Data.vo.Marking
|
||||||
import edu.whut.jianshu.Data.entity.Bookcontent_bmob
|
|
||||||
import edu.whut.jianshu.Data.entity.Perception_bmob
|
|
||||||
import edu.whut.jianshu.Data.vo.Perception
|
|
||||||
import edu.whut.jianshu.R
|
import edu.whut.jianshu.R
|
||||||
import kotlinx.android.synthetic.main.activity_book_info.*
|
import kotlinx.android.synthetic.main.activity_book_info.*
|
||||||
import kotlinx.android.synthetic.main.bookinfo_title.*
|
import kotlinx.android.synthetic.main.bookinfo_title.*
|
||||||
@ -36,8 +32,8 @@ import java.io.InputStream
|
|||||||
|
|
||||||
|
|
||||||
class BookInformationActivity : AppCompatActivity() {
|
class BookInformationActivity : AppCompatActivity() {
|
||||||
private lateinit var adapter: GoodperceptionAdapter
|
private lateinit var adapter: MarkingAdapter
|
||||||
private val perceptionList = ArrayList<Perception>()
|
private val MarkingList = ArrayList<Marking>()
|
||||||
private var isCommented = false
|
private var isCommented = false
|
||||||
private lateinit var bookName: String
|
private lateinit var bookName: String
|
||||||
private lateinit var authorName: String
|
private lateinit var authorName: String
|
||||||
@ -56,23 +52,33 @@ class BookInformationActivity : AppCompatActivity() {
|
|||||||
bookInfoTextView = findViewById(R.id.bookinfo_introduce)
|
bookInfoTextView = findViewById(R.id.bookinfo_introduce)
|
||||||
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
||||||
sourceActivityClass = intent.getSerializableExtra("Source_Activity") as? Class<*>
|
sourceActivityClass = intent.getSerializableExtra("Source_Activity") as? Class<*>
|
||||||
loadPerceptions()
|
loadMarkings()
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
loadBookInfo()
|
loadBookInfo()
|
||||||
judgeInBookshelf()
|
judgeInBookshelf()
|
||||||
setClickListeners()
|
setClickListeners()
|
||||||
judgeComment()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadPerceptions() {
|
|
||||||
val queryPerception = BmobQuery<Perception_bmob>()
|
private fun loadMarkings() {
|
||||||
queryPerception.addWhereEqualTo("b_name", bookName) //查询指定书名的精彩点评
|
val queryMarking = BmobQuery<Marking_bmob>()
|
||||||
queryPerception.findObjects(object : FindListener<Perception_bmob>() {
|
queryMarking.addWhereEqualTo("bookname", bookName) //查询指定书名的精彩点评
|
||||||
override fun done(list: List<Perception_bmob>, e: BmobException?) {
|
queryMarking.findObjects(object : FindListener<Marking_bmob>() {
|
||||||
|
override fun done(list: List<Marking_bmob>, e: BmobException?) {
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
bookinfo_swipeRefresh.isRefreshing = false
|
bookinfo_swipeRefresh.isRefreshing = false
|
||||||
list.forEach { perceptionList.add(Perception(it.objectId)) }
|
list.forEach {
|
||||||
|
if (it.userid == userId) {
|
||||||
|
when (it.grade) {
|
||||||
|
1 -> b_henhao.setImageResource(R.drawable.recommend2)
|
||||||
|
2 -> b_yiban.setImageResource(R.drawable.normal2)
|
||||||
|
3 -> b_buxing.setImageResource(R.drawable.bad2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MarkingList.add(Marking(it.objectId, it.countOfLike, it.countOfCollect, it.userid, it.grade, it.evaluation))
|
||||||
|
}
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.e("BookInfo", "Error loading perceptions: ${e.message}")
|
Log.e("BookInfo", "Error loading perceptions: ${e.message}")
|
||||||
}
|
}
|
||||||
@ -83,7 +89,7 @@ class BookInformationActivity : AppCompatActivity() {
|
|||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
val layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
val layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||||
bookinfo_recyclerView.layoutManager = layoutManager
|
bookinfo_recyclerView.layoutManager = layoutManager
|
||||||
adapter=GoodperceptionAdapter(perceptionList)
|
adapter=MarkingAdapter(MarkingList)
|
||||||
bookinfo_recyclerView.adapter = adapter
|
bookinfo_recyclerView.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,12 +222,12 @@ class BookInformationActivity : AppCompatActivity() {
|
|||||||
private fun setCommentClickListeners() {
|
private fun setCommentClickListeners() {
|
||||||
if (!isCommented) {
|
if (!isCommented) {
|
||||||
val commentClickListener = View.OnClickListener {
|
val commentClickListener = View.OnClickListener {
|
||||||
val intent = Intent(this, SendSpecificActivity::class.java)
|
val intent = Intent(this, SendMarkingActivity::class.java)
|
||||||
intent.putExtra("bookname", bookName)
|
intent.putExtra("bookname", bookName)
|
||||||
when (it.id) {
|
when (it.id) {
|
||||||
R.id.b_henhao -> intent.putExtra("comment_rank", 1)
|
R.id.b_henhao -> intent.putExtra("evaluation_grade", 1)
|
||||||
R.id.b_yiban -> intent.putExtra("comment_rank", 2)
|
R.id.b_yiban -> intent.putExtra("evaluation_grade", 2)
|
||||||
R.id.b_buxing -> intent.putExtra("comment_rank", 3)
|
R.id.b_buxing -> intent.putExtra("evaluation_grade", 3)
|
||||||
}
|
}
|
||||||
ContextCompat.startActivity(this, intent, null)
|
ContextCompat.startActivity(this, intent, null)
|
||||||
}
|
}
|
||||||
@ -233,53 +239,6 @@ class BookInformationActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun updateBookComment(isRecommended: Boolean) {
|
|
||||||
// if (!isCommented) {
|
|
||||||
// isCommented = true
|
|
||||||
// val queryBook = BmobQuery<Book_info_bmob>()
|
|
||||||
// queryBook.addWhereEqualTo("name", bookName)
|
|
||||||
// queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
|
||||||
// override fun done(books: List<Book_info_bmob>, e: BmobException?) {
|
|
||||||
// if (e == null) {
|
|
||||||
// for (book in books) {
|
|
||||||
// updateBookRankings(book, isRecommended)
|
|
||||||
// b_henhao.setImageResource(R.drawable.recommend2)
|
|
||||||
// }
|
|
||||||
// Toast.makeText(this@BookInformationActivity, "评价成功!", Toast.LENGTH_LONG)
|
|
||||||
// .show()
|
|
||||||
// } else {
|
|
||||||
// Log.e("BookInfo", "Error updating book comment: ${e.message}")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
// Toast.makeText(this, "仅能评价一次!", Toast.LENGTH_SHORT).show()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private fun judgeComment(){
|
|
||||||
val query=BmobQuery<Perception_bmob>()
|
|
||||||
query.addWhereEqualTo("userid",userId)
|
|
||||||
query.addWhereEqualTo("b_name",bookName)
|
|
||||||
query.findObjects(object : FindListener<Perception_bmob>() {
|
|
||||||
override fun done(lists: List<Perception_bmob>, e: BmobException?) {
|
|
||||||
if (e == null) {
|
|
||||||
if(lists.isNotEmpty()) {
|
|
||||||
isCommented=true
|
|
||||||
val Myperception = lists[0]
|
|
||||||
if (Myperception.evaluation == 1)
|
|
||||||
b_henhao.setImageResource(R.drawable.recommend2)
|
|
||||||
else if (Myperception.evaluation == 2)
|
|
||||||
b_yiban.setImageResource(R.drawable.normal2)
|
|
||||||
else if (Myperception.evaluation == 3)
|
|
||||||
b_buxing.setImageResource(R.drawable.bad2)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d("error", "error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
private fun loadBookCover(coverUrl: String) {
|
private fun loadBookCover(coverUrl: String) {
|
||||||
Glide.with(this) // 传入 Context
|
Glide.with(this) // 传入 Context
|
||||||
.load(coverUrl) // 加载图片的 URL
|
.load(coverUrl) // 加载图片的 URL
|
||||||
|
@ -44,7 +44,8 @@ class MyPostActivity : AppCompatActivity() {
|
|||||||
if (e == null) {
|
if (e == null) {
|
||||||
for (item in list) {
|
for (item in list) {
|
||||||
if (item.userid == userId) {
|
if (item.userid == userId) {
|
||||||
perceptionList.add(Perception(item.objectId))
|
perceptionList.add(Perception(
|
||||||
|
item.objectId,item.b_name,item.countOfLike,item.countOfCollect,item.userid,item.perception))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
|
@ -40,7 +40,8 @@ class PerceptionActivity : AppCompatActivity() {
|
|||||||
if (e == null) {
|
if (e == null) {
|
||||||
perception_swipeRefresh.isRefreshing = false
|
perception_swipeRefresh.isRefreshing = false
|
||||||
for (i in list){
|
for (i in list){
|
||||||
PerceptionList.add(Perception(i.objectId))
|
PerceptionList.add(Perception(
|
||||||
|
i.objectId,i.b_name,i.countOfLike,i.countOfCollect,i.userid,i.perception))
|
||||||
val adapter =PerceptionAdapter(PerceptionList)
|
val adapter =PerceptionAdapter(PerceptionList)
|
||||||
perception_recyclerView.adapter = adapter
|
perception_recyclerView.adapter = adapter
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.graphics.Bitmap
|
|||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||||
@ -14,6 +15,8 @@ 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.SaveListener
|
import cn.bmob.v3.listener.SaveListener
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import edu.whut.jianshu.Adapter.BookAdapter
|
||||||
import edu.whut.jianshu.Adapter.CommentAdapter
|
import edu.whut.jianshu.Adapter.CommentAdapter
|
||||||
import edu.whut.jianshu.Data.entity.Book_info_bmob
|
import edu.whut.jianshu.Data.entity.Book_info_bmob
|
||||||
import edu.whut.jianshu.Data.entity.Comment_bmob
|
import edu.whut.jianshu.Data.entity.Comment_bmob
|
||||||
@ -27,7 +30,8 @@ import java.net.HttpURLConnection
|
|||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
class Perception_informationActivity:AppCompatActivity() {
|
class Perception_informationActivity:AppCompatActivity() {
|
||||||
private lateinit var perceptionid:String
|
private lateinit var adapter: CommentAdapter
|
||||||
|
private lateinit var perceptionId:String
|
||||||
private lateinit var bookName:String
|
private lateinit var bookName:String
|
||||||
private val commentlist=ArrayList<Comment>()
|
private val commentlist=ArrayList<Comment>()
|
||||||
lateinit var userId:String
|
lateinit var userId:String
|
||||||
@ -35,19 +39,21 @@ class Perception_informationActivity:AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_perception_infomation)
|
setContentView(R.layout.activity_perception_infomation)
|
||||||
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
||||||
perceptionid = intent.getStringExtra("PerceptionId").toString()
|
perceptionId = intent.getStringExtra("PerceptionId").toString()
|
||||||
Log.d("mytest",perceptionid)
|
|
||||||
inits()
|
inits()
|
||||||
|
adapter = CommentAdapter(commentlist)
|
||||||
|
comment_recyclerview.adapter = adapter
|
||||||
val layoutManager =
|
val layoutManager =
|
||||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||||
comment_recyclerview.layoutManager = layoutManager
|
comment_recyclerview.layoutManager = layoutManager
|
||||||
var adapter = CommentAdapter(commentlist)
|
|
||||||
comment_recyclerview.adapter = adapter
|
|
||||||
submitComment.setOnClickListener {
|
submitComment.setOnClickListener {
|
||||||
val comment= Comment_bmob()
|
val commentText = yourcomment.text.toString()
|
||||||
comment.text=yourcomment.text.toString()
|
if (commentText.isNotBlank()) {
|
||||||
comment.perceptionid=perceptionid
|
val comment = Comment_bmob().apply {
|
||||||
comment.comment_personid= userId
|
text = commentText
|
||||||
|
perceptionid = perceptionId
|
||||||
|
comment_personid = userId
|
||||||
|
}
|
||||||
comment.save(object : SaveListener<String>() {
|
comment.save(object : SaveListener<String>() {
|
||||||
override fun done(objectId: String?, e: BmobException?) {
|
override fun done(objectId: String?, e: BmobException?) {
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
@ -57,6 +63,13 @@ class Perception_informationActivity:AppCompatActivity() {
|
|||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
yourcomment.text = null
|
yourcomment.text = null
|
||||||
|
// 隐藏软键盘
|
||||||
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm.hideSoftInputFromWindow(yourcomment.windowToken, 0)
|
||||||
|
val newComment = Comment(objectId ?: "")
|
||||||
|
commentlist.add(newComment)
|
||||||
|
adapter.notifyItemInserted(commentlist.size - 1)
|
||||||
|
comment_recyclerview.scrollToPosition(commentlist.size - 1)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@Perception_informationActivity,
|
this@Perception_informationActivity,
|
||||||
@ -66,7 +79,15 @@ class Perception_informationActivity:AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
this@Perception_informationActivity,
|
||||||
|
"评论内容不能为空",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inf_bookInf.setOnClickListener{
|
inf_bookInf.setOnClickListener{
|
||||||
val intent = Intent(this, BookInformationActivity::class.java)
|
val intent = Intent(this, BookInformationActivity::class.java)
|
||||||
intent.putExtra("Book_name", bookName)
|
intent.putExtra("Book_name", bookName)
|
||||||
@ -75,125 +96,76 @@ class Perception_informationActivity:AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun inits(){
|
private fun inits(){
|
||||||
|
//加载随笔
|
||||||
val query = BmobQuery<Perception_bmob>()
|
val query = BmobQuery<Perception_bmob>()
|
||||||
query.addWhereEqualTo("objectId",perceptionid)
|
query.addWhereEqualTo("objectId", perceptionId)
|
||||||
//加载用户头像
|
|
||||||
query.findObjects(object : FindListener<Perception_bmob>() {
|
query.findObjects(object : FindListener<Perception_bmob>() {
|
||||||
override fun done(p0: MutableList<Perception_bmob>?, p1: BmobException?) {
|
override fun done(perceptionList: MutableList<Perception_bmob>?, perceptionException: BmobException?) {
|
||||||
if (p1 == null) {
|
if (perceptionException == null && perceptionList != null && perceptionList.isNotEmpty()) {
|
||||||
if (p0 != null && p0.size > 0) {
|
val perception = perceptionList.first()
|
||||||
for (p in p0) {
|
inf_textView_perception.text = perception.perception
|
||||||
//找发布用户
|
postTime.text = "发表于 " + perception.createdAt
|
||||||
inf_textView_perception.text=p.perception
|
|
||||||
postTime.text="发表于 "+p.createdAt
|
// 查找发布用户
|
||||||
val queryUser = BmobQuery<User_bmob>()
|
val queryUser = BmobQuery<User_bmob>()
|
||||||
|
queryUser.addWhereEqualTo("objectId", perception.userid)
|
||||||
queryUser.findObjects(object : FindListener<User_bmob>() {
|
queryUser.findObjects(object : FindListener<User_bmob>() {
|
||||||
override fun done(list: List<User_bmob>, e: BmobException?) {
|
override fun done(userList: List<User_bmob>, userException: BmobException?) {
|
||||||
if (e == null) {
|
if (userException == null && userList.isNotEmpty()) {
|
||||||
for (i in list) {
|
val user = userList.first()
|
||||||
if (p.userid.equals(i.objectId)) {
|
inf_postPersonName.text = user.nickName
|
||||||
inf_postPersonName.text=i.nickName
|
// 使用 Glide 加载图片
|
||||||
// flag = true //找到
|
Glide.with(inf_user_icon.context)
|
||||||
Log.d("myLog", "find sucessflly")
|
.load(user.face?.url)
|
||||||
//加载图片
|
.placeholder(R.drawable.pre_load) // 占位符图片
|
||||||
object : Thread() {
|
.error(R.drawable.pre_load) // 错误图片
|
||||||
override fun run() {
|
.into(inf_user_icon)
|
||||||
try {
|
|
||||||
val url = URL(i!!.face?.url)
|
|
||||||
val connection: HttpURLConnection =
|
|
||||||
url.openConnection() as HttpURLConnection
|
|
||||||
connection.setRequestMethod("GET")
|
|
||||||
connection.setConnectTimeout(3000)
|
|
||||||
val `in`: InputStream = connection.getInputStream()
|
|
||||||
val bitmap: Bitmap =
|
|
||||||
BitmapFactory.decodeStream(`in`)
|
|
||||||
inf_user_icon.setImageBitmap(bitmap)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("myLog", "error")
|
Log.d("myLog", "User query error: ${userException?.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
// 查找书籍信息
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//加载书籍封面
|
|
||||||
query.findObjects(object : FindListener<Perception_bmob>() {
|
|
||||||
override fun done(p0: MutableList<Perception_bmob>?, p1: BmobException?) {
|
|
||||||
if (p1 == null) {
|
|
||||||
if (p0 != null && p0.size > 0) {
|
|
||||||
for (p in p0) {
|
|
||||||
Log.d("myLog", p.b_name)
|
|
||||||
bookName = p.b_name
|
|
||||||
inf_bookName.text = bookName
|
|
||||||
val queryBook = BmobQuery<Book_info_bmob>()
|
val queryBook = BmobQuery<Book_info_bmob>()
|
||||||
|
queryBook.addWhereEqualTo("name", perception.b_name)
|
||||||
queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
||||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
override fun done(bookList: List<Book_info_bmob>, bookException: BmobException?) {
|
||||||
if (e == null) {
|
if (bookException == null && bookList.isNotEmpty()) {
|
||||||
for (i in list) {
|
val book = bookList.first()
|
||||||
if (p.b_name.equals(i.name)) {
|
inf_bookAuthor.text = book.author_name
|
||||||
inf_bookAuthor.text =
|
// 使用 Glide 加载书籍封面图片
|
||||||
i.author_name
|
Glide.with(inf_book_pic.context)
|
||||||
//加载图片
|
.load(book.picture?.url)
|
||||||
object : Thread() {
|
.placeholder(R.drawable.pre_load) // 占位符图片
|
||||||
override fun run() {
|
.error(R.drawable.pre_load) // 错误图片
|
||||||
try {
|
.into(inf_book_pic)
|
||||||
val url = URL(i!!.picture?.url)
|
|
||||||
val connection: HttpURLConnection =
|
|
||||||
url.openConnection() as HttpURLConnection
|
|
||||||
connection.setRequestMethod("GET")
|
|
||||||
connection.setConnectTimeout(3000)
|
|
||||||
val `in`: InputStream =
|
|
||||||
connection.getInputStream()
|
|
||||||
val bitmap: Bitmap =
|
|
||||||
BitmapFactory.decodeStream(`in`)
|
|
||||||
inf_book_pic.setImageBitmap(
|
|
||||||
bitmap
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("myLog", "error")
|
Log.d("myLog", "Book query error: ${bookException?.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
} else {
|
||||||
}
|
Log.d("myLog", "Perception query error: ${perceptionException?.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
val bmobquery=BmobQuery<Comment_bmob>()
|
// 加载评论
|
||||||
bmobquery.addWhereEqualTo("perceptionid",perceptionid)
|
commentlist.clear()
|
||||||
bmobquery.findObjects(object:FindListener<Comment_bmob>(){
|
val bmobQuery = BmobQuery<Comment_bmob>()
|
||||||
override fun done(list:List<Comment_bmob>,e:BmobException?){
|
bmobQuery.addWhereEqualTo("perceptionid", perceptionId)
|
||||||
if(e==null){
|
bmobQuery.findObjects(object : FindListener<Comment_bmob>() {
|
||||||
var cnt=0
|
override fun done(list: List<Comment_bmob>?, e: BmobException?) {
|
||||||
for(i in list){
|
if (e == null && list != null) {
|
||||||
cnt++
|
for (comment in list) {
|
||||||
commentlist.add(Comment(i.objectId))
|
commentlist.add(Comment(comment.objectId))
|
||||||
val adapter = CommentAdapter(commentlist)
|
|
||||||
comment_recyclerview.adapter = adapter
|
|
||||||
}
|
}
|
||||||
comment_cnt.text="评论 "+cnt.toString()
|
comment_cnt.text = "评论 ${commentlist.size}"
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
} else {
|
||||||
|
Log.d("myLog", "Error retrieving comments: ${e?.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,12 +14,14 @@ import cn.bmob.v3.listener.UpdateListener
|
|||||||
import edu.whut.jianshu.Data.entity.User_bmob
|
import edu.whut.jianshu.Data.entity.User_bmob
|
||||||
import edu.whut.jianshu.R
|
import edu.whut.jianshu.R
|
||||||
import kotlinx.android.synthetic.main.activity_editinfo.*
|
import kotlinx.android.synthetic.main.activity_editinfo.*
|
||||||
|
|
||||||
class ReAddressActivity : AppCompatActivity() {
|
class ReAddressActivity : AppCompatActivity() {
|
||||||
lateinit var userId: String
|
lateinit var userId: String
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_editinfo)
|
setContentView(R.layout.activity_editinfo)
|
||||||
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "")
|
||||||
|
.toString()
|
||||||
t_title.text = "修改地址"
|
t_title.text = "修改地址"
|
||||||
val extra_address = intent.getStringExtra("extra_address")
|
val extra_address = intent.getStringExtra("extra_address")
|
||||||
et_item.setHint(extra_address)
|
et_item.setHint(extra_address)
|
||||||
@ -42,8 +44,6 @@ class ReAddressActivity : AppCompatActivity() {
|
|||||||
for (i in list) {
|
for (i in list) {
|
||||||
if (user_account.equals(i.account)) {
|
if (user_account.equals(i.account)) {
|
||||||
flag = true //找到
|
flag = true //找到
|
||||||
Log.d("myLog", "find sucessflly")
|
|
||||||
//-------更新数据库中的sex
|
|
||||||
i.setaddress(curAddress)
|
i.setaddress(curAddress)
|
||||||
i.update(i.objectId, object : UpdateListener() {
|
i.update(i.objectId, object : UpdateListener() {
|
||||||
override fun done(p0: BmobException?) {
|
override fun done(p0: BmobException?) {
|
||||||
@ -55,7 +55,6 @@ class ReAddressActivity : AppCompatActivity() {
|
|||||||
).show()
|
).show()
|
||||||
//跳转个人信息页面,但是跳转之后原来的信息消失,需要重新进才能刷新
|
//跳转个人信息页面,但是跳转之后原来的信息消失,需要重新进才能刷新
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
// startActivityForResult(intent,1)
|
|
||||||
finish()
|
finish()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -63,8 +62,7 @@ class ReAddressActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@ReAddressActivity,
|
this@ReAddressActivity,
|
||||||
"请输入自己的账号!",
|
"请输入自己的账号!",
|
||||||
|
@ -8,70 +8,68 @@ import android.view.WindowManager
|
|||||||
import android.view.inputmethod.InputMethodManager
|
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.exception.BmobException
|
import cn.bmob.v3.exception.BmobException
|
||||||
import cn.bmob.v3.listener.SaveListener
|
import cn.bmob.v3.listener.SaveListener
|
||||||
import edu.whut.jianshu.Data.entity.Perception_bmob
|
import edu.whut.jianshu.Data.entity.Marking_bmob
|
||||||
import edu.whut.jianshu.R
|
import edu.whut.jianshu.R
|
||||||
import kotlinx.android.synthetic.main.activity_sendspecific.*
|
import kotlinx.android.synthetic.main.activity_book_info.*
|
||||||
|
import kotlinx.android.synthetic.main.activity_sendmarking.*
|
||||||
|
|
||||||
class SendSpecificActivity: AppCompatActivity() {
|
class SendMarkingActivity: AppCompatActivity() {
|
||||||
lateinit var userId:String
|
lateinit var userId:String
|
||||||
lateinit var bookname:String
|
lateinit var bookname:String
|
||||||
var comment_rank: Int? = null
|
var evaluation_grade: Int=0
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_sendspecific)
|
setContentView(R.layout.activity_sendmarking)
|
||||||
sendspecific_content.requestFocus()
|
sendmarking_content.requestFocus()
|
||||||
// 弹出软键盘
|
// 弹出软键盘
|
||||||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
imm.showSoftInput(sendspecific_content, InputMethodManager.SHOW_IMPLICIT)
|
imm.showSoftInput(sendmarking_content, InputMethodManager.SHOW_IMPLICIT)
|
||||||
// 防止自动弹出软键盘时页面被顶起
|
// 防止自动弹出软键盘时页面被顶起
|
||||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||||
comment_rank = intent.getIntExtra("comment_rank",0)
|
evaluation_grade = intent.getIntExtra("evaluation_grade",0)
|
||||||
bookname = intent.getStringExtra("bookname")?: ""
|
bookname = intent.getStringExtra("bookname")?: ""
|
||||||
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
userId = getSharedPreferences("userinf", Context.MODE_PRIVATE).getString("user_id", "").toString()
|
||||||
sendspecific_title.text="点评《"+bookname+"》"
|
sendmarking_title.text="点评《"+bookname+"》"
|
||||||
judgeComment()
|
judgeComment()
|
||||||
setClickListeners()
|
setClickListeners()
|
||||||
}
|
}
|
||||||
private fun judgeComment(){
|
private fun judgeComment(){
|
||||||
if(comment_rank==1)
|
when (evaluation_grade) {
|
||||||
sendspecific_henhao.setImageResource(R.drawable.recommend2)
|
1 -> sendmarking_henhao.setImageResource(R.drawable.recommend2)
|
||||||
else if(comment_rank==2)
|
2 -> sendmarking_yiban.setImageResource(R.drawable.normal2)
|
||||||
sendspecific_yiban.setImageResource(R.drawable.normal2)
|
3 -> sendmarking_buxing.setImageResource(R.drawable.bad2)
|
||||||
else if(comment_rank==3)
|
}
|
||||||
sendspecific_buxing.setImageResource(R.drawable.bad2)
|
|
||||||
}
|
}
|
||||||
private fun setClickListeners(){
|
private fun setClickListeners(){
|
||||||
sendspecific_cancel.setOnClickListener {
|
sendmarking_cancel.setOnClickListener {
|
||||||
val intent = Intent(this, BookInformationActivity::class.java)
|
val intent = Intent(this, BookInformationActivity::class.java)
|
||||||
intent.putExtra("Book_name", bookname)
|
intent.putExtra("Book_name", bookname)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
sendspecific_submit.setOnClickListener {
|
sendmarking_submit.setOnClickListener {
|
||||||
val perception= Perception_bmob()
|
val Marking= Marking_bmob()
|
||||||
perception.b_name=bookname
|
Marking.bookname=bookname
|
||||||
perception.userid=userId
|
Marking.userid=userId
|
||||||
perception.perception=sendspecific_content.text.toString()
|
Marking.evaluation=sendmarking_content.text.toString()
|
||||||
perception.evaluation= comment_rank!!
|
Marking.grade=evaluation_grade
|
||||||
perception.save(object : SaveListener<String>() {
|
Marking.save(object : SaveListener<String>() {
|
||||||
override fun done(objectId: String?, e: BmobException?) {
|
override fun done(objectId: String?, e: BmobException?) {
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
// 保存成功
|
// 保存成功
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@SendSpecificActivity,
|
this@SendMarkingActivity,
|
||||||
"点评成功!",
|
"点评成功!",
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
Log.d("sendspecific", "Perception_bmob saved successfully. objectId: $objectId")
|
val intent = Intent(this@SendMarkingActivity, BookInformationActivity::class.java)
|
||||||
val intent = Intent(this@SendSpecificActivity, BookInformationActivity::class.java)
|
|
||||||
intent.putExtra("Book_name", bookname)
|
intent.putExtra("Book_name", bookname)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
finish()
|
||||||
} else {
|
} else {
|
||||||
// 保存失败
|
// 保存失败
|
||||||
Log.e("sendspecific", "Failed to save Perception_bmob: ${e.message}")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -1,7 +1,5 @@
|
|||||||
package edu.whut.jianshu.Adapter
|
package edu.whut.jianshu.Adapter
|
||||||
|
|
||||||
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
|
||||||
@ -12,20 +10,20 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
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.bumptech.glide.Glide
|
||||||
import edu.whut.jianshu.Data.entity.Comment_bmob
|
import edu.whut.jianshu.Data.entity.Comment_bmob
|
||||||
import edu.whut.jianshu.Data.entity.User_bmob
|
import edu.whut.jianshu.Data.entity.User_bmob
|
||||||
import edu.whut.jianshu.Data.vo.Comment
|
import edu.whut.jianshu.Data.vo.Comment
|
||||||
import edu.whut.jianshu.R
|
import edu.whut.jianshu.R
|
||||||
import java.io.InputStream
|
|
||||||
import java.net.HttpURLConnection
|
|
||||||
import java.net.URL
|
|
||||||
|
|
||||||
class CommentAdapter(val commentlist: List<Comment>) :
|
class CommentAdapter(val commentList: List<Comment>) :
|
||||||
RecyclerView.Adapter<CommentAdapter.ViewHolder>() {
|
RecyclerView.Adapter<CommentAdapter.ViewHolder>() {
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
val user_icon: ImageView = view.findViewById(R.id.inf_comment_user_icon)
|
val userIcon: ImageView = view.findViewById(R.id.inf_comment_user_icon)
|
||||||
val user_name: TextView = view.findViewById(R.id.inf_comment_postPersonName)
|
val userName: TextView = view.findViewById(R.id.inf_comment_postPersonName)
|
||||||
val content: TextView = view.findViewById(R.id.inf_comment_textView_perception)
|
val content: TextView = view.findViewById(R.id.inf_comment_textView_perception)
|
||||||
|
val commentTime:TextView=view.findViewById(R.id.inf_comment_commentTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
@ -33,48 +31,40 @@ class CommentAdapter(val commentlist: List<Comment>) :
|
|||||||
return ViewHolder(view)
|
return ViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: CommentAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val comment = commentlist[position]
|
val comment = commentList[position]
|
||||||
val query = BmobQuery<Comment_bmob>()
|
val query = BmobQuery<Comment_bmob>()
|
||||||
query.addWhereEqualTo("objectId", comment.commentid)
|
query.addWhereEqualTo("objectId", comment.commentid)
|
||||||
query.findObjects(object : FindListener<Comment_bmob>() {
|
query.findObjects(object : FindListener<Comment_bmob>() {
|
||||||
override fun done(list: List<Comment_bmob>, e: BmobException?) {
|
override fun done(commentList: List<Comment_bmob>, e: BmobException?) {
|
||||||
if (e == null) {
|
if (e == null && commentList.isNotEmpty()) {
|
||||||
for (i in list) {
|
val commentBmob = commentList.first()
|
||||||
holder.content.text = i.text
|
holder.content.text = commentBmob.text
|
||||||
Log.d("zytt",i.text)
|
holder.commentTime.text=" "+commentBmob.createdAt
|
||||||
val query2 = BmobQuery<User_bmob>()
|
val queryUser = BmobQuery<User_bmob>()
|
||||||
query2.addWhereEqualTo("objectId",i.comment_personid)
|
queryUser.addWhereEqualTo("objectId", commentBmob.comment_personid)
|
||||||
query2.findObjects(object:FindListener<User_bmob>(){
|
queryUser.findObjects(object : FindListener<User_bmob>() {
|
||||||
override fun done(list:List<User_bmob>,e:BmobException?){
|
override fun done(userList: List<User_bmob>, e: BmobException?) {
|
||||||
if(e==null){
|
if (e == null && userList.isNotEmpty()) {
|
||||||
for(j in list){
|
val user = userList.first()
|
||||||
holder.user_name.text=j.nickName
|
holder.userName.text = user.nickName
|
||||||
object : Thread() {
|
// 使用 Glide 加载用户头像
|
||||||
override fun run() {
|
Glide.with(holder.userIcon.context)
|
||||||
try {
|
.load(user.face?.url)
|
||||||
val url = URL(j!!.face.url)
|
.placeholder(R.drawable.pre_load) // 占位符图片
|
||||||
val connection: HttpURLConnection =
|
.error(R.drawable.pre_load) // 错误图片
|
||||||
url.openConnection() as HttpURLConnection
|
.into(holder.userIcon)
|
||||||
connection.setRequestMethod("GET")
|
} else {
|
||||||
connection.setConnectTimeout(5000)
|
Log.d("myLog", "User query error: ${e?.message}")
|
||||||
val `in`: InputStream = connection.getInputStream()
|
|
||||||
val bitmap: Bitmap =
|
|
||||||
BitmapFactory.decodeStream(`in`)
|
|
||||||
holder.user_icon.setImageBitmap(bitmap)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start()
|
})
|
||||||
}
|
} else {
|
||||||
|
Log.d("myLog", "Comment query error: ${e?.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
override fun getItemCount() = commentList.size
|
||||||
})
|
|
||||||
}
|
|
||||||
override fun getItemCount() = commentlist.size
|
|
||||||
}
|
}
|
@ -1,70 +0,0 @@
|
|||||||
package edu.whut.jianshu.Adapter
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
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 edu.whut.jianshu.Data.entity.Perception_bmob
|
|
||||||
import edu.whut.jianshu.Data.entity.User_bmob
|
|
||||||
import edu.whut.jianshu.Data.vo.Perception
|
|
||||||
import edu.whut.jianshu.R
|
|
||||||
|
|
||||||
|
|
||||||
class GoodperceptionAdapter(val perceptionList: List<Perception>) : RecyclerView.Adapter<GoodperceptionAdapter.ViewHolder>() {
|
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|
||||||
val user_Image: ImageView = view.findViewById(R.id.goodperception_avatar)
|
|
||||||
val user_name: TextView = view.findViewById(R.id.user_Name)
|
|
||||||
val perception: TextView = view.findViewById(R.id.goodContent)
|
|
||||||
val evaluation_state:ImageView=view.findViewById(R.id.evaluation_state)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
|
||||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.goodperception_item, parent, false)
|
|
||||||
return ViewHolder(view)
|
|
||||||
}
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
|
||||||
val perception = perceptionList[position]
|
|
||||||
// 从 Perception_bmob 表中查找与 perception 对应的数据
|
|
||||||
BmobQuery<Perception_bmob>()
|
|
||||||
.addWhereEqualTo("objectId", perception.perceptionid)
|
|
||||||
.findObjects(object : FindListener<Perception_bmob>() {
|
|
||||||
override fun done(perceptionList: MutableList<Perception_bmob>?, exception: BmobException?) {
|
|
||||||
if (exception == null && perceptionList != null && perceptionList.isNotEmpty()) {
|
|
||||||
val perceptionData = perceptionList.first()
|
|
||||||
holder.perception.text = perceptionData.perception
|
|
||||||
if (perceptionData.evaluation == 1)
|
|
||||||
holder.evaluation_state.setImageResource(R.drawable.recommend1)
|
|
||||||
else if (perceptionData.evaluation == 2)
|
|
||||||
holder.evaluation_state.setImageResource(R.drawable.normal1)
|
|
||||||
else if (perceptionData.evaluation == 3)
|
|
||||||
holder.evaluation_state.setImageResource(R.drawable.bad1)
|
|
||||||
// 从 User_bmob 表中查找与 perceptionData.userid 对应的数据
|
|
||||||
BmobQuery<User_bmob>()
|
|
||||||
.addWhereEqualTo("objectId", perceptionData.userid)
|
|
||||||
.findObjects(object : FindListener<User_bmob>() {
|
|
||||||
override fun done(userList: MutableList<User_bmob>?, userException: BmobException?) {
|
|
||||||
if (userException == null && userList != null && userList.isNotEmpty()) {
|
|
||||||
val userData = userList.first()
|
|
||||||
holder.user_name.text = userData.nickName
|
|
||||||
Glide.with(holder.itemView.context)
|
|
||||||
.load(userData.face.url)
|
|
||||||
.placeholder(R.drawable.pre_load)
|
|
||||||
.error(R.drawable.fail_load)
|
|
||||||
.into(holder.user_Image)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
override fun getItemCount() =perceptionList.size
|
|
||||||
|
|
||||||
}
|
|
229
app/src/main/java/edu/whut/jianshu/Adapter/MarkingAdapter.kt
Normal file
229
app/src/main/java/edu/whut/jianshu/Adapter/MarkingAdapter.kt
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
package edu.whut.jianshu.Adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
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.QueryListener
|
||||||
|
import cn.bmob.v3.listener.SaveListener
|
||||||
|
import cn.bmob.v3.listener.UpdateListener
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import edu.whut.jianshu.Data.entity.*
|
||||||
|
import edu.whut.jianshu.Data.vo.Marking
|
||||||
|
import edu.whut.jianshu.R
|
||||||
|
|
||||||
|
|
||||||
|
class MarkingAdapter(val markingList: List<Marking>) :
|
||||||
|
RecyclerView.Adapter<MarkingAdapter.ViewHolder>() {
|
||||||
|
|
||||||
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
val user_Image: ImageView = view.findViewById(R.id.goodperception_avatar)
|
||||||
|
val user_name: TextView = view.findViewById(R.id.user_Name)
|
||||||
|
val evaluation: TextView = view.findViewById(R.id.goodContent)
|
||||||
|
val marking_likecnt:TextView=view.findViewById(R.id.marking_likecnt)
|
||||||
|
val marking_collectcnt:TextView=view.findViewById(R.id.marking_collectcnt)
|
||||||
|
val marking_grade: ImageView = view.findViewById(R.id.marking_grade)
|
||||||
|
val marking_like:ImageView=view.findViewById(R.id.marking_like)
|
||||||
|
val marking_collect:ImageView=view.findViewById(R.id.marking_collect)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
val view =
|
||||||
|
LayoutInflater.from(parent.context).inflate(R.layout.goodperception_item, parent, false)
|
||||||
|
return ViewHolder(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
val marking = markingList[position]
|
||||||
|
when (marking.grade) {
|
||||||
|
1 -> holder.marking_grade.setImageResource(R.drawable.recommend1)
|
||||||
|
2 -> holder.marking_grade.setImageResource(R.drawable.normal1)
|
||||||
|
3 -> holder.marking_grade.setImageResource(R.drawable.bad1)
|
||||||
|
}
|
||||||
|
holder.evaluation.text=marking.evaluation
|
||||||
|
holder.marking_collectcnt.text=marking.countOfCollect.toString()
|
||||||
|
holder.marking_likecnt.text=marking.countOfLike.toString()
|
||||||
|
BmobQuery<User_bmob>()
|
||||||
|
.addWhereEqualTo("objectId", marking.userid)
|
||||||
|
.findObjects(object : FindListener<User_bmob>() {
|
||||||
|
override fun done(
|
||||||
|
userList: MutableList<User_bmob>?,
|
||||||
|
userException: BmobException?
|
||||||
|
) {
|
||||||
|
if (userException == null && userList != null && userList.isNotEmpty()) {
|
||||||
|
val userData = userList.first()
|
||||||
|
holder.user_name.text = userData.nickName
|
||||||
|
Glide.with(holder.itemView.context)
|
||||||
|
.load(userData.face.url)
|
||||||
|
.placeholder(R.drawable.pre_load)
|
||||||
|
.error(R.drawable.fail_load)
|
||||||
|
.into(holder.user_Image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
updateIcon<Like_bmob>(
|
||||||
|
marking.userid, marking.markingid,
|
||||||
|
R.drawable.like2, R.drawable.like1
|
||||||
|
) { holder.marking_like.setImageResource(it) }
|
||||||
|
|
||||||
|
updateIcon<Collect_bmob>(
|
||||||
|
marking.userid, marking.markingid,
|
||||||
|
R.drawable.collect2, R.drawable.collect1
|
||||||
|
) { holder.marking_collect.setImageResource(it) }
|
||||||
|
holder.marking_like.setOnClickListener {
|
||||||
|
handleLikeAction(marking, holder)
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.marking_collect.setOnClickListener {
|
||||||
|
handleCollectAction(marking, holder)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 抽取的更新图标方法
|
||||||
|
private inline fun <reified T> updateIcon(
|
||||||
|
userId: String, articleId: String,
|
||||||
|
iconActive: Int, iconInactive: Int,
|
||||||
|
crossinline setIcon: (Int) -> Unit
|
||||||
|
) {
|
||||||
|
BmobQuery<T>()
|
||||||
|
.addWhereEqualTo("userid", userId)
|
||||||
|
.addWhereEqualTo("articleid", articleId)
|
||||||
|
.findObjects(object : FindListener<T>() {
|
||||||
|
override fun done(resultList: MutableList<T>?, userException: BmobException?) {
|
||||||
|
if (userException == null && resultList != null && resultList.isNotEmpty()) {
|
||||||
|
setIcon(iconActive)
|
||||||
|
} else {
|
||||||
|
setIcon(iconInactive)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun handleLikeAction(marking: Marking, holder: ViewHolder) {
|
||||||
|
val currentDrawable = holder.marking_like.drawable.constantState
|
||||||
|
val like1Drawable = ContextCompat.getDrawable(holder.marking_like.context, R.drawable.like1)?.constantState
|
||||||
|
val like2Drawable = ContextCompat.getDrawable(holder.marking_like.context, R.drawable.like2)?.constantState
|
||||||
|
|
||||||
|
if (currentDrawable == like1Drawable) {
|
||||||
|
holder.marking_like.setImageResource(R.drawable.like2)
|
||||||
|
updateLikeStatus(marking, holder, true)
|
||||||
|
} else if (currentDrawable == like2Drawable) {
|
||||||
|
holder.marking_like.setImageResource(R.drawable.like1)
|
||||||
|
updateLikeStatus(marking, holder, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleCollectAction(marking: Marking, holder: ViewHolder) {
|
||||||
|
val currentDrawable = holder.marking_collect.drawable.constantState
|
||||||
|
val collect1Drawable = ContextCompat.getDrawable(holder.marking_collect.context, R.drawable.collect1)?.constantState
|
||||||
|
val collect2Drawable = ContextCompat.getDrawable(holder.marking_collect.context, R.drawable.collect2)?.constantState
|
||||||
|
|
||||||
|
if (currentDrawable == collect1Drawable) {
|
||||||
|
holder.marking_collect.setImageResource(R.drawable.collect2)
|
||||||
|
updateCollectStatus(marking, holder, true)
|
||||||
|
} else if (currentDrawable == collect2Drawable) {
|
||||||
|
holder.marking_collect.setImageResource(R.drawable.collect1)
|
||||||
|
updateCollectStatus(marking, holder, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateLikeStatus(marking: Marking, holder: ViewHolder, isLiked: Boolean) {
|
||||||
|
if (isLiked) {
|
||||||
|
val like = Like_bmob().apply {
|
||||||
|
userid = marking.userid
|
||||||
|
articleid = marking.markingid
|
||||||
|
}
|
||||||
|
like.save(object : SaveListener<String>() {
|
||||||
|
override fun done(objectId: String?, e: BmobException?) {
|
||||||
|
if (e == null) updateMarkingLikeCount(marking, holder, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
val query = BmobQuery<Like_bmob>()
|
||||||
|
query.addWhereEqualTo("userid", marking.userid)
|
||||||
|
query.addWhereEqualTo("articleid", marking.markingid)
|
||||||
|
query.findObjects(object : FindListener<Like_bmob>() {
|
||||||
|
override fun done(items: MutableList<Like_bmob>?, e: BmobException?) {
|
||||||
|
if (e == null && items != null && items.isNotEmpty()) {
|
||||||
|
items.first().delete(object : UpdateListener() {
|
||||||
|
override fun done(ex: BmobException?) {
|
||||||
|
if (ex == null) updateMarkingLikeCount(marking, holder, false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateCollectStatus(marking: Marking, holder: ViewHolder, isCollected: Boolean) {
|
||||||
|
if (isCollected) {
|
||||||
|
val collect = Collect_bmob().apply {
|
||||||
|
userid = marking.userid
|
||||||
|
articleid = marking.markingid
|
||||||
|
}
|
||||||
|
collect.save(object : SaveListener<String>() {
|
||||||
|
override fun done(objectId: String?, e: BmobException?) {
|
||||||
|
if (e == null) updateMarkingCollectCount(marking, holder, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
val query = BmobQuery<Collect_bmob>()
|
||||||
|
query.addWhereEqualTo("userid", marking.userid)
|
||||||
|
query.addWhereEqualTo("articleid", marking.markingid)
|
||||||
|
query.findObjects(object : FindListener<Collect_bmob>() {
|
||||||
|
override fun done(items: MutableList<Collect_bmob>?, e: BmobException?) {
|
||||||
|
if (e == null && items != null && items.isNotEmpty()) {
|
||||||
|
items.first().delete(object : UpdateListener() {
|
||||||
|
override fun done(ex: BmobException?) {
|
||||||
|
if (ex == null) updateMarkingCollectCount(marking, holder, false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateMarkingLikeCount(marking: Marking, holder: ViewHolder, increment: Boolean) {
|
||||||
|
val bmobQuery = BmobQuery<Marking_bmob>()
|
||||||
|
bmobQuery.getObject(marking.markingid, object : QueryListener<Marking_bmob>() {
|
||||||
|
override fun done(theMarking: Marking_bmob?, ex: BmobException?) {
|
||||||
|
if (ex == null && theMarking != null) {
|
||||||
|
theMarking.countOfLike = if (increment) theMarking.countOfLike + 1 else theMarking.countOfLike - 1
|
||||||
|
holder.marking_likecnt.text = theMarking.countOfLike.toString()
|
||||||
|
theMarking.update(marking.markingid, object : UpdateListener() {
|
||||||
|
override fun done(p0: BmobException?) {
|
||||||
|
// 处理更新结果
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateMarkingCollectCount(marking: Marking, holder: ViewHolder, increment: Boolean) {
|
||||||
|
val bmobQuery = BmobQuery<Marking_bmob>()
|
||||||
|
bmobQuery.getObject(marking.markingid, object : QueryListener<Marking_bmob>() {
|
||||||
|
override fun done(theMarking: Marking_bmob?, ex: BmobException?) {
|
||||||
|
if (ex == null && theMarking != null) {
|
||||||
|
theMarking.countOfCollect = if (increment) theMarking.countOfCollect + 1 else theMarking.countOfCollect - 1
|
||||||
|
holder.marking_collectcnt.text = theMarking.countOfCollect.toString()
|
||||||
|
theMarking.update(marking.markingid, object : UpdateListener() {
|
||||||
|
override fun done(p0: BmobException?) {
|
||||||
|
// 处理更新结果
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = markingList.size
|
||||||
|
|
||||||
|
}
|
@ -12,12 +12,14 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
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.QueryListener
|
||||||
|
import cn.bmob.v3.listener.SaveListener
|
||||||
|
import cn.bmob.v3.listener.UpdateListener
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import edu.whut.jianshu.Activity.BookInformationActivity
|
import edu.whut.jianshu.Activity.BookInformationActivity
|
||||||
import edu.whut.jianshu.Activity.Perception_informationActivity
|
import edu.whut.jianshu.Activity.Perception_informationActivity
|
||||||
import edu.whut.jianshu.Data.entity.Book_info_bmob
|
import edu.whut.jianshu.Data.entity.*
|
||||||
import edu.whut.jianshu.Data.entity.Perception_bmob
|
import edu.whut.jianshu.Data.vo.Marking
|
||||||
import edu.whut.jianshu.Data.entity.User_bmob
|
|
||||||
import edu.whut.jianshu.Data.vo.Perception
|
import edu.whut.jianshu.Data.vo.Perception
|
||||||
import edu.whut.jianshu.R
|
import edu.whut.jianshu.R
|
||||||
|
|
||||||
@ -26,18 +28,22 @@ class PerceptionAdapter(val perceptionList: List<Perception>) :
|
|||||||
RecyclerView.Adapter<PerceptionAdapter.ViewHolder>() {
|
RecyclerView.Adapter<PerceptionAdapter.ViewHolder>() {
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
val perception_perception: TextView = view.findViewById(R.id.perception_content)
|
//随笔相关
|
||||||
|
val perception_content: TextView = view.findViewById(R.id.perception_content)
|
||||||
|
val perception_likecnt:TextView=view.findViewById(R.id.perception_likecnt)
|
||||||
|
val perception_collectcnt:TextView=view.findViewById(R.id.perception_collectcnt)
|
||||||
|
val perception_like:ImageView=view.findViewById(R.id.perception_likeicon)
|
||||||
|
val perception_collect:ImageView=view.findViewById(R.id.perception_collecticon)
|
||||||
|
|
||||||
//用户头像
|
//用户头像
|
||||||
val perception_userIcon: ImageView = view.findViewById(R.id.perception_avatar)
|
val perception_userIcon: ImageView = view.findViewById(R.id.perception_avatar)
|
||||||
val perception_posetPerson: TextView = view.findViewById(R.id.perception_username)
|
val perception_username: TextView = view.findViewById(R.id.perception_username)
|
||||||
|
|
||||||
//书籍封面
|
//书籍封面
|
||||||
val perception_bookPic: ImageView = view.findViewById(R.id.perception_bookpic)
|
val perception_bookPic: ImageView = view.findViewById(R.id.perception_bookpic)
|
||||||
val perception_bookName: TextView = view.findViewById(R.id.perception_bookName)
|
val perception_bookName: TextView = view.findViewById(R.id.perception_bookName)
|
||||||
val perception_bookAuthor: TextView = view.findViewById(R.id.perception_bookAuthor)
|
val perception_bookAuthor: TextView = view.findViewById(R.id.perception_bookAuthor)
|
||||||
val perception_bookInf: View = view.findViewById(R.id.perception_bookInf)
|
val perception_bookInf: View = view.findViewById(R.id.perception_bookInf)
|
||||||
lateinit var perceptionid: String
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
@ -47,48 +53,35 @@ class PerceptionAdapter(val perceptionList: List<Perception>) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
var bookName: String = ""
|
|
||||||
val perception = perceptionList[position]
|
val perception = perceptionList[position]
|
||||||
//设置text
|
holder.perception_content.text=perception.perception
|
||||||
holder.perceptionid = perception.perceptionid
|
holder.perception_collectcnt.text=perception.countOfCollect.toString()
|
||||||
val query = BmobQuery<Perception_bmob>()
|
holder.perception_likecnt.text=perception.countOfLike.toString()
|
||||||
query.addWhereEqualTo("objectId", perception.perceptionid)
|
BmobQuery<User_bmob>()
|
||||||
//加载用户头像
|
.addWhereEqualTo("objectId", perception.userid)
|
||||||
query.findObjects(object : FindListener<Perception_bmob>() {
|
.findObjects(object : FindListener<User_bmob>() {
|
||||||
override fun done(p0: MutableList<Perception_bmob>?, p1: BmobException?) {
|
override fun done(
|
||||||
if (p1 == null) {
|
userList: MutableList<User_bmob>?,
|
||||||
if (p0 != null && p0.size > 0) {
|
userException: BmobException?
|
||||||
for (p in p0) {
|
) {
|
||||||
bookName = p.b_name
|
if (userException == null && userList != null && userList.isNotEmpty()) {
|
||||||
//找发布用户
|
val userData = userList.first()
|
||||||
holder.perception_perception.text = p.perception
|
holder.perception_username.text = userData.nickName
|
||||||
val queryUser = BmobQuery<User_bmob>()
|
|
||||||
queryUser.findObjects(object : FindListener<User_bmob>() {
|
|
||||||
override fun done(list: List<User_bmob>, e: BmobException?) {
|
|
||||||
if (e == null) {
|
|
||||||
for (i in list) {
|
|
||||||
if (p.userid.equals(i.objectId)) {
|
|
||||||
holder.perception_posetPerson.text = i.nickName
|
|
||||||
//加载图片
|
|
||||||
Glide.with(holder.itemView.context)
|
Glide.with(holder.itemView.context)
|
||||||
.load(i.face.url) // 确保你的Book对象有正确的图片URL
|
.load(userData.face.url)
|
||||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
.placeholder(R.drawable.pre_load)
|
||||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
.error(R.drawable.fail_load)
|
||||||
.into(holder.perception_userIcon)
|
.into(holder.perception_userIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Log.d("perception", "error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
val queryBook = BmobQuery<Book_info_bmob>()
|
val queryBook = BmobQuery<Book_info_bmob>()
|
||||||
queryBook.addWhereEqualTo("name", bookName)
|
queryBook.addWhereEqualTo("name", perception.bookname)
|
||||||
queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
||||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
for (i in list) {
|
for (i in list) {
|
||||||
holder.perception_bookName.text=bookName
|
holder.perception_bookName.text = perception.bookname
|
||||||
holder.perception_bookAuthor.text = i.author_name
|
holder.perception_bookAuthor.text = i.author_name
|
||||||
Glide.with(holder.itemView.context)
|
Glide.with(holder.itemView.context)
|
||||||
.load(i.picture.url) // 确保你的Book对象有正确的图片URL
|
.load(i.picture.url) // 确保你的Book对象有正确的图片URL
|
||||||
@ -101,24 +94,171 @@ class PerceptionAdapter(val perceptionList: List<Perception>) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
updateIcon<Like_bmob>(
|
||||||
|
perception.userid, perception.perceptionid,
|
||||||
|
R.drawable.like2, R.drawable.like1
|
||||||
|
) { holder.perception_like.setImageResource(it) }
|
||||||
|
|
||||||
|
updateIcon<Collect_bmob>(
|
||||||
|
perception.userid, perception.perceptionid,
|
||||||
|
R.drawable.collect2, R.drawable.collect1
|
||||||
|
) { holder.perception_collect.setImageResource(it) }
|
||||||
|
holder.perception_like.setOnClickListener {
|
||||||
|
handleLikeAction(perception, holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holder.perception_collect.setOnClickListener {
|
||||||
|
handleCollectAction(perception, holder)
|
||||||
}
|
}
|
||||||
|
holder.perception_bookInf.setOnClickListener() {
|
||||||
|
val intent = Intent(holder.itemView.context, BookInformationActivity::class.java)
|
||||||
|
intent.putExtra("Book_name", perception.bookname)
|
||||||
|
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||||
|
}
|
||||||
|
holder.perception_content.setOnClickListener {
|
||||||
|
val intent = Intent(holder.itemView.context, Perception_informationActivity::class.java)
|
||||||
|
intent.putExtra("PerceptionId", perception.perceptionid)
|
||||||
|
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 抽取的更新图标方法
|
||||||
|
private inline fun <reified T> updateIcon(
|
||||||
|
userId: String, articleId: String,
|
||||||
|
iconActive: Int, iconInactive: Int,
|
||||||
|
crossinline setIcon: (Int) -> Unit
|
||||||
|
) {
|
||||||
|
BmobQuery<T>()
|
||||||
|
.addWhereEqualTo("userid", userId)
|
||||||
|
.addWhereEqualTo("articleid", articleId)
|
||||||
|
.findObjects(object : FindListener<T>() {
|
||||||
|
override fun done(resultList: MutableList<T>?, userException: BmobException?) {
|
||||||
|
if (userException == null && resultList != null && resultList.isNotEmpty()) {
|
||||||
|
setIcon(iconActive)
|
||||||
|
} else {
|
||||||
|
setIcon(iconInactive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
holder.perception_bookInf.setOnClickListener() {
|
|
||||||
val intent = Intent(holder.itemView.context, BookInformationActivity::class.java)
|
|
||||||
intent.putExtra("Book_name", bookName)
|
|
||||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
|
||||||
}
|
}
|
||||||
holder.perception_perception.setOnClickListener {
|
private fun handleLikeAction(perception: Perception, holder: PerceptionAdapter.ViewHolder) {
|
||||||
val intent = Intent(holder.itemView.context, Perception_informationActivity::class.java)
|
val currentDrawable = holder.perception_like.drawable.constantState
|
||||||
intent.putExtra("PerceptionId", holder.perceptionid)
|
val like1Drawable = ContextCompat.getDrawable(holder.perception_like.context, R.drawable.like1)?.constantState
|
||||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
val like2Drawable = ContextCompat.getDrawable(holder.perception_like.context, R.drawable.like2)?.constantState
|
||||||
|
|
||||||
|
if (currentDrawable == like1Drawable) {
|
||||||
|
holder.perception_like.setImageResource(R.drawable.like2)
|
||||||
|
updateLikeStatus(perception, holder, true)
|
||||||
|
} else if (currentDrawable == like2Drawable) {
|
||||||
|
holder.perception_like.setImageResource(R.drawable.like1)
|
||||||
|
updateLikeStatus(perception, holder, false)
|
||||||
}
|
}
|
||||||
//给评论图标设置点击事件
|
}
|
||||||
//给评论图标设置点击事件
|
|
||||||
// holder.comment.setOnClickListener(View.OnClickListener { showPopupcomment() })
|
private fun handleCollectAction(perception: Perception, holder: PerceptionAdapter.ViewHolder) {
|
||||||
|
val currentDrawable = holder.perception_collect.drawable.constantState
|
||||||
|
val collect1Drawable = ContextCompat.getDrawable(holder.perception_collect.context, R.drawable.collect1)?.constantState
|
||||||
|
val collect2Drawable = ContextCompat.getDrawable(holder.perception_collect.context, R.drawable.collect2)?.constantState
|
||||||
|
|
||||||
|
if (currentDrawable == collect1Drawable) {
|
||||||
|
holder.perception_collect.setImageResource(R.drawable.collect2)
|
||||||
|
updateCollectStatus(perception, holder, true)
|
||||||
|
} else if (currentDrawable == collect2Drawable) {
|
||||||
|
holder.perception_collect.setImageResource(R.drawable.collect1)
|
||||||
|
updateCollectStatus(perception, holder, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateLikeStatus(perception: Perception, holder: PerceptionAdapter.ViewHolder, isLiked: Boolean) {
|
||||||
|
if (isLiked) {
|
||||||
|
val like = Like_bmob().apply {
|
||||||
|
userid = perception.userid
|
||||||
|
articleid = perception.perceptionid
|
||||||
|
}
|
||||||
|
like.save(object : SaveListener<String>() {
|
||||||
|
override fun done(objectId: String?, e: BmobException?) {
|
||||||
|
if (e == null) updatePerceptionLikeCount(perception, holder, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
val query = BmobQuery<Like_bmob>()
|
||||||
|
query.addWhereEqualTo("userid", perception.userid)
|
||||||
|
query.addWhereEqualTo("articleid", perception.perceptionid)
|
||||||
|
query.findObjects(object : FindListener<Like_bmob>() {
|
||||||
|
override fun done(items: MutableList<Like_bmob>?, e: BmobException?) {
|
||||||
|
if (e == null && items != null && items.isNotEmpty()) {
|
||||||
|
items.first().delete(object : UpdateListener() {
|
||||||
|
override fun done(ex: BmobException?) {
|
||||||
|
if (ex == null) updatePerceptionLikeCount(perception, holder, false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateCollectStatus(perception: Perception, holder: PerceptionAdapter.ViewHolder, isCollected: Boolean) {
|
||||||
|
if (isCollected) {
|
||||||
|
val collect = Collect_bmob().apply {
|
||||||
|
userid = perception.userid
|
||||||
|
articleid = perception.perceptionid
|
||||||
|
}
|
||||||
|
collect.save(object : SaveListener<String>() {
|
||||||
|
override fun done(objectId: String?, e: BmobException?) {
|
||||||
|
if (e == null) updatePerceptionCollectCount(perception, holder, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
val query = BmobQuery<Collect_bmob>()
|
||||||
|
query.addWhereEqualTo("userid", perception.userid)
|
||||||
|
query.addWhereEqualTo("articleid", perception.perceptionid)
|
||||||
|
query.findObjects(object : FindListener<Collect_bmob>() {
|
||||||
|
override fun done(items: MutableList<Collect_bmob>?, e: BmobException?) {
|
||||||
|
if (e == null && items != null && items.isNotEmpty()) {
|
||||||
|
items.first().delete(object : UpdateListener() {
|
||||||
|
override fun done(ex: BmobException?) {
|
||||||
|
if (ex == null) updatePerceptionCollectCount(perception, holder, false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePerceptionLikeCount(perception: Perception, holder: PerceptionAdapter.ViewHolder, increment: Boolean) {
|
||||||
|
val bmobQuery = BmobQuery<Perception_bmob>()
|
||||||
|
bmobQuery.getObject(perception.perceptionid, object : QueryListener<Perception_bmob>() {
|
||||||
|
override fun done(thePerception: Perception_bmob?, ex: BmobException?) {
|
||||||
|
if (ex == null && thePerception != null) {
|
||||||
|
thePerception.countOfLike = if (increment) thePerception.countOfLike + 1 else thePerception.countOfLike - 1
|
||||||
|
holder.perception_likecnt.text = thePerception.countOfLike.toString()
|
||||||
|
thePerception.update(perception.perceptionid, object : UpdateListener() {
|
||||||
|
override fun done(p0: BmobException?) {
|
||||||
|
// 处理更新结果
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePerceptionCollectCount(perception: Perception, holder: PerceptionAdapter.ViewHolder, increment: Boolean) {
|
||||||
|
val bmobQuery = BmobQuery<Perception_bmob>()
|
||||||
|
bmobQuery.getObject(perception.perceptionid, object : QueryListener<Perception_bmob>() {
|
||||||
|
override fun done(thePerception: Perception_bmob?, ex: BmobException?) {
|
||||||
|
if (ex == null && thePerception != null) {
|
||||||
|
thePerception.countOfCollect = if (increment) thePerception.countOfCollect + 1 else thePerception.countOfCollect - 1
|
||||||
|
holder.perception_collectcnt.text = thePerception.countOfCollect.toString()
|
||||||
|
thePerception.update(perception.perceptionid, object : UpdateListener() {
|
||||||
|
override fun done(p0: BmobException?) {
|
||||||
|
// 处理更新结果
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = perceptionList.size
|
override fun getItemCount() = perceptionList.size
|
||||||
|
@ -12,14 +12,4 @@ class Book_info_bmob:BmobObject(){
|
|||||||
var tuijian:Int=0
|
var tuijian:Int=0
|
||||||
var buxing:Int=0
|
var buxing:Int=0
|
||||||
var countOfReaders:Int=0
|
var countOfReaders:Int=0
|
||||||
fun settuijian(tuijian1: Int){
|
|
||||||
this.tuijian=tuijian1
|
|
||||||
}
|
|
||||||
fun setyiban(yiban1: Int){
|
|
||||||
this.yiban=yiban1
|
|
||||||
}
|
|
||||||
fun setbuxing(buxing1: Int){
|
|
||||||
this.buxing=buxing1
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package edu.whut.jianshu.Data.entity
|
||||||
|
|
||||||
|
import cn.bmob.v3.BmobObject
|
||||||
|
|
||||||
|
class Collect_bmob:BmobObject() {
|
||||||
|
var userid:String=""
|
||||||
|
var articleid:String=""
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package edu.whut.jianshu.Data.entity
|
||||||
|
|
||||||
|
import cn.bmob.v3.BmobObject
|
||||||
|
|
||||||
|
class Like_bmob:BmobObject() {
|
||||||
|
var userid:String=""
|
||||||
|
var articleid:String=""
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package edu.whut.jianshu.Data.entity
|
||||||
|
|
||||||
|
import cn.bmob.v3.BmobObject
|
||||||
|
|
||||||
|
class Marking_bmob:BmobObject() {
|
||||||
|
var evaluation: String = ""
|
||||||
|
var bookname: String = ""
|
||||||
|
var userid: String = ""
|
||||||
|
var grade:Int=0 //1->推荐 2->一般 3->不行
|
||||||
|
var countOfLike:Int=0
|
||||||
|
var countOfCollect:Int=0
|
||||||
|
}
|
@ -4,7 +4,8 @@ import cn.bmob.v3.BmobObject
|
|||||||
class Perception_bmob:BmobObject() {
|
class Perception_bmob:BmobObject() {
|
||||||
var perception: String = ""
|
var perception: String = ""
|
||||||
var b_name: String = ""
|
var b_name: String = ""
|
||||||
var post_person: String = ""
|
|
||||||
var userid: String = ""
|
var userid: String = ""
|
||||||
var evaluation:Int=0
|
var countOfLike:Int=0
|
||||||
|
var countOfCollect:Int=0
|
||||||
|
var countOfComment:Int=0
|
||||||
}
|
}
|
10
app/src/main/java/edu/whut/jianshu/Data/vo/Marking.kt
Normal file
10
app/src/main/java/edu/whut/jianshu/Data/vo/Marking.kt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package edu.whut.jianshu.Data.vo
|
||||||
|
|
||||||
|
class Marking (
|
||||||
|
var markingid:String,
|
||||||
|
var countOfLike:Int,
|
||||||
|
var countOfCollect:Int,
|
||||||
|
var userid:String,
|
||||||
|
var grade:Int,
|
||||||
|
var evaluation:String
|
||||||
|
)
|
@ -1,3 +1,10 @@
|
|||||||
package edu.whut.jianshu.Data.vo
|
package edu.whut.jianshu.Data.vo
|
||||||
|
|
||||||
class Perception(val perceptionid:String)
|
class Perception(
|
||||||
|
var perceptionid:String,
|
||||||
|
var bookname:String,
|
||||||
|
var countOfLike:Int,
|
||||||
|
var countOfCollect:Int,
|
||||||
|
var userid:String,
|
||||||
|
var perception:String
|
||||||
|
)
|
BIN
app/src/main/res/drawable/collect1.png
Normal file
BIN
app/src/main/res/drawable/collect1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 848 B |
BIN
app/src/main/res/drawable/collect2.png
Normal file
BIN
app/src/main/res/drawable/collect2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 728 B |
4
app/src/main/res/drawable/color_lightsteelblue.xml
Normal file
4
app/src/main/res/drawable/color_lightsteelblue.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<corners android:radius="20dp" />
|
||||||
|
<solid android:color="#B0C4DE" />
|
||||||
|
</shape>
|
@ -7,7 +7,9 @@
|
|||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/bookinfo_swipeRefresh"
|
android:id="@+id/bookinfo_swipeRefresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/bookinfo_bottom">
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -206,7 +208,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:text="精彩随笔"
|
android:text="精彩点评"
|
||||||
android:textSize="16dp"
|
android:textSize="16dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/Book_name_View" />
|
app:layout_constraintTop_toBottomOf="@+id/Book_name_View" />
|
||||||
|
@ -182,7 +182,7 @@
|
|||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
android:src="@drawable/collect" />
|
android:src="@drawable/collect1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -38,12 +38,12 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="35dp"
|
android:layout_marginTop="25dp"
|
||||||
android:layout_marginEnd="177dp"
|
android:layout_marginEnd="177dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
|
android:textSize="@dimen/s_dp_16"
|
||||||
android:layout_toEndOf="@+id/inf_user_icon"
|
android:layout_toEndOf="@+id/inf_user_icon"
|
||||||
android:text="百利甜斤鱼子"
|
android:text="百利甜斤鱼子" />
|
||||||
android:textColor="@color/black" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
@ -97,8 +97,7 @@
|
|||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="钱钟书"
|
android:text="钱钟书"
|
||||||
android:textColor="@color/black"
|
android:textSize="16sp" />
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/inf_bookName"
|
android:id="@+id/inf_bookName"
|
||||||
@ -109,8 +108,7 @@
|
|||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:paddingTop="15dp"
|
android:paddingTop="15dp"
|
||||||
android:text="围城"
|
android:text="围城"
|
||||||
android:textColor="@color/black"
|
android:textSize="16sp" />
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -135,7 +133,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="发表于 "
|
android:text="发表于 "
|
||||||
android:textColor="@color/black" />
|
android:textColor="#808080" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/comment_cnt"
|
android:id="@+id/comment_cnt"
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
android:gravity="center_horizontal">
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sendspecific_title"
|
android:id="@+id/sendmarking_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="点评xx"
|
android:text="点评xx"
|
||||||
@ -22,23 +22,23 @@
|
|||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
sendmarking
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/sendspecific_henhao"
|
android:id="@+id/sendmarking_henhao"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
app:srcCompat="@drawable/recommend1" />
|
app:srcCompat="@drawable/recommend1" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/sendspecific_yiban"
|
android:id="@+id/sendmarking_yiban"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
app:srcCompat="@drawable/normal1" />
|
app:srcCompat="@drawable/normal1" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/sendspecific_buxing"
|
android:id="@+id/sendmarking_buxing"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@ -52,7 +52,7 @@
|
|||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_marginTop="10dp" />
|
android:layout_marginTop="10dp" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/sendspecific_content"
|
android:id="@+id/sendmarking_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="350dp"
|
android:layout_height="350dp"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
@ -64,7 +64,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sendspecific_cancel"
|
android:id="@+id/sendmarking_cancel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
@ -78,7 +78,7 @@
|
|||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sendspecific_submit"
|
android:id="@+id/sendmarking_submit"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#00BFFF"
|
android:textColor="#00BFFF"
|
@ -3,37 +3,48 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="200dp"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:padding="8dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/inf_comment_user_icon"
|
android:id="@+id/inf_comment_user_icon"
|
||||||
android:layout_width="36dp"
|
android:layout_width="28dp"
|
||||||
android:layout_height="38dp"
|
android:layout_height="28dp"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_margin="4dp"
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:src="@drawable/touxiang" />
|
android:src="@drawable/touxiang" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/inf_comment_postPersonName"
|
android:id="@+id/inf_comment_postPersonName"
|
||||||
android:layout_width="156dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="20dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="5dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="19dp"
|
android:text="百利甜斤鱼子"
|
||||||
android:layout_toEndOf="@+id/inf_comment_user_icon"
|
android:textSize="14sp"
|
||||||
android:text="百利甜斤鱼子" />
|
android:gravity="center_vertical" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/inf_comment_commentTime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="2024-05-22 11:00:00"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/inf_comment_textView_perception"
|
android:id="@+id/inf_comment_textView_perception"
|
||||||
android:layout_width="380dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginStart="40dp"
|
||||||
android:text="多边形裁剪用于裁剪掉被裁剪多边形(又称为实体多边形,后文用S表示)位于窗口(又称为裁剪多边形,后文用C表示)之外的部分。裁剪的结果多边形是由实体多边形位于裁剪多边形内的边界和裁剪多边形位于实体多边形内的边界组成的。" />
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="多边形裁剪用于裁剪掉被裁剪多边形(又称为实体多边形,后文用S表示)位于窗口(又称为裁剪多边形,后文用C表示)之外的部分。裁剪的结果多边形是由实体多边形位于裁剪多边形内的边界和裁剪多边形位于实体多边形内的边界组成的。"
|
||||||
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -34,7 +34,7 @@
|
|||||||
android:text="张三" />
|
android:text="张三" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/evaluation_state"
|
android:id="@+id/marking_grade"
|
||||||
android:layout_width="99dp"
|
android:layout_width="99dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:src="@drawable/recommend1" />
|
android:src="@drawable/recommend1" />
|
||||||
@ -69,14 +69,18 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/marking_like"
|
||||||
android:layout_width="25dp"
|
android:layout_width="25dp"
|
||||||
android:layout_height="25dp"
|
android:layout_height="25dp"
|
||||||
android:layout_marginLeft="50dp"
|
android:layout_marginLeft="40dp"
|
||||||
android:src="@drawable/like1" />
|
android:src="@drawable/like1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:id="@+id/marking_likecnt"
|
||||||
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_5"
|
||||||
android:text="点赞数" />
|
android:text="点赞数" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -88,15 +92,19 @@
|
|||||||
android:gravity="end">
|
android:gravity="end">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/marking_collect"
|
||||||
android:layout_width="25dp"
|
android:layout_width="25dp"
|
||||||
android:layout_height="25dp"
|
android:layout_height="25dp"
|
||||||
android:src="@drawable/comment1" />
|
android:src="@drawable/collect1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:id="@+id/marking_collectcnt"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="50dp"
|
android:layout_marginLeft="@dimen/s_dp_5"
|
||||||
android:text="评论数" />
|
android:layout_marginRight="40dp"
|
||||||
|
android:text="收藏数" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
android:layout_marginRight="20dp"
|
android:layout_marginRight="20dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:background="@drawable/mydimgrey"
|
android:background="@drawable/color_lightsteelblue"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent">
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
@ -125,12 +125,16 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/perception_likeicon"
|
||||||
android:layout_width="25dp"
|
android:layout_width="25dp"
|
||||||
android:layout_height="25dp"
|
android:layout_height="25dp"
|
||||||
android:layout_marginLeft="50dp"
|
android:layout_marginLeft="50dp"
|
||||||
android:src="@drawable/like1" />
|
android:src="@drawable/like1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginLeft="@dimen/s_dp_5"
|
||||||
|
android:id="@+id/perception_likecnt"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="点赞数" />
|
android:text="点赞数" />
|
||||||
@ -144,11 +148,15 @@
|
|||||||
android:gravity="end">
|
android:gravity="end">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/perception_collecticon"
|
||||||
android:layout_width="25dp"
|
android:layout_width="25dp"
|
||||||
android:layout_height="25dp"
|
android:layout_height="25dp"
|
||||||
android:src="@drawable/collect" />
|
android:src="@drawable/collect" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginLeft="@dimen/s_dp_5"
|
||||||
|
android:id="@+id/perception_collectcnt"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="50dp"
|
android:layout_marginRight="50dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user