diff --git a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java index 32fe68918..4b6891105 100644 --- a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java @@ -1,29 +1,99 @@ package com.yunbao.common.adapter; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.yunbao.common.R; +import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.views.DrawerRecommendViewHolder; +import com.yunbao.common.views.DrawerTaskViewHolder; +import com.yunbao.common.views.FunGamesViewHolder; +import com.yunbao.common.views.RecommendViewHolder; +import com.yunbao.common.views.RigtsInterestsViewHolder; + +import java.util.ArrayList; +import java.util.List; + /** * 新侧边栏适配器 */ -public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { +public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { + private Context mContext; + // "type": 1,//模块类型 1 充值送好礼类型2 任务中心类型 3趣味游戏类4 权益 ,5为你推荐 + private final int GOOD_GIFTS = 1; + private final int TASK_CENTER = 2; + private final int FUN_GAMES = 3; + private final int RIGHTS_INTERESTS = 4; + private final int RECOMMEND = 5; + private List infoModels = new ArrayList<>(); + + public CustomDrawerPopupAdapter(Context mContext) { + this.mContext = mContext; + } @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return null; + switch (viewType) { + case GOOD_GIFTS: + View goodGiftsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_good_gifts, parent, false); + return new DrawerRecommendViewHolder(goodGiftsView); + case TASK_CENTER: + View taskCenterView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_tsak_center, parent, false); + return new DrawerTaskViewHolder(taskCenterView); + case FUN_GAMES: + View runGamesView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_fun_games_view, parent, false); + return new FunGamesViewHolder(runGamesView); + case RIGHTS_INTERESTS: + View rightsInterestsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_rights_interests, parent, false); + return new RigtsInterestsViewHolder(rightsInterestsView); + default: + View recommendView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_recommend, parent, false); + return new RecommendViewHolder(recommendView); + } } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - + if (holder instanceof DrawerRecommendViewHolder) { + DrawerRecommendViewHolder recommendViewHolder = (DrawerRecommendViewHolder) holder; + recommendViewHolder.setData(infoModels.get(position)); + } } @Override public int getItemCount() { - return 0; + return infoModels.size(); + } + + @Override + public int getItemViewType(int position) { + CustomSidebarInfoModel model = infoModels.get(position); + switch (model.getType()) { + case "1": + return GOOD_GIFTS; + case "2": + return TASK_CENTER; + case "3": + return FUN_GAMES; + case "4": + return RIGHTS_INTERESTS; + case "5": + return RECOMMEND; + } + return super.getItemViewType(position); + + } + + public void updateData(List mInfoModels) { + infoModels.clear(); + infoModels.addAll(mInfoModels); + notifyDataSetChanged(); } } diff --git a/common/src/main/java/com/yunbao/common/adapter/DrawerRecommendAdapter.java b/common/src/main/java/com/yunbao/common/adapter/DrawerRecommendAdapter.java new file mode 100644 index 000000000..96e64c665 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/DrawerRecommendAdapter.java @@ -0,0 +1,49 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.views.DrawerRecommendChildViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class DrawerRecommendAdapter extends RecyclerView.Adapter { + private Context mContext; + private List child = new ArrayList<>(); + + public DrawerRecommendAdapter(Context mContext) { + this.mContext = mContext; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View goodGiftsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_drawer_recommend_child, parent, false); + return new DrawerRecommendChildViewHolder(goodGiftsView); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + DrawerRecommendChildViewHolder childViewHolder = (DrawerRecommendChildViewHolder) holder; + childViewHolder.setData(child.get(position)); + } + + @Override + public int getItemCount() { + return child.size(); + } + + public void updateData(List mChild) { + child.clear(); + child.addAll(mChild); + notifyDataSetChanged(); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java index 1ddfedce5..0aabefe86 100644 --- a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java +++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java @@ -3,12 +3,15 @@ package com.yunbao.common.views; import android.content.Context; import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; 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.CustomSidebarInfoModel; import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.ToastUtil; import java.util.List; @@ -16,6 +19,7 @@ public class CustomDrawerPopupView extends DrawerPopupView { private Context mContext; private RecyclerView drawerList; + private CustomDrawerPopupAdapter adapter; public CustomDrawerPopupView(@NonNull Context context) { super(context); @@ -38,6 +42,9 @@ public class CustomDrawerPopupView extends DrawerPopupView { private void initView() { drawerList = findViewById(R.id.drawerList); + adapter = new CustomDrawerPopupAdapter(mContext); + drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + drawerList.setAdapter(adapter); } private void initData() { @@ -45,12 +52,12 @@ public class CustomDrawerPopupView extends DrawerPopupView { .getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback>() { @Override public void onSuccess(List data) { - + adapter.updateData(data); } @Override public void onError(String error) { - + ToastUtil.show(error); } }); } diff --git a/common/src/main/java/com/yunbao/common/views/DrawerRecommendChildViewHolder.java b/common/src/main/java/com/yunbao/common/views/DrawerRecommendChildViewHolder.java new file mode 100644 index 000000000..044b6183f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/DrawerRecommendChildViewHolder.java @@ -0,0 +1,31 @@ +package com.yunbao.common.views; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.glide.ImgLoader; + + +public class DrawerRecommendChildViewHolder extends RecyclerView.ViewHolder { + private ImageView icon; + private TextView title, subtitle; + + public DrawerRecommendChildViewHolder(@NonNull View itemView) { + super(itemView); + icon = itemView.findViewById(R.id.icon); + title = itemView.findViewById(R.id.title); + subtitle = itemView.findViewById(R.id.subtitle); + } + + public void setData(CustomSidebarChildModel model) { + ImgLoader.display2(itemView.getContext(), model.getIcon(), icon); + title.setText(model.getTitle()); + subtitle.setText(model.getSubtitle()); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java b/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java index 876bac123..50fb078bf 100644 --- a/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/DrawerRecommendViewHolder.java @@ -1,15 +1,38 @@ 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.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.DrawerRecommendAdapter; +import com.yunbao.common.bean.CustomSidebarInfoModel; + /** * 侧边栏推荐布局 任务 */ public class DrawerRecommendViewHolder extends RecyclerView.ViewHolder { + private TextView sendGoodGift, subtitle; + private RecyclerView childList; + private DrawerRecommendAdapter recommendAdapter; + public DrawerRecommendViewHolder(@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 DrawerRecommendAdapter(itemView.getContext()); + childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 2)); + childList.setAdapter(recommendAdapter); + } + + public void setData(CustomSidebarInfoModel model) { + sendGoodGift.setText(model.getTitle()); + subtitle.setText(model.getSubtitle()); + recommendAdapter.updateData(model.getChild()); } } diff --git a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java new file mode 100644 index 000000000..1ae8f0ad9 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java @@ -0,0 +1,12 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class FunGamesViewHolder extends RecyclerView.ViewHolder { + public FunGamesViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java b/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java new file mode 100644 index 000000000..d91499f51 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/RecommendViewHolder.java @@ -0,0 +1,13 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + + +public class RecommendViewHolder extends RecyclerView.ViewHolder { + public RecommendViewHolder(@NonNull View itemView) { + super(itemView); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/RigtsInterestsViewHolder.java b/common/src/main/java/com/yunbao/common/views/RigtsInterestsViewHolder.java new file mode 100644 index 000000000..9c381da96 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/RigtsInterestsViewHolder.java @@ -0,0 +1,13 @@ +package com.yunbao.common.views; + +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +public class RigtsInterestsViewHolder extends RecyclerView.ViewHolder { + public RigtsInterestsViewHolder(@NonNull View itemView) { + super(itemView); + } +} + diff --git a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java b/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java index 5005387ea..e4cb1333a 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java @@ -19,6 +19,8 @@ import com.lzf.easyfloat.interfaces.OnInvokeView; import com.tencent.live2.V2TXLivePlayer; import com.tencent.live2.V2TXLivePlayerObserver; import com.tencent.live2.impl.V2TXLivePlayerImpl; +import com.tencent.rtmp.ITXLivePlayListener; +import com.tencent.rtmp.TXLivePlayer; import com.tencent.rtmp.ui.TXCloudVideoView; import com.yunbao.common.R; import com.yunbao.common.bean.LiveBean; @@ -50,7 +52,7 @@ public class LiveFloatView implements Function1 { private int mLiveTypeVal; private FloatCallbacks.Builder builder; private String TAG = "LiveFloatView"; - private V2TXLivePlayer mPlayer; + private TXLivePlayer mPlayer; public static LiveFloatView getInstance() { if (instance == null) { @@ -81,29 +83,27 @@ public class LiveFloatView implements Function1 { cardParams.width = DpUtil.dp2px(126); } TXCloudVideoView videoView = magnetView.findViewById(R.id.video_view); - mPlayer = new V2TXLivePlayerImpl(mContext); - mPlayer.setRenderView(videoView); - mPlayer.startPlay(url); - mPlayer.setObserver(new V2TXLivePlayerObserver() { + mPlayer = new TXLivePlayer(mContext); + mPlayer.setPlayerView(videoView); + mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV); + mPlayer.setPlayListener(new ITXLivePlayListener() { @Override - public void onWarning(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { - super.onWarning(player, code, msg, extraInfo); - Log.e(TAG, msg + "==============" + code); + public void onPlayEvent(int event, Bundle param) { + float videoWidth = param.getInt("EVT_PARAM1", 0); + float videoHeight = param.getInt("EVT_PARAM2", 0); } @Override - public void onError(V2TXLivePlayer player, int code, String msg, Bundle extraInfo) { - super.onError(player, code, msg, extraInfo); - Log.e(TAG, msg + "==============" + code); + public void onNetStatus(Bundle bundle) { } }); ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); APPEasyFloat.getInstance().dismiss(mContext); - if (IMLoginManager.get(mContext).isHint2()&& !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) { + if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) { HintDialog fragment = new HintDialog(); Bundle args = new Bundle(); args.putString("close", "1"); @@ -113,7 +113,7 @@ public class LiveFloatView implements Function1 { } }); ViewClicksAntiShake.clicksAntiShake(videoView, () -> { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); APPEasyFloat.getInstance().dismiss(mContext); new Handler().post(liveCheck); @@ -129,7 +129,7 @@ public class LiveFloatView implements Function1 { @Override public void dismiss() { if (mPlayer != null) - mPlayer.stopPlay(); + mPlayer.stopPlay(true); } }) .show(mContext); @@ -168,15 +168,14 @@ public class LiveFloatView implements Function1 { callback.invoke(aBoolean); } builder.dismiss(() -> { - if (mPlayer != null && mPlayer.isPlaying() == 1) { - mPlayer.stopPlay(); + if (mPlayer != null && mPlayer.isPlaying() ) { + mPlayer.stopPlay(true); } return null; }); builder.hide(view12 -> { - if (mPlayer != null && mPlayer.isPlaying() == 1) { - mPlayer.pauseAudio(); - mPlayer.pauseVideo(); + if (mPlayer != null && mPlayer.isPlaying() ) { + mPlayer.pause(); } return null; }); @@ -195,9 +194,9 @@ public class LiveFloatView implements Function1 { public void invoke(View view) { TXCloudVideoView videoView = view.findViewById(R.id.video_view); CardView layout = view.findViewById(R.id.layout); - mPlayer = new V2TXLivePlayerImpl(mContext); - mPlayer.setRenderView(videoView); - mPlayer.startPlay(url); + mPlayer = new TXLivePlayer(mContext); + mPlayer.setPlayerView(videoView); + mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV); RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams(); if (mLiveBean.getLandscape() == 1) { cardParams.height = DpUtil.dp2px(130); @@ -210,7 +209,7 @@ public class LiveFloatView implements Function1 { ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); EasyFloat.dismiss("LiveFloatView", true); if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) { HintDialog fragment = new HintDialog(); @@ -223,7 +222,7 @@ public class LiveFloatView implements Function1 { }); ViewClicksAntiShake.clicksAntiShake(view, () -> { - mPlayer.stopPlay(); + mPlayer.stopPlay(true); new Handler().post(liveCheck); diff --git a/common/src/main/res/drawable/bg_drawer_popup.xml b/common/src/main/res/drawable/bg_drawer_popup.xml new file mode 100644 index 000000000..36be141cd --- /dev/null +++ b/common/src/main/res/drawable/bg_drawer_popup.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/custom_drawer_popup.xml b/common/src/main/res/layout/custom_drawer_popup.xml index aec92c644..1fe7b92b8 100644 --- a/common/src/main/res/layout/custom_drawer_popup.xml +++ b/common/src/main/res/layout/custom_drawer_popup.xml @@ -11,8 +11,7 @@ android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="48dp" - android:layout_weight="1" - android:background="@color/white" /> + android:layout_weight="1" /> + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_fun_games_view.xml b/common/src/main/res/layout/view_fun_games_view.xml new file mode 100644 index 000000000..77d9ef65f --- /dev/null +++ b/common/src/main/res/layout/view_fun_games_view.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_good_gifts.xml b/common/src/main/res/layout/view_good_gifts.xml new file mode 100644 index 000000000..823a83781 --- /dev/null +++ b/common/src/main/res/layout/view_good_gifts.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_recommend.xml b/common/src/main/res/layout/view_recommend.xml new file mode 100644 index 000000000..77d9ef65f --- /dev/null +++ b/common/src/main/res/layout/view_recommend.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_rights_interests.xml b/common/src/main/res/layout/view_rights_interests.xml new file mode 100644 index 000000000..77d9ef65f --- /dev/null +++ b/common/src/main/res/layout/view_rights_interests.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_tsak_center.xml b/common/src/main/res/layout/view_tsak_center.xml new file mode 100644 index 000000000..77d9ef65f --- /dev/null +++ b/common/src/main/res/layout/view_tsak_center.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_more_01.png b/common/src/main/res/mipmap-xxhdpi/icon_more_01.png new file mode 100644 index 000000000..597eb3552 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_more_01.png differ