pull/423/head
gedoor 4 years ago
parent 9223f807dd
commit cabcbb2512
  1. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt
  2. 3
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  3. 3
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
  4. 10
      app/src/main/res/layout/fragment_books.xml
  5. 23
      app/src/main/res/layout/fragment_find_book.xml
  6. 3
      app/src/main/res/layout/item_find_book.xml
  7. 22
      app/src/main/res/layout/view_empty.xml

@ -29,7 +29,6 @@ import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.observeEvent import io.legado.app.utils.observeEvent
import io.legado.app.utils.startActivity 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
@ -110,7 +109,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() tv_empty_msg.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 }

@ -6,6 +6,7 @@ import android.view.MenuItem
import android.view.SubMenu import android.view.SubMenu
import android.view.View import android.view.View
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
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.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -43,6 +44,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_find_
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
setSupportToolbar(toolbar) setSupportToolbar(toolbar)
tv_empty_msg.text = "当前没有发现源,关注公众号[开源阅读]添加带发现的书源!"
initSearchView() initSearchView()
initRecyclerView() initRecyclerView()
initGroupData() initGroupData()
@ -111,6 +113,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_find_
App.db.bookSourceDao().liveExplore("%$key%") App.db.bookSourceDao().liveExplore("%$key%")
} }
liveExplore?.observe(viewLifecycleOwner, { liveExplore?.observe(viewLifecycleOwner, {
tv_empty_msg.isGone = it.isNotEmpty()
val diffResult = DiffUtil val diffResult = DiffUtil
.calculateDiff(ExploreDiffCallBack(ArrayList(adapter.getItems()), it)) .calculateDiff(ExploreDiffCallBack(ArrayList(adapter.getItems()), it))
adapter.setItems(it) adapter.setItems(it)

@ -138,6 +138,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
} }
} }
if (!isInEditMode) {
if (a.getBoolean(R.styleable.TitleBar_fitStatusBar, true)) { if (a.getBoolean(R.styleable.TitleBar_fitStatusBar, true)) {
topPadding = context.statusBarHeight topPadding = context.statusBarHeight
} }
@ -154,7 +155,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
} else { } else {
AppConfig.elevation.toFloat() AppConfig.elevation.toFloat()
} }
}
a.recycle() a.recycle()
} }

@ -17,7 +17,15 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<include layout="@layout/view_empty" /> <TextView
android:id="@+id/tv_empty_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:layout_gravity="center"
android:visibility="gone"
tools:text="TextView" />
</FrameLayout> </FrameLayout>

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
@ -17,6 +18,22 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_find" android:id="@+id/rv_find"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/title_bar"
app:layout_constraintBottom_toBottomOf="parent"
tools:listitem="@layout/item_find_book" />
</LinearLayout> <TextView
android:id="@+id/tv_empty_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@+id/title_bar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:text="TextView" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -24,7 +24,8 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:textColor="@color/primaryText" /> android:textColor="@color/primaryText"
tools:text="起点中文" />
<io.legado.app.ui.widget.anima.RotateLoading <io.legado.app.ui.widget.anima.RotateLoading
android:id="@+id/rotate_loading" android:id="@+id/rotate_loading"

@ -1,22 +0,0 @@
<?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>
Loading…
Cancel
Save