226 lines
8.9 KiB
Java
226 lines
8.9 KiB
Java
package com.ubt.jimu.user.setting.view;
|
|
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.CheckBox;
|
|
import android.widget.CompoundButton;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.analytics.BuglyUtil;
|
|
import com.ubt.jimu.analytics.JimuAnalyticsUtil;
|
|
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
|
import com.ubt.jimu.base.dialog.JimuSimpleDialog;
|
|
import com.ubt.jimu.base.entities.Constant;
|
|
import com.ubt.jimu.base.mvp.BaseMvpFragment;
|
|
import com.ubt.jimu.base.mvp.SingleClickListener;
|
|
import com.ubt.jimu.user.setting.presenter.CommonUsePresenter;
|
|
import com.ubt.jimu.utils.GlideCacheUtils;
|
|
import com.ubt.jimu.utils.SPUtils;
|
|
import com.ubtech.utils.PermissionHelper;
|
|
import com.ubtrobot.log.ALog;
|
|
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
|
import io.reactivex.Observable;
|
|
import io.reactivex.ObservableEmitter;
|
|
import io.reactivex.ObservableOnSubscribe;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class CommonUseFragment extends BaseMvpFragment<CommonUsePresenter> implements CommonUsePresenter.CommonUseView, SingleClickListener {
|
|
private RelativeLayout a;
|
|
private TextView b;
|
|
private RelativeLayout c;
|
|
private CheckBox d;
|
|
private RelativeLayout e;
|
|
private CheckBox f;
|
|
private SharePreferenceHelper g;
|
|
private RelativeLayout h;
|
|
private ImageView i;
|
|
|
|
static /* synthetic */ void a(ObservableEmitter observableEmitter) throws Exception {
|
|
GlideCacheUtils.a().a(JimuApplication.l());
|
|
observableEmitter.onNext(true);
|
|
}
|
|
|
|
private void initView(View view) {
|
|
this.a = (RelativeLayout) view.findViewById(R.id.xr_clear_cache);
|
|
this.b = (TextView) view.findViewById(R.id.tv_cache_size);
|
|
this.c = (RelativeLayout) view.findViewById(R.id.xr_wifi);
|
|
this.d = (CheckBox) view.findViewById(R.id.cb_wifi);
|
|
this.e = (RelativeLayout) view.findViewById(R.id.xr_info);
|
|
this.f = (CheckBox) view.findViewById(R.id.cb_info);
|
|
this.h = (RelativeLayout) view.findViewById(R.id.user_experience_info);
|
|
this.i = (ImageView) view.findViewById(R.id.cb_user_experience);
|
|
}
|
|
|
|
private void o() {
|
|
if (SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE)) {
|
|
this.i.setBackgroundResource(R.drawable.checkbox_on_xxx);
|
|
} else {
|
|
this.i.setBackgroundResource(R.drawable.checkbox_off_xxx);
|
|
}
|
|
}
|
|
|
|
private void q() {
|
|
this.a.setOnClickListener(this);
|
|
this.c.setOnClickListener(this);
|
|
this.e.setOnClickListener(this);
|
|
this.h.setOnClickListener(this);
|
|
this.i.setOnClickListener(this);
|
|
this.d.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // from class: com.ubt.jimu.user.setting.view.CommonUseFragment.1
|
|
@Override // android.widget.CompoundButton.OnCheckedChangeListener
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
|
|
((CommonUsePresenter) CommonUseFragment.this.mPresenter).a(z);
|
|
}
|
|
});
|
|
this.f.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // from class: com.ubt.jimu.user.setting.view.CommonUseFragment.2
|
|
@Override // android.widget.CompoundButton.OnCheckedChangeListener
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
|
|
((CommonUsePresenter) CommonUseFragment.this.mPresenter).b(z);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void v() {
|
|
this.b.setText(GlideCacheUtils.a().c(getActivity()));
|
|
this.g = new SharePreferenceHelper();
|
|
this.d.setChecked(this.g.getBoolean(SharePreferenceHelper.SP_KEY_WIFI_VIEW, true).booleanValue());
|
|
this.f.setChecked(this.g.getBoolean(SharePreferenceHelper.SP_KEY_INFO_TO, true).booleanValue());
|
|
o();
|
|
}
|
|
|
|
private void x() {
|
|
new JimuSimpleDialog.Builder(getActivity()).title(R.string.ubt_user_experience_title).cancel(R.string.dialog_add_later).ok(R.string.ok).content(R.string.ubt_user_experience_content).gravity(17).cancleBtnBg(R.drawable.sel_common_negative_btn).onCancel(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.f
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
CommonUseFragment.this.a(dialogInterface, i);
|
|
}
|
|
}).onOk(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.g
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
CommonUseFragment.this.b(dialogInterface, i);
|
|
}
|
|
}).build().show();
|
|
}
|
|
|
|
public void b() {
|
|
if (PermissionHelper.a(getActivity(), "android.permission.WRITE_EXTERNAL_STORAGE")) {
|
|
Observable.create(new ObservableOnSubscribe() { // from class: com.ubt.jimu.user.setting.view.h
|
|
@Override // io.reactivex.ObservableOnSubscribe
|
|
public final void subscribe(ObservableEmitter observableEmitter) {
|
|
CommonUseFragment.a(observableEmitter);
|
|
}
|
|
}).observeOn(AndroidSchedulers.a()).subscribeOn(Schedulers.b()).subscribe(new Observer<Boolean>() { // from class: com.ubt.jimu.user.setting.view.CommonUseFragment.3
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(Boolean bool) {
|
|
GlideCacheUtils.a().b(JimuApplication.l());
|
|
GlideCacheUtils.a().a(JimuApplication.l().getExternalCacheDir() + "image_manager_disk_cache", true);
|
|
CommonUseFragment.this.p();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
}
|
|
});
|
|
} else {
|
|
((CommonUsePresenter) this.mPresenter).a();
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public int getLayoutID() {
|
|
return R.layout.fragment_commonuse;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener, android.view.View.OnClickListener
|
|
public /* synthetic */ void onClick(View view) {
|
|
com.ubt.jimu.base.mvp.b.$default$onClick(this, view);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener
|
|
public void onSingleClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R.id.xr_clear_cache) {
|
|
b();
|
|
return;
|
|
}
|
|
if (id == R.id.xr_wifi) {
|
|
this.d.setChecked(!r2.isChecked());
|
|
} else if (id == R.id.xr_info) {
|
|
this.f.setChecked(!r2.isChecked());
|
|
} else if (id == R.id.user_experience_info || id == R.id.cb_user_experience) {
|
|
x();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onStart() {
|
|
super.onStart();
|
|
v();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
super.onViewCreated(view, bundle);
|
|
initView(view);
|
|
q();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.setting.presenter.CommonUsePresenter.CommonUseView
|
|
public void p() {
|
|
this.b.setText(GlideCacheUtils.a().c(getActivity()));
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public CommonUsePresenter createPresenter() {
|
|
return new CommonUsePresenter();
|
|
}
|
|
|
|
private void a(boolean z) {
|
|
if (z) {
|
|
Context context = getContext();
|
|
if (context == null) {
|
|
return;
|
|
}
|
|
JimuAnalyticsUtil.a(context);
|
|
JimuAnalytics.b().a(z);
|
|
} else {
|
|
ALog.b("关闭体验优化", new Object[0]);
|
|
if (JimuAnalytics.b().a()) {
|
|
JimuAnalytics.b().a(z);
|
|
}
|
|
}
|
|
BuglyUtil.a(z);
|
|
}
|
|
|
|
public /* synthetic */ void b(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE, true);
|
|
o();
|
|
a(true);
|
|
}
|
|
|
|
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
SPUtils.a(Constant.NoviceGuide.JOIN_USER_EXPERIENCE, false);
|
|
o();
|
|
a(false);
|
|
}
|
|
}
|