diff --git a/app/src/main/java/com/gh/common/databind/BindingAdapters.java b/app/src/main/java/com/gh/common/databind/BindingAdapters.java index ae51556d3d..1ec5e3cf25 100644 --- a/app/src/main/java/com/gh/common/databind/BindingAdapters.java +++ b/app/src/main/java/com/gh/common/databind/BindingAdapters.java @@ -850,11 +850,11 @@ public class BindingAdapters { public static void setVideoData(TextView view, int count) { if (count > 0) { - view.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null, null); + ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null); view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333)); view.setText(count + ""); } else { - view.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); + ExtensionsKt.removeDrawable(view); view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc)); view.setText("-"); } diff --git a/app/src/main/java/com/gh/common/util/DialogUtils.java b/app/src/main/java/com/gh/common/util/DialogUtils.java index 12c531c614..6d2b275db0 100644 --- a/app/src/main/java/com/gh/common/util/DialogUtils.java +++ b/app/src/main/java/com/gh/common/util/DialogUtils.java @@ -8,7 +8,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; -import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.CountDownTimer; import android.provider.Settings; @@ -93,8 +92,8 @@ import com.gh.gamecenter.entity.SettingsEntity; import com.gh.gamecenter.entity.SimpleGameEntity; import com.gh.gamecenter.entity.TrackableEntity; import com.gh.gamecenter.login.entity.Badge; -import com.gh.gamecenter.setting.view.security.BindPhoneActivity; import com.gh.gamecenter.setting.view.GameDownloadSettingFragment; +import com.gh.gamecenter.setting.view.security.BindPhoneActivity; import com.gh.gamecenter.suggest.SuggestType; import com.lightgame.adapter.BaseRecyclerAdapter; import com.lightgame.download.DownloadEntity; @@ -1618,7 +1617,7 @@ public class DialogUtils { TextView commitTv = view.findViewById(R.id.commitTv); Context finalContext = context; //添加透明阴影,实现类似 clipPadding=false 效果 - complaintCommentEt.setShadowLayer(complaintCommentEt.getExtendedPaddingBottom(), 0f, 0f, Color.TRANSPARENT); + complaintCommentEt.setShadowLayer(complaintCommentEt.getExtendedPaddingBottom(), 0F, 0F, Color.TRANSPARENT); ExtensionsKt.setTextChangedListener(complaintCommentEt, (s, start, before, count) -> { commitTv.setTextColor(ContextCompat.getColor(finalContext, s.toString().trim().isEmpty() ? R.color.text_subtitleDesc : R.color.theme_font)); @@ -1628,7 +1627,7 @@ public class DialogUtils { for (String option : options) { TextView reportTv = new TextView(context); reportTv.setText(option); - reportTv.setTextSize(16f); + reportTv.setTextSize(16F); if (disabledOptions != null && disabledOptions.contains(option)) { reportTv.setTextColor(ContextCompat.getColor(context, R.color.btn_gray)); } else { @@ -1637,12 +1636,10 @@ public class DialogUtils { } reportTv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); - reportTv.setPadding(DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 17f), - DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 17f)); + reportTv.setPadding(DisplayUtils.dip2px(context, 20F), DisplayUtils.dip2px(context, 17F), + DisplayUtils.dip2px(context, 20F), DisplayUtils.dip2px(context, 17F)); if (option.equals("其它")) { - Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_complaint_arrow_right); - drawable.setBounds(0, 0, DisplayUtils.dip2px(6f), DisplayUtils.dip2px(10f)); - reportTv.setCompoundDrawables(null, null, drawable, null); + ExtensionsKt.setDrawableEnd(reportTv, R.drawable.ic_complaint_arrow_right, DisplayUtils.dip2px(6F), DisplayUtils.dip2px(6F)); } complaintContainer.addView(reportTv); @@ -2051,7 +2048,7 @@ public class DialogUtils { binding.confirmTv.setText("我知道了"); binding.centerDivider.setVisibility(View.GONE); binding.cancelTv.setVisibility(View.GONE); - binding.titleTv.setCompoundDrawablesWithIntrinsicBounds(ExtensionsKt.toDrawable(R.drawable.ic_reserve_success), null, null, null); + ExtensionsKt.setDrawableStart(binding.titleTv, R.drawable.ic_reserve_success, null, null); binding.confirmTv.setOnClickListener(v -> dialog.dismiss()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(binding.getRoot()); diff --git a/app/src/main/java/com/gh/common/view/CatalogFilterView.kt b/app/src/main/java/com/gh/common/view/CatalogFilterView.kt index 94f39dd430..adee76f8d7 100644 --- a/app/src/main/java/com/gh/common/view/CatalogFilterView.kt +++ b/app/src/main/java/com/gh/common/view/CatalogFilterView.kt @@ -12,9 +12,10 @@ 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.R import com.gh.gamecenter.entity.CatalogEntity import com.gh.gamecenter.entity.SubjectSettingEntity import com.google.android.flexbox.FlexboxLayout @@ -94,13 +95,8 @@ class CatalogFilterView @JvmOverloads constructor( } private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) { - val drawableUp = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - typeTv.setTextColor(R.color.theme_font.toColor(context)) - typeTv.setCompoundDrawables(null, null, drawableUp, null) + typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(typeTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -145,7 +141,7 @@ class CatalogFilterView @JvmOverloads constructor( popupWindow.setOnDismissListener { typeTv.setTextColor(R.color.text_757575.toColor(context)) - typeTv.setCompoundDrawables(null, null, drawableDown, null) + typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) mTypePopupWindow = null } @@ -156,13 +152,8 @@ class CatalogFilterView @JvmOverloads constructor( } private fun showSelectCatalogPopupWindow(containerView: View, catalogTv: TextView, catalogText: String) { - val drawableUp = ContextCompat.getDrawable(catalogTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = ContextCompat.getDrawable(catalogTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - catalogTv.setTextColor(R.color.theme_font.toColor(context)) - catalogTv.setCompoundDrawables(null, null, drawableUp, null) + catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(catalogTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -209,7 +200,7 @@ class CatalogFilterView @JvmOverloads constructor( popupWindow.setOnDismissListener { catalogTv.setTextColor(R.color.text_757575.toColor(context)) - catalogTv.setCompoundDrawables(null, null, drawableDown, null) + catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) mCatalogPopupWindow = null } @@ -220,13 +211,8 @@ class CatalogFilterView @JvmOverloads constructor( } private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) { - val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - sizeTv.setTextColor(R.color.theme_font.toColor(context)) - sizeTv.setCompoundDrawables(null, null, drawableUp, null) + sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(sizeTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -281,7 +267,7 @@ class CatalogFilterView @JvmOverloads constructor( popupWindow.setOnDismissListener { sizeTv.setTextColor(R.color.text_757575.toColor(context)) - sizeTv.setCompoundDrawables(null, null, drawableDown, null) + sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) mSizePopupWindow = null } diff --git a/app/src/main/java/com/gh/common/view/CategoryFilterView.kt b/app/src/main/java/com/gh/common/view/CategoryFilterView.kt index cce34d9357..0ea5eca177 100644 --- a/app/src/main/java/com/gh/common/view/CategoryFilterView.kt +++ b/app/src/main/java/com/gh/common/view/CategoryFilterView.kt @@ -11,9 +11,10 @@ import android.widget.PopupWindow import android.widget.TextView import androidx.annotation.ColorInt import androidx.core.content.ContextCompat -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toColor import com.gh.gamecenter.R +import com.gh.gamecenter.common.utils.dip2px +import com.gh.gamecenter.common.utils.setDrawableEnd +import com.gh.gamecenter.common.utils.toColor import com.gh.gamecenter.entity.SubjectSettingEntity import com.google.android.flexbox.FlexboxLayout @@ -89,13 +90,8 @@ class CategoryFilterView @JvmOverloads constructor( } private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) { - val drawableUp = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - typeTv.setTextColor(R.color.theme_font.toColor(context)) - typeTv.setCompoundDrawables(null, null, drawableUp, null) + typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(typeTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -141,7 +137,7 @@ class CategoryFilterView @JvmOverloads constructor( popupWindow.setOnDismissListener { typeTv.setTextColor(R.color.text_757575.toColor(context)) - typeTv.setCompoundDrawables(null, null, drawableDown, null) + typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) mTypePopupWindow = null } @@ -152,13 +148,8 @@ class CategoryFilterView @JvmOverloads constructor( } private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) { - val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - sizeTv.setTextColor(R.color.theme_font.toColor(context)) - sizeTv.setCompoundDrawables(null, null, drawableUp, null) + sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(sizeTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -214,7 +205,7 @@ class CategoryFilterView @JvmOverloads constructor( popupWindow.setOnDismissListener { sizeTv.setTextColor(R.color.text_757575.toColor(context)) - sizeTv.setCompoundDrawables(null, null, drawableDown, null) + sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) mSizePopupWindow = null } diff --git a/app/src/main/java/com/gh/common/view/ConfigFilterView.kt b/app/src/main/java/com/gh/common/view/ConfigFilterView.kt index c23e4d444e..7c5cd63417 100644 --- a/app/src/main/java/com/gh/common/view/ConfigFilterView.kt +++ b/app/src/main/java/com/gh/common/view/ConfigFilterView.kt @@ -9,8 +9,8 @@ import android.widget.LinearLayout import android.widget.PopupWindow import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout -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.toDrawable import com.gh.gamecenter.entity.SubjectSettingEntity @@ -112,14 +112,8 @@ class ConfigFilterView @JvmOverloads constructor( } private fun showSelectionPopupWindow(containerView: View, sizeTv: TextView, sizeText: String) { - val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = - ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - sizeTv.setTextColor(R.color.theme_font.toColor(sizeTv.context)) - sizeTv.setCompoundDrawables(null, null, drawableUp, null) + sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(sizeTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -178,7 +172,7 @@ class ConfigFilterView @JvmOverloads constructor( popupWindow.setOnDismissListener { sizeTv.setTextColor(R.color.text_757575.toColor(sizeTv.context)) - sizeTv.setCompoundDrawables(null, null, drawableDown, null) + sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) mPopupWindow = null } diff --git a/app/src/main/java/com/gh/common/view/FilterView.kt b/app/src/main/java/com/gh/common/view/FilterView.kt index 3504b7478f..5d32836a85 100644 --- a/app/src/main/java/com/gh/common/view/FilterView.kt +++ b/app/src/main/java/com/gh/common/view/FilterView.kt @@ -14,9 +14,10 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toColor import com.gh.gamecenter.R +import com.gh.gamecenter.common.utils.dip2px +import com.gh.gamecenter.common.utils.setDrawableEnd +import com.gh.gamecenter.common.utils.toColor import com.gh.gamecenter.common.utils.toDrawable import com.gh.gamecenter.databinding.ItemFilterBinding import com.gh.gamecenter.databinding.LayoutFilterBinding @@ -107,13 +108,8 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet subFilterText: String, selectedCallback: ((String) -> Unit) ) { - val drawableUp = ContextCompat.getDrawable(subFilterTv.context, R.drawable.ic_filter_arrow_up) - val drawableDown = ContextCompat.getDrawable(subFilterTv.context, R.drawable.ic_filter_arrow_down) - drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight) - drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight) - subFilterTv.setTextColor(R.color.theme_font.toColor(context)) - subFilterTv.setCompoundDrawables(null, null, drawableUp, null) + subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_up) val inflater = LayoutInflater.from(subFilterTv.context) val layout = inflater.inflate(R.layout.layout_filter_size, null) @@ -163,7 +159,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet } popupWindow.setOnDismissListener { - subFilterTv.setCompoundDrawables(null, null, drawableDown, null) + subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_down) } popupWindow.isTouchable = true diff --git a/app/src/main/java/com/gh/download/dialog/DownloadDialogItemViewHolder.kt b/app/src/main/java/com/gh/download/dialog/DownloadDialogItemViewHolder.kt index 4f821e2525..0189aaf978 100644 --- a/app/src/main/java/com/gh/download/dialog/DownloadDialogItemViewHolder.kt +++ b/app/src/main/java/com/gh/download/dialog/DownloadDialogItemViewHolder.kt @@ -83,7 +83,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas binding.containerView.setBackgroundResource(R.drawable.download_dialog_item_background) - binding.status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + binding.status.removeDrawable() changeRecommendUI(apkEntity, listData, position) if (apkLink != null) { @@ -95,12 +95,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas binding.remark.goneIf(apkLink.remark.isEmpty()) binding.status.text = "点击查看" - binding.status.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - ContextCompat.getDrawable(binding.status.context, R.drawable.download_dialog_collection_status_link), - null - ) + binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_link) binding.containerView.setBackgroundResource(R.drawable.download_dialog_installed_background) itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.LINK) } else if (apkCollection != null || (!isCollectionPage && apkEntity.downloadInstruction.isNotEmpty())) { @@ -149,15 +144,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas binding.status.visibility = View.VISIBLE binding.status.text = "可更新" - binding.status.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - ContextCompat.getDrawable( - binding.status.context, - R.drawable.download_dialog_collection_status_update - ), - null - ) + binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_update) binding.downloadStatusIcon.visibility = View.GONE itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.UPDATE) } else if (PackageUtils.getGhId(apkEntity.packageName) == gameEntity.id || @@ -184,15 +171,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas // 点击启动 binding.status.text = "点击启动" itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.LAUNCH) - binding.status.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - ContextCompat.getDrawable( - binding.status.context, - R.drawable.download_dialog_collection_status_launch - ), - null - ) + binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_launch) } } else { binding.downloadStatusIcon.visibility = View.VISIBLE diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index 5e6440864e..9036bf25ba 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -593,12 +593,7 @@ public class MainActivity extends BaseActivity { SimpleDraweeView adImage = findViewById(R.id.adImage); startAdContainer.setVisibility(View.VISIBLE); jumpDetailBtn.setText(ad.getDesc()); - jumpDetailBtn.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - VectorDrawableCompat.create(getResources(), R.drawable.ic_startup_ad_arrow, null), - null - ); + ExtensionsKt.setDrawableEnd(jumpDetailBtn, VectorDrawableCompat.create(getResources(), R.drawable.ic_startup_ad_arrow, null), null, null); ImageUtils.display(adImage, ad.getImg()); startAdContainer.setOnClickListener(v -> { // do nothing 只是为了点击拦截事件,避免传递到下面的页面 diff --git a/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java index b528e66dfc..5a10ef83d3 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java @@ -349,12 +349,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter { }, 12, content.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); holder.binding.libaodetailCondition.setText(content); holder.binding.libaodetailCondition.setMovementMethod(new LinkMovementMethod()); - holder.binding.libaodetailCondition.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - ExtensionsKt.toDrawable(com.gh.gamecenter.common.R.drawable.ic_libao_activity_arrow, mContext), - null - ); + ExtensionsKt.setDrawableEnd(holder.binding.libaodetailCondition, com.gh.gamecenter.common.R.drawable.ic_libao_activity_arrow, null, null); holder.binding.libaodetailCondition.setCompoundDrawablePadding(DisplayUtils.dip2px(4F)); } } diff --git a/app/src/main/java/com/gh/gamecenter/amway/search/AmwaySearchDefaultFragment.kt b/app/src/main/java/com/gh/gamecenter/amway/search/AmwaySearchDefaultFragment.kt index 00ead0ad2a..117d1be89b 100644 --- a/app/src/main/java/com/gh/gamecenter/amway/search/AmwaySearchDefaultFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/amway/search/AmwaySearchDefaultFragment.kt @@ -5,10 +5,7 @@ import android.view.View import androidx.recyclerview.widget.LinearLayoutManager import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import com.gh.gamecenter.R -import com.gh.gamecenter.common.utils.DialogHelper -import com.gh.gamecenter.common.utils.observeNonNull -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.viewModelProviderFromParent +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.databinding.FragmentAmwaySearchDefaultBinding import com.gh.gamecenter.eventbus.EBSearch import com.gh.gamecenter.search.SearchDefaultFragment @@ -68,13 +65,11 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() { headTitle.textSize = 16F headActionTv.text = "清空" headActionTv.setTextColor(R.color.text_subtitleDesc.toColor(requireContext())) - headActionTv.setCompoundDrawablesWithIntrinsicBounds( - VectorDrawableCompat.create( - resources, - R.drawable.search_history_delete, - null - ), null, null, null - ) + headActionTv.setDrawableStart(VectorDrawableCompat.create( + resources, + R.drawable.search_history_delete, + null + )) headActionTv.setOnClickListener { DialogHelper.showCenterWarningDialog(requireContext(), "清空记录", "确定清空历史搜索记录?", confirmClickCallback = { mSearchDao.deleteAll() diff --git a/app/src/main/java/com/gh/gamecenter/category2/CategoryV2ListAdapter.kt b/app/src/main/java/com/gh/gamecenter/category2/CategoryV2ListAdapter.kt index 432471fade..fe3c221712 100644 --- a/app/src/main/java/com/gh/gamecenter/category2/CategoryV2ListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/category2/CategoryV2ListAdapter.kt @@ -5,25 +5,23 @@ import android.util.SparseArray import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource import com.gh.common.exposure.ExposureType import com.gh.common.exposure.IExposable -import com.gh.common.util.* -import com.gh.gamecenter.common.view.DrawableView +import com.gh.common.util.DownloadItemUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.common.constant.ItemViewType +import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.DrawableView +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.utils.PageSwitchDataHelper +import com.gh.gamecenter.core.utils.StringUtils import com.gh.gamecenter.databinding.CategoryGameItemBinding import com.gh.gamecenter.entity.GameEntity import com.gh.gamecenter.eventbus.EBDownloadStatus @@ -229,12 +227,7 @@ class CategoryV2ListAdapter( BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() } else "" diff --git a/app/src/main/java/com/gh/gamecenter/discovery/DiscoveryAdapter.kt b/app/src/main/java/com/gh/gamecenter/discovery/DiscoveryAdapter.kt index dc05eb1e98..ef89f644ca 100644 --- a/app/src/main/java/com/gh/gamecenter/discovery/DiscoveryAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/discovery/DiscoveryAdapter.kt @@ -175,12 +175,7 @@ class DiscoveryAdapter( labelTv.goneIf(labels.size < index + 1) { labelTv.setTextColor(R.color.text_subtitle.toColor(mContext)) labelTv.background = R.drawable.bg_shape_white_radius_4.toDrawable(mContext) - labelTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_interest_arrow.toDrawable(mContext), - null - ) + labelTv.setDrawableEnd(R.drawable.ic_interest_arrow) labels[index].text = labels[index].linkText labelTv.text = labels[index].title labelTv.setOnClickListener { @@ -306,12 +301,7 @@ class DiscoveryAdapter( gameIconView.displayGameIcon(gameEntity) BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() } else { @@ -338,19 +328,14 @@ class DiscoveryAdapter( recommendReasonTv.text = "${gameEntity.columnRank!!.name}·第${gameEntity.columnRank!!.position}名" recommendReasonTv.setTextColor(R.color.theme_yellow.toColor(binding.root.context)) - recommendReasonTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_discovery_rank.toDrawable(binding.root.context), - null, - null, - null - ) + recommendReasonTv.setDrawableStart(R.drawable.ic_discovery_rank) recommendReasonTv.background = R.drawable.bg_discovery_recommend.toDrawable(binding.root.context) recommendReasonTv.visibility = View.VISIBLE } else if (gameEntity.type == "recommend") { recommendReasonTv.text = "其他玩家推荐" recommendReasonTv.setTextColor(R.color.theme_font.toColor(binding.root.context)) - recommendReasonTv.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + recommendReasonTv.removeDrawable() recommendReasonTv.background = R.drawable.bg_discovery_rank.toDrawable(binding.root.context) recommendReasonTv.visibility = View.VISIBLE } diff --git a/app/src/main/java/com/gh/gamecenter/download/UpdatableGameAdapter.kt b/app/src/main/java/com/gh/gamecenter/download/UpdatableGameAdapter.kt index f3a9b5551d..8cfbff4713 100644 --- a/app/src/main/java/com/gh/gamecenter/download/UpdatableGameAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/download/UpdatableGameAdapter.kt @@ -11,19 +11,19 @@ import androidx.core.content.ContextCompat import androidx.core.view.setPadding import androidx.fragment.app.FragmentActivity import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.core.utils.CurrentActivityHolder import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureEvent.Companion.createEvent import com.gh.common.exposure.ExposureSource import com.gh.common.exposure.IExposable import com.gh.common.util.* import com.gh.common.util.DialogUtils -import com.gh.gamecenter.common.view.BugFixedPopupWindow import com.gh.download.DownloadManager import com.gh.download.dialog.DownloadDialog import com.gh.gamecenter.DownloadManagerActivity import com.gh.gamecenter.R import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.BugFixedPopupWindow +import com.gh.gamecenter.core.utils.CurrentActivityHolder import com.gh.gamecenter.databinding.* import com.gh.gamecenter.entity.GameUpdateEntity import com.gh.gamecenter.eventbus.EBSkip @@ -98,26 +98,18 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) : if (itemData.header != null) { holder.binding.infoTv.setTextColor(R.color.text_title.toColor(mContext)) holder.binding.root.setOnClickListener(null) - holder.binding.infoTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - null, - null - ) + holder.binding.infoTv.removeDrawable() } else { holder.binding.infoTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) holder.binding.root.setOnClickListener { mViewModel.toggleIgnoredUpdateVisibility() } - holder.binding.infoTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, + holder.binding.infoTv.setDrawableEnd( if (mViewModel.isIgnoredUpdateExpanded()) { R.drawable.ic_arrow_up_grey.toDrawable() } else { R.drawable.ic_arrow_down_grey.toDrawable() - }, - null + } ) } } @@ -187,19 +179,9 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) : mViewModel.toggleOtherVersionVisibility(itemData.miscPackageName) } if (itemData.otherVersionUpdateHint == true) { - holder.binding.selectorTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_arrow_up_blue.toDrawable(), - null - ) + holder.binding.selectorTv.setDrawableEnd(R.drawable.ic_arrow_up_blue) } else { - holder.binding.selectorTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_arrow_down_blue.toDrawable(), - null - ) + holder.binding.selectorTv.setDrawableEnd(R.drawable.ic_arrow_down_blue) } holder.binding.closeHintTv.enlargeTouchArea() holder.binding.closeHintTv.setOnClickListener { diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt index b971567939..53bfdd4097 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt @@ -6,17 +6,19 @@ import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.text.SpannableStringBuilder import android.view.View -import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.common.util.* import com.gh.common.util.DialogUtils import com.gh.common.util.LogUtils import com.gh.common.util.NewLogUtils import com.gh.gamecenter.R +import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.callback.ConfirmListener -import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* -import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.core.utils.MtaHelper +import com.gh.gamecenter.core.utils.SpanBuilder +import com.gh.gamecenter.core.utils.ToastUtils +import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.entity.ForumVideoEntity import com.gh.gamecenter.eventbus.EBUserFollow import com.gh.gamecenter.forum.detail.ForumDetailActivity @@ -77,12 +79,12 @@ class ForumArticleAskItemViewHolder(val binding: CommunityAnswerItemBinding) : else -> R.color.text_CCFF5269 }.toColor(statusTv.context) ) - statusTv.setCompoundDrawablesWithIntrinsicBounds( + statusTv.setDrawableStart( when { entity.me.isFollower -> R.drawable.ic_forum_follow entity.status == "pending" -> R.drawable.ic_forum_pending else -> R.drawable.icon_forum_fail - }.toDrawable(), null, null, null + } ) title.goneIf(entity.type == "answer") title.text = if (entity.type.contains("video")) entity.articleTitle else entity.questions.title @@ -224,24 +226,17 @@ class ForumArticleAskItemViewHolder(val binding: CommunityAnswerItemBinding) : bbsType ) } - followUser(entity, object : EmptyCallback { - override fun onCallback() { - entity.me.isFollower = true - binding.concernBtn.visibility = View.GONE - binding.statusTv.visibility = View.VISIBLE - binding.statusTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_forum_follow.toDrawable(), - null, - null, - null - ) - binding.statusTv.setTextColor(R.color.theme_alpha_80.toColor(binding.statusTv.context)) - binding.statusTv.text = R.string.follow_status.toResString() - binding.time.text = " · ${binding.time.text}" - ToastUtils.toast("关注成功") - EventBus.getDefault().post(EBUserFollow(userId, true)) - } - }) + followUser(entity) { + entity.me.isFollower = true + binding.concernBtn.visibility = View.GONE + binding.statusTv.visibility = View.VISIBLE + binding.statusTv.setDrawableStart(R.drawable.ic_forum_follow) + binding.statusTv.setTextColor(R.color.theme_alpha_80.toColor(binding.statusTv.context)) + binding.statusTv.text = R.string.follow_status.toResString() + binding.time.text = " · ${binding.time.text}" + ToastUtils.toast("关注成功") + EventBus.getDefault().post(EBUserFollow(userId, true)) + } } } } diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt index ae8d7823e3..8e96fa4d47 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt @@ -6,20 +6,17 @@ import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.base.activity.BaseActivity -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.gamecenter.common.syncpage.ISyncAdapterHandler -import com.gh.gamecenter.core.utils.MtaHelper import com.gh.common.util.NewLogUtils -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.goneIf import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable -import com.gh.gamecenter.databinding.CommunityAnswerItemBinding +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.syncpage.ISyncAdapterHandler +import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.utils.MtaHelper +import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity import com.gh.gamecenter.qa.entity.ArticleEntity import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity @@ -91,12 +88,7 @@ class ForumArticleListAdapter( } else { viewHolder.commentCount.text = "回答" } - viewHolder.commentCount.setCompoundDrawablesWithIntrinsicBounds( - ContextCompat.getDrawable( - mContext, - R.drawable.community_comment_count - ), null, null, null - ) + viewHolder.commentCount.setDrawableStart(R.drawable.community_comment_count) viewHolder.voteCountContainer.visibility = View.GONE } else { viewHolder.voteCountContainer.visibility = View.VISIBLE diff --git a/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt index 83c254cdcc..00660402db 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/search/ForumContentSearchListAdapter.kt @@ -9,20 +9,23 @@ import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.base.activity.BaseActivity -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.gamecenter.common.syncpage.ISyncAdapterHandler -import com.gh.common.util.* import com.gh.common.util.NewLogUtils +import com.gh.common.util.NewsUtils import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder +import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.baselist.ListAdapter +import com.gh.gamecenter.common.constant.ItemViewType +import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.syncpage.ISyncAdapterHandler import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.utils.CenterImageSpan +import com.gh.gamecenter.core.utils.MtaHelper +import com.gh.gamecenter.core.utils.SpanBuilder +import com.gh.gamecenter.core.utils.TimeUtils import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.databinding.ForumSearchContentListBinding -import com.gh.gamecenter.common.entity.CommunityEntity import com.gh.gamecenter.forum.home.ForumArticleAskItemViewHolder import com.gh.gamecenter.login.user.UserManager import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity @@ -245,12 +248,12 @@ class ForumContentSearchListAdapter( else -> R.color.text_CCFF5269 }.toColor(statusTv.context) ) - statusTv.setCompoundDrawablesWithIntrinsicBounds( + statusTv.setDrawableStart( when { answer.me.isFollower -> R.drawable.ic_forum_follow answer.status == "pending" -> R.drawable.ic_forum_pending else -> R.drawable.icon_forum_fail - }.toDrawable(), null, null, null + } ) title.goneIf(answer.type == "answer") title.text = diff --git a/app/src/main/java/com/gh/gamecenter/forum/search/ForumOrUserSearchDefaultFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/search/ForumOrUserSearchDefaultFragment.kt index fb6583d6e9..cfe313d4c8 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/search/ForumOrUserSearchDefaultFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/search/ForumOrUserSearchDefaultFragment.kt @@ -5,10 +5,7 @@ import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import com.gh.gamecenter.R -import com.gh.gamecenter.common.utils.DialogHelper -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.viewModelProvider +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.databinding.FragmentSearchDefaultBinding import com.gh.gamecenter.eventbus.EBSearch import com.gh.gamecenter.search.SearchDefaultFragment @@ -78,13 +75,11 @@ class ForumOrUserSearchDefaultFragment : SearchDefaultFragment() { headTitle.textSize = 16F headActionTv.text = "清空" headActionTv.setTextColor(R.color.text_subtitleDesc.toColor(requireContext())) - headActionTv.setCompoundDrawablesWithIntrinsicBounds( - VectorDrawableCompat.create( - resources, - R.drawable.search_history_delete, - null - ), null, null, null - ) + headActionTv.setDrawableStart(VectorDrawableCompat.create( + resources, + R.drawable.search_history_delete, + null + )) headActionTv.setOnClickListener { DialogHelper.showCenterWarningDialog(requireContext(), "清空记录", "确定清空历史搜索记录?", confirmClickCallback = { mSearchDao.deleteAll() diff --git a/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt index 995472d629..8f8715b728 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt @@ -10,10 +10,7 @@ import androidx.constraintlayout.widget.ConstraintSet import com.gh.common.databind.BindingAdapters import com.gh.gamecenter.R import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.goneIf -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.databinding.GameItemBinding import com.gh.gamecenter.entity.GameEntity @@ -44,12 +41,7 @@ class GameItemViewHolder(var binding: GameItemBinding) : BaseRecyclerViewHolder< BindingAdapters.setGameName(gameName, entity, isShowPlatform, isShowSuffix) BindingAdapters.setTextSize(gameRating, if (entity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, entity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (entity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (entity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.setPadding(0, 0, if (entity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (entity.commentCount > 3) { if (entity.star == 10.0F) "10" else entity.star.toString() diff --git a/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalItemViewHolder.kt index d90bc4fa73..e9d565ff3a 100644 --- a/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalItemViewHolder.kt @@ -16,12 +16,7 @@ class GameHorizontalItemViewHolder(val binding: GameHorizontalItemBinding) : fun bindGameHorizontalItem(gameEntity: GameEntity, subjectEntity: SubjectEntity) { binding.gameRating.textSize = if (gameEntity.commentCount > 3) 12F else 10F binding.gameRating.goneIf("star" != subjectEntity.typeStyle, visibleCallback = { - binding.gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + binding.gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) binding.gameRating.text = if (gameEntity.commentCount > 3) (if (gameEntity.star == 10.0f) "10" else gameEntity.star.toString()) else "" }) diff --git a/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt index 4e03d59741..8f01637c12 100644 --- a/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt @@ -12,10 +12,7 @@ import com.gh.common.databind.BindingAdapters import com.gh.common.util.DownloadItemUtils import com.gh.gamecenter.R import com.gh.gamecenter.adapter.viewholder.GameViewHolder -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.goneIf -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.common.view.AsyncUi import com.gh.gamecenter.entity.GameEntity import com.gh.gamecenter.entity.SubjectEntity @@ -149,7 +146,7 @@ class GameVerticalAdapter( if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() } - gameRatingTv.setCompoundDrawables(gameRatingDrawableStart, null, null, null) + gameRatingTv.setDrawableStart(gameRatingDrawableStart) gameRatingTv.setPadding(0, 0, gameRatingPaddingEnd, 0) gameRatingTv.setTextColor(gameRatingTextColor) gameRatingTv.text = gameRatingText diff --git a/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt b/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt index dad2d91fde..21bcc62b36 100644 --- a/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt @@ -237,7 +237,6 @@ open class GameCollectionDetailAdapter( // 评论详情用的样式 floorHintTv.visibility = View.GONE commentCountTv.setOnClickListener { commentClosure?.invoke(comment) } -// commentCountTv.setCompoundDrawables(null, null, null, null) commentCountTv.text = "回复" likeCountTv.text = mViewModel.getLikeText(comment.vote, "") root.setOnClickListener { binding.commentCountTv.performClick() } @@ -409,31 +408,16 @@ open class GameCollectionDetailAdapter( if (comment.me?.isCommentVoted == true) { likeCountTv.setTextColor(R.color.theme_font.toColor(likeCountTv.context)) - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_select, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_select) } else { likeCountTv.setTextColor(R.color.text_subtitleDesc.toColor(likeCountTv.context)) - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_unselect) } likeCountTv.setDebouncedClickListener { likeCountTv.context.ifLogin("游戏单详情-评论-点赞") { mViewModel.postVoteGameCollectionComment(comment) { - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - if (comment.me?.isCommentVoted == true) R.drawable.comment_vote_select else R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(if (comment.me?.isCommentVoted == true) R.drawable.comment_vote_select else R.drawable.comment_vote_unselect) likeCountTv.text = mViewModel.getLikeText(comment.vote) likeCountTv.setTextColor( if (comment.me?.isCommentVoted == true) R.color.theme_font.toColor(likeCountTv.context) @@ -600,10 +584,8 @@ open class GameCollectionDetailAdapter( BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable( - mContext - ) else null, null, null, null + gameRating.setDrawableStart( + if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable(mContext) else null ) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/desc/DescAdapter.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/desc/DescAdapter.kt index 45e177eaf3..c282cba206 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/desc/DescAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/desc/DescAdapter.kt @@ -34,18 +34,18 @@ import com.gh.common.util.NewLogUtils import com.gh.gamecenter.GameNewsActivity import com.gh.gamecenter.R import com.gh.gamecenter.SuggestionActivity -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.common.callback.OnListClickListener import com.gh.gamecenter.common.constant.Constants +import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.entity.LinkEntity +import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.common.view.GridSpacingItemColorDecoration import com.gh.gamecenter.common.view.divider.HorizontalDividerItemDecoration +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.* -import com.gh.gamecenter.common.entity.CommunityEntity import com.gh.gamecenter.entity.GameEntity -import com.gh.gamecenter.common.entity.LinkEntity -import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.game.horizontal.GameHorizontalAdapter import com.gh.gamecenter.gamedetail.GameDetailFragment import com.gh.gamecenter.gamedetail.entity.CustomColumn @@ -243,12 +243,7 @@ class DescAdapter( viewHolder.binding.run { titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) galleryRv.isNestedScrollingEnabled = false @@ -345,12 +340,7 @@ class DescAdapter( viewHolder.binding.run { titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) containerWrapper.setPadding(0, itemData.paddingTop, 0, itemData.paddingBottom) galleryRv.isNestedScrollingEnabled = false @@ -426,12 +416,7 @@ class DescAdapter( viewHolder.binding.run { titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) containerWrapper.setPadding(0, itemData.paddingTop, 0, itemData.paddingBottom) galleryRv.isNestedScrollingEnabled = false @@ -476,12 +461,7 @@ class DescAdapter( viewHolder.binding.run { titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) galleryRv.isNestedScrollingEnabled = false containerWrapper.setPadding(0, itemData.paddingTop, 0, itemData.paddingBottom) @@ -556,18 +536,8 @@ class DescAdapter( titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) tipsTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) - tipsTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.servers_calendar_hint.toDrawable(mContext), - null, - null, - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) + tipsTv.setDrawableStart(R.drawable.servers_calendar_hint) serviceRv.isNestedScrollingEnabled = false containerWrapper.setPadding( mDefaultHorizontalPadding, @@ -625,12 +595,7 @@ class DescAdapter( viewHolder.binding.run { titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) galleryRv.isNestedScrollingEnabled = false containerWrapper.setPadding(0, itemData.paddingTop, 0, itemData.paddingBottom) @@ -685,12 +650,7 @@ class DescAdapter( viewHolder.binding.run { titleTv.setTextColor(R.color.text_title.toColor(mContext)) moreTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) - moreTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_right_arrow_darker.toDrawable(mContext), - null - ) + moreTv.setDrawableEnd(R.drawable.ic_right_arrow_darker) containerWrapper.setPadding(0, itemData.paddingTop, 0, itemData.paddingBottom) galleryRv.isNestedScrollingEnabled = false @@ -1014,12 +974,7 @@ class DescAdapter( text = label if (hasDividingLine) { compoundDrawablePadding = 12F.dip2px() - setCompoundDrawablesWithIntrinsicBounds( - R.drawable.game_detail_info_dividing_line.toDrawable(mContext), - null, - null, - null - ) + setDrawableStart(R.drawable.game_detail_info_dividing_line) } } } diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt index fb8429bb37..85840fd57e 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/dialog/GameDetailMoreDialog.kt @@ -143,12 +143,7 @@ class GameDetailMoreDialog : BaseDraggableDialogFragment() { binding.concernTv.visibility = View.VISIBLE if (mIsConcerned) { binding.concernTv.text = "取消关注" - binding.concernTv.setCompoundDrawablesWithIntrinsicBounds( - null, - R.drawable.ic_gamedetail_menu_followed.toDrawable(), - null, - null - ) + binding.concernTv.setDrawableTop(R.drawable.ic_gamedetail_menu_followed) binding.concernTv.setOnClickListener { ifLogin("游戏详情-[关注]") { DialogHelper.showCancelDialog(requireContext(), { @@ -158,12 +153,7 @@ class GameDetailMoreDialog : BaseDraggableDialogFragment() { } } else { binding.concernTv.text = "关注游戏" - binding.concernTv.setCompoundDrawablesWithIntrinsicBounds( - null, - R.drawable.ic_gamedetail_menu_follow.toDrawable(), - null, - null - ) + binding.concernTv.setDrawableTop(R.drawable.ic_gamedetail_menu_follow) binding.concernTv.setOnClickListener { ifLogin("游戏详情-[关注]") { mViewModel.concernCommand(true) @@ -190,30 +180,15 @@ class GameDetailMoreDialog : BaseDraggableDialogFragment() { } binding.copyLinkTv.run { setTextColor(R.color.text_subtitle.toColor(requireContext())) - setCompoundDrawablesWithIntrinsicBounds( - null, - R.drawable.icon_gamedetail_copy_link.toDrawable(requireContext()), - null, - null - ) + setDrawableTop(R.drawable.icon_gamedetail_copy_link) } binding.feedbackTv.run { setTextColor(R.color.text_subtitle.toColor(requireContext())) - setCompoundDrawablesWithIntrinsicBounds( - null, - R.drawable.icon_gamedetail_feedback.toDrawable(requireContext()), - null, - null - ) + setDrawableTop(R.drawable.icon_gamedetail_feedback) } binding.copyrightTv.run { setTextColor(R.color.text_subtitle.toColor(requireContext())) - setCompoundDrawablesWithIntrinsicBounds( - null, - R.drawable.icon_gamedetail_copyright.toDrawable(requireContext()), - null, - null - ) + setDrawableTop(R.drawable.icon_gamedetail_copyright) } binding.cancelTv.run { background = R.drawable.button_round_gray_light.toDrawable(requireContext()) diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingCommentItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingCommentItemViewHolder.kt index f764711ba7..5c8d330756 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingCommentItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingCommentItemViewHolder.kt @@ -18,18 +18,18 @@ import android.widget.LinearLayout import android.widget.PopupWindow import android.widget.TextView import androidx.core.content.ContextCompat -import com.gh.gamecenter.common.base.activity.BaseActivity -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.Constants import com.gh.common.util.* import com.gh.common.util.DialogUtils import com.gh.common.util.NewLogUtils -import com.gh.gamecenter.common.view.CustomLinkMovementMethod -import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.R import com.gh.gamecenter.WebActivity +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder +import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.callback.ConfirmListener +import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.CustomLinkMovementMethod +import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.RatingCommentItemBinding import com.gh.gamecenter.entity.GameEntity @@ -82,13 +82,9 @@ class RatingCommentItemViewHolder(val binding: RatingCommentItemBinding) : BaseR if (commentData.active && commentData.getDevice().isNotEmpty()) View.VISIBLE else View.GONE version.visibility = if (commentData.active && commentData.gameVersion.isNotEmpty()) View.VISIBLE else View.GONE - val commentDrawable = ContextCompat.getDrawable(context, R.drawable.community_comment_count) - commentDrawable?.setBounds(0, 0, 20f.dip2px(), 20f.dip2px()) - comment.setCompoundDrawables(commentDrawable, null, null, null) + comment.setDrawableStart(R.drawable.community_comment_count, 20F.dip2px(), 20F.dip2px()) comment.text = if (commentData.reply > 0) NumberUtils.transSimpleCount(commentData.reply) else "" - val voteDrawable = ContextCompat.getDrawable(context, R.drawable.comment_vote_selector) - voteDrawable?.setBounds(0, 0, 20f.dip2px(), 20f.dip2px()) - vote.setCompoundDrawables(voteDrawable, null, null, null) + vote.setDrawableStart(R.drawable.comment_vote_selector, 20F.dip2px(), 20F.dip2px()) vote.isChecked = commentData.me.isVoted vote.text = if (commentData.vote > 0) NumberUtils.transSimpleCount(commentData.vote) else "" groupCl.goneIf(!commentData.active) diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingDetailCommentItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingDetailCommentItemViewHolder.kt index 20d84af403..e38cfbee07 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingDetailCommentItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingDetailCommentItemViewHolder.kt @@ -15,17 +15,17 @@ import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.core.content.ContextCompat -import com.gh.gamecenter.common.base.activity.BaseActivity -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.Constants import com.gh.common.util.* import com.gh.common.util.DialogUtils import com.gh.common.util.NewLogUtils -import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.R import com.gh.gamecenter.WebActivity +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder +import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.callback.ConfirmListener +import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.ItemArticleDetailCommentBinding import com.gh.gamecenter.entity.GameEntity @@ -91,20 +91,10 @@ class RatingDetailCommentItemViewHolder(val binding: ItemArticleDetailCommentBin if (commentData.active && commentData.gameVersion.isNotEmpty()) View.VISIBLE else View.GONE if (commentData.me.isVoted) { likeCountTv.setTextColor(R.color.theme_font.toColor(likeCountTv.context)) - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_select, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_select) } else { likeCountTv.setTextColor(R.color.text_subtitleDesc.toColor(likeCountTv.context)) - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_unselect) } likeCountTv.text = if (commentData.vote > 0) NumberUtils.transSimpleCount(commentData.vote) else "" likeCountTv.goneIf(!commentData.active) diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingItemViewHolder.kt index 0322267b52..7d48618a11 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingItemViewHolder.kt @@ -4,10 +4,11 @@ import android.view.LayoutInflater import android.widget.LinearLayout import android.widget.TextView import androidx.core.content.ContextCompat +import com.gh.gamecenter.R import com.gh.gamecenter.common.base.BaseRecyclerViewHolder +import com.gh.gamecenter.common.utils.setDrawableEnd import com.gh.gamecenter.common.utils.showAutoOrientation import com.gh.gamecenter.common.view.BugFixedPopupWindow -import com.gh.gamecenter.R import com.gh.gamecenter.databinding.RatingItemBinding class RatingItemViewHolder(val binding: RatingItemBinding) : BaseRecyclerViewHolder(binding.root) { @@ -17,9 +18,7 @@ class RatingItemViewHolder(val binding: RatingItemBinding) : BaseRecyclerViewHol * contentList [POP_SORT] 和 [POP_FILTER] 文案的内容 与[RatingViewModel.filterList] 判断对应 */ fun showPopWindow(view: TextView, type: Int, selectedValue: String, clickListener: (String) -> Unit) { - val bottomDrawable = view.context.resources.getDrawable(R.drawable.game_comment_filter_top) - bottomDrawable.setBounds(0, 0, bottomDrawable.minimumWidth, bottomDrawable.minimumHeight) - view.setCompoundDrawables(null, null, bottomDrawable, null) + view.setDrawableEnd(R.drawable.game_comment_filter_top) val contentList = when (type) { POP_SORT -> arrayListOf("默认", "热门", "最新") @@ -56,9 +55,7 @@ class RatingItemViewHolder(val binding: RatingItemBinding) : BaseRecyclerViewHol } popupWindow.setOnDismissListener { - val topDrawable = view.context.resources.getDrawable(R.drawable.game_comment_filter_bottom) - topDrawable.setBounds(0, 0, topDrawable.minimumWidth, topDrawable.minimumHeight) - view.setCompoundDrawables(null, null, topDrawable, null) + view.setDrawableEnd(R.drawable.game_comment_filter_bottom) } popupWindow.isTouchable = true diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt index ede1d5df02..6aeccd471a 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt @@ -191,12 +191,7 @@ class RatingReplyAdapter( likeCountTv.context.ifLogin("${entrance}-评论详情-点赞") { if (!commentData.me.isVoted) { viewModel.voteComment { - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_select, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_select) likeCountTv.setTextColor(R.color.theme_font.toColor(likeCountTv.context)) likeCountTv.text = (commentData.vote + 1).toString() commentData.vote = commentData.vote + 1 @@ -209,12 +204,7 @@ class RatingReplyAdapter( ) } else { viewModel.unvoteComment { - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_unselect) likeCountTv.setTextColor(R.color.text_subtitleDesc.toColor(likeCountTv.context)) val count = commentData.vote - 1 likeCountTv.text = if (count == 0) "" else count.toString() @@ -261,20 +251,10 @@ class RatingReplyAdapter( } if (replyEntity.me.isVoted) { likeCountTv.setTextColor(R.color.theme_font.toColor(likeCountTv.context)) - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_select, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_select) } else { likeCountTv.setTextColor(R.color.text_subtitleDesc.toColor(likeCountTv.context)) - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_unselect) } likeCountTv.text = if (replyEntity.vote > 0) NumberUtils.transSimpleCount(replyEntity.vote) else "" contentTv.setTextWithHighlightedTextWrappedInsideWrapper( @@ -357,12 +337,7 @@ class RatingReplyAdapter( mContext.ifLogin("游戏详情-评分-评论详情-点赞评论") { if (!replyEntity.me.isVoted) { viewModel.voteReply(replyEntity.id, callback = { - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_select, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_select) likeCountTv.setTextColor(R.color.theme_font.toColor(likeCountTv.context)) likeCountTv.text = (replyEntity.vote).toString() }) @@ -373,12 +348,7 @@ class RatingReplyAdapter( ) } else { viewModel.voteReply(replyEntity.id, false, callback = { - likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + likeCountTv.setDrawableStart(R.drawable.comment_vote_unselect) likeCountTv.setTextColor(R.color.text_subtitleDesc.toColor(likeCountTv.context)) likeCountTv.text = if (replyEntity.vote == 0) "" else (replyEntity.vote).toString() }) diff --git a/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt index b34abd977b..5fd145d744 100644 --- a/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt @@ -127,9 +127,7 @@ class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerVie binding.gameBrief.setTextColor(R.color.text_title.toColor(binding.root.context)) binding.gameRating.text = game.star.toString() binding.gameRating2.text = game.star.toString() - val drawable = R.drawable.home_game_rating.toDrawable(binding.root.context) - drawable?.setBounds(0, 0, 12F.dip2px(), 12F.dip2px()) - binding.gameRating.setCompoundDrawables(drawable, null, null, null) + binding.gameRating.setDrawableStart(R.drawable.home_game_rating, 12F.dip2px(), 12F.dip2px()) ImageUtils.display(binding.gameImage, game.homeSetting.image) binding.gameTags.postDelayed({ binding.gameTags.visibility = if (game.tagStyle.isNotEmpty()) { diff --git a/app/src/main/java/com/gh/gamecenter/home/LegacyHomeFragmentAdapterAssistant.kt b/app/src/main/java/com/gh/gamecenter/home/LegacyHomeFragmentAdapterAssistant.kt index 66de687d3d..6d8e325ed8 100644 --- a/app/src/main/java/com/gh/gamecenter/home/LegacyHomeFragmentAdapterAssistant.kt +++ b/app/src/main/java/com/gh/gamecenter/home/LegacyHomeFragmentAdapterAssistant.kt @@ -11,6 +11,9 @@ import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource import com.gh.common.util.* +import com.gh.common.util.LogUtils +import com.gh.common.util.NewFlatLogUtils +import com.gh.common.util.NewLogUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.MainActivity import com.gh.gamecenter.R @@ -19,10 +22,7 @@ import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.entity.LinkEntity -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.core.iinterface.IOffsetable import com.gh.gamecenter.core.runOnIoThread import com.gh.gamecenter.core.utils.PageSwitchDataHelper @@ -703,21 +703,11 @@ class LegacyHomeFragmentAdapterAssistant( holder.binding.pluginHeadOpen.visibility = View.GONE if (mPluginDisplayStatus == PluginDisplayStatus.OPEN_TWO_AND_BUTTON) { holder.binding.pluginExtend.text = "展开" - holder.binding.pluginExtend.setCompoundDrawablesWithIntrinsicBounds( - 0, - 0, - R.drawable.home_plugin_bottom_open, - 0 - ) + holder.binding.pluginExtend.setDrawableEnd(R.drawable.home_plugin_bottom_open) holder.binding.pluginExtend.setTextColor(R.color.theme.toColor(mContext)) } else { holder.binding.pluginExtend.text = "收起" - holder.binding.pluginExtend.setCompoundDrawablesWithIntrinsicBounds( - 0, - 0, - R.drawable.home_plugin_bottom_close, - 0 - ) + holder.binding.pluginExtend.setDrawableEnd(R.drawable.home_plugin_bottom_close) holder.binding.pluginExtend.setTextColor(R.color.text_subtitleDesc.toColor(mContext)) } } else { diff --git a/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt b/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt index 56de5e4a7b..372bcaf760 100644 --- a/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt @@ -9,19 +9,19 @@ import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintSet import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource import com.gh.common.exposure.IExposable import com.gh.common.util.NewFlatLogUtils -import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.baselist.LoadType +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.DrawableView +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.MtaHelper import com.gh.gamecenter.databinding.ItemFollowedGameBinding import com.gh.gamecenter.entity.GameEntity @@ -86,12 +86,7 @@ class MyFollowedGameAdapter(context: Context, var mViewModel: MyFollowedGameView BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() diff --git a/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt b/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt index 3138707320..6d5827b83d 100644 --- a/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt @@ -8,21 +8,25 @@ import android.view.View import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource import com.gh.common.exposure.IExposable -import com.gh.common.util.* +import com.gh.common.util.DownloadItemUtils import com.gh.common.util.NewFlatLogUtils +import com.gh.common.util.ReservationHelper import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.callback.CancelListener +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.utils.DisplayUtils +import com.gh.gamecenter.core.utils.EmptyCallback +import com.gh.gamecenter.core.utils.MtaHelper +import com.gh.gamecenter.core.utils.StringUtils import com.gh.gamecenter.databinding.ItemFollowedGameBinding import com.gh.gamecenter.entity.GameEntity import com.gh.gamecenter.eventbus.EBDownloadStatus @@ -89,10 +93,8 @@ class MyReservationAdapter(context: Context, var mViewModel: MyReservationViewMo BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable( - mContext - ) else null, null, null, null + gameRating.setDrawableStart( + if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable(mContext) else null ) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { diff --git a/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt b/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt index fa6dc7339b..82126f8d6a 100644 --- a/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt @@ -6,16 +6,12 @@ import android.graphics.drawable.GradientDrawable import android.os.Build import android.util.SparseArray import android.util.TypedValue -import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.core.AppExecutor -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource @@ -23,18 +19,20 @@ import com.gh.common.exposure.IExposable import com.gh.common.util.* import com.gh.common.util.DialogUtils import com.gh.common.util.NewFlatLogUtils -import com.gh.gamecenter.common.view.BugFixedPopupWindow -import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder - -import com.gh.gamecenter.common.callback.CancelListener import com.gh.gamecenter.common.baselist.ListAdapter +import com.gh.gamecenter.common.callback.CancelListener import com.gh.gamecenter.common.callback.ConfirmListener +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.common.view.DrawableView +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.AppExecutor +import com.gh.gamecenter.core.utils.EmptyCallback +import com.gh.gamecenter.core.utils.NumberUtils +import com.gh.gamecenter.core.utils.StringUtils import com.gh.gamecenter.databinding.ItemPlayedGameBinding import com.gh.gamecenter.databinding.ViewSimpleToggleBinding import com.gh.gamecenter.energy.EnergyBridge @@ -126,12 +124,7 @@ open class PlayedGameAdapter( BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() diff --git a/app/src/main/java/com/gh/gamecenter/mypost/MyPostAdapter.kt b/app/src/main/java/com/gh/gamecenter/mypost/MyPostAdapter.kt index dfb3b06952..ce1ea8365c 100644 --- a/app/src/main/java/com/gh/gamecenter/mypost/MyPostAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mypost/MyPostAdapter.kt @@ -8,10 +8,10 @@ import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.SpanBuilder import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.entity.ForumVideoEntity @@ -20,7 +20,6 @@ import com.gh.gamecenter.forum.home.ArticleItemVideoView import com.gh.gamecenter.personalhome.PersonalItemViewHolder import com.gh.gamecenter.personalhome.home.UserHistoryViewModel import com.gh.gamecenter.qa.entity.AnswerEntity -import com.lightgame.utils.Utils import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack import com.shuyu.gsyvideoplayer.utils.OrientationUtils @@ -104,12 +103,12 @@ class MyPostAdapter( else -> R.color.text_CCFF5269 }.toColor(mContext) ) - statusTv.setCompoundDrawablesWithIntrinsicBounds( + statusTv.setDrawableStart( when { historyEntity.me.isFollower -> R.drawable.ic_forum_follow historyEntity.status == "pending" -> R.drawable.ic_forum_pending else -> R.drawable.icon_forum_fail - }.toDrawable(), null, null, null + } ) title.goneIf(historyEntity.type.contains("answer")) title.text = diff --git a/app/src/main/java/com/gh/gamecenter/personal/HaloPersonalFragment.kt b/app/src/main/java/com/gh/gamecenter/personal/HaloPersonalFragment.kt index f164f15786..dfc150a45f 100644 --- a/app/src/main/java/com/gh/gamecenter/personal/HaloPersonalFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/personal/HaloPersonalFragment.kt @@ -16,7 +16,6 @@ import androidx.recyclerview.widget.PagerSnapHelper import androidx.recyclerview.widget.RecyclerView import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import androidx.viewpager2.widget.ViewPager2 -import com.alibaba.android.arouter.launcher.ARouter import com.gh.common.constant.Config import com.gh.common.databind.BindingAdapters import com.gh.common.util.* @@ -25,11 +24,7 @@ import com.gh.common.util.LogUtils import com.gh.common.util.NewFlatLogUtils import com.gh.common.util.NewLogUtils import com.gh.gamecenter.* -import com.gh.gamecenter.common.base.activity.BaseActivity -import com.gh.gamecenter.common.base.activity.ToolBarActivity import com.gh.gamecenter.common.base.fragment.BaseLazyFragment -import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.constant.RouteConsts import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.common.retrofit.ApiResponse import com.gh.gamecenter.common.utils.* @@ -876,36 +871,11 @@ class HaloPersonalFragment : BaseLazyFragment() { myCollectionTv.setTextColor(R.color.text_title.toColor(requireContext())) historyTv.setTextColor(R.color.text_title.toColor(requireContext())) myPostTv.setTextColor(R.color.text_title.toColor(requireContext())) - myGameTv.setCompoundDrawablesWithIntrinsicBounds( - null, - VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_game, null), - null, - null - ) - myGameCollectionTv.setCompoundDrawablesWithIntrinsicBounds( - null, - VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_game_collection, null), - null, - null - ) - myCollectionTv.setCompoundDrawablesWithIntrinsicBounds( - null, - VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_collection, null), - null, - null - ) - historyTv.setCompoundDrawablesWithIntrinsicBounds( - null, - VectorDrawableCompat.create(resources, R.drawable.ic_personal_history, null), - null, - null - ) - myPostTv.setCompoundDrawablesWithIntrinsicBounds( - null, - VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_post, null), - null, - null - ) + myGameTv.setDrawableTop(VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_game, null)) + myGameCollectionTv.setDrawableTop(VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_game_collection, null)) + myCollectionTv.setDrawableTop(VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_collection, null)) + historyTv.setDrawableTop(VectorDrawableCompat.create(resources, R.drawable.ic_personal_history, null)) + myPostTv.setDrawableTop(VectorDrawableCompat.create(resources, R.drawable.ic_personal_my_post, null)) } } } diff --git a/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt b/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt index 4318ab7cc8..6fd6e7a8d6 100644 --- a/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt @@ -7,16 +7,18 @@ import android.util.SparseBooleanArray import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.common.util.* import com.gh.common.util.DialogUtils +import com.gh.common.util.DirectUtils +import com.gh.common.util.NewsUtils import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.adapter.viewholder.PersonalHomeRatingViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.callback.ConfirmListener +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.utils.NumberUtils +import com.gh.gamecenter.core.utils.SpanBuilder import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.databinding.PersonalHomeRatingBinding import com.gh.gamecenter.entity.ForumVideoEntity @@ -122,12 +124,12 @@ class UserHistoryAdapter( else -> R.color.text_CCFF5269 }.toColor(mContext) ) - statusTv.setCompoundDrawablesWithIntrinsicBounds( + statusTv.setDrawableStart( when { historyEntity.me.isFollower -> R.drawable.ic_forum_follow historyEntity.status == "pending" -> R.drawable.ic_forum_pending else -> R.drawable.icon_forum_fail - }.toDrawable(), null, null, null + } ) title.goneIf(historyEntity.type.contains("answer")) title.text = diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt index 0cddd3027b..4a14abd924 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt @@ -4,15 +4,19 @@ import android.annotation.SuppressLint import android.view.View import android.widget.TextView import com.airbnb.lottie.LottieAnimationView -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.common.util.* import com.gh.common.view.GameIconView import com.gh.gamecenter.R +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder +import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.retrofit.BiResponse +import com.gh.gamecenter.common.retrofit.Response import com.gh.gamecenter.common.utils.debounceActionWithInterval import com.gh.gamecenter.common.utils.doOnAnimationEnd +import com.gh.gamecenter.common.utils.setDrawableStart import com.gh.gamecenter.common.utils.toColor import com.gh.gamecenter.core.utils.* -import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.energy.EnergyBridge import com.gh.gamecenter.entity.VoteEntity import com.gh.gamecenter.forum.detail.ForumDetailActivity import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity @@ -23,9 +27,6 @@ import com.gh.gamecenter.qa.entity.QuestionsDetailEntity import com.gh.gamecenter.qa.questions.invite.QuestionsInviteActivity import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity -import com.gh.gamecenter.common.retrofit.BiResponse -import com.gh.gamecenter.common.retrofit.Response -import com.gh.gamecenter.energy.EnergyBridge import com.gh.gamecenter.retrofit.RetrofitManager import com.lightgame.utils.Utils import com.lightgame.view.CheckableImageView @@ -317,15 +318,10 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH } if (entity.commentable && entity.active) { - val commentIcon = itemView.context.resources.getDrawable(R.drawable.community_comment_count) - commentIcon.setBounds(0, 0, commentIcon.minimumWidth, commentIcon.minimumHeight) - commentCount.setCompoundDrawables(commentIcon, null, null, null) + commentCount.setDrawableStart(R.drawable.community_comment_count) commentCount.setTextColor(R.color.text_subtitleDesc.toColor(commentCount.context)) } else { - val commentCloseIcon = - itemView.context.resources.getDrawable(R.drawable.community_comment_count_unavailable) - commentCloseIcon.setBounds(0, 0, commentCloseIcon.minimumWidth, commentCloseIcon.minimumHeight) - commentCount.setCompoundDrawables(commentCloseIcon, null, null, null) + commentCount.setDrawableStart(R.drawable.community_comment_count_unavailable) commentCount.setTextColor(R.color.text_body.toColor(commentCount.context)) } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt index 1222e769ff..b0ee6542ec 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt @@ -8,16 +8,17 @@ import android.view.View import android.widget.LinearLayout import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat -import com.gh.common.util.* import com.gh.common.util.DialogUtils +import com.gh.common.util.DirectUtils +import com.gh.common.util.NewsUtils import com.gh.gamecenter.CollectionActivity import com.gh.gamecenter.R import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.callback.ConfirmListener import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.SpanBuilder import com.gh.gamecenter.core.utils.DisplayUtils import com.gh.gamecenter.core.utils.MtaHelper +import com.gh.gamecenter.core.utils.SpanBuilder import com.gh.gamecenter.databinding.CommunityAnswerItemBinding import com.gh.gamecenter.login.user.UserManager import com.gh.gamecenter.qa.entity.AnswerEntity @@ -102,12 +103,12 @@ class CommunityAnswerItemViewHolder(val binding: CommunityAnswerItemBinding) : else -> R.color.text_CCFF5269 }.toColor(statusTv.context) ) - statusTv.setCompoundDrawablesWithIntrinsicBounds( + statusTv.setDrawableStart( when { entity.me.isFollower -> R.drawable.ic_forum_follow entity.status == "pending" -> R.drawable.ic_forum_pending else -> R.drawable.icon_forum_fail - }.toDrawable(), null, null, null + } ) title.goneIf(entity.type == "answer") title.text = if (entity.type.contains("video")) entity.articleTitle else entity.questions.title diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/draft/ArticleDraftAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/article/draft/ArticleDraftAdapter.kt index 8c413113ee..e12d00e7cd 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/draft/ArticleDraftAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/draft/ArticleDraftAdapter.kt @@ -5,12 +5,14 @@ import android.text.TextUtils import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat +import com.gh.gamecenter.R +import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.DialogHelper import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.R +import com.gh.gamecenter.common.utils.removeDrawable +import com.gh.gamecenter.common.utils.setDrawableStart import com.gh.gamecenter.common.viewholder.FooterViewHolder -import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.databinding.CommunityArticleDraftItemBinding import com.gh.gamecenter.qa.entity.ArticleDraftEntity @@ -60,12 +62,7 @@ class ArticleDraftAdapter( text = entity.community.name textSize = 11f setPadding(10f.dip2px(), 6f.dip2px(), 10f.dip2px(), 6f.dip2px()) - setCompoundDrawablesWithIntrinsicBounds( - ContextCompat.getDrawable( - context, - R.drawable.ic_forum_label - ), null, null, null - ) + setDrawableStart(R.drawable.ic_forum_label) background = ContextCompat.getDrawable(context, R.drawable.bg_shape_f5_radius_999) } } else { @@ -73,12 +70,13 @@ class ArticleDraftAdapter( text = "未选择论坛" textSize = 12f setPadding(0, 6f.dip2px(), 0, 6f.dip2px()) - setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + removeDrawable() setBackgroundColor(ContextCompat.getColor(context, R.color.transparent)) } } holder.binding.articleDraftDelete.setOnClickListener { - DialogHelper.showDialog(mContext, "警告", "确定要删除帖子草稿吗?删除之后不可恢复", + DialogHelper.showDialog( + mContext, "警告", "确定要删除帖子草稿吗?删除之后不可恢复", "确定", "取消", { deleteCallback.invoke(entity) }, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true) diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt index 4b62d6577e..ab895fad32 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/edit/ArticleEditActivity.kt @@ -17,19 +17,19 @@ import androidx.lifecycle.ViewModelProviders import com.gh.base.BaseRichEditorActivity import com.gh.common.util.ErrorHelper import com.gh.common.util.NewLogUtils -import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment -import com.gh.gamecenter.core.AppExecutor -import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.R +import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment import com.gh.gamecenter.common.callback.ConfirmListener +import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.EntranceConsts +import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.core.AppExecutor import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.ActivityCommunityArticleEditBinding import com.gh.gamecenter.entity.ActivityLabelEntity -import com.gh.gamecenter.common.entity.CommunityEntity import com.gh.gamecenter.entity.GameEntity -import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.login.user.UserManager import com.gh.gamecenter.qa.BbsType import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity @@ -225,7 +225,8 @@ class ArticleEditActivity : BaseRichEditorActivity(), Keyb mProcessingDialog = WaitingDialogFragment.newInstance(it.msg, false) mProcessingDialog?.show(supportFragmentManager, null) { if (mViewModel.uploadImageSubscription != null && !mViewModel?.uploadImageSubscription!!.isDisposed) { - mUploadImageCancelDialog = DialogUtils.showAlertDialog(this, "提示", "图片正在上传中,确定取消吗?", + mUploadImageCancelDialog = DialogUtils.showAlertDialog( + this, "提示", "图片正在上传中,确定取消吗?", "确定", "取消", object : ConfirmListener { override fun onConfirm() { mViewModel.uploadImageSubscription!!.dispose() @@ -270,7 +271,7 @@ class ArticleEditActivity : BaseRichEditorActivity(), Keyb setGameName() if (mViewModel.type == BbsType.GAME_BBS.value) { mBinding.articleGameName.isEnabled = false - mBinding.articleGameName.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + mBinding.articleGameName.removeDrawable() } } mBinding.articleEditTitle.requestFocus() @@ -378,7 +379,7 @@ class ArticleEditActivity : BaseRichEditorActivity(), Keyb mMenuDraft.isVisible = false mBinding.articleGameName.isEnabled = false mBinding.chooseActivityContainer.isEnabled = false - mBinding.articleGameName.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + mBinding.articleGameName.removeDrawable() // 编辑文章时可能存在草稿 if (mViewModel.draftEntity != null) { @@ -546,12 +547,7 @@ class ArticleEditActivity : BaseRichEditorActivity(), Keyb private fun setForumUI() { mBinding.forumIconView.visibility = View.VISIBLE mBinding.forumContainer.background = ContextCompat.getDrawable(this, R.drawable.bg_shape_f5_radius_999) - mBinding.articleGameName.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - ContextCompat.getDrawable(this, R.drawable.ic_article_edit_choose_forum_arrow_gray), - null - ) + mBinding.articleGameName.setDrawableEnd(R.drawable.ic_article_edit_choose_forum_arrow_gray) mBinding.articleGameName.setTextColor(ContextCompat.getColor(this, R.color.text_title)) } diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/base/BaseCommentAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/comment/base/BaseCommentAdapter.kt index 6330d427fe..87c656de1e 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/base/BaseCommentAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/comment/base/BaseCommentAdapter.kt @@ -442,7 +442,6 @@ abstract class BaseCommentAdapter( // 评论详情用的样式 binding.floorHintTv.visibility = View.GONE binding.commentCountTv.setOnClickListener { commentClosure?.invoke(comment) } -// binding.commentCountTv.setCompoundDrawables(null, null, null, null) binding.commentCountTv.text = "回复" binding.likeCountTv.text = viewModel.getLikeText(comment.vote, "") binding.root.setOnClickListener { binding.commentCountTv.performClick() } @@ -708,20 +707,10 @@ abstract class BaseCommentAdapter( if (comment.me?.isCommentVoted == true) { binding.likeCountTv.setTextColor(R.color.theme_font.toColor(binding.likeCountTv.context)) - binding.likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_select, - 0, - 0, - 0 - ) + binding.likeCountTv.setDrawableStart(R.drawable.comment_vote_select) } else { binding.likeCountTv.setTextColor(R.color.text_subtitleDesc.toColor(binding.likeCountTv.context)) - binding.likeCountTv.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.comment_vote_unselect, - 0, - 0, - 0 - ) + binding.likeCountTv.setDrawableStart(R.drawable.comment_vote_unselect) } binding.likeCountTv.setDebouncedClickListener { diff --git a/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt b/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt index 4b662622c9..d6703f99eb 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/dialog/MoreFunctionPanelDialog.kt @@ -20,6 +20,7 @@ import com.gh.gamecenter.common.eventbus.EBShare import com.gh.gamecenter.common.utils.ShareUtils import com.gh.gamecenter.common.utils.debounceActionWithInterval import com.gh.gamecenter.common.utils.dip2px +import com.gh.gamecenter.common.utils.setDrawableTop import com.gh.gamecenter.databinding.DialogGameDetailMoreBinding import com.gh.gamecenter.entity.MenuItemEntity import org.greenrobot.eventbus.EventBus @@ -191,12 +192,7 @@ class MoreFunctionPanelDialog : BaseDraggableDialogFragment() { gravity = Gravity.CENTER layoutParams = params compoundDrawablePadding = 8F.dip2px() - setCompoundDrawablesWithIntrinsicBounds( - null, - ContextCompat.getDrawable(requireContext(), itemEntity.normalIcon), - null, - null - ) + setDrawableTop(itemEntity.normalIcon) } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/draft/QuestionDraftAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/draft/QuestionDraftAdapter.kt index b8f22fb0ac..b65d31416c 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/draft/QuestionDraftAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/draft/QuestionDraftAdapter.kt @@ -6,13 +6,15 @@ import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView +import com.gh.gamecenter.R import com.gh.gamecenter.common.base.BaseRecyclerViewHolder +import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.DialogHelper import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.R +import com.gh.gamecenter.common.utils.removeDrawable +import com.gh.gamecenter.common.utils.setDrawableStart import com.gh.gamecenter.common.viewholder.FooterViewHolder -import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.databinding.CommunityQuestionDraftItemBinding import com.gh.gamecenter.qa.entity.QuestionDraftEntity @@ -63,12 +65,7 @@ class QuestionDraftAdapter( text = entity.bbs?.name textSize = 11f setPadding(10f.dip2px(), 6f.dip2px(), 10f.dip2px(), 6f.dip2px()) - setCompoundDrawablesWithIntrinsicBounds( - ContextCompat.getDrawable( - context, - R.drawable.ic_forum_label - ), null, null, null - ) + setDrawableStart(R.drawable.ic_forum_label) background = ContextCompat.getDrawable(context, R.drawable.bg_shape_f5_radius_999) } } else { @@ -76,7 +73,7 @@ class QuestionDraftAdapter( text = "未选择论坛" textSize = 12f setPadding(0, 6f.dip2px(), 0, 6f.dip2px()) - setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + removeDrawable() setBackgroundColor(ContextCompat.getColor(context, R.color.transparent)) } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt index 71b5e127fa..22167e4763 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/edit/QuestionEditActivity.kt @@ -21,24 +21,23 @@ import androidx.lifecycle.ViewModelProviders import com.gh.base.BaseRichEditorActivity import com.gh.common.util.ErrorHelper import com.gh.common.util.NewLogUtils -import com.gh.gamecenter.common.utils.NotificationHelper -import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment -import com.gh.gamecenter.core.AppExecutor -import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.R +import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment import com.gh.gamecenter.common.callback.ConfirmListener +import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.EntranceConsts import com.gh.gamecenter.common.entity.CommunityEntity import com.gh.gamecenter.common.entity.NotificationUgc +import com.gh.gamecenter.common.eventbus.EBReuse +import com.gh.gamecenter.common.mvvm.Status import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.ToastUtils +import com.gh.gamecenter.core.AppExecutor import com.gh.gamecenter.core.utils.KeyboardHeightObserver import com.gh.gamecenter.core.utils.PatternUtils +import com.gh.gamecenter.core.utils.ToastUtils import com.gh.gamecenter.databinding.ActivityQuestionsEditBinding import com.gh.gamecenter.entity.* -import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.login.user.UserManager -import com.gh.gamecenter.common.mvvm.Status import com.gh.gamecenter.qa.BbsType import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity import com.gh.gamecenter.qa.article.draft.ArticleDraftActivity @@ -274,12 +273,7 @@ class QuestionEditActivity : BaseRichEditorActivity(), setForumName() if (mViewModel.type == BbsType.GAME_BBS.value) { mBinding.chooseForumTv.isEnabled = false - mBinding.chooseForumTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - null, - null - ) + mBinding.chooseForumTv.removeDrawable() } } showUploadVideoGuide() @@ -324,7 +318,7 @@ class QuestionEditActivity : BaseRichEditorActivity(), setForumName() mBinding.chooseActivityContainer.isEnabled = false mBinding.chooseForumTv.isEnabled = false - mBinding.chooseForumTv.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + mBinding.chooseForumTv.removeDrawable() mViewModel.isModeratorPatch = intent.getBooleanExtra(EntranceConsts.KEY_QUESTION_MODERATOR_PATCH, false) @@ -788,12 +782,7 @@ class QuestionEditActivity : BaseRichEditorActivity(), mBinding.forumIconView.visibility = View.VISIBLE mBinding.forumContainer.background = ContextCompat.getDrawable(this, R.drawable.bg_shape_f5_radius_999) - mBinding.chooseForumTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - ContextCompat.getDrawable(this, R.drawable.ic_article_edit_choose_forum_arrow_gray), - null - ) + mBinding.chooseForumTv.setDrawableEnd(R.drawable.ic_article_edit_choose_forum_arrow_gray) mBinding.chooseForumTv.setTextColor(ContextCompat.getColor(this, R.color.text_title)) } diff --git a/app/src/main/java/com/gh/gamecenter/qa/video/publish/VideoPublishFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/video/publish/VideoPublishFragment.kt index 1c03b56b6c..9242b0c122 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/video/publish/VideoPublishFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/video/publish/VideoPublishFragment.kt @@ -14,24 +14,23 @@ import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doOnTextChanged import com.gh.base.BaseRichEditorActivity -import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment -import com.gh.gamecenter.core.AppExecutor -import com.gh.gamecenter.core.runOnUiThread -import com.gh.common.util.* +import com.gh.common.util.ErrorHelper import com.gh.common.util.NewLogUtils import com.gh.gamecenter.CropImageActivity import com.gh.gamecenter.R +import com.gh.gamecenter.common.base.fragment.ToolbarFragment +import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment import com.gh.gamecenter.common.constant.EntranceConsts +import com.gh.gamecenter.common.entity.CommunityEntity +import com.gh.gamecenter.common.entity.NotificationUgc +import com.gh.gamecenter.common.mvvm.Status import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.core.AppExecutor +import com.gh.gamecenter.core.runOnUiThread import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.FragmentVideoPublishBinding import com.gh.gamecenter.entity.* import com.gh.gamecenter.login.user.UserManager -import com.gh.gamecenter.common.mvvm.Status -import com.gh.gamecenter.common.base.fragment.ToolbarFragment -import com.gh.gamecenter.common.callback.ConfirmListener -import com.gh.gamecenter.common.entity.CommunityEntity -import com.gh.gamecenter.common.entity.NotificationUgc import com.gh.gamecenter.qa.BbsType import com.gh.gamecenter.qa.dialog.ChooseActivityDialogFragment import com.gh.gamecenter.qa.dialog.ChooseForumActivity @@ -230,12 +229,7 @@ class VideoPublishFragment : ToolbarFragment(), KeyboardHeightObserver { setForumName() if (mIsForumSelectionDisabled && mViewModel.type == BbsType.GAME_BBS.value) { mBinding.forumContainer.isEnabled = false - mBinding.chooseForumTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - null, - null - ) + mBinding.chooseForumTv.removeDrawable() } } if (mViewModel.selectActivityLabelEntity != null) { @@ -608,12 +602,7 @@ class VideoPublishFragment : ToolbarFragment(), KeyboardHeightObserver { private fun setForumUI() { mBinding.forumIconView.visibility = View.VISIBLE mBinding.forumContainer.background = R.drawable.bg_shape_f5_radius_999.toDrawable() - mBinding.chooseForumTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_article_edit_choose_forum_arrow_gray.toDrawable(), - null - ) + mBinding.chooseForumTv.setDrawableEnd(R.drawable.ic_article_edit_choose_forum_arrow_gray) mBinding.chooseForumTv.setTextColor(R.color.text_title.toColor()) } diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchDefaultFragment.kt b/app/src/main/java/com/gh/gamecenter/search/SearchDefaultFragment.kt index 1a5ff896f6..f56c0b132e 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchDefaultFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/search/SearchDefaultFragment.kt @@ -134,13 +134,11 @@ open class SearchDefaultFragment : BaseFragment() { headTitle.textSize = 16F headActionTv.text = "清空" headActionTv.setTextColor(R.color.text_subtitleDesc.toColor(requireContext())) - headActionTv.setCompoundDrawablesWithIntrinsicBounds( - VectorDrawableCompat.create( - resources, - R.drawable.search_history_delete, - null - ), null, null, null - ) + headActionTv.setDrawableStart(VectorDrawableCompat.create( + resources, + R.drawable.search_history_delete, + null + )) headActionTv.setOnClickListener { DialogHelper.showCenterWarningDialog(requireContext(), "清空记录", "确定清空历史搜索记录?", confirmClickCallback = { mSearchHistoryDao?.deleteAll() @@ -362,7 +360,7 @@ open class SearchDefaultFragment : BaseFragment() { } private fun createSmartHotTagStyle(flexCell: TextView) { - flexCell.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_smart_search, 0, 0, 0) + flexCell.setDrawableStart(R.drawable.ic_smart_search) flexCell.compoundDrawablePadding = 4F.dip2px() flexCell.gravity = Gravity.CENTER_VERTICAL flexCell.typeface = Typeface.DEFAULT_BOLD diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt b/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt index 27e12390a0..1e680113e5 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt @@ -11,15 +11,14 @@ import android.widget.LinearLayout import androidx.collection.ArrayMap import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.constant.Constants -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource import com.gh.common.exposure.ExposureType import com.gh.common.exposure.IExposable import com.gh.common.filter.RegionSettingHelper -import com.gh.common.util.* +import com.gh.common.util.DirectUtils +import com.gh.common.util.DownloadItemUtils import com.gh.common.util.LogUtils import com.gh.common.util.NewLogUtils import com.gh.gamecenter.GameDetailActivity @@ -28,8 +27,12 @@ import com.gh.gamecenter.SearchType import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.adapter.viewholder.SearchHistoryViewHolder import com.gh.gamecenter.common.baselist.ListAdapter +import com.gh.gamecenter.common.constant.Constants +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.core.utils.EmptyCallback +import com.gh.gamecenter.core.utils.SPUtils +import com.gh.gamecenter.core.utils.StringUtils import com.gh.gamecenter.databinding.FmSearchHistoryItemBinding import com.gh.gamecenter.databinding.LayoutSearchGameContentTagBinding import com.gh.gamecenter.databinding.SearchGameIndexItemBinding @@ -41,7 +44,6 @@ import com.gh.gamecenter.gamedetail.GameDetailFragment import com.lightgame.download.DownloadEntity import com.lightgame.utils.Util_System_Keyboard import org.greenrobot.eventbus.EventBus -import java.util.* class SearchGameIndexAdapter( context: Context, @@ -130,12 +132,7 @@ class SearchGameIndexAdapter( BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexItemViewHolder.kt index d64af625c8..a46c9e1a7c 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexItemViewHolder.kt @@ -10,6 +10,7 @@ import com.gh.common.exposure.ExposureSource import com.gh.common.util.DirectUtils import com.gh.gamecenter.R import com.gh.gamecenter.common.utils.goneIf +import com.gh.gamecenter.common.utils.setDrawableEnd import com.gh.gamecenter.common.utils.toColor import com.gh.gamecenter.common.view.DrawableView import com.gh.gamecenter.databinding.SearchGameIndexItemBinding @@ -74,12 +75,7 @@ class SearchSubjectItemViewHolder(var binding: SearchSubjectItemBinding) : Recyc headContainer.headTitle.text = entity.name headContainer.headActionTv.text = "全部" headContainer.headActionTv.setTextColor(R.color.theme_font.toColor(context)) - headContainer.headActionTv.setCompoundDrawablesWithIntrinsicBounds( - null, - null, - VectorDrawableCompat.create(context.resources, R.drawable.ic_home_head_arrow, null), - null - ) + headContainer.headActionTv.setDrawableEnd(VectorDrawableCompat.create(context.resources, R.drawable.ic_home_head_arrow, null)) headContainer.headActionTv.setOnClickListener { dao?.add(key) DirectUtils.directToSubject(context, entity.columnId, entity.name, "($type-专题)") diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt b/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt index 7d1861dcb9..95336b4818 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt @@ -10,27 +10,30 @@ import android.widget.LinearLayout import androidx.collection.ArrayMap import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.constant.Constants -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent import com.gh.common.exposure.ExposureSource import com.gh.common.exposure.ExposureType import com.gh.common.exposure.IExposable import com.gh.common.filter.RegionSettingHelper -import com.gh.common.util.* +import com.gh.common.util.DirectUtils +import com.gh.common.util.DownloadItemUtils import com.gh.common.util.LogUtils import com.gh.common.util.NewLogUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R import com.gh.gamecenter.SearchType import com.gh.gamecenter.SuggestionActivity -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.adapter.viewholder.SearchGameFooterViewHolder import com.gh.gamecenter.common.baselist.ListAdapter +import com.gh.gamecenter.common.constant.Constants +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* -import com.gh.gamecenter.core.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.core.utils.EmptyCallback +import com.gh.gamecenter.core.utils.SPUtils +import com.gh.gamecenter.core.utils.StringUtils import com.gh.gamecenter.databinding.LayoutSearchGameContentTagBinding import com.gh.gamecenter.databinding.SearchGameFooterBinding import com.gh.gamecenter.databinding.SearchGameIndexItemBinding @@ -42,7 +45,6 @@ import com.gh.gamecenter.suggest.SuggestType import com.lightgame.download.DownloadEntity import com.lightgame.utils.Util_System_Keyboard import org.greenrobot.eventbus.EventBus -import java.util.* class SearchGameResultAdapter( context: Context, @@ -195,12 +197,7 @@ class SearchGameResultAdapter( BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() diff --git a/app/src/main/java/com/gh/gamecenter/simulatorgame/SimulatorGameListAdapter.kt b/app/src/main/java/com/gh/gamecenter/simulatorgame/SimulatorGameListAdapter.kt index 71a3e70531..35dac161c0 100644 --- a/app/src/main/java/com/gh/gamecenter/simulatorgame/SimulatorGameListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/simulatorgame/SimulatorGameListAdapter.kt @@ -18,25 +18,24 @@ import androidx.core.content.pm.ShortcutInfoCompat import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.graphics.drawable.IconCompat import androidx.recyclerview.widget.RecyclerView -import com.g00fy2.versioncompare.Version -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters import com.gh.common.simulator.SimulatorDownloadManager import com.gh.common.simulator.SimulatorGameManager import com.gh.common.util.* import com.gh.common.util.DialogUtils import com.gh.common.util.NewFlatLogUtils -import com.gh.gamecenter.common.view.BugFixedPopupWindow import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.MainActivity import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.adapter.viewholder.GameViewHolder +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.callback.BiCallback import com.gh.gamecenter.common.constant.EntranceConsts +import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.BugFixedPopupWindow +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.SimulatorGameItemBinding import com.gh.gamecenter.databinding.SimulatorHeaderViewBinding @@ -124,9 +123,14 @@ class SimulatorGameListAdapter( holder.binding.btnSimulator.run { if (PackageUtils.isInstalledFromAllPackage(context, simulator.apk?.packageName)) { // val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator.apk?.packageName) - val shouldShowUpdate = PackageUtils.isInstalledApkMatchedMd5(simulator.apk?.packageName, simulator.apk?.md5) + val shouldShowUpdate = + PackageUtils.isInstalledApkMatchedMd5(simulator.apk?.packageName, simulator.apk?.md5) text = if (shouldShowUpdate) "更新模拟器" else "" - setTextColor(if (shouldShowUpdate) R.color.theme.toColor(mContext) else R.color.text_subtitleDesc.toColor(mContext)) + setTextColor( + if (shouldShowUpdate) R.color.theme.toColor(mContext) else R.color.text_subtitleDesc.toColor( + mContext + ) + ) setOnClickListener { if (shouldShowUpdate) { SimulatorDownloadManager.getInstance().showDownloadDialog( @@ -181,12 +185,7 @@ class SimulatorGameListAdapter( BindingAdapters.setGameName(gameName, gameEntity, false, null) BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10) BindingAdapters.setGameTags(labelList, gameEntity) - gameRating.setCompoundDrawablesWithIntrinsicBounds( - if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null, - null, - null, - null - ) + gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null) gameRating.setPadding(0, 0, if (gameEntity.commentCount > 3) 8F.dip2px() else 0, 0) gameRating.text = if (gameEntity.commentCount > 3) { if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString() @@ -411,30 +410,39 @@ class SimulatorGameListAdapter( private fun showDeleteSingleGameDialog(gameEntity: GameEntity) { NewFlatLogUtils.logSimulatorGameDeleteAlertShow() - DialogHelper.showDialog(mContext, "删除游戏", "即将删除游戏记录和本地文件,是否确定删除", "确定", "取消", { - NewFlatLogUtils.logSimulatorGameDeleteAlertClick("确定") - val isNetworkConnected = NetworkUtils.isNetworkConnected(mContext) - SimulatorGameManager.deleteLocalGame(gameEntity.name ?: "") - if (isNetworkConnected) { - SimulatorGameManager.deleteSimulatorGame(gameEntity.id) { + DialogHelper.showDialog( + mContext, + "删除游戏", + "即将删除游戏记录和本地文件,是否确定删除", + "确定", + "取消", + { + NewFlatLogUtils.logSimulatorGameDeleteAlertClick("确定") + val isNetworkConnected = NetworkUtils.isNetworkConnected(mContext) + SimulatorGameManager.deleteLocalGame(gameEntity.name ?: "") + if (isNetworkConnected) { + SimulatorGameManager.deleteSimulatorGame(gameEntity.id) { + if (mEntityList.size == 1) { + (fragment.parentFragment as SimulatorGameFragment).refresh() + } else { + fragment.onLoadRefresh() + } + } + mSimulatorGameDao.deleteSimulatorGameByName(gameEntity.name ?: "") + } else { + mSimulatorGameDao.logicalDeleteSimulatorGame(gameEntity.name ?: "") + } + if (!isNetworkConnected) { if (mEntityList.size == 1) { (fragment.parentFragment as SimulatorGameFragment).refresh() } else { fragment.onLoadRefresh() } } - mSimulatorGameDao.deleteSimulatorGameByName(gameEntity.name ?: "") - } else { - mSimulatorGameDao.logicalDeleteSimulatorGame(gameEntity.name ?: "") - } - if (!isNetworkConnected) { - if (mEntityList.size == 1) { - (fragment.parentFragment as SimulatorGameFragment).refresh() - } else { - fragment.onLoadRefresh() - } - } - }, cancelClickCallback = { NewFlatLogUtils.logSimulatorGameDeleteAlertClick("取消") }, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)) + }, + cancelClickCallback = { NewFlatLogUtils.logSimulatorGameDeleteAlertClick("取消") }, + extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true) + ) } fun resetPageFromFragment() { diff --git a/app/src/main/java/com/gh/gamecenter/video/poster/PosterEditActivity.kt b/app/src/main/java/com/gh/gamecenter/video/poster/PosterEditActivity.kt index 84314086a8..5ac5b053c1 100644 --- a/app/src/main/java/com/gh/gamecenter/video/poster/PosterEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/video/poster/PosterEditActivity.kt @@ -9,16 +9,13 @@ import android.view.View import android.widget.AdapterView import android.widget.PopupWindow import android.widget.TextView -import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment -import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout -import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout import com.gh.gamecenter.CropImageActivity import com.gh.gamecenter.R +import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout +import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.DialogHelper -import com.gh.gamecenter.common.utils.addOnPageChangeListener -import com.gh.gamecenter.common.utils.dip2px +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.core.utils.DisplayUtils import com.gh.gamecenter.databinding.ActivityPosterEditBinding import com.gh.gamecenter.entity.VideoEntity @@ -27,7 +24,6 @@ import com.gh.gamecenter.video.poster.photo.PhotoAlbumsSpanner import com.gh.gamecenter.video.poster.photo.PhotoPosterFragment import com.gh.gamecenter.video.poster.video.VideoPosterFragment import com.gh.gamecenter.video.upload.view.UploadVideoActivity -import com.halo.assistant.HaloApp import com.zhihu.matisse.Matisse import com.zhihu.matisse.MimeType import com.zhihu.matisse.internal.entity.Album @@ -98,7 +94,7 @@ class PosterEditActivity : BaseActivity_TabLayout(), AdapterView.OnItemSelectedL mBinding.activityViewPager.addOnPageChangeListener { if (VIDEO_POSTER_INDEX == it) { setNavigationTitle("编辑封面") - mTitleTv.setCompoundDrawables(null, null, null, null) + mTitleTv.removeDrawable() } else { setPhotoNavigationTitle(false) } @@ -168,14 +164,7 @@ class PosterEditActivity : BaseActivity_TabLayout(), AdapterView.OnItemSelectedL private fun setPhotoNavigationTitle(up: Boolean) { if (mBinding.activityViewPager.currentItem == VIDEO_POSTER_INDEX) return - - val drawable = if (up) { - ContextCompat.getDrawable(HaloApp.getInstance().application, R.drawable.poster_select_up) - } else { - ContextCompat.getDrawable(HaloApp.getInstance().application, R.drawable.poster_select_down) - } - drawable?.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight) - mTitleTv.setCompoundDrawables(null, null, drawable, null) + mTitleTv.setDrawableEnd(if (up) R.drawable.poster_select_up else R.drawable.poster_select_down) mTitleTv.compoundDrawablePadding = 2F.dip2px() mTitleTv.text = "全部图片" } diff --git a/app/src/main/java/com/gh/gamecenter/video/videomanager/VideoDraftAdapter.kt b/app/src/main/java/com/gh/gamecenter/video/videomanager/VideoDraftAdapter.kt index 62990d1254..a33b814673 100644 --- a/app/src/main/java/com/gh/gamecenter/video/videomanager/VideoDraftAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/video/videomanager/VideoDraftAdapter.kt @@ -8,18 +8,15 @@ import android.widget.LinearLayout import android.widget.TextView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.common.util.* -import com.gh.gamecenter.common.view.BugFixedPopupWindow +import com.gh.common.util.LogUtils import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.common.baselist.ListAdapter -import com.gh.gamecenter.common.utils.DialogHelper +import com.gh.gamecenter.common.constant.ItemViewType +import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.view.BugFixedPopupWindow +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.EmptyCallback -import com.gh.gamecenter.common.utils.PermissionHelper -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.showAutoOrientation import com.gh.gamecenter.databinding.CommunityVideoDraftItemBinding import com.gh.gamecenter.entity.VideoDraftEntity @@ -66,12 +63,7 @@ class VideoDraftAdapter( text = draftEntity.game?.name textSize = 11f setPadding(10f.dip2px(), 6f.dip2px(), 10f.dip2px(), 6f.dip2px()) - setCompoundDrawablesWithIntrinsicBounds( - ContextCompat.getDrawable( - context, - R.drawable.ic_forum_label - ), null, null, null - ) + setDrawableStart(R.drawable.ic_forum_label) background = ContextCompat.getDrawable(context, R.drawable.bg_shape_f5_radius_999) } } else { @@ -79,7 +71,7 @@ class VideoDraftAdapter( text = "未选择论坛" textSize = 12f setPadding(0, 6f.dip2px(), 0, 6f.dip2px()) - setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + removeDrawable() setBackgroundColor(ContextCompat.getColor(context, R.color.transparent)) } } diff --git a/app/src/main/java/com/gh/gamecenter/vote/VoteAdapter.kt b/app/src/main/java/com/gh/gamecenter/vote/VoteAdapter.kt index 53834a2698..6eb6782b61 100644 --- a/app/src/main/java/com/gh/gamecenter/vote/VoteAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/vote/VoteAdapter.kt @@ -20,10 +20,7 @@ import com.gh.gamecenter.adapter.viewholder.VoteViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.baselist.LoadStatus import com.gh.gamecenter.common.constant.EntranceConsts -import com.gh.gamecenter.common.utils.dip2px -import com.gh.gamecenter.common.utils.ifLogin -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable +import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.common.view.CustomLinkMovementMethod import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.DisplayUtils @@ -196,7 +193,7 @@ class VoteAdapter( viewHolder.hint.setText(R.string.loading_failed_retry) viewHolder.hint.setTextColor(R.color.text_B3B3B3.toColor(mContext)) viewHolder.hint.textSize = 12F - viewHolder.hint.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + viewHolder.hint.removeDrawable() viewHolder.itemView.isClickable = true viewHolder.itemView.setPadding(0, 0, 0, 0) viewHolder.itemView.layoutParams = viewHolder.itemView.layoutParams.apply { height = 48F.dip2px() } @@ -206,7 +203,7 @@ class VoteAdapter( text = "添加选项" setTextColor(R.color.theme_font.toColor(mContext)) textSize = 14F - setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_add_vote.toDrawable(mContext), null, null, null) + setDrawableStart(R.drawable.ic_add_vote) compoundDrawablePadding = 4F.dip2px() } viewHolder.itemView.isClickable = false @@ -218,7 +215,7 @@ class VoteAdapter( viewHolder.hint.setText(R.string.loading) viewHolder.hint.setTextColor(R.color.text_B3B3B3.toColor(mContext)) viewHolder.hint.textSize = 12F - viewHolder.hint.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) + viewHolder.hint.removeDrawable() viewHolder.itemView.isClickable = false viewHolder.itemView.setPadding(0, 0, 0, 0) viewHolder.itemView.layoutParams = viewHolder.itemView.layoutParams.apply { height = 48F.dip2px() } diff --git a/app/src/main/java/com/gh/vspace/VDownloadManagerAdapter.kt b/app/src/main/java/com/gh/vspace/VDownloadManagerAdapter.kt index 1e8ef50fd7..241371f7ef 100644 --- a/app/src/main/java/com/gh/vspace/VDownloadManagerAdapter.kt +++ b/app/src/main/java/com/gh/vspace/VDownloadManagerAdapter.kt @@ -7,8 +7,6 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.PopupWindow import androidx.appcompat.app.AppCompatActivity -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.recyclerview.widget.DiffUtil.calculateDiff import androidx.recyclerview.widget.RecyclerView import com.gh.common.databind.BindingAdapters import com.gh.common.exposure.ExposureEvent @@ -19,12 +17,12 @@ import com.gh.common.view.DownloadButton import com.gh.download.DownloadManager import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.baselist.LoadType import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.ItemViewType import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.AppExecutor import com.gh.gamecenter.core.runOnIoThread import com.gh.gamecenter.core.utils.CurrentActivityHolder @@ -260,12 +258,7 @@ class VDownloadManagerAdapter( root.setBackgroundColor(R.color.background_white.toColor(mContext)) checkAllCb.setTextColor(R.color.text_title.toColor(mContext)) selectNumTv.setTextColor(R.color.theme_font.toColor(mContext)) - checkAllCb.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.selector_ic_simulator.toDrawable(mContext), - null, - null, - null - ) + checkAllCb.setDrawableStart(R.drawable.selector_ic_simulator) checkSelectItems() } } diff --git a/app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java b/app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java index ea33ecb705..57b2ab4c76 100644 --- a/app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java +++ b/app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java @@ -111,7 +111,7 @@ public class GamePluginAdapter extends BaseRecyclerAdapter { BindingAdapters.setGameName(binding.gameItemIncluded.gameName, gameEntity, true, null); BindingAdapters.setTextSize(binding.gameItemIncluded.gameRating, gameEntity.getCommentCount() > 3 ? 12 : 10); BindingAdapters.setGameTags(binding.gameItemIncluded.labelList, gameEntity); - binding.gameItemIncluded.gameRating.setCompoundDrawablesWithIntrinsicBounds(gameEntity.getCommentCount() > 3 ? ExtensionsKt.toDrawable(R.drawable.game_horizontal_rating) : null, null, null, null); + ExtensionsKt.setDrawableStart(binding.gameItemIncluded.gameRating, gameEntity.getCommentCount() > 3 ? ExtensionsKt.toDrawable(R.drawable.game_horizontal_rating) : null, null, null); binding.gameItemIncluded.gameRating.setPadding(0, 0, gameEntity.getCommentCount() > 3 ? DisplayUtils.dip2px(8) : 0, 0); binding.gameItemIncluded.gameRating.setText(gameEntity.getCommentCount() > 3 ? (gameEntity.getStar() == 10.0 ? "10" : String.valueOf(gameEntity.getStar())) : ""); binding.gameItemIncluded.gameRating.setTextColor(gameEntity.getCommentCount() > 3 ? ExtensionsKt.toColor(R.color.theme_font) : ExtensionsKt.toColor(R.color.theme)); diff --git a/module_common/src/main/java/com/gh/gamecenter/common/utils/DialogHelper.kt b/module_common/src/main/java/com/gh/gamecenter/common/utils/DialogHelper.kt index c41967a244..a29ced6a02 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/utils/DialogHelper.kt +++ b/module_common/src/main/java/com/gh/gamecenter/common/utils/DialogHelper.kt @@ -6,11 +6,7 @@ import android.content.Context import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.text.Html -import android.view.Gravity -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.Window +import android.view.* import com.alibaba.android.arouter.launcher.ARouter import com.gh.gamecenter.common.R import com.gh.gamecenter.common.base.TrackableDialog @@ -411,12 +407,7 @@ object DialogHelper { visibility = View.VISIBLE text = "查看活动详情" setTextColor(R.color.theme_font.toColor(context)) - setCompoundDrawablesWithIntrinsicBounds( - null, - null, - R.drawable.ic_libao_activity_arrow.toDrawable(context), - null - ) + setDrawableEnd(R.drawable.ic_libao_activity_arrow) compoundDrawablePadding = 4F.dip2px() setOnClickListener { hintClickCallback.onCallback() diff --git a/module_common/src/main/java/com/gh/gamecenter/common/utils/Extensions.kt b/module_common/src/main/java/com/gh/gamecenter/common/utils/Extensions.kt index 0e2f3b104c..3a54f27eb7 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/utils/Extensions.kt +++ b/module_common/src/main/java/com/gh/gamecenter/common/utils/Extensions.kt @@ -1379,4 +1379,48 @@ fun View.convertViewToBitmap(): Bitmap? { canvas.save() bitmap } else null +} + +fun TextView.removeDrawable() { + this.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) +} + +fun TextView.setDrawableStart(@DrawableRes drawableRes: Int, width: Int? = null, height: Int? = null) { + val drawable = drawableRes.toDrawable(this.context) + this.setDrawableStart(drawable, width, height) +} + +fun TextView.setDrawableStart(drawable: Drawable?, width: Int? = null, height: Int? = null) { + drawable?.setBounds(0, 0, width ?: drawable.minimumWidth, height ?: drawable.minimumHeight) + this.setCompoundDrawables(drawable, null, null, null) +} + +fun TextView.setDrawableTop(@DrawableRes drawableRes: Int, width: Int? = null, height: Int? = null) { + val drawable = drawableRes.toDrawable(this.context) + this.setDrawableTop(drawable, width, height) +} + +fun TextView.setDrawableTop(drawable: Drawable?, width: Int? = null, height: Int? = null) { + drawable?.setBounds(0, 0, width ?: drawable.minimumWidth, height ?: drawable.minimumHeight) + this.setCompoundDrawables(null, drawable, null, null) +} + +fun TextView.setDrawableEnd(@DrawableRes drawableRes: Int, width: Int? = null, height: Int? = null) { + val drawable = drawableRes.toDrawable(this.context) + this.setDrawableEnd(drawable, width, height) +} + +fun TextView.setDrawableEnd(drawable: Drawable?, width: Int? = null, height: Int? = null) { + drawable?.setBounds(0, 0, width ?: drawable.minimumWidth, height ?: drawable.minimumHeight) + this.setCompoundDrawables(null, null, drawable, null) +} + +fun TextView.setDrawableBottom(@DrawableRes drawableRes: Int, width: Int? = null, height: Int? = null) { + val drawable = drawableRes.toDrawable(this.context) + this.setDrawableBottom(drawable, width, height) +} + +fun TextView.setDrawableBottom(drawable: Drawable?, width: Int? = null, height: Int? = null) { + drawable?.setBounds(0, 0, width ?: drawable.minimumWidth, height ?: drawable.minimumHeight) + this.setCompoundDrawables(null, null, null, drawable) } \ No newline at end of file diff --git a/module_common/src/main/java/com/gh/gamecenter/common/view/DrawableView.kt b/module_common/src/main/java/com/gh/gamecenter/common/view/DrawableView.kt index 1dee70ccb2..2296f0dd76 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/view/DrawableView.kt +++ b/module_common/src/main/java/com/gh/gamecenter/common/view/DrawableView.kt @@ -15,8 +15,9 @@ import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.core.content.ContextCompat import com.gh.gamecenter.common.HaloApp -import com.gh.gamecenter.core.utils.DisplayUtils import com.gh.gamecenter.common.utils.dip2px +import com.gh.gamecenter.common.utils.setDrawableStart +import com.gh.gamecenter.core.utils.DisplayUtils object DrawableView { @@ -114,8 +115,7 @@ object DrawableView { } else { null } - drawable?.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight) - textView.setCompoundDrawables(drawable, null, null, null) + textView.setDrawableStart(drawable) if (text != null) textView.text = text }