侧边栏:侧边栏界面完成,文字消息更改
This commit is contained in:
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.views.DrawerRecommendViewHolder;
|
||||
import com.yunbao.common.views.DrawerTaskViewHolder;
|
||||
@@ -30,6 +31,7 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
|
||||
private final int FUN_GAMES = 3;
|
||||
private final int RIGHTS_INTERESTS = 4;
|
||||
private final int RECOMMEND = 5;
|
||||
private List<AnchorRecommendItemModel> list = new ArrayList<>();
|
||||
|
||||
private List<CustomSidebarInfoModel> infoModels = new ArrayList<>();
|
||||
|
||||
@@ -37,6 +39,11 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public CustomDrawerPopupAdapter setList(List<AnchorRecommendItemModel> list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@@ -64,15 +71,20 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
|
||||
if (holder instanceof DrawerRecommendViewHolder) {
|
||||
DrawerRecommendViewHolder recommendViewHolder = (DrawerRecommendViewHolder) holder;
|
||||
recommendViewHolder.setData(infoModels.get(position));
|
||||
}else if (holder instanceof DrawerTaskViewHolder) {
|
||||
} else if (holder instanceof DrawerTaskViewHolder) {
|
||||
DrawerTaskViewHolder taskViewHolder = (DrawerTaskViewHolder) holder;
|
||||
taskViewHolder.setData(infoModels.get(position));
|
||||
}else if (holder instanceof FunGamesViewHolder) {
|
||||
} else if (holder instanceof FunGamesViewHolder) {
|
||||
FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder;
|
||||
funGamesViewHolder.setData(infoModels.get(position));
|
||||
}else if (holder instanceof RigtsInterestsViewHolder) {
|
||||
} else if (holder instanceof RigtsInterestsViewHolder) {
|
||||
RigtsInterestsViewHolder rigtsInterestsViewHolder = (RigtsInterestsViewHolder) holder;
|
||||
rigtsInterestsViewHolder.setData(infoModels.get(position));
|
||||
} else if (holder instanceof RecommendViewHolder) {
|
||||
|
||||
RecommendViewHolder recommendViewHolder = (RecommendViewHolder) holder;
|
||||
recommendViewHolder.setData(infoModels.get(position));
|
||||
recommendViewHolder.updateData(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yunbao.common.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.views.RecommendChildViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecommendAdapter extends RecyclerView.Adapter {
|
||||
private List<AnchorRecommendItemModel> list = new ArrayList<>();
|
||||
private Context mContext;
|
||||
|
||||
public RecommendAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new RecommendChildViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_sidebar_lives_new, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
RecommendChildViewHolder itemViewHolder = (RecommendChildViewHolder) holder;
|
||||
itemViewHolder.setData(list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void updateData(List<AnchorRecommendItemModel> mList) {
|
||||
list.clear();
|
||||
list.addAll(mList);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -687,7 +687,7 @@ public class IMLoginModel extends BaseModel {
|
||||
* @return
|
||||
*/
|
||||
public boolean anchorUserType() {
|
||||
return !TextUtils.equals("C", usersType);
|
||||
return TextUtils.equals("C", usersType);
|
||||
}
|
||||
|
||||
public IMLoginModel setUsersType(String usersType) {
|
||||
|
||||
@@ -9,10 +9,12 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.lxj.xpopup.core.DrawerPopupView;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.CustomDrawerPopupAdapter;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CustomDrawerPopupView extends DrawerPopupView {
|
||||
@@ -20,6 +22,12 @@ public class CustomDrawerPopupView extends DrawerPopupView {
|
||||
|
||||
private RecyclerView drawerList;
|
||||
private CustomDrawerPopupAdapter adapter;
|
||||
private List<AnchorRecommendItemModel> list = new ArrayList<>();
|
||||
|
||||
public CustomDrawerPopupView setList(List<AnchorRecommendItemModel> list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomDrawerPopupView(@NonNull Context context) {
|
||||
super(context);
|
||||
@@ -43,6 +51,7 @@ public class CustomDrawerPopupView extends DrawerPopupView {
|
||||
private void initView() {
|
||||
drawerList = findViewById(R.id.drawerList);
|
||||
adapter = new CustomDrawerPopupAdapter(mContext);
|
||||
adapter.setList(list);
|
||||
drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
drawerList.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
public class RecommendChildViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView cover;
|
||||
private ImageView liveType;
|
||||
private TextView name;
|
||||
|
||||
public RecommendChildViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
cover = itemView.findViewById(R.id.cover);
|
||||
liveType = itemView.findViewById(R.id.live_type);
|
||||
name = itemView.findViewById(R.id.name);
|
||||
}
|
||||
|
||||
public void setData(AnchorRecommendItemModel bean) {
|
||||
Context mContext = itemView.getContext();
|
||||
if (bean.getContentPicSizeTwo() != null && !bean.getContentPicSizeTwo().equals("")) {
|
||||
Picasso.with(mContext)
|
||||
.load(bean.getContentPicSizeTwo())
|
||||
.into(liveType);
|
||||
} else if (bean.getContentPicSizeThree() != null && !bean.getContentPicSizeThree().equals("")) {
|
||||
Picasso.with(mContext)
|
||||
.load(bean.getContentPicSizeThree())
|
||||
.into(liveType);
|
||||
}
|
||||
ImgLoader.display(itemView.getContext(), bean.getThumb(), cover);
|
||||
name.setText(bean.getUserNicename());
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,41 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.RecommendAdapter;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class RecommendViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView sendGoodGift, subtitle;
|
||||
private RecyclerView childList;
|
||||
private RecommendAdapter recommendAdapter;
|
||||
|
||||
public RecommendViewHolder(@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);
|
||||
recommendAdapter = new RecommendAdapter(itemView.getContext());
|
||||
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 3));
|
||||
childList.setAdapter(recommendAdapter);
|
||||
}
|
||||
|
||||
public void setData(CustomSidebarInfoModel model) {
|
||||
sendGoodGift.setText(model.getTitle());
|
||||
subtitle.setText(model.getSubtitle());
|
||||
}
|
||||
|
||||
public void updateData(List<AnchorRecommendItemModel> list) {
|
||||
recommendAdapter.updateData(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.jakewharton.rxbinding3.view.RxView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import kotlin.Unit;
|
||||
|
||||
/**
|
||||
* 直播页面布局
|
||||
*/
|
||||
public class SidebarLiveItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView mCover, liveType;
|
||||
private TextView mName;
|
||||
|
||||
public SidebarLiveItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
//展示普通布局,隐藏周星榜布局
|
||||
|
||||
mCover = itemView.findViewById(R.id.cover);
|
||||
liveType = itemView.findViewById(R.id.live_type);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置页面数据
|
||||
*
|
||||
* @param bean 数据类
|
||||
* @param position 下标
|
||||
*/
|
||||
public void loadViewDate(AnchorRecommendItemModel bean, int position, int height, OnItemClickListener listener) {
|
||||
Context mContext = itemView.getContext();
|
||||
itemView.setTag(position);
|
||||
liveType.setImageDrawable(null);
|
||||
if (bean.getContentPicSizeTwo() != null && !bean.getContentPicSizeTwo().equals("") && height <= 1920) {
|
||||
Picasso.with(mContext)
|
||||
.load(bean.getContentPicSizeTwo())
|
||||
.into(liveType);
|
||||
} else if (bean.getContentPicSizeThree() != null && !bean.getContentPicSizeThree().equals("") && height > 1920) {
|
||||
Picasso.with(mContext)
|
||||
.load(bean.getContentPicSizeThree())
|
||||
.into(liveType);
|
||||
}
|
||||
ImgLoader.display(itemView.getContext(), bean.getThumb(), mCover);
|
||||
|
||||
mName.setText(bean.getUserNicename());
|
||||
|
||||
RxView.clicks(itemView)
|
||||
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
|
||||
.subscribe(new Observer<Unit>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Unit unit) {
|
||||
if (listener != null) {
|
||||
listener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(AnchorRecommendItemModel bean, int position);
|
||||
}
|
||||
|
||||
}
|
||||
46
common/src/main/res/layout/item_sidebar_lives_new.xml
Normal file
46
common/src/main/res/layout/item_sidebar_lives_new.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="94dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:orientation="vertical"
|
||||
app:cardCornerRadius="4dp"
|
||||
app:cardElevation="16dp">
|
||||
|
||||
<FrameLayout
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/live_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
android:gravity="center" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@mipmap/bg_main_item_bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_margin="6dp"
|
||||
android:textColor="#FFF6F7FB"
|
||||
android:textSize="12sp" />
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -1,6 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@drawable/bg_drawer_popup"
|
||||
android:orientation="vertical">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/send_good_gift"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="任務中心"
|
||||
android:textColor="#F6F7FB"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:drawableStart="@mipmap/icon_change"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="查看更多"
|
||||
android:textColor="#A1A7BE"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/child_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="16dp" />
|
||||
</LinearLayout>
|
||||
BIN
common/src/main/res/mipmap-xxhdpi/icon_change.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_change.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user