|
|
@@ -30,8 +30,8 @@ public class CertificationUtil {
|
|
|
|
|
|
private static CertificationUtil certificationUtil;
|
|
|
|
|
|
- public static CertificationUtil newInstance(){
|
|
|
- if(certificationUtil == null)
|
|
|
+ public static CertificationUtil newInstance() {
|
|
|
+ if (certificationUtil == null)
|
|
|
certificationUtil = new CertificationUtil();
|
|
|
return certificationUtil;
|
|
|
}
|
|
|
@@ -39,71 +39,74 @@ public class CertificationUtil {
|
|
|
|
|
|
/**
|
|
|
* 退出app
|
|
|
+ *
|
|
|
* @param errorMsg
|
|
|
*/
|
|
|
- public void showCertificationErrorAndExitApp(final String errorMsg, long skip_time) {
|
|
|
+ public void showCertificationErrorAndExitApp(Activity activity, final String errorMsg, long skip_time) {
|
|
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
SheepApp.getInstance().setGamePackgeName("");
|
|
|
SheepApp.getInstance().setGameCode("");
|
|
|
SheepApp.getInstance().setGameFlag(false);
|
|
|
- SheepApp.getInstance().quit();
|
|
|
+ activity.finish();
|
|
|
}
|
|
|
}, skip_time);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 跳转回,游戏
|
|
|
*/
|
|
|
- public void doCertification(final Context context, String token, String packageName, String ext){
|
|
|
+ public void doCertification(final Activity activity, String token, String packageName, String ext) {
|
|
|
try {
|
|
|
- Log.e("game_-packgename---"+packageName,"");
|
|
|
+ Log.e("game_-packgename---" + packageName, "");
|
|
|
Intent intent = new Intent();
|
|
|
intent.setClassName(packageName, "com.kfzs.duanduan.data.observer.helper.WhistleActivity");
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
- intent.putExtra(context.getString(R.string.kfzs_duanduan_datashare_certification_key), SheepApp.getInstance().getGameCode());
|
|
|
+ intent.putExtra(activity.getString(R.string.kfzs_duanduan_datashare_certification_key), SheepApp.getInstance().getGameCode());
|
|
|
|
|
|
if (TextUtils.isEmpty(ext)) {
|
|
|
- intent.putExtra(context.getString(R.string.kfzs_duanduan_datashare_package_extras), "");
|
|
|
- intent.putExtra(context.getString(R.string.kfzs_duanduan_datashare_certification_token), token);
|
|
|
- } else if("delete".equals(ext)){
|
|
|
- intent.putExtra(context.getString(R.string.kfzs_duanduan_datashare_certification_cancel), "delete");
|
|
|
- }else {
|
|
|
- intent.putExtra(context.getString(R.string.kfzs_duanduan_datashare_package_extras), ext);
|
|
|
- intent.putExtra(context.getString(R.string.kfzs_duanduan_datashare_certification_token), token);
|
|
|
+ intent.putExtra(activity.getString(R.string.kfzs_duanduan_datashare_package_extras), "");
|
|
|
+ intent.putExtra(activity.getString(R.string.kfzs_duanduan_datashare_certification_token), token);
|
|
|
+ } else if ("delete".equals(ext)) {
|
|
|
+ intent.putExtra(activity.getString(R.string.kfzs_duanduan_datashare_certification_cancel), "delete");
|
|
|
+ } else {
|
|
|
+ intent.putExtra(activity.getString(R.string.kfzs_duanduan_datashare_package_extras), ext);
|
|
|
+ intent.putExtra(activity.getString(R.string.kfzs_duanduan_datashare_certification_token), token);
|
|
|
}
|
|
|
- context.startActivity(intent);
|
|
|
- showCertificationErrorAndExitApp("", 100);
|
|
|
+ activity.startActivity(intent);
|
|
|
+ showCertificationErrorAndExitApp(activity, "", 100);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- showCertificationErrorAndExitApp("认证失败", 100);
|
|
|
+ showCertificationErrorAndExitApp(activity, "认证失败", 100);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 验证获取数据
|
|
|
*/
|
|
|
- public void authCertificationCode(final Context context, final String token){
|
|
|
- ViewUtil.newInstance().showProgress((Activity) context);
|
|
|
+ public void authCertificationCode(final Activity activity, final String token) {
|
|
|
+ ViewUtil.newInstance().showProgress((Activity) activity);
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().verificationAuth(token, SheepApp.getInstance().getGameCode())
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
- ViewUtil.newInstance().hideProgress((Activity) context);
|
|
|
- if(baseMessage != null && baseMessage.getData() != null){
|
|
|
- Log.e("data-------","");
|
|
|
- doCertification(context, token, SheepApp.getInstance().getGamePackgeName(), baseMessage.getData()+"");
|
|
|
- }else {
|
|
|
- CertificationUtil.newInstance().showCertificationErrorAndExitApp("请求授权错误 " + (baseMessage == null ? "无数据" : baseMessage.getMsg()),1000);
|
|
|
+ ViewUtil.newInstance().hideProgress((Activity) activity);
|
|
|
+ if (baseMessage != null && baseMessage.getData() != null) {
|
|
|
+ Log.e("data-------", "");
|
|
|
+ doCertification(activity, token, SheepApp.getInstance().getGamePackgeName(), baseMessage.getData() + "");
|
|
|
+ } else {
|
|
|
+ showCertificationErrorAndExitApp(activity, "请求授权错误 " + (baseMessage == null ? "无数据" : baseMessage.getMsg()), 1000);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
- ViewUtil.newInstance().hideProgress((Activity) context);
|
|
|
- CertificationUtil.newInstance().showCertificationErrorAndExitApp("请求授权错误 " + baseMessage.getMsg(),1000);
|
|
|
+ ViewUtil.newInstance().hideProgress((Activity) activity);
|
|
|
+ showCertificationErrorAndExitApp(activity, "请求授权错误 " + baseMessage.getMsg(), 1000);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -113,7 +116,7 @@ public class CertificationUtil {
|
|
|
CommonUtil.getInstance().callActionWithUserInfo(new Action1<UserEntity>() {
|
|
|
@Override
|
|
|
public void call(UserEntity userEntity) {
|
|
|
- if(userEntity != null){
|
|
|
+ if (userEntity != null) {
|
|
|
SdkLoginUser newSdkLoginUser = new SdkLoginUser();
|
|
|
newSdkLoginUser.setAvatar(userEntity.getAvatar());
|
|
|
newSdkLoginUser.setToken(SpUtils.getToken(SheepApp.getInstance()));
|