-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
why
committed
Dec 10, 2023
1 parent
76e9372
commit a825f54
Showing
17 changed files
with
161 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/xiaoyv/bangumi/ui/feature/tag/TagDetailActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.xiaoyv.bangumi.ui.feature.tag | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import com.xiaoyv.bangumi.R | ||
import com.xiaoyv.bangumi.base.BaseListActivity | ||
import com.xiaoyv.bangumi.helper.RouteHelper | ||
import com.xiaoyv.bangumi.ui.feature.search.detail.SearchDetailItemAdapter | ||
import com.xiaoyv.blueprint.constant.NavKey | ||
import com.xiaoyv.common.api.parser.entity.SearchResultEntity | ||
import com.xiaoyv.common.config.GlobalConfig | ||
import com.xiaoyv.common.kts.setOnDebouncedChildClickListener | ||
import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter | ||
|
||
/** | ||
* Class: [TagDetailActivity] | ||
* | ||
* @author why | ||
* @since 12/10/23 | ||
*/ | ||
class TagDetailActivity : BaseListActivity<SearchResultEntity, TagDetailViewModel>() { | ||
|
||
override val isOnlyOnePage: Boolean | ||
get() = false | ||
|
||
override fun initIntentData(intent: Intent, bundle: Bundle, isNewIntent: Boolean) { | ||
viewModel.mediaType = bundle.getString(NavKey.KEY_STRING).orEmpty() | ||
viewModel.tag = bundle.getString(NavKey.KEY_STRING_SECOND).orEmpty() | ||
} | ||
|
||
override fun initView() { | ||
super.initView() | ||
binding.toolbar.title = buildString { | ||
append(GlobalConfig.mediaTypeName(viewModel.mediaType)) | ||
append("标签:") | ||
append(viewModel.tag) | ||
} | ||
} | ||
|
||
override fun initListener() { | ||
super.initListener() | ||
|
||
contentAdapter.setOnDebouncedChildClickListener(R.id.item_search) { | ||
RouteHelper.jumpMediaDetail(it.id) | ||
} | ||
} | ||
|
||
override fun onCreateContentAdapter(): BaseQuickDiffBindingAdapter<SearchResultEntity, *> { | ||
return SearchDetailItemAdapter() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/xiaoyv/bangumi/ui/feature/tag/TagDetailViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.xiaoyv.bangumi.ui.feature.tag | ||
|
||
import com.xiaoyv.bangumi.base.BaseListViewModel | ||
import com.xiaoyv.common.api.BgmApiManager | ||
import com.xiaoyv.common.api.parser.entity.SearchResultEntity | ||
import com.xiaoyv.common.api.parser.impl.parserTagDetail | ||
import com.xiaoyv.common.config.annotation.BrowserSortType | ||
import com.xiaoyv.common.config.annotation.MediaType | ||
|
||
/** | ||
* Class: [TagDetailViewModel] | ||
* | ||
* @author why | ||
* @since 12/10/23 | ||
*/ | ||
class TagDetailViewModel : BaseListViewModel<SearchResultEntity>() { | ||
internal var mediaType = MediaType.TYPE_UNKNOWN | ||
internal var tag = "" | ||
internal var time = "" | ||
|
||
@BrowserSortType | ||
internal var sort = BrowserSortType.TYPE_DEFAULT | ||
|
||
override suspend fun onRequestListImpl(): List<SearchResultEntity> { | ||
require(mediaType.isNotBlank()) { "标签条目类型不存在" } | ||
require(tag.isNotBlank()) { "标签不存在" } | ||
return BgmApiManager.bgmWebApi.queryTagDetail(mediaType, tag, time, sort, current) | ||
.parserTagDetail() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lib-common/src/main/java/com/xiaoyv/common/api/parser/impl/TagParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.xiaoyv.common.api.parser.impl | ||
|
||
import com.xiaoyv.common.api.parser.entity.SearchResultEntity | ||
import com.xiaoyv.common.config.annotation.BgmPathType | ||
import org.jsoup.nodes.Element | ||
|
||
/** | ||
* @author why | ||
* @since 12/10/23 | ||
*/ | ||
fun Element.parserTagDetail(): List<SearchResultEntity> { | ||
// 标签详情页面复用 BgmPathType.TYPE_SEARCH_SUBJECT 的解析逻辑 | ||
return parserSearchResult(BgmPathType.TYPE_SEARCH_SUBJECT) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters