diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a8c55d9a9..84193153a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,7 +72,6 @@ android_build: only: - dev - release - - feat/GHZSCY-6488 # 代码检查 sonarqube_analysis: @@ -157,5 +156,4 @@ oss-upload&send-email: - /usr/local/bin/python /ci-android-mail-jira-comment.py only: - dev - - release - - feat/GHZSCY-6488 \ No newline at end of file + - release \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 79a9d74e59..12864f1da5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -333,14 +333,6 @@ android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden" /> - - - - @@ -562,14 +554,6 @@ android:name=".simulatorgame.SimulatorManagementActivity" android:screenOrientation="portrait" /> - - - - diff --git a/app/src/main/java/com/gh/common/DefaultUrlHandler.kt b/app/src/main/java/com/gh/common/DefaultUrlHandler.kt index 3b9ca778bf..2b34992ec9 100644 --- a/app/src/main/java/com/gh/common/DefaultUrlHandler.kt +++ b/app/src/main/java/com/gh/common/DefaultUrlHandler.kt @@ -268,10 +268,6 @@ object DefaultUrlHandler { directToGameVideo(context, id, entrance, "") } - EntranceConsts.HOST_CATEGORY -> { - val title = uri.getQueryParameter("title") - DirectUtils.directCategoryDirectory(context, id, title ?: "", entrance, "") - } EntranceConsts.HOST_COLUMN_COLLECTION -> { val name = uri.getQueryParameter("name") DirectUtils.directToColumnCollection(context, id, -1, entrance, name ?: "") diff --git a/app/src/main/java/com/gh/common/util/DirectUtils.kt b/app/src/main/java/com/gh/common/util/DirectUtils.kt index 020d151803..afb12201be 100644 --- a/app/src/main/java/com/gh/common/util/DirectUtils.kt +++ b/app/src/main/java/com/gh/common/util/DirectUtils.kt @@ -19,8 +19,6 @@ import com.gh.common.util.EntranceUtils.jumpActivity import com.gh.common.util.EntranceUtils.jumpActivityCompat import com.gh.gamecenter.* import com.gh.gamecenter.amway.AmwayActivity -import com.gh.gamecenter.catalog.CatalogActivity -import com.gh.gamecenter.category.CategoryDirectoryActivity import com.gh.gamecenter.category2.CategoryV2Activity import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout @@ -151,14 +149,12 @@ object DirectUtils { "qqqun", "tag", "all_community_article", - "category", "block", "column_collection", "server", "top_game_comment", "wechat_bind", "video", - "catalog", "category_v2", "common_collection", "game_list", @@ -285,10 +281,6 @@ object DirectUtils { ) ) - "category", "分类" -> directCategoryDirectory(context, linkEntity.link!!, linkEntity.text!!) - - "catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path) - "category_v2" -> directCategoryV2( context, linkEntity.link!!, @@ -1423,47 +1415,6 @@ object DirectUtils { } } - /** - * 跳转分类 - */ - @JvmStatic - fun directCategoryDirectory( - context: Context, - categoryId: String, - categoryTitle: String, - entrance: String? = null, - path: String? = "" - ) { - if (categoryId.isEmpty()) return - val bundle = Bundle() - bundle.putString(KEY_TO, CategoryDirectoryActivity::class.java.name) - bundle.putString(KEY_CATEGORY_ID, categoryId) - bundle.putString(KEY_CATEGORY_TITLE, categoryTitle) - bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER) - bundle.putString(KEY_PATH, path) - jumpActivity(context, bundle) - } - - /** - * 跳转新分类 - */ - @JvmStatic - fun directCatalog( - context: Context, - catalogId: String, - catalogTitle: String, - entrance: String? = null, - path: String? = "", - ) { - if (catalogId.isEmpty()) return - val bundle = Bundle() - bundle.putString(KEY_TO, CatalogActivity::class.java.name) - bundle.putString(KEY_CATALOG_ID, catalogId) - bundle.putString(KEY_CATALOG_TITLE, catalogTitle) - bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path)) - jumpActivity(context, bundle) - } - /** * 跳转新分类2.0 */ diff --git a/app/src/main/java/com/gh/common/util/LogUtils.java b/app/src/main/java/com/gh/common/util/LogUtils.java index 420b6a080b..d4b9bc7215 100644 --- a/app/src/main/java/com/gh/common/util/LogUtils.java +++ b/app/src/main/java/com/gh/common/util/LogUtils.java @@ -734,18 +734,6 @@ public class LogUtils { LoghubUtils.log(object, LOG_STORE_EVENT, false); } - public static void logNewCatalogAppearanceEvent(String entrance, String key) { - logCatalogEvent("access_to_classification", entrance, key, -1, -1, -1, -1); - } - - public static void logSubCatalogClickEvent(String entrance, String key, int seq1) { - logCatalogEvent("click_first_classification", entrance, key, seq1, -1, -1, -1); - } - - public static void logSubCatalogContentClickEvent(String entrance, String key, int seq1, int seq2) { - logCatalogEvent("click_secondary_classification", entrance, key, seq1, seq2, -1, -1); - } - public static void logSpecialCatalogContentClickEvent(String entrance, String key, int seq1, int seqContent) { logCatalogEvent("click_content", entrance, key, seq1, -1, seqContent, -1); } diff --git a/app/src/main/java/com/gh/common/view/CatalogFilterView.kt b/app/src/main/java/com/gh/common/view/CatalogFilterView.kt deleted file mode 100644 index 67229d0ade..0000000000 --- a/app/src/main/java/com/gh/common/view/CatalogFilterView.kt +++ /dev/null @@ -1,331 +0,0 @@ -package com.gh.common.view - -import android.content.Context -import android.graphics.Color -import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.LinearLayout -import android.widget.PopupWindow -import android.widget.TextView -import androidx.annotation.ColorInt -import androidx.core.content.ContextCompat -import com.gh.gamecenter.R -import com.gh.gamecenter.common.utils.setDrawableEnd -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.visibleIf -import com.gh.gamecenter.entity.CatalogEntity -import com.gh.gamecenter.entity.SubjectSettingEntity -import com.google.android.flexbox.FlexboxLayout - -class CatalogFilterView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : LinearLayout(context, attrs, defStyleAttr) { - - private var mTypeTv: TextView - private var mCatalogTv: TextView - private var mSizeTv: TextView - private var mTypeContainer: View - private var mCatalogContainer: View - private var mSizeContainer: View - - private var mTypeFilterArray = ArrayList() - private var mCatalogFilterArray = ArrayList() - private var sizeFilterArray: ArrayList? = null - - private var mOnCatalogFilterSetupListener: OnCatalogFilterSetupListener? = null - - private var mTypePopupWindow: PopupWindow? = null - private var mCatalogPopupWindow: PopupWindow? = null - private var mSizePopupWindow: PopupWindow? = null - - init { - View.inflate(context, R.layout.layout_catalog_filter, this) - - mTypeTv = findViewById(R.id.type_tv) - mCatalogTv = findViewById(R.id.catalog_tv) - mSizeTv = findViewById(R.id.size_tv) - mTypeContainer = findViewById(R.id.container_type) - mCatalogContainer = findViewById(R.id.container_catalog) - mSizeContainer = findViewById(R.id.container_size) - - mTypeContainer.setOnClickListener { - showSelectTypePopupWindow(this, mTypeTv, mTypeTv.text.toString()) - } - - mCatalogContainer.setOnClickListener { - showSelectCatalogPopupWindow(this, mCatalogTv, mCatalogTv.text.toString()) - } - - mSizeContainer.setOnClickListener { - showSelectSizePopupWindow(this, mSizeTv, mSizeTv.text.toString()) - } - } - - fun setTypeList(switch: CatalogEntity.CatalogSwitch) { - switch.run { - if ("on" == hotSort) mTypeFilterArray.add(SortType.RECOMMENDED) - if ("on" == newSort) mTypeFilterArray.add(SortType.NEWEST) - if ("on" == starSort) mTypeFilterArray.add(SortType.RATING) - } - if (mTypeFilterArray.isNotEmpty()) mTypeTv.text = mTypeFilterArray[0].value - } - - fun setCatalogList(subCatalogList: List, initCatalogName: String) { - mCatalogFilterArray = ArrayList(subCatalogList) - mCatalogTv.text = initCatalogName - } - - fun setOnConfigSetupListener(onCatalogFilterSetupListener: OnCatalogFilterSetupListener) { - mOnCatalogFilterSetupListener = onCatalogFilterSetupListener - } - - private fun toggleHighlightedTextView(targetTextView: TextView, highlightIt: Boolean) { - if (highlightIt) { - targetTextView.background = ContextCompat.getDrawable(targetTextView.context, R.drawable.bg_tag_text) - targetTextView.setTextColor(Color.WHITE) - } else { - targetTextView.background = null - targetTextView.setTextColor(R.color.text_757575.toColor(context)) - } - } - - private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) { - typeTv.setTextColor(R.color.text_theme.toColor(context)) - typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) - - val inflater = LayoutInflater.from(typeTv.context) - val layout = inflater.inflate(R.layout.layout_filter_size, null) - val popupWindow = PopupWindow( - layout, - LayoutParams.MATCH_PARENT, - LayoutParams.WRAP_CONTENT - ).apply { mTypePopupWindow = this } - - val flexboxLayout = layout.findViewById(R.id.flexbox) - val backgroundView = layout.findViewById(R.id.background) - - backgroundView.setOnClickListener { - popupWindow.dismiss() - } - - for (type in mTypeFilterArray) { - val item = inflater.inflate(R.layout.item_filter_size, flexboxLayout, false) - - // 单列 3 个,强行设置宽度为屏幕的 1/3 - val width = typeTv.context.resources.displayMetrics.widthPixels / 3 - val height = item.layoutParams.height - - item.layoutParams = ViewGroup.LayoutParams(width, height) - flexboxLayout.addView(item) - - val tv = item.findViewById(R.id.size_tv) - tv.text = type.value - - toggleHighlightedTextView(tv, typeText == type.value) - - tv.tag = type.value - - item.setOnClickListener { - toggleHighlightedTextView(tv, true) - popupWindow.dismiss() - typeTv.text = type.value - - mOnCatalogFilterSetupListener?.onSetupSortType(type) - } - } - - popupWindow.setOnDismissListener { - typeTv.setTextColor(R.color.text_757575.toColor(context)) - typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) - mTypePopupWindow = null - } - - popupWindow.isTouchable = true - popupWindow.isFocusable = true - popupWindow.animationStyle = 0 - popupWindow.showAsDropDown(containerView, 0, 0) - } - - private fun showSelectCatalogPopupWindow(containerView: View, catalogTv: TextView, catalogText: String) { - catalogTv.setTextColor(R.color.text_theme.toColor(context)) - catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) - - val inflater = LayoutInflater.from(catalogTv.context) - val layout = inflater.inflate(R.layout.layout_filter_size, null) - val popupWindow = PopupWindow( - layout, - LayoutParams.MATCH_PARENT, - LayoutParams.WRAP_CONTENT - ).apply { mCatalogPopupWindow = this } - - val flexboxLayout = layout.findViewById(R.id.flexbox) - val backgroundView = layout.findViewById(R.id.background) - - backgroundView.setOnClickListener { - popupWindow.dismiss() - } - - for (entity in mCatalogFilterArray) { - val item = inflater.inflate(R.layout.item_filter_size, flexboxLayout, false) - - // 单列 3 个,强行设置宽度为屏幕的 1/3 - val width = catalogTv.context.resources.displayMetrics.widthPixels / 3 - val height = item.layoutParams.height - - item.layoutParams = ViewGroup.LayoutParams(width, height) - flexboxLayout.addView(item) - - val tv = item.findViewById(R.id.size_tv) - val iv = item.findViewById(R.id.recommend_iv) - tv.text = entity.name - iv.visibleIf(entity.recommended) - - toggleHighlightedTextView(tv, catalogText == entity.name) - - tv.tag = entity.name - - item.setOnClickListener { - toggleHighlightedTextView(tv, true) - popupWindow.dismiss() - catalogTv.text = entity.name - - mOnCatalogFilterSetupListener?.onSetupSortCatalog(entity) - } - } - - popupWindow.setOnDismissListener { - catalogTv.setTextColor(R.color.text_757575.toColor(context)) - catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) - mCatalogPopupWindow = null - } - - popupWindow.isTouchable = true - popupWindow.isFocusable = true - popupWindow.animationStyle = 0 - popupWindow.showAsDropDown(containerView, 0, 0) - } - - private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) { - sizeTv.setTextColor(R.color.text_theme.toColor(context)) - sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) - - val inflater = LayoutInflater.from(sizeTv.context) - val layout = inflater.inflate(R.layout.layout_filter_size, null) - val popupWindow = PopupWindow( - layout, - LayoutParams.MATCH_PARENT, - LayoutParams.WRAP_CONTENT - ).apply { mSizePopupWindow = this } - - val flexboxLayout = layout.findViewById(R.id.flexbox) - val backgroundView = layout.findViewById(R.id.background) - - sizeFilterArray = if (sizeFilterArray == null) { - getDefaultSizeFilterArray() - } else { - sizeFilterArray?.apply { - if (firstOrNull()?.text != "全部大小") { - add(0, SubjectSettingEntity.Size(min = -1, max = -1, text = "全部大小")) - } - } - } - - backgroundView.setOnClickListener { - popupWindow.dismiss() - } - - for (size in sizeFilterArray!!) { - val item = inflater.inflate(R.layout.item_filter_size, flexboxLayout, false) - - // 单列 3 个,强行设置宽度为屏幕的 1/3 - val width = sizeTv.context.resources.displayMetrics.widthPixels / 3 - val height = item.layoutParams.height - - item.layoutParams = ViewGroup.LayoutParams(width, height) - flexboxLayout.addView(item) - - val tv = item.findViewById(R.id.size_tv) - tv.text = size.text - - toggleHighlightedTextView(tv, sizeText == size.text) - - tv.tag = size.text - - item.setOnClickListener { - toggleHighlightedTextView(tv, true) - popupWindow.dismiss() - sizeTv.text = size.text - - mOnCatalogFilterSetupListener?.onSetupSortSize(size) - } - } - - popupWindow.setOnDismissListener { - sizeTv.setTextColor(R.color.text_757575.toColor(context)) - sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) - mSizePopupWindow = null - } - - popupWindow.isTouchable = true - popupWindow.isFocusable = true - popupWindow.animationStyle = 0 - popupWindow.showAsDropDown(containerView, 0, 0) - } - - private fun getDefaultSizeFilterArray(): ArrayList { - return arrayListOf().apply { - add(SubjectSettingEntity.Size(min = -1, max = -1, text = "全部大小")) - add(SubjectSettingEntity.Size(min = -1, max = 100, text = "100M以下")) - add(SubjectSettingEntity.Size(min = 100, max = 300, text = "100-300M")) - add(SubjectSettingEntity.Size(min = 300, max = 500, text = "300-500M")) - add(SubjectSettingEntity.Size(min = 500, max = 1000, text = "500M-1G")) - add(SubjectSettingEntity.Size(min = 1000, max = -1, text = "1G以上")) - } - } - - fun setRootBackgroundColor(@ColorInt color: Int) { - findViewById(R.id.config_controller).setBackgroundColor(color) - } - - fun setItemTextColor(@ColorInt color: Int) { - mTypeTv.setTextColor(color) - mCatalogTv.setTextColor(color) - mSizeTv.setTextColor(color) - } - - fun updatePopupWindow() { - when { - mTypePopupWindow != null && mTypePopupWindow!!.isShowing -> { - mTypePopupWindow?.dismiss() - showSelectTypePopupWindow(this, mTypeTv, mTypeTv.text.toString()) - } - - mCatalogPopupWindow != null && mCatalogPopupWindow!!.isShowing -> { - mCatalogPopupWindow?.dismiss() - showSelectCatalogPopupWindow(this, mCatalogTv, mCatalogTv.text.toString()) - } - - mSizePopupWindow != null && mSizePopupWindow!!.isShowing -> { - mSizePopupWindow?.dismiss() - showSelectSizePopupWindow(this, mSizeTv, mSizeTv.text.toString()) - } - } - } - - interface OnCatalogFilterSetupListener { - fun onSetupSortSize(sortSize: SubjectSettingEntity.Size) - fun onSetupSortType(sortType: SortType) - fun onSetupSortCatalog(sortCatalog: CatalogEntity.SubCatalogEntity) - } - - enum class SortType(val value: String) { - RECOMMENDED("热门推荐"), - NEWEST("最新上线"), - RATING("最高评分") - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/common/view/SubCategoryView.kt b/app/src/main/java/com/gh/common/view/SubCategoryView.kt deleted file mode 100644 index 997f7bac5e..0000000000 --- a/app/src/main/java/com/gh/common/view/SubCategoryView.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.gh.common.view - -import android.content.Context -import android.util.AttributeSet -import android.view.View -import android.widget.LinearLayout -import android.widget.TextView -import com.gh.gamecenter.R -import com.gh.gamecenter.category.CategoryListActivity -import com.gh.gamecenter.entity.CategoryEntity - -class SubCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : - LinearLayout(context, attrs, defStyleAttr) { - - var leftTv: TextView - var centerTv: TextView - var rightTv: TextView - - var leftDivider: View - var rightDivider: View - - var primeCategory: CategoryEntity? = null - var categoryTitle: String? = "" - - init { - View.inflate(context, R.layout.layout_sub_category, this) - - leftTv = findViewById(R.id.tv_left_sub_category) - centerTv = findViewById(R.id.tv_center_sub_category) - rightTv = findViewById(R.id.tv_right_sub_category) - - leftDivider = findViewById(R.id.divider_left) - rightDivider = findViewById(R.id.divider_right) - } - - fun setLeftCategory(category: CategoryEntity) { - setCategory(leftTv, category) - } - - fun setCenterCategory(category: CategoryEntity) { - setCategory(centerTv, category) - leftDivider.visibility = View.VISIBLE - } - - fun setRightCategory(category: CategoryEntity) { - setCategory(rightTv, category) - rightDivider.visibility = View.VISIBLE - } - - private fun setCategory(tv: TextView, category: CategoryEntity) { - tv.text = category.name - tv.setOnClickListener { - tv.context.startActivity( - CategoryListActivity.getIntent( - tv.context, - categoryTitle!!, - primeCategory!!, - category.name!! - ) - ) - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/SkipActivity.java b/app/src/main/java/com/gh/gamecenter/SkipActivity.java index 533863692a..c85ab9f159 100644 --- a/app/src/main/java/com/gh/gamecenter/SkipActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SkipActivity.java @@ -5,7 +5,6 @@ import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_PUSH; import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ANSWER; import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARCHIVE_LOGIN; import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARTICLE; -import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_CATEGORY; import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COLUMN; import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COLUMN_COLLECTION; import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COMMUNITY; @@ -315,10 +314,6 @@ public class SkipActivity extends BaseActivity { DirectUtils.directToCommunityColumn(this, community, columnId, entrance, ""); break; - case HOST_CATEGORY: - title = uri.getQueryParameter("title"); - DirectUtils.directCategoryDirectory(this, path, title, entrance, pathName); - break; case HOST_COLUMN_COLLECTION: DirectUtils.directToColumnCollection(this, path, -1, entrance, "", "", "", "", null,false); break; diff --git a/app/src/main/java/com/gh/gamecenter/catalog/CatalogActivity.kt b/app/src/main/java/com/gh/gamecenter/catalog/CatalogActivity.kt deleted file mode 100644 index dbe7ac9e36..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/CatalogActivity.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import com.gh.base.DownloadToolbarActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.updateStatusBarColor - -class CatalogActivity : DownloadToolbarActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setToolbarMenu(R.menu.menu_download) - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } - - override fun showDownloadMenu(): Boolean { - return true - } - - override fun provideNormalIntent(): Intent { - return getTargetIntent(this, CatalogActivity::class.java, CatalogFragment::class.java) - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } - - override fun isAutoResetViewBackgroundEnabled() = true - - companion object { - fun getIntent(context: Context, catalogId: String, catalogTitle: String, entrance: String): Intent { - val bundle = Bundle() - bundle.putString(EntranceConsts.KEY_CATALOG_ID, catalogId) - bundle.putString(EntranceConsts.KEY_CATALOG_TITLE, catalogTitle) - bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance) - return getTargetIntent(context, CatalogActivity::class.java, CatalogFragment::class.java, bundle) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/CatalogAdapter.kt b/app/src/main/java/com/gh/gamecenter/catalog/CatalogAdapter.kt deleted file mode 100644 index 25211385ab..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/CatalogAdapter.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.content.Context -import android.view.View -import android.view.ViewGroup -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.utils.goneIf -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.R -import com.gh.gamecenter.databinding.CatalogItemBinding -import com.gh.gamecenter.entity.CatalogEntity -import com.lightgame.adapter.BaseRecyclerAdapter - -class CatalogAdapter( - context: Context, - private val mFragment: CatalogFragment, - private val mViewModel: CatalogViewModel, - private val mList: List -) : BaseRecyclerAdapter(context) { - - override fun getItemCount() = mList.size - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = - CatalogItemViewHolder(parent.toBinding()) - - override fun onBindViewHolder(holder: CatalogItemViewHolder, position: Int) { - holder.binding.run { - val catalogEntity = mList[position] - catalogName.text = catalogEntity.name - recommendTag.goneIf(!catalogEntity.recommended) - if (catalogEntity.name == mViewModel.selectedCatalogName) { - selectedTag.visibility = View.VISIBLE - catalogName.setTextColor(R.color.text_theme.toColor(mContext)) - root.setBackgroundColor(R.color.ui_surface.toColor(mContext)) - } else { - selectedTag.visibility = View.GONE - catalogName.setTextColor(R.color.text_primary.toColor(mContext)) - root.background = null - } - root.setOnClickListener { - if (catalogEntity.name != mViewModel.selectedCatalogName) { - mViewModel.selectedCatalogName = catalogEntity.name - mViewModel.logSubCatalogClick(position) - mFragment.changeCatalog(position) - notifyDataSetChanged() - } - } - } - } - - class CatalogItemViewHolder(val binding: CatalogItemBinding) : BaseRecyclerViewHolder(binding.root) -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt b/app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt deleted file mode 100644 index 7e932e6b73..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt +++ /dev/null @@ -1,240 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.os.Bundle -import android.view.View -import androidx.core.os.bundleOf -import androidx.lifecycle.Observer -import com.gh.gamecenter.common.base.fragment.LazyFragment -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.viewModelProviderFromParent -import com.gh.gamecenter.common.view.FixLinearLayoutManager -import com.gh.gamecenter.R -import com.gh.gamecenter.databinding.FragmentCatalogBinding -import com.gh.gamecenter.entity.CatalogEntity - -class CatalogFragment : LazyFragment() { - - private var mBinding: FragmentCatalogBinding? = null - private var mViewModel: CatalogViewModel? = null - private var mEntity: CatalogEntity? = null - private var mSpecialCatalogFragment: SpecialCatalogFragment? = null - private var mSubCatalogFragment: SubCatalogFragment? = null - - private var mCatalogId: String = "" - private var mCatalogTitle: String = "" - private var mLastSelectedPosition = -1 - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - savedInstanceState?.run { - mLastSelectedPosition = getInt(EntranceConsts.KEY_LAST_SELECTED_POSITION) - } - } - - override fun onSaveInstanceState(outState: Bundle) { - mViewModel?.run { - outState.putInt(EntranceConsts.KEY_LAST_SELECTED_POSITION, selectedCatalogPosition) - } - super.onSaveInstanceState(outState) - } - - override fun getRealLayoutId() = R.layout.fragment_catalog - - override fun onRealLayoutInflated(inflatedView: View) { - mBinding = FragmentCatalogBinding.bind(inflatedView) - } - - override fun onFragmentFirstVisible() { - mCatalogId = arguments?.getString(EntranceConsts.KEY_CATALOG_ID) ?: "" - mCatalogTitle = arguments?.getString(EntranceConsts.KEY_CATALOG_TITLE) ?: "" - mViewModel = viewModelProviderFromParent(CatalogViewModel.Factory(mCatalogId, mCatalogTitle), mCatalogId) - - mViewModel?.validEntranceName = if (mEntrance.contains("首页")) "首页" else "板块" - if (arguments?.getBoolean(EntranceConsts.KEY_IS_HOME) == true) { - mViewModel?.validEntranceName = "首页Tab栏" - } - mViewModel?.logAppearance() - - super.onFragmentFirstVisible() - } - - override fun initRealView() { - super.initRealView() - - setNavigationTitle(mCatalogTitle) - mViewModel?.catalogs?.observe(viewLifecycleOwner, Observer { - mBinding?.run { - reuseLoading.root.visibility = View.GONE - if (it != null) { - reuseNoConnection.root.visibility = View.GONE - if (it.subCatalog.isNotEmpty()) { - containerCatalog.visibility = View.VISIBLE - reuseNoneData.root.visibility = View.GONE - mEntity = it - if (mEntity!!.hasSpecial) { - val specialEntity = CatalogEntity.SubCatalogEntity(name = "精选") - (mEntity!!.subCatalog as ArrayList).add(0, specialEntity) - } - initView() - } else { - containerCatalog.visibility = View.GONE - reuseNoneData.root.visibility = View.VISIBLE - } - } else { - containerCatalog.visibility = View.GONE - reuseNoneData.root.visibility = View.GONE - reuseNoConnection.root.visibility = View.VISIBLE - reuseNoConnection.root.setOnClickListener { - reuseNoConnection.root.visibility = View.GONE - reuseLoading.root.visibility = View.VISIBLE - mViewModel?.getCatalogs() - } - } - } - }) - - // 嵌入在首页时特殊处理 - if (arguments?.getBoolean(EntranceConsts.KEY_IS_HOME) == true) { - mBinding?.divider?.visibility = View.GONE - mBinding?.root?.setBackgroundColor(R.color.ui_surface.toColor(requireContext())) - mBinding?.root?.setPadding(0, 8F.dip2px(), 0, 0) - mBinding?.rvCatalog?.setBackgroundColor(R.color.ui_background.toColor(requireContext())) - } - } - - private fun initView() { - mEntity?.run { - mViewModel?.run { - if (subCatalog.isNotEmpty()) { - if (mLastSelectedPosition != -1) { - selectedCatalogPosition = mLastSelectedPosition - selectedCatalogName = subCatalog[mLastSelectedPosition].name - } else { - selectedCatalogPosition = 0 - selectedCatalogName = subCatalog[0].name - } - mBinding?.rvCatalog?.layoutManager = FixLinearLayoutManager(requireContext()) - mBinding?.rvCatalog?.adapter = - CatalogAdapter(requireContext(), this@CatalogFragment, this, subCatalog) - - if (hasSpecial && selectedCatalogPosition == 0) { - mSpecialCatalogFragment = - childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.name) as? SpecialCatalogFragment - ?: SpecialCatalogFragment() - mSpecialCatalogFragment?.arguments = bundleOf( - EntranceConsts.KEY_IS_CATEGORY_V2 to false, - EntranceConsts.KEY_CATALOG_ID to id, - EntranceConsts.KEY_CATALOG_TITLE to mCatalogTitle, - EntranceConsts.KEY_EXPOSURE_SOURCE to arguments?.getParcelable( - EntranceConsts.KEY_EXPOSURE_SOURCE - ) - ) - childFragmentManager.beginTransaction().replace( - R.id.container_sub_catalog, - mSpecialCatalogFragment!!, - SpecialCatalogFragment::class.java.name - ).commitAllowingStateLoss() - } else { - mSubCatalogFragment = - childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.name) as? SubCatalogFragment - ?: SubCatalogFragment() - mSubCatalogFragment?.arguments = bundleOf( - EntranceConsts.KEY_CATALOG_ID to id, - EntranceConsts.KEY_PRIMARY_CATALOG_ID to subCatalog[selectedCatalogPosition].id, - EntranceConsts.KEY_CATALOG_TITLE to mCatalogTitle - ) - childFragmentManager.beginTransaction().replace( - R.id.container_sub_catalog, - mSubCatalogFragment!!, - SubCatalogFragment::class.java.name - ).commitAllowingStateLoss() - } - } - } - } - } - - fun changeCatalog(position: Int) { - mEntity?.run { - mViewModel?.run { - if (hasSpecial) { - changeCatalogIfHasSpecial(position) - } else { - changeSubCatalogInSubCatalogFragment(position) - } - selectedCatalogPosition = position - } - } - } - - private fun changeCatalogIfHasSpecial(position: Int) { - mViewModel?.run { - when { - selectedCatalogPosition == 0 -> changeToSubCatalogFragment(position) - position == 0 -> changeToSpecialCatalogFragment() - else -> changeSubCatalogInSubCatalogFragment(position) - } - } - } - - private fun changeToSubCatalogFragment(position: Int) { - mEntity?.run { - mSubCatalogFragment = - childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.name) as? SubCatalogFragment - ?: SubCatalogFragment() - mSubCatalogFragment?.arguments = bundleOf( - EntranceConsts.KEY_CATALOG_ID to id, - EntranceConsts.KEY_PRIMARY_CATALOG_ID to subCatalog[position].id, - EntranceConsts.KEY_CATALOG_TITLE to mCatalogTitle - ) - childFragmentManager.beginTransaction().replace( - R.id.container_sub_catalog, - mSubCatalogFragment!!, - SubCatalogFragment::class.java.name - ).commitAllowingStateLoss() - } - } - - private fun changeToSpecialCatalogFragment() { - mEntity?.run { - mSpecialCatalogFragment = - childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.name) as? SpecialCatalogFragment - ?: SpecialCatalogFragment() - mSpecialCatalogFragment?.arguments = bundleOf( - EntranceConsts.KEY_IS_CATEGORY_V2 to false, - EntranceConsts.KEY_CATALOG_ID to id, - EntranceConsts.KEY_CATALOG_TITLE to mCatalogTitle, - EntranceConsts.KEY_EXPOSURE_SOURCE to arguments?.getParcelable( - EntranceConsts.KEY_EXPOSURE_SOURCE - ) - ) - childFragmentManager.beginTransaction().replace( - R.id.container_sub_catalog, - mSpecialCatalogFragment!!, - SpecialCatalogFragment::class.java.name - ).commitAllowingStateLoss() - } - } - - private fun changeSubCatalogInSubCatalogFragment(position: Int) { - mEntity?.run { - if (mSubCatalogFragment?.isStateSaved == false) { - mSubCatalogFragment?.arguments = bundleOf( - EntranceConsts.KEY_CATALOG_ID to id, - EntranceConsts.KEY_PRIMARY_CATALOG_ID to subCatalog[position].id, - EntranceConsts.KEY_CATALOG_TITLE to mCatalogTitle - ) - } - mSubCatalogFragment?.changeSubCatalog(subCatalog[position].id) - } - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - mBinding?.rvCatalog?.adapter?.run { - notifyItemRangeChanged(0, itemCount) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/CatalogViewModel.kt b/app/src/main/java/com/gh/gamecenter/catalog/CatalogViewModel.kt deleted file mode 100644 index 4934cb3067..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/CatalogViewModel.kt +++ /dev/null @@ -1,72 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.annotation.SuppressLint -import android.app.Application -import androidx.lifecycle.AndroidViewModel -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.gh.common.util.LogUtils -import com.gh.gamecenter.entity.CatalogEntity -import com.gh.gamecenter.common.retrofit.BiResponse -import com.gh.gamecenter.retrofit.RetrofitManager -import com.halo.assistant.HaloApp -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.schedulers.Schedulers - -class CatalogViewModel(application: Application, val catalogId: String, val catalogTitle: String) : - AndroidViewModel(application) { - - private val api = RetrofitManager.getInstance().api - var catalogs = MutableLiveData() - - var selectedCatalogName: String = "" - var selectedCatalogPosition: Int = 0 - - var validEntranceName: String = "" - - init { - getCatalogs() - } - - @SuppressLint("CheckResult") - fun getCatalogs() { - api.getCatalogs(catalogId) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(object : BiResponse() { - override fun onSuccess(data: CatalogEntity) { - catalogs.postValue(data) - } - - override fun onFailure(exception: Exception) { - super.onFailure(exception) - catalogs.postValue(null) - } - }) - } - - fun logAppearance() { - LogUtils.logNewCatalogAppearanceEvent(validEntranceName, catalogTitle) - } - - fun logSubCatalogClick(position: Int) { - LogUtils.logSubCatalogClickEvent(validEntranceName, "${catalogTitle}_${selectedCatalogName}", position) - } - - fun logSubCatalogContentClick(itemName: String, listPosition: Int) { - LogUtils.logSubCatalogContentClickEvent( - validEntranceName, - "${catalogTitle}_${selectedCatalogName}_${itemName}", - selectedCatalogPosition, - listPosition - ) - } - - class Factory(private val catalogId: String, private val catalogTitle: String) : - ViewModelProvider.NewInstanceFactory() { - override fun create(modelClass: Class): T { - return CatalogViewModel(HaloApp.getInstance().application, catalogId, catalogTitle) as T - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListActivity.kt b/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListActivity.kt deleted file mode 100644 index 5cff9351d9..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListActivity.kt +++ /dev/null @@ -1,56 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import com.gh.base.DownloadToolbarActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.updateStatusBarColor -import com.gh.gamecenter.entity.CatalogEntity - -class NewCatalogListActivity : DownloadToolbarActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setToolbarMenu(R.menu.menu_download) - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } - - override fun showDownloadMenu(): Boolean { - return true - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } - - override fun isAutoResetViewBackgroundEnabled() = true - - companion object { - fun getIntent( - context: Context, - primaryCatalogId: String, // 一级分类 id - primaryCatalogName: String, // 一级分类名 - catalogTitle: String, - catalog: CatalogEntity, - initTitle: String - ): Intent { - val bundle = Bundle() - bundle.putParcelable(EntranceConsts.KEY_DATA, catalog) - bundle.putString(EntranceConsts.KEY_PRIMARY_CATALOG_ID, primaryCatalogId) - bundle.putString(EntranceConsts.KEY_PRIMARY_CATALOG_NAME, primaryCatalogName) - bundle.putString(EntranceConsts.KEY_NAME, catalog.name) - bundle.putString(EntranceConsts.KEY_CATALOG_TITLE, catalogTitle) - bundle.putString(EntranceConsts.KEY_CATALOG_INIT_TITLE, initTitle) - return getTargetIntent( - context, - NewCatalogListActivity::class.java, - NewCatalogListFragment::class.java, - bundle - ) - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListAdapter.kt b/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListAdapter.kt deleted file mode 100644 index 71deadefa9..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListAdapter.kt +++ /dev/null @@ -1,192 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.content.Context -import android.util.SparseArray -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import com.gh.common.exposure.IExposable -import com.gh.common.util.DownloadItemUtils -import com.gh.gamecenter.GameDetailActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.adapter.viewholder.GameViewHolder -import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.gamecenter.common.exposure.ExposureSource -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.viewholder.FooterViewHolder -import com.gh.gamecenter.core.utils.StringUtils -import com.gh.gamecenter.eventbus.EBDownloadStatus -import com.gh.gamecenter.feature.entity.GameEntity -import com.gh.gamecenter.feature.exposure.ExposureEvent -import com.gh.gamecenter.feature.exposure.ExposureType -import com.gh.gamecenter.feature.game.GameItemViewHolder -import com.lightgame.download.DownloadEntity - -class NewCatalogListAdapter( - context: Context, - private val mBaseExposureSource: ExposureSource, - private val mViewModel: NewCatalogListViewModel, - private val mEntrance: String? -) : ListAdapter(context), IExposable { - - private val mExposureEventSparseArray: SparseArray = SparseArray() - - val positionAndPackageMap = HashMap() - - override fun setListData(updateData: MutableList?) { - // 记录游戏位置 - if (updateData != null) { - for (i in 0 until updateData.size) { - val gameEntity = updateData[i] - var packages = gameEntity.id - for (apkEntity in gameEntity.getApk()) { - packages += apkEntity.packageName - } - positionAndPackageMap[packages + i] = i - } - } - super.setListData(updateData) - } - - fun clearPositionAndPackageMap() { - positionAndPackageMap.clear() - } - - override fun areItemsTheSame(oldItem: GameEntity?, newItem: GameEntity?): Boolean { - return oldItem?.id == newItem?.id - } - - override fun getItemViewType(position: Int): Int { - if (position == itemCount - 1) { - return ItemViewType.ITEM_FOOTER - } - return ItemViewType.GAME_NORMAL - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { - return when (viewType) { - ItemViewType.GAME_NORMAL -> { - GameItemViewHolder(parent.toBinding()) - } - else -> { - FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)) - } - } - } - - override fun getItemCount(): Int { - return if (mEntityList == null || mEntityList.isEmpty()) return 0 else mEntityList.size + 1 - } - - override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { - if (holder is GameItemViewHolder) { - val padTop = if (position == 0) 16F.dip2px() else 8F.dip2px() - holder.itemView.setPadding(16F.dip2px(), padTop, 16F.dip2px(), 8F.dip2px()) - - val gameEntity = mEntityList[position] - - holder.bindGameItem(gameEntity) - holder.initServerType(gameEntity) - - val sortType = mViewModel.sortType.value - val sortSize = mViewModel.sortSize.text - val toolbarTitle = mViewModel.title - val selectedCatalogName = mViewModel.selectedCatalog.name - - val exposureSources = ArrayList() - exposureSources.add(mBaseExposureSource) - exposureSources.add(ExposureSource(toolbarTitle)) - exposureSources.add(ExposureSource("二级分类详情", "$selectedCatalogName+$sortType+$sortSize")) - - val event = ExposureEvent.createEvent(gameEntity, exposureSources, null, ExposureType.EXPOSURE) - mExposureEventSparseArray.put(position, event) - - holder.itemView.setOnClickListener { - GameDetailActivity.startGameDetailActivity( - mContext, - gameEntity, - StringUtils.buildString( - mEntrance, - "+(", - toolbarTitle, - ":列表[", - selectedCatalogName, - "=", - sortType, - "=", - (position + 1).toString(), - "])" - ), - traceEvent = event - ) - } - DownloadItemUtils.setOnClickListener( - mContext, - holder.binding.downloadBtn, - gameEntity, - position, - this, - StringUtils.buildString( - StringUtils.buildString( - mEntrance, - "+(", - toolbarTitle, - ":列表[", - selectedCatalogName, - "=", - sortType, - "=", - (position + 1).toString(), - "])" - ) - ), - location = StringUtils.buildString(selectedCatalogName, ":", gameEntity.name), - traceEvent = event - ) - - DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(holder.binding), "star&brief") - } else if (holder is FooterViewHolder) { - holder.initItemPadding() - holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver) - } - } - - fun notifyItemByDownload(download: DownloadEntity) { - for (key in positionAndPackageMap.keys) { - // sentry上报download.packageName可能为空 - if (download.packageName != null - && download.gameId != null - && key.contains(download.packageName) - && key.contains(download.gameId) - ) { - val position = positionAndPackageMap[key] - if (position != null && mEntityList != null && position < mEntityList.size) { - mEntityList[position].getEntryMap()[download.platform] = download - notifyItemChanged(position) - } - } - } - } - - fun notifyItemAndRemoveDownload(status: EBDownloadStatus) { - for (key in positionAndPackageMap.keys) { - if (key.contains(status.packageName) && key.contains(status.gameId)) { - val position = positionAndPackageMap[key] - if (position != null && mEntityList != null && position < mEntityList.size) { - mEntityList[position].getEntryMap().remove(status.platform) - notifyItemChanged(position) - } - } - } - } - - override fun getEventByPosition(pos: Int): ExposureEvent? { - return mExposureEventSparseArray.get(pos) - } - - override fun getEventListByPosition(pos: Int): List? { - return null - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListFragment.kt b/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListFragment.kt deleted file mode 100644 index f32835296c..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListFragment.kt +++ /dev/null @@ -1,209 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.os.Bundle -import android.view.View -import com.ethanhua.skeleton.Skeleton -import com.gh.common.exposure.ExposureListener -import com.gh.common.util.DialogUtils -import com.gh.common.view.CatalogFilterView -import com.gh.common.xapk.XapkInstaller -import com.gh.common.xapk.XapkUnzipStatus -import com.gh.download.DownloadManager -import com.gh.gamecenter.R -import com.gh.gamecenter.common.constant.Constants -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.observeNonNull -import com.gh.gamecenter.common.baselist.ListFragment -import com.gh.gamecenter.common.exposure.ExposureSource -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.viewModelProvider -import com.gh.gamecenter.databinding.FragmentCatalogListBinding -import com.gh.gamecenter.entity.CatalogEntity -import com.gh.gamecenter.feature.entity.GameEntity -import com.gh.gamecenter.entity.SubjectSettingEntity -import com.gh.gamecenter.eventbus.EBDownloadStatus -import com.gh.gamecenter.eventbus.EBPackage -import com.lightgame.download.DataWatcher -import com.lightgame.download.DownloadEntity -import org.greenrobot.eventbus.Subscribe -import org.greenrobot.eventbus.ThreadMode - -class NewCatalogListFragment : ListFragment() { - - private var mPrimaryCatalogName: String = "" // 一级分类名 - private var mPrimaryCatalogId: String = "" // 一级分类 id - private var mPrimeCatalog: CatalogEntity? = null - private var mSubCatalogList = arrayListOf() - private var mInitCatalogName = "" - private var mAdapter: NewCatalogListAdapter? = null - private val mDataWatcher = object : DataWatcher() { - override fun onDataChanged(downloadEntity: DownloadEntity) { - mAdapter?.notifyItemByDownload(downloadEntity) - - if (downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS] == XapkUnzipStatus.FAILURE.name) { - showUnzipFailureDialog(downloadEntity) - } - } - - override fun onDataInit(downloadEntity: DownloadEntity) { - mAdapter?.notifyItemByDownload(downloadEntity) - } - } - - private var mBinding: FragmentCatalogListBinding? = null - private lateinit var mExposureListener: ExposureListener - private lateinit var mViewModel: NewCatalogListViewModel - - override fun getLayoutId() = 0 - - override fun getInflatedLayout() = FragmentCatalogListBinding.inflate(layoutInflater).apply { mBinding = this }.root - - override fun provideListViewModel() = viewModelProvider() - - override fun provideListAdapter() = mAdapter - ?: NewCatalogListAdapter( - requireContext(), - ExposureSource(mPrimaryCatalogName), - mViewModel, - mEntrance - ).apply { mAdapter = this } - - override fun getItemDecoration() = null - - override fun onCreate(savedInstanceState: Bundle?) { - mViewModel = provideListViewModel() - - mViewModel.title = arguments?.getString(EntranceConsts.KEY_NAME) ?: "" - mViewModel.categoryTitle = arguments?.getString(EntranceConsts.KEY_CATALOG_TITLE) ?: "" - mEntrance = arguments?.getString(EntranceConsts.KEY_ENTRANCE) ?: Constants.ENTRANCE_UNKNOWN - mPrimeCatalog = arguments?.getParcelable(EntranceConsts.KEY_DATA) - mSubCatalogList = mPrimeCatalog?.subCatalog as? ArrayList ?: arrayListOf() - - mInitCatalogName = arguments?.getString(EntranceConsts.KEY_CATALOG_INIT_TITLE) ?: "" - mPrimaryCatalogName = arguments?.getString(EntranceConsts.KEY_PRIMARY_CATALOG_NAME) ?: "" - mPrimaryCatalogId = arguments?.getString(EntranceConsts.KEY_PRIMARY_CATALOG_ID) ?: "" - - mViewModel.selectedCatalog = mSubCatalogList.find { entity -> entity.name == mInitCatalogName } - ?: CatalogEntity.SubCatalogEntity() - mViewModel.primaryCatalogId = mPrimaryCatalogId - initSortType() - - super.onCreate(savedInstanceState) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - setNavigationTitle(mViewModel.title) - - initFilterView() - - mViewModel.refresh.observeNonNull(this) { onRefresh() } - - mExposureListener = ExposureListener(this, mAdapter!!) - mListRv.addOnScrollListener(mExposureListener) - - mSkeletonScreen = Skeleton.bind(mBinding?.listSkeleton) - .shimmer(true) - .angle(Constants.SHIMMER_ANGLE) - .color(R.color.ui_skeleton_highlight) - .duration(Constants.SHIMMER_DURATION) - .maskWidth(Constants.MASK_WIDTH) - .gradientCenterColorWidth(Constants.GRADIENT_CENTER_COLOR_WIDTH) - .load(R.layout.fragment_tags_skeleton) - .show() - } - - private fun initSortType() { - mPrimeCatalog?.switch?.run { - if (hotSort == "on") { - mViewModel.sortType = CatalogFilterView.SortType.RECOMMENDED - return@run - } - if (newSort == "on") { - mViewModel.sortType = CatalogFilterView.SortType.NEWEST - return@run - } - if (starSort == "on") { - mViewModel.sortType = CatalogFilterView.SortType.RATING - return@run - } - } - } - - private fun initFilterView() { - mBinding?.filterContainer?.run { - visibility = View.VISIBLE - setTypeList(mPrimeCatalog?.switch ?: CatalogEntity.CatalogSwitch()) - setCatalogList(mSubCatalogList, mInitCatalogName) - setOnConfigSetupListener(object : CatalogFilterView.OnCatalogFilterSetupListener { - override fun onSetupSortSize(sortSize: SubjectSettingEntity.Size) { - mViewModel.updateSortConfig(sortSize = sortSize) - } - - override fun onSetupSortType(sortType: CatalogFilterView.SortType) { - mViewModel.updateSortConfig(sortType = sortType) - } - - override fun onSetupSortCatalog(sortCatalog: CatalogEntity.SubCatalogEntity) { - mViewModel.updateSortConfig(sortCatalog = sortCatalog) - } - }) - } - - } - - override fun onResume() { - super.onResume() - DownloadManager.getInstance().addObserver(mDataWatcher) - } - - override fun onPause() { - super.onPause() - DownloadManager.getInstance().removeObserver(mDataWatcher) - } - - override fun onRefresh() { - mAdapter?.clearPositionAndPackageMap() - - super.onRefresh() - } - - // 下载被删除事件 - @Subscribe(threadMode = ThreadMode.MAIN) - fun onEventMainThread(status: EBDownloadStatus) { - if ("delete" == status.status) { - mAdapter?.notifyItemAndRemoveDownload(status) - } - } - - // 安装/卸载 事件 - @Subscribe(threadMode = ThreadMode.MAIN) - fun onEventMainThread(busFour: EBPackage) { - if (busFour.isInstalledOrUninstalled()) { - mAdapter?.notifyDataSetChanged() - } - } - - fun showUnzipFailureDialog(downloadEntity: DownloadEntity) { - val data = mAdapter?.positionAndPackageMap ?: return - for (gameAndPosition in data) { - if (gameAndPosition.key.contains(downloadEntity.packageName)) { - val targetView = mLayoutManager.findViewByPosition(gameAndPosition.value) - if (targetView != null) { - DialogUtils.showUnzipFailureDialog(requireContext(), downloadEntity) - return - } - } - } - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - mBinding?.filterContainer?.run { - setRootBackgroundColor(R.color.ui_surface.toColor(requireContext())) - setItemTextColor(R.color.text_secondary.toColor(requireContext())) - updatePopupWindow() - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListViewModel.kt b/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListViewModel.kt deleted file mode 100644 index 4eba7e64f3..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/NewCatalogListViewModel.kt +++ /dev/null @@ -1,98 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.app.Application -import androidx.lifecycle.MutableLiveData -import com.gh.gamecenter.common.entity.ExposureEntity -import com.gh.common.exposure.ExposureUtils -import com.gh.gamecenter.core.utils.UrlFilterUtils -import com.gh.common.view.CatalogFilterView -import com.gh.gamecenter.common.baselist.ListViewModel -import com.gh.gamecenter.entity.CatalogEntity -import com.gh.gamecenter.feature.entity.GameEntity -import com.gh.gamecenter.entity.SubjectSettingEntity -import com.gh.gamecenter.retrofit.RetrofitManager -import io.reactivex.Observable -import io.reactivex.Single - -class NewCatalogListViewModel(application: Application) : ListViewModel(application) { - - var title = "" // 显示在 Toolbar 的标题 - var categoryTitle = "" // 跳转进来的分类的标题 - - val refresh = MutableLiveData() - - var selectedCatalog = CatalogEntity.SubCatalogEntity() - var sortType = CatalogFilterView.SortType.RECOMMENDED - var sortSize = SubjectSettingEntity.Size() - - var primaryCatalogId = "" // 一级分类 id - private val sensitiveApi = RetrofitManager.getInstance().api - - override fun provideDataObservable(page: Int): Observable>? = null - - override fun provideDataSingle(page: Int): Single> { - return if (selectedCatalog.link.type == "column") { // column(专题)/tag(标签) - sensitiveApi.getColumn(selectedCatalog.link.link, getSortType(), getSortSize(), page) // 专题 - } else { - sensitiveApi.getGamesWithSpecificTag(getSortSize(), getSortType(), page) // 标签 - } - } - - override fun mergeResultLiveData() { - mResultLiveData.addSource(mListLiveData) { - it.forEach { game -> game.hideSizeInsideDes = true } - ExposureUtils.updateExposureInfo( - gameList = it, - containerId = primaryCatalogId, - containerType = ExposureEntity.CATEGORY_ID - ) - mResultLiveData.postValue(it) - } - } - - fun updateSortConfig( - sortSize: SubjectSettingEntity.Size? = null, - sortType: CatalogFilterView.SortType? = null, - sortCatalog: CatalogEntity.SubCatalogEntity? = null - ) { - when { - sortSize != null && sortSize != this.sortSize -> { - this.sortSize = sortSize - refresh.postValue(true) - } - - sortType != null && sortType != this.sortType -> { - this.sortType = sortType - refresh.postValue(true) - } - - sortCatalog != null && sortCatalog != selectedCatalog -> { - selectedCatalog = sortCatalog - refresh.postValue(true) - } - } - } - - private fun getSortSize(): String? { - return if (selectedCatalog.link.type == "column") { - UrlFilterUtils.getFilterQuery( - "min_size", sortSize.min.toString(), - "max_size", sortSize.max.toString() - ) - } else { - UrlFilterUtils.getFilterQuery( - "tag_id", selectedCatalog.link.link, - "min_size", sortSize.min.toString(), - "max_size", sortSize.max.toString() - ) - } - } - - private fun getSortType(): String? { - return when (sortType) { - CatalogFilterView.SortType.RECOMMENDED -> if (selectedCatalog.link.type == "column") "position:1" else "download:-1" - CatalogFilterView.SortType.NEWEST -> "publish:-1" - CatalogFilterView.SortType.RATING -> "star:-1" - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogAdapter.kt b/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogAdapter.kt deleted file mode 100644 index fbd738998e..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogAdapter.kt +++ /dev/null @@ -1,54 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.content.Context -import android.view.ViewGroup -import com.gh.gamecenter.R -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.databinding.SubCatalogItemBinding -import com.gh.gamecenter.entity.CatalogEntity -import com.lightgame.adapter.BaseRecyclerAdapter - -class SubCatalogAdapter( - context: Context, - private val mCatalogViewModel: CatalogViewModel, - private val mPrimaryCatalog: CatalogEntity, - private var mList: List -) : BaseRecyclerAdapter(context) { - - private val mTypes = listOf("专题", "标签") - - override fun getItemCount() = mList.size - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = - SubCatalogItemViewHolder(parent.toBinding()) - - override fun onBindViewHolder(holder: SubCatalogItemViewHolder, position: Int) { - holder.binding.run { - val catalogEntity = mList[position] - ImageUtils.display(catalogIcon, catalogEntity.icon) - catalogName.text = catalogEntity.name - catalogName.setTextColor(R.color.text_primary.toColor(mContext)) - recommendTag.goneIf(!catalogEntity.recommended) - root.setOnClickListener { - mCatalogViewModel.logSubCatalogContentClick(catalogEntity.name, position) - if (mTypes.contains(catalogEntity.type)) { - root.context.startActivity( - NewCatalogListActivity.getIntent( - mContext, - mCatalogViewModel.catalogId, - mCatalogViewModel.catalogTitle, - catalogEntity.name, - mPrimaryCatalog, - catalogEntity.name - ) - ) - } else { - DialogHelper.showUpgradeDialog(mContext) - } - } - } - } - - class SubCatalogItemViewHolder(val binding: SubCatalogItemBinding) : BaseRecyclerViewHolder(binding.root) -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogFragment.kt b/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogFragment.kt deleted file mode 100644 index 51e9fef87e..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogFragment.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.os.Bundle -import android.view.View -import androidx.lifecycle.Observer -import androidx.recyclerview.widget.GridLayoutManager -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.viewModelProvider -import com.gh.gamecenter.common.utils.viewModelProviderFromParent -import com.gh.gamecenter.databinding.FragmentSubCatalogBinding -import com.gh.gamecenter.entity.CatalogEntity -import com.gh.gamecenter.common.base.fragment.ToolbarFragment - -class SubCatalogFragment : ToolbarFragment() { - - private var mBinding: FragmentSubCatalogBinding? = null - private var mViewModel: SubCatalogViewModel? = null - private var mCatalogViewModel: CatalogViewModel? = null - private var mEntity: CatalogEntity? = null - private var mCatalogId: String = "" - private var mCatalogTitle: String = "" - private var mPrimaryCatalogId: String = "" - - override fun getLayoutId() = 0 - - override fun getInflatedLayout() = FragmentSubCatalogBinding.inflate(layoutInflater).apply { mBinding = this }.root - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - mCatalogId = arguments?.getString(EntranceConsts.KEY_CATALOG_ID) ?: "" - mCatalogTitle = arguments?.getString(EntranceConsts.KEY_CATALOG_TITLE) ?: "" - mPrimaryCatalogId = arguments?.getString(EntranceConsts.KEY_PRIMARY_CATALOG_ID) ?: "" - mViewModel = viewModelProvider(SubCatalogViewModel.Factory(mCatalogId)) - mCatalogViewModel = viewModelProviderFromParent(CatalogViewModel.Factory(mCatalogId, mCatalogTitle), mCatalogId) - mViewModel?.getSubCatalogs(mPrimaryCatalogId) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - mViewModel?.catalogs?.observe(viewLifecycleOwner, Observer { - mBinding?.run { - reuseLoading.root.visibility = View.GONE - if (it != null) { - reuseNoConnection.root.visibility = View.GONE - if (it.subCatalog.isNotEmpty()) { - rvSubCatalog.visibility = View.VISIBLE - reuseNoneData.root.visibility = View.GONE - mEntity = it - initView() - } else { - rvSubCatalog.visibility = View.GONE - reuseNoneData.root.visibility = View.VISIBLE - } - } else { - rvSubCatalog.visibility = View.GONE - reuseNoneData.root.visibility = View.GONE - reuseNoConnection.root.visibility = View.VISIBLE - reuseNoConnection.root.setOnClickListener { - reuseLoading.root.visibility = View.VISIBLE - mViewModel?.getSubCatalogs(mPrimaryCatalogId) - } - } - } - }) - } - - private fun initView() { - mEntity?.takeIf { mCatalogViewModel != null }?.run { - mBinding?.rvSubCatalog?.layoutManager = GridLayoutManager(requireContext(), 3) - mBinding?.rvSubCatalog?.adapter = SubCatalogAdapter(requireContext(), mCatalogViewModel!!, this, subCatalog) - } - } - - fun changeSubCatalog(primaryCatalogId: String) { - mBinding?.run { - mPrimaryCatalogId = primaryCatalogId - rvSubCatalog.visibility = View.GONE - reuseNoneData.root.visibility = View.GONE - reuseNoConnection.root.visibility = View.GONE - reuseLoading.root.visibility = View.VISIBLE - mViewModel?.getSubCatalogs(mPrimaryCatalogId) - } - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - mBinding?.rvSubCatalog?.adapter?.run { - mBinding?.rvSubCatalog?.recycledViewPool?.clear() - notifyItemRangeChanged(0, itemCount) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogViewModel.kt b/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogViewModel.kt deleted file mode 100644 index 0965363148..0000000000 --- a/app/src/main/java/com/gh/gamecenter/catalog/SubCatalogViewModel.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.gh.gamecenter.catalog - -import android.annotation.SuppressLint -import android.app.Application -import androidx.lifecycle.AndroidViewModel -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.gh.gamecenter.entity.CatalogEntity -import com.gh.gamecenter.common.retrofit.BiResponse -import com.gh.gamecenter.retrofit.RetrofitManager -import com.halo.assistant.HaloApp -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.schedulers.Schedulers - -class SubCatalogViewModel(application: Application, private val catalogId: String) : AndroidViewModel(application) { - - private val api = RetrofitManager.getInstance().api - var catalogs = MutableLiveData() - - - @SuppressLint("CheckResult") - fun getSubCatalogs(primaryCatalogId: String) { - api.getSubCatalogs(catalogId, primaryCatalogId) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(object : BiResponse() { - override fun onSuccess(data: CatalogEntity) { - catalogs.postValue(data) - } - - override fun onFailure(exception: Exception) { - super.onFailure(exception) - catalogs.postValue(null) - } - }) - } - - class Factory(private val catalogId: String) : ViewModelProvider.NewInstanceFactory() { - override fun create(modelClass: Class): T { - return SubCatalogViewModel(HaloApp.getInstance().application, catalogId) as T - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryActivity.kt b/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryActivity.kt deleted file mode 100644 index fcef336e93..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryActivity.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.gh.gamecenter.category - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import com.gh.base.DownloadToolbarActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.updateStatusBarColor - -class CategoryDirectoryActivity : DownloadToolbarActivity() { - - companion object { - fun getIntent(context: Context, categoryId: String, categoryTitle: String): Intent { - val bundle = Bundle() - bundle.putString(EntranceConsts.KEY_CATEGORY_ID, categoryId) - bundle.putString(EntranceConsts.KEY_CATEGORY_TITLE, categoryTitle) - return getTargetIntent( - context, - CategoryDirectoryActivity::class.java, - CategoryDirectoryFragment::class.java, - bundle - ) - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setToolbarMenu(R.menu.menu_download) - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } - - override fun showDownloadMenu(): Boolean { - return true - } - - override fun getActivityNameInChinese(): String { - return "游戏分类" - } - - override fun provideNormalIntent(): Intent { - return getTargetIntent(this, CategoryDirectoryActivity::class.java, CategoryDirectoryFragment::class.java) - } - - override fun isAutoResetViewBackgroundEnabled() = true - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryAdapter.kt b/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryAdapter.kt deleted file mode 100644 index 87baedd847..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryAdapter.kt +++ /dev/null @@ -1,157 +0,0 @@ -package com.gh.gamecenter.category - -import android.content.Context -import android.view.View -import android.view.ViewGroup -import android.widget.LinearLayout -import androidx.recyclerview.widget.RecyclerView -import com.gh.common.view.SubCategoryView -import com.gh.gamecenter.R -import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.category.CategoryListActivity.Companion.getIntent -import com.gh.gamecenter.common.utils.ImageUtils -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.core.utils.DisplayUtils -import com.gh.gamecenter.databinding.ItemCategoryBinding -import com.gh.gamecenter.entity.CategoryEntity -import net.cachapa.expandablelayout.ExpandableLayout - -class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : ListAdapter(context) { - - var recyclerView: RecyclerView? = null - var expandStatusMap: HashMap = HashMap() - - private var sixteenDp: Int = 0 - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { - if (sixteenDp == 0) sixteenDp = DisplayUtils.dip2px(parent.context, 16f) - return CategoryViewHolder(parent.toBinding()) - } - - override fun getItemCount(): Int { - return mEntityList.size - } - - override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { - when (holder) { - is CategoryViewHolder -> { - val category = mEntityList[position] - holder.binding.run { - divider.setBackgroundColor(R.color.ui_background.toColor(mContext)) - containerPrimaryCategory.setOnClickListener { - root.context.startActivity(getIntent(root.context, categoryTitle, category, "全部")) - } - ImageUtils.display(iconIv, category.icon) - categoryName.text = category.name - } - holder.bindCategory( - category = mEntityList[position], - expandableStatusMap = expandStatusMap, - isExpended = expandStatusMap[position] != null && expandStatusMap[position] == true, - marginTop = sixteenDp, - categoryTitle = categoryTitle, - expandedAction = { recyclerView?.smoothScrollToPosition(position) }) - } - } - } - - internal class CategoryViewHolder(var binding: ItemCategoryBinding) : RecyclerView.ViewHolder(binding.root) { - fun bindCategory( - category: CategoryEntity, - expandableStatusMap: HashMap, - isExpended: Boolean, - marginTop: Int, - categoryTitle: String, - expandedAction: () -> Unit - ) { - category.data?.let { - var subCategoryView: SubCategoryView? = null - - binding.containerUnexpandable.removeAllViews() - val unexpandableSize = if (it.size > 6) 6 else it.size - val unexpandableCategoryList = it.subList(0, unexpandableSize) - unexpandableCategoryList.forEachIndexed { index, c -> - when (index % 3) { - 0 -> { - val params = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT - ) - if (subCategoryView != null) params.setMargins(0, marginTop, 0, 0) - - subCategoryView = SubCategoryView(binding.root.context) - - subCategoryView?.categoryTitle = categoryTitle - subCategoryView?.primeCategory = category - subCategoryView?.layoutParams = params - - binding.containerUnexpandable.addView(subCategoryView) - subCategoryView?.setLeftCategory(c) - } - 1 -> subCategoryView?.setCenterCategory(c) - 2 -> subCategoryView?.setRightCategory(c) - } - } - - if (it.size >= 7) { - val extraCategoryList = it.subList(6, it.size) - - binding.ivToggle.visibility = View.VISIBLE - binding.ivToggle.setOnClickListener { binding.containerExpandable.toggle() } - when { - isExpended -> binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_up) - else -> binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_down) - } - - val subCategoryViewLinearLayout = LinearLayout(binding.root.context) - subCategoryViewLinearLayout.orientation = LinearLayout.VERTICAL - subCategoryView = SubCategoryView(binding.root.context) - - binding.containerExpandable.removeAllViews() - binding.containerExpandable.addView(subCategoryViewLinearLayout) - binding.containerExpandable.setExpanded(isExpended, false) - binding.containerExpandable.setOnExpansionUpdateListener { _, state -> - when (state) { - ExpandableLayout.State.COLLAPSED -> { - binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_down) - expandableStatusMap[adapterPosition] = false - } - ExpandableLayout.State.EXPANDED -> { - binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_up) - expandableStatusMap[adapterPosition] = true - expandedAction.invoke() - } - } - } - - extraCategoryList.forEachIndexed { index, c -> - when (index % 3) { - 0 -> { - subCategoryView = SubCategoryView(binding.root.context) - - val params = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT - ) - params.setMargins(0, marginTop, 0, 0) - - subCategoryView?.categoryTitle = categoryTitle - subCategoryView?.primeCategory = category - subCategoryView?.layoutParams = params - - subCategoryViewLinearLayout.addView(subCategoryView) - subCategoryView?.setLeftCategory(c) - } - 1 -> subCategoryView?.setCenterCategory(c) - 2 -> subCategoryView?.setRightCategory(c) - } - } - } else { - binding.ivToggle.visibility = View.GONE - binding.containerExpandable.removeAllViews() - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryFragment.kt b/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryFragment.kt deleted file mode 100644 index 0652236291..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryFragment.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.gh.gamecenter.category - -import android.graphics.Color -import android.view.View -import androidx.lifecycle.ViewModelProviders -import com.ethanhua.skeleton.Skeleton -import com.gh.gamecenter.common.constant.Constants -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.view.VerticalItemDecoration -import com.gh.gamecenter.R -import com.gh.gamecenter.common.baselist.LazyListFragment -import com.gh.gamecenter.databinding.FragmentListBaseSkeletonBinding -import com.gh.gamecenter.entity.CategoryEntity - -class CategoryDirectoryFragment : LazyListFragment() { - - private lateinit var mViewModel: CategoryDirectoryListViewModel - private lateinit var mAdapter: CategoryDirectoryAdapter - private var mBinding: FragmentListBaseSkeletonBinding? = null - - override fun getRealLayoutId() = R.layout.fragment_list_base_skeleton - - override fun onRealLayoutInflated(inflatedView: View) { - super.onRealLayoutInflated(inflatedView) - mBinding = FragmentListBaseSkeletonBinding.bind(inflatedView) - } - - override fun onFragmentFirstVisible() { - mViewModel = ViewModelProviders.of(this).get(CategoryDirectoryListViewModel::class.java) - mViewModel.categoryId = arguments?.getString(EntranceConsts.KEY_CATEGORY_ID) ?: "" - mAdapter = - CategoryDirectoryAdapter(requireContext(), arguments?.getString(EntranceConsts.KEY_CATEGORY_TITLE) ?: "") - super.onFragmentFirstVisible() - } - - override fun initRealView() { - super.initRealView() - - setNavigationTitle(arguments?.getString(EntranceConsts.KEY_CATEGORY_TITLE)) - - mSkeletonScreen = Skeleton.bind(mBinding?.listSkeleton) - .shimmer(true) - .angle(Constants.SHIMMER_ANGLE) - .color(R.color.ui_skeleton_highlight) - .duration(Constants.SHIMMER_DURATION) - .maskWidth(Constants.MASK_WIDTH) - .gradientCenterColorWidth(Constants.GRADIENT_CENTER_COLOR_WIDTH) - .load(R.layout.fragment_category_skeleton) - .show() - onLoadRefresh() - - if (arguments?.getBoolean(EntranceConsts.KEY_IS_HOME) == true) { - mListRv?.setPadding( - 0, - context?.resources?.getDimension(R.dimen.home_recyclerview_padding_top)?.toInt() ?: 0, - 0, - 0 - ) - mListRv?.clipToPadding = false - } - - mListRv?.setBackgroundColor(R.color.ui_surface.toColor(requireContext())) - mAdapter.recyclerView = mListRv - mListRefresh?.isEnabled = false - } - - override fun isAutomaticLoad() = false - - override fun provideListAdapter() = mAdapter - - override fun provideListViewModel() = mViewModel - - override fun getItemDecoration() = VerticalItemDecoration(context, 0F, false) - - override fun onLoadRefresh() { - mCachedView?.setBackgroundColor(R.color.ui_surface.toColor(requireContext())) - super.onLoadRefresh() - } - - override fun onLoadDone() { - mCachedView?.setBackgroundColor(Color.TRANSPARENT) - super.onLoadDone() - } - - override fun onLoadEmpty() { - mCachedView?.setBackgroundColor(Color.TRANSPARENT) - super.onLoadEmpty() - } - - override fun onLoadError() { - mCachedView?.setBackgroundColor(Color.TRANSPARENT) - super.onLoadError() - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - mListRv?.setBackgroundColor(R.color.ui_surface.toColor(requireContext())) - mListRv?.adapter?.run { - mListRv?.recycledViewPool?.clear() - notifyItemRangeChanged(0, itemCount) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryListViewModel.kt b/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryListViewModel.kt deleted file mode 100644 index 9cf154d8a1..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/CategoryDirectoryListViewModel.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.gh.gamecenter.category - -import android.app.Application -import com.gh.gamecenter.common.baselist.ListViewModel -import com.gh.gamecenter.entity.CategoryEntity -import com.gh.gamecenter.retrofit.RetrofitManager -import io.reactivex.Observable - -class CategoryDirectoryListViewModel(application: Application) : - ListViewModel(application) { - - var categoryId = "" - - override fun mergeResultLiveData() { - mResultLiveData.addSource(mListLiveData, mResultLiveData::postValue) - } - - override fun provideDataObservable(page: Int): Observable> { - return RetrofitManager.getInstance().api.getCategories(categoryId, page) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/CategoryListActivity.kt b/app/src/main/java/com/gh/gamecenter/category/CategoryListActivity.kt deleted file mode 100644 index 17e3688e66..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/CategoryListActivity.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.gh.gamecenter.category - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import com.gh.base.DownloadToolbarActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.updateStatusBarColor -import com.gh.gamecenter.entity.CategoryEntity - -class CategoryListActivity : DownloadToolbarActivity() { - - companion object { - fun getIntent(context: Context, categoryTitle: String, category: CategoryEntity, initTitle: String): Intent { - val bundle = Bundle() - if (category.data!!.isEmpty() || category.data!![0].name != "全部") { - val plainCategory = CategoryEntity(id = category.id, name = "全部") - ((category.data) as ArrayList).add(0, plainCategory) - } - bundle.putParcelable(EntranceConsts.KEY_DATA, category) - bundle.putString(EntranceConsts.KEY_NAME, category.name) - bundle.putString(EntranceConsts.KEY_CATEGORY_TITLE, categoryTitle) - bundle.putString(EntranceConsts.KEY_CATEGORY_INIT_TITLE, initTitle) - return getTargetIntent( - context, - CategoryListActivity::class.java, - NewCategoryListFragment::class.java, - bundle - ) - } - } - - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setToolbarMenu(R.menu.menu_download) - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } - - override fun showDownloadMenu(): Boolean { - return true - } - - override fun getActivityNameInChinese(): String { - return "游戏分类详情" - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - updateStatusBarColor(R.color.ui_surface, R.color.ui_surface) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/NewCategoryHorizontalAdapter.kt b/app/src/main/java/com/gh/gamecenter/category/NewCategoryHorizontalAdapter.kt deleted file mode 100644 index a733e59934..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/NewCategoryHorizontalAdapter.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.gh.gamecenter.category - -import android.content.Context -import android.view.ViewGroup -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.R -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable -import com.gh.gamecenter.databinding.ItemTagBinding -import com.gh.gamecenter.entity.CategoryEntity -import com.lightgame.adapter.BaseRecyclerAdapter - -class NewCategoryHorizontalAdapter( - context: Context, - private val mViewModel: NewCategoryListViewModel, - private val mCategoryList: List, - private val mSmoothScrollAction: (position: Int) -> Unit -) : BaseRecyclerAdapter(context) { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TagsViewHolder { - return TagsViewHolder(parent.toBinding()) - } - - override fun onBindViewHolder(holder: TagsViewHolder, position: Int) { - val categoryEntity = mCategoryList[position] - - if (mViewModel.selectedCategory.name == categoryEntity.name) { - holder.binding.tagTv.background = R.drawable.bg_tag_text.toDrawable() - holder.binding.tagTv.setTextColor(R.color.text_white.toColor(mContext)) - } else { - holder.binding.tagTv.background = null - holder.binding.tagTv.setTextColor(R.color.text_757575.toColor(mContext)) - } - - holder.binding.tagTv.text = categoryEntity.name - holder.binding.tagTv.setOnClickListener { - mViewModel.changeSelectedCategory(categoryEntity) - notifyDataSetChanged() - - mSmoothScrollAction.invoke(position) - } - } - - override fun getItemCount(): Int { - return mCategoryList.size - } - -} - -class TagsViewHolder(val binding: ItemTagBinding) : BaseRecyclerViewHolder(binding.root) diff --git a/app/src/main/java/com/gh/gamecenter/category/NewCategoryListAdapter.kt b/app/src/main/java/com/gh/gamecenter/category/NewCategoryListAdapter.kt deleted file mode 100644 index 39f8e429c9..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/NewCategoryListAdapter.kt +++ /dev/null @@ -1,185 +0,0 @@ -package com.gh.gamecenter.category - -import android.content.Context -import android.util.SparseArray -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import com.gh.common.exposure.IExposable -import com.gh.common.util.DownloadItemUtils -import com.gh.gamecenter.GameDetailActivity -import com.gh.gamecenter.R -import com.gh.gamecenter.adapter.viewholder.GameViewHolder -import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.gamecenter.common.exposure.ExposureSource -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.viewholder.FooterViewHolder -import com.gh.gamecenter.core.utils.StringUtils -import com.gh.gamecenter.eventbus.EBDownloadStatus -import com.gh.gamecenter.feature.entity.GameEntity -import com.gh.gamecenter.feature.exposure.ExposureEvent -import com.gh.gamecenter.feature.exposure.ExposureType -import com.gh.gamecenter.feature.game.GameItemViewHolder -import com.lightgame.download.DownloadEntity - -class NewCategoryListAdapter( - context: Context, - private val mViewModel: NewCategoryListViewModel, - private val mEntrance: String? -) : ListAdapter(context), IExposable { - - private val mExposureEventSparseArray: SparseArray = SparseArray() - - val positionAndPackageMap = HashMap() - - override fun setListData(updateData: MutableList?) { - // 记录游戏位置 - if (updateData != null) { - for (i in 0 until updateData.size) { - val gameEntity = updateData[i] - var packages = gameEntity.id - for (apkEntity in gameEntity.getApk()) { - packages += apkEntity.packageName - } - positionAndPackageMap[packages + i] = i - } - } - super.setListData(updateData) - } - - fun clearPositionAndPackageMap() { - positionAndPackageMap.clear() - } - - override fun areItemsTheSame(oldItem: GameEntity?, newItem: GameEntity?): Boolean { - return oldItem?.id == newItem?.id - } - - override fun getItemViewType(position: Int): Int { - if (position == itemCount - 1) { - return ItemViewType.ITEM_FOOTER - } - return ItemViewType.GAME_NORMAL - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { - return when (viewType) { - ItemViewType.GAME_NORMAL -> { - GameItemViewHolder(parent.toBinding()) - } - else -> { - FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)) - } - } - } - - override fun getItemCount(): Int { - return if (mEntityList == null || mEntityList.isEmpty()) return 0 else mEntityList.size + 1 - } - - override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { - if (holder is GameItemViewHolder) { - val gameEntity = mEntityList[position] - - holder.bindGameItem(gameEntity) - holder.initServerType(gameEntity) - - val padTop = if (position == 0) 16F.dip2px() else 8F.dip2px() - holder.itemView.setPadding(16F.dip2px(), padTop, 16F.dip2px(), 8F.dip2px()) - - val sortType = if ("download:-1" == mViewModel.getSortType()) "最热" else "最新" - val toolbarTitle = mViewModel.title - val categoryTitle = mViewModel.categoryTitle - val selectedCategoryName = mViewModel.selectedCategory.name ?: "" - - val exposureSources = ArrayList() - exposureSources.add(ExposureSource(categoryTitle, selectedCategoryName)) - exposureSources.add(ExposureSource("二级分类", "$selectedCategoryName+$sortType")) - - val event = ExposureEvent.createEvent(gameEntity, exposureSources, null, ExposureType.EXPOSURE) - mExposureEventSparseArray.put(position, event) - - holder.itemView.setOnClickListener { - GameDetailActivity.startGameDetailActivity( - mContext, - gameEntity, - StringUtils.buildString( - mEntrance, - "+(", - toolbarTitle, - ":列表[", - selectedCategoryName, - "=", - sortType, - "=", - (position + 1).toString(), - "])" - ), - traceEvent = event - ) - } - DownloadItemUtils.setOnClickListener( - mContext, - holder.binding.downloadBtn, - gameEntity, - position, - this, - StringUtils.buildString( - StringUtils.buildString( - mEntrance, - "+(", - toolbarTitle, - ":列表[", - selectedCategoryName, - "=", - sortType, - "=", - (position + 1).toString(), - "])" - ) - ), - location = StringUtils.buildString(selectedCategoryName, ":", gameEntity.name), - traceEvent = event - ) - - DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(holder.binding)) - } else if (holder is FooterViewHolder) { - holder.initItemPadding() - holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver) - } - } - - fun notifyItemByDownload(download: DownloadEntity) { - for (key in positionAndPackageMap.keys) { - if (key.contains(download.packageName) && key.contains(download.gameId)) { - val position = positionAndPackageMap[key] - if (position != null && mEntityList != null && position < mEntityList.size) { - mEntityList[position].getEntryMap()[download.platform] = download - notifyItemChanged(position) - } - } - } - } - - fun notifyItemAndRemoveDownload(status: EBDownloadStatus) { - for (key in positionAndPackageMap.keys) { - if (key.contains(status.packageName) && key.contains(status.gameId)) { - val position = positionAndPackageMap[key] - if (position != null && mEntityList != null && position < mEntityList.size) { - mEntityList[position].getEntryMap().remove(status.platform) - notifyItemChanged(position) - } - } - } - } - - override fun getEventByPosition(pos: Int): ExposureEvent? { - return mExposureEventSparseArray.get(pos) - } - - override fun getEventListByPosition(pos: Int): List? { - return null - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/NewCategoryListFragment.kt b/app/src/main/java/com/gh/gamecenter/category/NewCategoryListFragment.kt deleted file mode 100644 index eb9351de05..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/NewCategoryListFragment.kt +++ /dev/null @@ -1,198 +0,0 @@ -package com.gh.gamecenter.category - -import android.os.Bundle -import android.view.View -import androidx.recyclerview.widget.LinearLayoutManager -import com.ethanhua.skeleton.Skeleton -import com.gh.common.exposure.ExposureListener -import com.gh.common.util.DialogUtils -import com.gh.common.view.ConfigFilterView -import com.gh.common.xapk.XapkInstaller -import com.gh.common.xapk.XapkUnzipStatus -import com.gh.download.DownloadManager -import com.gh.gamecenter.R -import com.gh.gamecenter.common.constant.Constants -import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.common.baselist.ListFragment -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.observeNonNull -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.tryCatchInRelease -import com.gh.gamecenter.common.utils.viewModelProvider -import com.gh.gamecenter.databinding.FragmentTagsBinding -import com.gh.gamecenter.entity.CategoryEntity -import com.gh.gamecenter.feature.entity.GameEntity -import com.gh.gamecenter.entity.SubjectSettingEntity -import com.gh.gamecenter.eventbus.EBDownloadStatus -import com.gh.gamecenter.eventbus.EBPackage -import com.lightgame.download.DataWatcher -import com.lightgame.download.DownloadEntity -import org.greenrobot.eventbus.Subscribe -import org.greenrobot.eventbus.ThreadMode - -class NewCategoryListFragment : ListFragment() { - - private var mPrimeCategory: CategoryEntity? = null - private var mSubCategoryList = arrayListOf() - private val mBinding by lazy { FragmentTagsBinding.inflate(layoutInflater) } - - private var mAdapter: NewCategoryListAdapter? = null - private val mDataWatcher = object : DataWatcher() { - override fun onDataChanged(downloadEntity: DownloadEntity) { - mAdapter?.notifyItemByDownload(downloadEntity) - - if (downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS] == XapkUnzipStatus.FAILURE.name) { - showUnzipFailureDialog(downloadEntity) - } - } - - override fun onDataInit(downloadEntity: DownloadEntity) { - mAdapter?.notifyItemByDownload(downloadEntity) - } - } - - private lateinit var mExposureListener: ExposureListener - private lateinit var mViewModel: NewCategoryListViewModel - - override fun onCreate(savedInstanceState: Bundle?) { - mViewModel = provideListViewModel() - - mViewModel.title = arguments?.getString(EntranceConsts.KEY_NAME) ?: "" - mViewModel.categoryTitle = arguments?.getString(EntranceConsts.KEY_CATEGORY_TITLE) ?: "" - mEntrance = arguments?.getString(EntranceConsts.KEY_ENTRANCE) ?: Constants.ENTRANCE_UNKNOWN - mPrimeCategory = arguments?.getParcelable(EntranceConsts.KEY_DATA) - mSubCategoryList = mPrimeCategory?.data as? ArrayList ?: arrayListOf() - - val initSelectedCategory = arguments?.getString(EntranceConsts.KEY_CATEGORY_INIT_TITLE) - - mViewModel.selectedCategory = - mSubCategoryList.find { categoryEntity -> categoryEntity.name == initSelectedCategory } - ?: CategoryEntity() - - super.onCreate(savedInstanceState) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - setNavigationTitle(mViewModel.title) - - mViewModel.refresh.observeNonNull(this) { onRefresh() } - - mBinding.configContainer.visibility = View.VISIBLE - mBinding.configContainer.updateAllTextView(mViewModel.sortType) - mBinding.configContainer.setOnConfigSetupListener(object : ConfigFilterView.OnConfigFilterSetupListener { - override fun onShowSortSize() {} - - override fun onSetupSortSize(sortSize: SubjectSettingEntity.Size) { - mViewModel.updateSortConfig(sortSize = sortSize) - } - - override fun onSetupSortType(sortType: ConfigFilterView.SortType) { - mViewModel.updateSortConfig(sortType = sortType) - } - }) - - mExposureListener = ExposureListener(this, mAdapter!!) - mListRv.addOnScrollListener(mExposureListener) - - updateCategoriesView(mSubCategoryList) - - mSkeletonScreen = - Skeleton.bind(mBinding.listSkeleton).shimmer(false).load(R.layout.fragment_subject_skeleton).show() - } - - override fun onResume() { - super.onResume() - DownloadManager.getInstance().addObserver(mDataWatcher) - } - - override fun onPause() { - super.onPause() - DownloadManager.getInstance().removeObserver(mDataWatcher) - } - - override fun getItemDecoration() = null - - override fun getLayoutId() = 0 - - override fun getInflatedLayout() = mBinding.root - - override fun provideListViewModel(): NewCategoryListViewModel { - return viewModelProvider() - } - - override fun provideListAdapter(): ListAdapter { - return mAdapter - ?: NewCategoryListAdapter(requireContext(), mViewModel, mEntrance).apply { mAdapter = this } - } - - private fun updateCategoriesView(categoryList: ArrayList) { - mBinding.tagsRecyclerView.layoutManager = - LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false) - mBinding.tagsRecyclerView.adapter = NewCategoryHorizontalAdapter(requireContext(), mViewModel, categoryList) { - mBinding.tagsRecyclerView.smoothScrollToPosition(it) - } - - // 调整选中标签位置 - for (index in 0 until categoryList.size) { - if (categoryList[index].name == mViewModel.selectedCategory.name) { - mBinding.tagsRecyclerView.postDelayed({ - tryCatchInRelease { mBinding.tagsRecyclerView.smoothScrollToPosition(index) } - }, 200) - break - } - } - } - - override fun onRefresh() { - mAdapter?.clearPositionAndPackageMap() - - super.onRefresh() - } - - // 下载被删除事件 - @Subscribe(threadMode = ThreadMode.MAIN) - fun onEventMainThread(status: EBDownloadStatus) { - if ("delete" == status.status) { - mAdapter?.notifyItemAndRemoveDownload(status) - } - } - - // 安装/卸载 事件 - @Subscribe(threadMode = ThreadMode.MAIN) - fun onEventMainThread(busFour: EBPackage) { - if (busFour.isInstalledOrUninstalled()) { - mAdapter?.notifyDataSetChanged() - } - } - - fun showUnzipFailureDialog(downloadEntity: DownloadEntity) { - val data = mAdapter?.positionAndPackageMap ?: return - for (gameAndPosition in data) { - if (gameAndPosition.key.contains(downloadEntity.packageName)) { - val targetView = mLayoutManager.findViewByPosition(gameAndPosition.value) - if (targetView != null) { - DialogUtils.showUnzipFailureDialog(requireContext(), downloadEntity) - return - } - } - } - } - - override fun onDarkModeChanged() { - super.onDarkModeChanged() - mBinding.run { - divider.setBackgroundColor(R.color.ui_background.toColor(requireContext())) - tagsRecyclerView.setBackgroundColor(R.color.ui_surface.toColor(requireContext())) - tagsRecyclerView.adapter?.run { - notifyItemRangeChanged(0, itemCount) - } - configContainer.run { - container.setBackgroundColor(R.color.ui_surface.toColor(requireContext())) - updateAllTextView(mViewModel.sortType) - updatePopupWindow() - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/category/NewCategoryListViewModel.kt b/app/src/main/java/com/gh/gamecenter/category/NewCategoryListViewModel.kt deleted file mode 100644 index 2a6755cb66..0000000000 --- a/app/src/main/java/com/gh/gamecenter/category/NewCategoryListViewModel.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.gh.gamecenter.category - -import android.app.Application -import androidx.lifecycle.MutableLiveData -import com.gh.common.exposure.ExposureUtils -import com.gh.gamecenter.core.utils.UrlFilterUtils -import com.gh.common.view.ConfigFilterView -import com.gh.gamecenter.common.baselist.ListViewModel -import com.gh.gamecenter.entity.CategoryEntity -import com.gh.gamecenter.feature.entity.GameEntity -import com.gh.gamecenter.entity.SubjectSettingEntity -import com.gh.gamecenter.retrofit.RetrofitManager -import io.reactivex.Observable -import io.reactivex.Single - -class NewCategoryListViewModel(application: Application) : ListViewModel(application) { - - var title = "" // 显示在 Toolbar 的标题 - var categoryTitle = "" // 跳转进来的分类的标题 - - val refresh = MutableLiveData() - - var selectedCategory = CategoryEntity() - - var sortType = ConfigFilterView.SortType.RECOMMENDED - private var mSortSize = SubjectSettingEntity.Size() - - override fun provideDataObservable(page: Int): Observable>? { - return null - } - - override fun provideDataSingle(page: Int): Single> { - return RetrofitManager.getInstance() - .api - .getGamesInCategory(selectedCategory.id, getSortType(), getSortSize(), page) - } - - override fun mergeResultLiveData() { - mResultLiveData.addSource(mListLiveData) { - ExposureUtils.updateExposureInfo(it) - mResultLiveData.postValue(it) - } - } - - fun changeSelectedCategory(category: CategoryEntity) { - if (selectedCategory != category) { - selectedCategory = category - - refresh.postValue(true) - } - } - - fun updateSortConfig( - sortSize: SubjectSettingEntity.Size? = null, - sortType: ConfigFilterView.SortType? = null - ) { - if (sortSize != null && sortSize != mSortSize) { - mSortSize = sortSize - refresh.postValue(true) - } else if (sortType != null && sortType != this.sortType) { - this.sortType = sortType - refresh.postValue(true) - } - } - - private fun getSortSize(): String? { - return UrlFilterUtils.getFilterQuery( - "min_size", mSortSize.min.toString(), - "max_size", mSortSize.max.toString() - ) - } - - fun getSortType(): String? { - return if (sortType == ConfigFilterView.SortType.RECOMMENDED) { - "download:-1" - } else { - "publish:-1" - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/entity/CatalogEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/CatalogEntity.kt index 5c02364d4b..5e5f3d5879 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/CatalogEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/CatalogEntity.kt @@ -6,40 +6,6 @@ import com.gh.gamecenter.feature.entity.GameEntity import com.google.gson.annotations.SerializedName import kotlinx.parcelize.Parcelize -@Parcelize -data class CatalogEntity( - @SerializedName("_id") - var id: String = "", - var name: String = "", - var switch: CatalogSwitch = CatalogSwitch(), - @SerializedName("has_special") - var hasSpecial: Boolean = false, - @SerializedName("sub_catalogs") - var subCatalog: List = emptyList() -) : Parcelable { - - @Parcelize - data class SubCatalogEntity( - @SerializedName("_id") - var id: String = "", - var name: String = "", - var icon: String = "", - var type: String = "", - var link: LinkEntity = LinkEntity(), - var recommended: Boolean = false - ) : Parcelable - - @Parcelize - data class CatalogSwitch( - @SerializedName("sort_hot") - var hotSort: String = "", - @SerializedName("sort_new") - var newSort: String = "", - @SerializedName("sort_star") - var starSort: String = "" - ) : Parcelable -} - @Parcelize class SpecialCatalogEntity( diff --git a/app/src/main/java/com/gh/gamecenter/entity/SubjectRecommendEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/SubjectRecommendEntity.kt index 48433f7a0a..04e7f4729a 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/SubjectRecommendEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/SubjectRecommendEntity.kt @@ -73,8 +73,6 @@ data class SubjectRecommendEntity( "column" -> "专题" "column_collection" -> "专题合集" "block" -> "版块" - "category" -> "分类" - "catalog" -> "新分类" "category_v2" -> "新分类2.0" "column_test" -> "开测表" "server" -> "开服表" diff --git a/app/src/main/java/com/gh/gamecenter/fragment/HomeTabWrapperFragment.kt b/app/src/main/java/com/gh/gamecenter/fragment/HomeTabWrapperFragment.kt index 8a23819faa..65611a5a3f 100644 --- a/app/src/main/java/com/gh/gamecenter/fragment/HomeTabWrapperFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/fragment/HomeTabWrapperFragment.kt @@ -11,8 +11,6 @@ import androidx.fragment.app.Fragment import androidx.viewpager.widget.ViewPager import com.gh.gamecenter.R import com.gh.gamecenter.amway.AmwayFragment -import com.gh.gamecenter.catalog.CatalogFragment -import com.gh.gamecenter.category.CategoryDirectoryFragment import com.gh.gamecenter.category2.CategoryV2Fragment import com.gh.gamecenter.common.base.adapter.FragmentAdapter import com.gh.gamecenter.common.constant.EntranceConsts @@ -159,16 +157,6 @@ abstract class HomeTabWrapperFragment : SearchToolWrapperFragment() { putString(GameServersTestFragment.TEST_COLUMN_ID, tabEntity.link) }) - "category" -> CategoryDirectoryFragment().with(Bundle().apply { - putString(EntranceConsts.KEY_CATEGORY_ID, tabEntity.link) - putString(EntranceConsts.KEY_CATEGORY_TITLE, tabEntity.text) - }) - - "catalog" -> CatalogFragment().with(Bundle().apply { - putString(EntranceConsts.KEY_CATALOG_ID, tabEntity.link) - putString(EntranceConsts.KEY_CATALOG_TITLE, tabEntity.text) - }) - "category_v2" -> CategoryV2Fragment().with(Bundle().apply { putString(EntranceConsts.KEY_CATEGORY_ID, tabEntity.link) putString(EntranceConsts.KEY_CATEGORY_TITLE, tabEntity.text) diff --git a/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.kt index db1ed4e798..c34243824d 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.kt @@ -26,7 +26,6 @@ import com.gh.gamecenter.adapter.viewholder.GameHeadViewHolder import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewPagerViewHolder -import com.gh.gamecenter.category.CategoryDirectoryActivity import com.gh.gamecenter.common.baselist.LoadStatus import com.gh.gamecenter.common.callback.OnViewClickListener import com.gh.gamecenter.common.constant.EntranceConsts @@ -980,14 +979,6 @@ class GameFragmentAdapter( ) ) - "category" -> mContext.startActivity( - CategoryDirectoryActivity.getIntent( - mContext, - entity.link!!, - entity.text!! - ) - ) - "column" -> { SubjectActivity.startSubjectActivity( mContext, diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 827e82abfb..5f9e6b66e4 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -20,7 +20,6 @@ import com.gh.gamecenter.entity.BadgeEntity; import com.gh.gamecenter.entity.BlockEntity; import com.gh.gamecenter.entity.BottomTab; import com.gh.gamecenter.entity.CarouselEntity; -import com.gh.gamecenter.entity.CatalogEntity; import com.gh.gamecenter.entity.CategoryEntity; import com.gh.gamecenter.entity.CommonCollectionContentEntity; import com.gh.gamecenter.entity.CommonCollectionEntity; @@ -913,19 +912,6 @@ public interface ApiService { @GET("blocks/{block_id}/columns") Observable> getBlockColumns(@Path("block_id") String blockId, @Query("page") int page); - /** - * 获取分类目录 - */ - @Headers({"Content-Type: application/json", "Accept: application/json"}) - @GET("categories/{category_id}/directories") - Observable> getCategories(@Path("category_id") String categoryId, @Query("page") int page); - - /** - * 获取分类游戏 - */ - @GET("categories/{category_id}/games") - Single> getGamesInCategory(@Path("category_id") String categoryId, @Query("sort") String sort, @Query("filter") String filter, @Query("page") int page); - /** * 获取关注的用户列表 */ @@ -2285,18 +2271,6 @@ public interface ApiService { @Query("page") int page, @Query("page_size") int pageSize); - /** - * 获取一级分类数据 - */ - @GET("catalogs/{catalog_id}") - Single getCatalogs(@Path("catalog_id") String catalogId); - - /** - * 获取一级分类数据 及其 二级分类数据 - */ - @GET("catalogs/{catalog_id}/{primary_catalog_id}") - Single getSubCatalogs(@Path("catalog_id") String catalogId, @Path("primary_catalog_id") String primaryCatalogId); - /** * 获取精选分类 */ diff --git a/app/src/main/res/drawable-night/bg_forum_home_search.xml b/app/src/main/res/drawable-night/bg_forum_home_search.xml deleted file mode 100644 index 78f6878997..0000000000 --- a/app/src/main/res/drawable-night/bg_forum_home_search.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable-xhdpi/ic_category_arrow_down.webp b/app/src/main/res/drawable-xhdpi/ic_category_arrow_down.webp deleted file mode 100644 index fd60a4c626..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_category_arrow_down.webp and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_category_arrow_up.webp b/app/src/main/res/drawable-xhdpi/ic_category_arrow_up.webp deleted file mode 100644 index eec083f35a..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_category_arrow_up.webp and /dev/null differ diff --git a/app/src/main/res/layout/catalog_item.xml b/app/src/main/res/layout/catalog_item.xml deleted file mode 100644 index fe954cbb72..0000000000 --- a/app/src/main/res/layout/catalog_item.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_catalog.xml b/app/src/main/res/layout/fragment_catalog.xml deleted file mode 100644 index b18b16bae5..0000000000 --- a/app/src/main/res/layout/fragment_catalog.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_catalog_list.xml b/app/src/main/res/layout/fragment_catalog_list.xml deleted file mode 100644 index 456c54deac..0000000000 --- a/app/src/main/res/layout/fragment_catalog_list.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_category_skeleton.xml b/app/src/main/res/layout/fragment_category_skeleton.xml deleted file mode 100644 index bfb0e1a65d..0000000000 --- a/app/src/main/res/layout/fragment_category_skeleton.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_sub_catalog.xml b/app/src/main/res/layout/fragment_sub_catalog.xml deleted file mode 100644 index 37f4e373ff..0000000000 --- a/app/src/main/res/layout/fragment_sub_catalog.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_category.xml b/app/src/main/res/layout/item_category.xml deleted file mode 100644 index 0f094f5638..0000000000 --- a/app/src/main/res/layout/item_category.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_skeleton_category.xml b/app/src/main/res/layout/item_skeleton_category.xml deleted file mode 100644 index 967f1cc8be..0000000000 --- a/app/src/main/res/layout/item_skeleton_category.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/layout_catalog_filter.xml b/app/src/main/res/layout/layout_catalog_filter.xml deleted file mode 100644 index 17d4bfba40..0000000000 --- a/app/src/main/res/layout/layout_catalog_filter.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/layout_sub_category.xml b/app/src/main/res/layout/layout_sub_category.xml deleted file mode 100644 index 18605e0ec5..0000000000 --- a/app/src/main/res/layout/layout_sub_category.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/sub_catalog_item.xml b/app/src/main/res/layout/sub_catalog_item.xml deleted file mode 100644 index c3e89a717e..0000000000 --- a/app/src/main/res/layout/sub_catalog_item.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/feature/new_feedback/src/main/res/drawable-night-xxxhdpi/ic_my_selected.webp b/feature/new_feedback/src/main/res/drawable-night-xxxhdpi/ic_my_selected.webp deleted file mode 100644 index 8f86026084..0000000000 Binary files a/feature/new_feedback/src/main/res/drawable-night-xxxhdpi/ic_my_selected.webp and /dev/null differ diff --git a/feature/new_feedback/src/main/res/drawable-night-xxxhdpi/ic_my_unselected.webp b/feature/new_feedback/src/main/res/drawable-night-xxxhdpi/ic_my_unselected.webp deleted file mode 100644 index f89064aa67..0000000000 Binary files a/feature/new_feedback/src/main/res/drawable-night-xxxhdpi/ic_my_unselected.webp and /dev/null differ diff --git a/feature/new_feedback/src/main/res/drawable-xxxhdpi/ic_my_selected.webp b/feature/new_feedback/src/main/res/drawable-xxxhdpi/ic_my_selected.webp deleted file mode 100644 index 76eaf08eac..0000000000 Binary files a/feature/new_feedback/src/main/res/drawable-xxxhdpi/ic_my_selected.webp and /dev/null differ diff --git a/feature/new_feedback/src/main/res/drawable-xxxhdpi/ic_my_unselected.webp b/feature/new_feedback/src/main/res/drawable-xxxhdpi/ic_my_unselected.webp deleted file mode 100644 index 9fb9cfde89..0000000000 Binary files a/feature/new_feedback/src/main/res/drawable-xxxhdpi/ic_my_unselected.webp and /dev/null differ diff --git a/module_common/src/main/java/com/gh/gamecenter/common/constant/EntranceConsts.java b/module_common/src/main/java/com/gh/gamecenter/common/constant/EntranceConsts.java index 7b1d35486d..9cec42ee6c 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/constant/EntranceConsts.java +++ b/module_common/src/main/java/com/gh/gamecenter/common/constant/EntranceConsts.java @@ -31,7 +31,6 @@ public class EntranceConsts { public static final String HOST_USERHOME = "userhome";//个人主页 public static final String HOST_VIDEO = "video"; public static final String HOST_FORUM = "forum"; - public static final String HOST_CATEGORY = "category";//分类 public static final String HOST_COLUMN_COLLECTION = "column_collection";//专题合集 public static final String HOST_COMMUNITY_QUESTION_LABEL_DETAIL = "community_question_label_detail";//问题标签详情 public static final String HOST_COMMUNITY_COLUMN_DETAIL = "community_column_detail";//专栏详情 @@ -170,10 +169,8 @@ public class EntranceConsts { public static final String KEY_IS_COLUMN_COLLECTION = "is_column_collection";//是专题合集 public static final String KEY_DRAFT_ID = "draft_id"; public static final String KEY_KAIFU_LIST = "kaifuList"; - public static final String KEY_CATEGORY = "category"; public static final String KEY_CATEGORY_ID = "category_id"; public static final String KEY_CATEGORY_TITLE = "category_title"; - public static final String KEY_CATEGORY_INIT_TITLE = "category_init_title"; public static final String KEY_BLOCK_DATA = "blockData"; public static final String KEY_ASK_TAG = "askTag"; public static final String KEY_SCROLL_TO_LIBAO = "libao"; @@ -251,11 +248,7 @@ public class EntranceConsts { public static final String KEY_SIMULATOR = "simulator"; public static final String KEY_MARKET_DETAILS = "market_details"; public static final String KEY_CATALOG_ID = "catalogId"; - public static final String KEY_PRIMARY_CATALOG_ID = "primaryCatalogId"; - public static final String KEY_PRIMARY_CATALOG_NAME = "primaryCatalogName"; public static final String KEY_CATALOG_TITLE = "catalog_title"; - public static final String KEY_CATALOG_INIT_TITLE = "catalog_init_title"; - public static final String KEY_CATEGORY_LIST = "categoty_list"; public static final String KEY_IS_FREE = "is_free"; public static final String KEY_IS_SIGN = "is_sign"; public static final String KEY_IS_FORCED_TO_CERTIFICATE = "is_forced_to_certificate";