version:1.6.9
fix: add:
This commit is contained in:
@@ -8,6 +8,8 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
@@ -46,6 +48,9 @@ public class StatisticsInfo {
|
||||
this.add("com.android.launcher3");
|
||||
this.add("com.android.settings");
|
||||
this.add("com.appstore.uiui");
|
||||
this.add("com.gankao.gkwxhd");
|
||||
this.add("com.jiaoguanyi.os");
|
||||
|
||||
}};
|
||||
|
||||
//将次数和时间为0的应用信息过滤掉
|
||||
@@ -58,6 +63,7 @@ public class StatisticsInfo {
|
||||
if (AppInfoList.get(i).getUsedTimebyDay() > 0
|
||||
&& AppInfoList.get(i).getTimes() > 0
|
||||
// && !AppUtil.isSystemApp(mContext, AppInfoList.get(i).getPackageName())
|
||||
&& ApkUtils.getIsCanStart(mContext, AppInfoList.get(i).getPackageName())
|
||||
&& !packageList.contains(AppInfoList.get(i).getPackageName())
|
||||
) {
|
||||
|
||||
@@ -170,8 +176,10 @@ public class StatisticsInfo {
|
||||
|
||||
//再计算一次当前应用的运行时间,因为当前应用,最后得不到MOVE_TO_BACKGROUND 的timeStamp
|
||||
AppInformation information = mapData.get(context.getPackageName());
|
||||
information.setTimeStampMoveToBackGround(now);
|
||||
information.calculateRunningTime();
|
||||
if (information!=null){
|
||||
information.setTimeStampMoveToBackGround(now);
|
||||
information.calculateRunningTime();
|
||||
}
|
||||
|
||||
return new ArrayList<>(mapData.values());
|
||||
}
|
||||
|
||||
93
app/src/main/java/com/info/sn/activity/GuideActivity.java
Normal file
93
app/src/main/java/com/info/sn/activity/GuideActivity.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.info.sn.activity;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.base.BaseActivity;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.manager.NetInterfaceManager;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class GuideActivity extends BaseActivity {
|
||||
|
||||
private PhotoView mPhotoView;
|
||||
private ConstraintLayout root;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_guide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
mPhotoView = findViewById(R.id.photoView);
|
||||
root = findViewById(R.id.root);
|
||||
root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mPhotoView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
getGuidePic();
|
||||
}
|
||||
|
||||
private void getGuidePic() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGetGuideControl()
|
||||
.compose(this.bindToLifecycle())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getGuidePic", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("getGuidePic", "onNext: ");
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = JSON.parseObject(JSONObject.toJSONString(baseResponse.data));
|
||||
String file = jsonObject.getString("file");
|
||||
if (!TextUtils.isEmpty(file)) {
|
||||
Log.e("getGuidePic", "onNext: " + file);
|
||||
Glide.with(GuideActivity.this).load(file).into(mPhotoView);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getGuidePic", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getGuidePic", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
71
app/src/main/java/com/info/sn/activity/SNUidActivity.java
Normal file
71
app/src/main/java/com/info/sn/activity/SNUidActivity.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.info.sn.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.adapter.SNUidAdapter;
|
||||
import com.info.sn.base.BaseActivity;
|
||||
import com.info.sn.bean.zuoye.SNUidBean;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class SNUidActivity extends BaseActivity {
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView mRecyclerView;
|
||||
@BindView(R.id.root)
|
||||
ConstraintLayout root;
|
||||
private SNUidAdapter mAdapter = new SNUidAdapter();
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_sn_uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(SNUidActivity.this));
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
Intent intent = getIntent();
|
||||
String jsonString = intent.getStringExtra("json");
|
||||
Log.e("TAG", "initData: " + jsonString);
|
||||
if (TextUtils.isEmpty(jsonString)) {
|
||||
ToastUtil.show("暂未获取到信息");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("card_info");
|
||||
List<SNUidBean> snUidBeads = JSON.parseArray(jsonArray.toJSONString(), SNUidBean.class);
|
||||
if (snUidBeads == null) {
|
||||
|
||||
} else {
|
||||
mAdapter.setSnUidBeans(snUidBeads);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,9 @@ import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.flyco.tablayout.SlidingTabLayout;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.activity.GuideActivity;
|
||||
import com.info.sn.activity.SNUidActivity;
|
||||
import com.info.sn.activity.selectegrade.SelecteGradeActivity;
|
||||
import com.info.sn.base.BaseActivity;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
@@ -60,7 +63,9 @@ import com.info.sn.utils.Utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -84,6 +89,9 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
@BindView(R.id.cl_update)
|
||||
ConstraintLayout cl_update;
|
||||
|
||||
@BindView(R.id.cl_vip)
|
||||
ConstraintLayout cl_vip;
|
||||
|
||||
@BindView(R.id.tv_exit)
|
||||
TextView iv_exit;
|
||||
|
||||
@@ -111,6 +119,9 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
@BindView(R.id.tv_grade)
|
||||
TextView tv_grade;
|
||||
|
||||
@BindView(R.id.tv_vip)
|
||||
TextView tv_vip;
|
||||
|
||||
@BindView(R.id.tv_version)
|
||||
TextView tv_version;
|
||||
|
||||
@@ -120,6 +131,15 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
@BindView(R.id.bt_activation)
|
||||
TextView bt_activation;
|
||||
|
||||
@BindView(R.id.bt_repurchase)
|
||||
TextView bt_repurchase;
|
||||
|
||||
@BindView(R.id.tv_guide)
|
||||
TextView tv_guide;
|
||||
|
||||
@BindView(R.id.tv_activate)
|
||||
TextView tv_activate;
|
||||
|
||||
@BindView(R.id.viewPager)
|
||||
ViewPager viewPager;
|
||||
|
||||
@@ -133,7 +153,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
mPresenter.getInfo();
|
||||
mPresenter.getSnInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,6 +204,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
Log.e(TAG, "getWeekDay: " + TimeUtils.inWeekDay(1627702095000L));
|
||||
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString());
|
||||
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString(1627702095000L));
|
||||
// DeviceManager.doMasterClear();
|
||||
}
|
||||
JPushInterface.init(this);
|
||||
if (DeviceManager.isDebugMode()) {
|
||||
@@ -200,6 +221,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
mPresenter.getQRCode();
|
||||
// mPresenter.getInfo();
|
||||
mPresenter.getUserInfo();
|
||||
mPresenter.queryPowerUserList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +235,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setClickable();
|
||||
mPresenter.getInfo();
|
||||
mPresenter.getUserInfo();
|
||||
mPresenter.getSnInfo();
|
||||
isForeground = true;
|
||||
}
|
||||
|
||||
@@ -236,7 +259,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
if (REFRESHACTION.equals(intent.getAction())) {
|
||||
mPresenter.getInfo();
|
||||
mPresenter.getSnInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,10 +389,20 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
continuousClick(COUNTS, DURATION);
|
||||
}
|
||||
});
|
||||
cl_vip.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("json", SnUidJSON);
|
||||
intent.setClass(MainActivity.this, SNUidActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
bt_activation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showActivationDialog();
|
||||
startActivity(new Intent(MainActivity.this, SelecteGradeActivity.class));
|
||||
// showActivationDialog();
|
||||
}
|
||||
});
|
||||
iv_exit.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -389,6 +422,12 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
|
||||
}
|
||||
});
|
||||
tv_guide.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(MainActivity.this, GuideActivity.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +440,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
.setOnClickBottomListener(new ActivationDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
mPresenter.checkSN();
|
||||
// mPresenter.checkSN();
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
@@ -426,12 +465,18 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowerUserList(String date) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSNFinish(int code) {
|
||||
switch (code) {
|
||||
case 200:
|
||||
case 300:
|
||||
mPresenter.getGankaoUID();
|
||||
ToastUtil.show("设备验证成功");
|
||||
break;
|
||||
case 400:
|
||||
ToastUtil.show("此设备未经授权,禁止激活");
|
||||
@@ -450,19 +495,19 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
ToastUtil.show("用户注册失败");
|
||||
} else {
|
||||
ToastUtil.show("用户注册成功");
|
||||
mPresenter.queryAvailableProduct();
|
||||
mPresenter.queryAvailableProduct(gankaoUID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAvailableProduct(@NotNull List<AvailableProduct> availableProductList) {
|
||||
setGrade(availableProductList);
|
||||
public void setAvailableProduct(@NotNull List<AvailableProduct> availableProductList, String gankaoUID) {
|
||||
setGrade(availableProductList, gankaoUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list 通过年纪获取对应的产品id
|
||||
*/
|
||||
private void setGrade(List<AvailableProduct> list) {
|
||||
private void setGrade(List<AvailableProduct> list, String gankaoUID) {
|
||||
if (list == null || list.size() == 0) {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
} else {
|
||||
@@ -490,7 +535,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
}
|
||||
switch (grade) {
|
||||
default:
|
||||
activeUser(defaultProduct);
|
||||
activeUser(defaultProduct, gankaoUID);
|
||||
break;
|
||||
// case "一年级":
|
||||
// case "二年级":
|
||||
@@ -514,8 +559,19 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param product 通过产品id激活设备
|
||||
*/
|
||||
private void activeUser(AvailableProduct product, String gankaoUID) {
|
||||
if (product == null) {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
return;
|
||||
}
|
||||
mPresenter.activeUser(product, gankaoUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeUser(int code) {
|
||||
public void activeUserFinish(int code) {
|
||||
switch (code) {
|
||||
case 10000:
|
||||
ToastUtil.show("授权成功");
|
||||
@@ -553,17 +609,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param product 通过产品id激活设备
|
||||
*/
|
||||
private void activeUser(AvailableProduct product) {
|
||||
if (product == null) {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
return;
|
||||
}
|
||||
mPresenter.activeUser(product);
|
||||
}
|
||||
|
||||
private final int COUNTS = 4; // 点击次数
|
||||
private final long DURATION = 2 * 1000; // 规定有效时间
|
||||
private long[] mHits = new long[COUNTS];
|
||||
@@ -584,13 +629,22 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
private void setClickable() {
|
||||
int isEnabled = Settings.System.getInt(getContentResolver(), activation, 0);
|
||||
if (isEnabled == 0) {
|
||||
bt_activation.setVisibility(View.VISIBLE);
|
||||
bt_repurchase.setVisibility(View.GONE);
|
||||
tv_vip.setVisibility(View.GONE);
|
||||
bt_activation.setEnabled(true);
|
||||
bt_activation.setText("激活学习系统");
|
||||
} else {
|
||||
bt_activation.setVisibility(View.GONE);
|
||||
bt_repurchase.setVisibility(View.VISIBLE);
|
||||
tv_vip.setVisibility(View.VISIBLE);
|
||||
bt_activation.setEnabled(false);
|
||||
bt_activation.setText("已激活学习系统");
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
bt_activation.setVisibility(View.VISIBLE);
|
||||
bt_repurchase.setVisibility(View.GONE);
|
||||
tv_vip.setVisibility(View.VISIBLE);
|
||||
bt_activation.setEnabled(true);
|
||||
bt_activation.setText("激活学习系统");
|
||||
}
|
||||
@@ -625,7 +679,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (REFRESHACTION.equals(intent.getAction())) {
|
||||
mPresenter.getInfo();
|
||||
mPresenter.getSnInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -667,37 +721,77 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfo(BaseResponse<UserInfo> response) {
|
||||
int code = response.code;
|
||||
if (code == 200) {
|
||||
UserInfo userInfo = response.data;
|
||||
SPUtils.put(this, Configs.isLogined, 1);
|
||||
SPUtils.put(this, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(this, "sn_id", userInfo.getId());
|
||||
if (!TextUtils.isEmpty(userInfo.getSn_name())) {
|
||||
SPUtils.put(this, "USERINFO_NAME", userInfo.getSn_name());
|
||||
tv_username.setText(userInfo.getSn_name());
|
||||
public void setSnInfo(BaseResponse<UserInfo> response) {
|
||||
if (response != null) {
|
||||
int code = response.code;
|
||||
//设备已经绑定
|
||||
if (code == 200) {
|
||||
UserInfo userInfo = response.data;
|
||||
boolean username = Settings.System.putString(getContentResolver(), "UserInfo_username", userInfo.getSn_name());
|
||||
boolean gread = Settings.System.putString(getContentResolver(), "UserInfo_grade", userInfo.getGrade());
|
||||
SPUtils.put(this, Configs.isLogined, 1);
|
||||
SPUtils.put(this, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(this, "sn_id", userInfo.getId());
|
||||
if (!TextUtils.isEmpty(userInfo.getSn_name())) {
|
||||
SPUtils.put(this, "USERINFO_NAME", userInfo.getSn_name());
|
||||
tv_username.setText(userInfo.getSn_name());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getSchool())) {
|
||||
SPUtils.put(this, "USERINFO_SCHOOL", userInfo.getSchool());
|
||||
tv_school.setText(userInfo.getSchool());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getGrade())) {
|
||||
SPUtils.put(this, "USERINFO_GRADE", userInfo.getGrade());
|
||||
tv_grade.setText(userInfo.getGrade());
|
||||
}
|
||||
mPresenter.getLocked();
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getSchool())) {
|
||||
SPUtils.put(this, "USERINFO_SCHOOL", userInfo.getSchool());
|
||||
tv_school.setText(userInfo.getSchool());
|
||||
//设备没有绑定
|
||||
else if (code == 300) {
|
||||
tv_username.setText(defaultText);
|
||||
tv_school.setText(defaultText);
|
||||
tv_grade.setText(defaultText);
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getGrade())) {
|
||||
SPUtils.put(this, "USERINFO_GRADE", userInfo.getGrade());
|
||||
tv_grade.setText(userInfo.getGrade());
|
||||
//没有授权的设备
|
||||
else if (code == 400) {
|
||||
ToastUtil.show("设备未经授权");
|
||||
Log.e(TAG, "setInfo: " + "设备未经授权");
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
mPresenter.getLocked();
|
||||
} else if (code == 300) {
|
||||
tv_username.setText(defaultText);
|
||||
tv_school.setText(defaultText);
|
||||
tv_grade.setText(defaultText);
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
} else if (code == 400) {
|
||||
ToastUtil.show("设备未经授权");
|
||||
Log.e(TAG, "setInfo: " + "设备未经授权");
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
Log.e(TAG, "setInfo: " + (System.currentTimeMillis() - time0) + "ms");
|
||||
mPresenter.getSnUid();
|
||||
}
|
||||
|
||||
private String SnUidJSON;
|
||||
|
||||
@Override
|
||||
public void setSnUid(JSONObject jsonObject) {
|
||||
if (jsonObject != null) {
|
||||
this.SnUidJSON = jsonObject.toJSONString();
|
||||
String uid = jsonObject.getString("uid");
|
||||
if (!TextUtils.isEmpty(uid)) {
|
||||
Settings.System.putString(getContentResolver(), "gankaoUID", uid);
|
||||
}
|
||||
// long activate_time = jsonObject.getLong("activate_time");
|
||||
// String card_info = jsonObject.getString("card_info");
|
||||
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// Date d1 = new Date(activate_time * 1000);
|
||||
// int grade = jsonObject.getIntValue("grade");
|
||||
// SPUtils.put(MainActivity.this, "int_grade", grade);
|
||||
// String t1 = format.format(d1);
|
||||
// tv_vip.setText(card_info);
|
||||
// tv_activate.setText(t1 + " 激活");
|
||||
} else {
|
||||
mPresenter.registerGankao();
|
||||
}
|
||||
setClickable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGankao(String gankaoUID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.info.sn.activity.main;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.bean.zuoye.UserInfo;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
@@ -12,13 +13,16 @@ import java.util.List;
|
||||
|
||||
public class MainContact {
|
||||
public interface MainView extends BaseView {
|
||||
void setPowerUserList(String date);
|
||||
void checkSNFinish(int code);
|
||||
void setGankaoUID(String gankaoUID);
|
||||
void setAvailableProduct( List<AvailableProduct> availableProductList);
|
||||
void activeUser( int code);
|
||||
void setAvailableProduct(List<AvailableProduct> availableProductList, String gankaoUID);
|
||||
void activeUserFinish(int code);
|
||||
|
||||
void setQRCode(Bitmap bitmap);
|
||||
void setInfo(BaseResponse<UserInfo> response);
|
||||
void setSnInfo(BaseResponse<UserInfo> response);
|
||||
void setSnUid(JSONObject jsonObject);
|
||||
void setGankao(String gankaoUID);
|
||||
void setUserInfo();
|
||||
void setLocked(int lockedStatus);
|
||||
void onLocationChanged();
|
||||
@@ -34,15 +38,20 @@ public class MainContact {
|
||||
}
|
||||
|
||||
interface Presenter extends BasePresenter<MainView> {
|
||||
void queryPowerUserList();
|
||||
void checkSN();
|
||||
void getGankaoUID();
|
||||
void queryAvailableProduct();
|
||||
void activeUser(AvailableProduct product);
|
||||
void queryAvailableProduct(String gankaoUID);
|
||||
void activeUser(AvailableProduct product, String gankaoUID);
|
||||
|
||||
//获取二维码
|
||||
void getQRCode();
|
||||
//获取设备信息
|
||||
void getInfo();
|
||||
void getSnInfo();
|
||||
//获取激活时间
|
||||
void getSnUid();
|
||||
//注册赶考账号
|
||||
void registerGankao();
|
||||
//获取头像昵称
|
||||
void getUserInfo();
|
||||
//获取锁定状态
|
||||
|
||||
@@ -15,11 +15,14 @@ import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.bean.gankao.CreateUserBean;
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.bean.gankao.PowerUser;
|
||||
import com.info.sn.bean.zuoye.AppInfo;
|
||||
import com.info.sn.bean.zuoye.AppStart;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
@@ -35,6 +38,7 @@ import com.info.sn.manager.ControlManager;
|
||||
import com.info.sn.manager.NetInterfaceManager;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
import com.info.sn.service.ManagerService;
|
||||
import com.info.sn.service.RemoteService;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.CXAESUtil;
|
||||
import com.info.sn.utils.JGYUtils;
|
||||
@@ -95,6 +99,65 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void queryPowerUserList() {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryPowerUserListControl()
|
||||
.queryPowerUserList(appid, timestamp, LaunchTools.getToken(params))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("queryPowerUserList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e("queryPowerUserList", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
int code = gankaoBaseResponse.code;
|
||||
if (code == 10000) {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<PowerUser>>() {
|
||||
}.getType();
|
||||
JsonObject jsonObject = JsonParser.parseString(gson.toJson(gankaoBaseResponse.data)).getAsJsonObject();
|
||||
JsonArray jsonArray = jsonObject.getAsJsonArray("powerlist");
|
||||
List<PowerUser> powerUserList = gson.fromJson(gson.toJson(jsonArray), type);
|
||||
HashMap<String, PowerUser> hashMap = new HashMap<>();
|
||||
for (PowerUser powerUser : powerUserList) {
|
||||
hashMap.put(powerUser.getUserID(), powerUser);
|
||||
}
|
||||
PowerUser powerUser = hashMap.get(Utils.getSerial());
|
||||
if (powerUser != null) {
|
||||
String date = powerUser.getAuthorizationDate();
|
||||
mView.setPowerUserList(date);
|
||||
} else {
|
||||
mView.setPowerUserList("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("queryPowerUserList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("queryPowerUserList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSN() {
|
||||
NetInterfaceManager.getInstance()
|
||||
@@ -136,12 +199,319 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
Log.e(TAG + TAG, "getGankaoUID: uid: $uid");
|
||||
Log.e(TAG + TAG, "getGankaoUID: uid: " + uid);
|
||||
if (TextUtils.isEmpty(uid) || "0".equals(uid)) {
|
||||
ToastUtil.show("设备未绑定账号,请绑定后重试");
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
String token = LaunchTools.getToken(params);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getCreateUserControl()
|
||||
.createUser(appid, timestamp, uid, token)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "getGankaoUID", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "getGankaoUID", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
if (gankaoBaseResponse.code == 10002) {
|
||||
Type type = new TypeToken<CreateUserBean>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
CreateUserBean userBean = gson.fromJson(gson.toJson(gankaoBaseResponse.data), type);
|
||||
String gankaoPartnerUID = userBean.getGankaoPartnerUID();
|
||||
int gankaoUIDint = userBean.getGankaoUID();
|
||||
String gankaoUID = String.valueOf(gankaoUIDint);
|
||||
Log.e(TAG + "getGankaoUID", "onNext: gankaoUID: " + gankaoUID);
|
||||
SPUtils.put(mContext, "gankaoUID", gankaoUID);
|
||||
Settings.System.putString(mContext.getContentResolver(), "gankaoUID", gankaoUID);
|
||||
int isNew = userBean.getIsNew();
|
||||
mView.setGankaoUID(gankaoUID);
|
||||
} else {
|
||||
mView.setGankaoUID("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
mView.setGankaoUID("");
|
||||
Log.e(TAG + "getGankaoUID", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "getGankaoUID", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void queryAvailableProduct(String gankaoUID) {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryProductControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
if (gankaoBaseResponse.code == 10000) {
|
||||
Type type = new TypeToken<List<AvailableProduct>>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<AvailableProduct> availableProductList = gson.fromJson(gson.toJson(gankaoBaseResponse.data), type);
|
||||
mView.setAvailableProduct(availableProductList, gankaoUID);
|
||||
} else {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
mView.setAvailableProduct(new ArrayList(), gankaoUID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onError: " + e.getMessage());
|
||||
mView.setAvailableProduct(new ArrayList(), gankaoUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "queryAvailableProduct", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeUser(@NotNull AvailableProduct product, String gankaoUID) {
|
||||
String specification_id = product.getSpecification_id();
|
||||
Log.e(TAG, "activeUser: specification_id: " + specification_id);
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
params.put("specification_id", String.valueOf(specification_id));
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getActiveUserControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params), uid, specification_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "activeUser", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "activeUser", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
switch (gankaoBaseResponse.code) {
|
||||
case 10000:
|
||||
case 50000:
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 1);
|
||||
// sendUid(product, gankaoUID);
|
||||
break;
|
||||
default:
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 0);
|
||||
break;
|
||||
|
||||
}
|
||||
mView.activeUserFinish(gankaoBaseResponse.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "activeUser", "onError: ");
|
||||
mView.activeUserFinish(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "activeUser", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gankaoUID 发送赶考uid到后台
|
||||
*/
|
||||
// private void sendUid(AvailableProduct product, String gankaoUID) {
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getSaveSnUidApiControl()
|
||||
// .saveSnUid(Utils.getSerial(), gankaoUID, System.currentTimeMillis() / 1000, product.getDuration())
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<Response>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// Log.e(TAG + "sendUid", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(Response response) {
|
||||
// Log.e(TAG + "sendUid", "onNext: " + JSONObject.toJSONString(response));
|
||||
// if (response.code == 200) {
|
||||
// Log.e(TAG + "sendUid", "onNext: " + response.msg);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.e(TAG + "sendUid", "onError: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e(TAG + "sendUid", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
@Override
|
||||
public void getQRCode() {
|
||||
String encryptString = CXAESUtil.encrypt(Configs.AES_KEY, Utils.getSerial());
|
||||
Log.e(TAG + TAG, "setImageAndText: " + encryptString);
|
||||
Bitmap bitmap = Utils.createQRImage(encryptString, 400, 400);
|
||||
mView.setQRCode(bitmap);
|
||||
}
|
||||
|
||||
private static final String UPDATE_USER_INFO = "UPDATE_USER_INFO";
|
||||
|
||||
@Override
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getsnInfoControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<UserInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "getInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<UserInfo> userInfoBaseResponse) {
|
||||
Log.e(TAG + "getInfo", "onNext: ");
|
||||
mView.setSnInfo(userInfoBaseResponse);
|
||||
int code = userInfoBaseResponse.code;
|
||||
if (code == 200) {
|
||||
UserInfo userInfo = userInfoBaseResponse.data;
|
||||
Settings.System.putString(mContext.getContentResolver(), "UserInfo_username", userInfo.getSn_name());
|
||||
Settings.System.putString(mContext.getContentResolver(), "UserInfo_grade", userInfo.getGrade());
|
||||
SPUtils.put(mContext, Configs.isLogined, 1);
|
||||
SPUtils.put(mContext, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(mContext, "sn_id", userInfo.getId());
|
||||
if (!TextUtils.isEmpty(userInfo.getSn_name())) {
|
||||
SPUtils.put(mContext, "USERINFO_NAME", userInfo.getSn_name());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getSchool())) {
|
||||
SPUtils.put(mContext, "USERINFO_SCHOOL", userInfo.getSchool());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getGrade())) {
|
||||
SPUtils.put(mContext, "USERINFO_GRADE", userInfo.getGrade());
|
||||
}
|
||||
String gankaoUID = Settings.System.getString(mContext.getContentResolver(), "gankaoUID");
|
||||
String avatar = Settings.System.getString(mContext.getContentResolver(), "UserInfo_avatar");
|
||||
int gread = (int) SPUtils.get(mContext,"int_grade",0);
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("username", userInfo.getSn_name());
|
||||
jsonObject.addProperty("avatar", avatar);
|
||||
jsonObject.addProperty("grade", gread);
|
||||
jsonObject.addProperty("userid", gankaoUID);
|
||||
jsonObject.addProperty("sn", Utils.getSerial());
|
||||
Log.e(TAG, "getUserInfo:" + jsonObject.toString());
|
||||
Intent intent = new Intent(UPDATE_USER_INFO);
|
||||
intent.putExtra("user_info", jsonObject.toString());
|
||||
intent.setPackage("com.jiaoguanyi.os");
|
||||
intent.setPackage("com.tt.ttutils");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "getInfo", "onError: " + e.getMessage());
|
||||
mView.setSnInfo(null);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "getInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSnUid() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnUidApiControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSnUid", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("getSnUid", "onNext: "+JSONObject.toJSONString(baseResponse));
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 1);
|
||||
JSONObject jsonObject = JSON.parseObject(JSONObject.toJSONString(baseResponse.data));
|
||||
mView.setSnUid(jsonObject);
|
||||
} else {
|
||||
mView.setSnUid(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getSnUid", "onError: " + e.getMessage());
|
||||
mView.setSnUid(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSnUid", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGankao() {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
@@ -170,21 +540,19 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
String gankaoPartnerUID = userBean.getGankaoPartnerUID();
|
||||
int gankaoUIDint = userBean.getGankaoUID();
|
||||
String gankaoUID = String.valueOf(gankaoUIDint);
|
||||
sendUid(gankaoUID);
|
||||
Log.e(TAG + "getGankaoUID", "onNext: gankaoUID: $gankaoUID");
|
||||
Log.e(TAG + "getGankaoUID", "onNext: gankaoUID: " + gankaoUID);
|
||||
SPUtils.put(mContext, "gankaoUID", gankaoUID);
|
||||
Settings.System.putString(mContext.getContentResolver(), "gankaoUID", gankaoUID);
|
||||
int isNew = userBean.getIsNew();
|
||||
mView.setGankaoUID(gankaoUID);
|
||||
mView.setGankao(gankaoUID);
|
||||
} else {
|
||||
mView.setGankaoUID("");
|
||||
mView.setGankao("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
mView.setGankaoUID("");
|
||||
mView.setGankao("");
|
||||
Log.e(TAG + "getGankaoUID", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -195,183 +563,6 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gankaoUID 发送赶考uid到后台
|
||||
*/
|
||||
private void sendUid(String gankaoUID) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSaveSnUidApiControl(gankaoUID)
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "sendUid", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
Log.e(TAG + "sendUid", "onNext: " + response);
|
||||
if (response.code == 200) {
|
||||
Log.e(TAG + "sendUid", "onNext: " + response.msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "sendUid", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "sendUid", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryAvailableProduct() {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryProductControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
if (gankaoBaseResponse.code == 10000) {
|
||||
Type type = new TypeToken<List<AvailableProduct>>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<AvailableProduct> availableProductList = gson.fromJson(gson.toJson(gankaoBaseResponse.data), type);
|
||||
mView.setAvailableProduct(availableProductList);
|
||||
} else {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
mView.setAvailableProduct(new ArrayList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onError: " + e.getMessage());
|
||||
mView.setAvailableProduct(new ArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "queryAvailableProduct", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeUser(@NotNull AvailableProduct product) {
|
||||
int specification_id = product.getSpecification_id();
|
||||
Log.e(TAG, "activeUser: specification_id: " + specification_id);
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
params.put("specification_id", String.valueOf(specification_id));
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getActiveUserControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params), uid, specification_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "activeUser", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "activeUser", "onNext: ");
|
||||
switch (gankaoBaseResponse.code) {
|
||||
case 10000:
|
||||
case 50000:
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 1);
|
||||
break;
|
||||
default:
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 0);
|
||||
break;
|
||||
|
||||
}
|
||||
mView.activeUser(gankaoBaseResponse.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "activeUser", "onError: ");
|
||||
mView.activeUser(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "activeUser", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getQRCode() {
|
||||
String encryptString = CXAESUtil.encrypt(Configs.AES_KEY, Utils.getSerial());
|
||||
Log.e(TAG + TAG, "setImageAndText: " + encryptString);
|
||||
Bitmap bitmap = Utils.createQRImage(encryptString, 300, 300);
|
||||
mView.setQRCode(bitmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getsnInfoControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<UserInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "getInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<UserInfo> userInfoBaseResponse) {
|
||||
Log.e(TAG + "getInfo", "onNext: ");
|
||||
if (userInfoBaseResponse.code == 200) {
|
||||
UserInfo userInfo = userInfoBaseResponse.data;
|
||||
boolean username = Settings.System.putString(mContext.getContentResolver(), "UserInfo_username", userInfo.getSn_name());
|
||||
boolean gread = Settings.System.putString(mContext.getContentResolver(), "UserInfo_grade", userInfo.getGrade());
|
||||
mView.setInfo(userInfoBaseResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "getInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "getInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getUserInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
@@ -411,6 +602,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "getUserInfo", "onComplete: ");
|
||||
mView.setUserInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -578,18 +770,22 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
@Override
|
||||
public void onNext(BaseResponse<SystemSettings> systemSettingsBaseResponse) {
|
||||
Log.e(TAG + "getSystemSettings", "onNext: ");
|
||||
SPUtils.put(mContext, "is_first_connection", 0);
|
||||
int code = systemSettingsBaseResponse.code;
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(systemSettingsBaseResponse.data);
|
||||
Log.e(TAG + "getSystemSettings", "onNext: settings: " + jsonObject.toString());
|
||||
ControlManager.getInstance().setSystemSetting(mContext, jsonObject.toJSONString());
|
||||
} else {
|
||||
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if ((int) SPUtils.get(mContext, "is_first_connection", 1) == 1) {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
Log.e(TAG + "getSystemSettings", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
package com.info.sn.activity.selectegrade;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.activity.main.MainActivity;
|
||||
import com.info.sn.base.BaseActivity;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.bean.gankao.PowerUser;
|
||||
import com.info.sn.config.Scheme;
|
||||
import com.info.sn.utils.LaunchTools;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
import com.info.sn.utils.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class SelecteGradeActivity extends BaseActivity implements SelecteGradeContact.MainView {
|
||||
@BindView(R.id.radioGroup1)
|
||||
RadioGroup radioGroup1;
|
||||
@BindView(R.id.radioGroup2)
|
||||
RadioGroup radioGroup2;
|
||||
@BindView(R.id.radioGroup3)
|
||||
RadioGroup radioGroup3;
|
||||
@BindView(R.id.radioGroup4)
|
||||
RadioGroup radioGroup4;
|
||||
@BindView(R.id.radioButton1)
|
||||
RadioButton radioButton1;
|
||||
@BindView(R.id.radioButton2)
|
||||
RadioButton radioButton2;
|
||||
@BindView(R.id.radioButton3)
|
||||
RadioButton radioButton3;
|
||||
@BindView(R.id.radioButton4)
|
||||
RadioButton radioButton4;
|
||||
@BindView(R.id.radioButton5)
|
||||
RadioButton radioButton5;
|
||||
@BindView(R.id.radioButton6)
|
||||
RadioButton radioButton6;
|
||||
@BindView(R.id.radioButton7)
|
||||
RadioButton radioButton7;
|
||||
@BindView(R.id.radioButton8)
|
||||
RadioButton radioButton8;
|
||||
@BindView(R.id.radioButton9)
|
||||
RadioButton radioButton9;
|
||||
@BindView(R.id.radioButton10)
|
||||
RadioButton radioButton10;
|
||||
@BindView(R.id.radioButton11)
|
||||
RadioButton radioButton11;
|
||||
@BindView(R.id.radioButton12)
|
||||
RadioButton radioButton12;
|
||||
|
||||
@BindView(R.id.bt_unactivation)
|
||||
Button bt_unactivation;
|
||||
@BindView(R.id.bt_activation)
|
||||
Button bt_activation;
|
||||
|
||||
|
||||
@OnClick({R.id.radioButton1, R.id.radioButton2, R.id.radioButton3, R.id.radioButton4, R.id.radioButton5, R.id.radioButton6,
|
||||
R.id.radioButton7, R.id.radioButton8, R.id.radioButton9, R.id.radioButton10, R.id.radioButton11, R.id.radioButton12})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
default:
|
||||
break;
|
||||
case R.id.radioButton1:
|
||||
showGroup1();
|
||||
grade = 1;
|
||||
break;
|
||||
case R.id.radioButton2:
|
||||
showGroup1();
|
||||
grade = 2;
|
||||
break;
|
||||
case R.id.radioButton3:
|
||||
showGroup1();
|
||||
grade = 3;
|
||||
break;
|
||||
case R.id.radioButton4:
|
||||
showGroup2();
|
||||
grade = 4;
|
||||
break;
|
||||
case R.id.radioButton5:
|
||||
showGroup2();
|
||||
grade = 5;
|
||||
break;
|
||||
case R.id.radioButton6:
|
||||
showGroup2();
|
||||
grade = 6;
|
||||
break;
|
||||
case R.id.radioButton7:
|
||||
showGroup3();
|
||||
grade = 7;
|
||||
break;
|
||||
case R.id.radioButton8:
|
||||
showGroup3();
|
||||
grade = 8;
|
||||
break;
|
||||
case R.id.radioButton9:
|
||||
showGroup3();
|
||||
grade = 9;
|
||||
break;
|
||||
case R.id.radioButton10:
|
||||
showGroup4();
|
||||
grade = 10;
|
||||
break;
|
||||
case R.id.radioButton11:
|
||||
showGroup4();
|
||||
grade = 11;
|
||||
break;
|
||||
case R.id.radioButton12:
|
||||
showGroup4();
|
||||
grade = 12;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private int grade;
|
||||
private SelecteGradePresenter mPresenter = new SelecteGradePresenter(this);
|
||||
|
||||
private void showGroup1() {
|
||||
radioGroup2.clearCheck();
|
||||
radioGroup3.clearCheck();
|
||||
radioGroup4.clearCheck();
|
||||
}
|
||||
|
||||
private void showGroup2() {
|
||||
radioGroup1.clearCheck();
|
||||
radioGroup3.clearCheck();
|
||||
radioGroup4.clearCheck();
|
||||
}
|
||||
|
||||
private void showGroup3() {
|
||||
radioGroup1.clearCheck();
|
||||
radioGroup2.clearCheck();
|
||||
radioGroup4.clearCheck();
|
||||
}
|
||||
|
||||
private void showGroup4() {
|
||||
radioGroup1.clearCheck();
|
||||
radioGroup2.clearCheck();
|
||||
radioGroup3.clearCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_selecte_grade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter.setProvider(this);
|
||||
mPresenter.attachView(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
setOnclick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mPresenter.detachView();
|
||||
}
|
||||
|
||||
private void setOnclick() {
|
||||
bt_unactivation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
bt_activation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
checkGrade();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkGrade() {
|
||||
if (grade == 0) {
|
||||
ToastUtil.show("请选择激活年级");
|
||||
return;
|
||||
}
|
||||
|
||||
mPresenter.checkSN();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSNResult(int code) {
|
||||
switch (code) {
|
||||
case 200:
|
||||
case 300:
|
||||
mPresenter.getGankaoUID();
|
||||
ToastUtil.show("设备验证成功");
|
||||
break;
|
||||
case 400:
|
||||
ToastUtil.show("此设备未经授权,禁止激活");
|
||||
break;
|
||||
case 404:
|
||||
ToastUtil.show("网络连接失败,稍后重试");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGankaoUID(String gankaoUID) {
|
||||
if (TextUtils.isEmpty(gankaoUID)) {
|
||||
ToastUtil.show("用户注册失败");
|
||||
} else {
|
||||
ToastUtil.show("用户注册成功");
|
||||
mPresenter.queryAvailableProduct();
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, String> mAvailableProductHashMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void setAvailableProduct(List<AvailableProduct> availableProductList) {
|
||||
for (AvailableProduct product : availableProductList) {
|
||||
mAvailableProductHashMap.put(product.getDuration(), product.getSpecification_id());
|
||||
}
|
||||
setGrade(availableProductList);
|
||||
}
|
||||
|
||||
private void setGrade(List<AvailableProduct> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
} else {
|
||||
AvailableProduct defaultProduct = null;
|
||||
AvailableProduct primary = null;
|
||||
AvailableProduct junior = null;
|
||||
AvailableProduct high = null;
|
||||
for (AvailableProduct product : list) {
|
||||
if (product.getDuration().contains("全学段")) {
|
||||
defaultProduct = product;
|
||||
}
|
||||
if (product.getDuration().contains("小学")) {
|
||||
primary = product;
|
||||
}
|
||||
if (product.getDuration().contains("初中")) {
|
||||
junior = product;
|
||||
}
|
||||
if (product.getDuration().contains("高中")) {
|
||||
high = product;
|
||||
}
|
||||
}
|
||||
switch (grade) {
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
activeUser(primary, grade);
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
activeUser(junior, grade);
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
activeUser(high, grade);
|
||||
break;
|
||||
}
|
||||
SPUtils.put(SelecteGradeActivity.this, "int_grade", grade);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param product 通过产品id激活设备
|
||||
*/
|
||||
private void activeUser(AvailableProduct product, int grade) {
|
||||
if (product == null) {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
return;
|
||||
}
|
||||
mPresenter.activeUser(product, grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeUserFinish(int code, int grade) {
|
||||
switch (code) {
|
||||
case 10000:
|
||||
ToastUtil.show("授权成功");
|
||||
break;
|
||||
case 50000:
|
||||
ToastUtil.show("已经授权");
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
ToastUtil.show("授权失败");
|
||||
break;
|
||||
}
|
||||
mPresenter.queryPowerUserList(grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryPowerUserListFinish(List<PowerUser> powerUserList, int grade) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (powerUserList != null && powerUserList.size() != 0) {
|
||||
for (PowerUser powerUser : powerUserList) {
|
||||
if (powerUser.getUserID().equals(Utils.getSerial())) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("card_info", powerUser.getAuthorityName());
|
||||
jsonObject.put("grade", powerUser.getGrade());
|
||||
jsonObject.put("activate_time", powerUser.getAuthorizationDate());
|
||||
jsonObject.put("user_power_id", powerUser.getAuthorizationNumber());
|
||||
jsonObject.put("specification_id", mAvailableProductHashMap.get(powerUser.getAuthorityName()));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
mPresenter.sendUid(jsonArray.toJSONString(), grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUidFinish(int code) {
|
||||
if (code == 200) {
|
||||
toGankaoApp();
|
||||
finish();
|
||||
} else {
|
||||
ToastUtil.show("保存信息失败请重试");
|
||||
}
|
||||
}
|
||||
|
||||
private void toGankaoApp() {
|
||||
String gankaoUID = (String) SPUtils.get(SelecteGradeActivity.this, "gankaoUID", "");
|
||||
if (TextUtils.isEmpty(gankaoUID)) {
|
||||
ToastUtil.show("获取用户信息失败");
|
||||
return;
|
||||
}
|
||||
HashMap keys = new HashMap();
|
||||
//device_id 传入赶考 UID 可实现账户公用,不会创建新账号
|
||||
keys.put("device_id", Uri.encode(gankaoUID));
|
||||
keys.put("partner_id", Scheme.partner_id);
|
||||
keys.put("macaddr", Uri.encode(Utils.getAndroid7MAC()));
|
||||
try {
|
||||
String uri = LaunchTools.toUserCenter(SelecteGradeActivity.this, keys, Uri.encode(Scheme.ownCenter));
|
||||
// Scheme.openScheme(MainActivity.this, Scheme.getLogin(MainActivity.this));
|
||||
Scheme.openScheme(SelecteGradeActivity.this, uri);
|
||||
// LaunchTools.goGankao(MainActivity.this, "", "");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.info.sn.activity.selectegrade;
|
||||
|
||||
import com.info.sn.activity.main.MainContact;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.bean.gankao.PowerUser;
|
||||
import com.info.sn.mvp.BasePresenter;
|
||||
import com.info.sn.mvp.BaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SelecteGradeContact {
|
||||
public interface MainView extends BaseView {
|
||||
void checkSNResult(int code);
|
||||
void setGankaoUID(String gankaoUID);
|
||||
void setAvailableProduct(List<AvailableProduct> availableProductList);
|
||||
void activeUserFinish(int code,int grade);
|
||||
void queryPowerUserListFinish(List<PowerUser> powerUserList, int grade);
|
||||
void sendUidFinish(int code);
|
||||
}
|
||||
|
||||
interface Presenter extends BasePresenter<SelecteGradeContact.MainView> {
|
||||
void checkSN();
|
||||
void getGankaoUID();
|
||||
void queryAvailableProduct();
|
||||
void activeUser(AvailableProduct product,int grade);
|
||||
void queryPowerUserList(int grade);
|
||||
void sendUid(String jsonString,int grade);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
package com.info.sn.activity.selectegrade;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.info.sn.activity.main.MainActivity;
|
||||
import com.info.sn.activity.main.MainPresenter;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.bean.gankao.CreateUserBean;
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.bean.gankao.PowerUser;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.bean.zuoye.Response;
|
||||
import com.info.sn.bean.zuoye.UserInfo;
|
||||
import com.info.sn.config.Scheme;
|
||||
import com.info.sn.manager.NetInterfaceManager;
|
||||
import com.info.sn.utils.LaunchTools;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
import com.info.sn.utils.Utils;
|
||||
import com.trello.rxlifecycle2.LifecycleProvider;
|
||||
import com.trello.rxlifecycle2.android.ActivityEvent;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class SelecteGradePresenter implements SelecteGradeContact.Presenter {
|
||||
private String TAG;
|
||||
|
||||
private SelecteGradeContact.MainView mView;
|
||||
private Context mContext;
|
||||
|
||||
SelecteGradePresenter(Context context) {
|
||||
this.mContext = context;
|
||||
TAG = context.getClass().getSimpleName() + "." + MainPresenter.class.getSimpleName() + ":";
|
||||
}
|
||||
|
||||
private LifecycleProvider<ActivityEvent> provider;
|
||||
|
||||
public void setProvider(LifecycleProvider<ActivityEvent> provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public LifecycleProvider<ActivityEvent> getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(SelecteGradeContact.MainView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSN() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getsnInfoControl()
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<UserInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "checkSN", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<UserInfo> userInfoBaseResponse) {
|
||||
Log.e(TAG + "checkSN", "onNext: ");
|
||||
int code = userInfoBaseResponse.code;
|
||||
mView.checkSNResult(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "checkSN", "onError: " + e.getMessage());
|
||||
mView.checkSNResult(404);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + TAG + "checkSN", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGankaoUID() {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
Log.e(TAG + TAG, "getGankaoUID: uid: " + uid);
|
||||
if (TextUtils.isEmpty(uid) || "0".equals(uid)) {
|
||||
ToastUtil.show("设备未绑定账号,请绑定后重试");
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
String token = LaunchTools.getToken(params);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getCreateUserControl()
|
||||
.createUser(appid, timestamp, uid, token)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "getGankaoUID", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "getGankaoUID", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
if (gankaoBaseResponse.code == 10002) {
|
||||
Type type = new TypeToken<CreateUserBean>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
CreateUserBean userBean = gson.fromJson(gson.toJson(gankaoBaseResponse.data), type);
|
||||
String gankaoPartnerUID = userBean.getGankaoPartnerUID();
|
||||
int gankaoUIDint = userBean.getGankaoUID();
|
||||
String gankaoUID = String.valueOf(gankaoUIDint);
|
||||
Log.e(TAG + "getGankaoUID", "onNext: gankaoUID: " + gankaoUID);
|
||||
SPUtils.put(mContext, "gankaoUID", gankaoUID);
|
||||
Settings.System.putString(mContext.getContentResolver(), "gankaoUID", gankaoUID);
|
||||
int isNew = userBean.getIsNew();
|
||||
mView.setGankaoUID(gankaoUID);
|
||||
} else {
|
||||
mView.setGankaoUID("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
mView.setGankaoUID("");
|
||||
Log.e(TAG + "getGankaoUID", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "getGankaoUID", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryAvailableProduct() {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryProductControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
if (gankaoBaseResponse.code == 10000) {
|
||||
Type type = new TypeToken<List<AvailableProduct>>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<AvailableProduct> availableProductList = gson.fromJson(gson.toJson(gankaoBaseResponse.data), type);
|
||||
mView.setAvailableProduct(availableProductList);
|
||||
} else {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
mView.setAvailableProduct(new ArrayList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "queryAvailableProduct", "onError: " + e.getMessage());
|
||||
mView.setAvailableProduct(new ArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "queryAvailableProduct", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeUser(AvailableProduct product,int grade) {
|
||||
String specification_id = product.getSpecification_id();
|
||||
Log.e(TAG, "activeUser: specification_id: " + specification_id);
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
params.put("specification_id", String.valueOf(specification_id));
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getActiveUserControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params), uid, specification_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "activeUser", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
String jsonString = JSONObject.toJSONString(gankaoBaseResponse);
|
||||
Log.e(TAG + "activeUser", "onNext: " + jsonString);
|
||||
switch (gankaoBaseResponse.code) {
|
||||
//第一次激活
|
||||
case 10000:
|
||||
//已经授权过的
|
||||
case 50000:
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 1);
|
||||
break;
|
||||
default:
|
||||
Settings.System.putInt(mContext.getContentResolver(), MainActivity.activation, 0);
|
||||
break;
|
||||
}
|
||||
mView.activeUserFinish(gankaoBaseResponse.code,grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "activeUser", "onError: ");
|
||||
mView.activeUserFinish(0,grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "activeUser", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryPowerUserList(int grade) {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryPowerUserListControl()
|
||||
.queryPowerUserList(appid, timestamp, LaunchTools.getToken(params))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("queryPowerUserList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e("queryPowerUserList", "onNext: ");
|
||||
// Log.e("queryPowerUserList", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
int code = gankaoBaseResponse.code;
|
||||
if (code == 10000) {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<PowerUser>>() {
|
||||
}.getType();
|
||||
JsonObject jsonObject = JsonParser.parseString(gson.toJson(gankaoBaseResponse.data)).getAsJsonObject();
|
||||
JsonArray jsonArray = jsonObject.getAsJsonArray("powerlist");
|
||||
List<PowerUser> powerUserList = gson.fromJson(gson.toJson(jsonArray), type);
|
||||
mView. queryPowerUserListFinish(powerUserList,grade);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("queryPowerUserList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("queryPowerUserList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUid(String jsonString, int grade) {
|
||||
String gankaoUID = Settings.System.getString(mContext.getContentResolver(), "gankaoUID");
|
||||
if (TextUtils.isEmpty(gankaoUID)) {
|
||||
ToastUtil.show("获取设备UID失败,请重新激活");
|
||||
}
|
||||
Log.e(TAG, "sendUid: " + jsonString);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSaveSnUidApiControl()
|
||||
.saveSnUid(Utils.getSerial(), gankaoUID, grade, jsonString)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + "sendUid", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
Log.e(TAG + "sendUid", "onNext: " + JSONObject.toJSONString(response));
|
||||
mView.sendUidFinish(response.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + "sendUid", "onError: " + e.getMessage());
|
||||
mView.sendUidFinish(404);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + "sendUid", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
60
app/src/main/java/com/info/sn/adapter/SNUidAdapter.java
Normal file
60
app/src/main/java/com/info/sn/adapter/SNUidAdapter.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.info.sn.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.bean.zuoye.SNUidBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SNUidAdapter extends RecyclerView.Adapter<SNUidAdapter.ViewHolder> {
|
||||
|
||||
private List<SNUidBean> snUidBeans;
|
||||
|
||||
public void setSnUidBeans(List<SNUidBean> uidBeads) {
|
||||
this.snUidBeans = uidBeads;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
View v = View.inflate(parent.getContext(), R.layout.item_snuid, null);
|
||||
v.setLayoutParams(layoutParams);
|
||||
return new ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
SNUidBean snUidBean = snUidBeans.get(position);
|
||||
holder.tv_name.setText(snUidBean.getCard_info());
|
||||
holder.tv_grade.setText(String.valueOf(snUidBean.getGrade()));
|
||||
holder.tv_time.setText(snUidBean.getActivate_time());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return snUidBeans == null ? 0 : snUidBeans.size();
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tv_name;
|
||||
TextView tv_grade;
|
||||
TextView tv_time;
|
||||
|
||||
ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_grade = itemView.findViewById(R.id.tv_grade);
|
||||
tv_time = itemView.findViewById(R.id.tv_time);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class AvailableProduct implements Serializable {
|
||||
|
||||
String productname;
|
||||
String product_id;
|
||||
int specification_id;
|
||||
String specification_id;
|
||||
String duration;
|
||||
String register_autobind;
|
||||
String max_apply_preuser;
|
||||
@@ -30,11 +30,11 @@ public class AvailableProduct implements Serializable {
|
||||
this.product_id = product_id;
|
||||
}
|
||||
|
||||
public int getSpecification_id() {
|
||||
public String getSpecification_id() {
|
||||
return specification_id;
|
||||
}
|
||||
|
||||
public void setSpecification_id(int specification_id) {
|
||||
public void setSpecification_id(String specification_id) {
|
||||
this.specification_id = specification_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.info.sn.bean.gankao;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GankaoBaseResponse<T> implements Serializable {
|
||||
@@ -8,8 +14,15 @@ public class GankaoBaseResponse<T> implements Serializable {
|
||||
public int code;
|
||||
public int status;
|
||||
public String msg;
|
||||
public long serverTime;
|
||||
public long serverTime;
|
||||
public String tokenOK;
|
||||
public T data;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject();
|
||||
return jsonObject.toString();
|
||||
}
|
||||
}
|
||||
|
||||
129
app/src/main/java/com/info/sn/bean/gankao/PowerUser.java
Normal file
129
app/src/main/java/com/info/sn/bean/gankao/PowerUser.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package com.info.sn.bean.gankao;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PowerUser implements Serializable {
|
||||
private static final long serialVersionUID = -6368881020242541651L;
|
||||
@SerializedName("合作方用户id")
|
||||
private String userID;
|
||||
@SerializedName("赶考内部PUID")
|
||||
private int pUID;
|
||||
@SerializedName("赶考UID")
|
||||
private int gankaoUID;
|
||||
@SerializedName("姓名")
|
||||
private String name;
|
||||
@SerializedName("年级")
|
||||
private int grade;
|
||||
@SerializedName("身份")
|
||||
private String identity;
|
||||
@SerializedName("授权记录编号")
|
||||
private int authorizationNumber;
|
||||
@SerializedName("授权日期")
|
||||
private String authorizationDate;
|
||||
@SerializedName("权限规格ID")
|
||||
private int authorityID;
|
||||
@SerializedName("权限名称")
|
||||
private String authorityName;
|
||||
@SerializedName("回款价")
|
||||
private float returnPrice;
|
||||
@SerializedName("有效期")
|
||||
private String validPeriod;
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public int getpUID() {
|
||||
return pUID;
|
||||
}
|
||||
|
||||
public void setpUID(int pUID) {
|
||||
this.pUID = pUID;
|
||||
}
|
||||
|
||||
public int getGankaoUID() {
|
||||
return gankaoUID;
|
||||
}
|
||||
|
||||
public void setGankaoUID(int gankaoUID) {
|
||||
this.gankaoUID = gankaoUID;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getGrade() {
|
||||
return grade;
|
||||
}
|
||||
|
||||
public void setGrade(int grade) {
|
||||
this.grade = grade;
|
||||
}
|
||||
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
public int getAuthorizationNumber() {
|
||||
return authorizationNumber;
|
||||
}
|
||||
|
||||
public void setAuthorizationNumber(int authorizationNumber) {
|
||||
this.authorizationNumber = authorizationNumber;
|
||||
}
|
||||
|
||||
public String getAuthorizationDate() {
|
||||
return authorizationDate;
|
||||
}
|
||||
|
||||
public void setAuthorizationDate(String authorizationDate) {
|
||||
this.authorizationDate = authorizationDate;
|
||||
}
|
||||
|
||||
public int getAuthorityID() {
|
||||
return authorityID;
|
||||
}
|
||||
|
||||
public void setAuthorityID(int authorityID) {
|
||||
this.authorityID = authorityID;
|
||||
}
|
||||
|
||||
public String getAuthorityName() {
|
||||
return authorityName;
|
||||
}
|
||||
|
||||
public void setAuthorityName(String authorityName) {
|
||||
this.authorityName = authorityName;
|
||||
}
|
||||
|
||||
public float getReturnPrice() {
|
||||
return returnPrice;
|
||||
}
|
||||
|
||||
public void setReturnPrice(float returnPrice) {
|
||||
this.returnPrice = returnPrice;
|
||||
}
|
||||
|
||||
public String getValidPeriod() {
|
||||
return validPeriod;
|
||||
}
|
||||
|
||||
public void setValidPeriod(String validPeriod) {
|
||||
this.validPeriod = validPeriod;
|
||||
}
|
||||
}
|
||||
130
app/src/main/java/com/info/sn/bean/gankao/UserProduct.java
Normal file
130
app/src/main/java/com/info/sn/bean/gankao/UserProduct.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.info.sn.bean.gankao;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserProduct implements Serializable {
|
||||
private static final long serialVersionUID = 7962643432696702587L;
|
||||
|
||||
String id;
|
||||
String user_id;
|
||||
String name;
|
||||
boolean isgroup;
|
||||
String product_id;
|
||||
String user_power_id;
|
||||
String specification_id;
|
||||
String register_autobind;
|
||||
float upgradable;
|
||||
String upgradablehint;
|
||||
String expired_time;
|
||||
String created_at;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUser_id(String user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isIsgroup() {
|
||||
return isgroup;
|
||||
}
|
||||
|
||||
public void setIsgroup(boolean isgroup) {
|
||||
this.isgroup = isgroup;
|
||||
}
|
||||
|
||||
public String getProduct_id() {
|
||||
return product_id;
|
||||
}
|
||||
|
||||
public void setProduct_id(String product_id) {
|
||||
this.product_id = product_id;
|
||||
}
|
||||
|
||||
public String getUser_power_id() {
|
||||
return user_power_id;
|
||||
}
|
||||
|
||||
public void setUser_power_id(String user_power_id) {
|
||||
this.user_power_id = user_power_id;
|
||||
}
|
||||
|
||||
public String getSpecification_id() {
|
||||
return specification_id;
|
||||
}
|
||||
|
||||
public void setSpecification_id(String specification_id) {
|
||||
this.specification_id = specification_id;
|
||||
}
|
||||
|
||||
public String getRegister_autobind() {
|
||||
return register_autobind;
|
||||
}
|
||||
|
||||
public void setRegister_autobind(String register_autobind) {
|
||||
this.register_autobind = register_autobind;
|
||||
}
|
||||
|
||||
public float getUpgradable() {
|
||||
return upgradable;
|
||||
}
|
||||
|
||||
public void setUpgradable(float upgradable) {
|
||||
this.upgradable = upgradable;
|
||||
}
|
||||
|
||||
public String getUpgradablehint() {
|
||||
return upgradablehint;
|
||||
}
|
||||
|
||||
public void setUpgradablehint(String upgradablehint) {
|
||||
this.upgradablehint = upgradablehint;
|
||||
}
|
||||
|
||||
public String getExpired_time() {
|
||||
return expired_time;
|
||||
}
|
||||
|
||||
public void setExpired_time(String expired_time) {
|
||||
this.expired_time = expired_time;
|
||||
}
|
||||
|
||||
public String getCreated_at() {
|
||||
return created_at;
|
||||
}
|
||||
|
||||
public void setCreated_at(String created_at) {
|
||||
this.created_at = created_at;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject();
|
||||
return jsonObject.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.info.sn.bean.gankao;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserProductCards<T> implements Serializable {
|
||||
private static final long serialVersionUID = 2956193416718626851L;
|
||||
|
||||
T cards;
|
||||
|
||||
public T getCards() {
|
||||
return cards;
|
||||
}
|
||||
|
||||
public void setCards(T cards) {
|
||||
this.cards = cards;
|
||||
}
|
||||
}
|
||||
53
app/src/main/java/com/info/sn/bean/zuoye/SNUidBean.java
Normal file
53
app/src/main/java/com/info/sn/bean/zuoye/SNUidBean.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.info.sn.bean.zuoye;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SNUidBean implements Serializable {
|
||||
private static final long serialVersionUID = 8415979808461790756L;
|
||||
|
||||
String specification_id;
|
||||
String user_power_id;
|
||||
int grade;
|
||||
String activate_time;
|
||||
String card_info;
|
||||
|
||||
public String getSpecification_id() {
|
||||
return specification_id;
|
||||
}
|
||||
|
||||
public void setSpecification_id(String specification_id) {
|
||||
this.specification_id = specification_id;
|
||||
}
|
||||
|
||||
public String getUser_power_id() {
|
||||
return user_power_id;
|
||||
}
|
||||
|
||||
public void setUser_power_id(String user_power_id) {
|
||||
this.user_power_id = user_power_id;
|
||||
}
|
||||
|
||||
public int getGrade() {
|
||||
return grade;
|
||||
}
|
||||
|
||||
public void setGrade(int grade) {
|
||||
this.grade = grade;
|
||||
}
|
||||
|
||||
public String getActivate_time() {
|
||||
return activate_time;
|
||||
}
|
||||
|
||||
public void setActivate_time(String activate_time) {
|
||||
this.activate_time = activate_time;
|
||||
}
|
||||
|
||||
public String getCard_info() {
|
||||
return card_info;
|
||||
}
|
||||
|
||||
public void setCard_info(String card_info) {
|
||||
this.card_info = card_info;
|
||||
}
|
||||
}
|
||||
@@ -529,7 +529,7 @@ public class ControlManager {
|
||||
|
||||
private static void setCanReset(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int mode = jsonObject.getInteger("qch_restore");
|
||||
int mode = jsonObject.getIntValue("qch_restore");
|
||||
if (mode == 1) {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
} else {
|
||||
@@ -555,7 +555,7 @@ public class ControlManager {
|
||||
|
||||
public void setDeveloperOptions(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int dev_mode = changeNum(jsonObject.getInteger("dev_mode"));
|
||||
int dev_mode = changeNum(jsonObject.getIntValue("dev_mode"));
|
||||
Log.e(TAG, "getDeveloper: " + dev_mode);
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
JGYUtils.putInt(context.getContentResolver(), "qch_Developeroptions", dev_mode);
|
||||
|
||||
@@ -7,25 +7,28 @@ import android.os.Environment;
|
||||
import com.info.sn.bean.zuoye.AppInfo;
|
||||
import com.info.sn.bean.zuoye.AppStart;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.bean.zuoye.Response;
|
||||
import com.info.sn.bean.zuoye.SystemSettings;
|
||||
import com.info.sn.bean.zuoye.UserAvatarInfo;
|
||||
import com.info.sn.bean.zuoye.UserInfo;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
import com.info.sn.network.api.APPJump;
|
||||
import com.info.sn.network.api.ActiveUserApi;
|
||||
import com.info.sn.network.api.gankao.ActiveUserApi;
|
||||
import com.info.sn.network.api.AddAppInstall;
|
||||
import com.info.sn.network.api.AppUsedApi;
|
||||
import com.info.sn.network.api.BindDevices;
|
||||
import com.info.sn.network.api.Browser;
|
||||
import com.info.sn.network.api.CreateUserApi;
|
||||
import com.info.sn.network.api.gankao.CancelUserPowerApi;
|
||||
import com.info.sn.network.api.gankao.CreateUserApi;
|
||||
import com.info.sn.network.api.ForceInstall;
|
||||
import com.info.sn.network.api.BrowserLabel;
|
||||
import com.info.sn.network.api.GetGuideApi;
|
||||
import com.info.sn.network.api.GetSnUidApi;
|
||||
import com.info.sn.network.api.NewestAppUpdate;
|
||||
import com.info.sn.network.api.QRCodeApi;
|
||||
import com.info.sn.network.api.QueryAllApp;
|
||||
import com.info.sn.network.api.QueryAppInside;
|
||||
import com.info.sn.network.api.QueryProductApi;
|
||||
import com.info.sn.network.api.gankao.QueryPowerUserListApi;
|
||||
import com.info.sn.network.api.gankao.QueryProductApi;
|
||||
import com.info.sn.network.api.QuerySnAppStart;
|
||||
import com.info.sn.network.api.RunningApp;
|
||||
import com.info.sn.network.api.SNInfoApi;
|
||||
@@ -38,6 +41,8 @@ import com.info.sn.network.api.TimeControl;
|
||||
import com.info.sn.network.api.UpdateAdminSn;
|
||||
import com.info.sn.network.api.UploadScreenshot;
|
||||
import com.info.sn.network.api.UserInfoControl;
|
||||
import com.info.sn.network.api.gankao.UpgradeUserPowerApi;
|
||||
import com.info.sn.network.api.gankao.UserProductsApi;
|
||||
import com.info.sn.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -218,11 +223,8 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<Response> getSaveSnUidApiControl(String uid) {
|
||||
return mRetrofit.create(SaveSnUidApi.class)
|
||||
.saveSnUid(Utils.getSerial(), uid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
public SaveSnUidApi getSaveSnUidApiControl() {
|
||||
return mRetrofit.create(SaveSnUidApi.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -251,6 +253,19 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getGetGuideControl() {
|
||||
return mRetrofit.create(GetGuideApi.class)
|
||||
.getGuidePic(2)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getSnUidApiControl() {
|
||||
return mRetrofit.create(GetSnUidApi.class)
|
||||
.getSnUid(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
//赶考
|
||||
|
||||
@@ -266,5 +281,19 @@ public class NetInterfaceManager {
|
||||
return mGankaoRetrofit.create(QueryProductApi.class);
|
||||
}
|
||||
|
||||
public QueryPowerUserListApi getQueryPowerUserListControl() {
|
||||
return mGankaoRetrofit.create(QueryPowerUserListApi.class);
|
||||
}
|
||||
|
||||
public UserProductsApi getUserProductsControl() {
|
||||
return mGankaoRetrofit.create(UserProductsApi.class);
|
||||
}
|
||||
|
||||
public CancelUserPowerApi getCancelUserPowerControl() {
|
||||
return mGankaoRetrofit.create(CancelUserPowerApi.class);
|
||||
}
|
||||
|
||||
public UpgradeUserPowerApi getUpgradeUserPowerControl() {
|
||||
return mGankaoRetrofit.create(UpgradeUserPowerApi.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class HTTPInterface {
|
||||
// Log.e("SendAppInstall", installOrRemove + "return: " + packages);
|
||||
// return;
|
||||
// }
|
||||
|
||||
Log.e(TAG, "SendAppInstall: " + jsonString);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAddAppInstallControl()
|
||||
.installorRemove(
|
||||
|
||||
@@ -49,11 +49,14 @@ public class UrlAddress {
|
||||
public static final String GET_USER_AVATAR_INFO = "sn/getUserAvatarInfo";
|
||||
//上传设备赶考的UID
|
||||
public static final String POST_USER_SAVESNUID = "sn/saveSnUid";
|
||||
//获取激活时间和赶考UID
|
||||
public static final String GET_SN_UID = "sn/getSnUid";
|
||||
//获取app使用信息
|
||||
public static final String UPLOAD_APP_USE_INFO = "sn/uploadAppUseInfo";
|
||||
//获取小程序二维码
|
||||
public static final String GET_APPLET_QRCODE = "file/getAppletQrCode";
|
||||
|
||||
//获取操作指南
|
||||
public static final String GET_OPERATION_GUIDE = "file/getFiles";
|
||||
|
||||
|
||||
|
||||
@@ -65,5 +68,12 @@ public class UrlAddress {
|
||||
public static final String ACTIVE_USER = "activeUser";
|
||||
//获得可用的权限产品规格
|
||||
public static final String QUERY_AVAILABLE_PRODUCT_SPECIFICATIONS = "queryAvailableProductSpecifications";
|
||||
|
||||
//获取机构的接口授权记录
|
||||
public static final String QUERY_POWER_USER_LIST = "queryPowerUserList";
|
||||
//获取用户已获得的产品列表(权限、单体课程、套餐等)
|
||||
public static final String GET_USER_PRODUCTS = "getUserProducts";
|
||||
//升级用户会员权限的学段
|
||||
public static final String UPGRADE_USER_POWER = "upgradeUserPower";
|
||||
//撤销指定的用户授权记录
|
||||
public static final String CANCEL_USER_POWER = "cancelUserPower";
|
||||
}
|
||||
|
||||
15
app/src/main/java/com/info/sn/network/api/GetGuideApi.java
Normal file
15
app/src/main/java/com/info/sn/network/api/GetGuideApi.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetGuideApi {
|
||||
@GET(UrlAddress.GET_OPERATION_GUIDE)
|
||||
Observable<BaseResponse> getGuidePic(
|
||||
@Query("type") int type
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetGuideApiTest {
|
||||
@GET(UrlAddress.GET_OPERATION_GUIDE)
|
||||
Observable getGuidePic(
|
||||
@Query("type") int type
|
||||
);
|
||||
}
|
||||
15
app/src/main/java/com/info/sn/network/api/GetSnUidApi.java
Normal file
15
app/src/main/java/com/info/sn/network/api/GetSnUidApi.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetSnUidApi {
|
||||
@GET(UrlAddress.GET_SN_UID)
|
||||
Observable<BaseResponse> getSnUid(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,8 @@ public interface SaveSnUidApi {
|
||||
@POST(UrlAddress.POST_USER_SAVESNUID)
|
||||
Observable<Response> saveSnUid(
|
||||
@Field("sn") String sn,
|
||||
@Field("uid") String uid
|
||||
@Field("uid") String uid,
|
||||
@Field("grade") int grade,
|
||||
@Field("card_info") String card_info
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.info.sn.network.api;
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
@@ -15,6 +15,6 @@ public interface ActiveUserApi {
|
||||
@Query("timestamp") String timestamp,
|
||||
@Query("token") String token,
|
||||
@Query("uid") String uid,
|
||||
@Query("specification_id") int specification_id
|
||||
@Query("specification_id") String specification_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface CancelUserPowerApi {
|
||||
@GET(UrlAddress.CANCEL_USER_POWER)
|
||||
Observable<GankaoBaseResponse> cancelUserPower(
|
||||
@Query("app_id") String app_id,
|
||||
@Query("timestamp") String timestamp,
|
||||
@Query("token") String token,
|
||||
@Query("user_power_id") String user_power_id,
|
||||
@Query("specification_id") String specification_id
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.info.sn.network.api;
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface QueryPowerUserListApi {
|
||||
@GET(UrlAddress.QUERY_POWER_USER_LIST)
|
||||
Observable<GankaoBaseResponse> queryPowerUserList(
|
||||
@Query("app_id") String app_id,
|
||||
@Query("timestamp") String timestamp,
|
||||
@Query("token") String token
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.info.sn.network.api;
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface UpgradeUserPowerApi {
|
||||
@GET(UrlAddress.UPGRADE_USER_POWER)
|
||||
Observable<GankaoBaseResponse> upgradeUserPower(
|
||||
@Query("app_id") String app_id,
|
||||
@Query("timestamp") String timestamp,
|
||||
@Query("token") String token,
|
||||
@Query("uid") String uid,
|
||||
@Query("user_power_id") int user_power_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.info.sn.network.api.gankao;
|
||||
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.bean.gankao.UserProduct;
|
||||
import com.info.sn.bean.gankao.UserProductCards;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface UserProductsApi {
|
||||
@GET(UrlAddress.GET_USER_PRODUCTS)
|
||||
Observable<GankaoBaseResponse<UserProductCards<List<UserProduct>>>> getUserProducts(
|
||||
@Query("app_id") String app_id,
|
||||
@Query("timestamp") String timestamp,
|
||||
@Query("token") String token,
|
||||
@Query("uid") String uid
|
||||
);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class InstallResultReceiver extends BroadcastReceiver {
|
||||
// Log.e("fht", LEGACY_STATUS);
|
||||
// Log.e("fht", STATUS_MESSAGE);
|
||||
if (STATUS_MESSAGE != null && STATUS_MESSAGE.equals("INSTALL_SUCCEEDED")) {
|
||||
ToastUtil.show(PACKAGE_NAME + "安装成功");
|
||||
// ToastUtil.show(PACKAGE_NAME + "安装成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@@ -20,7 +21,15 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.info.sn.activity.main.MainActivity;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.bean.gankao.GankaoBaseResponse;
|
||||
import com.info.sn.bean.gankao.UserProduct;
|
||||
import com.info.sn.bean.gankao.UserProductCards;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.config.Scheme;
|
||||
import com.info.sn.jpush.Logger;
|
||||
import com.info.sn.manager.ControlManager;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
@@ -33,15 +42,21 @@ import com.info.sn.utils.CacheUtils;
|
||||
import com.info.sn.utils.CmdUtil;
|
||||
import com.info.sn.manager.DeviceManager;
|
||||
import com.info.sn.utils.JGYUtils;
|
||||
import com.info.sn.utils.LaunchTools;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.ServiceAliveUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
import com.info.sn.utils.Utils;
|
||||
import com.info.sn.dialog.CustomDialog;
|
||||
import com.trello.rxlifecycle2.android.ActivityEvent;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -139,7 +154,12 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
//搜题开关
|
||||
private static final String JIGUANG_SEARCH_TOPIC = "39";
|
||||
//电话白名单推送
|
||||
private static final String JIGUANG_PHONE_LIST = "49";
|
||||
private static final String JIGUANG_PHONE_LIST = "40";
|
||||
//调整套餐
|
||||
private static final String JIGUANG_CHANGE_COMBO = "41";
|
||||
//取消所有套餐
|
||||
private static final String JIGUANG_CANCEL_COMBO = "42";
|
||||
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -217,7 +237,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
case JIGUANG_APP_NETWORKSTATE:
|
||||
ToastUtil.debugShow("收到推送消息: 应用联网管控");
|
||||
setAppNetworkstate(context, extras);
|
||||
HTTPInterface.getAppInside();
|
||||
Handler.getMain().postDelayed(HTTPInterface::getAppInside, 2000);
|
||||
break;
|
||||
case JIGUANG_APP_LOCKEDSTATE:
|
||||
ToastUtil.debugShow("收到推送消息: 应用锁管控");
|
||||
@@ -263,12 +283,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
case JIGUANG_APP_NET_AUTO:
|
||||
ToastUtil.debugShow("收到推送消息: APP联网自启管控");
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HTTPInterface.getAllappPackage(context);
|
||||
}
|
||||
}, 2000);
|
||||
Handler.getMain().postDelayed(() -> HTTPInterface.getAllappPackage(context), 2000);
|
||||
break;
|
||||
case JIGUANG_BROWSER_LABEL:
|
||||
try {
|
||||
@@ -290,12 +305,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
case JIGUANG_APP_SETTING:
|
||||
ToastUtil.debugShow("收到推送消息: 获取app管控设置");
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HTTPInterface.getAllappPackage(context);
|
||||
}
|
||||
}, 2000);
|
||||
Handler.getMain().postDelayed(() -> HTTPInterface.getAllappPackage(context), 2000);
|
||||
break;
|
||||
case JIGUANG_FORCE_KILL:
|
||||
ToastUtil.debugShow("收到推送消息: 强制停止应用");
|
||||
@@ -353,11 +363,18 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
ToastUtil.debugShow("收到推送消息: 电话白名单管控");
|
||||
setPhone(context, extras);
|
||||
break;
|
||||
case JIGUANG_CHANGE_COMBO:
|
||||
changeCombo(context, extras);
|
||||
break;
|
||||
case JIGUANG_CANCEL_COMBO:
|
||||
cancleCombo(context, extras);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int changeNum(int paramInt) {
|
||||
return paramInt == 1 ? 0 : 1;
|
||||
}
|
||||
@@ -399,7 +416,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
synchronized private void setTfcardState(Context context, String jsonString) {
|
||||
if (!TextUtils.isEmpty(jsonString)) {
|
||||
JSONObject extra = JSON.parseObject(jsonString);
|
||||
int is_tf = extra.getInteger("setting_memory");
|
||||
int is_tf = extra.getIntValue("setting_memory");
|
||||
boolean qch_sdcard_forbid_on = JGYUtils.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", changeNum(is_tf));
|
||||
if (qch_sdcard_forbid_on) {
|
||||
Log.e("setTfcardState:", JGYUtils.getString(context.getContentResolver(), "qch_sdcard_forbid_on"));
|
||||
@@ -419,7 +436,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();//获取默认蓝牙适配器
|
||||
}
|
||||
JSONObject extra = JSON.parseObject(jsonString);
|
||||
int is_bluetooth = changeNum(extra.getInteger("setting_bluetooth"));
|
||||
int is_bluetooth = changeNum(extra.getIntValue("setting_bluetooth"));
|
||||
Log.e(TAG, "qch_bht_forbid_on:" + is_bluetooth);
|
||||
try {
|
||||
//写入系统数据库
|
||||
@@ -474,7 +491,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
if (!TextUtils.isEmpty(jsonString)) {
|
||||
JSONObject extra = JSON.parseObject(jsonString);
|
||||
String packageName = extra.getString("package");
|
||||
int is_lock = extra.getInteger("is_lock");
|
||||
int is_lock = extra.getIntValue("is_lock");
|
||||
ToastUtil.debugShow("收到应用锁管控消息:包名" + packageName + "is_lock_state:" + is_lock);
|
||||
PackageManager pm = context.getPackageManager();
|
||||
//后台为0可能传过来null
|
||||
@@ -622,7 +639,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
private void setTFmedia(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
//影音管控开关
|
||||
int setting_tfmedia = jsonObject.getInteger("setting_tfmedia");
|
||||
int setting_tfmedia = jsonObject.getIntValue("setting_tfmedia");
|
||||
Log.e("SystemSetting", "qch_tfmedia_forbid---------" + setting_tfmedia);
|
||||
|
||||
if (setting_tfmedia == 1) {
|
||||
@@ -642,16 +659,16 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
private void setCameta(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
//摄像头开关
|
||||
int setting_camera = changeNum(jsonObject.getInteger("setting_camera"));
|
||||
int setting_camera = changeNum(jsonObject.getIntValue("setting_camera"));
|
||||
JGYUtils.putInt(context.getContentResolver(), "qch_app_camera", setting_camera);
|
||||
ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera");
|
||||
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
|
||||
String cameraStatus = "";
|
||||
switch (setting_camera) {
|
||||
case 1:
|
||||
case 0:
|
||||
cameraStatus = "qch_camera_open";
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
cameraStatus = "qch_camera_forbid";
|
||||
break;
|
||||
default:
|
||||
@@ -698,9 +715,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
// intent.putExtra("name", name);
|
||||
if (type.equals("1")) {
|
||||
if ("1".equals(type)) {
|
||||
intent.setAction(ManagerService.ACTION_LOCK);
|
||||
} else if (type.equals("0")) {
|
||||
} else if ("0".equals(type)) {
|
||||
intent.setAction(ManagerService.ACTION_UNLOCK);
|
||||
}
|
||||
context.sendBroadcast(intent);
|
||||
@@ -841,7 +858,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
*/
|
||||
private void setHotspot(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int setting_hotspot = changeNum(jsonObject.getInteger("setting_hotspot"));//热点
|
||||
int setting_hotspot = changeNum(jsonObject.getIntValue("setting_hotspot"));//热点
|
||||
try {
|
||||
if (setting_hotspot == 1) {
|
||||
Intent intent = new Intent();
|
||||
@@ -859,20 +876,20 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private void setRestore(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int mode = jsonObject.getInteger("qch_restore");
|
||||
int mode = jsonObject.getIntValue("qch_restore");
|
||||
boolean qch_restore_forbid_on = JGYUtils.putInt(context.getContentResolver(), "qch_restore_forbid_on", changeNum(mode));
|
||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
}
|
||||
|
||||
private void setBrowserInput(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int setting_browserInput = changeNum(jsonObject.getInteger("setting_browserInput"));
|
||||
int setting_browserInput = changeNum(jsonObject.getIntValue("setting_browserInput"));
|
||||
JGYUtils.putInt(context.getContentResolver(), "qch_Browser_input", setting_browserInput);
|
||||
}
|
||||
|
||||
private void setDeveloper(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int dev_mode = changeNum(jsonObject.getInteger("dev_mode"));
|
||||
int dev_mode = changeNum(jsonObject.getIntValue("dev_mode"));
|
||||
Log.e(TAG, "getDeveloper: " + dev_mode);
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
JGYUtils.putInt(context.getContentResolver(), "qch_Developeroptions", dev_mode);
|
||||
@@ -912,9 +929,211 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
private void searchTopic(Context context, String jsonString) {
|
||||
Log.e(TAG, "searchTopic: " + jsonString);
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int search_topic = jsonObject.getInteger("search_topic");
|
||||
int search_topic = jsonObject.getIntValue("search_topic");
|
||||
SPUtils.put(context, "search_topic", search_topic);
|
||||
JGYUtils.updateForbidList(context);
|
||||
}
|
||||
|
||||
private void changeCombo(Context context, String jsonString) {
|
||||
Log.e(TAG, "changeCombo: " + jsonString);
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
String card_info = jsonObject.getString("card_info");
|
||||
if (TextUtils.isEmpty(card_info)) {
|
||||
ToastUtil.show("要修改的套餐名为空");
|
||||
} else {
|
||||
HashSet<String> infoSet = new HashSet<>(Arrays.asList(card_info.split(",")));
|
||||
for (String cardInfo : infoSet) {
|
||||
queryAvailableProduct(cardInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void queryAvailableProduct(String card_info) {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryProductControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + ":queryAvailableProduct", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + ":queryAvailableProduct", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
if (gankaoBaseResponse.code == 10000) {
|
||||
Type type = new TypeToken<List<AvailableProduct>>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<AvailableProduct> availableProductList = gson.fromJson(gson.toJson(gankaoBaseResponse.data), type);
|
||||
AvailableProduct product = null;
|
||||
for (AvailableProduct availableProduct : availableProductList) {
|
||||
if (availableProduct.getDuration().contains(card_info)) {
|
||||
product = availableProduct;
|
||||
}
|
||||
}
|
||||
activeUser(product);
|
||||
} else {
|
||||
ToastUtil.show("获取激活套餐失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + ":queryAvailableProduct", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":queryAvailableProduct", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void activeUser(@NotNull AvailableProduct product) {
|
||||
if (product == null) {
|
||||
ToastUtil.show("获取套餐失败");
|
||||
return;
|
||||
}
|
||||
String specification_id = product.getSpecification_id();
|
||||
Log.e(TAG, "activeUser: specification_id: " + specification_id);
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
params.put("specification_id", String.valueOf(specification_id));
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getActiveUserControl()
|
||||
.activeUser(appid, timestamp, LaunchTools.getToken(params), uid, specification_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<GankaoBaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG + ":activeUser", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse gankaoBaseResponse) {
|
||||
Log.e(TAG + ":activeUser", "onNext: " + JSONObject.toJSONString(gankaoBaseResponse));
|
||||
switch (gankaoBaseResponse.code) {
|
||||
case 10000:
|
||||
case 50000:
|
||||
// sendUid(product, gankaoUID);
|
||||
ToastUtil.show("激活成功:" + product.getDuration());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG + ":activeUser", "onError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":activeUser", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
interface GetUserProductsCallback {
|
||||
void activeUserProduct(UserProduct activeUserProduct);
|
||||
}
|
||||
|
||||
private void getUserProducts(String card_info, GetUserProductsCallback callback) {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getUserProductsControl()
|
||||
.getUserProducts(appid, timestamp, LaunchTools.getToken(params), uid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<GankaoBaseResponse<UserProductCards<List<UserProduct>>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GankaoBaseResponse<UserProductCards<List<UserProduct>>> userProductCardsGankaoBaseResponse) {
|
||||
Log.e("getUserProducts", "onNext: " + userProductCardsGankaoBaseResponse.toString());
|
||||
if (userProductCardsGankaoBaseResponse.code == 200) {
|
||||
UserProduct userProduct = null;
|
||||
for (UserProduct product : userProductCardsGankaoBaseResponse.data.getCards()) {
|
||||
if (product.getName().contains("权益套装") && product.getName().contains(card_info)) {
|
||||
userProduct = product;
|
||||
}
|
||||
}
|
||||
callback.activeUserProduct(userProduct);
|
||||
} else {
|
||||
ToastUtil.show("获取用户已激活的套餐失败");
|
||||
callback.activeUserProduct(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getUserProducts", "onError: " + e.getMessage());
|
||||
callback.activeUserProduct(null);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getUserProducts", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void cancleCombo(Context context, String jsonString) {
|
||||
Log.e(TAG, "cancleCombo: " + jsonString);
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
cancelUserPower(jsonObject);
|
||||
|
||||
}
|
||||
|
||||
private void cancelUserPower(JSONObject jsonObject) {
|
||||
String appid = Scheme.partner_id;
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String uid = Utils.getSerial();
|
||||
String user_power_id = jsonObject.getString("user_power_id");
|
||||
String specification_id = jsonObject.getString("specification_id");
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("appid", appid);
|
||||
params.put("timestamp", timestamp);
|
||||
params.put("uid", uid);
|
||||
params.put("user_power_id", user_power_id);
|
||||
params.put("specification_id", specification_id);
|
||||
|
||||
NetInterfaceManager.getInstance()
|
||||
.getCancelUserPowerControl()
|
||||
.cancelUserPower(appid, timestamp, LaunchTools.getToken(params), user_power_id, specification_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.info.sn.activity.main.MainActivity;
|
||||
import com.info.sn.activity.main.MainContact;
|
||||
@@ -15,6 +18,7 @@ import com.info.sn.activity.main.MainPresenter;
|
||||
import com.info.sn.bean.zuoye.BaseResponse;
|
||||
import com.info.sn.bean.zuoye.UserInfo;
|
||||
import com.info.sn.bean.gankao.AvailableProduct;
|
||||
import com.info.sn.config.Configs;
|
||||
import com.info.sn.jpush.TagAliasOperatorHelper;
|
||||
import com.info.sn.manager.ControlManager;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
@@ -27,6 +31,8 @@ import com.trello.rxlifecycle2.RxLifecycle;
|
||||
import com.trello.rxlifecycle2.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -197,6 +203,11 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
||||
TagAliasOperatorHelper.getInstance().handleAction(MainService.this, TagAliasOperatorHelper.sequence, tagAliasBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowerUserList(String date) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSNFinish(int code) {
|
||||
|
||||
@@ -208,12 +219,12 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAvailableProduct(List<AvailableProduct> availableProductList) {
|
||||
public void setAvailableProduct(List<AvailableProduct> availableProductList, String gankaoUID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeUser(int code) {
|
||||
public void activeUserFinish(int code) {
|
||||
|
||||
}
|
||||
|
||||
@@ -223,17 +234,69 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfo(BaseResponse<UserInfo> response) {
|
||||
int code = response.code;
|
||||
if (code == 200) {
|
||||
mPresenter.getLocked();
|
||||
public void setSnInfo(BaseResponse<UserInfo> response) {
|
||||
if (response != null) {
|
||||
int code = response.code;
|
||||
//设备已经绑定
|
||||
if (code == 200) {
|
||||
UserInfo userInfo = response.data;
|
||||
boolean username = Settings.System.putString(getContentResolver(), "UserInfo_username", userInfo.getSn_name());
|
||||
boolean gread = Settings.System.putString(getContentResolver(), "UserInfo_grade", userInfo.getGrade());
|
||||
SPUtils.put(this, Configs.isLogined, 1);
|
||||
SPUtils.put(this, "member_id", userInfo.getMember_id());
|
||||
SPUtils.put(this, "sn_id", userInfo.getId());
|
||||
if (!TextUtils.isEmpty(userInfo.getSn_name())) {
|
||||
SPUtils.put(this, "USERINFO_NAME", userInfo.getSn_name());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getSchool())) {
|
||||
SPUtils.put(this, "USERINFO_SCHOOL", userInfo.getSchool());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userInfo.getGrade())) {
|
||||
SPUtils.put(this, "USERINFO_GRADE", userInfo.getGrade());
|
||||
}
|
||||
|
||||
mPresenter.getLocked();
|
||||
}
|
||||
//设备没有绑定
|
||||
else if (code == 300) {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
//没有授权的设备
|
||||
else if (code == 400) {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
}
|
||||
mPresenter.getSnUid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnUid(JSONObject jsonObject) {
|
||||
if (jsonObject != null) {
|
||||
String uid = jsonObject.getString("uid");
|
||||
if (!TextUtils.isEmpty(uid)) {
|
||||
Settings.System.putString(getContentResolver(), "gankaoUID", uid);
|
||||
}
|
||||
// String uid = jsonObject.getString("uid");
|
||||
// long activate_time = jsonObject.getLong("activate_time");
|
||||
// String card_info = jsonObject.getString("card_info");
|
||||
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// Date d1 = new Date(activate_time * 1000);
|
||||
// int grade = jsonObject.getIntValue("grade");
|
||||
// SPUtils.put(MainService.this, "int_grade", grade);
|
||||
// String t1 = format.format(d1);
|
||||
} else {
|
||||
mPresenter.registerGankao();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGankao(String gankaoUID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserInfo() {
|
||||
|
||||
mPresenter.getSnInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ManagerService extends Service {
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(baseResponse.data));
|
||||
int is_screen_lock = jsonObject.getInteger("is_screen_lock");
|
||||
int is_screen_lock = jsonObject.getIntValue("is_screen_lock");
|
||||
if (is_screen_lock == 1) {
|
||||
if (!timelocked) {
|
||||
showFloatingWindow("屏幕已锁定");
|
||||
@@ -223,14 +223,14 @@ public class ManagerService extends Service {
|
||||
getScreenLockState();
|
||||
return;
|
||||
}
|
||||
if (ACTION_LOCK == action) {
|
||||
if (ACTION_LOCK.equals(action)) {
|
||||
// String name = intent.getStringExtra("name");
|
||||
String name = "屏幕已锁定";
|
||||
if (!timelocked) {
|
||||
showFloatingWindow(name);
|
||||
}
|
||||
screenlocked = true;
|
||||
} else if (ACTION_UNLOCK == action) {
|
||||
} else if (ACTION_UNLOCK.equals(action)) {
|
||||
if (!timelocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
@@ -288,10 +288,10 @@ public class ManagerService extends Service {
|
||||
// if (null != workingContralTime) {
|
||||
if (TimeUtils.inContralTime(workingContralTime, weekContralTime)) {
|
||||
if (!screenlocked) {
|
||||
showFloatingWindow("管控时间:\n" + TimeUtils.getNowTimeString(ManagerService.this));
|
||||
showFloatingWindow("可用时间:\n" + TimeUtils.getNowTimeString(ManagerService.this));
|
||||
} else {
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText("管控时间:\n" + TimeUtils.getNowTimeString(ManagerService.this));
|
||||
textView.setText("可用时间:\n" + TimeUtils.getNowTimeString(ManagerService.this));
|
||||
}
|
||||
timelocked = true;
|
||||
} else {
|
||||
@@ -317,9 +317,14 @@ public class ManagerService extends Service {
|
||||
screenLockReceiver = new ScreenLockReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
|
||||
filter.addAction(Intent.ACTION_USER_PRESENT);
|
||||
filter.addAction(Intent.ACTION_SHUTDOWN);
|
||||
filter.addAction(Intent.ACTION_FACTORY_RESET);
|
||||
filter.addAction(Intent.ACTION_MASTER_CLEAR);
|
||||
registerReceiver(screenLockReceiver, filter);
|
||||
}
|
||||
|
||||
@@ -334,11 +339,13 @@ public class ManagerService extends Service {
|
||||
}
|
||||
switch (action) {
|
||||
case Intent.ACTION_USER_PRESENT:
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_ON:
|
||||
sendScreenState(1);
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_OFF:
|
||||
case Intent.ACTION_SHUTDOWN:
|
||||
case Intent.ACTION_FACTORY_RESET:
|
||||
case Intent.ACTION_MASTER_CLEAR:
|
||||
sendScreenState(0);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -12,20 +12,25 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.info.sn.KeepAliveConnection;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.activity.main.MainActivity;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.JGYUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -181,8 +186,19 @@ public class MyDownloadService extends Service {
|
||||
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
void running(DownloadTask task) {
|
||||
void running(DownloadTask task) {
|
||||
Log.e("aria running", "正在下载:" + task.getState() + "--" + task.getPercent() + "--" + task.getExtendField());
|
||||
String appName = "";
|
||||
try {
|
||||
String jsonString = task.getExtendField();
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
if (!TextUtils.isEmpty(jsonString) && jsonObject != null) {
|
||||
appName = jsonObject.getString("app_name");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("running", "running: " + e.getMessage());
|
||||
}
|
||||
ToastUtils.showShort("正在下载:" + appName + "--" + task.getPercent() + "%");
|
||||
}
|
||||
|
||||
@Download.onTaskComplete
|
||||
@@ -192,5 +208,4 @@ public class MyDownloadService extends Service {
|
||||
Log.e("taskComplete", task.getExtendField());
|
||||
Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ public class RemoteService extends Service {
|
||||
public String getUserInfo() throws RemoteException {
|
||||
String username = Settings.System.getString(getContentResolver(), "UserInfo_username");
|
||||
String avatar = Settings.System.getString(getContentResolver(), "UserInfo_avatar");
|
||||
String gread = Settings.System.getString(getContentResolver(), "UserInfo_grade");
|
||||
// String gread = Settings.System.getString(getContentResolver(), "UserInfo_grade");
|
||||
int gread = (int) SPUtils.get(RemoteService.this,"int_grade",0);
|
||||
String gankaoUID = Settings.System.getString(getContentResolver(), "gankaoUID");
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("username", username);
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
@@ -40,6 +41,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
@@ -790,6 +792,7 @@ public class ApkUtils {
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
|
||||
public static String getTaskPackname(Context context) {
|
||||
String currentApp = "CurrentNULL";
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
@@ -813,4 +816,22 @@ public class ApkUtils {
|
||||
// Log.e("TAG", "Current App in foreground is: " + currentApp);
|
||||
return currentApp;
|
||||
}
|
||||
|
||||
public static boolean getIsCanStart(Context context, String pkg) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN, null);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
// 通过查询,获得所有ResolveInfo对象.
|
||||
List<ResolveInfo> infos = context.getPackageManager().queryIntentActivities(intent, 0);
|
||||
HashMap<String, ResolveInfo> hashMap = new HashMap<>();
|
||||
for (ResolveInfo info : infos) {
|
||||
hashMap.put(info.activityInfo.packageName, info);
|
||||
}
|
||||
if (hashMap.get(pkg) == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,8 +33,11 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||
|
||||
@@ -610,4 +613,129 @@ public class JGYUtils {
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
//应用管理-允许联网
|
||||
public final static String ACTION_HrReceiver_JGY = "qch_jgy_network_allow";
|
||||
//应用管理-禁止联网
|
||||
public final static String ACTION_HrReceiver_JGY_DIS = "qch_jgy_network_disallow";
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
synchronized public static void setAppNetwork(Context context, HashSet<String> blackList) {
|
||||
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控" + blackList);
|
||||
String dis = Settings.System.getString(context.getContentResolver(), ACTION_HrReceiver_JGY_DIS);
|
||||
String not = Settings.System.getString(context.getContentResolver(), ACTION_HrReceiver_JGY);
|
||||
//清除旧数据
|
||||
if (!TextUtils.isEmpty(dis)) {
|
||||
Log.e(TAG, "setAppNetwork: dis = " + dis);
|
||||
Settings.System.putString(context.getContentResolver(), ACTION_HrReceiver_JGY_DIS, "Invalid");
|
||||
}
|
||||
if (!TextUtils.isEmpty(not)) {
|
||||
Log.e(TAG, "setAppNetwork: not = " + not);
|
||||
Settings.System.putString(context.getContentResolver(), ACTION_HrReceiver_JGY, "Invalid");
|
||||
}
|
||||
|
||||
String oldBlackList = (String) SPUtils.get(context, ACTION_HrReceiver_JGY_DIS, "");
|
||||
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(",")));
|
||||
oldBlackListSet.removeIf(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
//去空
|
||||
return TextUtils.isEmpty(s.trim());
|
||||
}
|
||||
});
|
||||
//之前禁止上网得列表
|
||||
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
|
||||
if (oldBlackListSet.size() == 0) {
|
||||
Log.e(TAG, "setAppNetwork: blackList: " + blackList);
|
||||
for (String pkg : blackList) {
|
||||
if (TextUtils.isEmpty(pkg)) continue;
|
||||
//发送没有安装的
|
||||
if (!ApkUtils.isAvailable(context, pkg)) {
|
||||
Log.e(TAG, "setAppNetwork: skip: " + pkg);
|
||||
continue;
|
||||
} else {
|
||||
Log.e(TAG, "setAppNetwork: " + pkg + " 已安装");
|
||||
}
|
||||
Intent netControlNotIntent = new Intent(ACTION_HrReceiver_JGY_DIS);
|
||||
netControlNotIntent.putExtra("package_name", pkg);
|
||||
netControlNotIntent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(netControlNotIntent);
|
||||
}
|
||||
} else {
|
||||
//减少的
|
||||
Set<String> removedNet = oldBlackListSet;
|
||||
//增加的
|
||||
Set<String> addedNet = new HashSet<>();
|
||||
for (String pkg : blackList) {
|
||||
if (TextUtils.isEmpty(pkg)) continue;
|
||||
if (removedNet.contains(pkg)) {
|
||||
removedNet.remove(pkg);
|
||||
} else {
|
||||
addedNet.add(pkg);
|
||||
}
|
||||
}
|
||||
|
||||
Log.e(TAG, "setAppNetwork: removedNet: " + removedNet);
|
||||
Log.e(TAG, "setAppNetwork: addedNet: " + addedNet);
|
||||
for (String pkg : removedNet) {
|
||||
if (TextUtils.isEmpty(pkg)) continue;
|
||||
Intent netControlNotIntent = new Intent(ACTION_HrReceiver_JGY);
|
||||
netControlNotIntent.putExtra("package_name", pkg);
|
||||
netControlNotIntent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(netControlNotIntent);
|
||||
}
|
||||
for (String pkg : addedNet) {
|
||||
if (TextUtils.isEmpty(pkg)) continue;
|
||||
if (!ApkUtils.isAvailable(context, pkg)) {
|
||||
Log.e(TAG, "setAppNetwork: skip: " + pkg);
|
||||
continue;
|
||||
} else {
|
||||
Log.e(TAG, "setAppNetwork: " + pkg + " 已安装");
|
||||
}
|
||||
Intent netControlNotIntent = new Intent(ACTION_HrReceiver_JGY_DIS);
|
||||
netControlNotIntent.putExtra("package_name", pkg);
|
||||
netControlNotIntent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(netControlNotIntent);
|
||||
}
|
||||
}
|
||||
|
||||
String net_not = String.join(",", blackList);
|
||||
SPUtils.put(context, ACTION_HrReceiver_JGY_DIS, net_not);
|
||||
//Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
|
||||
Log.e("fht", "not::" + net_not);
|
||||
|
||||
//Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
|
||||
//netControlIntent.putExtra("package_name", net_not);
|
||||
//sendBroadcast(netControlIntent);
|
||||
|
||||
//Intent netControlNotIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY);
|
||||
//netControlNotIntent.putExtra("package_name", net_ok);
|
||||
//sendBroadcast(netControlNotIntent);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
synchronized public void onBootSendNetwork() {
|
||||
String oldBlackListString = (String) SPUtils.get(mContext, ACTION_HrReceiver_JGY_DIS, "");
|
||||
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackListString.split(",")));
|
||||
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
|
||||
oldBlackListSet.removeIf(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return TextUtils.isEmpty(s.trim());
|
||||
}
|
||||
});
|
||||
for (String pkg : oldBlackListSet) {
|
||||
if (TextUtils.isEmpty(pkg)) continue;
|
||||
if (!ApkUtils.isAvailable(mContext, pkg)) {
|
||||
Log.e(TAG, "setAppNetwork: skip: " + pkg);
|
||||
continue;
|
||||
}
|
||||
Intent netControlNotIntent = new Intent(ACTION_HrReceiver_JGY_DIS);
|
||||
netControlNotIntent.putExtra("package_name", pkg);
|
||||
netControlNotIntent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(netControlNotIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public class TimeUtils {
|
||||
public static final String WEEK_START_TIME_KEY = "WEEK_START_TIME";
|
||||
public static final String WEEK_END_TIME_KEY = "WEEK_END_TIME";
|
||||
public static long dayTime = 60 * 60 * 24 * 1000;
|
||||
public static long minuteTime = 60 * 1000;
|
||||
|
||||
|
||||
public static String getNowTime() {
|
||||
long nowTime = System.currentTimeMillis();
|
||||
@@ -173,7 +175,7 @@ public class TimeUtils {
|
||||
* @return 时间戳格式化文本
|
||||
*/
|
||||
public static String getDate(long time) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String finaWayDate = sdf.format(time);
|
||||
Log.e(TAG, "getDate: " + finaWayDate);
|
||||
return finaWayDate;
|
||||
@@ -332,7 +334,9 @@ public class TimeUtils {
|
||||
//开始时间大于结束时间 列 16:00-01:00
|
||||
endDate.setTime(endDate.getTime() + dayTime);
|
||||
}
|
||||
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
|
||||
Log.e(TAG, "inControlTime: " + (startDate.getTime() - minuteTime));
|
||||
assert nowDate != null;
|
||||
if (nowDate.getTime() <= startDate.getTime() - minuteTime || nowDate.getTime() >= endDate.getTime()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1169,6 +1169,7 @@ public class Utils {
|
||||
|
||||
/**
|
||||
* 获取系统配置信息
|
||||
*
|
||||
* @param key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
@@ -1216,7 +1217,7 @@ public class Utils {
|
||||
Log.e(TAG, "getHardware: storage = " + storage);
|
||||
double use_space = getUse_space(context);
|
||||
Log.e(TAG, "getHardware: use_space = " + use_space);
|
||||
long wifi_time = (long) com.info.sn.utils.SPUtils.get(context, "wifi_last_connect_time", 0L)/1000;
|
||||
long wifi_time = (long) com.info.sn.utils.SPUtils.get(context, "wifi_last_connect_time", 0L) / 1000;
|
||||
Log.e(TAG, "getHardware: wifi_time" + wifi_time);
|
||||
int CPU = getNumCores();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@@ -1246,7 +1247,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String getAppUsedStatistics(Context context) {
|
||||
StatisticsInfo statisticsInfo = new StatisticsInfo(context, 3);
|
||||
StatisticsInfo statisticsInfo = new StatisticsInfo(context, 0);
|
||||
long totalTime = statisticsInfo.getTotalTime();
|
||||
int totalTimes = statisticsInfo.getTotalTimes();
|
||||
List<AppInformation> datalist = statisticsInfo.getShowList();
|
||||
@@ -1265,6 +1266,7 @@ public class Utils {
|
||||
}
|
||||
});
|
||||
String jsonString = JSON.toJSONString(appUsedList);
|
||||
Log.e(TAG, "getAppUsedStatistics: " + jsonString);
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
|
||||
72
app/src/main/java/com/info/sn/view/FlowRadioGroup.java
Normal file
72
app/src/main/java/com/info/sn/view/FlowRadioGroup.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.info.sn.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
/**
|
||||
* 流式布局的RadioGroup
|
||||
*/
|
||||
public class FlowRadioGroup extends RadioGroup {
|
||||
|
||||
public FlowRadioGroup(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public FlowRadioGroup(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int childCount = getChildCount();
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int row = 0;
|
||||
|
||||
for (int index = 0; index < childCount; index++) {
|
||||
final View child = getChildAt(index);
|
||||
if (child.getVisibility() != View.GONE) {
|
||||
child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
// 此处增加onlayout中的换行判断,用于计算所需的高度
|
||||
int width = child.getMeasuredWidth();
|
||||
int height = child.getMeasuredHeight();
|
||||
x += width;
|
||||
y = row * height + height;
|
||||
if (x > maxWidth) {
|
||||
x = width;
|
||||
row++;
|
||||
y = row * height + height;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置容器所需的宽度和高度
|
||||
setMeasuredDimension(maxWidth, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
final int childCount = getChildCount();
|
||||
int maxWidth = r - l;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int row = 0;
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = this.getChildAt(i);
|
||||
if (child.getVisibility() != View.GONE) {
|
||||
int width = child.getMeasuredWidth();
|
||||
int height = child.getMeasuredHeight();
|
||||
x += width;
|
||||
y = row * height + height;
|
||||
if (x > maxWidth) {
|
||||
x = width;
|
||||
row++;
|
||||
y = row * height + height;
|
||||
}
|
||||
child.layout(x - width, y - height, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user