Skip to content

Commit

Permalink
[Feat]: Mikan RSS 功能原生实现
Browse files Browse the repository at this point in the history
  • Loading branch information
why committed Mar 20, 2024
1 parent 772174b commit 008a369
Show file tree
Hide file tree
Showing 17 changed files with 473 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

210 changes: 0 additions & 210 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@
android:name="com.xiaoyv.bangumi.ui.feature.schedule.ScheduleActivity"
android:configChanges="orientation|keyboard|screenSize"
android:exported="false" />
<activity
android:name="com.xiaoyv.bangumi.special.mikan.MikanActivity"
android:configChanges="orientation|keyboard|screenSize"
android:exported="false" />
<activity
android:name="com.xiaoyv.bangumi.special.mikan.resource.MikanResourceActivity"
android:configChanges="orientation|keyboard|screenSize"
android:exported="false" />

<receiver
android:name="com.xiaoyv.bangumi.special.widget.AnimeWidget"
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/xiaoyv/bangumi/helper/RouteHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.xiaoyv.bangumi.special.collection.CollectionActivity
import com.xiaoyv.bangumi.special.detect.anime.ImageDetectAnimeActivity
import com.xiaoyv.bangumi.special.detect.character.ImageDetectCharacterActivity
import com.xiaoyv.bangumi.special.magnet.MagnetActivity
import com.xiaoyv.bangumi.special.mikan.MikanActivity
import com.xiaoyv.bangumi.special.mikan.resource.MikanResourceActivity
import com.xiaoyv.bangumi.special.picture.AnimePicturesNetActivity
import com.xiaoyv.bangumi.special.syncer.SyncerActivity
import com.xiaoyv.bangumi.special.syncer.list.SyncerListActivity
Expand Down Expand Up @@ -399,6 +401,19 @@ object RouteHelper {
ActivityUtils.startActivity(MessageActivity::class.java)
}

fun jumpMikan(mikanId: String) {
MikanActivity::class.open(bundleOf(NavKey.KEY_STRING to mikanId))
}

fun jumpMikanGroupResource(mikanId: String, groupId: String, groupName: String) {
MikanResourceActivity::class.open(
bundleOf(
NavKey.KEY_STRING to mikanId,
NavKey.KEY_STRING_SECOND to groupId,
NavKey.KEY_STRING_THIRD to groupName
)
)
}

fun jumpMessageDetail(messageId: String, fromName: String) {
MessageDetailActivity::class.open(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.net.Uri
import android.os.Bundle
import android.widget.FrameLayout
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.LifecycleOwner
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.KeyboardUtils
Expand All @@ -22,6 +23,7 @@ import com.xiaoyv.common.kts.showOptionsDialog
import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter
import com.xiaoyv.widget.callback.setOnFastLimitClickListener
import com.xiaoyv.widget.kts.errorMsg
import com.xiaoyv.widget.kts.showToastCompat

/**
* Class: [MagnetActivity]
Expand Down Expand Up @@ -95,42 +97,57 @@ class MagnetActivity : BaseListActivity<AnimeMagnetEntity.Resource, MagnetViewMo
}
}

/**
* 弹窗
*/
private fun onMagnetItemClick(resource: AnimeMagnetEntity.Resource) {
showOptionsDialog(
title = "资源详情",
items = listOf("复制磁链", "复制完整磁链", "复制发布来源", "打开方式", "磁链资源预览"),
onItemClick = { _, which ->
when (which) {
0 -> copyText(resource.magnet.orEmpty())
1 -> copyText(resource.magnet.orEmpty())
2 -> copyText(resource.pageUrl.orEmpty())
3 -> {
runCatching {
val intent = Intent(Intent.ACTION_VIEW)
intent.setData(Uri.parse(resource.magnet.orEmpty()))
ActivityUtils.startActivity(Intent.createChooser(intent, "打开方式"))
}.onFailure {
showToast(it.errorMsg)
override fun onCreateContentAdapter(): BaseQuickDiffBindingAdapter<AnimeMagnetEntity.Resource, *> {
return MagnetAdapter { viewModel.keyword }
}

companion object {

/**
* 弹窗
*/
@JvmStatic
fun FragmentActivity.onMagnetItemClick(resource: AnimeMagnetEntity.Resource) {
showOptionsDialog(
title = "资源详情",
items = listOf(
"复制磁链",
"复制完整磁链",
"复制发布来源",
"打开方式",
"磁链资源预览"
),
onItemClick = { _, which ->
when (which) {
0 -> copyText(resource.magnet.orEmpty())
1 -> copyText(resource.magnet.orEmpty())
2 -> copyText(resource.pageUrl.orEmpty())
3 -> {
runCatching {
val intent = Intent(Intent.ACTION_VIEW)
intent.setData(Uri.parse(resource.magnet.orEmpty()))
ActivityUtils.startActivity(
Intent.createChooser(
intent,
"打开方式"
)
)
}.onFailure {
showToastCompat(it.errorMsg)
}
}
// 磁力预览
4 -> {
val magnetHash = resource.magnet.orEmpty().magnetHash()
RouteHelper.jumpWeb(
url = "https://beta.magnet.pics/m/$magnetHash",
fitToolbar = true,
smallToolbar = true
)
}
}
// 磁力预览
4 -> {
val magnetHash = resource.magnet.orEmpty().magnetHash()
RouteHelper.jumpWeb(
url = "https://beta.magnet.pics/m/$magnetHash",
fitToolbar = true,
smallToolbar = true
)
}
}
}
)
}

override fun onCreateContentAdapter(): BaseQuickDiffBindingAdapter<AnimeMagnetEntity.Resource, *> {
return MagnetAdapter { viewModel.keyword }
)
}
}
}
Loading

0 comments on commit 008a369

Please sign in to comment.