feat#_注销接口
This commit is contained in:
parent
7907e47f0c
commit
e8f52aa35f
|
|
@ -24,8 +24,10 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
|
import com.ifish.activity.newbind.NewBindDeviceActivity;
|
||||||
import com.ifish.basebean.BaseBean;
|
import com.ifish.basebean.BaseBean;
|
||||||
import com.ifish.basebean.FinishMainActivity;
|
import com.ifish.basebean.FinishMainActivity;
|
||||||
|
import com.ifish.basebean.User;
|
||||||
import com.ifish.basebean.Version;
|
import com.ifish.basebean.Version;
|
||||||
import com.ifish.baseclass.BaseActivity;
|
import com.ifish.baseclass.BaseActivity;
|
||||||
import com.ifish.baseclass.UriForFile;
|
import com.ifish.baseclass.UriForFile;
|
||||||
|
|
@ -89,24 +91,16 @@ public class MySettingActivity extends BaseActivity {
|
||||||
if (BuildConfig.DEBUG){
|
if (BuildConfig.DEBUG){
|
||||||
tvDebug = findMyViewById(R.id.tv_debug);
|
tvDebug = findMyViewById(R.id.tv_debug);
|
||||||
tvDebug.setVisibility(View.VISIBLE);
|
tvDebug.setVisibility(View.VISIBLE);
|
||||||
tvDebug.setOnClickListener(new View.OnClickListener() {
|
tvDebug.setOnClickListener(view -> startActivity(new Intent(MySettingActivity.this,PhoneInfoActivity.class)));
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
startActivity(new Intent(MySettingActivity.this,PhoneInfoActivity.class));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView title_text = (TextView) findViewById(R.id.title_text);
|
TextView title_text = (TextView) findViewById(R.id.title_text);
|
||||||
title_text.setOnClickListener(new View.OnClickListener() {
|
title_text.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
clickCount++;
|
clickCount++;
|
||||||
if (clickCount == MAX_CLICKS) {
|
if (clickCount == MAX_CLICKS) {
|
||||||
startNewActivity();
|
startNewActivity();
|
||||||
clickCount = 0; // 重置计数器
|
clickCount = 0; // 重置计数器
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +126,58 @@ public class MySettingActivity extends BaseActivity {
|
||||||
findViewById(R.id.rl_devicerestart).setOnClickListener(this);
|
findViewById(R.id.rl_devicerestart).setOnClickListener(this);
|
||||||
findViewById(R.id.rl_devicereset).setOnClickListener(this);
|
findViewById(R.id.rl_devicereset).setOnClickListener(this);
|
||||||
findViewById(R.id.rl_bindphone).setOnClickListener(this);
|
findViewById(R.id.rl_bindphone).setOnClickListener(this);
|
||||||
|
findViewById(R.id.tv_exit).setOnClickListener(view -> exitAccount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exitAccount(){
|
||||||
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT);
|
||||||
|
dialog.setCancelable(true);
|
||||||
|
dialog.setTitle("提示");
|
||||||
|
dialog.setMessage("执行注销账号,您账号下的所有信息将从该平台彻底删除,且无法恢复,是否继续注销账户?");
|
||||||
|
dialog.setNegativeButton("取消", (arg0, arg1) -> {
|
||||||
|
arg0.dismiss();
|
||||||
|
});
|
||||||
|
dialog.setPositiveButton("继续注销", (dialog1, which) -> {
|
||||||
|
dialog1.dismiss();
|
||||||
|
hm.unregister(new HttpListener<BaseBean<User>>() {
|
||||||
|
private int result;
|
||||||
|
@Override
|
||||||
|
public void success(BaseBean<User> baseBean) {
|
||||||
|
result = baseBean.result;
|
||||||
|
if (baseBean.isSuccess()){
|
||||||
|
SPUtil sp = SPUtil.getInstance(MySettingActivity.this);
|
||||||
|
sp.clear();
|
||||||
|
Commons.clean();
|
||||||
|
exitAccountSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
updateHandler.sendEmptyMessage(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(Exception e, String msg) {
|
||||||
|
result = Commons.NetWork.ERROR;
|
||||||
|
}
|
||||||
|
},Commons.USER.getUserId());
|
||||||
|
});
|
||||||
|
|
||||||
|
L.i("jjia-------userId----"+Commons.USER.getUserId());
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
private void exitAccountSuccess(){
|
||||||
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT);
|
||||||
|
dialog.setCancelable(true);
|
||||||
|
dialog.setTitle("提示");
|
||||||
|
dialog.setMessage("账户注销成功,退出APP");
|
||||||
|
dialog.setPositiveButton("退出", (dialog1, which) -> {
|
||||||
|
dialog1.dismiss();
|
||||||
|
P2PHandler.getInstance().p2pDisconnect();//断开技威p2p连接
|
||||||
|
ActivityManager.getInstance().exit();
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -226,35 +272,27 @@ public class MySettingActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
}
|
}
|
||||||
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
dialog.setNegativeButton("取消", (dialog2, which) -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if ("1".equals(isMustUpdate)) {
|
if ("1".equals(isMustUpdate)) {
|
||||||
dialog.dismiss();
|
dialog2.dismiss();
|
||||||
mNotificationManager.cancelAll();//清除通知栏
|
mNotificationManager.cancelAll();//清除通知栏
|
||||||
P2PHandler.getInstance().p2pDisconnect();//断开技威p2p连接
|
P2PHandler.getInstance().p2pDisconnect();//断开技威p2p连接
|
||||||
ActivityManager.getInstance().exit();
|
ActivityManager.getInstance().exit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
dialog.setPositiveButton("确定", (dialog1, which) -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if ("1".equals(isMustUpdate)) {
|
if ("1".equals(isMustUpdate)) {
|
||||||
try {
|
try {
|
||||||
//不关闭
|
//不关闭
|
||||||
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
|
Field field = dialog1.getClass().getSuperclass().getDeclaredField("mShowing");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(dialog, false);
|
field.set(dialog1, false);
|
||||||
dialog.dismiss();
|
dialog1.dismiss();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showDownloadApkDialog();
|
showDownloadApkDialog();
|
||||||
dialog.dismiss();
|
dialog1.dismiss();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ifish.basebean;
|
package com.ifish.basebean;
|
||||||
|
|
||||||
|
import com.ifish.utils.Commons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @ClassName: BaseBean
|
* @ClassName: BaseBean
|
||||||
|
|
@ -11,4 +13,9 @@ public class BaseBean <T>{
|
||||||
public int result;
|
public int result;
|
||||||
public int total;
|
public int total;
|
||||||
public T data;
|
public T data;
|
||||||
|
|
||||||
|
public boolean isSuccess(){
|
||||||
|
return Commons.NetWork.Success == result;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -365,6 +365,40 @@ public class HttpManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public HttpHandler unregister(final HttpListener<BaseBean<User>> httpListener, String userId) {
|
||||||
|
String url = getFullUrl(users_URL + v3_URL + "deregister.do");
|
||||||
|
L.d(url);
|
||||||
|
RequestParams requestParams = new RequestParams();
|
||||||
|
requestParams.addBodyParameter("userId", userId);
|
||||||
|
String curTime = System.currentTimeMillis() / 1000 + "";
|
||||||
|
String nonce = getRandomNum() + "";
|
||||||
|
requestParams.addHeader(APPKEY, appKey);
|
||||||
|
requestParams.addHeader(NONCE, nonce);
|
||||||
|
requestParams.addHeader(CURTIME, curTime);
|
||||||
|
requestParams.addHeader(CHECKSUM, MD5Util.GetMD5(appSecret + nonce + curTime));
|
||||||
|
return http.send(HttpMethod.POST, url, requestParams, new RequestCallBack<String>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ResponseInfo<String> responseInfo) {
|
||||||
|
L.d(responseInfo.result.toString());
|
||||||
|
BaseBean<User> baseBean = null;
|
||||||
|
try {
|
||||||
|
baseBean = new Gson().fromJson(responseInfo.result, new TypeToken<BaseBean<User>>() {
|
||||||
|
}.getType());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
httpListener.success(baseBean);
|
||||||
|
httpListener.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(HttpException error, String msg) {
|
||||||
|
L.d("error=" + error + "msg=" + msg);
|
||||||
|
httpListener.error(error, msg);
|
||||||
|
httpListener.finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param @param httpListener
|
* @param @param httpListener
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@
|
||||||
<include
|
<include
|
||||||
android:id="@+id/in_daohang"
|
android:id="@+id/in_daohang"
|
||||||
layout="@layout/title_layout_device_alpha" />
|
layout="@layout/title_layout_device_alpha" />
|
||||||
<TabLayout
|
<!-- <TabLayout-->
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tabLayout"
|
android:id="@+id/tabLayout"
|
||||||
android:layout_below="@+id/rl_banner"
|
android:layout_below="@+id/rl_banner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue