|
|
@ -23,8 +23,8 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick |
|
|
|
|
|
|
|
|
|
|
|
class ExploreAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) : |
|
|
|
class ExploreAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) : |
|
|
|
SimpleRecyclerAdapter<BookSource>(context, R.layout.item_find_book) { |
|
|
|
SimpleRecyclerAdapter<BookSource>(context, R.layout.item_find_book) { |
|
|
|
|
|
|
|
|
|
|
|
private var exIndex = 0 |
|
|
|
private var exIndex = 0 |
|
|
|
|
|
|
|
private var scrollTo = -1 |
|
|
|
|
|
|
|
|
|
|
|
override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) { |
|
|
|
override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) { |
|
|
|
with(holder.itemView) { |
|
|
|
with(holder.itemView) { |
|
|
@ -35,6 +35,9 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca |
|
|
|
iv_status.setImageResource(R.drawable.ic_remove) |
|
|
|
iv_status.setImageResource(R.drawable.ic_remove) |
|
|
|
rotate_loading.loadingColor = context.accentColor |
|
|
|
rotate_loading.loadingColor = context.accentColor |
|
|
|
rotate_loading.show() |
|
|
|
rotate_loading.show() |
|
|
|
|
|
|
|
if (scrollTo >= 0) { |
|
|
|
|
|
|
|
callBack.scrollTo(scrollTo) |
|
|
|
|
|
|
|
} |
|
|
|
Coroutine.async(scope) { |
|
|
|
Coroutine.async(scope) { |
|
|
|
item.getExploreKinds() |
|
|
|
item.getExploreKinds() |
|
|
|
}.onSuccess { kindList -> |
|
|
|
}.onSuccess { kindList -> |
|
|
@ -59,6 +62,10 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca |
|
|
|
} |
|
|
|
} |
|
|
|
}.onFinally { |
|
|
|
}.onFinally { |
|
|
|
rotate_loading.hide() |
|
|
|
rotate_loading.hide() |
|
|
|
|
|
|
|
if (scrollTo >= 0) { |
|
|
|
|
|
|
|
callBack.scrollTo(scrollTo) |
|
|
|
|
|
|
|
scrollTo = -1 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
iv_status.setImageResource(R.drawable.ic_add) |
|
|
|
iv_status.setImageResource(R.drawable.ic_add) |
|
|
@ -76,11 +83,10 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca |
|
|
|
exIndex = if (exIndex == position) -1 else position |
|
|
|
exIndex = if (exIndex == position) -1 else position |
|
|
|
notifyItemChanged(oldEx, false) |
|
|
|
notifyItemChanged(oldEx, false) |
|
|
|
if (exIndex != -1) { |
|
|
|
if (exIndex != -1) { |
|
|
|
|
|
|
|
scrollTo = position |
|
|
|
|
|
|
|
callBack.scrollTo(position) |
|
|
|
notifyItemChanged(position, false) |
|
|
|
notifyItemChanged(position, false) |
|
|
|
} |
|
|
|
} |
|
|
|
postDelayed({ |
|
|
|
|
|
|
|
callBack.scrollTo(position) |
|
|
|
|
|
|
|
}, 200) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
ll_title.onLongClick { |
|
|
|
ll_title.onLongClick { |
|
|
|
showMenu(ll_title, holder.layoutPosition) |
|
|
|
showMenu(ll_title, holder.layoutPosition) |
|
|
|