diff --git a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java index f67c931c1..089347d62 100644 --- a/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java +++ b/common/src/main/java/com/yunbao/common/bean/IMLoginModel.java @@ -126,9 +126,12 @@ public class IMLoginModel extends BaseModel { // @SerializedName("medal_name") private String medalName = ""; - // + //贵族id @SerializedName("noble_id") private long nobleId = 0; + //贵族到期时间 + @SerializedName("noble_end_time") + private String nobleEndTime = ""; // @SerializedName("province") private String province = ""; @@ -190,6 +193,7 @@ public class IMLoginModel extends BaseModel { private String medalNoDisplaySrc = ""; @SerializedName("mobile") private String mobile = ""; + //贵族等级 @SerializedName("noble_name") private String nobleName = ""; @SerializedName("users_type") diff --git a/common/src/main/java/com/yunbao/common/bean/NobleTrumpetModel.java b/common/src/main/java/com/yunbao/common/bean/NobleTrumpetModel.java new file mode 100644 index 000000000..05a66ba1e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NobleTrumpetModel.java @@ -0,0 +1,38 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +/** + * 直播全站喇叭数据类 + */ +public class NobleTrumpetModel extends BaseModel { + + + /** + * noble_id : 1 + * trumpet_num : 0 + */ + + @SerializedName("noble_id") + private long nobleId; + @SerializedName("trumpet_num") + private long trumpetNum; + + public long getNobleId() { + return nobleId; + } + + public NobleTrumpetModel setNobleId(long nobleId) { + this.nobleId = nobleId; + return this; + } + + public long getTrumpetNum() { + return trumpetNum; + } + + public NobleTrumpetModel setTrumpetNum(long trumpetNum) { + this.trumpetNum = trumpetNum; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/API.java b/common/src/main/java/com/yunbao/common/http/API.java index 0b602d9bf..7aaff67e3 100644 --- a/common/src/main/java/com/yunbao/common/http/API.java +++ b/common/src/main/java/com/yunbao/common/http/API.java @@ -6,11 +6,17 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.internal.bind.DateTypeAdapter; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.CommonAppContext; import com.yunbao.common.http.base.BaseApi; +import com.yunbao.common.http.base.ParamsContext; +import java.io.IOException; import java.util.Date; +import okhttp3.Interceptor; import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; @@ -43,10 +49,24 @@ public class API extends BaseApi { .create(); OkHttpClient.Builder builder = new OkHttpClient() .newBuilder() - .addInterceptor(new PDLiveInterceptor(context)); + .addInterceptor(initQuery(CommonAppContext.sInstance.getApplicationContext())); pdLiveApi = create(builder.build(), GsonConverterFactory.create(gson), RxJava2CallAdapterFactory.create(), CommonAppConfig.HOST, PDLiveApi.class); } return pdLiveApi; } + + //公共参数 + public Interceptor initQuery(final Context context) { + Interceptor addQueryParameterInterceptor = new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + //配置公共参数 + request = new ParamsContext(request, context).getInRequest(); + return chain.proceed(request); + } + }; + return addQueryParameterInterceptor; + } } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 16984b744..b025091fb 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1,10 +1,12 @@ package com.yunbao.common.http; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.NobleTrumpetModel; import io.reactivex.Observable; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; import retrofit2.http.POST; /** @@ -30,4 +32,12 @@ public interface PDLiveApi { @Field("pushid") String pushid, @Field("lastlogindevice") String lastlogindevice ); + + /** + * 获取用户贵族喇叭的数量 参数 uid token + * + * @return + */ + @GET("/api/public/?service=Noble.getNobleTrumpetNum") + Observable> getNobleTrumpetNum(); } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveInterceptor.java b/common/src/main/java/com/yunbao/common/http/PDLiveInterceptor.java deleted file mode 100644 index 487830a79..000000000 --- a/common/src/main/java/com/yunbao/common/http/PDLiveInterceptor.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.yunbao.common.http; - -import android.content.Context; -import android.util.Log; - -import com.yunbao.common.bean.IMLoginModel; -import com.yunbao.common.manager.IMLoginManager; - -import java.io.IOException; - -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; - -/** - * PDlLive通用拦截器 - */ -public class PDLiveInterceptor implements Interceptor { - private Context context; - - PDLiveInterceptor(Context context) { - this.context = context; - } - - @Override - public Response intercept(Chain chain) throws IOException { - //拼接请求,添加头 - Request request = chain.request(); - Request.Builder builder = request.newBuilder(); - Log.e("TAG", "Request: " + request.toString()); - //已登录则添加全局参数 - if (IMLoginManager.isLogin(context)) { - IMLoginModel model = IMLoginManager.get(context).getUserInfo(); - builder.addHeader("userid", String.valueOf(model.getId())); - builder.addHeader("token", model.getToken()); - } - Response response = chain.proceed(builder.build()); - Log.e("TAG", "Request: " + response.toString()); - return response; - } -} diff --git a/common/src/main/java/com/yunbao/common/http/base/GetRequestParams.java b/common/src/main/java/com/yunbao/common/http/base/GetRequestParams.java new file mode 100644 index 000000000..174392b95 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/http/base/GetRequestParams.java @@ -0,0 +1,28 @@ +package com.yunbao.common.http.base; + +import android.content.Context; + +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.manager.IMLoginManager; + +import okhttp3.HttpUrl; +import okhttp3.Request; + +public class GetRequestParams implements IRequestParam { + @Override + public Request getRequest(Request request, Context context) { + //添加公共参数 + if (IMLoginManager.isLogin(context)) { + IMLoginModel model = IMLoginManager.get(context).getUserInfo(); + HttpUrl modifiedUrl = request.url().newBuilder() + .addQueryParameter("uid", String.valueOf(model.getId())) + .addQueryParameter("token", model.getToken()) + .build(); + return request.newBuilder().url(modifiedUrl).build(); + + } + + return request; + + } +} diff --git a/common/src/main/java/com/yunbao/common/http/main/HttpCallback.java b/common/src/main/java/com/yunbao/common/http/base/HttpCallback.java similarity index 87% rename from common/src/main/java/com/yunbao/common/http/main/HttpCallback.java rename to common/src/main/java/com/yunbao/common/http/base/HttpCallback.java index 26171f1cf..aca443bdd 100644 --- a/common/src/main/java/com/yunbao/common/http/main/HttpCallback.java +++ b/common/src/main/java/com/yunbao/common/http/base/HttpCallback.java @@ -1,4 +1,4 @@ -package com.yunbao.common.http.main; +package com.yunbao.common.http.base; /** * maim的请求回调接口 diff --git a/common/src/main/java/com/yunbao/common/http/base/IRequestParam.java b/common/src/main/java/com/yunbao/common/http/base/IRequestParam.java new file mode 100644 index 000000000..505f4cae2 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/http/base/IRequestParam.java @@ -0,0 +1,9 @@ +package com.yunbao.common.http.base; + +import android.content.Context; + +import okhttp3.Request; + +public interface IRequestParam { + Request getRequest(Request request, Context context); +} diff --git a/common/src/main/java/com/yunbao/common/http/base/ParamsContext.java b/common/src/main/java/com/yunbao/common/http/base/ParamsContext.java new file mode 100644 index 000000000..4bfe01e39 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/http/base/ParamsContext.java @@ -0,0 +1,28 @@ +package com.yunbao.common.http.base; + +import android.content.Context; + +import okhttp3.Request; + +public class ParamsContext { + private IRequestParam iRequestParam; + private Context context; + private Request request; + + public ParamsContext(Request request, Context context) { + this.context = context; + this.request = request; + } + + public Request getInRequest() { + switch (request.method()) { + case "GET": + iRequestParam = new GetRequestParams(); + break; + case "POST": + iRequestParam = new PostRequestParams(); + break; + } + return iRequestParam.getRequest(request, context); + } +} diff --git a/common/src/main/java/com/yunbao/common/http/base/PostRequestParams.java b/common/src/main/java/com/yunbao/common/http/base/PostRequestParams.java new file mode 100644 index 000000000..9e90f6762 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/http/base/PostRequestParams.java @@ -0,0 +1,33 @@ +package com.yunbao.common.http.base; + +import android.content.Context; + +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.manager.IMLoginManager; + +import okhttp3.FormBody; +import okhttp3.Request; + +public class PostRequestParams implements IRequestParam { + @Override + public Request getRequest(Request request, Context context) { + if (request.body() instanceof FormBody) { + FormBody.Builder bodyBuilder = new FormBody.Builder(); + + FormBody formBody = (FormBody) request.body(); + + for (int i = 0; i < formBody.size(); i++) { + bodyBuilder.addEncoded(formBody.encodedName(i), formBody.encodedValue(i)); + } + if (IMLoginManager.isLogin(context)) { + IMLoginModel model = IMLoginManager.get(context).getUserInfo(); + formBody = bodyBuilder.addEncoded("uid", String.valueOf(model.getId())) + .addEncoded("token", model.getToken()) + .build(); + + } + request = request.newBuilder().post(formBody).build(); + } + return request; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java new file mode 100644 index 000000000..7e1a591cc --- /dev/null +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -0,0 +1,52 @@ +package com.yunbao.common.http.live; + +import android.app.Activity; + +import com.yunbao.common.bean.NobleTrumpetModel; +import com.yunbao.common.http.API; +import com.yunbao.common.http.base.HttpCallback; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +/** + * 直播网络请求整合 + */ +public class LiveNetManager { + private Activity mContext; + private static LiveNetManager manager; + + public LiveNetManager(Activity context) { + this.mContext = context; + } + + /** + * 获取单利 + * + * @return + */ + public static LiveNetManager get(Activity context) { + if (null == manager) { + manager = new LiveNetManager(context); + } + return manager; + } + + /** + * 获取用户贵族喇叭的数量 + * + * @param callback 回调 + */ + public void getNobleTrumpetNum(HttpCallback callback) { + API.get().pdLiveApi(mContext).getNobleTrumpetNum() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(nobleTrumpetModelResponseModel -> { + if (callback != null) + callback.onSuccess(nobleTrumpetModelResponseModel.getData().getInfo()); + }, throwable -> { + if (callback != null) + callback.onError(throwable.getMessage()); + }).isDisposed(); + } +} diff --git a/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java b/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java index 8105366e2..b147a12cb 100644 --- a/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java @@ -5,6 +5,7 @@ import android.app.Activity; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.http.API; import com.yunbao.common.http.ResponseModel; +import com.yunbao.common.http.base.HttpCallback; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.functions.Consumer; diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index 41d7cf7cb..3a2570a13 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -214,6 +214,7 @@ public class IMLoginManager extends BaseCacheManager { } else { EventBus.getDefault().post(new DataUserInfoEvent().setUpDataSuccess(false)); } + put(KEY_USER_INFO, new Gson().toJson(userInfo)); } }); } diff --git a/common/src/main/res/drawable/bg_btn_common.xml b/common/src/main/res/drawable/bg_btn_common.xml new file mode 100644 index 000000000..d24a9ba65 --- /dev/null +++ b/common/src/main/res/drawable/bg_btn_common.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_btn_common_shape.xml b/common/src/main/res/drawable/bg_btn_common_shape.xml new file mode 100644 index 000000000..c20bea3e5 --- /dev/null +++ b/common/src/main/res/drawable/bg_btn_common_shape.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_general_message.png b/common/src/main/res/mipmap-xxhdpi/icon_general_message.png new file mode 100644 index 000000000..e524439ff Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_general_message.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_general_message_p.png b/common/src/main/res/mipmap-xxhdpi/icon_general_message_p.png new file mode 100644 index 000000000..cd52d9b56 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_general_message_p.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_popup_screen.png b/common/src/main/res/mipmap-xxhdpi/icon_popup_screen.png new file mode 100644 index 000000000..88b0f381d Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_popup_screen.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_popup_screen_p.png b/common/src/main/res/mipmap-xxhdpi/icon_popup_screen_p.png new file mode 100644 index 000000000..74012ef11 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_popup_screen_p.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_world_horn.png b/common/src/main/res/mipmap-xxhdpi/icon_world_horn.png new file mode 100644 index 000000000..fd1d7c496 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_world_horn.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_world_horn_p.png b/common/src/main/res/mipmap-xxhdpi/icon_world_horn_p.png new file mode 100644 index 000000000..fd548930c Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_world_horn_p.png differ diff --git a/common/src/main/res/values-en/strings.xml b/common/src/main/res/values-en/strings.xml index fa0fc1af5..65f4dd3f0 100644 --- a/common/src/main/res/values-en/strings.xml +++ b/common/src/main/res/values-en/strings.xml @@ -839,4 +839,10 @@ Contact your dedicated mentor to We can match you with more styles of anchor! Contact a mentor now! + Withdrawal succeeded + normal barrage + floating screen + Whole station horn + quote + Available times: %s Note: Update times at 4:00 am on the 1st of each month diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 0607c7048..2fd8f154b 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -854,4 +854,14 @@ 給您匹配更多風格的主播唷! 趕快聯系他/她吧! 撤回成功 + 普通彈幕 + 飄屏彈幕 + 全站喇叭 + 可用次數:%s 注:每月1日凌晨4點更新次數 + 内容不可为空 + 貴族專屬全站消息 + 全站顯示消息並可跳轉到當前直播間 + 开通贵族国王、皇帝、超级皇帝免费获得 + 返回 + 前往贵族 diff --git a/config.gradle b/config.gradle index d190f2cce..e36818899 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式 - serverHost : "https://napi.yaoulive.com", - //測試 -// serverHost : "https://ceshi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", +// 測試 + serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java b/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java new file mode 100644 index 000000000..06fcc3bf9 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/HighNobilityDialog.java @@ -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(); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java index 4fba3b959..b3b575f34 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java @@ -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 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() { + @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); + } + }); + } + }; } diff --git a/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java b/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java index a51f7a3af..ba701c16f 100644 --- a/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java +++ b/live/src/main/java/com/yunbao/live/http/LiveHttpUtil.java @@ -879,4 +879,12 @@ public class LiveHttpUtil { .execute(callback); } + /** + * 获取用户贵族喇叭的数量 + */ + public static void getNobleTrumpetNum( HttpCallback callback) { + HttpClient.getInstance().get("Noble.getNobleTrumpetNum", "getNobleTrumpetNum") + .execute(callback); + } + } diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java index c47a3085b..1ab1813d7 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java @@ -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"); diff --git a/live/src/main/res/drawable/radio_horn_type.xml b/live/src/main/res/drawable/radio_horn_type.xml new file mode 100644 index 000000000..de5773252 --- /dev/null +++ b/live/src/main/res/drawable/radio_horn_type.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_live_chat_input.xml b/live/src/main/res/layout/dialog_live_chat_input.xml index af3acbfc0..44fe83c46 100644 --- a/live/src/main/res/layout/dialog_live_chat_input.xml +++ b/live/src/main/res/layout/dialog_live_chat_input.xml @@ -8,20 +8,74 @@ + + + + + + + + + + - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/mipmap-xxxhdpi/viptip_box.png b/live/src/main/res/mipmap-xxxhdpi/viptip_box.png new file mode 100644 index 000000000..6f2de4c2a Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/viptip_box.png differ diff --git a/main/src/main/res/layout/view_main_me.xml b/main/src/main/res/layout/view_main_me.xml index 33d8cd0ff..80f235b38 100644 --- a/main/src/main/res/layout/view_main_me.xml +++ b/main/src/main/res/layout/view_main_me.xml @@ -471,7 +471,7 @@