1.4.0509 增加mvvm,修改主页
This commit is contained in:
@@ -9,7 +9,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.base.mvp.BaseMvpActivity;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.AppUtil;
|
||||
import com.hjq.toast.Toaster;
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class CleanupActivity extends BaseActivity {
|
||||
public class CleanupActivity extends BaseMvpActivity {
|
||||
private static final String TAG = CleanupActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.tv_clean)
|
||||
@@ -38,6 +38,16 @@ public class CleanupActivity extends BaseActivity {
|
||||
return R.layout.activity_cleanup;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
|
||||
@@ -6,14 +6,14 @@ import android.view.View;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.base.mvp.BaseMvpActivity;
|
||||
import com.aoleyun.sn.view.ToggleButton;
|
||||
import com.hjq.toast.Toaster;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class EyeProtectionActivity extends BaseActivity {
|
||||
public class EyeProtectionActivity extends BaseMvpActivity {
|
||||
|
||||
@BindView(R.id.cl_exit)
|
||||
ConstraintLayout cl_exit;
|
||||
@@ -33,6 +33,15 @@ public class EyeProtectionActivity extends BaseActivity {
|
||||
return R.layout.activity_eye_protection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.base.mvp.BaseMvpActivity;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.SysSettingUtils;
|
||||
@@ -26,7 +26,7 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
public class CheckNetActivity extends BaseActivity implements CheckNetContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
public class CheckNetActivity extends BaseMvpActivity implements CheckNetContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = CheckNetActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.giv_1)
|
||||
@@ -65,13 +65,23 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
return R.layout.activity_checknet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mCheckNetPresenter = new CheckNetPresenter(this);
|
||||
mCheckNetPresenter.attachView(this);
|
||||
mCheckNetPresenter.setProvider(this);
|
||||
mCheckNetPresenter.setLifecycle(lifecycleSubject);
|
||||
mCheckNetPresenter.setLifecycle(getLifecycleSubject());
|
||||
JGYUtils.startServices(CheckNetActivity.this);
|
||||
Log.e(TAG, "initView: " + "start request");
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.aoleyun.sn.activity.checknet;
|
||||
|
||||
import com.aoleyun.sn.base.BasePresenter;
|
||||
import com.aoleyun.sn.base.BaseView;
|
||||
import com.aoleyun.sn.base.mvp.BasePresenter;
|
||||
import com.aoleyun.sn.base.mvp.BaseView;
|
||||
|
||||
public class CheckNetContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.aoleyun.sn.activity.main;
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.aoleyun.sn.base.BasePresenter;
|
||||
import com.aoleyun.sn.base.BaseView;
|
||||
import com.aoleyun.sn.base.mvp.BasePresenter;
|
||||
import com.aoleyun.sn.base.mvp.BaseView;
|
||||
import com.aoleyun.sn.bean.StudentsInfo;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
@@ -12,8 +12,6 @@ public class MainAContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
/*获取设备锁定状态*/
|
||||
void getLockedState();
|
||||
/*获取设备二维码*/
|
||||
void getQrCode(boolean loocked);
|
||||
/*获取学生信息*/
|
||||
void getStudesInfo();
|
||||
/*获取电子书包激活码*/
|
||||
@@ -37,8 +35,6 @@ public class MainAContact {
|
||||
public interface MainView extends BaseView {
|
||||
/*获取设备锁定状态*/
|
||||
void setLockedState(boolean loocked);
|
||||
/*获取设备二维码*/
|
||||
void setQrCode(Bitmap qrcode);
|
||||
/*获取学生信息*/
|
||||
void setStudesInfo(StudentsInfo studesInfo);
|
||||
/*获取电子书包激活码*/
|
||||
|
||||
@@ -86,14 +86,6 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getQrCode(boolean loocked) {
|
||||
String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial(mContext));
|
||||
Log.e("getQRCode", "setImageAndText: " + encryptString);
|
||||
Bitmap bitmap = Utils.createQRImage(encryptString, 400, 400);
|
||||
mView.setQrCode(bitmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过sn获取用户信息
|
||||
*/
|
||||
@@ -122,7 +114,6 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getExclusiveAdminApp() {
|
||||
NetInterfaceManager.getInstance().getExclusiveAdminAppObservable()
|
||||
@@ -163,7 +154,6 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
NetInterfaceManager.getInstance().getPublicIp(lifecycle, ip -> mView.setPublicIp(ip));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void buttonCheckUpdate(View view) {
|
||||
checkUpdateInfo();
|
||||
|
||||
@@ -23,21 +23,20 @@ import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.activity.requestlog.RequestLogActivity;
|
||||
import com.aoleyun.sn.activity.update.UpdateActivity;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.base.mvvm.BaseMvvmActivity;
|
||||
import com.aoleyun.sn.bean.StudentsInfo;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.comm.PackageNames;
|
||||
import com.aoleyun.sn.databinding.ActivityMainBinding;
|
||||
import com.aoleyun.sn.dialog.UpdateDialog;
|
||||
import com.aoleyun.sn.service.main.MainService;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.SPUtils;
|
||||
import com.aoleyun.sn.utils.SysSettingUtils;
|
||||
@@ -51,8 +50,6 @@ import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
@@ -65,7 +62,7 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import static android.os.BatteryManager.EXTRA_LEVEL;
|
||||
import static android.os.BatteryManager.EXTRA_VOLTAGE;
|
||||
|
||||
public class MainActivity extends BaseActivity implements MainAContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> implements MainAContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
@@ -73,67 +70,31 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
public static final String UPDATE_LOCKED_STATUS = "UPDATE_LOCKED_STATUS";
|
||||
public static final String REFRESHACTION = BuildConfig.APPLICATION_ID + ".REFRESH";
|
||||
|
||||
public class BtnClick {
|
||||
public void exit(View view) {
|
||||
lazyExit();
|
||||
}
|
||||
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView back;
|
||||
@BindView(R.id.tv_version)
|
||||
TextView tv_version;
|
||||
@BindView(R.id.tv_activation_time)
|
||||
TextView tv_activation_time;
|
||||
@BindView(R.id.iv_update)
|
||||
ImageView iv_update;
|
||||
@BindView(R.id.iv_active_state)
|
||||
ImageView iv_active_state;
|
||||
@BindView(R.id.iv_head)
|
||||
ImageView iv_head;
|
||||
@BindView(R.id.tv_name)
|
||||
TextView tv_name;
|
||||
@BindView(R.id.tv_batch)
|
||||
TextView tv_batch;
|
||||
@BindView(R.id.tv_number)
|
||||
TextView tv_number;
|
||||
@BindView(R.id.tv_class)
|
||||
TextView tv_class;
|
||||
@BindView(R.id.tv_model)
|
||||
TextView tv_model;
|
||||
@BindView(R.id.cl_ota)
|
||||
ConstraintLayout cl_ota;
|
||||
@BindView(R.id.tv_system_version)
|
||||
TextView tv_system_version;
|
||||
public void log(View view) {
|
||||
continuousClick(COUNTS, DURATION);
|
||||
}
|
||||
|
||||
@BindView(R.id.tv_serial)
|
||||
TextView tv_serial;
|
||||
@BindView(R.id.tv_imei)
|
||||
TextView tv_imei;
|
||||
@BindView(R.id.tv_mac)
|
||||
TextView tv_mac;
|
||||
public void logcat(View view) {
|
||||
if (ApkUtils.isAvailable(MainActivity.this, PackageNames.AI_LOGGER_PACKAGE)) {
|
||||
if (!ApkUtils.openPackage(MainActivity.this, PackageNames.AI_LOGGER_PACKAGE, PackageNames.AI_LOGGER_MAIN_CLASS)) {
|
||||
Toaster.showShort("打开失败");
|
||||
}
|
||||
} else {
|
||||
Toaster.showShort("应用未安装");
|
||||
}
|
||||
}
|
||||
|
||||
@BindView(R.id.tv_bind_statu)
|
||||
TextView tv_bind_statu;
|
||||
@BindView(R.id.tv_bind_status)
|
||||
TextView tv_bind_status;
|
||||
@BindView(R.id.cl_bind)
|
||||
ConstraintLayout cl_bind;
|
||||
@BindView(R.id.cl_qrcode)
|
||||
ConstraintLayout cl_qrcode;
|
||||
@BindView(R.id.iv_qrcode)
|
||||
ImageView iv_qrcode;
|
||||
@BindView(R.id.iv_qrcode2)
|
||||
ImageView iv_qrcode2;
|
||||
@BindView(R.id.tv_bind_time)
|
||||
TextView tv_bind_time;
|
||||
public void update(View view) {
|
||||
startActivity(new Intent(MainActivity.this, UpdateActivity.class));
|
||||
}
|
||||
|
||||
@OnClick({R.id.iv_back, R.id.tv_title})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.iv_back:
|
||||
lazyExit();
|
||||
break;
|
||||
case R.id.tv_title:
|
||||
continuousClick(COUNTS, DURATION);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
public void openOta(View view) {
|
||||
JGYUtils.getInstance().openRomOta();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,9 +133,25 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
String defaultDesktop = mMMKV.decodeString(CommonConfig.DEFAULT_DESKTOP_PACKAGE_NAME, "");
|
||||
Log.e(TAG, "initView: defaultDesktop = " + defaultDesktop);
|
||||
String defaultLauncher = mMMKV.decodeString(CommonConfig.DEFAULT_LAUNCHER_PACKAGE_NAME, "");
|
||||
@@ -186,14 +163,14 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
|
||||
mMainAPresenter = new MainAPresenter(this);
|
||||
mMainAPresenter.attachView(this);
|
||||
mMainAPresenter.setLifecycle(lifecycleSubject);
|
||||
mMainAPresenter.setLifecycle(getLifecycleSubject());
|
||||
Log.e(TAG, "initView: " + Build.MODEL);
|
||||
if ("YX-T01".equalsIgnoreCase(Build.MODEL)) {
|
||||
cl_bind.setVisibility(View.GONE);
|
||||
cl_qrcode.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.clBind.setVisibility(View.GONE);
|
||||
mViewDataBinding.clQrcode.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cl_bind.setVisibility(View.VISIBLE);
|
||||
cl_qrcode.setVisibility(View.GONE);
|
||||
mViewDataBinding.clBind.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.clQrcode.setVisibility(View.GONE);
|
||||
}
|
||||
JGYUtils.startServices(MainActivity.this);
|
||||
getDevicesInfo();
|
||||
@@ -209,12 +186,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
} else {
|
||||
|
||||
}
|
||||
iv_update.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(MainActivity.this, UpdateActivity.class));
|
||||
}
|
||||
});
|
||||
// setStoreUpdateListener(bt_checkupdate);
|
||||
registerReceiver();
|
||||
|
||||
@@ -274,31 +245,31 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
}
|
||||
|
||||
private void getDevicesInfo() {
|
||||
tv_model.setText(Build.MODEL);
|
||||
mViewDataBinding.tvModel.setText(Build.MODEL);
|
||||
String sn = Utils.getSerial(this);
|
||||
Log.e(TAG, "getDevicesInfo: " + sn);
|
||||
Log.e(TAG, "getDevicesInfo: " + Utils.getMac());
|
||||
if (TextUtils.isEmpty(sn)) {
|
||||
tv_serial.setText(getString(R.string.no_data));
|
||||
mViewDataBinding.tvSerial.setText(getString(R.string.no_data));
|
||||
} else {
|
||||
tv_serial.setText(sn);
|
||||
mViewDataBinding.tvSerial.setText(sn);
|
||||
}
|
||||
getIMEI();
|
||||
setMac();
|
||||
checkSnError(sn);
|
||||
tv_version.setText(BuildConfig.VERSION_NAME);
|
||||
mViewDataBinding.tvVersion.setText(BuildConfig.VERSION_NAME);
|
||||
//获取自定义版本号
|
||||
Log.e(TAG, "getDevicesInfo: CustomVersion: " + Utils.getCustomVersion());
|
||||
Log.e(TAG, "getDevicesInfo: RomVersion: " + Utils.getRomVersion());
|
||||
tv_system_version.setText(Utils.getCustomVersion());
|
||||
mViewDataBinding.tvSystemVersion.setText(Utils.getCustomVersion());
|
||||
}
|
||||
|
||||
private void getIMEI() {
|
||||
if (!Utils.NOSN.equalsIgnoreCase(Utils.getSerial(this))) {
|
||||
tv_imei.setText(Utils.getIMEI(this, 1));
|
||||
mViewDataBinding.tvImei.setText(Utils.getIMEI(this, 1));
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(Utils.getIMEI(this, 1))) {
|
||||
tv_imei.setText(Utils.getIMEI(this, 1));
|
||||
mViewDataBinding.tvImei.setText(Utils.getIMEI(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,9 +277,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
private void setMac() {
|
||||
String macaddr = Utils.getAndroid10MAC(this);
|
||||
if (TextUtils.isEmpty(macaddr)) {
|
||||
tv_mac.setText("获取失败");
|
||||
mViewDataBinding.tvMac.setText("获取失败");
|
||||
} else {
|
||||
tv_mac.setText(macaddr);
|
||||
mViewDataBinding.tvMac.setText(macaddr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +317,14 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
bindService(intent, serviceConnect, BIND_AUTO_CREATE);
|
||||
startService(intent);
|
||||
mMainAPresenter.getLockedState();
|
||||
mViewModel.getQrCodeData().observe(this, new androidx.lifecycle.Observer<Bitmap>() {
|
||||
@Override
|
||||
public void onChanged(Bitmap bitmap) {
|
||||
mViewDataBinding.ivQrcode.setImageBitmap(bitmap);
|
||||
mViewDataBinding.ivQrcode2.setImageBitmap(bitmap);
|
||||
}
|
||||
});
|
||||
mViewModel.getQrCode();
|
||||
}
|
||||
|
||||
MainService.MainBinder mMainBinder;
|
||||
@@ -380,24 +359,16 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
SysSettingUtils.setEnableSetting(this);
|
||||
}
|
||||
mMainAPresenter.getEBagCode();
|
||||
mMainAPresenter.getQrCode(loocked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQrCode(Bitmap qrcode) {
|
||||
iv_qrcode.setImageBitmap(qrcode);
|
||||
iv_qrcode2.setImageBitmap(qrcode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStudesInfo(StudentsInfo studesInfo) {
|
||||
if (studesInfo == null) {
|
||||
iv_active_state.setImageDrawable(getDrawable(R.drawable.icon_inactivated));
|
||||
mViewDataBinding.tvActivationTime.setText("未激活");
|
||||
return;
|
||||
}
|
||||
iv_active_state.setImageDrawable(getDrawable(R.drawable.icon_activated));
|
||||
long activation_time = studesInfo.getActivation_time();
|
||||
tv_activation_time.setText("激活时间:" + TimeUtils.getActivationTime(activation_time));
|
||||
mViewDataBinding.tvActivationTime.setText("激活时间:" + TimeUtils.getActivationTime(activation_time));
|
||||
int trade_type = studesInfo.getTrade_type();
|
||||
String sno = studesInfo.getSno();
|
||||
String realname = studesInfo.getRealname();
|
||||
@@ -407,9 +378,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
int bind_statu = studesInfo.getBind_status();
|
||||
if (bind_statu == 1) {
|
||||
String phone = studesInfo.getBind_mobile();
|
||||
tv_bind_status.setText("绑定号码:" + phone);
|
||||
mViewDataBinding.tvBindStatus.setText("绑定号码:" + phone);
|
||||
} else {
|
||||
tv_bind_status.setText("未绑定");
|
||||
mViewDataBinding.tvBindStatus.setText("未绑定");
|
||||
}
|
||||
|
||||
settradeType(trade_type);
|
||||
@@ -473,30 +444,30 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
}
|
||||
|
||||
public void setBatchText(String text, int visibility) {
|
||||
tv_batch.setText(text);
|
||||
mViewDataBinding.tvBatch.setText(text);
|
||||
// tv_batch.setVisibility(visibility);
|
||||
}
|
||||
|
||||
public void setClassText(String text, int visibility) {
|
||||
tv_class.setText(text);
|
||||
mViewDataBinding.tvClass.setText(text);
|
||||
// layout_class.setVisibility(visibility);
|
||||
}
|
||||
|
||||
public void setNumberText(String text, int visibility) {
|
||||
tv_number.setText(text);
|
||||
mViewDataBinding.tvNumber.setText(text);
|
||||
// layout_number.setVisibility(visibility);
|
||||
}
|
||||
|
||||
public void setNameText(String text, int visibility) {
|
||||
tv_name.setText(text);
|
||||
mViewDataBinding.tvName.setText(text);
|
||||
// layout_name.setVisibility(visibility);
|
||||
}
|
||||
|
||||
public void setIv_head(String url) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
Glide.with(iv_head).load(getDrawable(R.drawable.default_avatar)).into(iv_head);
|
||||
Glide.with(mViewDataBinding.ivHead).load(getDrawable(R.drawable.default_avatar)).into(mViewDataBinding.ivHead);
|
||||
} else {
|
||||
Glide.with(iv_head).load(url).error(R.drawable.default_avatar).into(iv_head);
|
||||
Glide.with(mViewDataBinding.ivHead).load(url).error(R.drawable.default_avatar).into(mViewDataBinding.ivHead);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,7 +647,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
setNameText("", View.GONE);
|
||||
setClassText("", View.GONE);
|
||||
setBatchText("", View.GONE);
|
||||
Glide.with(iv_head).load(getDrawable(R.drawable.default_avatar)).error(R.drawable.default_avatar).into(iv_head);
|
||||
Glide.with(mViewDataBinding.ivHead).load(getDrawable(R.drawable.default_avatar)).error(R.drawable.default_avatar).into(mViewDataBinding.ivHead);
|
||||
SysSettingUtils.setEnableSetting(MainActivity.this);
|
||||
}
|
||||
}
|
||||
@@ -787,4 +758,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
private String getBatteryVolt(int batteryVolt) {
|
||||
return String.format("%.3f V", batteryVolt / 1000.0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.aoleyun.sn.activity.main;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.aoleyun.sn.base.mvvm.BaseViewModel;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.databinding.ActivityMainBinding;
|
||||
import com.aoleyun.sn.utils.AES.CXAESUtil;
|
||||
import com.aoleyun.sn.utils.Utils;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEvent> {
|
||||
@Override
|
||||
public ActivityMainBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
private MutableLiveData<Bitmap> mQrCodeData =new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<Bitmap> getQrCodeData() {
|
||||
return mQrCodeData;
|
||||
}
|
||||
|
||||
public void getQrCode(){
|
||||
String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial(getCtx()));
|
||||
Log.e("getQRCode", "setImageAndText: " + encryptString);
|
||||
Bitmap bitmap = Utils.createQRImage(encryptString, 400, 400);
|
||||
mQrCodeData.setValue(bitmap);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.base.mvp.BaseMvpActivity;
|
||||
import com.aoleyun.sn.rlog.LogBean;
|
||||
import com.aoleyun.sn.rlog.LogDBManager;
|
||||
|
||||
@@ -17,7 +17,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class RequestLogActivity extends BaseActivity implements RequestLogContact.MainView {
|
||||
public class RequestLogActivity extends BaseMvpActivity implements RequestLogContact.MainView {
|
||||
private static final String TAG = RequestLogActivity.class.getSimpleName();
|
||||
private RequestLogAdapter mAdapter;
|
||||
|
||||
@@ -53,12 +53,22 @@ public class RequestLogActivity extends BaseActivity implements RequestLogContac
|
||||
return R.layout.activity_request_log;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new RequestLogPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mAdapter = new RequestLogAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.aoleyun.sn.activity.requestlog;
|
||||
|
||||
import com.aoleyun.sn.base.BasePresenter;
|
||||
import com.aoleyun.sn.base.BaseView;
|
||||
import com.aoleyun.sn.base.mvp.BasePresenter;
|
||||
import com.aoleyun.sn.base.mvp.BaseView;
|
||||
import com.aoleyun.sn.rlog.LogBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.adapter.AppUpdateAdapter;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.base.mvp.BaseMvpActivity;
|
||||
import com.aoleyun.sn.bean.AppUpdateInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class UpdateActivity extends BaseActivity implements UpdateContact.UpdateView {
|
||||
public class UpdateActivity extends BaseMvpActivity implements UpdateContact.UpdateView {
|
||||
|
||||
private static final String TAG = UpdateActivity.class.getSimpleName();
|
||||
@BindView(R.id.root)
|
||||
@@ -44,12 +44,22 @@ public class UpdateActivity extends BaseActivity implements UpdateContact.Update
|
||||
return R.layout.activity_update;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new UpdatePresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.setLifecycle(getLifecycleSubject());
|
||||
|
||||
mAppUpdateAdapter = new AppUpdateAdapter();
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(UpdateActivity.this));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.aoleyun.sn.activity.update;
|
||||
|
||||
import com.aoleyun.sn.base.BasePresenter;
|
||||
import com.aoleyun.sn.base.BaseView;
|
||||
import com.aoleyun.sn.base.mvp.BasePresenter;
|
||||
import com.aoleyun.sn.base.mvp.BaseView;
|
||||
import com.aoleyun.sn.bean.AppUpdateInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -3,39 +3,22 @@ package com.aoleyun.sn.base;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.ContentView;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
public abstract class BaseActivity extends BaseRxActivity {
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||
public final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
setBar();
|
||||
//状态栏改变放在setContentView前后有所不同
|
||||
setContentView(this.getLayoutId());
|
||||
initView();
|
||||
initData();
|
||||
public BaseActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
private void setBar() {
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// StatusBarUtil.init(this);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
@@ -51,82 +34,5 @@ public abstract class BaseActivity extends AppCompatActivity implements Lifecycl
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
public abstract int getLayoutId();
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
public abstract void initView();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
public abstract void initData();
|
||||
|
||||
|
||||
public BaseActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ContentView
|
||||
public BaseActivity(@LayoutRes int contentLayoutId) {
|
||||
super(contentLayoutId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
lifecycleSubject.onNext(ActivityEvent.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
lifecycleSubject.onNext(ActivityEvent.RESUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onPause() {
|
||||
lifecycleSubject.onNext(ActivityEvent.PAUSE);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStop() {
|
||||
lifecycleSubject.onNext(ActivityEvent.STOP);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onDestroy() {
|
||||
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
protected abstract int getLayoutId();
|
||||
}
|
||||
38
app/src/main/java/com/aoleyun/sn/base/BaseActivityLight.java
Normal file
38
app/src/main/java/com/aoleyun/sn/base/BaseActivityLight.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.aoleyun.sn.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public abstract class BaseActivityLight extends BaseRxActivity {
|
||||
|
||||
public BaseActivityLight() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// StatusBarUtil.init(this);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.aoleyun.sn.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public abstract class BaseDataBindingActivity extends BaseRxActivity {
|
||||
|
||||
public BaseDataBindingActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// StatusBarUtil.init(this);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
protected abstract void initView();
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
protected abstract void initData();
|
||||
}
|
||||
94
app/src/main/java/com/aoleyun/sn/base/BaseRxActivity.java
Normal file
94
app/src/main/java/com/aoleyun/sn/base/BaseRxActivity.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.aoleyun.sn.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* {@link com.trello.rxlifecycle4.components.RxActivity}
|
||||
* copied form RxActivity}
|
||||
*/
|
||||
public abstract class BaseRxActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycleSubject() {
|
||||
return lifecycleSubject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
lifecycleSubject.onNext(ActivityEvent.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
lifecycleSubject.onNext(ActivityEvent.RESUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onPause() {
|
||||
lifecycleSubject.onNext(ActivityEvent.PAUSE);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStop() {
|
||||
lifecycleSubject.onNext(ActivityEvent.STOP);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onDestroy() {
|
||||
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.aoleyun.sn.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public abstract class BaseTransparentActivity extends BaseRxActivity {
|
||||
|
||||
public BaseTransparentActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// StatusBarUtil.init(this);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(setNightMode())
|
||||
.fitWindow(setfitWindow())
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(setNightMode())
|
||||
.fitWindow(setfitWindow())
|
||||
.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
/**
|
||||
* @return 是否是黑色状态栏
|
||||
*/
|
||||
protected abstract boolean setNightMode();
|
||||
|
||||
/**
|
||||
* @return 是否是入侵
|
||||
*/
|
||||
protected abstract boolean setfitWindow();
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.aoleyun.sn.base;
|
||||
|
||||
public interface BaseView {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.aoleyun.sn.base.mvp;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.aoleyun.sn.base.BaseTransparentActivity;
|
||||
|
||||
public abstract class BaseMvpActivity extends BaseTransparentActivity {
|
||||
|
||||
public BaseMvpActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutId());
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
protected abstract void initView();
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
protected abstract void initData();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.sn.base;
|
||||
package com.aoleyun.sn.base.mvp;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -7,4 +7,4 @@ public interface BasePresenter<V extends BaseView> {
|
||||
void attachView(@NonNull V view);
|
||||
|
||||
void detachView();
|
||||
}
|
||||
}
|
||||
4
app/src/main/java/com/aoleyun/sn/base/mvp/BaseView.java
Normal file
4
app/src/main/java/com/aoleyun/sn/base/mvp/BaseView.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package com.aoleyun.sn.base.mvp;
|
||||
|
||||
public interface BaseView {
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.aoleyun.sn.base.mvvm;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.aoleyun.sn.base.BaseTransparentActivity;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
public abstract class BaseMvvmActivity<VM extends ViewModel, VDB extends ViewDataBinding> extends BaseTransparentActivity {
|
||||
|
||||
private static final String TAG = BaseMvvmActivity.class.getSimpleName();
|
||||
|
||||
protected VM mViewModel;
|
||||
protected VDB mViewDataBinding;
|
||||
protected Class<VM> vmClass;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//ViewDataBinding
|
||||
mViewDataBinding = DataBindingUtil.setContentView(this, getLayoutId());
|
||||
mViewDataBinding.setLifecycleOwner(this);
|
||||
//ViewModel
|
||||
vmClass = (Class<VM>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
boolean isAbstract = Modifier.isAbstract(vmClass.getModifiers());
|
||||
Log.e(TAG, "isLocalClass:" + vmClass.getSimpleName().equals(ViewModel.class.getSimpleName()) + " isAbstract:" + isAbstract);
|
||||
if (!isAbstract) {//不是一个抽象类
|
||||
mViewModel = new ViewModelProvider(this).get(vmClass);
|
||||
}
|
||||
initDataBinding();
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
protected abstract void initDataBinding();
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
protected abstract void initView();
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
protected abstract void initData();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.aoleyun.sn.base.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* 所有viewmodel的基类
|
||||
*/
|
||||
public abstract class BaseViewModel<VDB extends ViewDataBinding, T> extends ViewModel implements ViewDataBindingCallback {
|
||||
|
||||
/**
|
||||
* 当前viewmodel对应的页面binding
|
||||
*/
|
||||
protected VDB binding;
|
||||
|
||||
@Override
|
||||
public void setVDBinding(ViewDataBinding vdBinding) {
|
||||
|
||||
binding = (VDB) vdBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VDB getVDBinding() {
|
||||
if (binding == null) {
|
||||
throw new NullPointerException("BaseViewModel >> getVDBinding >> null!!!");
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上下文
|
||||
*/
|
||||
private WeakReference<Context> ctx;
|
||||
|
||||
@Override
|
||||
public void setCtx(Context context) {
|
||||
if (ctx == null) {
|
||||
ctx = new WeakReference<>(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getCtx() {
|
||||
if (ctx == null) {
|
||||
throw new NullPointerException("BaseViewModel >> getCtx >> null!!!");
|
||||
}
|
||||
return ctx.get();
|
||||
}
|
||||
|
||||
|
||||
public abstract void onDestroy();
|
||||
|
||||
private BehaviorSubject<T> mBehaviorSubject;
|
||||
|
||||
@Override
|
||||
public void setLifecycle(BehaviorSubject subject) {
|
||||
this.mBehaviorSubject = (BehaviorSubject<T>) subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BehaviorSubject<T> getLifecycle() {
|
||||
return mBehaviorSubject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.aoleyun.sn.base.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public interface ViewDataBindingCallback<VDB extends ViewDataBinding, T> {
|
||||
|
||||
void setVDBinding(VDB binding);
|
||||
|
||||
VDB getVDBinding() throws NullPointerException;
|
||||
|
||||
void setCtx(Context context);
|
||||
|
||||
Context getCtx() throws NullPointerException;
|
||||
|
||||
void setLifecycle(BehaviorSubject<T> subject);
|
||||
|
||||
BehaviorSubject<T> getLifecycle();
|
||||
}
|
||||
@@ -19,4 +19,7 @@ public class PackageNames {
|
||||
public static final String LEARNING_DESKTOP = "com.aoleyunos.dop2";
|
||||
public static final String YIXUEPAI_DESKTOP = "com.ygyb.yischool";
|
||||
|
||||
public static final String AI_LOGGER_PACKAGE = "com.aoleyun.ailog";
|
||||
public static final String AI_LOGGER_MAIN_CLASS = "com.aoleyun.ailog.activity.main.MainActivity";
|
||||
|
||||
}
|
||||
|
||||
@@ -889,9 +889,9 @@ public class NetInterfaceManager {
|
||||
.getUpdateApi().getUpdate(PackageNames.AILOG, JGYUtils.getInstance().checkAppPlatform());
|
||||
|
||||
Observable.zip(infoUpdateObservable, storeUpdateObservable, desktopUpdateObservable,
|
||||
notifyUpdateObservable, browserUpdateObservable,ailogUpdateObservable,
|
||||
notifyUpdateObservable, browserUpdateObservable, ailogUpdateObservable,
|
||||
new Function6<BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>,
|
||||
BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>,BaseResponse<AppUpdateInfo>,
|
||||
BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>,
|
||||
List<AppUpdateInfo>>() {
|
||||
@Override
|
||||
public List<AppUpdateInfo> apply
|
||||
@@ -979,7 +979,7 @@ public class NetInterfaceManager {
|
||||
.getUpdateApi().getUpdate(desktop, JGYUtils.getInstance().checkAppPlatform());
|
||||
|
||||
Observable.zip(infoUpdateObservable, storeUpdateObservable, desktopUpdateObservable,
|
||||
notifyUpdateObservable, browserUpdateObservable, learningDesktopObservable,ailogUpdateObservable,
|
||||
notifyUpdateObservable, browserUpdateObservable, learningDesktopObservable, ailogUpdateObservable,
|
||||
new Function7<BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>,
|
||||
BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, List<AppUpdateInfo>>() {
|
||||
@Override
|
||||
@@ -1343,6 +1343,12 @@ public class NetInterfaceManager {
|
||||
}
|
||||
mMMKV.encode(CommonConfig.DEFAULT_DESKTOP_PACKAGE_NAME, "com.aoleyunos.dop3");
|
||||
setDefaultDesktop("com.aoleyunos.dop3");
|
||||
} else if (
|
||||
// TODO: 2024/5/9 YXPC2的问题,默认启动桌面就是他们,这个需要修改,去根据型号进行判断,默认桌面要是易学派
|
||||
JGYUtils.getInstance().checkAppPlatform() == JGYUtils.C2Platform
|
||||
) {
|
||||
JGYUtils.getInstance().showApp(PackageNames.YIXUEPAI_DESKTOP);
|
||||
JGYUtils.getInstance().setYxpDefaultDesktop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1442,13 +1448,13 @@ public class NetInterfaceManager {
|
||||
connectMode = ConnectMode.ONE_MINUTE;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_DEVELOPER, connectMode)) {
|
||||
Log.e(TAG, "getDeveloper: cache2" );
|
||||
Log.e(TAG, "getDeveloper: cache2");
|
||||
getDeveloper(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = cacheHelper.getAsString(UrlAddress.GET_DEVELOPER);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
Log.e(TAG, "getDeveloper: cache2" );
|
||||
Log.e(TAG, "getDeveloper: cache2");
|
||||
getDeveloper(lifecycle, callback);
|
||||
} else {
|
||||
// Gson gson = new Gson();
|
||||
@@ -2282,11 +2288,12 @@ public class NetInterfaceManager {
|
||||
// Log.e( "getLockedState", "onNext: " + "state changed , reset devices");
|
||||
// Utils.doMasterClear(mContext);
|
||||
// }
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.C2Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.YXPD1Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G11Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform
|
||||
// TODO: 2024/5/9 C2 默认易学派
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.C2Platform
|
||||
// || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
|
||||
// || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.YXPD1Platform
|
||||
// || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G11Platform
|
||||
// || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform
|
||||
) {
|
||||
JGYUtils.getInstance().showApp(PackageNames.YIXUEPAI_DESKTOP);
|
||||
JGYUtils.getInstance().setYxpDefaultDesktop();
|
||||
@@ -2534,7 +2541,7 @@ public class NetInterfaceManager {
|
||||
tagSets.add(JGYUtils.YXPD1TAG);
|
||||
} else if (platform == JGYUtils.G11Platform) {
|
||||
tagSets.add(JGYUtils.G11TAG);
|
||||
} else if (platform == JGYUtils.MT8768Platform) {
|
||||
} else if (platform == JGYUtils.MT8768Platform) {
|
||||
tagSets.add(JGYUtils.MT8768Tag);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.aoleyun.sn.service.main;
|
||||
|
||||
import com.aoleyun.sn.base.BasePresenter;
|
||||
import com.aoleyun.sn.base.BaseView;
|
||||
import com.aoleyun.sn.base.mvp.BasePresenter;
|
||||
import com.aoleyun.sn.base.mvp.BaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -2022,10 +2022,36 @@ public class JGYUtils {
|
||||
|
||||
public void openOTA() {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
/**知道要跳转应用的包命与目标Activity*/
|
||||
/*知道要跳转应用的包命与目标Activity*/
|
||||
ComponentName componentName = new ComponentName("com.adups.fota", "com.adups.fota.GoogleOtaClient");
|
||||
intent.setComponent(componentName);
|
||||
mContext.startActivity(intent);
|
||||
try {
|
||||
mContext.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openOTA: " + e.getMessage());
|
||||
Toaster.show("打开失败");
|
||||
}
|
||||
}
|
||||
|
||||
public void openRomOta() {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
/*知道要跳转应用的包命与目标Activity*/
|
||||
switch (JGYUtils.getInstance().checkAppPlatform()) {
|
||||
case JGYUtils.C2Platform:
|
||||
intent.setComponent(new ComponentName("com.jintaiyi.update", "com.jintaiyi.update.activity.NoVersionActivity"));
|
||||
break;
|
||||
case JGYUtils.YXPD1Platform:
|
||||
default:
|
||||
intent.setComponent(new ComponentName("com.adups.fota", "com.adups.fota.GoogleOtaClient"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
mContext.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openOTA: " + e.getMessage());
|
||||
Toaster.show("打开失败");
|
||||
}
|
||||
}
|
||||
|
||||
public void openLauncher() {
|
||||
@@ -2416,6 +2442,7 @@ public class JGYUtils {
|
||||
openLauncher3();
|
||||
} else {
|
||||
String className = getStartClassName(pkg);
|
||||
Log.e(TAG, "setDefaultDesktop: " + className);
|
||||
if (TextUtils.isEmpty(className)) {
|
||||
openLauncher3();
|
||||
} else {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 7.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 17 KiB |
18
app/src/main/res/drawable/bg_log.xml
Normal file
18
app/src/main/res/drawable/bg_log.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 内部颜色 -->
|
||||
<solid android:color="@color/check_update_color" />
|
||||
|
||||
<!-- 圆角的幅度 -->
|
||||
<corners
|
||||
android:bottomLeftRadius="@dimen/dp_16"
|
||||
android:bottomRightRadius="@dimen/dp_16"
|
||||
android:topLeftRadius="@dimen/dp_16"
|
||||
android:topRightRadius="@dimen/dp_16" />
|
||||
|
||||
<padding
|
||||
android:bottom="@dimen/dp_4"
|
||||
android:left="@dimen/dp_10"
|
||||
android:right="@dimen/dp_10"
|
||||
android:top="@dimen/dp_4" />
|
||||
</shape>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -59,37 +59,37 @@
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_nodata"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_nodata"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:text="没有找到更新信息"
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/imageView2"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.621" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_64"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:layout_marginBottom="@dimen/dp_32"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_nodata"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textView7"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView7"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView7" />
|
||||
app:layout_constraintStart_toStartOf="@+id/imageView2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView2" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
Reference in New Issue
Block a user