侧边栏修改

This commit is contained in:
18401019693 2022-11-14 16:54:42 +08:00
parent 81763110d7
commit da3398f1f9
6 changed files with 75 additions and 6 deletions

View File

@ -17,10 +17,10 @@ import java.util.List;
public class FunGamesAdapter extends RecyclerView.Adapter {
private Context mContext;
private boolean rigts ;
private boolean rigts;
private List<CustomSidebarChildModel> child = new ArrayList<>();
public FunGamesAdapter(Context mContext,boolean rigts) {
public FunGamesAdapter(Context mContext, boolean rigts) {
this.mContext = mContext;
this.rigts = rigts;
}
@ -35,7 +35,7 @@ public class FunGamesAdapter extends RecyclerView.Adapter {
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
FunGamesChildViewHolder childViewHolder = (FunGamesChildViewHolder) holder;
childViewHolder.setData(child.get(position),rigts);
childViewHolder.setData(child.get(position), rigts);
}
@Override
@ -44,6 +44,18 @@ public class FunGamesAdapter extends RecyclerView.Adapter {
}
public void updateData(List<CustomSidebarChildModel> mChild) {
child.clear();
if (mChild.size() > 8) {
for (int i = 0; i < 8; i++) {
child.add(mChild.get(i));
}
} else {
child.addAll(mChild);
}
notifyDataSetChanged();
}
public void selectAll(List<CustomSidebarChildModel> mChild){
child.clear();
child.addAll(mChild);
notifyDataSetChanged();

View File

@ -1,8 +1,8 @@
package com.yunbao.common.views;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -12,24 +12,32 @@ import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.adapter.FunGamesAdapter;
import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.event.CustomDrawerPopupEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.List;
public class FunGamesViewHolder extends RecyclerView.ViewHolder {
private FunGamesAdapter funGamesAdapter;
private TextView sendGoodGift, subtitle;
private TextView sendGoodGift, subtitle, selectMore;
private RecyclerView childList;
private ImageView selectMoreIcon;
boolean isShowMore = true;
public FunGamesViewHolder(@NonNull View itemView) {
super(itemView);
sendGoodGift = itemView.findViewById(R.id.send_good_gift);
subtitle = itemView.findViewById(R.id.subtitle);
childList = itemView.findViewById(R.id.child_list);
selectMoreIcon = itemView.findViewById(R.id.select_more_icon);
selectMore = itemView.findViewById(R.id.select_more);
funGamesAdapter = new FunGamesAdapter(itemView.getContext(), true);
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4));
childList.setAdapter(funGamesAdapter);
@ -37,9 +45,14 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder {
}
public void setData(CustomSidebarInfoModel model) {
List<CustomSidebarChildModel> sidebarChildModels = model.getChild();
// sidebarChildModels.addAll(model.getChild());
// sidebarChildModels.addAll(model.getChild());
itemView.findViewById(R.id.select_more_layout).setVisibility(sidebarChildModels.size() >= 8 ? View.VISIBLE : View.GONE);
sendGoodGift.setText(model.getTitle());
subtitle.setText(model.getSubtitle());
funGamesAdapter.updateData(model.getChild());
funGamesAdapter.updateData(sidebarChildModels);
ViewClicksAntiShake.clicksAntiShake(subtitle, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
@ -64,5 +77,21 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder {
}
});
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.select_more_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (isShowMore) {
funGamesAdapter.selectAll(sidebarChildModels);
selectMore.setText(R.string.video_comment_collapsed);
ImgLoader.display(itemView.getContext(), R.mipmap.icon_more_up, selectMoreIcon);
} else {
funGamesAdapter.updateData(sidebarChildModels);
selectMore.setText(R.string.moer);
ImgLoader.display(itemView.getContext(), R.mipmap.icon_more_down, selectMoreIcon);
}
isShowMore = !isShowMore;
}
});
}
}

View File

@ -43,4 +43,30 @@
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" />
<LinearLayout
android:id="@+id/select_more_layout"
android:layout_width="wrap_content"
android:padding="14dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical">
<TextView
android:id="@+id/select_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/moer"
android:textColor="#EEF1FF"
android:textSize="12sp" />
<ImageView
android:id="@+id/select_more_icon"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_marginStart="3dp"
android:src="@mipmap/icon_more_down" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

View File

@ -781,6 +781,7 @@
<string name="encourage_dynamic_list">鼓勵記錄</string>
<string name="encourage_list_nodata">暫時還沒有人給予作者鼓勵T_T</string>
<string name="click_moer">點擊查看更多</string>
<string name="customer_service">客服</string>
<string name="set_up">設定</string>
<string name="kefu_time">每日13:00PM-1:00AM</string>
@ -960,4 +961,5 @@
<string name="already_collected" translatable="false">已領取</string>
<string name="image_quality_selection" translatable="false">畫質選擇</string>
<string name="more_settings" translatable="false">更多設置</string>
<string name="moer">查看更多</string>
</resources>