version:1.5
fix:迁移到奥乐云平台 add:
This commit is contained in:
127
src/com/aoleyun/os/network/HTTPInterface.java
Normal file
127
src/com/aoleyun/os/network/HTTPInterface.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package com.aoleyun.os.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
import static com.aoleyun.os.jpush.TagAliasOperatorHelper.ACTION_SET;
|
||||
import static com.aoleyun.os.jpush.TagAliasOperatorHelper.sequence;
|
||||
|
||||
/**
|
||||
* @author : fanhuitong
|
||||
* e-mail :
|
||||
* @date : 2021/10/27 15:31
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class HTTPInterface {
|
||||
private static final String TAG = HTTPInterface.class.getSimpleName();
|
||||
|
||||
public static void getAppPasswd() {
|
||||
NetWorkManager.getInstance().getAppPasswordObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppPasswdBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getAppPasswd", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<List<AppPasswdBean>> listBaseResponse) {
|
||||
Log.e("getAppPasswd", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
List<AppPasswdBean> beanList = listBaseResponse.data;
|
||||
String jsonString = JsonParser.parseString(new Gson().toJson(beanList)).getAsJsonArray().toString();
|
||||
MMKV.defaultMMKV().encode("ApplicationLock", jsonString);
|
||||
Log.e("getAppPasswd", "onNext: " + jsonString);
|
||||
} else {
|
||||
MMKV.defaultMMKV().encode("ApplicationLock", "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getAppPasswd", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppPasswd", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public static void setJpushTags(final Context context) {
|
||||
NetWorkManager.getInstance()
|
||||
.getJpushTagsObservable()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse response) {
|
||||
if (response.code == 200) {
|
||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
||||
String batch = jsonObject.get("batch").getAsString();
|
||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + batch);
|
||||
if (!TextUtils.isEmpty(batch)) {
|
||||
Set set = new HashSet();
|
||||
set.add(batch);
|
||||
JGYUtils.getInstance().getAppPlatform(new JGYUtils.GetAppPlatformCallback() {
|
||||
@Override
|
||||
public void AppPlatform(int platform) {
|
||||
if (platform == JGYUtils.MTKPlatform) {
|
||||
set.add(JGYUtils.MTKTag);
|
||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||
set.add(JGYUtils.ZhanruiTag);
|
||||
}
|
||||
}
|
||||
});
|
||||
setTag(context, set);
|
||||
} else {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + response.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setTag(Context context, Set set) {
|
||||
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||
tagAliasBean.action = ACTION_SET;
|
||||
sequence++;
|
||||
tagAliasBean.tags = set;
|
||||
tagAliasBean.isAliasAction = false;
|
||||
TagAliasOperatorHelper.getInstance().handleAction(context, sequence, tagAliasBean);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user