pull/32/head
kunfei 5 years ago
parent fd054211f5
commit ed5a83e860
  1. 14
      app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt
  2. 11
      app/src/main/res/layout/item_find_book.xml
  3. 12
      app/src/main/res/layout/item_text.xml

@ -3,7 +3,6 @@ package io.legado.app.ui.main.explore
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.widget.GridLayout
import android.widget.PopupMenu import android.widget.PopupMenu
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
@ -60,8 +59,6 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
}.onSuccess { }.onSuccess {
it?.let { it?.let {
gl_child.visible() gl_child.visible()
var rowNum = 0
var columnNum = 0
gl_child.removeAllViews() gl_child.removeAllViews()
it.map { kind -> it.map { kind ->
val tv = LayoutInflater.from(context) val tv = LayoutInflater.from(context)
@ -74,16 +71,7 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
kind.url kind.url
) )
} }
val rowSpecs = GridLayout.spec(rowNum, 1.0f) gl_child.addView(tv)
val colSpecs = GridLayout.spec(columnNum, 1.0f)
val params = GridLayout.LayoutParams(rowSpecs, colSpecs)
gl_child.addView(tv, params)
if (columnNum < 2) {
columnNum++
} else {
columnNum = 0
rowNum++
}
} }
} }
}.onFinally { }.onFinally {

@ -40,13 +40,18 @@
</LinearLayout> </LinearLayout>
<GridLayout <com.google.android.flexbox.FlexboxLayout
android:id="@+id/gl_child" android:id="@+id/gl_child"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false"
android:overScrollMode="never"
android:padding="3dp" android:padding="3dp"
android:columnCount="3" android:visibility="gone"
android:visibility="gone" /> app:dividerDrawable="@drawable/shape_space_divider"
app:flexDirection="row"
app:flexWrap="wrap"
app:showDivider="middle" />
<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,13 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp">
<TextView
android:id="@+id/text_view" android:id="@+id/text_view"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="@drawable/shape_card_view" android:background="@drawable/shape_card_view"
android:clickable="true" android:clickable="true"
android:ellipsize="end" android:ellipsize="end"
@ -17,5 +13,3 @@
android:singleLine="true" android:singleLine="true"
android:textColor="@color/tv_text_default" android:textColor="@color/tv_text_default"
android:textSize="14sp" /> android:textSize="14sp" />
</FrameLayout>

Loading…
Cancel
Save