diff --git a/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.kt b/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.kt index 5ee8976704..54f91c7256 100644 --- a/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.kt @@ -277,7 +277,6 @@ class SubjectAdapter(context: Context, } } } else if (holder is FooterViewHolder) { - holder.initItemPadding() holder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver, R.string.ask_loadover_hint) holder.itemView.setOnClickListener { if (mIsNetworkError) { diff --git a/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTileFragment.kt b/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTileFragment.kt index 97b1009352..b8cd2e2cde 100644 --- a/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTileFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTileFragment.kt @@ -68,7 +68,7 @@ class SubjectTileFragment : BaseFragment() { if (mSettingsEntity.typeEntity.content.size > 1) { - val adapter = SubjectTypeListAdapter(context!!, mItemClickListener = { + val adapter = SubjectTypeListAdapter(requireContext(), mItemClickListener = { mSelectedTypeName = it mSubjectData.filter = UrlFilterUtils.getFilterQuery("type", it) loadData() diff --git a/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTypeListAdapter.kt b/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTypeListAdapter.kt index 8bf2523730..544ec658e7 100644 --- a/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTypeListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/subject/tile/SubjectTypeListAdapter.kt @@ -8,9 +8,8 @@ import android.text.TextUtils import android.view.Gravity import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout +import android.widget.CheckedTextView import android.widget.RelativeLayout -import android.widget.TextView import com.gh.common.util.DisplayUtils import com.gh.gamecenter.R import com.lightgame.adapter.BaseRecyclerAdapter @@ -23,15 +22,14 @@ class SubjectTypeListAdapter(context: Context, override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubjectTypeViewHolder { val relativeLayout = RelativeLayout(mContext) - relativeLayout.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 35f)) + relativeLayout.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 32f)) relativeLayout.gravity = Gravity.CENTER - val textView = TextView(mContext) - textView.textSize = 14f - textView.setBackgroundResource(R.drawable.subject_tab_style) - textView.setTextColor(ContextCompat.getColor(mContext, R.color.title)) - textView.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(mContext, 25f)) + val textView = CheckedTextView(mContext) + textView.textSize = 12f + textView.setBackgroundResource(R.drawable.text_blue_or_white_style) + textView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(mContext, 24f)) textView.gravity = Gravity.CENTER - textView.setPadding(DisplayUtils.dip2px(mContext, 10f), 0, DisplayUtils.dip2px(mContext, 10f), 0) + textView.setPadding(DisplayUtils.dip2px(mContext, 8f), 0, DisplayUtils.dip2px(mContext, 8f), 0) relativeLayout.addView(textView) return SubjectTypeViewHolder(relativeLayout) } @@ -41,18 +39,17 @@ class SubjectTypeListAdapter(context: Context, holder.type.text = mGameType[position] if (!TextUtils.isEmpty(mCurType) && mCurType == mGameType[position]) { - holder.type.isSelected = true + holder.type.isChecked = true holder.type.setTextColor(Color.WHITE) - } else { - holder.type.isSelected = false - holder.type.setTextColor(ContextCompat.getColor(mContext, R.color.title)) + holder.type.isChecked = false + holder.type.setTextColor(ContextCompat.getColor(mContext, R.color.text_3a3a3a)) } holder.type.setOnClickListener { if (holder.adapterPosition == -1) return@setOnClickListener - holder.type.isSelected = true + holder.type.isChecked = true mCurType = mGameType[holder.adapterPosition] mItemClickListener.invoke(mGameType[holder.adapterPosition]) notifyDataSetChanged() @@ -63,7 +60,7 @@ class SubjectTypeListAdapter(context: Context, return mGameType.size } - inner class SubjectTypeViewHolder(itemView: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView) { - val type: TextView = (itemView as RelativeLayout).getChildAt(0) as TextView + inner class SubjectTypeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val type: CheckedTextView = (itemView as RelativeLayout).getChildAt(0) as CheckedTextView } } \ No newline at end of file diff --git a/app/src/main/res/color/subject_tiled_tab_color_selector.xml b/app/src/main/res/color/subject_tiled_tab_color_selector.xml new file mode 100644 index 0000000000..64c555feff --- /dev/null +++ b/app/src/main/res/color/subject_tiled_tab_color_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/text_black_or_white_color_style.xml b/app/src/main/res/color/text_black_or_white_color_style.xml similarity index 100% rename from app/src/main/res/drawable/text_black_or_white_color_style.xml rename to app/src/main/res/color/text_black_or_white_color_style.xml diff --git a/app/src/main/res/drawable/subject_tab_style.xml b/app/src/main/res/drawable/subject_tab_style.xml index b04107d53b..2c660a3ef3 100644 --- a/app/src/main/res/drawable/subject_tab_style.xml +++ b/app/src/main/res/drawable/subject_tab_style.xml @@ -2,7 +2,6 @@ - \ No newline at end of file diff --git a/app/src/main/res/drawable/subject_tiled_tab_background.xml b/app/src/main/res/drawable/subject_tiled_tab_background.xml new file mode 100644 index 0000000000..f74f5456b5 --- /dev/null +++ b/app/src/main/res/drawable/subject_tiled_tab_background.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/subject_tiled_tab_select.xml b/app/src/main/res/drawable/subject_tiled_tab_select.xml new file mode 100644 index 0000000000..9370a23371 --- /dev/null +++ b/app/src/main/res/drawable/subject_tiled_tab_select.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/subject_tiled_tab_selector.xml b/app/src/main/res/drawable/subject_tiled_tab_selector.xml new file mode 100644 index 0000000000..f45b10b7ab --- /dev/null +++ b/app/src/main/res/drawable/subject_tiled_tab_selector.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_subject_tiled.xml b/app/src/main/res/layout/fragment_subject_tiled.xml index 84bfe57ae7..cb36e1792a 100644 --- a/app/src/main/res/layout/fragment_subject_tiled.xml +++ b/app/src/main/res/layout/fragment_subject_tiled.xml @@ -1,62 +1,67 @@ - + + android:id="@+id/subject_appbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/white" + android:gravity="center" + app:layout_behavior="com.gh.common.view.FixAppBarLayoutBehavior"> + android:id="@+id/subject_type_list" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:layout_scrollFlags="scroll|enterAlwaysCollapsed" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="12dp" + android:layout_marginBottom="16dp" + android:background="@drawable/subject_tiled_tab_background"> + android:id="@+id/subject_tabbar_hottest" + android:layout_width="wrap_content" + android:layout_height="24dp" + android:background="@drawable/subject_tiled_tab_selector" + android:checked="true" + android:gravity="center" + android:paddingLeft="24dp" + android:paddingRight="24dp" + android:text="最热" + android:textAlignment="center" + android:textColor="@color/subject_tiled_tab_color_selector" + android:textSize="12sp" /> - + android:id="@+id/subject_tabbar_newest" + android:layout_width="wrap_content" + android:layout_height="24dp" + android:background="@drawable/subject_tiled_tab_selector" + android:checked="false" + android:gravity="center" + android:paddingLeft="24dp" + android:paddingRight="24dp" + android:text="最新" + android:textAlignment="center" + android:textColor="@color/subject_tiled_tab_color_selector" + android:textSize="12sp" /> + - + + android:id="@+id/subject_content_rl" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/subject_rows_label_item.xml b/app/src/main/res/layout/subject_rows_label_item.xml index cc211de762..1d614bb7ba 100644 --- a/app/src/main/res/layout/subject_rows_label_item.xml +++ b/app/src/main/res/layout/subject_rows_label_item.xml @@ -9,5 +9,5 @@ android:paddingRight = "8dp" android:singleLine="true" android:background="@drawable/text_blue_or_white_style" - android:textColor = "@drawable/text_black_or_white_color_style" + android:textColor = "@color/text_black_or_white_color_style" android:textSize = "12sp" />