eventbus and im 添加log打印。
This commit is contained in:
@@ -28,6 +28,7 @@ import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.BarUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.dialog.LoadingDialog;
|
||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.DisplayUtil;
|
||||
@@ -54,7 +55,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
public void onEvent(Object event) {
|
||||
}
|
||||
|
||||
// private LoadingDialog mLoadingDialog;
|
||||
private LoadingDialog mLoadingDialog;
|
||||
// 添加广播接收器成员变量
|
||||
private BroadcastReceiver mLogoutReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -282,27 +283,27 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
|
||||
public void showLoading(String content) {
|
||||
// if (mLoadingDialog == null) {
|
||||
// mLoadingDialog = new LoadingDialog(this);
|
||||
// }
|
||||
// if (!mLoadingDialog.isShowing()) {
|
||||
// mLoadingDialog.show();
|
||||
// }
|
||||
if (mLoadingDialog == null) {
|
||||
mLoadingDialog = new LoadingDialog(this,content);
|
||||
}
|
||||
if (!mLoadingDialog.isShowing()) {
|
||||
mLoadingDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void showLoading() {
|
||||
// if (mLoadingDialog == null) {
|
||||
// mLoadingDialog = new LoadingDialog(this);
|
||||
// }
|
||||
// if (!mLoadingDialog.isShowing()) {
|
||||
// mLoadingDialog.show();
|
||||
// }
|
||||
if (mLoadingDialog == null) {
|
||||
mLoadingDialog = new LoadingDialog(this);
|
||||
}
|
||||
if (!mLoadingDialog.isShowing()) {
|
||||
mLoadingDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void disLoading() {
|
||||
// if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
|
||||
// mLoadingDialog.dismiss();
|
||||
// }
|
||||
if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
|
||||
mLoadingDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,19 +14,26 @@ import com.xscm.moduleutil.R;
|
||||
*/
|
||||
public class LoadingDialog extends Dialog {
|
||||
|
||||
|
||||
private String content;
|
||||
public LoadingDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public LoadingDialog(@NonNull Context context,String content) {
|
||||
super(context);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 设置布局(这里假设你有一个R.layout.loading_dialog布局文件)
|
||||
setContentView(R.layout.loading_dialog);
|
||||
|
||||
if (content != null) {
|
||||
((TextView) findViewById(R.id.tv_loading_text)).setText(content);
|
||||
}
|
||||
// 设置不可取消
|
||||
setCancelable(false);
|
||||
setCancelable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -98,7 +98,7 @@ public class MqttConnect {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e(Tag,"开始重连。。。");
|
||||
LogUtils.e(Tag,"开始重连。。。");
|
||||
mqttClient();
|
||||
}
|
||||
},3000);
|
||||
@@ -112,7 +112,7 @@ public class MqttConnect {
|
||||
* @param msg
|
||||
*/
|
||||
private void uiTip(String msg){
|
||||
Log.d(Tag,msg);
|
||||
LogUtils.d(Tag,msg);
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -150,11 +150,11 @@ public class MqttConnect {
|
||||
mqttClient.disconnect();
|
||||
mqttClient = null;
|
||||
} catch (MqttException e) {
|
||||
Log.e(Tag,"关闭MQTT连接报错:"+e.getMessage());
|
||||
LogUtils.e(Tag,"关闭MQTT连接报错:"+e.getMessage());
|
||||
// ToastUtils.show("关闭MQTT连接报错");
|
||||
}
|
||||
}else {
|
||||
Log.d(Tag,"Mqtt已关闭");
|
||||
LogUtils.d(Tag,"Mqtt已关闭");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class MqttConnect {
|
||||
try {
|
||||
mqttClient.subscribe(topic);
|
||||
} catch (MqttException e) {
|
||||
Log.e(Tag,"MQTT主题订阅失败:" + e.getMessage());
|
||||
LogUtils.e(Tag,"MQTT主题订阅失败:" + e.getMessage());
|
||||
// uiTip("MQTT主题订阅失败");
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class MqttConnect {
|
||||
try {
|
||||
mqttClient.subscribe(topic, qos);
|
||||
}catch (MqttException e){
|
||||
Log.e(Tag,"订阅主题失败:"+e.getMessage());
|
||||
LogUtils.e(Tag,"订阅主题失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,15 @@ package com.xscm.moduleutil.service;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.HourlyBean;
|
||||
import com.xscm.moduleutil.event.RedBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||
@@ -43,7 +38,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
*/
|
||||
@Override
|
||||
public void connectionLost(Throwable cause) {
|
||||
Log.d(Tag, "mqtt连接断开,执行重连");
|
||||
LogUtils.d(Tag, "mqtt连接断开,执行重连");
|
||||
// ToastUtils.show("mqtt连接断开,执行重连");
|
||||
mqttConnect = MqttConnect.getInstance(context, HOST, clientId);
|
||||
mqttConnect.mqttClient();
|
||||
@@ -54,16 +49,11 @@ public class MqttInitCallback implements MqttCallback {
|
||||
*/
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) {
|
||||
// Log.d(Tag,"topic");
|
||||
// Log.d(Tag,topic);
|
||||
|
||||
String messageStr = message.toString();
|
||||
Logger.e("MQTT", "收到的消息", "主题:" + topic + " 收到的消息:" + messageStr);
|
||||
LogUtils.e("MQTT", "收到的消息", "主题:" + topic + " 收到的消息:" + messageStr);
|
||||
if (topic.equals("qx_room_topic")) {
|
||||
// ToastUtils.show("收到礼物飘屏");
|
||||
receiveMessage(topic, messageStr);
|
||||
} else if (topic.equals("qx_xunlehui")) {
|
||||
// ToastUtils.show("收到轮盘飘屏");
|
||||
receiveXlhMessage(messageStr);
|
||||
} else if (topic.equals("qx_hour_ranking")) {
|
||||
receiveQXHourRanking(topic, messageStr);
|
||||
@@ -81,7 +71,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
processRedMessage(topic, message);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +86,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
processDataRed(dataList);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +111,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
processMessage(topic, message);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
// ToastUtils.show("收到礼物飘屏,解析异常");
|
||||
}
|
||||
}
|
||||
@@ -139,7 +129,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +164,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
processMessageType(type, message);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
// ToastUtils.show("收到礼物飘屏,解析异常");
|
||||
}
|
||||
}
|
||||
@@ -216,7 +206,7 @@ public class MqttInitCallback implements MqttCallback {
|
||||
EventBus.getDefault().post(xlhBean);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("MQTT", "解析MQTT消息异常", e);
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
// ToastUtils.show("收到轮盘飘屏,解析异常");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/transparent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
android:background="@color/transparent">
|
||||
|
||||
<app.dinus.com.loadingdrawable.LoadingView
|
||||
android:id="@+id/cool_wait_view"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:visibility="visible"
|
||||
app:loading_renderer="CoolWaitLoadingRenderer"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:loading_renderer="CoolWaitLoadingRenderer" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_loading_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:text="加载中..."
|
||||
android:textColor="#333333"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cool_wait_view" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -162,7 +162,7 @@ public class LoginActivity extends BaseMvpActivity<LoginPresenter, ActivityLogin
|
||||
|
||||
@Override
|
||||
public void showLoadings() {
|
||||
showLoading();
|
||||
// showLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,7 +172,7 @@ public class LoginActivity extends BaseMvpActivity<LoginPresenter, ActivityLogin
|
||||
|
||||
@Override
|
||||
public void disLoadings() {
|
||||
disLoading();
|
||||
// disLoading();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1254,6 +1254,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
LogUtils.e("roomInfoEvent: ${messageEvent.toString()}")
|
||||
|
||||
val msgType = messageEvent.msgType
|
||||
val text = messageEvent.text
|
||||
|
||||
@@ -3184,6 +3186,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onMusicEvent(event: Music?) {
|
||||
LogUtils.e("eventMain: ${event.toString()} Music: ${customMusicFloatingView != null}")
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.onMusicEvent(event)
|
||||
}
|
||||
@@ -3191,6 +3194,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onMusicPlayBeanEvent(event: MusicPlayBean) {
|
||||
LogUtils.e("eventMain: ${event.toString()} MusicPlayBean: ${customMusicFloatingView != null}")
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.updateProgress(Math.toIntExact(event.position))
|
||||
}
|
||||
@@ -3198,6 +3202,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMain(event: BaseEvent?) {
|
||||
LogUtils.e("eventMain: ${event.toString()}")
|
||||
when (event) {
|
||||
is MusicEvent -> {
|
||||
if (!isMusic) {
|
||||
|
||||
@@ -204,7 +204,7 @@ public class SettingActivity extends BaseMvpActivity<SettingPresenter, ActivityS
|
||||
}
|
||||
}
|
||||
} else if (view.getId() == R.id.tv_share) {
|
||||
|
||||
showLoading("正在生成分享文件...");
|
||||
Observable.create(new ObservableOnSubscribe<Boolean>() {
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
@@ -227,6 +227,7 @@ public class SettingActivity extends BaseMvpActivity<SettingPresenter, ActivityS
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void accept(Boolean aBoolean) {
|
||||
disLoading();
|
||||
if (aBoolean){
|
||||
File file = new File(Application.Companion.getInstance().getAppContent()+"/DataInfo.zip");
|
||||
Uri uri = FileProvider.getUriForFile(SettingActivity.this, getPackageName()+".fileprovider", file);
|
||||
@@ -240,10 +241,6 @@ public class SettingActivity extends BaseMvpActivity<SettingPresenter, ActivityS
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private void showYouthModelDialog() {
|
||||
|
||||
@@ -431,12 +431,12 @@ public class PasswordLoginActivity extends BaseMvpActivity<LoginPresenter, Activ
|
||||
|
||||
@Override
|
||||
public void showLoadings() {
|
||||
showLoading();
|
||||
// showLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disLoadings() {
|
||||
disLoading();
|
||||
// disLoading();
|
||||
}
|
||||
|
||||
private void setUpLoginBtn() {
|
||||
|
||||
Reference in New Issue
Block a user