Commit 1280a706 by 万齐军

Merge branch 'feat/qj/volcengine' into 'd/v4.3.97'

feat: 火山引擎接入,去掉NewH5Activity的错误

See merge request app_android_lib/YDL-Component!153
parents 578c64b7 0bdb5f19
...@@ -4,9 +4,7 @@ import android.annotation.SuppressLint ...@@ -4,9 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Handler import android.os.Handler
import android.text.TextUtils import android.text.TextUtils
import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.bytedance.apm.insight.ApmInsightAgent
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.audioim.bean.AgoraInvitationBean import com.ydl.audioim.bean.AgoraInvitationBean
import com.ydl.audioim.http.AudioApiRequestUtil import com.ydl.audioim.http.AudioApiRequestUtil
...@@ -25,6 +23,7 @@ import com.ydl.ydl_av.messge_service.callback.LoginCallback ...@@ -25,6 +23,7 @@ import com.ydl.ydl_av.messge_service.callback.LoginCallback
import com.ydl.ydl_av.messge_service.request.LoginParam import com.ydl.ydl_av.messge_service.request.LoginParam
import com.ydl.ydl_av.messge_service.response.CallLocalResponse import com.ydl.ydl_av.messge_service.response.CallLocalResponse
import com.ydl.ydl_av.messge_service.response.CallRemoteResponse import com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.ActivityManager import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.LogUtil import com.ydl.ydlcommon.utils.LogUtil
...@@ -43,7 +42,6 @@ import io.agora.rtm.RtmStatusCode.ConnectionChangeReason.CONNECTION_CHANGE_REASO ...@@ -43,7 +42,6 @@ import io.agora.rtm.RtmStatusCode.ConnectionChangeReason.CONNECTION_CHANGE_REASO
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import org.json.JSONObject
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
...@@ -498,6 +496,7 @@ class YDLavManager { ...@@ -498,6 +496,7 @@ class YDLavManager {
} }
override fun onFailure(msg: String?) { override fun onFailure(msg: String?) {
Apm.reportCustom("agora_login_error", msg ?: "", Exception(msg))
LogUtil.e("[agora]实时消息登录失败:$msg") LogUtil.e("[agora]实时消息登录失败:$msg")
writeAgoraLog( writeAgoraLog(
"声网rtm登录失败:$msg-------Time:${ "声网rtm登录失败:$msg-------Time:${
...@@ -714,6 +713,8 @@ class YDLavManager { ...@@ -714,6 +713,8 @@ class YDLavManager {
* https://docs.agora.io/cn/Voice/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler.html#a31b2974a574ec45e62bb768e17d1f49e * https://docs.agora.io/cn/Voice/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler.html#a31b2974a574ec45e62bb768e17d1f49e
* */ * */
override fun onConnectionStateChanged(state: Int, reason: Int) { override fun onConnectionStateChanged(state: Int, reason: Int) {
val msg = "state:${state},reason:${reason}"
Apm.reportCustom("agora_connectionstate_error", msg, Exception(msg))
sdkStatus = state sdkStatus = state
writeAgoraLog( writeAgoraLog(
"声网rtm登录状态:${state}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", "声网rtm登录状态:${state}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}",
......
...@@ -8,8 +8,6 @@ import android.graphics.Color; ...@@ -8,8 +8,6 @@ import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.MediaStore; import android.provider.MediaStore;
import androidx.viewpager.widget.PagerAdapter;
import androidx.core.view.ViewCompat;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -17,6 +15,9 @@ import android.view.View; ...@@ -17,6 +15,9 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.PagerAdapter;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.luck.picture.lib.photoview.PhotoView; import com.luck.picture.lib.photoview.PhotoView;
import com.netease.nimlib.sdk.AbortableFuture; import com.netease.nimlib.sdk.AbortableFuture;
...@@ -31,6 +32,7 @@ import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum; ...@@ -31,6 +32,7 @@ import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum; import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum; import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage; import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.nimbase.common.ToastHelper; import com.yidianling.nimbase.common.ToastHelper;
import com.yidianling.nimbase.common.activity.ToolBarOptions; import com.yidianling.nimbase.common.activity.ToolBarOptions;
...@@ -335,6 +337,22 @@ public class WatchMessagePictureActivity extends UI { ...@@ -335,6 +337,22 @@ public class WatchMessagePictureActivity extends UI {
onDownloadStart(msg); onDownloadStart(msg);
message = msg; // 下载成功之后,判断是否是同一条消息时需要使用 message = msg; // 下载成功之后,判断是否是同一条消息时需要使用
downloadFuture = NIMClient.getService(MsgService.class).downloadAttachment(msg, false); downloadFuture = NIMClient.getService(MsgService.class).downloadAttachment(msg, false);
downloadFuture.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
} }
private boolean isOriginImageHasDownloaded(final IMMessage message) { private boolean isOriginImageHasDownloaded(final IMMessage message) {
......
...@@ -10,7 +10,6 @@ import android.media.MediaPlayer.OnPreparedListener; ...@@ -10,7 +10,6 @@ import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import androidx.appcompat.app.ActionBar;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
...@@ -23,21 +22,25 @@ import android.widget.ImageView; ...@@ -23,21 +22,25 @@ import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.ActionBar;
import com.netease.nimlib.sdk.AbortableFuture; import com.netease.nimlib.sdk.AbortableFuture;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer; import com.netease.nimlib.sdk.Observer;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService; import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.MsgServiceObserve; import com.netease.nimlib.sdk.msg.MsgServiceObserve;
import com.netease.nimlib.sdk.msg.attachment.VideoAttachment; import com.netease.nimlib.sdk.msg.attachment.VideoAttachment;
import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum; import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
import com.netease.nimlib.sdk.msg.model.AttachmentProgress; import com.netease.nimlib.sdk.msg.model.AttachmentProgress;
import com.netease.nimlib.sdk.msg.model.IMMessage; import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R;
import com.yidianling.nimbase.common.ToastHelper; import com.yidianling.nimbase.common.ToastHelper;
import com.yidianling.nimbase.common.activity.ToolBarOptions; import com.yidianling.nimbase.common.activity.ToolBarOptions;
import com.yidianling.nimbase.common.activity.UI; import com.yidianling.nimbase.common.activity.UI;
import com.yidianling.nimbase.common.util.file.FileUtil; import com.yidianling.nimbase.common.util.file.FileUtil;
import com.yidianling.nimbase.common.util.sys.TimeUtil; import com.yidianling.nimbase.common.util.sys.TimeUtil;
import com.yidianling.im.R;
import com.yidianling.uikit.custom.config.YDLToolBarOptions; import com.yidianling.uikit.custom.config.YDLToolBarOptions;
/** /**
...@@ -499,6 +502,21 @@ public class WatchVideoActivity extends UI implements Callback { ...@@ -499,6 +502,21 @@ public class WatchVideoActivity extends UI implements Callback {
// async download original image // async download original image
onDownloadStart(message); onDownloadStart(message);
downloadFuture = NIMClient.getService(MsgService.class).downloadAttachment(message, false); downloadFuture = NIMClient.getService(MsgService.class).downloadAttachment(message, false);
downloadFuture.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
downloading = true; downloading = true;
} }
} }
......
...@@ -4,13 +4,9 @@ import android.animation.Animator; ...@@ -4,13 +4,9 @@ import android.animation.Animator;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
...@@ -30,7 +26,6 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -30,7 +26,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer; import com.netease.nimlib.sdk.Observer;
...@@ -49,28 +44,20 @@ import com.netease.nimlib.sdk.uinfo.model.NimUserInfo; ...@@ -49,28 +44,20 @@ import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
import com.ydl.webview.H5Params; import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity; import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.config.HttpConfig; import com.ydl.ydlcommon.app.Apm;
import com.ydl.ydlcommon.data.PlatformDataManager;
import com.ydl.ydlcommon.data.http.RxUtils; import com.ydl.ydlcommon.data.http.RxUtils;
import com.ydl.ydlcommon.modular.ModularServiceManager; import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.ydl.ydlcommon.ui.LoadingDialogFragment;
import com.ydl.ydlcommon.utils.AnimUtils; import com.ydl.ydlcommon.utils.AnimUtils;
import com.ydl.ydlcommon.utils.LogUtil; import com.ydl.ydlcommon.utils.LogUtil;
import com.ydl.ydlcommon.utils.NetworkParamsUtils;
import com.ydl.ydlcommon.utils.SharedPreferencesEditor; import com.ydl.ydlcommon.utils.SharedPreferencesEditor;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils; import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils;
import com.ydl.ydlcommon.utils.log.AliYunLogConfig; import com.ydl.ydlcommon.utils.log.AliYunLogConfig;
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper; import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper;
import com.ydl.ydlcommon.utils.log.LogHelper; import com.ydl.ydlcommon.utils.log.LogHelper;
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils;
import com.ydl.ydlcommon.view.CircleImageView; import com.ydl.ydlcommon.view.CircleImageView;
import com.ydl.ydlcommon.view.dialog.CommonDialog; import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.ydl.ydlcommon.view.dialog.ListDialog;
import com.yidianling.common.tools.ToastUtil; import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.im.bean.RemoveHistory;
import com.yidianling.im.config.constants.ImConstants;
import com.yidianling.im.event.CloseBottomWebviewEvent; import com.yidianling.im.event.CloseBottomWebviewEvent;
import com.yidianling.im.event.MultipleAnswerBean; import com.yidianling.im.event.MultipleAnswerBean;
import com.yidianling.im.event.MultipleSelectedEvent; import com.yidianling.im.event.MultipleSelectedEvent;
...@@ -97,7 +84,6 @@ import com.yidianling.uikit.api.NimUIKitImpl; ...@@ -97,7 +84,6 @@ import com.yidianling.uikit.api.NimUIKitImpl;
import com.yidianling.uikit.business.ait.AitManager; import com.yidianling.uikit.business.ait.AitManager;
import com.yidianling.uikit.business.session.activity.YDLBaseMessageActivity; import com.yidianling.uikit.business.session.activity.YDLBaseMessageActivity;
import com.yidianling.uikit.business.session.helper.ChatStatusCacheHelper; import com.yidianling.uikit.business.session.helper.ChatStatusCacheHelper;
import com.yidianling.uikit.business.session.helper.MessageListPanelHelper;
import com.yidianling.uikit.business.session.module.input.InputPanel; import com.yidianling.uikit.business.session.module.input.InputPanel;
import com.yidianling.uikit.business.session.module.list.MessageListPanelEx; import com.yidianling.uikit.business.session.module.list.MessageListPanelEx;
import com.yidianling.uikit.business.session.view.ChatPrivateTips; import com.yidianling.uikit.business.session.view.ChatPrivateTips;
...@@ -1336,6 +1322,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy { ...@@ -1336,6 +1322,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
public void onFailed(int code) { public void onFailed(int code) {
if (msg != null) { if (msg != null) {
sendFailWithBlackList(code, msg); sendFailWithBlackList(code, msg);
Apm.INSTANCE.reportCustom("yx_sendmessage_error", "sessionId:" + msg.getSessionId(), new Exception(String.valueOf(code)));
} }
} }
......
...@@ -7,14 +7,15 @@ import android.graphics.Bitmap; ...@@ -7,14 +7,15 @@ import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.provider.MediaStore; import android.provider.MediaStore;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.NIMSDK; import com.netease.nimlib.sdk.NIMSDK;
import com.netease.nimlib.sdk.Observer; import com.netease.nimlib.sdk.Observer;
...@@ -40,6 +41,7 @@ import com.netease.nimlib.sdk.msg.model.TeamMessageReceipt; ...@@ -40,6 +41,7 @@ import com.netease.nimlib.sdk.msg.model.TeamMessageReceipt;
import com.netease.nimlib.sdk.robot.model.RobotAttachment; import com.netease.nimlib.sdk.robot.model.RobotAttachment;
import com.netease.nimlib.sdk.team.constant.TeamMemberType; import com.netease.nimlib.sdk.team.constant.TeamMemberType;
import com.netease.nimlib.sdk.team.model.TeamMember; import com.netease.nimlib.sdk.team.model.TeamMember;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.common.tools.ToastUtil; import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion; import com.yidianling.im.session.extension.CustomAttachLingxiWhichQuestion;
...@@ -838,7 +840,23 @@ public class MessageListPanelEx { ...@@ -838,7 +840,23 @@ public class MessageListPanelEx {
public void doOkAction() { public void doOkAction() {
// 正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载 // 正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载
if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment) if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
NIMClient.getService(MsgService.class).downloadAttachment(message, true); NIMClient.getService(MsgService.class).downloadAttachment(message, true)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
} }
}; };
...@@ -1145,6 +1163,8 @@ public class MessageListPanelEx { ...@@ -1145,6 +1163,8 @@ public class MessageListPanelEx {
@Override @Override
public void onFailed(int code) { public void onFailed(int code) {
String sessionId = item.getSessionId();
Apm.INSTANCE.reportCustom("yx_revoke_error", "sessionId:" + sessionId, new Exception(String.valueOf(code)));
if (code == ResponseCode.RES_OVERDUE) { if (code == ResponseCode.RES_OVERDUE) {
ToastHelper.showToast(container.activity, R.string.im_revoke_failed); ToastHelper.showToast(container.activity, R.string.im_revoke_failed);
} else { } else {
......
...@@ -10,18 +10,20 @@ import android.widget.ImageView; ...@@ -10,18 +10,20 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService; import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.attachment.AudioAttachment; import com.netease.nimlib.sdk.msg.attachment.AudioAttachment;
import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum; import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum; import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum; import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage; import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R;
import com.yidianling.nimbase.business.session.audio.MessageAudioControl; import com.yidianling.nimbase.business.session.audio.MessageAudioControl;
import com.yidianling.nimbase.common.media.audioplayer.Playable; import com.yidianling.nimbase.common.media.audioplayer.Playable;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter; import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.nimbase.common.util.sys.ScreenUtil; import com.yidianling.nimbase.common.util.sys.ScreenUtil;
import com.yidianling.nimbase.common.util.sys.TimeUtil; import com.yidianling.nimbase.common.util.sys.TimeUtil;
import com.yidianling.im.R;
import com.yidianling.uikit.api.NimUIKitImpl; import com.yidianling.uikit.api.NimUIKitImpl;
/** /**
...@@ -71,7 +73,24 @@ public class MsgViewHolderAudio extends MsgViewHolderBase { ...@@ -71,7 +73,24 @@ public class MsgViewHolderAudio extends MsgViewHolderBase {
if (audioControl != null) { if (audioControl != null) {
if (message.getDirect() == MsgDirectionEnum.In && message.getAttachStatus() != AttachStatusEnum.transferred) { if (message.getDirect() == MsgDirectionEnum.In && message.getAttachStatus() != AttachStatusEnum.transferred) {
if (message.getAttachStatus() == AttachStatusEnum.fail || message.getAttachStatus() == AttachStatusEnum.def) { if (message.getAttachStatus() == AttachStatusEnum.fail || message.getAttachStatus() == AttachStatusEnum.def) {
NIMClient.getService(MsgService.class).downloadAttachment(message, false); NIMClient.getService(MsgService.class).downloadAttachment(message, false)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
} }
return; return;
} }
......
...@@ -13,12 +13,14 @@ import android.widget.TextView; ...@@ -13,12 +13,14 @@ import android.widget.TextView;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.NIMSDK; import com.netease.nimlib.sdk.NIMSDK;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.msg.MsgService; import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.attachment.FileAttachment; import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum; import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum; import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum; import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage; import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.ydl.ydlcommon.app.Apm;
import com.yidianling.im.R; import com.yidianling.im.R;
import com.yidianling.nimbase.common.ui.imageview.HeadImageView; import com.yidianling.nimbase.common.ui.imageview.HeadImageView;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter; import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
...@@ -140,7 +142,23 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem ...@@ -140,7 +142,23 @@ public abstract class MsgViewHolderBase extends RecyclerViewHolder<BaseMultiItem
*/ */
protected void downloadAttachment() { protected void downloadAttachment() {
if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment) if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
NIMClient.getService(MsgService.class).downloadAttachment(message, true); NIMClient.getService(MsgService.class).downloadAttachment(message, true)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void o) {
}
@Override
public void onFailed(int i) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", new Exception(String.valueOf(i)));
}
@Override
public void onException(Throwable throwable) {
Apm.INSTANCE.reportCustom("yx_attchment_error", "", throwable);
}
});
} }
// 设置FrameLayout子控件的gravity参数 // 设置FrameLayout子控件的gravity参数
......
package com.ydl.ydlcommon.app
import android.content.Context
import com.apm.insight.MonitorCrash
import com.apm.insight.log.VLog
import com.bytedance.apm.insight.ApmInsight
import com.bytedance.apm.insight.ApmInsightInitConfig
import com.bytedance.apm.insight.IDynamicParams
import com.meituan.android.walle.WalleChannelReader
object Apm {
private var crash: MonitorCrash? = null
fun initApm(context: Context, appId: String, vCode: Long, vName: String, debug: Boolean, uidCall: () -> String?) {
val channel = if (debug) "debug" else WalleChannelReader.getChannel(context)
crash = MonitorCrash.init(
context,
appId,
vCode,
vName
)
crash?.config()?.setChannel(channel)
val builder = ApmInsightInitConfig.builder()
.aid(appId)
//.batteryMonitor(true)
//.cpuMonitor(true)
//.fpsMonitor(true)
//.seriousBlockDetect(true)
.blockDetect(true)
// .enableWebViewMonitor(true)
.channel(channel)
.debugMode(debug)
.enableLogRecovery(true)
.setDynamicParams(ApmParams(crash, uidCall))
ApmInsight.getInstance().init(context, builder.build())
VLog.init(context, 20)
}
fun reportCustom(type: String, msg: String, throwable: Throwable) {
crash?.reportCustomErr(msg, type, throwable)
}
}
private class ApmParams(val crash: MonitorCrash?, val uidCall: () -> String?) : IDynamicParams() {
override fun getUserUniqueID(): String? {
return null
}
override fun getAbSdkVersion(): String? {
return null
}
override fun getSsid(): String? {
return null
}
override fun getDid(): String? {
return null
}
override fun getUserId(): String? {
val uid = uidCall.invoke()
crash?.config()?.setUID(uid)
return uid
}
}
\ No newline at end of file
...@@ -4,7 +4,9 @@ import android.annotation.SuppressLint ...@@ -4,7 +4,9 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.text.TextUtils import android.text.TextUtils
import com.facebook.stetho.okhttp3.StethoInterceptor import com.facebook.stetho.okhttp3.StethoInterceptor
import com.google.gson.Gson
import com.ydl.pushserver.pushagent.YdlPushAgent import com.ydl.pushserver.pushagent.YdlPushAgent
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.bean.AuthBean import com.ydl.ydlcommon.bean.AuthBean
import com.ydl.ydlcommon.bean.GatewayRequestDTO import com.ydl.ydlcommon.bean.GatewayRequestDTO
...@@ -15,6 +17,7 @@ import com.ydl.ydlcommon.data.http.GsonProvider ...@@ -15,6 +17,7 @@ import com.ydl.ydlcommon.data.http.GsonProvider
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.api.ApiRequestUtil import com.ydl.ydlcommon.data.http.api.ApiRequestUtil
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.AliYunLogConfig import com.ydl.ydlcommon.utils.log.AliYunLogConfig
...@@ -23,7 +26,6 @@ import com.ydl.ydlnet.builder.config.OkHttpConfig ...@@ -23,7 +26,6 @@ import com.ydl.ydlnet.builder.config.OkHttpConfig
import com.ydl.ydlnet.builder.factory.ApiFactory import com.ydl.ydlnet.builder.factory.ApiFactory
import com.ydl.ydlnet.builder.interceptor.log.RequestHandler import com.ydl.ydlnet.builder.interceptor.log.RequestHandler
import com.ydl.ydlnet.builder.interceptor.log.RequestLogInterceptor import com.ydl.ydlnet.builder.interceptor.log.RequestLogInterceptor
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
...@@ -31,6 +33,8 @@ import io.reactivex.functions.Action ...@@ -31,6 +33,8 @@ import io.reactivex.functions.Action
import okhttp3.* import okhttp3.*
import okio.Buffer import okio.Buffer
import okio.BufferedSink import okio.BufferedSink
import java.io.EOFException
import java.nio.charset.Charset
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import kotlin.collections.HashMap import kotlin.collections.HashMap
...@@ -141,7 +145,8 @@ class HttpConfig { ...@@ -141,7 +145,8 @@ class HttpConfig {
commonParams(), commonParams(),
requestHead(appName), requestHead(appName),
addEncryptionHeaderParamsInterceptor(), addEncryptionHeaderParamsInterceptor(),
responseErrorInterceptor() responseErrorInterceptor(),
respErrorInterceptor()
) )
.setRequestHandler(getRequestHandler()) .setRequestHandler(getRequestHandler())
.setReadTimeout(15) .setReadTimeout(15)
...@@ -183,6 +188,53 @@ class HttpConfig { ...@@ -183,6 +188,53 @@ class HttpConfig {
} }
} }
private fun respErrorInterceptor(): Interceptor {
return Interceptor {
val req = it.request()
val resp = it.proceed(req)
if (appDebug) return@Interceptor resp
val code = resp.code()
val message = resp.message()
val api = req.url().encodedPath()
if (!resp.isSuccessful) {
Apm.reportCustom("network_request_error", "${api}(${code},${message})", Exception("${api}(${code},${message})"))
} else {
try {
val body = resp.body() ?: return@Interceptor resp
val buffer = body.source().buffer()
if(!isPlaintext(buffer)) return@Interceptor resp
val readString = buffer.clone().readString(Charset.forName("UTF-8"))
val fromJson = Gson().fromJson<BaseAPIResponse<Any>>(readString, BaseAPIResponse::class.java)
if (fromJson.code != "200") {
Apm.reportCustom("network_business_error", "${api}(${fromJson.code},${fromJson.msg})", Exception("${api}(${fromJson.code},${fromJson.msg})"))
}
} catch (throwable: Throwable) {
LogUtil.e(throwable.message)
}
}
return@Interceptor resp
}
}
private fun isPlaintext(buffer: Buffer): Boolean {
return try {
val prefix = Buffer()
val byteCount = if (buffer.size() < 64L) buffer.size() else 64L
buffer.copyTo(prefix, 0L, byteCount)
var i = 0
while (i < 16 && !prefix.exhausted()) {
val codePoint = prefix.readUtf8CodePoint()
if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) {
return false
}
++i
}
true
} catch (var6: EOFException) {
false
}
}
/** /**
* 接口返回错误日志埋点 * 接口返回错误日志埋点
*/ */
......
...@@ -3,7 +3,6 @@ package com.ydl.webview; ...@@ -3,7 +3,6 @@ package com.ydl.webview;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.ClipData; import android.content.ClipData;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -35,7 +34,6 @@ import com.tencent.smtt.sdk.WebView; ...@@ -35,7 +34,6 @@ import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient; import com.tencent.smtt.sdk.WebViewClient;
import com.umeng.socialize.UMShareAPI; import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA; import com.umeng.socialize.bean.SHARE_MEDIA;
import com.ydl.event.ReloadUrlEvent;
import com.ydl.utils.PopUtils; import com.ydl.utils.PopUtils;
import com.ydl.utils.ProxyCheckUtils; import com.ydl.utils.ProxyCheckUtils;
import com.ydl.utils.WebUrlParamsUtils; import com.ydl.utils.WebUrlParamsUtils;
...@@ -1388,7 +1386,6 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -1388,7 +1386,6 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
super.onDestroy(); super.onDestroy();
cancelSendNetLossMessage(); cancelSendNetLossMessage();
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
super.onDestroy();
if (wv_content != null) { if (wv_content != null) {
wv_content.destroy(); wv_content.destroy();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment