封版羽声,作为最后的基础版
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package com.qxcm.modulemain.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
@@ -15,6 +20,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.BuildConfig;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.FragmentUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
@@ -28,15 +34,28 @@ import com.qxcm.modulemain.contacts.HomeContacts;
|
||||
import com.qxcm.modulemain.databinding.ActivityMainBinding;
|
||||
import com.qxcm.modulemain.presenter.HomePresenter;
|
||||
import com.qxcm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.qxcm.moduleutil.adapter.AppUpdateDialog;
|
||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||
import com.qxcm.moduleutil.bean.AppUpdateModel;
|
||||
import com.qxcm.moduleutil.bean.FirstChargeBean;
|
||||
import com.qxcm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.qxcm.moduleutil.dialog.FirstChargeDialog;
|
||||
import com.qxcm.moduleutil.dialog.HeavenGiftDialog;
|
||||
import com.qxcm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.qxcm.moduleutil.event.RoomOutEvent;
|
||||
import com.qxcm.moduleutil.event.UnreadCountEvent;
|
||||
import com.qxcm.moduleutil.utils.ARouteConstants;
|
||||
import com.qxcm.moduleutil.utils.ImageLoader;
|
||||
import com.qxcm.moduleutil.utils.SpUtil;
|
||||
import com.qxcm.moduleutil.utils.logger.Logger;
|
||||
import com.tencent.imsdk.v2.V2TIMConversationListener;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
@Route(path = ARouteConstants.ME)
|
||||
public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBinding> implements HomeContacts.View, View.OnClickListener {
|
||||
private static int index = -1;
|
||||
@@ -49,6 +68,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
public String giftBagUrl;
|
||||
|
||||
private Fragment[] fragments;
|
||||
private AppUpdateDialog appUpdateDialog;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -74,6 +94,8 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
FragmentUtils.add(getSupportFragmentManager(), fragments, R.id.frame_layout, 0);
|
||||
MvpPre.initData();
|
||||
MvpPre.userFiles();
|
||||
|
||||
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// if (!Settings.canDrawOverlays(this)) {
|
||||
// Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
@@ -91,30 +113,31 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
// @Override
|
||||
// public void run() {
|
||||
|
||||
// 通过递归调用实现循环定时
|
||||
// 通过递归调用实现循环定时
|
||||
// new android.os.Handler().postDelayed(this, 1000);
|
||||
// }
|
||||
// }, 1000);
|
||||
//
|
||||
}
|
||||
// @Override
|
||||
// protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
// super.onActivityResult(requestCode, resultCode, data);
|
||||
// if (requestCode == 100) {
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// if (Settings.canDrawOverlays(this)) {
|
||||
// ToastUtils.showShort("已获得悬浮窗权限");
|
||||
//// showPiaoPingMessage("测试飘屏", 3000);
|
||||
// } else {
|
||||
// ToastUtils.showShort("未获得悬浮窗权限,功能无法使用");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 100) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
ToastUtils.showShort("已获得悬浮窗权限");
|
||||
// showPiaoPingMessage("测试飘屏", 3000);
|
||||
} else {
|
||||
ToastUtils.showShort("未获得悬浮窗权限,功能无法使用");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onUserInfoEvent(String event) {
|
||||
MvpPre.address_ip(event);
|
||||
MvpPre.address_ip(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +163,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
mBinding.rlMe.setOnClickListener(this);
|
||||
mBinding.ivGuanbi.setOnClickListener(this);
|
||||
mBinding.riv.setOnClickListener(this);
|
||||
mBinding.ivShouchl.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,28 +196,62 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
selectShow(0);
|
||||
} else if (id == R.id.rl_trend) {
|
||||
selectShow(1);
|
||||
} else if (id == R.id.rl_news) {
|
||||
} else if (id == R.id.rl_news) {
|
||||
selectShow(2);
|
||||
} else if (id == R.id.rl_me) {
|
||||
selectShow(3);
|
||||
//C0101我的界面
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.C0101);
|
||||
}
|
||||
else if (id == R.id.iv_guanbi) {
|
||||
} else if (id == R.id.iv_guanbi) {
|
||||
mBinding.ll.setVisibility(View.INVISIBLE);
|
||||
CommonAppContext.getInstance().isShow = false;
|
||||
CommonAppContext.getInstance().isPlaying = false;
|
||||
// if (RoomActivity.sDestroied) {
|
||||
// MvpPre.quitRoom(CommonAppContext.getInstance().playId);
|
||||
// } else {
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
// }
|
||||
}
|
||||
else if (id == R.id.riv) {
|
||||
} else if (id == R.id.riv) {
|
||||
String roomId = CommonAppContext.getInstance().playId;
|
||||
if (!TextUtils.isEmpty(roomId)) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", roomId).navigation();
|
||||
}
|
||||
} else if (id == R.id.iv_shouchl) {
|
||||
FirstChargeDialog firstChargeDialog = new FirstChargeDialog(this);
|
||||
firstChargeDialog.show();
|
||||
firstChargeDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
//首充弹窗关闭后,弹首充
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
firstChargeDialog.setOnFirstChargeListener(new FirstChargeDialog.OnFirstChargeListener() {
|
||||
@Override
|
||||
public void onFirstChargeConfirmed(FirstChargeGiftBean giftBean, int type) {
|
||||
String s = null;
|
||||
if (type == 1) {
|
||||
s = giftBean.getGift_bag().get(0).getMoney();
|
||||
|
||||
} else if (type == 2) {
|
||||
s = giftBean.getGift_bag().get(1).getMoney();
|
||||
} else if (type == 3) {
|
||||
s = giftBean.getGift_bag().get(2).getMoney();
|
||||
}
|
||||
if (s == null){
|
||||
ToastUtils.showShort("暂无礼物");
|
||||
return;
|
||||
}
|
||||
|
||||
RechargeDialogFragment.show(null, s, getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstChargeCancelled() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +337,36 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
if (CommonAppContext.getInstance().isPlaying && CommonAppContext.getInstance().isShow) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", CommonAppContext.getInstance().playId).navigation();
|
||||
}
|
||||
// Logger.i("isPlay", "onResume: " + b + "view:" + mBinding.ll.getVisibility());
|
||||
|
||||
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {
|
||||
@Override
|
||||
public void onSuccess(Long aLong) {
|
||||
if (aLong == 0) {
|
||||
mBinding.tvMessage.setVisibility(View.GONE);
|
||||
mBinding.tvMessage.setText("0");
|
||||
} else {
|
||||
mBinding.tvMessage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mBinding.tvMessage.setText(String.valueOf(aLong));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
MvpPre.getMyInfo(SpUtil.getUserId() + "");//获取首充是否需要展示
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(UnreadCountEvent event) {
|
||||
if (event.getALong() == 0) {
|
||||
mBinding.tvMessage.setVisibility(View.GONE);
|
||||
mBinding.tvMessage.setText("0");
|
||||
} else if (event.getALong() > 0) {
|
||||
mBinding.tvMessage.setText(String.valueOf(event.getALong()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -339,6 +426,30 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void appUpdate(AppUpdateModel appUpdateModel) {
|
||||
if (appUpdateModel.getCode() > getCurrentVersionCode(this)) {
|
||||
if (appUpdateDialog == null) {
|
||||
appUpdateDialog = new AppUpdateDialog(this);
|
||||
appUpdateDialog.setAppUpdateModel(appUpdateModel);
|
||||
if (appUpdateModel.getIs_force().equals("1") || getCurrentVersionCode(this) - appUpdateModel.getCode() >= 2) {
|
||||
appUpdateDialog.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
}
|
||||
appUpdateDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCurrentVersionCode(Context context) {
|
||||
try {
|
||||
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
return packageInfo.versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e("MainActivity", "Package name not found", e);
|
||||
return -1; // 如果出错,返回-1或其他适当的错误码
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRandomHotRoom(String roomId) {
|
||||
if (!TextUtils.isEmpty(roomId)) {
|
||||
@@ -359,18 +470,23 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
||||
|
||||
/**
|
||||
* 启动获取一次用户信息
|
||||
*
|
||||
*
|
||||
*/
|
||||
// @Override
|
||||
// public void UserFilesSuccess(UserBean userBean) {
|
||||
// MyApplication.getInstance().setUser(userBean);
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void myInfoSuccess(FirstChargeBean data) {
|
||||
if (data.getPermission() == 1) {
|
||||
mBinding.ivShouchl.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.ivShouchl.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import android.app.Activity;
|
||||
|
||||
import com.qxcm.moduleutil.activity.IPresenter;
|
||||
import com.qxcm.moduleutil.activity.IView;
|
||||
import com.qxcm.moduleutil.bean.AppUpdateModel;
|
||||
import com.qxcm.moduleutil.bean.FirstChargeBean;
|
||||
|
||||
|
||||
public final class HomeContacts {
|
||||
@@ -12,7 +14,7 @@ public final class HomeContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
|
||||
// void appUpdate(AppUpdateModel appUpdateModel);
|
||||
void appUpdate(AppUpdateModel appUpdateModel);
|
||||
|
||||
void setRandomHotRoom(String roomId);
|
||||
|
||||
@@ -21,6 +23,7 @@ public final class HomeContacts {
|
||||
// void UserFilesSuccess(UserBean userBean);
|
||||
|
||||
void quitSuccess(String roomId);
|
||||
void myInfoSuccess(FirstChargeBean data);
|
||||
}
|
||||
|
||||
public interface IHomePre extends IPresenter {
|
||||
@@ -42,5 +45,6 @@ public final class HomeContacts {
|
||||
|
||||
void address_ip(String ip);
|
||||
|
||||
void getMyInfo(String userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import androidx.annotation.RequiresApi;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.qxcm.modulemain.contacts.HomeContacts;
|
||||
import com.qxcm.moduleutil.bean.AppUpdateModel;
|
||||
import com.qxcm.moduleutil.bean.FirstChargeBean;
|
||||
import com.qxcm.moduleutil.bean.UserBean;
|
||||
import com.qxcm.moduleutil.http.BaseObserver;
|
||||
import com.qxcm.moduleutil.presenter.BasePresenter;
|
||||
@@ -33,22 +35,17 @@ public class HomePresenter extends BasePresenter<HomeContacts.View> implements H
|
||||
|
||||
@Override
|
||||
public void appUpdate() {
|
||||
// getApi().appUpdate(new BaseObserver<AppUpdateModel>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(AppUpdateModel appUpdataModel) {
|
||||
// MvpRef.get().appUpdate(appUpdataModel);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
api.appUpdate(new BaseObserver<AppUpdateModel>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AppUpdateModel appUpdataModel) {
|
||||
MvpRef.get().appUpdate(appUpdataModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,4 +329,24 @@ public class HomePresenter extends BasePresenter<HomeContacts.View> implements H
|
||||
// }
|
||||
// }, 6 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyInfo(String userId) {
|
||||
api.firstCharge( userId,new BaseObserver<FirstChargeBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(FirstChargeBean myInfoResp) {
|
||||
MvpRef.get().myInfoSuccess(myInfoResp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:layout_toRightOf="@+id/iv_news"
|
||||
|
||||
android:background="@drawable/ease_bg_msg_count"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/dp_5"
|
||||
@@ -213,6 +212,16 @@
|
||||
android:layout_marginRight="@dimen/dp_14"
|
||||
android:src="@mipmap/icon_guanbi" />
|
||||
</com.qxcm.moduleutil.widget.DropView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_shouchl"
|
||||
android:layout_width="@dimen/dp_57"
|
||||
android:layout_height="@dimen/dp_57"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:layout_marginBottom="@dimen/dp_100"
|
||||
android:src="@mipmap/shouchl" />
|
||||
</RelativeLayout>
|
||||
|
||||
</layout>
|
||||
Reference in New Issue
Block a user