pull/423/head
gedoor 4 years ago
parent dbe566310f
commit 9223f807dd
  1. 9
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt
  2. 25
      app/src/main/res/layout/fragment_books.xml
  3. 22
      app/src/main/res/layout/view_empty.xml
  4. 6
      app/src/main/res/layout/view_no_book.xml
  5. 2
      app/src/main/res/values-zh-rHK/strings.xml
  6. 2
      app/src/main/res/values-zh-rTW/strings.xml
  7. 2
      app/src/main/res/values-zh/strings.xml
  8. 2
      app/src/main/res/values/strings.xml

@ -2,6 +2,7 @@ package io.legado.app.ui.main.bookshelf.books
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.core.view.isGone
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
@ -23,8 +24,12 @@ import io.legado.app.ui.audio.AudioPlayActivity
import io.legado.app.ui.book.info.BookInfoActivity import io.legado.app.ui.book.info.BookInfoActivity
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.main.MainViewModel
import io.legado.app.utils.* import io.legado.app.utils.getPrefInt
import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.observeEvent
import io.legado.app.utils.startActivity
import kotlinx.android.synthetic.main.fragment_books.* import kotlinx.android.synthetic.main.fragment_books.*
import kotlinx.android.synthetic.main.view_empty.*
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import kotlin.math.max import kotlin.math.max
@ -55,6 +60,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
position = it.getInt("position", 0) position = it.getInt("position", 0)
groupId = it.getLong("groupId", -1) groupId = it.getLong("groupId", -1)
} }
tv_empty_msg.setText(R.string.bookshelf_empty)
initRecyclerView() initRecyclerView()
upRecyclerData() upRecyclerData()
} }
@ -104,6 +110,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
else -> App.db.bookDao().observeByGroup(groupId) else -> App.db.bookDao().observeByGroup(groupId)
} }
bookshelfLiveData?.observe(this, { list -> bookshelfLiveData?.observe(this, { list ->
vw_empty.isGone = list.isNotEmpty()
val books = when (getPrefInt(PreferKey.bookshelfSort)) { val books = when (getPrefInt(PreferKey.bookshelfSort)) {
1 -> list.sortedByDescending { it.latestChapterTime } 1 -> list.sortedByDescending { it.latestChapterTime }
2 -> list.sortedBy { it.name } 2 -> list.sortedBy { it.name }

@ -1,12 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<androidx.recyclerview.widget.RecyclerView <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/rv_bookshelf" android:id="@+id/refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bookshelf"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/item_bookshelf_list" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<include layout="@layout/view_empty" />
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/vw_empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:visibility="gone">
<TextView
android:id="@+id/tv_empty_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

@ -45,7 +45,7 @@
<string name="recent_reading">最近閲讀</string> <string name="recent_reading">最近閲讀</string>
<string name="last_read">最後閲讀</string> <string name="last_read">最後閲讀</string>
<string name="update_log">更新日誌</string> <string name="update_log">更新日誌</string>
<string name="bookshelf_empty">書架還空着,快去添加吧</string> <string name="bookshelf_empty">書架還空著,先去搜索書籍或從發現裏添加吧!\n如果初次使用請先關註公眾號[開源閱讀]獲取書源</string>
<string name="action_search">搜尋</string> <string name="action_search">搜尋</string>
<string name="action_download">下載</string> <string name="action_download">下載</string>
<string name="layout_list">列表</string> <string name="layout_list">列表</string>

@ -45,7 +45,7 @@
<string name="recent_reading">最近閱讀</string> <string name="recent_reading">最近閱讀</string>
<string name="last_read">最後閱讀</string> <string name="last_read">最後閱讀</string>
<string name="update_log">更新日誌</string> <string name="update_log">更新日誌</string>
<string name="bookshelf_empty">書架還空著,先去添加吧!</string> <string name="bookshelf_empty">書架還空著,先去搜索書籍或從發現裏添加吧!\n如果初次使用請先關註公眾號[開源閱讀]獲取書源</string>
<string name="action_search">搜尋</string> <string name="action_search">搜尋</string>
<string name="action_download">下載</string> <string name="action_download">下載</string>
<string name="layout_list">列表</string> <string name="layout_list">列表</string>

@ -47,7 +47,7 @@
<string name="recent_reading">最近阅读</string> <string name="recent_reading">最近阅读</string>
<string name="last_read">最后阅读</string> <string name="last_read">最后阅读</string>
<string name="update_log">更新日志</string> <string name="update_log">更新日志</string>
<string name="bookshelf_empty">书架还空着,先去添加吧!</string> <string name="bookshelf_empty">书架还空着,先去搜索书籍或从发现里添加吧!\n如果初次使用请先关注公众号[开源阅读]获取书源</string>
<string name="action_search">搜索</string> <string name="action_search">搜索</string>
<string name="action_download">下载</string> <string name="action_download">下载</string>
<string name="layout_list">列表</string> <string name="layout_list">列表</string>

@ -48,7 +48,7 @@
<string name="recent_reading">Recent reading</string> <string name="recent_reading">Recent reading</string>
<string name="last_read">Last reading</string> <string name="last_read">Last reading</string>
<string name="update_log">What\'s new</string> <string name="update_log">What\'s new</string>
<string name="bookshelf_empty">Still empty,please add it first.</string> <string name="bookshelf_empty">The bookshelf is still empty. Search for books or add them from discovery! \n if you use it for the first time, please pay attention to the public account [开源阅读] to get the book source!</string>
<string name="action_search">Search</string> <string name="action_search">Search</string>
<string name="action_download">Download</string> <string name="action_download">Download</string>
<string name="layout_list">List</string> <string name="layout_list">List</string>

Loading…
Cancel
Save