273 lines
10 KiB
Java
273 lines
10 KiB
Java
package com.ubt.jimu.user.setting.view;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.RelativeLayout;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.cache.Constants;
|
|
import com.ubt.jimu.base.db.user.UserDbHandler;
|
|
import com.ubt.jimu.base.dialog.JimuSimpleDialog;
|
|
import com.ubt.jimu.base.entities.ApiStatus;
|
|
import com.ubt.jimu.base.entities.Constant;
|
|
import com.ubt.jimu.base.event.MessageEvent;
|
|
import com.ubt.jimu.course.repository.CourseResult;
|
|
import com.ubt.jimu.unity.ModelType;
|
|
import com.ubt.jimu.user.contract.SettingContract$Presenter;
|
|
import com.ubt.jimu.user.contract.SettingContract$View;
|
|
import com.ubt.jimu.user.presenter.SettingPresenter;
|
|
import com.ubt.jimu.user.view.setting.ThePolicyActivity;
|
|
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
|
import com.ubt.jimu.utils.LocaleUtils;
|
|
import com.ubt.jimu.utils.NetWorkUtil;
|
|
import com.ubt.jimu.utils.SPUtils;
|
|
import com.ubt.jimu.utils.ShortcutHelper;
|
|
import com.ubt.jimu.widgets.JAlertDialog;
|
|
import com.ubtech.utils.FileHelper;
|
|
import com.ubtech.view.fragment.BaseFragment;
|
|
import com.ubtech.view.widget.ToastView;
|
|
import java.io.File;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class PrivacyFragment extends BaseFragment implements View.OnClickListener, SettingContract$View {
|
|
private RelativeLayout a;
|
|
private RelativeLayout b;
|
|
private RelativeLayout c;
|
|
private RelativeLayout d;
|
|
private RelativeLayout e;
|
|
private SettingPresenter f;
|
|
protected JAlertDialog g;
|
|
|
|
static /* synthetic */ void d(DialogInterface dialogInterface, int i) {
|
|
SPUtils.a(Constant.NoviceGuide.AGREE_LEGAL_EXAMINE, false);
|
|
SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE, false);
|
|
JimuApplication.l().b();
|
|
}
|
|
|
|
private void initView(View view) {
|
|
this.a = (RelativeLayout) view.findViewById(R.id.forward_privacy);
|
|
this.b = (RelativeLayout) view.findViewById(R.id.child_privacy);
|
|
this.c = (RelativeLayout) view.findViewById(R.id.suggest_ll);
|
|
this.d = (RelativeLayout) view.findViewById(R.id.reset_accredit);
|
|
this.e = (RelativeLayout) view.findViewById(R.id.logout);
|
|
this.a.setOnClickListener(this);
|
|
this.c.setOnClickListener(this);
|
|
this.d.setOnClickListener(this);
|
|
this.e.setOnClickListener(this);
|
|
this.d.setVisibility(0);
|
|
if (LocaleUtils.g()) {
|
|
this.b.setVisibility(0);
|
|
} else {
|
|
this.b.setVisibility(8);
|
|
}
|
|
this.b.setOnClickListener(this);
|
|
}
|
|
|
|
private void o() {
|
|
if (UserDbHandler.getUser() != null) {
|
|
this.e.setVisibility(0);
|
|
} else {
|
|
this.e.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
private void q() {
|
|
new JimuSimpleDialog.Builder(getActivity()).ok(R.string.dialog_reset).cancel(R.string.dialog_see_see).content(R.string.legal_reset_agree_tip).gravity(17).cancleBtnBg(R.drawable.sel_common_negative_btn).onCancel(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.g0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
}
|
|
}).onOk(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.f0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
PrivacyFragment.d(dialogInterface, i);
|
|
}
|
|
}).build().show();
|
|
}
|
|
|
|
private void v() {
|
|
new JimuSimpleDialog.Builder(getActivity()).title(getString(R.string.setting_suggest)).ok(R.string.ok).content(R.string.ubt_contact_info).gravity(17).onOk(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.c0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
}
|
|
}).build().show();
|
|
}
|
|
|
|
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
|
if (!NetWorkUtil.b(getActivity())) {
|
|
ToastView.a(JimuApplication.k, getString(R.string.network_error), ToastView.Type.NORMAL).a();
|
|
return;
|
|
}
|
|
this.f.b();
|
|
dialogInterface.dismiss();
|
|
showLoading(getString(R.string.logoff) + "...");
|
|
}
|
|
|
|
@Override // com.ubtech.view.BaseView
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void setPresenter(SettingContract$Presenter settingContract$Presenter) {
|
|
}
|
|
|
|
protected void b() {
|
|
new JimuSimpleDialog.Builder(getActivity()).cancel(R.string.dialog_see_see).ok(R.string.close_account).content(R.string.ubt_user_logout_remind).onCancel(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.e0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
}
|
|
}).onOk(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.d0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
PrivacyFragment.this.a(dialogInterface, i);
|
|
}
|
|
}).cancleBtnBg(R.drawable.shape_cor50_bg92a7b6).build().show();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public void c(ApiStatus apiStatus) {
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public void f(String str) {
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public void h() {
|
|
hideLoading();
|
|
ToastView.a(JimuApplication.k, getString(R.string.tips_delete_account_failed), ToastView.Type.NORMAL).a();
|
|
}
|
|
|
|
protected void hideLoading() {
|
|
JAlertDialog jAlertDialog = this.g;
|
|
if (jAlertDialog == null) {
|
|
return;
|
|
}
|
|
try {
|
|
jAlertDialog.dismiss();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void l() {
|
|
Cache.getInstance().clearCacheUser();
|
|
UserDbHandler.clearUser();
|
|
ShortcutHelper.a(getActivity());
|
|
EventBus.b().b(new MessageEvent(1));
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (R.id.forward_privacy == id) {
|
|
ThePolicyActivity.a(getActivity(), 0, 0);
|
|
return;
|
|
}
|
|
if (R.id.child_privacy == id) {
|
|
ThePolicyActivity.a(getActivity(), 1, 0);
|
|
return;
|
|
}
|
|
if (R.id.suggest_ll == id) {
|
|
v();
|
|
} else if (R.id.reset_accredit == id) {
|
|
q();
|
|
} else if (R.id.logout == id) {
|
|
b();
|
|
}
|
|
}
|
|
|
|
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
View inflate = layoutInflater.inflate(R.layout.fragment_privacy, viewGroup, false);
|
|
initView(inflate);
|
|
this.f = new SettingPresenter(getActivity(), this);
|
|
if (!EventBus.b().a(this)) {
|
|
EventBus.b().c(this);
|
|
}
|
|
return inflate;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
if (EventBus.b().a(this)) {
|
|
EventBus.b().d(this);
|
|
}
|
|
}
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
public void onLoginOrLogoutMessageEvent(MessageEvent messageEvent) {
|
|
RelativeLayout relativeLayout;
|
|
int type = messageEvent.getType();
|
|
if (type != 0) {
|
|
if (type == 1 && (relativeLayout = this.e) != null) {
|
|
relativeLayout.setVisibility(8);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
RelativeLayout relativeLayout2 = this.e;
|
|
if (relativeLayout2 != null) {
|
|
relativeLayout2.setVisibility(0);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
o();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public boolean r() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public boolean s() {
|
|
return false;
|
|
}
|
|
|
|
protected void showLoading(String str) {
|
|
JAlertDialog jAlertDialog = this.g;
|
|
if (jAlertDialog == null) {
|
|
JAlertDialog.Builder builder = new JAlertDialog.Builder(getActivity());
|
|
builder.a(R.drawable.ic_loading);
|
|
builder.a(str);
|
|
builder.a(true);
|
|
this.g = builder.a();
|
|
} else {
|
|
jAlertDialog.a(str);
|
|
}
|
|
this.g.show();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public boolean t() {
|
|
return false;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.SettingContract$View
|
|
public void a(ApiStatus apiStatus) {
|
|
hideLoading();
|
|
if (apiStatus.getCode() != 0 && !CourseResult.SUCCESS.equals(apiStatus.getMessage())) {
|
|
ToastView.a(JimuApplication.k, getString(R.string.tips_delete_account_failed), ToastView.Type.NORMAL).a();
|
|
return;
|
|
}
|
|
File file = new File(ExternalOverFroyoUtils.a(getActivity(), (ModelType) null) + String.format(Constants.USER_HOME, Cache.getInstance().getUserId()));
|
|
if (file.exists()) {
|
|
FileHelper.a(file);
|
|
}
|
|
ToastView.a(JimuApplication.k, getString(R.string.tips_delete_account), ToastView.Type.NORMAL).a();
|
|
l();
|
|
this.e.setVisibility(8);
|
|
}
|
|
}
|