pull/32/head
gedoor 6 years ago
parent ed505d9eda
commit a6866cea1d
  1. 8
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 2
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt
  3. 4
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
  4. 9
      app/src/main/res/layout/item_book_source.xml

@ -1,10 +1,7 @@
package io.legado.app.data.dao package io.legado.app.data.dao
import androidx.paging.DataSource import androidx.paging.DataSource
import androidx.room.Dao import androidx.room.*
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
@Dao @Dao
@ -18,4 +15,7 @@ interface BookSourceDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(bookSource: BookSource): Long fun insert(bookSource: BookSource): Long
@Update
fun update(vararg bookSource: BookSource)
} }

@ -60,7 +60,7 @@ class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewH
callBack?.update(bookSource) callBack?.update(bookSource)
} }
iv_more.setOnClickListener{ iv_more.setOnClickListener{
val popupMenu = PopupMenu(context, this) val popupMenu = PopupMenu(context, iv_more)
popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit) popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit)
popupMenu.menu.add(Menu.NONE, R.id.menu_del, Menu.NONE, R.string.delete) popupMenu.menu.add(Menu.NONE, R.id.menu_del, Menu.NONE, R.string.delete)
popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top) popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top)

@ -16,6 +16,8 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.ui.sourceedit.SourceEditActivity import io.legado.app.ui.sourceedit.SourceEditActivity
import kotlinx.android.synthetic.main.fragment_book_source.* import kotlinx.android.synthetic.main.fragment_book_source.*
import kotlinx.android.synthetic.main.view_titlebar.* import kotlinx.android.synthetic.main.view_titlebar.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack { class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack {
@ -59,7 +61,7 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour
} }
override fun update(bookSource: BookSource) { override fun update(bookSource: BookSource) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. GlobalScope.launch { App.db.bookSourceDao().update(bookSource) }
} }
override fun edit(bookSource: BookSource) { override fun edit(bookSource: BookSource) {

@ -4,7 +4,7 @@
android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="16dp" android:padding="16dp"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_gravity="center_vertical"> android:gravity="center_vertical">
<io.legado.app.lib.theme.view.ATECheckBox <io.legado.app.lib.theme.view.ATECheckBox
android:id="@+id/cb_book_source" android:id="@+id/cb_book_source"
@ -23,13 +23,12 @@
<ImageView <ImageView
android:id="@+id/iv_more" android:id="@+id/iv_more"
android:layout_width="40dp" android:layout_width="24dp"
android:layout_height="40dp" android:layout_height="24dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round" android:background="@drawable/bg_ib_pre_round"
android:layout_margin="6dp"
android:contentDescription="@string/to_top" android:contentDescription="@string/to_top"
android:padding="8dp"
android:src="@drawable/ic_more_vert" android:src="@drawable/ic_more_vert"
app:tint="@color/tv_text_default"/> app:tint="@color/tv_text_default"/>
</LinearLayout> </LinearLayout>
Loading…
Cancel
Save