jimu-decompiled/sources/com/ubt/jimu/user/setting/view/HardwareFragment.java
2025-05-13 19:24:51 +02:00

145 lines
5.8 KiB
Java

package com.ubt.jimu.user.setting.view;
import android.app.Dialog;
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 com.ubt.jimu.R;
import com.ubt.jimu.base.cache.SharePreferenceHelper;
import com.ubt.jimu.base.entities.Robot;
import com.ubt.jimu.base.mvp.BaseMvpFragment;
import com.ubt.jimu.base.mvp.SingleClickListener;
import com.ubt.jimu.unity.bluetooth.UnityActivity;
import com.ubt.jimu.user.setting.presenter.HardWarePresenter;
import com.ubtech.view.dialog.SimpleDialog;
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
/* loaded from: classes2.dex */
public class HardwareFragment extends BaseMvpFragment<HardWarePresenter> implements HardWarePresenter.HardWareView, SingleClickListener {
private boolean a = true;
private RelativeLayout b;
private CheckBox c;
private RelativeLayout d;
private ImageView e;
private RelativeLayout f;
private SharePreferenceHelper g;
private Dialog h;
private void initView(View view) {
this.b = (RelativeLayout) view.findViewById(R.id.xr_protect);
this.c = (CheckBox) view.findViewById(R.id.cb_protect);
this.d = (RelativeLayout) view.findViewById(R.id.xr_auto_connect);
this.e = (ImageView) view.findViewById(R.id.cb_auto);
this.f = (RelativeLayout) view.findViewById(R.id.xl_modify);
}
private void o() {
this.c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // from class: com.ubt.jimu.user.setting.view.b0
@Override // android.widget.CompoundButton.OnCheckedChangeListener
public final void onCheckedChanged(CompoundButton compoundButton, boolean z) {
HardwareFragment.this.a(compoundButton, z);
}
});
this.b.setOnClickListener(this);
this.d.setOnClickListener(this);
this.f.setOnClickListener(this);
}
private void q() {
this.a = this.g.getBoolean(SharePreferenceHelper.SP_KEY_AUTO_CONNECT, true).booleanValue();
this.e.setBackgroundResource(this.a ? R.drawable.checkbox_on_xxx : R.drawable.checkbox_off_xxx);
this.c.setChecked(this.g.getBoolean(SharePreferenceHelper.SP_KEY_ELECTRICITY_PROTECT, true).booleanValue());
}
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
public int getLayoutID() {
return R.layout.fragment_hardware;
}
@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.BaseMvpFragment, androidx.fragment.app.Fragment
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
this.g = new SharePreferenceHelper();
}
@Override // com.ubt.jimu.base.mvp.SingleClickListener
public void onSingleClick(View view) {
int id = view.getId();
if (id == R.id.xr_protect) {
CheckBox checkBox = this.c;
checkBox.setChecked(true ^ checkBox.isChecked());
return;
}
if (id != R.id.xr_auto_connect) {
if (id == R.id.xl_modify) {
UnityActivity.startUnityActivity(getActivity(), (Robot) null, 1, -1, UnityActivity.BLOCKLY_TYPE_NONE);
JimuAnalytics.b().a("click_P15_1");
return;
}
return;
}
if (this.a) {
b();
return;
}
this.a = true;
SharePreferenceHelper sharePreferenceHelper = this.g;
if (sharePreferenceHelper != null) {
sharePreferenceHelper.put(SharePreferenceHelper.SP_KEY_AUTO_CONNECT, Boolean.valueOf(this.a));
}
this.e.setBackgroundResource(R.drawable.checkbox_off_xxx);
}
@Override // androidx.fragment.app.Fragment
public void onStart() {
super.onStart();
q();
}
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
super.onViewCreated(view, bundle);
initView(view);
o();
}
public void b() {
this.h = new SimpleDialog.Builder(getActivity()).a(R.string.search_cancel_return).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.HardwareFragment.2
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
HardwareFragment.this.a = true;
dialogInterface.dismiss();
}
}).d(R.string.confirm).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.HardwareFragment.1
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
HardwareFragment.this.a = false;
if (HardwareFragment.this.g != null) {
HardwareFragment.this.g.put(SharePreferenceHelper.SP_KEY_AUTO_CONNECT, Boolean.valueOf(HardwareFragment.this.a));
}
HardwareFragment.this.e.setBackgroundResource(R.drawable.checkbox_off_xxx);
dialogInterface.dismiss();
}
}).b(R.string.bluetooth_auto_connect_tips).a();
this.h.show();
}
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
public HardWarePresenter createPresenter() {
return new HardWarePresenter();
}
public /* synthetic */ void a(CompoundButton compoundButton, boolean z) {
this.g.put(SharePreferenceHelper.SP_KEY_ELECTRICITY_PROTECT, Boolean.valueOf(z));
}
}