pull/34/head
parent
8427f0b7ff
commit
04944d6ae0
@ -1,18 +1,66 @@ |
||||
package io.legado.app.ui.rss.source |
||||
|
||||
import android.os.Bundle |
||||
import androidx.core.content.ContextCompat |
||||
import androidx.recyclerview.widget.DividerItemDecoration |
||||
import androidx.recyclerview.widget.ItemTouchHelper |
||||
import androidx.recyclerview.widget.LinearLayoutManager |
||||
import io.legado.app.R |
||||
import io.legado.app.base.VMBaseActivity |
||||
import io.legado.app.data.entities.RssSource |
||||
import io.legado.app.help.ItemTouchCallback |
||||
import io.legado.app.lib.theme.ATH |
||||
import io.legado.app.utils.getViewModel |
||||
import kotlinx.android.synthetic.main.activity_rss_source.* |
||||
|
||||
|
||||
class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_rss_source) { |
||||
class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_rss_source), |
||||
RssSourceAdapter.CallBack { |
||||
|
||||
override val viewModel: RssSourceViewModel |
||||
get() = getViewModel(RssSourceViewModel::class.java) |
||||
|
||||
private lateinit var adapter: RssSourceAdapter |
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) { |
||||
|
||||
} |
||||
|
||||
private fun initRecyclerView() { |
||||
ATH.applyEdgeEffectColor(recycler_view) |
||||
recycler_view.layoutManager = LinearLayoutManager(this) |
||||
recycler_view.addItemDecoration( |
||||
DividerItemDecoration(this, DividerItemDecoration.VERTICAL).apply { |
||||
ContextCompat.getDrawable(baseContext, R.drawable.ic_divider)?.let { |
||||
this.setDrawable(it) |
||||
} |
||||
}) |
||||
adapter = RssSourceAdapter(this, this) |
||||
recycler_view.adapter = adapter |
||||
val itemTouchCallback = ItemTouchCallback() |
||||
itemTouchCallback.onItemTouchCallbackListener = adapter |
||||
itemTouchCallback.isCanDrag = true |
||||
ItemTouchHelper(itemTouchCallback).attachToRecyclerView(recycler_view) |
||||
} |
||||
|
||||
override fun del(source: RssSource) { |
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||
} |
||||
|
||||
override fun edit(source: RssSource) { |
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||
} |
||||
|
||||
override fun update(vararg source: RssSource) { |
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||
} |
||||
|
||||
override fun toTop(source: RssSource) { |
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||
} |
||||
|
||||
override fun upOrder() { |
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@ |
||||
package io.legado.app.ui.rss.source |
||||
|
||||
import android.content.Context |
||||
import io.legado.app.R |
||||
import io.legado.app.base.adapter.ItemViewHolder |
||||
import io.legado.app.base.adapter.SimpleRecyclerAdapter |
||||
import io.legado.app.data.entities.RssSource |
||||
import io.legado.app.help.ItemTouchCallback |
||||
|
||||
class RssSourceAdapter(context: Context, val callBack: CallBack) : |
||||
SimpleRecyclerAdapter<RssSource>(context, R.layout.item_rss_source), |
||||
ItemTouchCallback.OnItemTouchCallbackListener { |
||||
|
||||
override fun convert(holder: ItemViewHolder, item: RssSource, payloads: MutableList<Any>) { |
||||
|
||||
} |
||||
|
||||
|
||||
override fun onSwiped(adapterPosition: Int) { |
||||
|
||||
} |
||||
|
||||
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
||||
val srcItem = getItem(srcPosition) |
||||
val targetItem = getItem(targetPosition) |
||||
if (srcItem != null && targetItem != null) { |
||||
if (srcItem.customOrder == targetItem.customOrder) { |
||||
callBack.upOrder() |
||||
} else { |
||||
val srcOrder = srcItem.customOrder |
||||
srcItem.customOrder = targetItem.customOrder |
||||
targetItem.customOrder = srcOrder |
||||
callBack.update(srcItem, targetItem) |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
interface CallBack { |
||||
fun del(source: RssSource) |
||||
fun edit(source: RssSource) |
||||
fun update(vararg source: RssSource) |
||||
fun toTop(source: RssSource) |
||||
fun upOrder() |
||||
} |
||||
} |
@ -1,27 +1,27 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:orientation="vertical" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<io.legado.app.ui.widget.TitleBar |
||||
android:id="@+id/title_bar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:contentInsetStartWithNavigation="0dp" |
||||
app:displayHomeAsUp="true" |
||||
app:title="@string/book_source" |
||||
app:contentLayout="@layout/view_search"/> |
||||
android:id="@+id/title_bar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:contentInsetStartWithNavigation="0dp" |
||||
app:contentLayout="@layout/view_search" |
||||
app:displayHomeAsUp="true" |
||||
app:title="@string/book_source" /> |
||||
|
||||
<FrameLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView |
||||
android:id="@+id/recycler_view" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"/> |
||||
android:id="@+id/recycler_view" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
|
||||
</FrameLayout> |
||||
|
||||
|
@ -1,7 +1,28 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:orientation="vertical" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<io.legado.app.ui.widget.TitleBar |
||||
android:id="@+id/title_bar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:contentInsetStartWithNavigation="0dp" |
||||
app:contentLayout="@layout/view_search" |
||||
app:displayHomeAsUp="true" |
||||
app:title="@string/rss_source" /> |
||||
|
||||
<FrameLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView |
||||
android:id="@+id/recycler_view" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
|
||||
</FrameLayout> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,50 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?android:attr/selectableItemBackground" |
||||
android:gravity="center_vertical" |
||||
android:orientation="horizontal" |
||||
android:padding="16dp"> |
||||
|
||||
<io.legado.app.lib.theme.view.ATECheckBox |
||||
android:id="@+id/cb_book_source" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:layout_weight="1" |
||||
android:singleLine="true" |
||||
android:textColor="@color/tv_text_default" /> |
||||
|
||||
<io.legado.app.lib.theme.view.ATESwitch |
||||
android:id="@+id/swt_enabled" |
||||
android:name="@string/enable" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginLeft="6dp" |
||||
android:layout_marginRight="6dp" |
||||
tools:ignore="RtlSymmetry" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView |
||||
android:id="@+id/iv_edit" |
||||
android:layout_width="36dp" |
||||
android:layout_height="36dp" |
||||
android:layout_gravity="center" |
||||
android:background="?android:attr/selectableItemBackgroundBorderless" |
||||
android:contentDescription="@string/edit" |
||||
android:padding="6dp" |
||||
android:src="@drawable/ic_edit" |
||||
android:tint="@color/tv_text_default" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView |
||||
android:id="@+id/iv_menu_more" |
||||
android:layout_width="36dp" |
||||
android:layout_height="36dp" |
||||
android:background="?attr/selectableItemBackgroundBorderless" |
||||
android:padding="6dp" |
||||
android:src="@drawable/ic_more_vert" |
||||
android:tint="@color/tv_text_default" |
||||
tools:ignore="RtlHardcoded" /> |
||||
|
||||
</LinearLayout> |
Loading…
Reference in new issue