diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index b18655118..f315816f4 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -11,6 +11,7 @@ import androidx.annotation.Nullable; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; +import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; import com.yunbao.common.R; @@ -128,7 +129,8 @@ public class ImgLoader { if (!contextIsExist(context)) { return; } - Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(new SimpleTarget() { + Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(new CustomTarget() { + @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { if (callback != null) { @@ -137,12 +139,29 @@ public class ImgLoader { } @Override - public void onLoadFailed(@Nullable Drawable errorDrawable) { + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } + public static void displayFileDrawable(Context context, File file, final DrawableCallback callback) { + if (!contextIsExist(context)) { + return; + } + Glide.with(context).asDrawable().load(file).skipMemoryCache(SKIP_MEMORY_CACHE).into(new CustomTarget() { + + + @Override + public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { if (callback != null) { - callback.onLoadFailed(); + callback.onLoadSuccess(resource); } } + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } }); } diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index 5d519a4b2..0bc787c92 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -35,9 +35,9 @@ import static com.yunbao.common.CommonAppContext.isReady; */ public class RongcloudIMManager { //融云开发者平台注册app唯一识别符 - public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; +// public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; //测试环境 -// public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; + public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; private static final String CLASSNAME = "RongcloudIMManager"; diff --git a/common/src/main/res/values-en/strings.xml b/common/src/main/res/values-en/strings.xml index 79f1b01b1..26d6a41c5 100644 --- a/common/src/main/res/values-en/strings.xml +++ b/common/src/main/res/values-en/strings.xml @@ -264,7 +264,7 @@ Write a title for the live broadcast channel Select live channel - Pay attention to the channel that suits you. During the live broadcast, if the operator finds that the selected channel does not match the live content, he / she will adjust your live channel. + During the live broadcast, if the operator finds that the selected channel does not match the live content, he / she will adjust your live channel. Please set room password Please set the charge amount (the revenue is subject to the end of live broadcast) Please set room password @@ -872,4 +872,5 @@ Limited ride And limited avatar frame You are in the current live room has recommended an anchor to you! has sent you a reward, come and get it! + Pay attention to the channel that suits you. diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index c14cd2757..4ca6950ce 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -214,7 +214,8 @@ 給直播寫個標題吧 頻道 選擇直播頻道 - 注意選擇適合自己的頻道。直播過程中,若運營人員發現選擇的頻道和直播內容不相符的情况,會調整您的直播頻道。 + 注意選擇適合自己的頻道。 + 直播過程中,若運營人員發現選擇的頻道和直播內容不相符的情况,會調整您的直播頻道。 請設定房間密碼 請設定收費金額\n(收益以直播結束顯示為准) 請設定房間密碼 diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java index c87ad778b..19782f23b 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java @@ -479,7 +479,9 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic mLiveRoomViewHolder.setName(u.getUserNiceName()); mLiveRoomViewHolder.setAvatar(u.getAvatar()); mLiveRoomViewHolder.setAnchorLevel(u.getLevelAnchor()); + mLiveRoomViewHolder.setLiveUid(u.getId()); } + mLiveRoomViewHolder.initHourRankList(); mLiveRoomViewHolder.startAnchorLight(); } if (mLiveAnchorViewHolder == null) { diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 8dffc63d6..a00177be3 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -47,6 +47,7 @@ import com.yunbao.live.dialog.LiveBeautyDialogFragment; import com.yunbao.live.dialog.LiveFunctionDialogFragment; import com.yunbao.live.dialog.LiveLinkMicListDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; +import com.yunbao.live.dialog.LiveNewWishListDialogFragment; import com.yunbao.live.dialog.LiveWishListDialogFragment; import com.yunbao.live.event.LinkMicTxMixStreamEvent; import com.yunbao.live.http.LiveHttpConsts; @@ -64,8 +65,8 @@ import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.views.AbsRyLivePushViewHolder; import com.yunbao.live.views.LiveEndViewHolder; import com.yunbao.live.views.LiveMusicViewHolder; +import com.yunbao.live.views.LiveNewReadyRyViewHolder; import com.yunbao.live.views.LivePushRyViewHolder; -import com.yunbao.live.views.LiveReadyRyViewHolder; import com.yunbao.live.views.LiveRoomViewHolder; import com.yunbao.live.views.LiveRyAnchorViewHolder; @@ -117,7 +118,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl private ViewGroup mRoot; private ViewGroup mContainerWrap; public static AbsRyLivePushViewHolder mLivePushViewHolder; - public static LiveReadyRyViewHolder mLiveReadyViewHolder; + public static LiveNewReadyRyViewHolder mLiveReadyViewHolder; public static LiveRyAnchorViewHolder mLiveAnchorViewHolder; private LiveMusicViewHolder mLiveMusicViewHolder; private boolean mStartPreview;//是否开始预览 @@ -172,7 +173,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePushViewHolder, true, mContainer); //添加开播前设置控件 - mLiveReadyViewHolder = new LiveReadyRyViewHolder(mContext, mContainer, mLiveSDK); + mLiveReadyViewHolder = new LiveNewReadyRyViewHolder(mContext, mContainer, mLiveSDK); mLiveReadyViewHolder.addToParent(); mLiveReadyViewHolder.subscribeActivityLifeCycle(); mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer); @@ -429,7 +430,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl * 打开心愿单窗口 */ public void openWishListWindow() { - LiveWishListDialogFragment fragment = new LiveWishListDialogFragment(); + LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment(); if (mContext instanceof LiveRyAnchorActivity) { fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragment"); } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveNewWishListAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveNewWishListAdapter.java new file mode 100644 index 000000000..40a6358bd --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LiveNewWishListAdapter.java @@ -0,0 +1,254 @@ +package com.yunbao.live.adapter; + +import android.app.Dialog; +import android.content.Context; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; +import com.yunbao.live.bean.LiveWishlistBean; + +import java.util.List; + +/** + * 直播 心愿单 + */ + +public class LiveNewWishListAdapter extends RecyclerView.Adapter { + private List mWishList; + private LayoutInflater mInflater; + private View.OnClickListener mOnClickListener; + private OnItemClickListener mOnItemClickListener; + private Context mContext; + + public LiveNewWishListAdapter(Context context, boolean noLink) { + mContext = context; + mInflater = LayoutInflater.from(context); + mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag != null) { + if (mOnItemClickListener != null) { + mOnItemClickListener.onItemClick((LiveWishlistBean) tag, 0); + } + } + } + }; + } + + + public void setData(List list) { + mWishList = list; + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + mOnItemClickListener = onItemClickListener; + } + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(R.layout.item_new_live_wish_list, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh vh, int position) { + vh.setData(mWishList.get(position), position); + } + + @Override + public int getItemCount() { + return mWishList.size(); + } + + class Vh extends RecyclerView.ViewHolder { + + ImageView mIcon; + TextView mName; + TextView mNum; + TextView mIncrease; + TextView mDecrease; + View mRlDelete; + ProgressBar pb_wishlist; + TextView tvProgress; + TextView tvWishIndex; + + public Vh(View itemView) { + super(itemView); + mIcon = (ImageView) itemView.findViewById(R.id.icon); + mName = (TextView) itemView.findViewById(R.id.name); + mNum = (TextView) itemView.findViewById(R.id.tv_num); + mIncrease = (TextView) itemView.findViewById(R.id.tv_increase); + mDecrease = (TextView) itemView.findViewById(R.id.tv_decrease); + mRlDelete = itemView.findViewById(R.id.iv_delete); + pb_wishlist = itemView.findViewById(R.id.pb_wishlist); + tvProgress = itemView.findViewById(R.id.tvProgress); + tvWishIndex = itemView.findViewById(R.id.tvWishIndex); + + itemView.setOnClickListener(mOnClickListener); + } + + void setData(LiveWishlistBean bean, int pos) { + itemView.setTag(bean); + ImgLoader.display(mContext, bean.getWishlist_icon(), mIcon); + mName.setText(bean.getWishlist_name()); + mNum.setText(bean.getWishlist_num()); + int pro = 0; + try { + int num1 = Integer.parseInt(bean.getWishlist_progress()); + int num2 = Integer.parseInt(bean.getWishlist_num()); + pro = num1 * 100 / num2; + //如果进度大于0,则不允许删除该礼物 + if (num1 > 0) { + mRlDelete.setVisibility(View.INVISIBLE); + } else { + mRlDelete.setVisibility(View.VISIBLE); + } + + } catch (Exception e) { + e.printStackTrace(); + } + pb_wishlist.setProgress(pro); + if (bean.getWishlist_num().isEmpty() || bean.getWishlist_progress().isEmpty()) { + tvProgress.setText(""); + } else { + tvProgress.setText(bean.getWishlist_progress() + "/" + bean.getWishlist_num()); + } + if (pro >= 100) { + tvWishIndex.setText("已达成"); + } else { + tvWishIndex.setText("心愿" + getNameByIndex(pos)); + } +// tvWishIndex.setText("心愿"+getNameByIndex(pos+1)); + decreaseClick(bean); + increaseClick(bean); + numTextClick(bean); + mRlDeleteClick(pos); + + } + + private String getNameByIndex(int pos) { + String ret = ""; + String arr[] = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}; + try { + ret = arr[pos]; + } catch (Exception e) { + e.printStackTrace(); + } + return ret; + } + + private void mRlDeleteClick(final int pos) { + mRlDelete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ToastUtil.show("删除" + mWishList.get(pos).getWishlist_name() + "成功"); + mWishList.remove(pos); + notifyDataSetChanged(); + } + }); + } + + private void numTextClick(final LiveWishlistBean bean) { + mNum.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + DialogUitl.showSimpleInputDialog(mContext, + "请输入" + bean.getWishlist_name() + "的数量", + DialogUitl.INPUT_TYPE_NUMBER, 5, + new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + if (TextUtils.isEmpty(content)) { + ToastUtil.show(R.string.live_set_wishlist_num); + } else { + int num; + if (StringUtil.isInt(content)) { + num = Integer.parseInt(content); + if (num <= 0) { + ToastUtil.show("数字必须大于0"); + } else { + mNum.setText(num + ""); + bean.setWishlist_num(num + ""); + } + } + dialog.dismiss(); + } + } + }); + } + }); + } + + private void increaseClick(final LiveWishlistBean bean) { + mIncrease.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + int num = Integer.parseInt(mNum.getText().toString()); + num++; + mNum.setText("x"+num ); + bean.setWishlist_num(num + ""); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + private void decreaseClick(final LiveWishlistBean bean) { + mDecrease.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + int num = Integer.parseInt(mNum.getText().toString()); + if (num > 1) { + num--; + mNum.setText("x"+num ); + bean.setWishlist_num(num + ""); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + } +} + + + + + + + + + + + + + + + + + + + + + + diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveReadyClassAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveReadyClassAdapter.java index 161327a4e..177f2d7f8 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveReadyClassAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveReadyClassAdapter.java @@ -1,12 +1,15 @@ package com.yunbao.live.adapter; import android.content.Context; + import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.RadioButton; import android.widget.TextView; import com.yunbao.common.bean.LiveClassBean; @@ -26,32 +29,27 @@ public class LiveReadyClassAdapter extends RecyclerView.Adapter mList; private LayoutInflater mInflater; - private View.OnClickListener mOnClickListener; private OnItemClickListener mOnItemClickListener; public LiveReadyClassAdapter(Context context, List list) { - mContext=context; + mContext = context; mList = list; mInflater = LayoutInflater.from(context); - mOnClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - Object tag = v.getTag(); - if (tag != null && mOnItemClickListener != null) { - mOnItemClickListener.onItemClick((LiveClassBean) tag, 0); - } - } - }; } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { mOnItemClickListener = onItemClickListener; } + public void setList(List mList) { + this.mList = mList; + notifyDataSetChanged(); + } + @NonNull @Override public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return new Vh(mInflater.inflate(R.layout.item_live_ready_class, parent, false)); + return new Vh(mInflater.inflate(R.layout.item_new_live_ready_class, parent, false)); } @Override @@ -70,23 +68,38 @@ public class LiveReadyClassAdapter extends RecyclerView.Adapter { + Object tag = view.getTag(); + if (tag != null && mOnItemClickListener != null) { + mOnItemClickListener.onItemClick((LiveClassBean) tag, 0); + } + }); } void setData(LiveClassBean bean) { itemView.setTag(bean); - ImgLoader.display(mContext,bean.getThumb(), mThumb); mName.setText(bean.getName()); mDes.setText(bean.getDes()); - mRadioButton.doChecked(bean.isChecked()); + mRadioButton.setChecked(bean.isChecked()); + if (bean.isChecked()) { + itemView.setBackgroundResource(R.drawable.bg_new_live_room_type_select); + } else { + itemView.setBackgroundResource(R.drawable.bg_new_live_room_type_uncheck); + } + try { + ImgLoader.display(mContext, bean.getThumb(), mThumb); + } catch (Exception e) { + e.printStackTrace(); + } + } } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewRoomClassDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewRoomClassDialogFragment.java new file mode 100644 index 000000000..f0798a528 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewRoomClassDialogFragment.java @@ -0,0 +1,107 @@ +package com.yunbao.live.dialog; + +import android.os.Bundle; +import android.view.Gravity; +import android.view.Window; +import android.view.WindowManager; + +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.ConfigBean; +import com.yunbao.common.bean.LiveClassBean; +import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.live.R; +import com.yunbao.live.adapter.LiveReadyClassAdapter; +import com.yunbao.live.bean.LiveRoomTypeBean; + +import java.util.ArrayList; +import java.util.List; + +public class LiveNewRoomClassDialogFragment extends AbsDialogFragment implements OnItemClickListener { + private RecyclerView mRecyclerView; + private LiveReadyClassAdapter adapter; + private List list = new ArrayList<>(); + private CommonCallback mCallback; + + @Override + protected int getLayoutId() { + return R.layout.dialog_new_live_room_class; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog2; + } + + @Override + protected boolean canCancel() { + return true; + } + + public void setCallback(CommonCallback callback) { + mCallback = callback; + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + Bundle bundle = getArguments(); + if (bundle == null) { + return; + } + final int checkedClassId = bundle.getInt(Constants.CLASS_ID, 0); + CommonAppConfig.getInstance().getConfig(new CommonCallback() { + @Override + public void callback(ConfigBean configBean) { + if (configBean != null) { + List list1 = configBean.getLiveClass(); + for (int i = 0; i < list1.size(); i++) { + if (!list1.get(i).getName().equals("New") && !list1.get(i).getName().equals("Hot") && !list1.get(i).getName().equals("熱門") && !list1.get(i).getName().equals("新秀")) { + list.add(list1.get(i)); + } + } + for (int i = 0, size = list.size(); i < size; i++) { + LiveClassBean bean = list.get(i); + if (bean.getId() == checkedClassId) { + bean.setChecked(true); + } else { + bean.setChecked(false); + } + } + adapter = new LiveReadyClassAdapter(mContext, list); + adapter.setOnItemClickListener(LiveNewRoomClassDialogFragment.this); + mRecyclerView.setAdapter(adapter); + } + } + }); + } + + @Override + protected void setWindowAttributes(Window window) { + window.setWindowAnimations(R.style.bottomToTopAnim); + WindowManager.LayoutParams params = window.getAttributes(); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = WindowManager.LayoutParams.WRAP_CONTENT; + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + + @Override + public void onItemClick(LiveClassBean bean, int position) { + System.out.println("bean = " + bean + ", position = " + position); + bean.setChecked(true); + if(mCallback!=null){ + mCallback.callback(bean); + } + dismiss(); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewRoomTypeDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewRoomTypeDialogFragment.java new file mode 100644 index 000000000..be55d20c2 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewRoomTypeDialogFragment.java @@ -0,0 +1,145 @@ +package com.yunbao.live.dialog; + +import android.os.Bundle; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; + +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.ConfigBean; +import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.live.R; +import com.yunbao.live.bean.LiveRoomTypeBean; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 新直播准备间 + */ + +public class LiveNewRoomTypeDialogFragment extends AbsDialogFragment implements OnItemClickListener { + + private CommonCallback mCallback; + private List mList; + private ConstraintLayout pub, pwd; + private ImageView pubBtn, pwdBtn; + + private boolean isSelectPublic = true; + + @Override + protected int getLayoutId() { + return R.layout.dialog_new_live_room_type; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog2; + } + + @Override + protected boolean canCancel() { + return true; + } + + @Override + protected void setWindowAttributes(Window window) { + window.setWindowAnimations(R.style.bottomToTopAnim); + WindowManager.LayoutParams params = window.getAttributes(); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = DpUtil.dp2px(236); + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + pub = mRootView.findViewById(R.id.public_room); + pwd = mRootView.findViewById(R.id.private_room); + View submit = mRootView.findViewById(R.id.submit); + pubBtn = pub.findViewById(R.id.public_select); + pwdBtn = pwd.findViewById(R.id.private_select); + Bundle bundle = getArguments(); + if (bundle == null) { + return; + } + int checkedId = bundle.getInt(Constants.CHECKED_ID, Constants.LIVE_TYPE_NORMAL); + select(checkedId == Constants.LIVE_TYPE_NORMAL); + pub.setOnClickListener(view -> select(true)); + pwd.setOnClickListener(view -> select(false)); + submit.setOnClickListener(view -> { + if (isSelectPublic) { + LiveRoomTypeBean bean = new LiveRoomTypeBean(0, WordUtil.getString(R.string.live_room_public)); + mCallback.callback(bean); + } else { + for (LiveRoomTypeBean bean : mList) { + if (bean.getId() == Constants.LIVE_TYPE_PWD) { + bean.setChecked(true); + mCallback.callback(bean); + break; + } + } + } + dismiss(); + }); + initData(); + } + + private void initData() { + mList = new ArrayList<>(); + ConfigBean configBean = CommonAppConfig.getInstance().getConfig(); + Log.i("tag", configBean.toString()); + String[][] liveType = configBean.getLiveType(); + if (liveType != null) { + Log.i("tag", Arrays.toString(liveType)); + List list = LiveRoomTypeBean.getLiveTypeList(liveType); + mList.addAll(list); + } + } + + private void select(boolean isSelectPublic) { + this.isSelectPublic = isSelectPublic; + if (isSelectPublic) { + pub.setBackgroundResource(R.drawable.bg_new_live_room_type_select); + pwd.setBackgroundResource(R.drawable.bg_new_live_room_type_uncheck); + pubBtn.setImageResource(R.mipmap.icon_selected); + pwdBtn.setImageResource(R.mipmap.icon_uncheck); + } else { + pub.setBackgroundResource(R.drawable.bg_new_live_room_type_uncheck); + pwd.setBackgroundResource(R.drawable.bg_new_live_room_type_select); + pubBtn.setImageResource(R.mipmap.icon_uncheck); + pwdBtn.setImageResource(R.mipmap.icon_selected); + } + + } + + @Override + public void onItemClick(LiveRoomTypeBean bean, int position) { + dismiss(); + if (mCallback != null) { + mCallback.callback(bean); + } + } + + public void setCallback(CommonCallback callback) { + mCallback = callback; + } + + @Override + public void onDestroy() { + mCallback = null; + super.onDestroy(); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java new file mode 100644 index 000000000..38834624e --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java @@ -0,0 +1,248 @@ +package com.yunbao.live.dialog; + +import android.os.Bundle; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.yunbao.common.bean.LiveGiftBean; +import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; +import com.yunbao.live.activity.LiveAnchorActivity; +import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.adapter.LiveNewWishListAdapter; +import com.yunbao.live.adapter.LiveWishListAdapter; +import com.yunbao.live.bean.LiveWishlistBean; +import com.yunbao.live.http.LiveHttpConsts; +import com.yunbao.live.http.LiveHttpUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.List; + +/** + * Created by cxf on 2018/10/19. + * 主播直播开播时 心愿单弹窗 + */ + +public class LiveNewWishListDialogFragment extends AbsDialogFragment implements OnItemClickListener { + + private RecyclerView mRecyclerView; + private ActionListener mActionListener; + private boolean mNoLink; + private View mrlAdd, tvDone; + LiveNewWishListAdapter mAdapter; + List mWishlist; + + @Override + protected int getLayoutId() { + return R.layout.dialog_new_live_wishlist; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog; + } + + @Override + protected boolean canCancel() { + return true; + } + + @Override + protected void setWindowAttributes(Window window) { + + window.setWindowAnimations(R.style.bottomToTopAnim); + WindowManager.LayoutParams params = window.getAttributes(); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = DpUtil.dp2px(580); + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerView); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + mrlAdd = findViewById(R.id.rl_add); + tvDone = findViewById(R.id.tvDone); + mrlAddClick(); + tvDoneClick(); + + loadData(); + EventBus.getDefault().register(this); + } + + private void tvDoneClick() { + tvDone.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + modifyWishlist(); + } + }); + + } + + //修改心愿单列表 + private void modifyWishlist() { + if (mWishlist != null && mWishlist.size() > 0) { + Gson gson = new Gson(); + int size = mWishlist.size(); + String params; + if (size > 0) { + Log.i("tos", gson.toJson(mWishlist)); + params = gson.toJson(mWishlist); + } else { + params = ""; + } + LiveHttpUtil.modifyWishList(params, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + ToastUtil.show("修改成功"); + dismiss(); + } else { + ToastUtil.show("修改失败" + (msg.isEmpty() ? "" : msg)); + } + } + + @Override + public void onFinish() { + } + }); + } + + + } + + + //获取心愿单列表 + private void loadData() { + LiveHttpUtil.getWishList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + try { + JSONObject obj = JSON.parseObject(info[0]); + String giftJson = obj.getString("wishlist"); + mWishlist = JSON.parseArray(giftJson, LiveWishlistBean.class); + mAdapter = new LiveNewWishListAdapter(mContext, mNoLink); + mAdapter.setData(mWishlist); + mRecyclerView.setAdapter(mAdapter); + mAdapter.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(LiveWishlistBean bean, int position) { + + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public void onFinish() { + } + }); + } + + //点击 + 号,弹出礼物列表 + private void mrlAddClick() { + mrlAdd.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openGiftWindow(); + } + }); + } + + + + /** + * 心愿单打开礼物窗口 + */ + public void openGiftWindow() { + LiveGiftDialogFragment4Wishlist fragment = new LiveGiftDialogFragment4Wishlist(); + Log.e("ry",getTag()); + if(getTag().equals("TX")) { + fragment.show(((LiveAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); + }else{ + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment"); + } + } + + @Override + public void onItemClick(LiveWishlistBean bean, int position) { + } + + public interface ActionListener { + void onItemClick(String type); + } + + public void setActionListener(ActionListener actionListener) { + mActionListener = actionListener; + } + + public void setNoLink(boolean noLink) { + mNoLink = noLink; + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onChooseGift(LiveGiftBean bean) { + //选择礼物回调 + if (bean != null) { + LiveWishlistBean wishlistBean = new LiveWishlistBean(); + wishlistBean.setWishlist_num(bean.getNum()); + wishlistBean.setWishlist_name(bean.getName()); + wishlistBean.setWishlist_icon(bean.getIcon()); + wishlistBean.setLid(bean.getId() + ""); + wishlistBean.setWishlist_progress("0"); + boolean isSame = false; + int size = mWishlist.size(); + for (int i = 0; i < size; i++) { + if ((mWishlist.get(i).getLid()).equals("" + bean.getId())) { + ToastUtil.show(bean.getName() + "礼物重复"); + isSame = true; + break; + } + } + if (size < 10) { + if (!isSame) { + mWishlist.add(0, wishlistBean); + mAdapter.notifyDataSetChanged(); + } + } else { + ToastUtil.show("最多添加10个心愿"); + } + + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + mActionListener = null; + mContext = null; + LiveHttpUtil.cancel(LiveHttpConsts.GET_WISH_LIST); + LiveHttpUtil.cancel(LiveHttpConsts.SET_WISH_LIST); + EventBus.getDefault().unregister(this); + } +} diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java new file mode 100644 index 000000000..100b9fbbe --- /dev/null +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -0,0 +1,528 @@ +package com.yunbao.live.views; + +import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.tencent.imsdk.v2.V2TIMManager; +import com.tencent.imsdk.v2.V2TIMSendCallback; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.LiveClassBean; +import com.yunbao.common.bean.UserBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.ActivityResultCallback; +import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.interfaces.ImageResultCallback; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.L; +import com.yunbao.common.utils.ProcessImageUtil; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.AbsViewHolder; +import com.yunbao.live.R; +import com.yunbao.live.activity.LiveActivity; +import com.yunbao.live.activity.LiveAnchorActivity; +import com.yunbao.live.activity.LiveChooseClassActivity; +import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.adapter.LiveReadyShareAdapter; +import com.yunbao.live.bean.LiveRoomTypeBean; +import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment; +import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment; +import com.yunbao.live.dialog.LiveNewWishListDialogFragment; +import com.yunbao.live.dialog.LiveRoomTypeDialogFragment; +import com.yunbao.live.dialog.LiveTimeDialogFragment; +import com.yunbao.live.dialog.LiveWishListDialogFragment; +import com.yunbao.live.http.LiveHttpConsts; +import com.yunbao.live.http.LiveHttpUtil; + +import java.io.File; + +import cn.rongcloud.rtc.api.RCRTCEngine; +import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream; + +public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener { + + private ConstraintLayout mAvatar; + private TextView mCoverText; + private EditText mEditTitle; + private ProcessImageUtil mImageUtil; + private File mAvatarFile; + private TextView mLiveClass; + private TextView mLiveTypeTextView;//房间类型TextView + private TextView mLiveWishListTextView;//心愿单TextView + private int mLiveClassID;//直播频道id + private int mLiveType;//房间类型 + private int mLiveTypeVal;//房间密码,门票收费金额 + private int mLiveTimeCoin;//计时收费金额 + private ActivityResultCallback mActivityResultCallback; + private CommonCallback mLiveTypeCallback; + private boolean mOpenLocation = true; + private int mLiveSdk; + private LiveClassBean classBean; + + public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) { + super(context, parentView, liveSdk); + } + + @Override + protected void processArguments(Object... args) { + if (args.length > 0) { + mLiveSdk = (int) args[0]; + } + } + + @Override + protected int getLayoutId() { + return R.layout.view_new_live_ready; + } + + @Override + public void init() { + ConstraintLayout traceroute_rootview = (ConstraintLayout)findViewById(R.id.traceroute_rootview); + traceroute_rootview.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + InputMethodManager imm = (InputMethodManager) + mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + }); + mAvatar = (ConstraintLayout) findViewById(R.id.avatar); + mAvatar.setOnClickListener(this); + UserBean u = CommonAppConfig.getInstance().getUserBean(); + ImgLoader.displayDrawable(mContext, u.getAvatar(), new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + mAvatar.setBackground(drawable); + } + + @Override + public void onLoadFailed() { + + } + }); + mCoverText = (TextView) findViewById(R.id.cover_text); + mEditTitle = (EditText) findViewById(R.id.edit_title); + findViewById(R.id.btn_room_type).setOnClickListener(this); + mOpenLocation = true; + mLiveClass = (TextView) findViewById(R.id.live_class); + mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type); + mLiveWishListTextView= (TextView) findViewById(R.id.text_wishlist); + mImageUtil = ((LiveActivity) mContext).getProcessImageUtil(); + mImageUtil.setImageResultCallback(new ImageResultCallback() { + + @Override + public void beforeCamera() { + ((LiveRyAnchorActivity) mContext).beforeCamera(); + } + + @Override + public void onSuccess(File file) { + if (file != null) { + ImgLoader.displayFileDrawable(mContext, file, new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + mAvatar.setBackground(drawable); + } + + @Override + public void onLoadFailed() { + + } + }); + if (mAvatarFile == null) { + mCoverText.setText(WordUtil.getString(R.string.live_cover_2)); + mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover)); + } + mAvatarFile = file; + } + } + + @Override + public void onFailure() { + } + }); + findViewById(R.id.btn_camera).setOnClickListener(this); + findViewById(R.id.btn_live_class).setOnClickListener(this); + findViewById(R.id.btn_close).setOnClickListener(this); + findViewById(R.id.btn_beauty).setOnClickListener(this); + findViewById(R.id.btn_start_live).setOnClickListener(this); + findViewById(R.id.btn_wishlist).setOnClickListener(this); + findViewById(R.id.btn_horizontally).setOnClickListener(this); + mActivityResultCallback = new ActivityResultCallback() { + @Override + public void onSuccess(Intent intent) { + mLiveClassID = intent.getIntExtra(Constants.CLASS_ID, 0); + mLiveClass.setText(intent.getStringExtra(Constants.CLASS_NAME)); + } + }; + mLiveTypeCallback = new CommonCallback() { + @Override + public void callback(LiveRoomTypeBean bean) { + switch (bean.getId()) { + case Constants.LIVE_TYPE_NORMAL: + onLiveTypeNormal(bean); + break; + case Constants.LIVE_TYPE_PWD: + onLiveTypePwd(bean); + break; + case Constants.LIVE_TYPE_PAY: + onLiveTypePay(bean); + break; + case Constants.LIVE_TYPE_TIME: + onLiveTypeTime(bean); + break; + } + } + }; + + } + + @Override + public void onClick(View v) { + if (!canClick()) { + return; + } + int i = v.getId(); + if (i == R.id.avatar) { + setAvatar(); + + } else if (i == R.id.btn_camera) { + toggleCamera(); + } else if (i == R.id.btn_close) { + close(); + } else if (i == R.id.btn_live_class) { + chooseLiveClass(); + } else if (i == R.id.btn_beauty) { + beauty(); + }else if (i == R.id.btn_wishlist) { + //点击心愿单 + openWishListWindow(); + } else if (i == R.id.btn_room_type) { + chooseLiveType(); + } else if (i == R.id.btn_start_live) { + startLive(); + + } else if (i == R.id.btn_locaiton) { + switchLocation(); + }else if(i == R.id.btn_horizontally){ + RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream(); + cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror()); + } + } + + + /** + * 打开心愿单窗口 + */ + public void openWishListWindow() { + LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment(); + + if (mContext instanceof LiveRyAnchorActivity){ + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY"); + } + } + + /** + * 打开 关闭位置 + */ + private void switchLocation() { + if (mOpenLocation) { + new DialogUitl.Builder(mContext) + .setContent(WordUtil.getString(R.string.live_location_close_3)) + .setCancelable(true) + .setConfrimString(WordUtil.getString(R.string.live_location_close_2)) + .setClickCallback(new DialogUitl.SimpleCallback() { + + @Override + public void onConfirmClick(Dialog dialog, String content) { + toggleLocation(); + } + }) + .build() + .show(); + } else { + toggleLocation(); + } + } + + private void toggleLocation() { + mOpenLocation = !mOpenLocation; + } + + /** + * 设置头像 + */ + private void setAvatar() { + if (mLiveSdk == Constants.LIVE_SDK_TX) { + mImageUtil.getImageByAlumb(); + } else { + DialogUitl.showStringArrayDialog(mContext, new Integer[]{ + R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() { + @Override + public void onItemClick(String text, int tag) { + if (tag == R.string.camera) { + mImageUtil.getImageByCamera(); + } else { + mImageUtil.getImageByAlumb(); + } + } + }); + } + } + + /** + * 切换镜头 + */ + private void toggleCamera() { + ((LiveRyAnchorActivity) mContext).toggleCamera(); + } + + /** + * 关闭 + */ + private void close() { + ((LiveRyAnchorActivity) mContext).endLives(); + } + + /** + * 选择直播频道 + */ + private void chooseLiveClass() { + /* try { + Intent intent = new Intent(mContext, LiveChooseClassActivity.class); + intent.putExtra(Constants.CLASS_ID, mLiveClassID); + mImageUtil.startActivityForResult(intent, mActivityResultCallback); + }catch (Exception e){ + + }*/ + + Bundle bundle = new Bundle(); + bundle.putInt(Constants.CLASS_ID, mLiveClassID); + LiveNewRoomClassDialogFragment fragment = new LiveNewRoomClassDialogFragment(); + fragment.setArguments(bundle);; + fragment.setCallback(new CommonCallback() { + @Override + public void callback(LiveClassBean bean) { + classBean=bean; + mLiveClassID=classBean.getId(); + mLiveClass.setText(bean.getName()); + } + }); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment"); + + } + + /** + * 设置美颜 + */ + private void beauty() { + ((LiveRyAnchorActivity) mContext).beauty(); +// Intent intent = new Intent(mContext, Beauty360Activity3.class); +// mContext.startActivity(intent); + + } + + /** + * 选择直播类型 + */ + private void chooseLiveType() { + Bundle bundle = new Bundle(); + bundle.putInt(Constants.CHECKED_ID, mLiveType); + LiveNewRoomTypeDialogFragment fragment = new LiveNewRoomTypeDialogFragment(); + fragment.setArguments(bundle); + fragment.setCallback(mLiveTypeCallback); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment"); + } + + /** + * 普通房间 + */ + private void onLiveTypeNormal(LiveRoomTypeBean bean) { + mLiveType = bean.getId(); + mLiveTypeTextView.setText(bean.getName()); + mLiveTypeVal = 0; + mLiveTimeCoin = 0; + } + + /** + * 密码房间 + */ + private void onLiveTypePwd(final LiveRoomTypeBean bean) { + DialogUitl.showSimpleInputDialog(mContext, WordUtil.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + if (TextUtils.isEmpty(content)) { + ToastUtil.show(R.string.live_set_pwd_empty); + } else { + mLiveType = bean.getId(); + mLiveTypeTextView.setText(bean.getName()); + if (StringUtil.isInt(content)) { + mLiveTypeVal = Integer.parseInt(content); + } + mLiveTimeCoin = 0; + dialog.dismiss(); + } + } + }); + } + + /** + * 付费房间 + */ + private void onLiveTypePay(final LiveRoomTypeBean bean) { + DialogUitl.showSimpleInputDialog(mContext, WordUtil.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + if (TextUtils.isEmpty(content)) { + ToastUtil.show(R.string.live_set_fee_empty); + } else { + mLiveType = bean.getId(); + mLiveTypeTextView.setText(bean.getName()); + if (StringUtil.isInt(content)) { + mLiveTypeVal = Integer.parseInt(content); + } + mLiveTimeCoin = 0; + dialog.dismiss(); + } + } + }); + } + + /** + * 计时房间 + */ + private void onLiveTypeTime(final LiveRoomTypeBean bean) { + LiveTimeDialogFragment fragment = new LiveTimeDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin); + fragment.setArguments(bundle); + fragment.setCommonCallback(new CommonCallback() { + @Override + public void callback(Integer coin) { + mLiveType = bean.getId(); + mLiveTypeTextView.setText(bean.getName()); + mLiveTypeVal = coin; + mLiveTimeCoin = coin; + } + }); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment"); + } + + public void hide() { + if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) { + mContentView.setVisibility(View.INVISIBLE); + } + } + + + public void show() { + if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) { + mContentView.setVisibility(View.VISIBLE); + } + } + + /** + * 点击开始直播按钮 + */ + private void startLive() { + boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview(); +// if (!startPreview) { +// ToastUtil.show(R.string.please_wait); +// return; +// } + if (mLiveClassID == 0) { + ToastUtil.show(R.string.live_choose_live_class); + return; + } + createRoom(); + } + + /** + * 请求创建直播间接口,开始直播 + */ + boolean isHttpBack = false; + private void createRoom() { + if(!isHttpBack) { + isHttpBack = true; + if (mLiveClassID == 0) { + ToastUtil.show(R.string.live_choose_live_class); + return; + } + String title = mEditTitle.getText().toString().trim(); + LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, final String[] info) { + if (code == 0 && info.length > 0) { + L.e("开播", "createRoom------->" + info[0]); + isHttpBack = false; + final CommonAppConfig appConfig = CommonAppConfig.getInstance(); + UserBean u = appConfig.getUserBean(); + V2TIMManager.getInstance().createGroup(V2TIMManager.GROUP_TYPE_AVCHATROOM, "g" + appConfig.getUid(), "直播", new V2TIMSendCallback() { + @Override + public void onProgress(int progress) { + + } + + @Override + public void onSuccess(String s) { + Log.i("tx", "创建成功"); + ((LiveAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal); + } + + @Override + public void onError(int code, String desc) { + Log.i("tx", code + "创建失败" + desc); + if (code == 10025) { + ((LiveAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal); + } else { + ToastUtil.show("开播失败,联系客服。"); + } + } + }); + } else { + ToastUtil.show(msg); + } + } + + @Override + public void onError() { + super.onError(); + isHttpBack = false; + } + }); + }else { + ToastUtil.show("請求中,請勿重複點擊"); + } + } + + public void release() { + mImageUtil = null; + mActivityResultCallback = null; + mLiveTypeCallback = null; + } + + @Override + public void onDestroy() { + LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM); + } +} diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java index 432579368..1918953a4 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java @@ -17,6 +17,7 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; +import com.lzy.okgo.model.Response; import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSendCallback; import com.tencent.trtc.TRTCCloudDef; @@ -25,6 +26,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.JsonBean; import com.yunbao.common.interfaces.ActivityResultCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.ImageResultCallback; @@ -493,7 +495,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi @Override public void onSuccess(int code, String msg, final String[] info) { if (code == 0 && info.length > 0) { - L.e("开播", "createRoom------->" + info[0]); + L.e("tx开播", "createRoom------->" + info[0]); final CommonAppConfig appConfig = CommonAppConfig.getInstance(); UserBean u = appConfig.getUserBean(); V2TIMManager.getInstance().createGroup(V2TIMManager.GROUP_TYPE_AVCHATROOM, "g" + appConfig.getUid(), "直播", new V2TIMSendCallback() { @@ -523,6 +525,18 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi ToastUtil.show(msg); } } + + @Override + public void onError() { + super.onError(); + System.out.println("tx 开播失败"); + } + + @Override + public void onError(Response response) { + super.onError(response); + System.out.println("tx 开播失败 = "+response); + } }); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index b4f57a372..d6edc9c61 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -936,9 +936,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis // fastMsgRecyclerView.setItemAnimator(new DefaultItemAnimator()); //主播页面隐藏头部 if (mContext instanceof LiveRyAnchorActivity) { - findViewById(R.id.hour_rank_layout).setVisibility(View.GONE); - findViewById(R.id.live_wks_layout).setVisibility(View.GONE); - findViewById(R.id.wish_list_layout).setVisibility(View.GONE); + // findViewById(R.id.hour_rank_layout).setVisibility(View.GONE); + // findViewById(R.id.live_wks_layout).setVisibility(View.GONE); + // findViewById(R.id.wish_list_layout).setVisibility(View.GONE); + // findViewById(R.id.hour_rank_layout).setEnabled(false); + /* findViewById(R.id.live_wks_layout).setEnabled(false); + findViewById(R.id.wish_list_layout).setEnabled(false);*/ findViewById(R.id.open_sidebar).setVisibility(View.GONE); findViewById(R.id.btn_follow).setVisibility(View.GONE); } @@ -1158,7 +1161,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis /** * 初始化小时榜 */ - protected void initHourRankList() { + public void initHourRankList() { ViewFlipper flipper = (ViewFlipper) findViewById(R.id.hour_rank_list); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(44), DpUtil.dp2px(16)); LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/live/src/main/res/drawable/bg_line.xml b/live/src/main/res/drawable/bg_line.xml new file mode 100644 index 000000000..931d7968e --- /dev/null +++ b/live/src/main/res/drawable/bg_line.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_ready_btn.xml b/live/src/main/res/drawable/bg_live_ready_btn.xml new file mode 100644 index 000000000..265144d24 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_ready_btn.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_room_class_radio_btn.xml b/live/src/main/res/drawable/bg_live_room_class_radio_btn.xml new file mode 100644 index 000000000..3ac6c7028 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_room_class_radio_btn.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_upload_cover.xml b/live/src/main/res/drawable/bg_live_upload_cover.xml new file mode 100644 index 000000000..e612dc685 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_upload_cover.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_new_live_room_type_select.xml b/live/src/main/res/drawable/bg_new_live_room_type_select.xml new file mode 100644 index 000000000..a1ab9b9b3 --- /dev/null +++ b/live/src/main/res/drawable/bg_new_live_room_type_select.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_new_live_room_type_uncheck.xml b/live/src/main/res/drawable/bg_new_live_room_type_uncheck.xml new file mode 100644 index 000000000..c31b2c2f4 --- /dev/null +++ b/live/src/main/res/drawable/bg_new_live_room_type_uncheck.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_xyd.png b/live/src/main/res/drawable/bg_xyd.png new file mode 100644 index 000000000..62f8aef9c Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd.png differ diff --git a/live/src/main/res/drawable/bg_xyd_add_item.png b/live/src/main/res/drawable/bg_xyd_add_item.png new file mode 100644 index 000000000..d1573cd21 Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd_add_item.png differ diff --git a/live/src/main/res/drawable/bg_xyd_button.png b/live/src/main/res/drawable/bg_xyd_button.png new file mode 100644 index 000000000..c33a847a7 Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd_button.png differ diff --git a/live/src/main/res/drawable/bg_xyd_empty.png b/live/src/main/res/drawable/bg_xyd_empty.png new file mode 100644 index 000000000..79af1482b Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd_empty.png differ diff --git a/live/src/main/res/drawable/bg_xyd_item.png b/live/src/main/res/drawable/bg_xyd_item.png new file mode 100644 index 000000000..23ecf4197 Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd_item.png differ diff --git a/live/src/main/res/drawable/bg_xyd_item_icon.png b/live/src/main/res/drawable/bg_xyd_item_icon.png new file mode 100644 index 000000000..449e36cbe Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd_item_icon.png differ diff --git a/live/src/main/res/drawable/bg_xyd_number.png b/live/src/main/res/drawable/bg_xyd_number.png new file mode 100644 index 000000000..af85a466d Binary files /dev/null and b/live/src/main/res/drawable/bg_xyd_number.png differ diff --git a/live/src/main/res/drawable/border_grey1.xml b/live/src/main/res/drawable/border_grey1.xml index b531830b6..702d688c7 100644 --- a/live/src/main/res/drawable/border_grey1.xml +++ b/live/src/main/res/drawable/border_grey1.xml @@ -1,9 +1,9 @@ - + - - + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_new_live_room_class.xml b/live/src/main/res/layout/dialog_new_live_room_class.xml new file mode 100644 index 000000000..9291aff61 --- /dev/null +++ b/live/src/main/res/layout/dialog_new_live_room_class.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + diff --git a/live/src/main/res/layout/dialog_new_live_room_type.xml b/live/src/main/res/layout/dialog_new_live_room_type.xml new file mode 100644 index 000000000..bc30f34c1 --- /dev/null +++ b/live/src/main/res/layout/dialog_new_live_room_type.xml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/live/src/main/res/layout/dialog_new_live_wishlist.xml b/live/src/main/res/layout/dialog_new_live_wishlist.xml new file mode 100644 index 000000000..f7fb67022 --- /dev/null +++ b/live/src/main/res/layout/dialog_new_live_wishlist.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_new_live_ready_class.xml b/live/src/main/res/layout/item_new_live_ready_class.xml new file mode 100644 index 000000000..61c1db27b --- /dev/null +++ b/live/src/main/res/layout/item_new_live_ready_class.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_new_live_wish_list.xml b/live/src/main/res/layout/item_new_live_wish_list.xml new file mode 100644 index 000000000..3b27c3148 --- /dev/null +++ b/live/src/main/res/layout/item_new_live_wish_list.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_live_ready.xml b/live/src/main/res/layout/view_live_ready.xml index 5eff372fe..20e7118f0 100644 --- a/live/src/main/res/layout/view_live_ready.xml +++ b/live/src/main/res/layout/view_live_ready.xml @@ -91,15 +91,14 @@ android:id="@+id/live_class" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_centerInParent="true" android:layout_gravity="center_vertical" + android:clickable="false" android:gravity="center_vertical" android:includeFontPadding="false" android:text="@string/live_class" - android:clickable="false" android:textColor="#B6B6B6" - android:layout_centerHorizontal="true" - android:layout_centerVertical="true" - android:textSize="12sp"/> + android:textSize="12sp" /> + android:textColor="#B6B6B6" + android:textSize="12sp" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +