second_submit
This commit is contained in:
parent
f9ac772512
commit
255b76c1bd
17
.idea/deploymentTargetDropDown.xml
generated
Normal file
17
.idea/deploymentTargetDropDown.xml
generated
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\zhangsan\.android\avd\Pixel_5_API_30.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2024-04-25T03:17:09.044472200Z" />
|
||||
</component>
|
||||
</project>
|
@ -28,15 +28,16 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Jianshu"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity android:name=".HotBookActivity"/>
|
||||
<activity android:name=".Book_informationActivity" />
|
||||
<activity android:name=".PerceptionActivity" />
|
||||
<activity android:name=".FindpwdActivity"/>
|
||||
<activity android:name=".WenXueActivity"/>
|
||||
<activity android:name=".xinliActivity"/>
|
||||
<activity android:name=".guanliActivity"/>
|
||||
<activity android:name=".zhexueActivity"/>
|
||||
<activity android:name=".LiteratureActivity"/>
|
||||
<activity android:name=".PsychologyActivity"/>
|
||||
<activity android:name=".ManagementActivity"/>
|
||||
<activity android:name=".PhilosophyActivity"/>
|
||||
<!-- <activity android:name=".BookShelfActivity"/>-->
|
||||
<activity android:name=".kexueActivity"/>
|
||||
<activity android:name=".ScienceActivity"/>
|
||||
<activity android:name=".author_introductionActivity"/>
|
||||
<!-- <activity android:name=".MainActivity"-->
|
||||
<!-- android:exported="true"-->
|
||||
|
@ -8,7 +8,7 @@ import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_info_bmob
|
||||
import com.zjgsu.jianshu.Book_informationActivity
|
||||
import com.zjgsu.jianshu.R
|
||||
import kotlinx.android.synthetic.main.activity_book_info.*
|
||||
@ -34,10 +34,10 @@ class BookIntro:AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
private fun inits(){
|
||||
val query = BmobQuery<Book_inf_bmob>()
|
||||
val query = BmobQuery<Book_info_bmob>()
|
||||
query.addWhereEqualTo("name", Bookname)
|
||||
query.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
query.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
expandable3.text = i.introduce
|
||||
|
@ -138,6 +138,7 @@ class BookShelfActivity : AppCompatActivity() {
|
||||
})
|
||||
}
|
||||
private fun setupBottomNavigation() {
|
||||
bookshelf.setImageResource(R.drawable.bookshelf2)
|
||||
bookcity.setOnClickListener {
|
||||
NavigationHelper.navigateTo(this, MainActivity::class.java)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import cn.bmob.v3.listener.SaveListener
|
||||
import com.zjgsu.jianshu.Activity.BookIntro
|
||||
import com.zjgsu.jianshu.Adapter.GoodsuibiAdapter
|
||||
import com.zjgsu.jianshu.Bmob.BookShelf
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
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.title.*
|
||||
@ -45,10 +45,10 @@ class Book_informationActivity : AppCompatActivity() {
|
||||
recyclerView3.layoutManager = layoutManager
|
||||
var adapter = GoodsuibiAdapter(perceptionList)
|
||||
recyclerView3.adapter = adapter
|
||||
val query = BmobQuery<Book_inf_bmob>()
|
||||
val query = BmobQuery<Book_info_bmob>()
|
||||
query.addWhereEqualTo("name", Bookname)
|
||||
query.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(p0: MutableList<Book_inf_bmob>?, p1: BmobException?) {
|
||||
query.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(p0: MutableList<Book_info_bmob>?, p1: BmobException?) {
|
||||
if (p1 == null) {
|
||||
if (p0 != null && p0.size > 0) {
|
||||
for (p in p0) {
|
||||
@ -132,8 +132,8 @@ class Book_informationActivity : AppCompatActivity() {
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
query.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
query.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
Book_name_View.text = i.name
|
||||
@ -153,8 +153,8 @@ class Book_informationActivity : AppCompatActivity() {
|
||||
b_henhao.setOnClickListener {
|
||||
if (Mycomment == false) {
|
||||
Mycomment = true
|
||||
query.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
query.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
i.settuijian(i.tuijian + 1)
|
||||
@ -186,8 +186,8 @@ class Book_informationActivity : AppCompatActivity() {
|
||||
b_yiban.setOnClickListener {
|
||||
if (Mycomment == false) {
|
||||
Mycomment = true
|
||||
query.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
query.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
i.setyiban(i.yiban + 1)
|
||||
@ -219,8 +219,8 @@ class Book_informationActivity : AppCompatActivity() {
|
||||
b_buxing.setOnClickListener {
|
||||
if (Mycomment == false) {
|
||||
Mycomment = true
|
||||
query.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
query.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
i.setbuxing(i.buxing + 1)
|
||||
|
@ -0,0 +1,4 @@
|
||||
package com.zjgsu.jianshu.Activity
|
||||
|
||||
class GoodBookActivity {
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.zjgsu.jianshu
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.widget.SearchView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
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.Bmob.Book_info_bmob
|
||||
import kotlinx.android.synthetic.main.activity_bookrank.*
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
class HotBookActivity: AppCompatActivity() {
|
||||
private var hotbookList=ArrayList<Book_rank>()
|
||||
lateinit var adapter:BookRankAdapter
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_bookrank)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
adapter= BookRankAdapter(hotbookList)
|
||||
bookrank_recyclerView.layoutManager=StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
bookrank_recyclerView.adapter=adapter
|
||||
bookrank_swipeRefresh.setOnRefreshListener {
|
||||
loadBookRanks() //下拉刷新
|
||||
}
|
||||
loadBookRanks()
|
||||
bookrank_title.text="热门图书榜单"
|
||||
}
|
||||
private fun loadBookRanks(){
|
||||
val queryHotBooks = BmobQuery<Book_info_bmob>()
|
||||
queryHotBooks.order("-countOfReaders") // 根据 countOfReaders 降序排序
|
||||
queryHotBooks.setLimit(10) // 限制查询结果的数量为3
|
||||
queryHotBooks.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(books: List<Book_info_bmob>?, e: BmobException?) {
|
||||
bookrank_swipeRefresh.isRefreshing = false
|
||||
if (e == null) {
|
||||
// 检查 books 是否非空
|
||||
if (books != null && books.isNotEmpty()) {
|
||||
hotbookList.clear() // 清空当前列表
|
||||
// 遍历 books 并转换为 Book_rank 类型后添加到列表
|
||||
books.forEach { b ->
|
||||
val bookRank = Book_rank(
|
||||
name = b.name,
|
||||
picUrl = b.picture.url,
|
||||
score="0.0",
|
||||
courtOfReaders = b.countOfReaders,
|
||||
author=b.author_name,
|
||||
intro=b.introduce
|
||||
)
|
||||
hotbookList.add(bookRank)
|
||||
adapter.notifyDataSetChanged() // 确保在这里更新适配器
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 处理错误情况
|
||||
Toast.makeText(
|
||||
this@HotBookActivity,
|
||||
"Failed to retrieve books: ${e.message}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun returnTOCity(){
|
||||
bookrank_return.setOnClickListener{
|
||||
NavigationHelper.navigateTo(this, MainActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_categorypage.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
|
||||
class LiteratureActivity : AppCompatActivity() {
|
||||
private lateinit var adapter: BookAdapter2
|
||||
private var bookList = ArrayList<Book>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_categorypage)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.menu)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
|
||||
val titleTextView = findViewById<TextView>(R.id.categoryPage_title)
|
||||
titleTextView.text = "文学"
|
||||
adapter = BookAdapter2(bookList)
|
||||
categoryPage_recyclerView.layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
categoryPage_recyclerView.adapter = adapter
|
||||
categoryPage_swipeRefresh.setOnRefreshListener {
|
||||
loadBooks() //下拉刷新
|
||||
}
|
||||
setupNavigation()
|
||||
loadBooks()
|
||||
setupBottomNavigation()
|
||||
returnToBookcity()
|
||||
|
||||
}
|
||||
|
||||
private fun setupNavigation() { //侧边栏
|
||||
categoryPage_navView.setCheckedItem(R.id.literature)
|
||||
categoryPage_navView.setNavigationItemSelectedListener { menuItem ->
|
||||
startActivity(Intent(this, when (menuItem.itemId) {
|
||||
R.id.literature -> LiteratureActivity::class.java
|
||||
R.id.management -> ManagementActivity::class.java
|
||||
R.id.psychology -> PsychologyActivity::class.java
|
||||
R.id.science -> ScienceActivity::class.java
|
||||
R.id.philosophy -> PhilosophyActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}))
|
||||
categoryPage_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadBooks() {
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("category_id", 1)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>?, e: BmobException?) {
|
||||
categoryPage_swipeRefresh.isRefreshing = false
|
||||
if (e == null && list != null) {
|
||||
updateBookList(list)
|
||||
} else {
|
||||
Log.e("LiteratureActivity", "Error refreshing books: ${e?.message}", e)
|
||||
Toast.makeText(this@LiteratureActivity, "Failed to refresh books.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateBookList(list: List<Book_bmob>) {
|
||||
bookList.clear()
|
||||
bookList.addAll(list.map { Book(it.name, it.introduce, it.picture.url) })
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setupBottomNavigation() {
|
||||
bookcity.setOnClickListener {
|
||||
finish() // Simplify navigation logic
|
||||
}
|
||||
bookshelf.setOnClickListener {
|
||||
startActivity(Intent(this, BookShelfActivity::class.java))
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
startActivity(Intent(this, PerceptionActivity::class.java))
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
startActivity(Intent(this, MyActivity::class.java))
|
||||
}
|
||||
}
|
||||
private fun returnToBookcity(){
|
||||
categoryPage_back.setOnClickListener{
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
categoryPage_drawerLayout.openDrawer(GravityCompat.START)
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
@ -1,274 +1,34 @@
|
||||
//package com.zjgsu.jianshu
|
||||
//import android.content.ClipData
|
||||
//import android.content.Intent
|
||||
//import androidx.appcompat.app.AppCompatActivity
|
||||
//import android.os.Bundle
|
||||
//import android.text.TextUtils
|
||||
//import android.util.Log
|
||||
//import android.view.Menu
|
||||
//import android.view.MenuItem
|
||||
//import android.widget.Adapter
|
||||
//import android.widget.SearchView
|
||||
//import android.widget.Toast
|
||||
//import androidx.core.view.GravityCompat
|
||||
//import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
//import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
//import cn.bmob.v3.Bmob
|
||||
//import cn.bmob.v3.BmobQuery
|
||||
//import cn.bmob.v3.exception.BmobException
|
||||
//import cn.bmob.v3.listener.FindListener
|
||||
//import kotlinx.android.synthetic.main.activity_main.*
|
||||
//import kotlinx.android.synthetic.main.activity_xinli.*
|
||||
//import java.io.BufferedReader
|
||||
//import java.io.IOException
|
||||
//import java.io.InputStream
|
||||
//import java.io.InputStreamReader
|
||||
//import java.lang.StringBuilder
|
||||
//import kotlin.concurrent.thread
|
||||
//
|
||||
//var UserId: String = ""
|
||||
//
|
||||
//class MainActivity : AppCompatActivity() {
|
||||
// private var user_id: String = ""
|
||||
// private var bookList = ArrayList<Book>()
|
||||
// private var bookList1 = ArrayList<Book>()
|
||||
// private var bookList2 = ArrayList<Book>()
|
||||
// private var bookList3 = ArrayList<Book>()
|
||||
// public fun Search(query: String): ArrayList<Book> {
|
||||
// val bookList1 = ArrayList<Book>()
|
||||
// for (source in bookList) {
|
||||
// if (source.name.contains(query))
|
||||
// bookList1.add(
|
||||
// Book(
|
||||
// source.name,
|
||||
// source.introduce,
|
||||
// source.tuijian,
|
||||
// source.yiban,
|
||||
// source.buxing
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// return bookList1
|
||||
// }
|
||||
//
|
||||
// override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// super.onCreate(savedInstanceState)
|
||||
// setContentView(R.layout.activity_main)
|
||||
// supportActionBar?.let {
|
||||
// it.setDisplayHomeAsUpEnabled(true)
|
||||
// it.setHomeAsUpIndicator(R.drawable.menu)
|
||||
// }
|
||||
// Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
// UserId = intent.getStringExtra("userid").toString()
|
||||
// inits()
|
||||
// val layoutManager =
|
||||
// StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||
// recyclerView.layoutManager = layoutManager
|
||||
// var adapter = BookAdapter(bookList)
|
||||
// recyclerView.adapter = adapter
|
||||
// swipeRefresh.setOnRefreshListener {
|
||||
// refreshBooks(adapter)
|
||||
// }
|
||||
// navView.setCheckedItem(R.id.goodbook)
|
||||
// navView.setNavigationItemSelectedListener {
|
||||
// val intentwenxue = Intent(this, WenXueActivity::class.java)
|
||||
// val intentguanli = Intent(this, guanliActivity::class.java)
|
||||
// val intentxinli = Intent(this, xinliActivity::class.java)
|
||||
// val intentkexue = Intent(this, kexueActivity::class.java)
|
||||
// val intentzhexue = Intent(this, zhexueActivity::class.java)
|
||||
// when (it.itemId) {
|
||||
// R.id.wenxue -> startActivity(intentwenxue)
|
||||
// R.id.guanli -> startActivity(intentguanli)
|
||||
// R.id.xinli -> startActivity(intentxinli)
|
||||
// R.id.zhexue -> startActivity(intentzhexue)
|
||||
// R.id.kexue -> startActivity(intentkexue)
|
||||
// }
|
||||
// drawerLayout.closeDrawers()
|
||||
// true
|
||||
// }
|
||||
// main_searchview.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
// // 设置搜索文本监听{
|
||||
// override fun onQueryTextSubmit(query: String): Boolean { //搜索时触发事件
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// override fun onQueryTextChange(newText: String): Boolean {
|
||||
// if (TextUtils.isEmpty(newText)) {
|
||||
// bookList.clear()
|
||||
// bookList.addAll(bookList2)
|
||||
// } else {
|
||||
// bookList1.clear()
|
||||
// bookList.clear()
|
||||
// bookList1.addAll(bookList2)
|
||||
// for (source in bookList1) {
|
||||
// if (source.name.contains(newText)) {
|
||||
// bookList.add(
|
||||
// Book(
|
||||
// source.name,
|
||||
// source.introduce,
|
||||
// source.tuijian,
|
||||
// source.yiban,
|
||||
// source.buxing
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// for (i in bookList)
|
||||
// Log.d("zy123", i.name)
|
||||
// bookList3.addAll(bookList)
|
||||
// thread {
|
||||
// Thread.sleep(2000)
|
||||
// runOnUiThread {
|
||||
// initBooks()
|
||||
// adapter.notifyDataSetChanged()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
// })
|
||||
// book_recommend.setOnClickListener {
|
||||
// val intent = Intent(this, MainActivity::class.java)
|
||||
// startActivity(intent)
|
||||
// finish()
|
||||
// }
|
||||
// book_bookshelf.setOnClickListener {
|
||||
// val intent = Intent(this, BookShelfActivity::class.java)
|
||||
// startActivity(intent)
|
||||
// finish()
|
||||
// }
|
||||
// reading_comprehension.setOnClickListener {
|
||||
// val intent = Intent(this, PerceptionActivity::class.java)
|
||||
// startActivity(intent)
|
||||
// finish()
|
||||
// }
|
||||
// self.setOnClickListener {
|
||||
// val intent = Intent(this, MyActivity::class.java)
|
||||
// startActivity(intent)
|
||||
// finish()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun refreshBooks(adapter: BookAdapter) {
|
||||
// thread {
|
||||
// Thread.sleep(2000)
|
||||
// runOnUiThread {
|
||||
// initBooks()
|
||||
// adapter.notifyDataSetChanged()
|
||||
// swipeRefresh.isRefreshing = false
|
||||
// Toast.makeText(this, "刷新成功!", Toast.LENGTH_SHORT).show()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
// when (item.itemId) {
|
||||
// android.R.id.home -> drawerLayout.openDrawer(GravityCompat.START)
|
||||
// }
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// private fun initBooks() {
|
||||
// if (bookList3.isNotEmpty()) {
|
||||
// bookList.clear()
|
||||
// bookList.addAll(bookList3)
|
||||
// val adapter = BookAdapter(bookList)
|
||||
// recyclerView.adapter = adapter
|
||||
// bookList3.clear()
|
||||
// } else {
|
||||
// bookList.clear()
|
||||
// val bmobQuery = BmobQuery<Book_bmob>()
|
||||
// bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
// override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
// var cnt: Int = 0
|
||||
// if (e == null) {
|
||||
// for (i in list) {
|
||||
// if (cnt < 15) {
|
||||
// bookList.add(
|
||||
// Book(
|
||||
// i.name,
|
||||
// i.introduce,
|
||||
// i.tuijian,
|
||||
// i.yiban,
|
||||
// i.buxing
|
||||
// )
|
||||
// )
|
||||
// val adapter = BookAdapter(bookList)
|
||||
// recyclerView.adapter = adapter
|
||||
// cnt++
|
||||
// }
|
||||
// }
|
||||
//// bookList.sortBy { it.tuijian * 100 / (it.buxing + it.tuijian + it.buxing) }
|
||||
// } else {
|
||||
// Log.d("error", "error")
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private fun inits() {
|
||||
//// initsIntroduction()
|
||||
//// val books= mutableListOf(Book("围城","1111111111111",R.drawable.weicheng),Book("当尼采哭泣","2222222222",R.drawable.nicai),Book("台北人","333333333",R.drawable.taibei))
|
||||
//// for(index in 0..2) {
|
||||
//// bookList.add(books[index])
|
||||
//// bookList2.add(books[index])
|
||||
//// val adapter = BookAdapter(this@MainActivity, bookList)
|
||||
//// recyclerView.adapter = adapter
|
||||
//// }
|
||||
// val bmobQuery = BmobQuery<Book_bmob>()
|
||||
// bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
// override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
// var cnt: Int = 0
|
||||
// if (e == null) {
|
||||
// for (i in list) {
|
||||
// if (cnt < 15) {
|
||||
// bookList.add(Book(i.name, i.introduce, i.tuijian, i.yiban, i.buxing))
|
||||
// bookList2.add(Book(i.name, i.introduce, i.tuijian, i.yiban, i.buxing))
|
||||
// val adapter = BookAdapter(bookList)
|
||||
// recyclerView.adapter = adapter
|
||||
// cnt++
|
||||
// }
|
||||
// }
|
||||
//// bookList.add(Book("www","www",11,12,13))
|
||||
// } else {
|
||||
// Log.d("error", "error")
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.app.Person
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.SearchView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import cn.bmob.v3.listener.QueryListListener
|
||||
import com.zjgsu.jianshu.Adapter.BillboardAdapter
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
import com.zjgsu.jianshu.Bmob.User_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_info_bmob
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.book_rank_item.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
|
||||
var UserId: String = ""
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private lateinit var adapter: BookAdapter
|
||||
private lateinit var billboardAdapter: BillboardAdapter
|
||||
private var bookList = ArrayList<Book>()
|
||||
private var listOfBookRankList: MutableList<ArrayList<Book_rank>> = mutableListOf()
|
||||
private var hotbookList=ArrayList<Book_rank>()
|
||||
private var goodbookList=ArrayList<Book_rank>()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
@ -276,13 +36,17 @@ class MainActivity : AppCompatActivity() {
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.menu)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
|
||||
adapter = BookAdapter(bookList)
|
||||
recyclerView.layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
recyclerView.layoutManager =
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
billboardAdapter= BillboardAdapter(listOfBookRankList)
|
||||
horizontal_recycler_view.layoutManager=
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.HORIZONTAL)
|
||||
horizontal_recycler_view.adapter=billboardAdapter
|
||||
swipeRefresh.setOnRefreshListener {
|
||||
loadBooks() //下拉刷新
|
||||
}
|
||||
|
||||
main_searchview.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String): Boolean = false
|
||||
|
||||
@ -297,21 +61,25 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
})
|
||||
|
||||
navView.setCheckedItem(R.id.goodbook)
|
||||
navView.setCheckedItem(R.id.recommend)
|
||||
navView.setNavigationItemSelectedListener { menuItem ->
|
||||
startActivity(Intent(this, when(menuItem.itemId) {
|
||||
R.id.wenxue -> WenXueActivity::class.java
|
||||
R.id.guanli -> guanliActivity::class.java
|
||||
R.id.xinli -> xinliActivity::class.java
|
||||
R.id.zhexue -> zhexueActivity::class.java
|
||||
R.id.kexue -> kexueActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}))
|
||||
startActivity(
|
||||
Intent(
|
||||
this, when (menuItem.itemId) {
|
||||
R.id.literature -> LiteratureActivity::class.java
|
||||
R.id.management -> ManagementActivity::class.java
|
||||
R.id.psychology -> PsychologyActivity::class.java
|
||||
R.id.philosophy -> PhilosophyActivity::class.java
|
||||
R.id.science -> ScienceActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}
|
||||
)
|
||||
)
|
||||
drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
|
||||
loadBooks()
|
||||
loadBookRanks()
|
||||
setupBottomNavigation()
|
||||
}
|
||||
|
||||
@ -331,13 +99,105 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
Toast.makeText(this@MainActivity, "Failed to retrieve books: ${e.message}", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
this@MainActivity,
|
||||
"Failed to retrieve books: ${e.message}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun loadBookRanks(){
|
||||
val queryHotBooks = BmobQuery<Book_info_bmob>()
|
||||
queryHotBooks.order("-countOfReaders") // 根据 countOfReaders 降序排序
|
||||
queryHotBooks.setLimit(3) // 限制查询结果的数量为3
|
||||
queryHotBooks.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(books: List<Book_info_bmob>?, e: BmobException?) {
|
||||
if (e == null) {
|
||||
// 检查 books 是否非空
|
||||
if (books != null && books.isNotEmpty()) {
|
||||
hotbookList.clear() // 清空当前列表
|
||||
// 遍历 books 并转换为 Book_rank 类型后添加到列表
|
||||
books.forEach { b ->
|
||||
val bookRank = Book_rank(
|
||||
name = b.name,
|
||||
picUrl = b.picture.url,
|
||||
score="0.0",
|
||||
courtOfReaders = b.countOfReaders,
|
||||
author=b.author_name,
|
||||
intro=""
|
||||
)
|
||||
hotbookList.add(bookRank)
|
||||
}
|
||||
listOfBookRankList.add(hotbookList)
|
||||
billboardAdapter.notifyDataSetChanged() // 确保在这里更新适配器
|
||||
}
|
||||
} else {
|
||||
// 处理错误情况
|
||||
Toast.makeText(
|
||||
this@MainActivity,
|
||||
"Failed to retrieve books: ${e.message}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
val queryGoodBooks = BmobQuery<Book_info_bmob>()
|
||||
queryGoodBooks.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(books: List<Book_info_bmob>?, e: BmobException?) {
|
||||
if (e == null) {
|
||||
// 清空之前的书籍列表
|
||||
goodbookList.clear()
|
||||
// 计算每本书的 good 比例,并构建 Book 对象加入列表
|
||||
books?.let {
|
||||
// 对书籍列表按照 good 比例进行排序
|
||||
val sortedBooks = it.sortedByDescending { book ->
|
||||
val total = book.tuijian + book.yiban + book.buxing
|
||||
if (total > 0) {
|
||||
book.tuijian.toDouble() / total.toDouble() // 计算 good 的比例
|
||||
} else {
|
||||
0.0 // 如果总数为 0,比例设为 0
|
||||
}
|
||||
}
|
||||
// 获取前三名书籍
|
||||
val topThreeBooks = sortedBooks.take(3)
|
||||
topThreeBooks.forEach { b ->
|
||||
val tmp = b.tuijian + b.yiban + b.buxing
|
||||
val scorePercentage = if (tmp > 0) {
|
||||
(b.tuijian.toDouble() / tmp.toDouble()) * 100
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
val formattedScore = String.format("%.1f%%", scorePercentage) // 将百分数格式化为带一位小数的字符串
|
||||
val bookRank = Book_rank(
|
||||
name = b.name,
|
||||
picUrl = b.picture.url,
|
||||
score = formattedScore,
|
||||
courtOfReaders = b.countOfReaders,
|
||||
author=b.author_name,
|
||||
intro=""
|
||||
)
|
||||
goodbookList.add(bookRank)
|
||||
}
|
||||
|
||||
listOfBookRankList.add(goodbookList)
|
||||
billboardAdapter.notifyDataSetChanged() // 确保在这里更新适配器
|
||||
}
|
||||
} else {
|
||||
// 处理错误情况
|
||||
Toast.makeText(
|
||||
this@MainActivity,
|
||||
"Failed to retrieve books: ${e.message}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
private fun setupBottomNavigation() {
|
||||
bookcity.setImageResource(R.drawable.bookcity2)
|
||||
bookcity.setOnClickListener {
|
||||
NavigationHelper.navigateTo(this, MainActivity::class.java)
|
||||
}
|
||||
|
@ -0,0 +1,109 @@
|
||||
package com.zjgsu.jianshu
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_categorypage.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
|
||||
class ManagementActivity:AppCompatActivity() {
|
||||
private lateinit var adapter: BookAdapter2
|
||||
private var bookList = ArrayList<Book>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_categorypage)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.menu)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
|
||||
val titleTextView = findViewById<TextView>(R.id.categoryPage_title)
|
||||
titleTextView.text = "管理学"
|
||||
adapter = BookAdapter2(bookList)
|
||||
categoryPage_recyclerView.layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
categoryPage_recyclerView.adapter = adapter
|
||||
categoryPage_swipeRefresh.setOnRefreshListener {
|
||||
loadBooks() //下拉刷新
|
||||
}
|
||||
setupNavigation()
|
||||
loadBooks()
|
||||
setupBottomNavigation()
|
||||
returnToBookcity()
|
||||
}
|
||||
|
||||
private fun setupNavigation() {
|
||||
categoryPage_navView.setCheckedItem(R.id.management)
|
||||
categoryPage_navView.setNavigationItemSelectedListener { menuItem ->
|
||||
startActivity(Intent(this, when (menuItem.itemId) {
|
||||
R.id.literature -> LiteratureActivity::class.java
|
||||
R.id.management -> ManagementActivity::class.java
|
||||
R.id.psychology -> PsychologyActivity::class.java
|
||||
R.id.science -> ScienceActivity::class.java
|
||||
R.id.philosophy -> PhilosophyActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}))
|
||||
categoryPage_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadBooks() {
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("category_id", 2)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>?, e: BmobException?) {
|
||||
categoryPage_swipeRefresh.isRefreshing = false
|
||||
if (e == null && list != null) {
|
||||
updateBookList(list)
|
||||
} else {
|
||||
Log.e("ManagementActivity", "Error refreshing books: ${e?.message}", e)
|
||||
Toast.makeText(this@ManagementActivity, "Failed to refresh books.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateBookList(list: List<Book_bmob>) {
|
||||
bookList.clear()
|
||||
bookList.addAll(list.map { Book(it.name, it.introduce, it.picture.url) })
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setupBottomNavigation() {
|
||||
bookcity.setOnClickListener {
|
||||
finish() // Simplify navigation logic
|
||||
}
|
||||
bookshelf.setOnClickListener {
|
||||
startActivity(Intent(this, BookShelfActivity::class.java))
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
startActivity(Intent(this, PerceptionActivity::class.java))
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
startActivity(Intent(this, MyActivity::class.java))
|
||||
}
|
||||
}
|
||||
private fun returnToBookcity(){
|
||||
categoryPage_back.setOnClickListener{
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
categoryPage_drawerLayout.openDrawer(GravityCompat.START)
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
@ -96,6 +96,7 @@ class MyActivity : AppCompatActivity() {
|
||||
setupBottomNavigation()
|
||||
}
|
||||
private fun setupBottomNavigation() {
|
||||
homepage.setImageResource(R.drawable.my2)
|
||||
bookcity.setOnClickListener {
|
||||
NavigationHelper.navigateTo(this, MainActivity::class.java)
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ class PerceptionActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
private fun setupBottomNavigation() {
|
||||
reading_comprehension.setImageResource(R.drawable.perception2)
|
||||
bookcity.setOnClickListener {
|
||||
NavigationHelper.navigateTo(this, MainActivity::class.java)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import cn.bmob.v3.listener.FindListener
|
||||
import cn.bmob.v3.listener.SaveListener
|
||||
import com.zjgsu.jianshu.*
|
||||
import com.zjgsu.jianshu.Adapter.CommentAdapter
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_info_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Comment_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Perception_bmob
|
||||
import com.zjgsu.jianshu.Bmob.User_bmob
|
||||
@ -133,9 +133,9 @@ class Perception_informationActivity:AppCompatActivity() {
|
||||
Log.d("myLog", p.b_name)
|
||||
bookName = p.b_name
|
||||
inf_bookName.text = bookName
|
||||
val queryBook = BmobQuery<Book_inf_bmob>()
|
||||
queryBook.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
val queryBook = BmobQuery<Book_info_bmob>()
|
||||
queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if (p.b_name.equals(i.name)) {
|
||||
|
@ -0,0 +1,110 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_categorypage.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
|
||||
class PhilosophyActivity:AppCompatActivity() {
|
||||
private lateinit var adapter: BookAdapter2
|
||||
private var bookList = ArrayList<Book>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_categorypage)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.menu)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
|
||||
val titleTextView = findViewById<TextView>(R.id.categoryPage_title)
|
||||
titleTextView.text = "哲学"
|
||||
adapter = BookAdapter2(bookList)
|
||||
categoryPage_recyclerView.layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
categoryPage_recyclerView.adapter = adapter
|
||||
categoryPage_swipeRefresh.setOnRefreshListener {
|
||||
loadBooks() //下拉刷新
|
||||
}
|
||||
setupNavigation()
|
||||
loadBooks()
|
||||
setupBottomNavigation()
|
||||
returnToBookcity()
|
||||
}
|
||||
|
||||
private fun setupNavigation() {
|
||||
categoryPage_navView.setCheckedItem(R.id.philosophy)
|
||||
categoryPage_navView.setNavigationItemSelectedListener { menuItem ->
|
||||
startActivity(Intent(this, when (menuItem.itemId) {
|
||||
R.id.literature -> LiteratureActivity::class.java
|
||||
R.id.management -> ManagementActivity::class.java
|
||||
R.id.psychology -> PsychologyActivity::class.java
|
||||
R.id.science -> ScienceActivity::class.java
|
||||
R.id.philosophy -> PhilosophyActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}))
|
||||
categoryPage_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadBooks() {
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("category_id", 5)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>?, e: BmobException?) {
|
||||
categoryPage_swipeRefresh.isRefreshing = false
|
||||
if (e == null && list != null) {
|
||||
updateBookList(list)
|
||||
} else {
|
||||
Log.e("PhilosophyActivity", "Error refreshing books: ${e?.message}", e)
|
||||
Toast.makeText(this@PhilosophyActivity, "Failed to refresh books.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateBookList(list: List<Book_bmob>) {
|
||||
bookList.clear()
|
||||
bookList.addAll(list.map { Book(it.name, it.introduce, it.picture.url) })
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setupBottomNavigation() {
|
||||
bookcity.setOnClickListener {
|
||||
finish() // Simplify navigation logic
|
||||
}
|
||||
bookshelf.setOnClickListener {
|
||||
startActivity(Intent(this, BookShelfActivity::class.java))
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
startActivity(Intent(this, PerceptionActivity::class.java))
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
startActivity(Intent(this, MyActivity::class.java))
|
||||
}
|
||||
}
|
||||
private fun returnToBookcity(){
|
||||
categoryPage_back.setOnClickListener{
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
categoryPage_drawerLayout.openDrawer(GravityCompat.START)
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.zjgsu.jianshu
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_categorypage.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
|
||||
class PsychologyActivity:AppCompatActivity() {
|
||||
private lateinit var adapter: BookAdapter2
|
||||
private var bookList = ArrayList<Book>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_categorypage)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.menu)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
|
||||
val titleTextView = findViewById<TextView>(R.id.categoryPage_title)
|
||||
titleTextView.text = "心理学"
|
||||
adapter = BookAdapter2(bookList)
|
||||
categoryPage_recyclerView.layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
categoryPage_recyclerView.adapter = adapter
|
||||
categoryPage_swipeRefresh.setOnRefreshListener {
|
||||
loadBooks() //下拉刷新
|
||||
}
|
||||
setupNavigation()
|
||||
loadBooks()
|
||||
setupBottomNavigation()
|
||||
returnToBookcity()
|
||||
}
|
||||
|
||||
private fun setupNavigation() {
|
||||
categoryPage_navView.setCheckedItem(R.id.psychology)
|
||||
categoryPage_navView.setNavigationItemSelectedListener { menuItem ->
|
||||
startActivity(Intent(this, when (menuItem.itemId) {
|
||||
R.id.literature -> LiteratureActivity::class.java
|
||||
R.id.management -> ManagementActivity::class.java
|
||||
R.id.psychology -> PsychologyActivity::class.java
|
||||
R.id.science -> ScienceActivity::class.java
|
||||
R.id.philosophy -> PhilosophyActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}))
|
||||
categoryPage_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadBooks() {
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("category_id", 3)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>?, e: BmobException?) {
|
||||
categoryPage_swipeRefresh.isRefreshing = false
|
||||
if (e == null && list != null) {
|
||||
updateBookList(list)
|
||||
} else {
|
||||
Log.e("PsychologyActivity", "Error refreshing books: ${e?.message}", e)
|
||||
Toast.makeText(this@PsychologyActivity, "Failed to refresh books.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateBookList(list: List<Book_bmob>) {
|
||||
bookList.clear()
|
||||
bookList.addAll(list.map { Book(it.name, it.introduce, it.picture.url) })
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setupBottomNavigation() {
|
||||
bookcity.setOnClickListener {
|
||||
finish() // Simplify navigation logic
|
||||
}
|
||||
bookshelf.setOnClickListener {
|
||||
startActivity(Intent(this, BookShelfActivity::class.java))
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
startActivity(Intent(this, PerceptionActivity::class.java))
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
startActivity(Intent(this, MyActivity::class.java))
|
||||
}
|
||||
}
|
||||
private fun returnToBookcity(){
|
||||
categoryPage_back.setOnClickListener{
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
categoryPage_drawerLayout.openDrawer(GravityCompat.START)
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
110
app/src/main/java/com/zjgsu/jianshu/Activity/ScienceActivity.kt
Normal file
110
app/src/main/java/com/zjgsu/jianshu/Activity/ScienceActivity.kt
Normal file
@ -0,0 +1,110 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_categorypage.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
|
||||
class ScienceActivity:AppCompatActivity() {
|
||||
private lateinit var adapter: BookAdapter2
|
||||
private var bookList = ArrayList<Book>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_categorypage)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.menu)
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")
|
||||
val titleTextView = findViewById<TextView>(R.id.categoryPage_title)
|
||||
titleTextView.text = "科学"
|
||||
adapter = BookAdapter2(bookList)
|
||||
categoryPage_recyclerView.layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
|
||||
categoryPage_recyclerView.adapter = adapter
|
||||
categoryPage_swipeRefresh.setOnRefreshListener {
|
||||
loadBooks() //下拉刷新
|
||||
}
|
||||
setupNavigation()
|
||||
loadBooks()
|
||||
setupBottomNavigation()
|
||||
returnToBookcity()
|
||||
}
|
||||
|
||||
private fun setupNavigation() {
|
||||
categoryPage_navView.setCheckedItem(R.id.science)
|
||||
categoryPage_navView.setNavigationItemSelectedListener { menuItem ->
|
||||
startActivity(Intent(this, when (menuItem.itemId) {
|
||||
R.id.literature -> LiteratureActivity::class.java
|
||||
R.id.management -> ManagementActivity::class.java
|
||||
R.id.psychology -> PsychologyActivity::class.java
|
||||
R.id.science -> ScienceActivity::class.java
|
||||
R.id.philosophy -> PhilosophyActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}))
|
||||
categoryPage_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadBooks() {
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("category_id", 4)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>?, e: BmobException?) {
|
||||
categoryPage_swipeRefresh.isRefreshing = false
|
||||
if (e == null && list != null) {
|
||||
updateBookList(list)
|
||||
} else {
|
||||
Log.e("ScienceActivity", "Error refreshing books: ${e?.message}", e)
|
||||
Toast.makeText(this@ScienceActivity, "Failed to refresh books.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateBookList(list: List<Book_bmob>) {
|
||||
bookList.clear()
|
||||
bookList.addAll(list.map { Book(it.name, it.introduce, it.picture.url) })
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setupBottomNavigation() {
|
||||
bookcity.setOnClickListener {
|
||||
finish() // Simplify navigation logic
|
||||
}
|
||||
bookshelf.setOnClickListener {
|
||||
startActivity(Intent(this, BookShelfActivity::class.java))
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
startActivity(Intent(this, PerceptionActivity::class.java))
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
startActivity(Intent(this, MyActivity::class.java))
|
||||
}
|
||||
}
|
||||
private fun returnToBookcity(){
|
||||
categoryPage_back.setOnClickListener{
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
categoryPage_drawerLayout.openDrawer(GravityCompat.START)
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_wenxue.*
|
||||
import kotlinx.android.synthetic.main.activity_xinli.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class WenXueActivity:AppCompatActivity() {
|
||||
private var bookList = ArrayList<Book>()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_wenxue)
|
||||
supportActionBar?.let {
|
||||
it.setDisplayHomeAsUpEnabled(true)
|
||||
it.setHomeAsUpIndicator(R.drawable.menu)
|
||||
}
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
inits()
|
||||
val layoutManager =
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||
wenxue_recyclerView.layoutManager = layoutManager
|
||||
var adapter = BookAdapter2(bookList)
|
||||
wenxue_recyclerView.adapter = adapter
|
||||
wenxue_swipeRefresh.setOnRefreshListener {
|
||||
refreshBooks(adapter)
|
||||
}
|
||||
wenxue_navView.setCheckedItem(R.id.wenxue)
|
||||
wenxue_navView.setNavigationItemSelectedListener {
|
||||
val intentwenxue = Intent(this, WenXueActivity::class.java)
|
||||
val intentguanli = Intent(this, guanliActivity::class.java)
|
||||
val intentxinli = Intent(this, xinliActivity::class.java)
|
||||
val intentkexue=Intent(this,kexueActivity::class.java)
|
||||
val intentzhexue=Intent(this,zhexueActivity::class.java)
|
||||
val intentgood=Intent(this,MainActivity::class.java)
|
||||
when (it.itemId) {
|
||||
R.id.wenxue -> startActivity(intentwenxue)
|
||||
R.id.guanli -> startActivity(intentguanli)
|
||||
R.id.xinli -> startActivity(intentxinli)
|
||||
R.id.kexue->startActivity(intentkexue)
|
||||
R.id.zhexue->startActivity(intentzhexue)
|
||||
R.id.goodbook->startActivity(intentgood)
|
||||
}
|
||||
wenxue_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
|
||||
wenxue_back.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookcity.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookshelf.setOnClickListener{
|
||||
val intent = Intent(this, BookShelfActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
val intent = Intent(this, PerceptionActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
val intent = Intent(this, MyActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> wenxue_drawerLayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
return true
|
||||
}
|
||||
private fun inits() {
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==1){
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
// bookList2.add(Book(i.name, i.introduce))
|
||||
val adapter = BookAdapter2(bookList)
|
||||
wenxue_recyclerView.adapter = adapter
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun refreshBooks(adapter: BookAdapter2) {
|
||||
thread {
|
||||
Thread.sleep(2000)
|
||||
runOnUiThread {
|
||||
initBooks()
|
||||
adapter.notifyDataSetChanged()
|
||||
wenxue_swipeRefresh.isRefreshing = false
|
||||
Toast.makeText(this, "刷新成功!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun initBooks() {
|
||||
bookList.clear()
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==1)
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_info_bmob
|
||||
import kotlinx.android.synthetic.main.activity_anthor_introduction.*
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.book_author_item.*
|
||||
@ -56,10 +56,10 @@ class author_introductionActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
private fun inits() {
|
||||
val bmobQuery = BmobQuery<Book_inf_bmob>()
|
||||
val bmobQuery = BmobQuery<Book_info_bmob>()
|
||||
bmobQuery.addWhereEqualTo("author_name",book_authorname1.text.toString())
|
||||
bmobQuery.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
bmobQuery.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(flag==0){
|
||||
@ -80,8 +80,6 @@ class author_introductionActivity : AppCompatActivity() {
|
||||
val `in`: InputStream = connection.getInputStream()
|
||||
val bitmap: Bitmap =
|
||||
BitmapFactory.decodeStream(`in`)
|
||||
// Log.d("myLog","fine")
|
||||
//yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||
author_img.setImageBitmap(bitmap)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
@ -1,139 +0,0 @@
|
||||
package com.zjgsu.jianshu
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_guanli.*
|
||||
import kotlinx.android.synthetic.main.activity_xinli.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class guanliActivity:AppCompatActivity() {
|
||||
private var bookList = ArrayList<Book>()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_guanli)
|
||||
supportActionBar?.let {
|
||||
it.setDisplayHomeAsUpEnabled(true)
|
||||
it.setHomeAsUpIndicator(R.drawable.menu)
|
||||
}
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
inits()
|
||||
val layoutManager =
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||
guanli_recyclerView.layoutManager = layoutManager
|
||||
var adapter = BookAdapter2(bookList)
|
||||
guanli_recyclerView.adapter = adapter
|
||||
guanli_swipeRefresh.setOnRefreshListener {
|
||||
refreshBooks(adapter)
|
||||
}
|
||||
guanli_navView.setCheckedItem(R.id.guanli)
|
||||
guanli_navView.setNavigationItemSelectedListener {
|
||||
val intentwenxue = Intent(this, WenXueActivity::class.java)
|
||||
val intentguanli = Intent(this, guanliActivity::class.java)
|
||||
val intentxinli = Intent(this, xinliActivity::class.java)
|
||||
val intentkexue=Intent(this,kexueActivity::class.java)
|
||||
val intentzhexue=Intent(this,zhexueActivity::class.java)
|
||||
val intentgood=Intent(this,MainActivity::class.java)
|
||||
when (it.itemId) {
|
||||
R.id.wenxue -> startActivity(intentwenxue)
|
||||
R.id.guanli -> startActivity(intentguanli)
|
||||
R.id.kexue->startActivity(intentkexue)
|
||||
R.id.zhexue->startActivity(intentzhexue)
|
||||
R.id.xinli->startActivity(intentxinli)
|
||||
R.id.goodbook->startActivity(intentgood)
|
||||
}
|
||||
guanli_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
guanli_back.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookshelf.setOnClickListener{
|
||||
val intent = Intent(this, BookShelfActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookcity.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
val intent = Intent(this, PerceptionActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
val intent = Intent(this, MyActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> guanli_drawerLayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
return true
|
||||
}
|
||||
private fun inits() {
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==2){
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
// bookList2.add(Book(i.name, i.introduce))
|
||||
val adapter = BookAdapter2(bookList)
|
||||
guanli_recyclerView.adapter = adapter
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun refreshBooks(adapter: BookAdapter2) {
|
||||
thread {
|
||||
Thread.sleep(2000)
|
||||
runOnUiThread {
|
||||
initBooks()
|
||||
adapter.notifyDataSetChanged()
|
||||
guanli_swipeRefresh.isRefreshing = false
|
||||
Toast.makeText(this, "刷新成功!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun initBooks() {
|
||||
bookList.clear()
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==2)
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_kexue.*
|
||||
import kotlinx.android.synthetic.main.activity_xinli.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class kexueActivity:AppCompatActivity() {
|
||||
private var bookList = ArrayList<Book>()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_kexue)
|
||||
supportActionBar?.let {
|
||||
it.setDisplayHomeAsUpEnabled(true)
|
||||
it.setHomeAsUpIndicator(R.drawable.menu)
|
||||
}
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
inits()
|
||||
val layoutManager =
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||
kexue_recyclerView.layoutManager = layoutManager
|
||||
var adapter = BookAdapter2(bookList)
|
||||
kexue_recyclerView.adapter = adapter
|
||||
kexue_swipeRefresh.setOnRefreshListener {
|
||||
refreshBooks(adapter)
|
||||
}
|
||||
kexue_navView.setCheckedItem(R.id.kexue)
|
||||
kexue_navView.setNavigationItemSelectedListener {
|
||||
val intentwenxue = Intent(this, WenXueActivity::class.java)
|
||||
val intentguanli = Intent(this, guanliActivity::class.java)
|
||||
val intentxinli = Intent(this, xinliActivity::class.java)
|
||||
val intentkexue=Intent(this,kexueActivity::class.java)
|
||||
val intentzhexue=Intent(this,zhexueActivity::class.java)
|
||||
val intentgood=Intent(this,MainActivity::class.java)
|
||||
when (it.itemId) {
|
||||
R.id.wenxue -> startActivity(intentwenxue)
|
||||
R.id.guanli -> startActivity(intentguanli)
|
||||
R.id.xinli -> startActivity(intentxinli)
|
||||
R.id.kexue->startActivity(intentkexue)
|
||||
R.id.zhexue->startActivity(intentzhexue)
|
||||
R.id.goodbook->startActivity(intentgood)
|
||||
}
|
||||
kexue_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
|
||||
kexue_back.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookcity.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookshelf.setOnClickListener{
|
||||
val intent = Intent(this, BookShelfActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
val intent = Intent(this, PerceptionActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
val intent = Intent(this, MyActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> kexue_drawerLayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
return true
|
||||
}
|
||||
private fun inits() {
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==4){
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
// bookList2.add(Book(i.name, i.introduce))
|
||||
val adapter = BookAdapter2(bookList)
|
||||
kexue_recyclerView.adapter = adapter
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun refreshBooks(adapter: BookAdapter2) {
|
||||
thread {
|
||||
Thread.sleep(2000)
|
||||
runOnUiThread {
|
||||
initBooks()
|
||||
adapter.notifyDataSetChanged()
|
||||
kexue_swipeRefresh.isRefreshing = false
|
||||
Toast.makeText(this, "刷新成功!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun initBooks() {
|
||||
bookList.clear()
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==4)
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import cn.bmob.v3.listener.SaveListener
|
||||
import com.zjgsu.jianshu.*
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_info_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Perception_bmob
|
||||
import com.zjgsu.jianshu.Bmob.User_bmob
|
||||
import kotlinx.android.synthetic.main.activity_sendperception.*
|
||||
@ -75,9 +75,9 @@ class sendPerceptionActivity:AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
private fun inits(){
|
||||
val bmobQuery = BmobQuery<Book_inf_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
val bmobQuery = BmobQuery<Book_info_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
bookList.add(BookAuthor(i.name, i.author_name))
|
||||
|
@ -1,138 +0,0 @@
|
||||
package com.zjgsu.jianshu
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_xinli.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class xinliActivity:AppCompatActivity() {
|
||||
private var bookList = ArrayList<Book>()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_xinli)
|
||||
supportActionBar?.let {
|
||||
it.setDisplayHomeAsUpEnabled(true)
|
||||
it.setHomeAsUpIndicator(R.drawable.menu)
|
||||
}
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
inits()
|
||||
val layoutManager =
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||
xinli_recyclerView.layoutManager = layoutManager
|
||||
var adapter = BookAdapter2(bookList)
|
||||
xinli_recyclerView.adapter = adapter
|
||||
xinli_swipeRefresh.setOnRefreshListener {
|
||||
refreshBooks(adapter)
|
||||
}
|
||||
xinli_navView.setCheckedItem(R.id.xinli)
|
||||
xinli_navView.setNavigationItemSelectedListener {
|
||||
val intentwenxue = Intent(this, WenXueActivity::class.java)
|
||||
val intentguanli = Intent(this, guanliActivity::class.java)
|
||||
val intentxinli = Intent(this, xinliActivity::class.java)
|
||||
val intentkexue=Intent(this,kexueActivity::class.java)
|
||||
val intentzhexue=Intent(this,zhexueActivity::class.java)
|
||||
val intentgood=Intent(this,MainActivity::class.java)
|
||||
when (it.itemId) {
|
||||
R.id.wenxue -> startActivity(intentwenxue)
|
||||
R.id.guanli -> startActivity(intentguanli)
|
||||
R.id.kexue->startActivity(intentkexue)
|
||||
R.id.zhexue->startActivity(intentzhexue)
|
||||
R.id.xinli->startActivity(intentxinli)
|
||||
R.id.goodbook->startActivity(intentgood)
|
||||
}
|
||||
xinli_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
xinli_back.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookshelf.setOnClickListener{
|
||||
val intent = Intent(this, BookShelfActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookcity.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
val intent = Intent(this, PerceptionActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
val intent = Intent(this, MyActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> xinli_drawerLayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
return true
|
||||
}
|
||||
private fun inits() {
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==3){
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
// bookList2.add(Book(i.name, i.introduce))
|
||||
val adapter = BookAdapter2(bookList)
|
||||
xinli_recyclerView.adapter = adapter
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun refreshBooks(adapter: BookAdapter2) {
|
||||
thread {
|
||||
Thread.sleep(2000)
|
||||
runOnUiThread {
|
||||
initBooks()
|
||||
adapter.notifyDataSetChanged()
|
||||
xinli_swipeRefresh.isRefreshing = false
|
||||
Toast.makeText(this, "刷新成功!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun initBooks() {
|
||||
bookList.clear()
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==3)
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import cn.bmob.v3.Bmob
|
||||
import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Adapter.BookAdapter2
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.activity_zhexue.*
|
||||
import kotlinx.android.synthetic.main.activity_xinli.*
|
||||
import kotlinx.android.synthetic.main.layout_bottom_navigation.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class zhexueActivity:AppCompatActivity() {
|
||||
private var bookList = ArrayList<Book>()
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_zhexue)
|
||||
supportActionBar?.let {
|
||||
it.setDisplayHomeAsUpEnabled(true)
|
||||
it.setHomeAsUpIndicator(R.drawable.menu)
|
||||
}
|
||||
Bmob.initialize(this, "8f9f1d1ea520b0ce4f84a6fa83a5f754")//连接bmob
|
||||
inits()
|
||||
val layoutManager =
|
||||
StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)//第一个参数是列数
|
||||
zhexue_recyclerView.layoutManager = layoutManager
|
||||
var adapter = BookAdapter2(bookList)
|
||||
zhexue_recyclerView.adapter = adapter
|
||||
zhexue_swipeRefresh.setOnRefreshListener {
|
||||
refreshBooks(adapter)
|
||||
}
|
||||
zhexue_navView.setCheckedItem(R.id.zhexue)
|
||||
zhexue_navView.setNavigationItemSelectedListener {
|
||||
val intentwenxue = Intent(this, WenXueActivity::class.java)
|
||||
val intentguanli = Intent(this, guanliActivity::class.java)
|
||||
val intentxinli = Intent(this, xinliActivity::class.java)
|
||||
val intentzhexue=Intent(this,zhexueActivity::class.java)
|
||||
val intentkexue=Intent(this,kexueActivity::class.java)
|
||||
val intentgood=Intent(this,MainActivity::class.java)
|
||||
when (it.itemId) {
|
||||
R.id.wenxue -> startActivity(intentwenxue)
|
||||
R.id.guanli -> startActivity(intentguanli)
|
||||
R.id.xinli -> startActivity(intentxinli)
|
||||
R.id.zhexue->startActivity(intentzhexue)
|
||||
R.id.kexue->startActivity(intentkexue)
|
||||
R.id.goodbook->startActivity(intentgood)
|
||||
}
|
||||
zhexue_drawerLayout.closeDrawers()
|
||||
true
|
||||
}
|
||||
|
||||
zhexue_back.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookcity.setOnClickListener{
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
bookshelf.setOnClickListener{
|
||||
val intent = Intent(this, BookShelfActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
reading_comprehension.setOnClickListener {
|
||||
val intent = Intent(this, PerceptionActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
homepage.setOnClickListener {
|
||||
val intent = Intent(this, MyActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> zhexue_drawerLayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
return true
|
||||
}
|
||||
private fun inits() {
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==5){
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
// bookList2.add(Book(i.name, i.introduce))
|
||||
val adapter = BookAdapter2(bookList)
|
||||
zhexue_recyclerView.adapter = adapter
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun refreshBooks(adapter: BookAdapter2) {
|
||||
thread {
|
||||
Thread.sleep(2000)
|
||||
runOnUiThread {
|
||||
initBooks()
|
||||
adapter.notifyDataSetChanged()
|
||||
zhexue_swipeRefresh.isRefreshing = false
|
||||
Toast.makeText(this, "刷新成功!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun initBooks() {
|
||||
bookList.clear()
|
||||
val bmobQuery = BmobQuery<Book_bmob>()
|
||||
bmobQuery.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(list: List<Book_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if(i.category_id==5)
|
||||
bookList.add(Book(i.name, i.introduce,i.picture.url))
|
||||
}
|
||||
} else {
|
||||
Log.d("error", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.zjgsu.jianshu.Adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.transition.Transition
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import com.zjgsu.jianshu.*
|
||||
|
||||
class BillboardAdapter(var listOfbookRankList: List<List<Book_rank>>) : RecyclerView.Adapter<BillboardAdapter.ViewHolder>() {
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val bookRank_title:TextView=view.findViewById(R.id.bookRank_title)
|
||||
val bookRank_name1: TextView = view.findViewById(R.id.bookRank_name1)
|
||||
val bookRank_pic1: ImageView = view.findViewById(R.id.bookRank_pic1)
|
||||
val bookRank_decr1: TextView = view.findViewById(R.id.bookRank_desc1)
|
||||
val bookRank_name2: TextView= view.findViewById(R.id.bookRank_name2)
|
||||
val bookRank_pic2: ImageView = view.findViewById(R.id.bookRank_pic2)
|
||||
val bookRank_decr2: TextView = view.findViewById(R.id.bookRank_desc2)
|
||||
val bookRank_name3: TextView = view.findViewById(R.id.bookRank_name3)
|
||||
val bookRank_pic3: ImageView = view.findViewById(R.id.bookRank_pic3)
|
||||
val bookRank_decr3: TextView = view.findViewById(R.id.bookRank_desc3)
|
||||
val bookRank_backimg:LinearLayout=view.findViewById(R.id.bookRank_backimg)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.book_rank_item, parent, false)
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val bookRankList = listOfbookRankList[position]
|
||||
Log.d("BillboardAdapter", "Size of bookRankList at position $position")
|
||||
if(position==0) {
|
||||
holder.bookRank_title.text="热门图书榜"
|
||||
holder.bookRank_decr1.text = "在读人数:"+bookRankList[0].courtOfReaders.toString()
|
||||
holder.bookRank_decr2.text = "在读人数:"+bookRankList[1].courtOfReaders.toString()
|
||||
holder.bookRank_decr3.text = "在读人数:"+bookRankList[2].courtOfReaders.toString()
|
||||
holder.bookRank_backimg.setOnClickListener {
|
||||
val intent = Intent(holder.itemView.context, HotBookActivity::class.java)
|
||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||
}
|
||||
}
|
||||
else{
|
||||
holder.bookRank_title.text="高分图书榜"
|
||||
holder.bookRank_decr1.text = "简书推荐值:"+bookRankList[0].score
|
||||
holder.bookRank_decr2.text = "简书推荐值:"+bookRankList[1].score
|
||||
holder.bookRank_decr3.text = "简书推荐值:"+bookRankList[2].score
|
||||
|
||||
}
|
||||
holder.bookRank_name1.text = bookRankList[0].name
|
||||
Glide.with(holder.itemView.context)
|
||||
.load(bookRankList[0].picUrl) // 确保你的Book对象有正确的图片URL
|
||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
||||
.into(holder.bookRank_pic1)
|
||||
holder.bookRank_name2.text = bookRankList[1].name
|
||||
Glide.with(holder.itemView.context)
|
||||
.load(bookRankList[1].picUrl) // 确保你的Book对象有正确的图片URL
|
||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
||||
.into(holder.bookRank_pic2)
|
||||
holder.bookRank_name3.text = bookRankList[2].name
|
||||
Glide.with(holder.itemView.context)
|
||||
.load(bookRankList[2].picUrl) // 确保你的Book对象有正确的图片URL
|
||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
||||
.into(holder.bookRank_pic3)
|
||||
}
|
||||
override fun getItemCount() = listOfbookRankList.size
|
||||
}
|
@ -3,6 +3,7 @@ package com.zjgsu.jianshu
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -14,6 +15,7 @@ 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.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import java.io.InputStream
|
||||
import java.net.HttpURLConnection
|
||||
@ -49,36 +51,13 @@ inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
else if(position==2){
|
||||
holder.rankimg.setImageResource(R.drawable.copper)
|
||||
}
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("name", book.name)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(p0: MutableList<Book_bmob>?, p1: BmobException?) {
|
||||
if (p1 == null) {
|
||||
if (p0 != null && p0.size > 0) {
|
||||
for (p in p0) {
|
||||
object : Thread() {
|
||||
override fun run() {
|
||||
try {
|
||||
val url = URL(p!!.picture.url)
|
||||
val connection: HttpURLConnection =
|
||||
url.openConnection() as HttpURLConnection
|
||||
connection.setRequestMethod("GET")
|
||||
connection.setConnectTimeout(5000)
|
||||
val `in`: InputStream = connection.getInputStream()
|
||||
val bitmap: Bitmap =
|
||||
BitmapFactory.decodeStream(`in`)
|
||||
holder.bookList_Image.setImageBitmap(bitmap)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// Glide.with(context).load(book.imageId).into(holder.bookList_Image)
|
||||
else holder.rankimg.setImageDrawable(null)
|
||||
|
||||
Glide.with(holder.itemView.context)
|
||||
.load(book.picUrl) // 确保你的Book对象有正确的图片URL
|
||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
||||
.into(holder.bookList_Image)
|
||||
holder.outerLinearLayout.setOnClickListener{
|
||||
val intent = Intent(holder.itemView.context, Book_informationActivity::class.java)
|
||||
intent.putExtra("Book_name", book.name)
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.zjgsu.jianshu.Adapter
|
||||
|
||||
import com.zjgsu.jianshu.Book
|
||||
import com.zjgsu.jianshu.Book_informationActivity
|
||||
import com.zjgsu.jianshu.R
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
@ -12,6 +9,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.ActivityChooserView
|
||||
import androidx.core.content.ContextCompat
|
||||
@ -21,6 +19,7 @@ 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.zjgsu.jianshu.*
|
||||
import com.zjgsu.jianshu.Bmob.Book_bmob
|
||||
import java.io.InputStream
|
||||
import java.net.HttpURLConnection
|
||||
@ -32,58 +31,23 @@ class BookAdapter2(val bookList: List<Book>) : RecyclerView.Adapter<BookAdapter2
|
||||
val bookList_Image: ImageView = view.findViewById(R.id.book_Image)
|
||||
val bookList_Name: TextView = view.findViewById(R.id.book_Name)
|
||||
val bookList_Introduce: TextView = view.findViewById(R.id.book_Introduce)
|
||||
val outerLinearLayout: LinearLayout =view.findViewById(R.id.bookItem_outerLinearLayout)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = View.inflate(parent.context, R.layout.book_item, null)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookAdapter2.ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.book_item, parent, false)
|
||||
return ViewHolder(view)
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val book = bookList[position]
|
||||
holder.bookList_Name.text = book.name
|
||||
holder.bookList_Introduce.text = book.introduce
|
||||
val query = BmobQuery<Book_bmob>()
|
||||
query.addWhereEqualTo("name", book.name)
|
||||
query.findObjects(object : FindListener<Book_bmob>() {
|
||||
override fun done(p0: MutableList<Book_bmob>?, p1: BmobException?) {
|
||||
if (p1 == null) {
|
||||
if (p0 != null && p0.size > 0) {
|
||||
for (p in p0) {
|
||||
object : Thread() {
|
||||
override fun run() {
|
||||
try {
|
||||
val url = URL(p!!.picture.url)
|
||||
val connection: HttpURLConnection =
|
||||
url.openConnection() as HttpURLConnection
|
||||
connection.setRequestMethod("GET")
|
||||
connection.setConnectTimeout(5000)
|
||||
val `in`: InputStream = connection.getInputStream()
|
||||
val bitmap: Bitmap =
|
||||
BitmapFactory.decodeStream(`in`)
|
||||
holder.bookList_Image.setImageBitmap(bitmap)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// Glide.with(context).load(book.imageId).into(holder.bookList_Image)
|
||||
|
||||
holder.bookList_Image.setOnClickListener {
|
||||
val intent = Intent(holder.itemView.context, Book_informationActivity::class.java)
|
||||
intent.putExtra("Book_name", book.name)
|
||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||
}
|
||||
holder.bookList_Introduce.setOnClickListener {
|
||||
val intent = Intent(holder.itemView.context, Book_informationActivity::class.java)
|
||||
intent.putExtra("Book_name", book.name)
|
||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||
}
|
||||
holder.bookList_Name.setOnClickListener {
|
||||
Glide.with(holder.itemView.context)
|
||||
.load(book.picUrl) // 确保你的Book对象有正确的图片URL
|
||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
||||
.into(holder.bookList_Image)
|
||||
holder.outerLinearLayout.setOnClickListener{
|
||||
val intent = Intent(holder.itemView.context, Book_informationActivity::class.java)
|
||||
intent.putExtra("Book_name", book.name)
|
||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||
|
@ -0,0 +1,64 @@
|
||||
package com.zjgsu.jianshu.Adapter
|
||||
|
||||
import android.content.Intent
|
||||
import android.media.Image
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.zjgsu.jianshu.*
|
||||
|
||||
class BookRankAdapter(var bookList: List<Book_rank>): RecyclerView.Adapter<BookRankAdapter.ViewHolder>() {
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val bookrank_pic:ImageView=view.findViewById(R.id.bookrank_pic)
|
||||
val bookrank_intro:TextView=view.findViewById(R.id.bookrank_intro)
|
||||
val bookrank_name:TextView=view.findViewById(R.id.bookrank_name)
|
||||
val bookrank_desc:TextView=view.findViewById(R.id.bookrank_desc)
|
||||
val innerLinearLayout: LinearLayout = view.findViewById(R.id.bookrank_innerLinearLayout)
|
||||
val outerLinearLayout:LinearLayout=view.findViewById(R.id.bookrank_outerLinearLayout)
|
||||
val bookrank_author:TextView=view.findViewById(R.id.bookrank_author)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.book_rank2_item, parent, false)
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val book = bookList[position]
|
||||
holder.bookrank_name.text = book.name
|
||||
holder.bookrank_intro.text = book.intro
|
||||
val backgrounds = arrayOf(
|
||||
R.drawable.color_lightpurple, R.drawable.color_lightblue,
|
||||
R.drawable.color_lightgreen, R.drawable.color_flesh)
|
||||
holder.innerLinearLayout.setBackgroundResource(backgrounds[position % backgrounds.size])
|
||||
holder.bookrank_desc.text="在读人数:"+book.courtOfReaders
|
||||
holder.bookrank_author.text=book.author
|
||||
// if (position == 0) { // 假设第一名使用金牌图片
|
||||
// holder.rankimg.setImageResource(R.drawable.gold)
|
||||
// } else if (position == 1) { // 第二名使用其他图片,以此类推
|
||||
// holder.rankimg.setImageResource(R.drawable.silver)
|
||||
// }
|
||||
// else if(position==2){
|
||||
// holder.rankimg.setImageResource(R.drawable.copper)
|
||||
// }
|
||||
// else holder.rankimg.setImageDrawable(null)
|
||||
|
||||
Glide.with(holder.itemView.context)
|
||||
.load(book.picUrl) // 确保你的Book对象有正确的图片URL
|
||||
.placeholder(R.drawable.pre_load) // 可以设置一个占位图
|
||||
.error(R.drawable.fail_load) // 设置加载失败的图
|
||||
.into(holder.bookrank_pic)
|
||||
holder.outerLinearLayout.setOnClickListener{
|
||||
val intent = Intent(holder.itemView.context, Book_informationActivity::class.java)
|
||||
intent.putExtra("Book_name", book.name)
|
||||
ContextCompat.startActivity(holder.itemView.context, intent, null)
|
||||
}
|
||||
}
|
||||
override fun getItemCount() = bookList.size
|
||||
}
|
@ -15,7 +15,7 @@ import cn.bmob.v3.BmobQuery
|
||||
import cn.bmob.v3.exception.BmobException
|
||||
import cn.bmob.v3.listener.FindListener
|
||||
import com.zjgsu.jianshu.Activity.Perception_informationActivity
|
||||
import com.zjgsu.jianshu.Bmob.Book_inf_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Book_info_bmob
|
||||
import com.zjgsu.jianshu.Bmob.Perception_bmob
|
||||
import com.zjgsu.jianshu.Bmob.User_bmob
|
||||
import java.io.InputStream
|
||||
@ -110,9 +110,9 @@ class PerceptionAdapter(val perceptionList: List<Perception>) : RecyclerView.Ada
|
||||
Log.d("myLog", p.b_name)
|
||||
bookName=p.b_name
|
||||
holder.perceptionList_bookName.text=bookName
|
||||
val queryBook = BmobQuery<Book_inf_bmob>()
|
||||
queryBook.findObjects(object : FindListener<Book_inf_bmob>() {
|
||||
override fun done(list: List<Book_inf_bmob>, e: BmobException?) {
|
||||
val queryBook = BmobQuery<Book_info_bmob>()
|
||||
queryBook.findObjects(object : FindListener<Book_info_bmob>() {
|
||||
override fun done(list: List<Book_info_bmob>, e: BmobException?) {
|
||||
if (e == null) {
|
||||
for (i in list) {
|
||||
if (p.b_name.equals(i.name)) {
|
||||
|
@ -8,9 +8,5 @@ class Book_bmob: BmobObject(){
|
||||
var name:String=""
|
||||
var picture: BmobFile=BmobFile()
|
||||
var introduce:String=""
|
||||
var tuijian:Int=0
|
||||
var yiban:Int=0
|
||||
var buxing:Int=0
|
||||
var category_id:Int=0
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.zjgsu.jianshu.Bmob
|
||||
import cn.bmob.v3.BmobObject
|
||||
import cn.bmob.v3.datatype.BmobFile
|
||||
|
||||
class Book_inf_bmob:BmobObject(){
|
||||
class Book_info_bmob:BmobObject(){
|
||||
var name: String=""
|
||||
var picture: BmobFile= BmobFile()
|
||||
var introduce: String=""
|
||||
@ -14,6 +14,7 @@ class Book_inf_bmob:BmobObject(){
|
||||
var yiban:Int=0
|
||||
var tuijian:Int=0
|
||||
var buxing:Int=0
|
||||
var countOfReaders:Int=0
|
||||
fun settuijian(tuijian1: Int){
|
||||
this.tuijian=tuijian1
|
||||
}
|
||||
|
9
app/src/main/java/com/zjgsu/jianshu/Book_rank.kt
Normal file
9
app/src/main/java/com/zjgsu/jianshu/Book_rank.kt
Normal file
@ -0,0 +1,9 @@
|
||||
package com.zjgsu.jianshu
|
||||
|
||||
class Book_rank(var name: String,
|
||||
var picUrl: String,
|
||||
var score:String,
|
||||
var courtOfReaders:Int,
|
||||
var author:String,
|
||||
var intro:String
|
||||
)
|
BIN
app/src/main/res/drawable/addbook.png
Normal file
BIN
app/src/main/res/drawable/addbook.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 701 B |
BIN
app/src/main/res/drawable/alreadyin.png
Normal file
BIN
app/src/main/res/drawable/alreadyin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 681 B |
BIN
app/src/main/res/drawable/fail_load.png
Normal file
BIN
app/src/main/res/drawable/fail_load.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
app/src/main/res/drawable/loading.png
Normal file
BIN
app/src/main/res/drawable/loading.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/drawable/pre_load.png
Normal file
BIN
app/src/main/res/drawable/pre_load.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
67
app/src/main/res/layout/activity_bookrank.xml
Normal file
67
app/src/main/res/layout/activity_bookrank.xml
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/categoryPage_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 左侧返回按钮和推荐标题 -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bookrank_return"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/return1" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<!-- 标题 -->
|
||||
<TextView
|
||||
android:id="@+id/bookrank_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif"
|
||||
android:text="文学"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif"
|
||||
android:text="10本"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="60dp">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/bookrank_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/bookrank_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -1,189 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawerLayout_bookshelf"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<!-- SwipeRefreshLayout 包裹的 RecyclerView -->
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/layout_bottom_navigation"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:background="@drawable/wenli">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh2"
|
||||
android:background="@drawable/wenli"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<!-- 底部导航栏 -->
|
||||
<include
|
||||
android:id="@+id/layout_bottom_navigation"
|
||||
layout="@layout/layout_bottom_navigation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:id="@+id/ll_mycollection_bottom_dialog"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="42dp"-->
|
||||
<!-- android:layout_alignParentBottom="true"-->
|
||||
<!-- android:layout_gravity="bottom"-->
|
||||
<!-- android:background="@color/myblue"-->
|
||||
<!-- android:orientation="vertical"-->
|
||||
<!-- android:visibility="gone">-->
|
||||
|
||||
|
||||
<!-- <View-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="1px"-->
|
||||
<!-- android:background="#e5e5e5" />-->
|
||||
|
||||
<!-- <RelativeLayout-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="90px"-->
|
||||
<!-- android:background="@color/white">-->
|
||||
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:layout_marginLeft="30px"-->
|
||||
<!-- android:text="select"-->
|
||||
<!-- android:textColor="#1A1A1A"-->
|
||||
<!-- android:textSize="28px" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv_select_num"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:layout_marginLeft="18px"-->
|
||||
<!-- android:layout_toRightOf="@+id/tv"-->
|
||||
<!-- android:text="0"-->
|
||||
<!-- android:textColor="#1A1A1A"-->
|
||||
<!-- android:textSize="28px" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_delete"-->
|
||||
<!-- android:layout_width="160px"-->
|
||||
<!-- android:layout_height="66px"-->
|
||||
<!-- android:layout_alignParentRight="true"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:layout_marginRight="30px"-->
|
||||
<!-- android:background="@color/myblue"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="删除"-->
|
||||
<!-- android:textSize="28px" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/select_all"-->
|
||||
<!-- android:layout_width="160px"-->
|
||||
<!-- android:layout_height="66px"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:layout_marginRight="30px"-->
|
||||
<!-- android:layout_toLeftOf="@+id/btn_delete"-->
|
||||
<!-- android:background="@color/myblue"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="全选"-->
|
||||
<!-- android:textColor="#000001"-->
|
||||
<!-- android:textSize="28px" />-->
|
||||
|
||||
<!-- </RelativeLayout>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_alignParentBottom="true"-->
|
||||
<!-- android:background="@color/mywhite"-->
|
||||
<!-- android:orientation="horizontal">-->
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="vertical">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/bookself_recommend"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="35dp"-->
|
||||
<!-- android:layout_weight="1"-->
|
||||
<!-- android:src="@drawable/bookcity1" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="100dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="书城"></TextView>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="vertical">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/bookself_bookshelf"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="35dp"-->
|
||||
<!-- android:layout_weight="1"-->
|
||||
<!-- android:src="@drawable/bookshelf2" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="100dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="书架"></TextView>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="vertical">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/bookself_reading_comprehension"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="35dp"-->
|
||||
<!-- android:layout_weight="1"-->
|
||||
<!-- android:src="@drawable/note1" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="100dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="随笔"></TextView>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="vertical">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
|
||||
<!-- android:id="@+id/bookself_self"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="35dp"-->
|
||||
<!-- android:layout_weight="1"-->
|
||||
<!-- android:src="@drawable/my1" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="100dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- android:text="我的"></TextView>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<!-- </LinearLayout>-->
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
</RelativeLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
91
app/src/main/res/layout/activity_categorypage.xml
Normal file
91
app/src/main/res/layout/activity_categorypage.xml
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/categoryPage_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 左侧返回按钮和推荐标题 -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/categoryPage_back"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/return1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 标题 -->
|
||||
<TextView
|
||||
android:id="@+id/categoryPage_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="文学"
|
||||
android:textSize="30dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/black"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/categoryPage_swipeRefresh"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 主内容区域 -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp">
|
||||
|
||||
<!-- SwipeRefreshLayout 包裹的 RecyclerView -->
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/categoryPage_swipeRefresh"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/layout_bottom_navigation"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/categoryPage_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<!-- 底部导航栏 -->
|
||||
<include
|
||||
layout="@layout/layout_bottom_navigation"
|
||||
android:id="@+id/layout_bottom_navigation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- 导航栏 -->
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/categoryPage_navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/guanli_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/guanli_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@drawable/return2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/guanli_tuijian"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="推荐好书"
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/guanli_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="管理"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp"
|
||||
android:orientation="vertical">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/guanli_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/guanli_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/guanli_navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/kexue_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/kexue_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@drawable/return2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/kexue_tuijian"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="推荐好书"
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/kexue_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="科学"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp"
|
||||
android:orientation="vertical">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/kexue_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/kexue_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/kexue_navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -1,70 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!-- <androidx.appcompat.widget.Toolbar-->
|
||||
<!-- android:id="@+id/toolbar"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_marginTop="0dp"-->
|
||||
<!-- android:layout_height="?attr/actionBarSize"-->
|
||||
<!-- android:background="@color/myblue"-->
|
||||
<!-- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"-->
|
||||
<!-- app:popupTheme="@style/ThemeOverlay.AppCompat.Light">-->
|
||||
<!-- </androidx.appcompat.widget.Toolbar>-->
|
||||
<LinearLayout
|
||||
|
||||
<!-- 主要内容布局 -->
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<SearchView
|
||||
android:id="@+id/main_searchview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/edit_bg"
|
||||
android:iconifiedByDefault="false"
|
||||
android:queryHint="输入书名搜索" >
|
||||
</SearchView>
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_weight="1"
|
||||
android:text="图书榜单TOP15"/>
|
||||
</LinearLayout>
|
||||
<!-- AppBarLayout 包裹 SearchView -->
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="75dp"
|
||||
android:orientation="vertical">
|
||||
<SearchView
|
||||
android:id="@+id/main_searchview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/edit_bg"
|
||||
android:iconifiedByDefault="false"
|
||||
android:queryHint="输入书名搜索" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh"
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<!-- SwipeRefreshLayout 包裹 NestedScrollView -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="简书榜单"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/horizontal_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="找好书"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<!-- 底部导航栏布局 -->
|
||||
<include
|
||||
android:id="@+id/layout_bottom_navigation"
|
||||
layout="@layout/layout_bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<!-- 左侧导航栏 -->
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
|
||||
|
@ -8,34 +8,38 @@
|
||||
android:background="@drawable/black"
|
||||
tools:context=".PerceptionActivity">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/perception_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/perception_swipeRefresh"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/layout_bottom_navigation"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/perception_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
</RelativeLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<include
|
||||
layout="@layout/layout_bottom_navigation"
|
||||
android:id="@+id/layout_bottom_navigation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@android:drawable/stat_notify_more"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/linearLayout"
|
||||
app:layout_constraintTop_toTopOf="@+id/linearLayout" />
|
||||
app:layout_constraintBottom_toTopOf="@id/layout_bottom_navigation"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/wenxue_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/wenxue_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@drawable/return2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wenxue_tuijian"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="推荐好书"
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wenxue_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="文学"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp"
|
||||
android:orientation="vertical">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/wenxue_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/wenxue_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/wenxue_navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/xinli_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/xinli_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@drawable/return2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/xinli_tuijian"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="推荐好书"
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/xinli_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="心理"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp"
|
||||
android:orientation="vertical">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/xinli_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/xinli_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/xinli_navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/zhexue_drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/zhexue_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@drawable/return2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/zhexue_tuijian"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="推荐好书"
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/zhexue_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="哲学"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp"
|
||||
android:orientation="vertical">
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/zhexue_swipeRefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/zhexue_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<include layout="@layout/layout_bottom_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/zhexue_navView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
app:menu="@menu/nav_menu" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -17,8 +17,8 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="10dp">
|
||||
android:layout_marginLeft="5dp"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
115
app/src/main/res/layout/book_rank2_item.xml
Normal file
115
app/src/main/res/layout/book_rank2_item.xml
Normal file
@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bookrank_outerLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<!-- 第一行:图书封面和简介 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 图书封面 -->
|
||||
<ImageView
|
||||
android:id="@+id/bookrank_pic"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="50"
|
||||
android:src="@drawable/pre_load" /> <!-- 替换为实际的封面图片资源 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/bookrank_innerLinearLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<!-- 书籍简介 -->
|
||||
<TextView
|
||||
android:id="@+id/bookrank_intro"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:maxLines="8"
|
||||
android:ellipsize="end"
|
||||
android:text="书籍简介" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 分割线 -->
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:layout_marginVertical="8dp" />
|
||||
|
||||
<!-- 第二行:书名评分和喜欢图标 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<!-- 书名和评分 -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 书名 -->
|
||||
<TextView
|
||||
android:id="@+id/bookrank_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="书名"
|
||||
android:textAppearance="?attr/textAppearanceListItem" />
|
||||
|
||||
<!-- 评分 -->
|
||||
<TextView
|
||||
android:id="@+id/bookrank_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="评分 8.5"
|
||||
android:textSize="14sp" />
|
||||
<TextView
|
||||
android:id="@+id/bookrank_author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="作者名称"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 喜欢图标和文字 -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivLikeIcon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/addBook" /> <!-- 替换为实际的喜欢图标资源 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLikeText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="想读"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
174
app/src/main/res/layout/book_rank_item.xml
Normal file
174
app/src/main/res/layout/book_rank_item.xml
Normal file
@ -0,0 +1,174 @@
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_margin="10dp"
|
||||
app:cardCornerRadius="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bookRank_backimg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#80F0FFF0"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookRank_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="热门图书榜"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 三本书的条目 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookRank_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="1"
|
||||
android:textSize="16sp">
|
||||
</TextView>
|
||||
<!-- 图书封面 -->
|
||||
<ImageView
|
||||
android:id="@+id/bookRank_pic1"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:src="@drawable/pre_load" /> <!-- 假设你有一个名为book_cover的图片资源 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<!-- 图书名称 -->
|
||||
<TextView
|
||||
android:id="@+id/bookRank_name1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="图书标题"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 图书评分 -->
|
||||
<TextView
|
||||
android:id="@+id/bookRank_desc1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="8.5"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/bookRank_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="2"
|
||||
android:textSize="16sp">
|
||||
</TextView>
|
||||
|
||||
<!-- 图书封面 -->
|
||||
<ImageView
|
||||
android:id="@+id/bookRank_pic2"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:src="@drawable/pre_load" /> <!-- 假设你有一个名为book_cover的图片资源 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<!-- 图书名称 -->
|
||||
<TextView
|
||||
android:id="@+id/bookRank_name2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="图书标题"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 图书评分 -->
|
||||
<TextView
|
||||
android:id="@+id/bookRank_desc2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="8.5"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/bookRank_3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="3"
|
||||
android:textSize="16sp">
|
||||
</TextView>
|
||||
<!-- 图书封面 -->
|
||||
<ImageView
|
||||
android:id="@+id/bookRank_pic3"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:src="@drawable/pre_load" /> <!-- 假设你有一个名为book_cover的图片资源 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<!-- 图书名称 -->
|
||||
<TextView
|
||||
android:id="@+id/bookRank_name3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="图书标题"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 图书评分 -->
|
||||
<TextView
|
||||
android:id="@+id/bookRank_desc3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="8.5"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
36
app/src/main/res/layout/item_book.xml
Normal file
36
app/src/main/res/layout/item_book.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bookRank_Image"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="150dp"
|
||||
android:src="@drawable/pre_load" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookRank_Name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="图书标题"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookRank_Desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="8.5"
|
||||
android:textSize="14sp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -10,11 +10,12 @@
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/bookcity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/bookcity1" />
|
||||
<TextView
|
||||
@ -27,13 +28,14 @@
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/bookshelf"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/bookshelf2" />
|
||||
android:src="@drawable/bookshelf1" />
|
||||
<TextView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
@ -44,11 +46,12 @@
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/reading_comprehension"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/note1" />
|
||||
<TextView
|
||||
@ -61,11 +64,12 @@
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/homepage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/my1" />
|
||||
<TextView
|
||||
|
@ -2,27 +2,27 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/wenxue"
|
||||
android:id="@+id/literature"
|
||||
android:icon="@drawable/wenxue"
|
||||
android:title="文学" />
|
||||
<item
|
||||
android:id="@+id/guanli"
|
||||
android:id="@+id/management"
|
||||
android:icon="@android:drawable/ic_input_get"
|
||||
android:title="管理学" />
|
||||
<item
|
||||
android:id="@+id/xinli"
|
||||
android:id="@+id/psychology"
|
||||
android:icon="@drawable/xinli"
|
||||
android:title="心理学" />
|
||||
<item
|
||||
android:id="@+id/kexue"
|
||||
android:id="@+id/science"
|
||||
android:icon="@drawable/kexue"
|
||||
android:title="科学" />
|
||||
<item
|
||||
android:id="@+id/zhexue"
|
||||
android:id="@+id/philosophy"
|
||||
android:icon="@drawable/zhexue"
|
||||
android:title="哲学" />
|
||||
<item
|
||||
android:id="@+id/goodbook"
|
||||
android:id="@+id/recommend"
|
||||
android:icon="@drawable/good"
|
||||
android:title="推荐" />
|
||||
</group>
|
||||
|
Loading…
x
Reference in New Issue
Block a user