|
|
@ -2,7 +2,9 @@ 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.widget.GridLayout |
|
|
|
import android.widget.GridLayout |
|
|
|
|
|
|
|
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 |
|
|
|
import io.legado.app.base.adapter.SimpleRecyclerAdapter |
|
|
|
import io.legado.app.base.adapter.SimpleRecyclerAdapter |
|
|
@ -15,6 +17,7 @@ import kotlinx.android.synthetic.main.item_find_book.view.* |
|
|
|
import kotlinx.android.synthetic.main.item_text.view.* |
|
|
|
import kotlinx.android.synthetic.main.item_text.view.* |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
|
|
|
import org.jetbrains.anko.sdk27.listeners.onLongClick |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FindBookAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) : |
|
|
|
class FindBookAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) : |
|
|
@ -35,6 +38,18 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c |
|
|
|
} |
|
|
|
} |
|
|
|
callBack.scrollTo(holder.layoutPosition) |
|
|
|
callBack.scrollTo(holder.layoutPosition) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ll_title.onLongClick { |
|
|
|
|
|
|
|
val popupMenu = PopupMenu(context, ll_title) |
|
|
|
|
|
|
|
popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit) |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener { |
|
|
|
|
|
|
|
when (it.itemId) { |
|
|
|
|
|
|
|
R.id.menu_edit -> callBack.editSource(item.bookSourceUrl) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
popupMenu.show() |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (exIndex == holder.layoutPosition) { |
|
|
|
if (exIndex == holder.layoutPosition) { |
|
|
|
iv_status.setImageResource(R.drawable.ic_remove) |
|
|
|
iv_status.setImageResource(R.drawable.ic_remove) |
|
|
@ -85,5 +100,6 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c |
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|
fun scrollTo(pos: Int) |
|
|
|
fun scrollTo(pos: Int) |
|
|
|
fun openExplore(sourceUrl: String, title: String, exploreUrl: String) |
|
|
|
fun openExplore(sourceUrl: String, title: String, exploreUrl: String) |
|
|
|
|
|
|
|
fun editSource(sourceUrl: String) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |