[Modify]修復公會數據和trtc的bug
This commit is contained in:
@@ -63,6 +63,7 @@ import com.yizhuan.xchat_android_core.gift.GiftModel;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.OpenSignInAttachment;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.interceptor.MyOkHttpRetryInterceptor;
|
||||
import com.yizhuan.xchat_android_core.interceptor.NoParamsInterceptor;
|
||||
import com.yizhuan.xchat_android_core.interceptor.ParamsInterceptor;
|
||||
import com.yizhuan.xchat_android_core.manager.IMMessageManager;
|
||||
@@ -401,6 +402,7 @@ public class XChatApplication extends BaseApp {
|
||||
.setBaseUrl(url)
|
||||
.addInterceptors(new ParamsInterceptor(httpParams))
|
||||
.addInterceptors(new NoParamsInterceptor())//注意:拦截器的添加顺序,请求的拦截顺序
|
||||
// .addInterceptors(new MyOkHttpRetryInterceptor())
|
||||
.certificates()
|
||||
.build();
|
||||
//单例的model 初始化
|
||||
|
@@ -4,6 +4,7 @@ import static com.yizhuan.xchat_android_core.UriProvider.IM_SERVER_URL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_CAR_EXPIRE;
|
||||
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
@@ -41,6 +42,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class MsgViewHolderText extends MsgViewHolderBase {
|
||||
private TextView mTvMsg;
|
||||
private TextView mTvSee;
|
||||
private NobleAttachment mNobleAttachment;
|
||||
private CarAttachment mCarAttachment;
|
||||
private AssistantAttachment awardAttachment;
|
||||
@@ -58,12 +60,21 @@ public class MsgViewHolderText extends MsgViewHolderBase {
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
mTvMsg = findViewById(R.id.tv_msg);
|
||||
mTvSee = findViewById(R.id.tv_see);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
CharSequence text = "";
|
||||
MsgAttachment attachment = message.getAttachment();
|
||||
if(attachment instanceof AssistantAttachment){
|
||||
awardAttachment = (AssistantAttachment) attachment;
|
||||
if(awardAttachment.routerValue != null){
|
||||
mTvSee.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}else {
|
||||
mTvSee.setVisibility(View.GONE);
|
||||
}
|
||||
if (attachment instanceof CarAttachment) {
|
||||
mCarAttachment = (CarAttachment) attachment;
|
||||
text = mCarAttachment.msg;
|
||||
|
@@ -1,10 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="215dp"
|
||||
android:orientation="vertical"
|
||||
tools:text="@string/layout_im_customer_msg_text_01" >
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_msg"
|
||||
android:textColor="@color/text_title_color"
|
||||
android:textSize="14sp"
|
||||
android:maxWidth="215dp"
|
||||
tools:text="@string/layout_im_customer_msg_text_01" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_see"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:visibility="gone"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/layout_layout_msg_view_holder_level_02"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:maxWidth="215dp"
|
||||
app:drawableRightCompat="@drawable/arrow_right" />
|
||||
|
||||
</LinearLayout>
|
@@ -967,7 +967,7 @@
|
||||
<string name="me_charge_diamond">充值鉆石</string>
|
||||
<string name="me_noble_center">貴族中心</string>
|
||||
<string name="me_open_various_privileges">開通立享各項特權</string>
|
||||
<string name="me_my_association">我的公會</string>
|
||||
<string name="me_my_association">公会·房间</string>
|
||||
<string name="me_join_guild">加入公會</string>
|
||||
<string name="me_personal_center">個人中心</string>
|
||||
<string name="me_my_room">我的房間</string>
|
||||
|
@@ -99,6 +99,8 @@ public class ModuleHallActivity extends BaseMvpActivity<IModuleHallView, ModuleH
|
||||
binding.ivSetting.setOnClickListener(this);
|
||||
binding.tvExit.setOnClickListener(this);
|
||||
binding.tvCheckStream.setOnClickListener(this);
|
||||
binding.tvMemberIncome.setOnClickListener(this);
|
||||
binding.tvManageSetup.setOnClickListener(this);
|
||||
hallId = getIntent().getLongExtra(KEY_HALL_ID, HallModel.get().getHallId());
|
||||
ownerUid = getIntent().getLongExtra(KEY_OWNER_UID, AuthModel.get().getCurrentUid());
|
||||
isSelfHall = hallId == HallModel.get().getHallId();
|
||||
|
@@ -4,8 +4,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
@@ -51,6 +53,8 @@ public class RoomIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, R
|
||||
private TextView tvMonthDayEnd;
|
||||
private TextView tvTotal;
|
||||
private AppCompatTextView tvTip;
|
||||
private LinearLayout llDayGroup;
|
||||
private AppCompatImageView ivDateArrow;
|
||||
|
||||
FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getSupportFragmentManager()) {
|
||||
@Override
|
||||
@@ -81,7 +85,7 @@ public class RoomIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, R
|
||||
initFindView();
|
||||
initIndicator();
|
||||
long id = getIntent().getLongExtra(HallIncomeFragment.FLAG_HALL_ID, 0);
|
||||
initWhiteTitleBar("收入统计");
|
||||
initWhiteTitleBar("收入統計");
|
||||
|
||||
HallIncomeFragment fragment = HallIncomeFragment.getInstance(id);
|
||||
fragment.setmDayIncomeFragmentListener(this);
|
||||
@@ -105,6 +109,11 @@ public class RoomIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, R
|
||||
tvMonthDayEnd = findViewById(R.id.tv_month_day_end);
|
||||
tvTotal = findViewById(R.id.tv_total);
|
||||
tvTip = findViewById(R.id.tv_tip);
|
||||
llDayGroup = findViewById(R.id.ll_day_group);
|
||||
ivDateArrow = findViewById(R.id.iv_date_arrow);
|
||||
|
||||
ivDateArrow.setOnClickListener(this);
|
||||
llDayGroup.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,9 +137,9 @@ public class RoomIncomeActivity extends BaseMvpActivity<IIncomeStatisticsView, R
|
||||
|
||||
private void initIndicator() {
|
||||
List<String> tagList = new ArrayList<>();
|
||||
tagList.add("按日统计");
|
||||
tagList.add("每周统计");
|
||||
tagList.add("每月统计");
|
||||
tagList.add("按日統計");
|
||||
tagList.add("每周統計");
|
||||
tagList.add("每月統計");
|
||||
StatisticsIndicatorAdapter adapter = new StatisticsIndicatorAdapter(tagList, 5);
|
||||
adapter.setOnItemSelectListener(position -> viewPager.setCurrentItem(position));
|
||||
CommonNavigator navigator = new CommonNavigator(this);
|
||||
|
@@ -24,7 +24,7 @@ public class HallIncomeAdapter extends BaseQuickAdapter<HallIncomeInfo, BaseView
|
||||
.setText(R.id.tv_room_income, "+" + decimalFormat.format(item.getRoomIncome()))
|
||||
.setText(R.id.tv_send_gift_number, item.getGiftUv())
|
||||
.setText(R.id.tv_new_user_send_gift_number, item.getNewUserSendGiftNum())
|
||||
.setText(R.id.tv_room_income_desc, "房间流水");
|
||||
.setText(R.id.tv_room_income_desc, "房間流水");
|
||||
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.civ_avatar), item.getHallAvatar());
|
||||
helper.setText(R.id.tv_name, item.getHallName());
|
||||
|
@@ -14,6 +14,7 @@ import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class IncomeAdapter extends BaseQuickAdapter<IncomeInfo, BaseViewHolder> {
|
||||
@@ -32,27 +33,14 @@ public class IncomeAdapter extends BaseQuickAdapter<IncomeInfo, BaseViewHolder>
|
||||
|
||||
helper.setText(R.id.tv_row_num, item.getRowNum());
|
||||
String nick = item.getNick();
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
|
||||
if (!TextUtils.isEmpty(nick) && nick.length() > 4)
|
||||
nick = nick.substring(0, 4) + "...";
|
||||
helper.setText(R.id.tv_name, nick);
|
||||
helper.setText(R.id.tv_num, String.format(mContext.getString(R.string.label_id_format), item.getErbanNo()));
|
||||
helper.setText(R.id.tv_gold, formatGoldNun(item.getTotalGoldNum()));
|
||||
helper.setText(R.id.tv_gold, decimalFormat.format(item.getTotalGoldNum()));
|
||||
|
||||
helper.addOnClickListener(R.id.container);
|
||||
}
|
||||
|
||||
private String formatGoldNun(long goldNum) {
|
||||
|
||||
if (goldNum > 10000) {
|
||||
double d = (double) goldNum;
|
||||
d = d / 10000;
|
||||
BigDecimal df = new BigDecimal(d);
|
||||
return df.setScale(2, RoundingMode.DOWN).toString() + ResUtil.getString(R.string.income_adapter_incomeadapter_01);
|
||||
|
||||
} else
|
||||
return String.valueOf(goldNum);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class LiveIncomeAdapter extends BaseQuickAdapter<LiveIncomeInfo, BaseViewHolder> {
|
||||
|
||||
@@ -22,8 +23,8 @@ public class LiveIncomeAdapter extends BaseQuickAdapter<LiveIncomeInfo, BaseView
|
||||
|
||||
@Override
|
||||
protected void convert(@NotNull BaseViewHolder helper, LiveIncomeInfo item) {
|
||||
|
||||
helper.setText(R.id.tvIncome, String.valueOf(item.getIncome()))
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
|
||||
helper.setText(R.id.tvIncome, decimalFormat.format(item.getIncome()))
|
||||
.setText(R.id.tv_hall_number, String.valueOf(helper.getLayoutPosition() + 1))
|
||||
.setText(R.id.tv_user_name, item.getNick())
|
||||
.setText(R.id.tv_hall_name, item.getHallName());
|
||||
|
@@ -11,6 +11,7 @@ import com.yizhuan.xchat_android_library.utils.TimeUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -54,21 +55,11 @@ public class IncomeStatisticsPresenter extends BaseMvpPresenter<IIncomeStatistic
|
||||
SpannableString spannableString;
|
||||
RelativeSizeSpan sizeSpan = new RelativeSizeSpan(0.5f);
|
||||
|
||||
if (total > 10000) {
|
||||
double d = (double) total;
|
||||
d = d / 10000;
|
||||
BigDecimal df = new BigDecimal(d);
|
||||
String str = df.setScale(2, RoundingMode.DOWN).toString() + ResUtil.getString(R.string.income_presenter_incomestatisticspresenter_01);
|
||||
|
||||
spannableString = new SpannableString(str);
|
||||
spannableString.setSpan(sizeSpan, str.length() - 3, str.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
} else {
|
||||
String str = String.valueOf(total) + ResUtil.getString(R.string.income_presenter_incomestatisticspresenter_02);
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
|
||||
String str = decimalFormat.format(total) + "鉆石";
|
||||
|
||||
spannableString = new SpannableString(str);
|
||||
spannableString.setSpan(sizeSpan, str.length() - 2, str.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
return spannableString;
|
||||
}
|
||||
|
@@ -120,9 +120,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_hall_income"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingTop="15dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/layout_activity_module_clan_04"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
@@ -149,9 +147,7 @@
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_hall_admin"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="@dimen/dp_0"
|
||||
android:paddingTop="15dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/layout_activity_module_clan_06"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
@@ -49,18 +49,6 @@
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_hall_avatar"
|
||||
tools:text="@string/layout_item_clan_income_01" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_contract_statement"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:text="@string/contract_statement"
|
||||
android:textColor="@color/color_2B2D33"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_hall_number"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_hall_avatar" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_1"
|
||||
android:layout_width="0dp"
|
||||
@@ -72,7 +60,7 @@
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ll_2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_contract_statement">
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_hall_avatar">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_room_income"
|
||||
@@ -104,7 +92,7 @@
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ll_3"
|
||||
app:layout_constraintStart_toEndOf="@+id/ll_1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_contract_statement">
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_hall_avatar">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_normal_gift_income"
|
||||
@@ -136,7 +124,7 @@
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/ll_2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_contract_statement">
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_hall_avatar">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_bag_income"
|
||||
|
@@ -44,7 +44,7 @@
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(钻石)"
|
||||
android:text="(鉆石)"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textColor="@color/color_1F1B4F"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_income"
|
||||
@@ -76,7 +76,7 @@
|
||||
android:id="@+id/tv_room_income_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="房间流水"
|
||||
android:text="房間流水"
|
||||
android:textColor="@color/color_8A8CAB"
|
||||
android:textSize="@dimen/sp_11" />
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="普通礼物流水"
|
||||
android:text="普通禮物流水"
|
||||
android:textColor="@color/color_8A8CAB"
|
||||
android:textSize="@dimen/sp_11" />
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="背包礼物流水"
|
||||
android:text="背包禮物流水"
|
||||
android:textColor="@color/color_8A8CAB"
|
||||
android:textSize="@dimen/sp_11" />
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="送礼人数"
|
||||
android:text="送禮人數"
|
||||
android:textColor="@color/color_8A8CAB"
|
||||
android:textSize="@dimen/sp_11" />
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="新用户送礼人数"
|
||||
android:text="新用戶送禮人數"
|
||||
android:textColor="@color/color_8A8CAB"
|
||||
android:textSize="@dimen/sp_11" />
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="新用户送礼人数"
|
||||
android:text="新用戶送禮人數"
|
||||
android:textColor="@color/color_8A8CAB"
|
||||
android:textSize="@dimen/sp_11" />
|
||||
|
||||
|
@@ -51,7 +51,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvIncome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
@@ -59,15 +59,11 @@
|
||||
android:textSize="@dimen/sp_14"
|
||||
tools:text="1,000,000,000" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.yizhuan.erban.common.widget.RectRoundImageView
|
||||
android:id="@+id/iv_hall_avatar"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_6"
|
||||
android:src="@drawable/default_cover"
|
||||
@@ -76,13 +72,16 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_hall_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:textColor="@color/color_1F1A4E"
|
||||
android:textSize="@dimen/sp_13"
|
||||
tools:text="房間名稱" />
|
||||
tools:text="房間名稱阿法狗發哈士大夫擊殺敵方" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -11,7 +11,7 @@ public class SDKConfig {
|
||||
* 进入腾讯云云通信[控制台](https://console.cloud.tencent.com/avc) 创建应用,即可看到 SDKAppId,
|
||||
* 它是腾讯云用于区分客户的唯一标识。
|
||||
*/
|
||||
public static int TX_SDKAPPID = 1400741885;//
|
||||
public static int TX_SDKAPPID = 1400823228;//
|
||||
|
||||
/**
|
||||
* 腾讯云 bizid和appid
|
||||
|
@@ -0,0 +1,60 @@
|
||||
package com.yizhuan.xchat_android_core.interceptor;
|
||||
|
||||
import com.yizhuan.xchat_android_core.utils.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* User: Administrator
|
||||
* Date: 2017/9/19
|
||||
* Description:
|
||||
*/
|
||||
public class MyOkHttpRetryInterceptor implements Interceptor {
|
||||
public int executionCount = 3;//最大重试次数
|
||||
private long retryInterval = 1000;//重试的间隔
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
Response response = doRequest(chain, request);
|
||||
int retryNum = 0;
|
||||
while ((response == null || !response.isSuccessful()) && retryNum <= executionCount) {
|
||||
Logger.info("intercept Request is not successful - {}", String.valueOf(retryNum));
|
||||
final long nextInterval = getRetryInterval();
|
||||
try {
|
||||
Logger.info("Wait for {}", String.valueOf(nextInterval));
|
||||
Thread.sleep(nextInterval);
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new InterruptedIOException();
|
||||
}
|
||||
retryNum++;
|
||||
// retry the request
|
||||
response = doRequest(chain, request);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private Response doRequest(Chain chain, Request request) {
|
||||
Response response = null;
|
||||
try {
|
||||
response = chain.proceed(request);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* retry间隔时间
|
||||
*/
|
||||
public long getRetryInterval() {
|
||||
return this.retryInterval;
|
||||
}
|
||||
|
||||
}
|
@@ -122,6 +122,8 @@ public final class RxNetManager {
|
||||
client.sslSocketFactory(new Tls12SocketFactory(sc.getSocketFactory()));
|
||||
|
||||
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||
// .allEnabledTlsVersions()
|
||||
// .allEnabledCipherSuites()
|
||||
.tlsVersions(TlsVersion.TLS_1_2)
|
||||
.build();
|
||||
|
||||
|
Reference in New Issue
Block a user