新贵族喇叭
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.ZhuangBanActivity;
|
||||
|
||||
/**
|
||||
* 开通更高级贵族的提醒弹窗
|
||||
*/
|
||||
public class HighNobilityDialog extends AbsDialogFragment {
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_hight_nobility;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setWindowAttributes(Window window) {
|
||||
window.setWindowAnimations(R.style.bottomToTopAnim);
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = DpUtil.dp2px(340);
|
||||
params.height = DpUtil.dp2px(360);
|
||||
params.gravity = Gravity.CENTER;
|
||||
window.setAttributes(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDialogStyle() {
|
||||
return R.style.dialog2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
findViewById(R.id.back_bt).setOnClickListener(v -> backClick());
|
||||
findViewById(R.id.go_nobility).setOnClickListener(v -> {
|
||||
Constants.isTitle = true;
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
String url = CommonAppConfig.HOST + "/h5/Nobility.html?nickname="
|
||||
+ u.getUserNiceName() + "&usernobId=" + u.getNoble_id() + "&uid="
|
||||
+ CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
ZhuangBanActivity.forward(mContext, url, false);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void backClick() {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -15,16 +20,29 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.custom.MyRadioButton;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/8/21.
|
||||
* 直播间发言框
|
||||
@@ -38,6 +56,16 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
private MyRadioButton mMyRadioButton;
|
||||
private String mHint1;
|
||||
private String mHint2;
|
||||
private RadioGroup radioHornType;
|
||||
private int[] radioList = {R.id.btn_0, R.id.btn_1, R.id.btn_2};
|
||||
private List<RadioButton> radioHornTypes = new ArrayList<>();
|
||||
//发送弹幕类型
|
||||
private SendMessageType messageType = SendMessageType.GENERALMESSAGE;
|
||||
//请求网络
|
||||
private Handler netHandler = new Handler();
|
||||
|
||||
private long nobleId;//贵族等级
|
||||
private long trumpetNum;//喇叭数量
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -67,8 +95,13 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm = (InputMethodManager) mContext.getSystemService(INPUT_METHOD_SERVICE);
|
||||
mInput = (EditText) mRootView.findViewById(R.id.input);
|
||||
radioHornType = mRootView.findViewById(R.id.radio_horn_type);
|
||||
for (int id : radioList) {
|
||||
RadioButton radioButton = mRootView.findViewById(id);
|
||||
radioHornTypes.add(radioButton);
|
||||
}
|
||||
mInput.setFocusable(true);
|
||||
mInput.setFocusableInTouchMode(true);
|
||||
mInput.requestFocus();
|
||||
@@ -132,23 +165,36 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
}
|
||||
}
|
||||
});
|
||||
//单选选中监听
|
||||
radioHornType.setOnCheckedChangeListener(changeListener);
|
||||
radioHornType.getCheckedRadioButtonId();
|
||||
netHandler.post(getNobleTrumpetNumRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sendMessage();
|
||||
}
|
||||
|
||||
//高级贵族
|
||||
private void sendMessage() {
|
||||
String content = mInput.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
if (mCheckBox.isChecked()) {
|
||||
((LiveActivity) mContext).sendDanmuMessage(content);
|
||||
} else {
|
||||
((LiveActivity) mContext).sendChatMessage(content);
|
||||
}
|
||||
mInput.setText("");
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(R.string.cannot_be_empty);
|
||||
return;
|
||||
}
|
||||
switch (messageType) {
|
||||
case WORLDHORN:
|
||||
|
||||
break;
|
||||
case POPUPSCREEN:
|
||||
((LiveActivity) mContext).sendDanmuMessage(content);
|
||||
break;
|
||||
case GENERALMESSAGE:
|
||||
((LiveActivity) mContext).sendChatMessage(content);
|
||||
break;
|
||||
}
|
||||
mInput.setText("");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +209,110 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mContext=null;
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
RadioGroup.OnCheckedChangeListener changeListener = new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
changeCheckState(checkedId);
|
||||
if (checkedId==R.id.btn_2) {
|
||||
if (nobleId<5){
|
||||
imm.hideSoftInputFromWindow(mInput.getWindowToken(), 0);
|
||||
HighNobilityDialog fragment = new HighNobilityDialog();
|
||||
fragment.show(((FragmentActivity)mContext).getSupportFragmentManager(), "HighNobilityDialog");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 更改选中view的样式
|
||||
*
|
||||
* @param checkedId 选中id
|
||||
*/
|
||||
private void changeCheckState(int checkedId) {
|
||||
Drawable generalMessage = getResources().getDrawable(R.mipmap.icon_general_message);
|
||||
Drawable generalMessageP = getResources().getDrawable(R.mipmap.icon_general_message_p);
|
||||
Drawable popupScreen = getResources().getDrawable(R.mipmap.icon_popup_screen);
|
||||
Drawable popupScreenP = getResources().getDrawable(R.mipmap.icon_popup_screen_p);
|
||||
Drawable worldHorn = getResources().getDrawable(R.mipmap.icon_world_horn);
|
||||
Drawable worldHornP = getResources().getDrawable(R.mipmap.icon_world_horn_p);
|
||||
for (RadioButton radioButton : radioHornTypes) {
|
||||
if (radioButton.getId() == checkedId) {
|
||||
radioButton.setTextColor(Color.parseColor("#ffffff"));
|
||||
if (radioButton.getId() == R.id.btn_0) {
|
||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(generalMessageP, null, null, null);
|
||||
mInput.setHint(mHint2);
|
||||
messageType = SendMessageType.GENERALMESSAGE;
|
||||
} else if (radioButton.getId() == R.id.btn_1) {
|
||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(popupScreenP, null, null, null);
|
||||
mInput.setHint(mHint1);
|
||||
messageType = SendMessageType.POPUPSCREEN;
|
||||
} else {
|
||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(worldHornP, null, null, null);
|
||||
mInput.setHint(String.format(WordUtil.getString(R.string.whole_station_horn_hint), trumpetNum));
|
||||
messageType = SendMessageType.WORLDHORN;
|
||||
}
|
||||
} else {
|
||||
radioButton.setTextColor(Color.parseColor("#FFB1B6C7"));
|
||||
if (radioButton.getId() == R.id.btn_0) {
|
||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(generalMessage, null, null, null);
|
||||
} else if (radioButton.getId() == R.id.btn_1) {
|
||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(popupScreen, null, null, null);
|
||||
} else {
|
||||
radioButton.setCompoundDrawablesRelativeWithIntrinsicBounds(worldHorn, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum SendMessageType {
|
||||
GENERALMESSAGE("普通彈幕", 0),
|
||||
POPUPSCREEN("飄屏彈幕", 1),
|
||||
WORLDHORN("全站喇叭", 2);
|
||||
private String name;
|
||||
private int index;
|
||||
|
||||
SendMessageType(String name, int index) {
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
//自写方法获取对应的值,不需要就不用写
|
||||
public String getStr() {
|
||||
return name;
|
||||
}
|
||||
|
||||
//自写方法获取对应的值,不需要就不用写
|
||||
public int getNumber() {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
//获取喇叭数量
|
||||
private Runnable getNobleTrumpetNumRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LiveNetManager.get((Activity) mContext)
|
||||
.getNobleTrumpetNum(new HttpCallback<NobleTrumpetModel>() {
|
||||
@Override
|
||||
public void onSuccess(NobleTrumpetModel data) {
|
||||
nobleId = data.getNobleId();
|
||||
trumpetNum = data.getTrumpetNum();
|
||||
Log.e("LiveInputDialogFragment","贵族等级:"+nobleId);
|
||||
Log.e("LiveInputDialogFragment","喇叭数量:"+trumpetNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -879,4 +879,12 @@ public class LiveHttpUtil {
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户贵族喇叭的数量
|
||||
*/
|
||||
public static void getNobleTrumpetNum( HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Noble.getNobleTrumpetNum", "getNobleTrumpetNum")
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
@@ -23,8 +22,6 @@ import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ms.banner.Banner;
|
||||
@@ -53,6 +50,7 @@ import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveAnchorActivity;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.ZhuangBanActivity;
|
||||
import com.yunbao.live.bean.LiveWishlistBean;
|
||||
import com.yunbao.live.dialog.LiveHDDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveOneDialogFragment;
|
||||
@@ -72,7 +70,6 @@ import com.yunbao.live.views.AbsLiveLinkMicPushViewHolder;
|
||||
import com.yunbao.live.views.CustomViewHolder;
|
||||
import com.yunbao.live.views.LiveLinkMicPlayTxViewHolder;
|
||||
import com.yunbao.live.views.LiveLinkMicPushTxViewHolder;
|
||||
import com.yunbao.live.activity.ZhuangBanActivity;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -132,57 +129,57 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
|
||||
public static String link = "";
|
||||
LinearLayout btn_event2;
|
||||
public static LiveGiftBean bean1 = new LiveGiftBean();
|
||||
String gold,experience;
|
||||
String gold, experience;
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onUpdata(String str) {
|
||||
if ("showBanner".equals(str)) {
|
||||
showBanner3();
|
||||
} else if ("stop_svga_new_user_double".equals(str)) {
|
||||
} else if ("stop_svga_new_user_double".equals(str) && mBannerList3.size() > 3) {
|
||||
mBannerList3.get(2).setLink("1");
|
||||
mBanner3.update(mBannerList3);
|
||||
if(mBannerList3.get(0).getLink().equals("1")){
|
||||
if(mBannerList3.get(1).getLink().equals("1")){
|
||||
if(mBannerList3.get(2).getLink().equals("1")){
|
||||
if (mBannerList3.get(0).getLink().equals("1")) {
|
||||
if (mBannerList3.get(1).getLink().equals("1")) {
|
||||
if (mBannerList3.get(2).getLink().equals("1")) {
|
||||
btnEvent3.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("stop_svga_new_user_follow".equals(str)) {
|
||||
} else if ("stop_svga_new_user_follow".equals(str)&& mBannerList3.size() > 2) {
|
||||
mBannerList3.get(1).setLink("1");
|
||||
mBanner3.update(mBannerList3);
|
||||
if(mBannerList3.get(0).getLink().equals("1")){
|
||||
if(mBannerList3.get(1).getLink().equals("1")){
|
||||
if(mBannerList3.get(2).getLink().equals("1")){
|
||||
if (mBannerList3.get(0).getLink().equals("1")) {
|
||||
if (mBannerList3.get(1).getLink().equals("1")) {
|
||||
if (mBannerList3.get(2).getLink().equals("1")) {
|
||||
btnEvent3.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("stop_new_user_gif".equals(str)) {
|
||||
} else if ("stop_new_user_gif".equals(str)&& mBannerList3.size() > 1) {
|
||||
IMLoginManager.get(mContext).setNewUserGif(false);
|
||||
mBannerList3.get(0).setLink("1");
|
||||
mBanner3.update(mBannerList3);
|
||||
if(mBannerList3.get(0).getLink().equals("1")){
|
||||
if(mBannerList3.get(1).getLink().equals("1")){
|
||||
if(mBannerList3.get(2).getLink().equals("1")){
|
||||
if (mBannerList3.get(0).getLink().equals("1")) {
|
||||
if (mBannerList3.get(1).getLink().equals("1")) {
|
||||
if (mBannerList3.get(2).getLink().equals("1")) {
|
||||
btnEvent3.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if("stop_svga_new_user_double1".equals(str)){
|
||||
} else if ("stop_svga_new_user_double1".equals(str)) {
|
||||
publicToast(mContext);
|
||||
}else if ("stop_svga_new_user_follow1".equals(str)) {
|
||||
} else if ("stop_svga_new_user_follow1".equals(str)) {
|
||||
publicToast(mContext);
|
||||
}else if ("stop_new_user_gif1".equals(str)) {
|
||||
} else if ("stop_new_user_gif1".equals(str)) {
|
||||
publicToast(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
public void publicToast(Context content){
|
||||
public void publicToast(Context content) {
|
||||
// 定义Toast对象
|
||||
Toast toast = new Toast(content);
|
||||
// 1、加载布局
|
||||
View view = LayoutInflater.from(content).inflate(R.layout.diy_toast_view,null);
|
||||
View view = LayoutInflater.from(content).inflate(R.layout.diy_toast_view, null);
|
||||
// 2、获取组件
|
||||
TextView gold_text = view.findViewById(R.id.gold);
|
||||
// 3、设置组件内容
|
||||
@@ -196,7 +193,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
|
||||
// 5-1、Gravity.CENTER | Gravity.TOP是设置toast在中间上方显示
|
||||
// 5-2、300 表示距离左边300dp
|
||||
// 5-3、250 表示距离上方250dp
|
||||
toast.setGravity(Gravity.CENTER ,Gravity.CENTER ,Gravity.CENTER );
|
||||
toast.setGravity(Gravity.CENTER, Gravity.CENTER, Gravity.CENTER);
|
||||
// 6、显示toast
|
||||
toast.show();
|
||||
}
|
||||
@@ -294,7 +291,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
|
||||
mBannerList1.add(bannerBean);
|
||||
|
||||
|
||||
LiveHttpUtil.getFrontTask(IMLoginManager.get(mContext).getUserInfo().getToken(),""+IMLoginManager.get(mContext).getUserInfo().getId(),new HttpCallback() {
|
||||
LiveHttpUtil.getFrontTask(IMLoginManager.get(mContext).getUserInfo().getToken(), "" + IMLoginManager.get(mContext).getUserInfo().getId(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
JSONObject old_obj = JSON.parseObject(info[0]);
|
||||
@@ -347,7 +344,6 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
|
||||
});
|
||||
|
||||
|
||||
|
||||
btn_onecz_event = root.findViewById(R.id.btn_onecz_event);
|
||||
btn_onecz_event.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -950,7 +946,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
|
||||
if (mBannerList3 != null) {
|
||||
if (mBannerList3.get(p).getLink().equals("0")) {
|
||||
if (p == 0) {
|
||||
((LiveAudienceActivity) mContext).openGiftWindow(""+bean1.getId(), "1");
|
||||
((LiveAudienceActivity) mContext).openGiftWindow("" + bean1.getId(), "1");
|
||||
EventBus.getDefault().post("svga_new_user_gif");
|
||||
} else if (p == 1) {
|
||||
EventBus.getDefault().post("svga_new_user_follow");
|
||||
|
||||
Reference in New Issue
Block a user