新贵族喇叭
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ResponseModel<NobleTrumpetModel>> getNobleTrumpetNum();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yunbao.common.http.main;
|
||||
package com.yunbao.common.http.base;
|
||||
|
||||
/**
|
||||
* maim的请求回调接口
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<NobleTrumpetModel> 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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
15
common/src/main/res/drawable/bg_btn_common.xml
Normal file
15
common/src/main/res/drawable/bg_btn_common.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="true">
|
||||
<shape>
|
||||
<corners android:radius="22dp"/>
|
||||
<solid android:color="@color/global"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_enabled="false">
|
||||
<shape>
|
||||
<corners android:radius="22dp"/>
|
||||
<solid android:color="@color/gray3"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
10
common/src/main/res/drawable/bg_btn_common_shape.xml
Normal file
10
common/src/main/res/drawable/bg_btn_common_shape.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item >
|
||||
<shape>
|
||||
<corners android:radius="22dp"/>
|
||||
<solid android:color="@color/gray3"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
BIN
common/src/main/res/mipmap-xxhdpi/icon_general_message.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_general_message.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
common/src/main/res/mipmap-xxhdpi/icon_general_message_p.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_general_message_p.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
common/src/main/res/mipmap-xxhdpi/icon_popup_screen.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_popup_screen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1004 B |
BIN
common/src/main/res/mipmap-xxhdpi/icon_popup_screen_p.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_popup_screen_p.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 921 B |
BIN
common/src/main/res/mipmap-xxhdpi/icon_world_horn.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_world_horn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
common/src/main/res/mipmap-xxhdpi/icon_world_horn_p.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_world_horn_p.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -839,4 +839,10 @@
|
||||
<string name="exclusive_instructor1">Contact your dedicated mentor to We can</string>
|
||||
<string name="exclusive_instructor2">match you with more styles of anchor!</string>
|
||||
<string name="hurry_contact">Contact a mentor now!</string>
|
||||
<string name="withdraw_success">Withdrawal succeeded</string>
|
||||
<string name="normal_barrage">normal barrage</string>
|
||||
<string name="floating_screen">floating screen</string>
|
||||
<string name="whole_station_horn">Whole station horn</string>
|
||||
<string name="quote">quote</string>
|
||||
<string name="whole_station_horn_hint">Available times: %s Note: Update times at 4:00 am on the 1st of each month</string>
|
||||
</resources>
|
||||
|
||||
@@ -854,4 +854,14 @@
|
||||
<string name="exclusive_instructor2">給您匹配更多風格的主播唷!</string>
|
||||
<string name="hurry_contact">趕快聯系他/她吧!</string>
|
||||
<string name="withdraw_success">撤回成功</string>
|
||||
<string name="normal_barrage">普通彈幕</string>
|
||||
<string name="floating_screen">飄屏彈幕</string>
|
||||
<string name="whole_station_horn">全站喇叭</string>
|
||||
<string name="whole_station_horn_hint">可用次數:%s 注:每月1日凌晨4點更新次數</string>
|
||||
<string name="cannot_be_empty">内容不可为空</string>
|
||||
<string name="site_wide_news">貴族專屬全站消息</string>
|
||||
<string name="site_wide_news_hint1">全站顯示消息並可跳轉到當前直播間</string>
|
||||
<string name="site_wide_news_hint2">开通贵族国王、皇帝、超级皇帝免费获得</string>
|
||||
<string name="back">返回</string>
|
||||
<string name="go_nobility">前往贵族</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user