侧边栏:充值送好礼

This commit is contained in:
18401019693 2022-11-09 14:02:39 +08:00
parent 24f691d4b8
commit 5e55a5b94c
18 changed files with 388 additions and 33 deletions

View File

@ -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 {
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<CustomSidebarInfoModel> 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<CustomSidebarInfoModel> mInfoModels) {
infoModels.clear();
infoModels.addAll(mInfoModels);
notifyDataSetChanged();
}
}

View File

@ -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<CustomSidebarChildModel> 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<CustomSidebarChildModel> mChild) {
child.clear();
child.addAll(mChild);
notifyDataSetChanged();
}
}

View File

@ -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<List<CustomSidebarInfoModel>>() {
@Override
public void onSuccess(List<CustomSidebarInfoModel> data) {
adapter.updateData(data);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<FloatCallbacks.Builder, Unit> {
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,27 +83,25 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
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()) {
HintDialog fragment = new HintDialog();
@ -113,7 +113,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
}
});
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<FloatCallbacks.Builder, Unit> {
@Override
public void dismiss() {
if (mPlayer != null)
mPlayer.stopPlay();
mPlayer.stopPlay(true);
}
})
.show(mContext);
@ -168,15 +168,14 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
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<FloatCallbacks.Builder, Unit> {
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<FloatCallbacks.Builder, Unit> {
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<FloatCallbacks.Builder, Unit> {
});
ViewClicksAntiShake.clicksAntiShake(view, () -> {
mPlayer.stopPlay();
mPlayer.stopPlay(true);
new Handler().post(liveCheck);

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <item android:state_enabled="true">-->
<!-- <shape>-->
<!-- <corners android:radius="7dp"/>-->
<!-- <solid android:color="#20ffffff"/>-->
<!-- </shape>-->
<!-- </item>-->
<!-- <item android:state_enabled="false">-->
<!-- <shape>-->
<!-- <corners android:radius="7dp"/>-->
<!-- <solid android:color="#20000000"/>-->
<!-- </shape>-->
<!-- </item>-->
<item android:state_enabled="true">
<shape>
<corners android:radius="7dp" />
<solid android:color="#7000" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:radius="7dp" />
<solid android:color="#7000" />
</shape>
</item>
</selector>

View File

@ -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" />
<HorizontalScrollView

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginStart="6dp"
android:background="@drawable/bg_drawer_popup">
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginStart="6dp"
android:scaleType="fitCenter"
android:src="@mipmap/icon_start_number" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="15dp"
android:layout_toEndOf="@+id/icon"
android:text="首充特惠大禮包"
android:textColor="#F6F7FB"
android:textSize="12sp" />
<TextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_toEndOf="@+id/icon"
android:text="首充特惠大禮包"
android:textColor="#9A9A9A"
android:textSize="10sp" />
</RelativeLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="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">
<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:drawableEnd="@mipmap/icon_more_01"
android:drawablePadding="3dp"
android:text="去充值"
android:textColor="#FBFF72"
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_marginTop="8dp"
android:layout_marginBottom="16dp"
android:paddingStart="4dp"
android:paddingEnd="10dp" />
</LinearLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B