Initial commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BtSpeakerConnectHelpActivity extends Activity {
|
||||
private NavigationBarView a;
|
||||
private TextView b;
|
||||
private String c;
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_speaker_connect_help);
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
this.c = intent.getStringExtra("KEY_BT_SPEAKER_NAME");
|
||||
}
|
||||
this.a = (NavigationBarView) findViewById(R.id.nbv_bar);
|
||||
this.a.setTitle(R.string.how_to_connect_bt_speaker);
|
||||
this.a.setLeftIvSrc(R.drawable.community_cancel);
|
||||
this.a.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.BtSpeakerConnectHelpActivity.1
|
||||
public void a(View view) {
|
||||
BtSpeakerConnectHelpActivity.this.finish();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.iv_left) {
|
||||
a(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b = (TextView) findViewById(R.id.tv_tap_to_connect);
|
||||
String string = getString(R.string.tap_to_connect);
|
||||
if (!TextUtils.isEmpty(this.c)) {
|
||||
string = string.replace("{0}", this.c);
|
||||
}
|
||||
this.b.setText(string);
|
||||
}
|
||||
}
|
59
sources/com/ubt/jimu/connect/view/CircleImageView.java
Normal file
59
sources/com/ubt/jimu/connect/view/CircleImageView.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircleImageView extends AppCompatImageView {
|
||||
private Paint c;
|
||||
|
||||
public CircleImageView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private Bitmap a(Bitmap bitmap, int i) {
|
||||
Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(createBitmap);
|
||||
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
this.c.setAntiAlias(true);
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
this.c.setColor(-12434878);
|
||||
float width = bitmap.getWidth() / 2;
|
||||
canvas.drawCircle(width, width, width, this.c);
|
||||
this.c.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmap, rect, rect, this.c);
|
||||
return createBitmap;
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
Drawable drawable = getDrawable();
|
||||
if (drawable == null) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
Bitmap a = a(((BitmapDrawable) drawable).getBitmap(), 14);
|
||||
Rect rect = new Rect(0, 0, a.getWidth(), a.getHeight());
|
||||
Rect rect2 = new Rect(0, 0, getWidth(), getHeight());
|
||||
this.c.reset();
|
||||
canvas.drawBitmap(a, rect, rect2, this.c);
|
||||
}
|
||||
|
||||
public CircleImageView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public CircleImageView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.c = new Paint();
|
||||
}
|
||||
}
|
104
sources/com/ubt/jimu/connect/view/CircleProgressBar.java
Normal file
104
sources/com/ubt/jimu/connect/view/CircleProgressBar.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R$styleable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircleProgressBar extends View {
|
||||
private Paint a;
|
||||
private Paint b;
|
||||
private Paint c;
|
||||
private Paint d;
|
||||
private int e;
|
||||
private int f;
|
||||
private int g;
|
||||
private float h;
|
||||
private float i;
|
||||
private float j;
|
||||
private int k;
|
||||
private int l;
|
||||
private int m;
|
||||
private int n;
|
||||
|
||||
public CircleProgressBar(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.m = 100;
|
||||
a(context, attributeSet);
|
||||
a();
|
||||
}
|
||||
|
||||
private void a(Context context, AttributeSet attributeSet) {
|
||||
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, R$styleable.TasksCompletedView, 0, 0);
|
||||
this.h = obtainStyledAttributes.getDimension(1, 80.0f);
|
||||
this.j = obtainStyledAttributes.getDimension(4, 10.0f);
|
||||
this.e = obtainStyledAttributes.getColor(0, -1);
|
||||
this.f = obtainStyledAttributes.getColor(3, -1);
|
||||
this.g = obtainStyledAttributes.getColor(2, -1);
|
||||
this.i = this.h + (this.j / 2.0f);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
this.k = getWidth() / 2;
|
||||
this.l = getHeight() / 2;
|
||||
canvas.drawCircle(this.k, this.l, this.h, this.a);
|
||||
RectF rectF = new RectF();
|
||||
int i = this.k;
|
||||
float f = this.i;
|
||||
rectF.left = i - f;
|
||||
int i2 = this.l;
|
||||
rectF.top = i2 - f;
|
||||
rectF.right = (f * 2.0f) + (i - f);
|
||||
rectF.bottom = (f * 2.0f) + (i2 - f);
|
||||
canvas.drawArc(rectF, 0.0f, 360.0f, false, this.c);
|
||||
if (this.n > 0) {
|
||||
RectF rectF2 = new RectF();
|
||||
int i3 = this.k;
|
||||
float f2 = this.i;
|
||||
rectF2.left = i3 - f2;
|
||||
int i4 = this.l;
|
||||
rectF2.top = i4 - f2;
|
||||
rectF2.right = (f2 * 2.0f) + (i3 - f2);
|
||||
rectF2.bottom = (2.0f * f2) + (i4 - f2);
|
||||
canvas.drawArc(rectF2, -90.0f, (this.n / this.m) * (-1.0f) * 360.0f, false, this.b);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgress(int i) {
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
}
|
||||
this.n = i;
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
private void a() {
|
||||
this.a = new Paint();
|
||||
this.a.setAntiAlias(true);
|
||||
this.a.setColor(this.e);
|
||||
this.a.setStyle(Paint.Style.FILL);
|
||||
this.c = new Paint();
|
||||
this.c.setAntiAlias(true);
|
||||
this.c.setColor(this.g);
|
||||
this.c.setStyle(Paint.Style.STROKE);
|
||||
this.c.setStrokeWidth(this.j);
|
||||
this.b = new Paint();
|
||||
this.b.setAntiAlias(true);
|
||||
this.b.setColor(this.f);
|
||||
this.b.setStyle(Paint.Style.STROKE);
|
||||
this.b.setStrokeWidth(this.j);
|
||||
this.d = new Paint();
|
||||
this.d.setAntiAlias(true);
|
||||
this.d.setStyle(Paint.Style.FILL);
|
||||
this.d.setColor(this.f);
|
||||
this.d.setTextSize(this.h / 2.0f);
|
||||
Paint.FontMetrics fontMetrics = this.d.getFontMetrics();
|
||||
Math.ceil(fontMetrics.descent - fontMetrics.ascent);
|
||||
}
|
||||
}
|
222
sources/com/ubt/jimu/connect/view/ComponentInfoDialog.java
Normal file
222
sources/com/ubt/jimu/connect/view/ComponentInfoDialog.java
Normal file
@@ -0,0 +1,222 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubtech.utils.DisplayUtil;
|
||||
import com.ubtech.view.dialog.BaseDialog;
|
||||
import com.ubtech.view.widget.UButton;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ComponentInfoDialog extends BaseDialog implements View.OnClickListener {
|
||||
public CharSequence b;
|
||||
public String c;
|
||||
public String d;
|
||||
public boolean e;
|
||||
public int f;
|
||||
public int g;
|
||||
public int h;
|
||||
public DialogInterface.OnClickListener i;
|
||||
public DialogInterface.OnClickListener j;
|
||||
public View.OnClickListener k;
|
||||
private TextView l;
|
||||
private TextView m;
|
||||
private ImageView n;
|
||||
public UButton o;
|
||||
public UButton p;
|
||||
public UButton q;
|
||||
public UButton r;
|
||||
|
||||
public ComponentInfoDialog(Context context) {
|
||||
super(context);
|
||||
this.e = false;
|
||||
this.f = 0;
|
||||
this.g = -1;
|
||||
this.h = -1;
|
||||
}
|
||||
|
||||
public void a(View view, Builder builder) {
|
||||
this.l = (TextView) view.findViewById(R.id.tvDialogTitle);
|
||||
this.m = (TextView) view.findViewById(R.id.tvTips);
|
||||
this.n = (ImageView) view.findViewById(R.id.imgLogo);
|
||||
this.p = (UButton) view.findViewById(R.id.btn_gray_cancel);
|
||||
this.q = (UButton) view.findViewById(R.id.btn_blue_cancel);
|
||||
this.q.setOnClickListener(this);
|
||||
this.o = (UButton) view.findViewById(R.id.btn_ok);
|
||||
this.r = (UButton) view.findViewById(R.id.btn_gray_cancel);
|
||||
this.r.setOnClickListener(this);
|
||||
this.o.setOnClickListener(this);
|
||||
if (!TextUtils.isEmpty(this.b)) {
|
||||
this.m.setText(this.b);
|
||||
this.m.setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||
}
|
||||
this.m.setOnClickListener(this);
|
||||
if (this.j == null) {
|
||||
this.o.setVisibility(8);
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.d)) {
|
||||
this.o.setText(this.d);
|
||||
}
|
||||
if (TextUtils.isEmpty(builder.b)) {
|
||||
this.l.setVisibility(8);
|
||||
} else {
|
||||
this.l.setVisibility(0);
|
||||
this.l.setText(builder.b);
|
||||
}
|
||||
if (TextUtils.isEmpty(builder.g)) {
|
||||
int i = builder.f;
|
||||
if (i != 0) {
|
||||
this.n.setImageResource(i);
|
||||
this.n.setVisibility(0);
|
||||
} else {
|
||||
this.n.setVisibility(8);
|
||||
}
|
||||
} else {
|
||||
Glide.e(getContext()).a(builder.g).a(this.n);
|
||||
this.n.setVisibility(0);
|
||||
if (this.h > 0 && this.g > 0) {
|
||||
ViewGroup.LayoutParams layoutParams = this.n.getLayoutParams();
|
||||
layoutParams.height = this.h;
|
||||
layoutParams.width = this.g;
|
||||
this.n.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
int i2 = builder.j;
|
||||
if (17 != i2) {
|
||||
this.m.setGravity(i2);
|
||||
}
|
||||
if (this.e) {
|
||||
this.q.setVisibility(8);
|
||||
this.p.setVisibility(0);
|
||||
this.r = this.p;
|
||||
} else {
|
||||
this.q.setVisibility(0);
|
||||
this.p.setVisibility(8);
|
||||
this.r = this.q;
|
||||
}
|
||||
if (this.i == null) {
|
||||
this.p.setVisibility(8);
|
||||
this.q.setVisibility(8);
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.c)) {
|
||||
this.r.setText(this.c);
|
||||
}
|
||||
this.m.setTextColor(this.f);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.btn_gray_cancel || id == R.id.btn_blue_cancel) {
|
||||
DialogInterface.OnClickListener onClickListener = this.i;
|
||||
if (onClickListener != null) {
|
||||
onClickListener.onClick(this, 0);
|
||||
return;
|
||||
} else {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (id == R.id.btn_ok) {
|
||||
DialogInterface.OnClickListener onClickListener2 = this.j;
|
||||
if (onClickListener2 != null) {
|
||||
onClickListener2.onClick(this, 0);
|
||||
return;
|
||||
} else {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (id != R.id.tvTips) {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
View.OnClickListener onClickListener3 = this.k;
|
||||
if (onClickListener3 != null) {
|
||||
onClickListener3.onClick(this.m);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected Context a;
|
||||
protected String b;
|
||||
protected CharSequence c;
|
||||
protected String d;
|
||||
protected String e;
|
||||
protected String g;
|
||||
protected DialogInterface.OnClickListener k;
|
||||
protected DialogInterface.OnClickListener l;
|
||||
protected View.OnClickListener m;
|
||||
protected int o;
|
||||
protected int f = 0;
|
||||
protected boolean h = true;
|
||||
protected boolean i = true;
|
||||
protected int j = 17;
|
||||
protected boolean n = false;
|
||||
protected int p = -1;
|
||||
protected int q = -1;
|
||||
|
||||
public Builder(Context context) {
|
||||
this.o = 0;
|
||||
this.a = context;
|
||||
this.o = context.getResources().getColor(R.color.comm_bg_596F80);
|
||||
}
|
||||
|
||||
public ComponentInfoDialog a() {
|
||||
ComponentInfoDialog componentInfoDialog = new ComponentInfoDialog(this.a);
|
||||
componentInfoDialog.requestWindowFeature(1);
|
||||
componentInfoDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
|
||||
componentInfoDialog.e = this.n;
|
||||
componentInfoDialog.b = this.c;
|
||||
componentInfoDialog.d = this.e;
|
||||
componentInfoDialog.c = this.d;
|
||||
componentInfoDialog.j = this.l;
|
||||
componentInfoDialog.i = this.k;
|
||||
componentInfoDialog.k = this.m;
|
||||
componentInfoDialog.f = this.o;
|
||||
componentInfoDialog.h = this.q;
|
||||
componentInfoDialog.g = this.p;
|
||||
View inflate = LayoutInflater.from(this.a).inflate(R.layout.layout_component_info_dialog, (ViewGroup) null, false);
|
||||
componentInfoDialog.a(inflate, this);
|
||||
componentInfoDialog.setContentView(inflate);
|
||||
componentInfoDialog.setCanceledOnTouchOutside(this.h);
|
||||
componentInfoDialog.setCancelable(this.i);
|
||||
Window window = componentInfoDialog.getWindow();
|
||||
WindowManager.LayoutParams attributes = window.getAttributes();
|
||||
window.setBackgroundDrawableResource(R.color.comm_transparent);
|
||||
int a = DisplayUtil.a(this.a, R.dimen.component_info_dialog_width);
|
||||
int a2 = DisplayUtil.a(this.a, R.dimen.component_info_dialog_height);
|
||||
attributes.width = a;
|
||||
attributes.height = a2;
|
||||
attributes.gravity = 17;
|
||||
window.setAttributes(attributes);
|
||||
return componentInfoDialog;
|
||||
}
|
||||
|
||||
public Builder a(String str) {
|
||||
this.b = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(CharSequence charSequence) {
|
||||
this.c = charSequence;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(boolean z) {
|
||||
this.h = z;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
1257
sources/com/ubt/jimu/connect/view/ComponentsListActivity.java
Normal file
1257
sources/com/ubt/jimu/connect/view/ComponentsListActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
948
sources/com/ubt/jimu/connect/view/ConnectFragment.java
Normal file
948
sources/com/ubt/jimu/connect/view/ConnectFragment.java
Normal file
@@ -0,0 +1,948 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.HelpActivity;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.base.dialog.UpdateDialog;
|
||||
import com.ubt.jimu.blockly.exception.JimuConnectionException;
|
||||
import com.ubt.jimu.connect.ConnectActivity;
|
||||
import com.ubt.jimu.connect.contract.ConnectContract$Presenter;
|
||||
import com.ubt.jimu.connect.contract.ConnectContract$View;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
import com.ubtech.utils.DisplayUtil;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtech.view.dialog.SimpleDialog;
|
||||
import com.ubtech.view.fragment.BaseFragment;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScanResult;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConnectFragment extends BaseFragment implements ConnectContract$View {
|
||||
private Dialog A;
|
||||
private boolean B;
|
||||
private WaveView a;
|
||||
private NavigationBarView b;
|
||||
private ImageView c;
|
||||
private ImageView d;
|
||||
private ProgressBar e;
|
||||
private RelativeLayout f;
|
||||
private CircleProgressBar g;
|
||||
private Button i;
|
||||
private ListView j;
|
||||
private RobotsScanedAdapter k;
|
||||
private FrameLayout l;
|
||||
private Dialog m;
|
||||
private ExecutorService n;
|
||||
private ConnectContract$Presenter p;
|
||||
private String r;
|
||||
private int s;
|
||||
private String t;
|
||||
private Handler u;
|
||||
private SharePreferenceHelper x;
|
||||
private int h = -10;
|
||||
private List<ScanResult> o = new ArrayList();
|
||||
private boolean q = false;
|
||||
private Runnable v = new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ALog.a("ConnectFragment").d("scan timeout. ListRobot.isEmpty:" + ConnectFragment.this.o.isEmpty());
|
||||
if (ConnectFragment.this.o.isEmpty()) {
|
||||
ConnectFragment.this.x();
|
||||
} else {
|
||||
ConnectFragment.this.q();
|
||||
}
|
||||
}
|
||||
};
|
||||
private volatile boolean y = false;
|
||||
private Runnable z = new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.7
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.y = true;
|
||||
if (ConnectFragment.this.isAdded() && !ConnectFragment.this.o.isEmpty()) {
|
||||
ConnectFragment connectFragment = ConnectFragment.this;
|
||||
if (connectFragment.j((List<ScanResult>) connectFragment.o)) {
|
||||
return;
|
||||
}
|
||||
ConnectFragment.this.A();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ProgressRunable implements Runnable {
|
||||
ProgressRunable() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
while (ConnectFragment.this.h < 75 && ConnectFragment.this.h >= 0) {
|
||||
ConnectFragment.this.h++;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RobotsScanedAdapter extends ArrayAdapter {
|
||||
private final int a;
|
||||
|
||||
public RobotsScanedAdapter(Context context, int i, List<ScanResult> list) {
|
||||
super(context, i, list);
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
@Override // android.widget.ArrayAdapter, android.widget.Adapter
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
ScanResult scanResult = (ScanResult) getItem(i);
|
||||
View inflate = LayoutInflater.from(getContext()).inflate(this.a, (ViewGroup) null);
|
||||
ImageView imageView = (ImageView) inflate.findViewById(R.id.iv_robot_rssi);
|
||||
TextView textView = (TextView) inflate.findViewById(R.id.tv_robot_name);
|
||||
if (scanResult != null && scanResult.a() != null) {
|
||||
String name = scanResult.a().getName();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Log.e("ConnectFragment", "Device name is empty! show empty. deviceName:" + name);
|
||||
} else {
|
||||
Log.i("ConnectFragment", "DeviceName:" + name);
|
||||
int i2 = 0;
|
||||
if (name.toLowerCase().startsWith("My_Jimu_".toLowerCase())) {
|
||||
i2 = 8;
|
||||
} else if (name.toLowerCase().startsWith("Jimu_".toLowerCase())) {
|
||||
i2 = 5;
|
||||
}
|
||||
if (i2 != 0) {
|
||||
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ConnectFragment.this.getResources().getColor(R.color.color_txt_red));
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(name);
|
||||
spannableStringBuilder.setSpan(foregroundColorSpan, i2, name.length(), 18);
|
||||
textView.setText(spannableStringBuilder);
|
||||
} else {
|
||||
textView.setText(name);
|
||||
}
|
||||
}
|
||||
imageView.setImageResource(ConnectFragment.this.e(scanResult.b()));
|
||||
}
|
||||
return inflate;
|
||||
}
|
||||
}
|
||||
|
||||
class SortByRssi implements Comparator {
|
||||
SortByRssi(ConnectFragment connectFragment) {
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Object obj, Object obj2) {
|
||||
return ((ScanResult) obj).b() < ((ScanResult) obj2).b() ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void A() {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.8
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (ConnectFragment.this.p.m() != 0) {
|
||||
Log.i("ConnectFragment", "Bluetooth not in scan state, not show robot scaned view");
|
||||
return;
|
||||
}
|
||||
ConnectFragment.this.a.c();
|
||||
ConnectFragment.this.a.setVisibility(8);
|
||||
ConnectFragment.this.c.setVisibility(8);
|
||||
if (ConnectFragment.this.j.getVisibility() != 0) {
|
||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, 0.0f, ConnectFragment.this.d.getMeasuredHeight());
|
||||
translateAnimation.setDuration(300L);
|
||||
ConnectFragment.this.d.startAnimation(translateAnimation);
|
||||
ConnectFragment.this.d.setVisibility(4);
|
||||
}
|
||||
ConnectFragment.this.e.setVisibility(0);
|
||||
ConnectFragment.this.l.setVisibility(8);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.b.setTitle(R.string.select_jimu_model);
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int e(int i) {
|
||||
return i < -90 ? R.mipmap.signal1 : i < -80 ? R.mipmap.signal2 : i < -70 ? R.mipmap.signal3 : R.mipmap.signal4;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void x() {
|
||||
ALog.a("ConnectFragment").d("gotoSearchFailPage");
|
||||
String valueOf = String.valueOf(JimuConnectionException.NOT_FOUND_DEVICE.getType());
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
String url = JimuConnectionException.getUrl(valueOf);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
HelpActivity.startForResultFromFragment(101, this, getActivity(), url, " ", R.color.theme_background, false);
|
||||
}
|
||||
|
||||
private void y() {
|
||||
ALog.a("ConnectFragment").d("onNotConnect");
|
||||
if (b()) {
|
||||
this.i.setVisibility(0);
|
||||
this.i.setText(R.string.click_to_scan);
|
||||
this.i.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.3
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (ConnectFragment.this.p == null) {
|
||||
Log.e("ConnectFragment", "Present is null");
|
||||
return;
|
||||
}
|
||||
if (ConnectFragment.this.p.d()) {
|
||||
Log.w("ConnectFragment", "Bluetooth connected, disconnect bluetooth.");
|
||||
ConnectFragment.this.p.a();
|
||||
}
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
this.a.setVisibility(8);
|
||||
this.a.c();
|
||||
this.c.setVisibility(0);
|
||||
this.d.setVisibility(8);
|
||||
this.j.setVisibility(8);
|
||||
this.e.setVisibility(8);
|
||||
this.l.setVisibility(0);
|
||||
this.f.setVisibility(8);
|
||||
this.g.setVisibility(0);
|
||||
this.h = -10;
|
||||
this.g.setProgress(this.h);
|
||||
this.b.setTitle(R.string.search_jimu_roobot);
|
||||
this.b.setRightIvVisibility(4);
|
||||
this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.4
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void G() {
|
||||
ALog.a("ConnectFragment").d("onShowNotAnyPeripherals");
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.16
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(ConnectFragment.this.getContext());
|
||||
builder.a((CharSequence) ConnectFragment.this.getString(R.string.err_msg_not_any_peripheral)).b(ConnectFragment.this.getString(R.string.retry)).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.16.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
builder.a().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void J() {
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.13
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(4);
|
||||
ConnectFragment.this.l.setVisibility(8);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.g.setVisibility(0);
|
||||
ConnectFragment.this.h = 85;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.b.setTitle(R.string.connecting_to_jimu);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.13.1
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.p.a();
|
||||
ConnectFragment.this.p.b(false);
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void O() {
|
||||
ALog.a("ConnectFragment").d("onPeripheralsTooMuchForModifyId");
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.14
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(ConnectFragment.this.getContext());
|
||||
builder.a((CharSequence) ConnectFragment.this.getString(R.string.err_msg_only_can_modify)).b(ConnectFragment.this.getString(R.string.retry)).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.14.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
builder.a().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void R() {
|
||||
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
startActivityForResult(new Intent("android.bluetooth.adapter.action.REQUEST_ENABLE"), 102);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void U() {
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.6
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
Log.e("ConnectFragment", "onScanStart");
|
||||
ConnectFragment.this.y = false;
|
||||
ConnectFragment.this.o.clear();
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
ConnectFragment.this.u.removeCallbacks(ConnectFragment.this.v);
|
||||
ConnectFragment.this.u.postDelayed(ConnectFragment.this.v, 20000L);
|
||||
ConnectFragment.this.u.removeCallbacks(ConnectFragment.this.z);
|
||||
ConnectFragment.this.u.postDelayed(ConnectFragment.this.z, 2500L);
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
ConnectFragment.this.a.setVisibility(0);
|
||||
ConnectFragment.this.a.b();
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.d.setVisibility(0);
|
||||
ConnectFragment.this.d.post(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.6.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, ConnectFragment.this.d.getMeasuredHeight(), 0.0f);
|
||||
translateAnimation.setDuration(1000L);
|
||||
translateAnimation.setInterpolator(new OvershootInterpolator());
|
||||
ConnectFragment.this.d.startAnimation(translateAnimation);
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.j.setVisibility(8);
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.g.setVisibility(0);
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.b.setTitle(R.string.search_for_jimu);
|
||||
ConnectFragment.this.b.setRightIvSrc(R.mipmap.rescan);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.6.2
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void Y() {
|
||||
ALog.a("ConnectFragment").d("onShowForbitChangeId");
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.15
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(ConnectFragment.this.getContext());
|
||||
builder.a((CharSequence) ConnectFragment.this.getString(R.string.forbit_modify_component_id)).b(ConnectFragment.this.getString(R.string.retry)).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.15.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
builder.a().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void b0() {
|
||||
Log.i("ConnectFragment", "onConnectFail");
|
||||
this.u.removeCallbacks(this.z);
|
||||
this.u.removeCallbacks(this.v);
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.12
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.a.setVisibility(8);
|
||||
ConnectFragment.this.a.c();
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(4);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(0);
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.d.setVisibility(8);
|
||||
ConnectFragment.this.g.setVisibility(8);
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.b.setTitle(R.string.connect_fail);
|
||||
ConnectFragment.this.b.setRightIvSrc(R.mipmap.connect_help);
|
||||
ConnectFragment.this.b.setRightIvVisibility(0);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.12.1
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
ConnectFragment.this.v();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.i.setText(R.string.reconnect);
|
||||
ConnectFragment.this.i.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.12.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.i.setVisibility(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void o() {
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onActivityResult(int i, int i2, Intent intent) {
|
||||
XLog.a("ConnectFragment", "onActivityResult requestCode:" + i + " resultCode:" + i2);
|
||||
if (i == 102) {
|
||||
if (i2 == -1) {
|
||||
ALog.a("ConnectFragment").d("BlueTooth is now Enabled");
|
||||
ConnectContract$Presenter connectContract$Presenter = this.p;
|
||||
if (connectContract$Presenter != null) {
|
||||
connectContract$Presenter.p();
|
||||
}
|
||||
}
|
||||
if (i2 == 0) {
|
||||
ALog.a("ConnectFragment").d("Error occured while enabling.");
|
||||
o();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i == 103) {
|
||||
ConnectContract$Presenter connectContract$Presenter2 = this.p;
|
||||
if (connectContract$Presenter2 != null) {
|
||||
connectContract$Presenter2.k();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i == 101) {
|
||||
ConnectContract$Presenter connectContract$Presenter3 = this.p;
|
||||
if (connectContract$Presenter3 != null) {
|
||||
connectContract$Presenter3.k();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i != 100) {
|
||||
return;
|
||||
}
|
||||
if (this.p == null) {
|
||||
d(i2);
|
||||
return;
|
||||
}
|
||||
if (i2 != -1) {
|
||||
XLog.a("ConnectFragment", "Match fail, scan robot");
|
||||
if (this.p.d()) {
|
||||
Log.w("ConnectFragment", "Bluetooth connected, disconnect bluetooth.");
|
||||
this.p.a();
|
||||
}
|
||||
this.p.r();
|
||||
d(0);
|
||||
return;
|
||||
}
|
||||
XLog.a("ConnectFragment", "Match success, back to busiess page.");
|
||||
BluetoothDevice l = this.p.l();
|
||||
if (l != null && l.getAddress() != null) {
|
||||
this.p.c(l.getAddress(), this.r);
|
||||
}
|
||||
this.p.a(getContext(), Cache.getInstance().getBoardInfo(), this.r, this.q);
|
||||
d(-1);
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
String str;
|
||||
ALog.a("ConnectFragment").d("onCreateView");
|
||||
this.u = new Handler();
|
||||
this.x = new SharePreferenceHelper();
|
||||
this.n = Executors.newSingleThreadExecutor();
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
str = arguments.getString("KEY_PIC_PATH");
|
||||
this.q = arguments.getBoolean("KEY_IS_DIY_MODEL", false);
|
||||
this.r = arguments.getString("KEY_MODEL_ID", "");
|
||||
this.s = arguments.getInt("KEY_MODEL_CODE", -10);
|
||||
this.t = arguments.getString("KEY_MODEL_NAME", "");
|
||||
} else {
|
||||
Log.i("ConnectFragment", "Not bundle arguments");
|
||||
str = null;
|
||||
}
|
||||
View a = a(layoutInflater, str);
|
||||
y();
|
||||
ConnectContract$Presenter connectContract$Presenter = this.p;
|
||||
if (connectContract$Presenter == null) {
|
||||
Log.e("ConnectFragment", "Present is null");
|
||||
return a;
|
||||
}
|
||||
connectContract$Presenter.a(this.q);
|
||||
this.p.a(this.s);
|
||||
if (this.p.d()) {
|
||||
Log.w("ConnectFragment", "Bluetooth connected, disconnect bluetooth.");
|
||||
this.p.a();
|
||||
}
|
||||
this.p.k();
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDestroyView() {
|
||||
this.a.c();
|
||||
ConnectContract$Presenter connectContract$Presenter = this.p;
|
||||
if (connectContract$Presenter != null) {
|
||||
connectContract$Presenter.q();
|
||||
}
|
||||
Dialog dialog = this.m;
|
||||
if (dialog != null && dialog.isShowing()) {
|
||||
this.m.dismiss();
|
||||
}
|
||||
this.m = null;
|
||||
this.n.shutdown();
|
||||
this.u.removeCallbacks(this.v);
|
||||
this.u.removeCallbacks(this.z);
|
||||
this.u.removeCallbacksAndMessages(null);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onResume() {
|
||||
ALog.a("ConnectFragment").d("onResume");
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void z() {
|
||||
if (isAdded() && Build.VERSION.SDK_INT >= 23) {
|
||||
if (this.A == null) {
|
||||
this.A = new SimpleDialog.Builder(getActivity()).a(false).a((CharSequence) getResources().getString(R.string.not_open_gps_tips)).b(getResources().getString(R.string.goto_setting)).a(getResources().getString(R.string.cancel), true).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.19
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ALog.a("ConnectFragment").d("dismiss setting dialog");
|
||||
ConnectFragment.this.B = false;
|
||||
}
|
||||
}).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.18
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.B = false;
|
||||
ConnectFragment.this.startActivityForResult(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"), 103);
|
||||
}
|
||||
}).a();
|
||||
}
|
||||
if (!this.A.isShowing()) {
|
||||
this.A.show();
|
||||
}
|
||||
ALog.a("ConnectFragment").d("show setting dialog");
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(int i) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (b() && activity != null) {
|
||||
if (activity instanceof ConnectActivity) {
|
||||
((ConnectActivity) activity).l(i);
|
||||
} else {
|
||||
Log.e("ConnectFragment", "Should not to this!");
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean j(List<ScanResult> list) {
|
||||
String string;
|
||||
if (this.y && this.p.g() && (string = this.x.getString(this.r, null)) != null) {
|
||||
for (ScanResult scanResult : list) {
|
||||
if (string.equals(scanResult.a().getAddress())) {
|
||||
ALog.a("ConnectFragment").d("Auto connect to mac " + string);
|
||||
this.p.a(scanResult.a());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void v() {
|
||||
ALog.a("ConnectFragment").d("gotoConnectFailPage");
|
||||
c(String.valueOf(JimuConnectionException.CONNECT_FAIL.getType()));
|
||||
}
|
||||
|
||||
public /* synthetic */ void h(final List list) {
|
||||
if (this.m == null) {
|
||||
UpdateDialog.Builder builder = new UpdateDialog.Builder();
|
||||
builder.backAble(false).canceledOnTouchOutside(false).title(getString(R.string.hand_damp_warming)).content(getString(R.string.hand_damp_warming_tips)).ok(getString(R.string.ok)).interactionListener(new UpdateDialog.InteractionListner() { // from class: com.ubt.jimu.connect.view.ConnectFragment.17
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onCancelClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onLeftImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onOkClick(UpdateDialog updateDialog) {
|
||||
if (ConnectFragment.this.p != null) {
|
||||
ConnectFragment.this.p.a(list);
|
||||
}
|
||||
updateDialog.dismiss();
|
||||
ConnectFragment.this.c(-1);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onRightImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
});
|
||||
this.m = new UpdateDialog(getActivity(), builder);
|
||||
this.m.setCancelable(false);
|
||||
}
|
||||
if (!b() || this.m.isShowing()) {
|
||||
return;
|
||||
}
|
||||
this.m.show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void i() {
|
||||
this.u.removeCallbacks(this.v);
|
||||
this.u.removeCallbacks(this.z);
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.11
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(4);
|
||||
ConnectFragment.this.a.c();
|
||||
ConnectFragment.this.a.setVisibility(8);
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.h = 0;
|
||||
ConnectFragment.this.g.setVisibility(0);
|
||||
ConnectFragment.this.d.setVisibility(0);
|
||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, ConnectFragment.this.d.getMeasuredHeight(), 0.0f);
|
||||
translateAnimation.setDuration(500L);
|
||||
translateAnimation.setInterpolator(new OvershootInterpolator());
|
||||
ConnectFragment.this.d.startAnimation(translateAnimation);
|
||||
ConnectFragment.this.n.execute(ConnectFragment.this.new ProgressRunable());
|
||||
ConnectFragment.this.b.setTitle(R.string.connecting_to_jimu);
|
||||
ConnectFragment.this.b.setRightIvVisibility(8);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.11.1
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.p.a();
|
||||
ConnectFragment.this.p.b(false);
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void q() {
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.10
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void c(String str) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
String url = JimuConnectionException.getUrl(str);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
HelpActivity.start(getActivity(), url, " ", R.color.theme_background, false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(ConnectContract$Presenter connectContract$Presenter) {
|
||||
this.p = connectContract$Presenter;
|
||||
}
|
||||
|
||||
private View a(LayoutInflater layoutInflater, String str) {
|
||||
View inflate = layoutInflater.inflate(R.layout.frag_connect, (ViewGroup) null);
|
||||
this.l = (FrameLayout) inflate.findViewById(R.id.fl_connect_state);
|
||||
this.l.setVisibility(0);
|
||||
this.g = (CircleProgressBar) inflate.findViewById(R.id.pb_connecting);
|
||||
this.e = (ProgressBar) inflate.findViewById(R.id.pb_progress);
|
||||
this.i = (Button) inflate.findViewById(R.id.btn_multi_function);
|
||||
this.f = (RelativeLayout) inflate.findViewById(R.id.rl_connect_fail);
|
||||
this.d = (ImageView) inflate.findViewById(R.id.iv_connect_hand);
|
||||
this.b = (NavigationBarView) inflate.findViewById(R.id.nbv_bar);
|
||||
this.b.setLeftIvSrc(R.drawable.community_cancel);
|
||||
this.c = (ImageView) inflate.findViewById(R.id.iv_robot);
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return inflate;
|
||||
}
|
||||
RequestOptions N = RequestOptions.N();
|
||||
N.a(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
RequestBuilder<Drawable> a = Glide.a(this).a(str);
|
||||
a.a(N);
|
||||
a.a(this.c);
|
||||
} else {
|
||||
RequestBuilder<Drawable> d = Glide.a(this).d(activity.getResources().getDrawable(R.drawable.controller_small, null));
|
||||
d.a(RequestOptions.P());
|
||||
d.a(this.c);
|
||||
}
|
||||
this.a = (WaveView) inflate.findViewById(R.id.wave);
|
||||
int a2 = DisplayUtil.a((Context) activity, R.dimen.searching_wave_width);
|
||||
int a3 = DisplayUtil.a((Context) activity, R.dimen.searching_wave_image_radius);
|
||||
int a4 = DisplayUtil.a((Context) activity, R.dimen.searching_wave_max_radius);
|
||||
this.a.setWidth(a2);
|
||||
this.a.setImageRadius(a3);
|
||||
this.a.setMaxRadius(a4);
|
||||
this.a.setFill(false);
|
||||
this.a.a();
|
||||
this.j = (ListView) inflate.findViewById(R.id.lv_robots_scaned);
|
||||
this.k = new RobotsScanedAdapter(getContext(), R.layout.item_robot_info_scaned, this.o);
|
||||
this.j.setAdapter((ListAdapter) this.k);
|
||||
this.j.setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.2
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
|
||||
ScanResult scanResult = (ScanResult) ConnectFragment.this.o.get(i);
|
||||
if (scanResult == null || scanResult.a() == null) {
|
||||
return;
|
||||
}
|
||||
if (scanResult.a().getAddress() == null) {
|
||||
Log.e("ConnectFragment", "click an device that address is null!");
|
||||
return;
|
||||
}
|
||||
ConnectFragment.this.o.clear();
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
ConnectFragment.this.p.a(scanResult.a());
|
||||
}
|
||||
});
|
||||
return inflate;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void c(int i) {
|
||||
ALog.a("ConnectFragment").d("onBackToBusinessPage");
|
||||
d(i);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(final ScanResult scanResult) {
|
||||
if (!b() || scanResult.a() == null || TextUtils.isEmpty(scanResult.a().getName()) || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.9
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ALog.a("ConnectFragment").d("scaned robot:" + scanResult.a().getAddress());
|
||||
Iterator it = ConnectFragment.this.o.iterator();
|
||||
while (it.hasNext()) {
|
||||
ScanResult scanResult2 = (ScanResult) it.next();
|
||||
if (TextUtils.isEmpty(scanResult2.a().getName())) {
|
||||
it.remove();
|
||||
} else if (scanResult.a().getName().equals(scanResult2.a().getName())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConnectFragment.this.o.add(scanResult);
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
ConnectFragment connectFragment = ConnectFragment.this;
|
||||
if (connectFragment.j((List<ScanResult>) connectFragment.o)) {
|
||||
return;
|
||||
}
|
||||
ALog.a("ConnectFragment").d("sort scaned robot by RSSI!");
|
||||
Collections.sort(ConnectFragment.this.o, new SortByRssi(ConnectFragment.this));
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
if (ConnectFragment.this.y) {
|
||||
ConnectFragment.this.A();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(String str, boolean z) {
|
||||
ALog.a("ConnectFragment").d("onMatchErrorOrNeedUpdate");
|
||||
this.h = 100;
|
||||
this.g.setProgress(this.h);
|
||||
if (getContext() == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(getContext(), (Class<?>) ComponentsListActivity.class);
|
||||
intent.putExtra("KEY_IS_DIY_MODEL", z);
|
||||
intent.putExtra("KEY_MODEL_ID", str);
|
||||
intent.putExtra("KEY_MODEL_NAME", this.t);
|
||||
if (this.p.l() != null) {
|
||||
intent.putExtra("KEY_DEVICE_NAME", this.p.l().getName());
|
||||
}
|
||||
startActivityForResult(intent, 100);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(final List<ServoAngleReadInfo> list) {
|
||||
if (list == null || list.size() == 0 || !b() || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.l
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
ConnectFragment.this.h(list);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
264
sources/com/ubt/jimu/connect/view/DisconnectFragment.java
Normal file
264
sources/com/ubt/jimu/connect/view/DisconnectFragment.java
Normal file
@@ -0,0 +1,264 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.dialog.UpdateDialog;
|
||||
import com.ubt.jimu.connect.ConnectActivity;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
import com.ubtech.view.dialog.SimpleDialog;
|
||||
import com.ubtech.view.fragment.BaseFragment;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionStateListener;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DisconnectFragment extends BaseFragment {
|
||||
private NavigationBarView a;
|
||||
private ImageView b;
|
||||
private CircleProgressBar c;
|
||||
private RelativeLayout d;
|
||||
private Button e;
|
||||
private FrameLayout f;
|
||||
private String h;
|
||||
private JimuManager j;
|
||||
private Dialog n;
|
||||
private boolean g = false;
|
||||
private String i = null;
|
||||
private boolean k = false;
|
||||
private volatile boolean l = false;
|
||||
private ConnectionStateListener m = new ConnectionStateListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.1
|
||||
@Override // com.ubtrobot.jimu.bluetooth.ConnectionStateListener
|
||||
public void onConnectionStateChange(String str, ConnectionState connectionState) {
|
||||
Log.e("DisconnectFragment", "onConnectionStateChange newState:" + connectionState);
|
||||
if (ConnectionState.STATE_DISCONNECTED != connectionState || DisconnectFragment.this.l) {
|
||||
return;
|
||||
}
|
||||
DisconnectFragment.this.x();
|
||||
}
|
||||
};
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void o() {
|
||||
this.l = true;
|
||||
JimuApplication.l().f().c();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean q() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
private void v() {
|
||||
ALog.a("DisconnectFragment").d("onConnected");
|
||||
if (b()) {
|
||||
this.d.setVisibility(8);
|
||||
this.c.setVisibility(0);
|
||||
this.c.setProgress(100);
|
||||
this.e.setText(R.string.bluetooth_disconnect);
|
||||
this.e.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.3
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
new SimpleDialog.Builder(DisconnectFragment.this.getContext()).d(R.string.ok).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.3.2
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
DisconnectFragment.this.o();
|
||||
DisconnectFragment.this.d(-1);
|
||||
}
|
||||
}).a(R.string.cancel, true).a(new DialogInterface.OnClickListener(this) { // from class: com.ubt.jimu.connect.view.DisconnectFragment.3.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a((CharSequence) DisconnectFragment.this.getString(R.string.ensure_diconnect_bluetooth_connection)).a().show();
|
||||
}
|
||||
});
|
||||
this.e.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void x() {
|
||||
ALog.a("DisconnectFragment").d("Show bluetooth disconnect dialog");
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (DisconnectFragment.this.n == null) {
|
||||
String string = DisconnectFragment.this.getString(R.string.bluetooth_disconnected);
|
||||
UpdateDialog.Builder builder = new UpdateDialog.Builder();
|
||||
builder.content(string).ok(DisconnectFragment.this.getString(R.string.ok)).interactionListener(new UpdateDialog.InteractionListner() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.4.1
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onCancelClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onLeftImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onOkClick(UpdateDialog updateDialog) {
|
||||
updateDialog.dismiss();
|
||||
DisconnectFragment.this.d(-1);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onRightImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
});
|
||||
DisconnectFragment.this.n = new UpdateDialog(activity, builder);
|
||||
}
|
||||
if (activity.isFinishing() || DisconnectFragment.this.n.isShowing() || !DisconnectFragment.this.q()) {
|
||||
return;
|
||||
}
|
||||
ALog.a("DisconnectFragment").d("real show bluetooth disconnect dialog");
|
||||
DisconnectFragment.this.n.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onActivityResult(int i, int i2, Intent intent) {
|
||||
if (i == 100 && i2 == 0) {
|
||||
d(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
String str;
|
||||
ALog.a("DisconnectFragment").d("onCreateView");
|
||||
this.l = false;
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
str = arguments.getString("KEY_PIC_PATH");
|
||||
this.g = arguments.getBoolean("KEY_IS_DIY_MODEL", false);
|
||||
this.h = arguments.getString("KEY_MODEL_ID", "");
|
||||
arguments.getInt("KEY_MODEL_CODE", -10);
|
||||
this.i = arguments.getString("KEY_MODEL_NAME", "");
|
||||
} else {
|
||||
Log.e("DisconnectFragment", "Not bundle arguments");
|
||||
str = null;
|
||||
}
|
||||
View a = a(layoutInflater, str);
|
||||
v();
|
||||
this.j = JimuApplication.l().f();
|
||||
this.j.a(this.m);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDestroyView() {
|
||||
this.j.b(this.m);
|
||||
this.n = null;
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onPause() {
|
||||
this.k = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
this.k = true;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(int i) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof ConnectActivity) {
|
||||
((ConnectActivity) activity).l(i);
|
||||
} else {
|
||||
Log.e("DisconnectFragment", "Should not to this!");
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return isAdded();
|
||||
}
|
||||
|
||||
private View a(LayoutInflater layoutInflater, String str) {
|
||||
View inflate = layoutInflater.inflate(R.layout.frag_disconnect, (ViewGroup) null);
|
||||
this.f = (FrameLayout) inflate.findViewById(R.id.fl_connect_state);
|
||||
this.f.setVisibility(0);
|
||||
this.e = (Button) inflate.findViewById(R.id.btn_multi_function);
|
||||
this.c = (CircleProgressBar) inflate.findViewById(R.id.pb_connecting);
|
||||
this.d = (RelativeLayout) inflate.findViewById(R.id.rl_connect_fail);
|
||||
this.a = (NavigationBarView) inflate.findViewById(R.id.nbv_bar);
|
||||
this.a.setLeftIvSrc(R.mipmap.icon_round_back);
|
||||
this.a.setRightIvSrc(R.drawable.bg_look_btn);
|
||||
this.a.setTitle(this.i);
|
||||
this.a.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.2
|
||||
public void a(View view) {
|
||||
DisconnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
if (DisconnectFragment.this.getContext() == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(DisconnectFragment.this.getContext(), (Class<?>) ComponentsListActivity.class);
|
||||
intent.putExtra("KEY_MODEL_CODE", 5001);
|
||||
intent.putExtra("KEY_IS_DIY_MODEL", DisconnectFragment.this.g);
|
||||
intent.putExtra("KEY_MODEL_ID", DisconnectFragment.this.h);
|
||||
intent.putExtra("KEY_MODEL_NAME", DisconnectFragment.this.i);
|
||||
BluetoothDevice lastConnectedDevice = Cache.getInstance().getLastConnectedDevice();
|
||||
if (lastConnectedDevice != null) {
|
||||
intent.putExtra("KEY_DEVICE_NAME", lastConnectedDevice.getName());
|
||||
}
|
||||
DisconnectFragment.this.startActivityForResult(intent, 100);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b = (ImageView) inflate.findViewById(R.id.iv_robot);
|
||||
RequestOptions N = RequestOptions.N();
|
||||
N.a(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
RequestBuilder<Drawable> a = Glide.a(this).a(str);
|
||||
a.a(N);
|
||||
a.a(this.b);
|
||||
} else {
|
||||
RequestBuilder<Drawable> d = Glide.a(this).d(getActivity().getResources().getDrawable(R.drawable.controller, null));
|
||||
d.a(RequestOptions.P());
|
||||
d.a(this.b);
|
||||
}
|
||||
return inflate;
|
||||
}
|
||||
}
|
54
sources/com/ubt/jimu/connect/view/FirmwareUpdateDialog.java
Normal file
54
sources/com/ubt/jimu/connect/view/FirmwareUpdateDialog.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FirmwareUpdateDialog extends Dialog {
|
||||
private TextView a;
|
||||
private TextView b;
|
||||
|
||||
public FirmwareUpdateDialog(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void a(final String str, final int i) {
|
||||
TextView textView = this.a;
|
||||
if (textView == null) {
|
||||
return;
|
||||
}
|
||||
textView.post(new Runnable() { // from class: com.ubt.jimu.connect.view.m
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
FirmwareUpdateDialog.this.a(i, str);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
getWindow().requestFeature(1);
|
||||
setContentView(R.layout.dialog_firmware_update);
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(0));
|
||||
getWindow().setLayout(-1, -1);
|
||||
setCanceledOnTouchOutside(false);
|
||||
this.a = (TextView) findViewById(R.id.tvUpdateProgress);
|
||||
this.b = (TextView) findViewById(R.id.tvCurrentFirmware);
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(int i, String str) {
|
||||
this.a.setText(i + "%");
|
||||
this.b.setText(str);
|
||||
}
|
||||
}
|
96
sources/com/ubt/jimu/connect/view/RecycleViewDivider.java
Normal file
96
sources/com/ubt/jimu/connect/view/RecycleViewDivider.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RecycleViewDivider extends RecyclerView.ItemDecoration {
|
||||
private static final int[] e = {R.attr.listDivider};
|
||||
private Paint a;
|
||||
private Drawable b;
|
||||
private int c;
|
||||
private int d;
|
||||
|
||||
public RecycleViewDivider(Context context, int i) {
|
||||
this.c = 2;
|
||||
if (i != 1 && i != 0) {
|
||||
throw new IllegalArgumentException("请输入正确的参数!");
|
||||
}
|
||||
this.d = i;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(e);
|
||||
this.b = obtainStyledAttributes.getDrawable(0);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
private void a(Canvas canvas, RecyclerView recyclerView) {
|
||||
int paddingLeft = recyclerView.getPaddingLeft();
|
||||
int measuredWidth = recyclerView.getMeasuredWidth() - recyclerView.getPaddingRight();
|
||||
int childCount = recyclerView.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = recyclerView.getChildAt(i);
|
||||
int bottom = childAt.getBottom() + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) childAt.getLayoutParams())).bottomMargin;
|
||||
int i2 = this.c + bottom;
|
||||
Drawable drawable = this.b;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(paddingLeft, bottom, measuredWidth, i2);
|
||||
this.b.draw(canvas);
|
||||
}
|
||||
Paint paint = this.a;
|
||||
if (paint != null) {
|
||||
canvas.drawRect(paddingLeft, bottom, measuredWidth, i2, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void b(Canvas canvas, RecyclerView recyclerView) {
|
||||
int paddingTop = recyclerView.getPaddingTop();
|
||||
int measuredHeight = recyclerView.getMeasuredHeight() - recyclerView.getPaddingBottom();
|
||||
int childCount = recyclerView.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = recyclerView.getChildAt(i);
|
||||
int right = childAt.getRight() + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) childAt.getLayoutParams())).rightMargin;
|
||||
int i2 = this.c + right;
|
||||
Drawable drawable = this.b;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(right, paddingTop, i2, measuredHeight);
|
||||
this.b.draw(canvas);
|
||||
}
|
||||
Paint paint = this.a;
|
||||
if (paint != null) {
|
||||
canvas.drawRect(right, paddingTop, i2, measuredHeight, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
public void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.State state) {
|
||||
super.getItemOffsets(rect, view, recyclerView, state);
|
||||
rect.set(0, 0, 0, this.c);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
|
||||
super.onDraw(canvas, recyclerView, state);
|
||||
if (this.d == 1) {
|
||||
b(canvas, recyclerView);
|
||||
} else {
|
||||
a(canvas, recyclerView);
|
||||
}
|
||||
}
|
||||
|
||||
public RecycleViewDivider(Context context, int i, int i2, int i3) {
|
||||
this(context, i);
|
||||
this.c = i2;
|
||||
this.a = new Paint(1);
|
||||
this.a.setColor(i3);
|
||||
this.a.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
}
|
143
sources/com/ubt/jimu/connect/view/WaveView.java
Normal file
143
sources/com/ubt/jimu/connect/view/WaveView.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.R$styleable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class WaveView extends View {
|
||||
private int a;
|
||||
private int b;
|
||||
private int c;
|
||||
private Integer d;
|
||||
private boolean e;
|
||||
private List<Integer> f;
|
||||
private List<Integer> g;
|
||||
private Paint h;
|
||||
private boolean i;
|
||||
|
||||
public WaveView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void d() {
|
||||
this.h = new Paint();
|
||||
this.h.setAntiAlias(true);
|
||||
this.f.add(255);
|
||||
this.g.add(0);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.f.add(255);
|
||||
this.g.add(0);
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.e = true;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.e = false;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void invalidate() {
|
||||
if (hasWindowFocus()) {
|
||||
super.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onDraw(Canvas canvas) {
|
||||
this.h.setColor(this.a);
|
||||
for (int i = 0; i < this.f.size(); i++) {
|
||||
Integer num = this.f.get(i);
|
||||
this.h.setAlpha(num.intValue());
|
||||
Integer num2 = this.g.get(i);
|
||||
if (this.i) {
|
||||
this.h.setStyle(Paint.Style.FILL);
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
||||
this.h.setStyle(Paint.Style.STROKE);
|
||||
this.h.setStrokeWidth(3.0f);
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
||||
} else {
|
||||
this.h.setStyle(Paint.Style.STROKE);
|
||||
this.h.setStrokeWidth(3.0f);
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
||||
}
|
||||
if (this.d.intValue() == 0) {
|
||||
this.d = 600;
|
||||
}
|
||||
if (num.intValue() > 0 && this.b + num2.intValue() < this.d.intValue()) {
|
||||
this.f.set(i, Integer.valueOf((int) ((1.0f - (((this.b + num2.intValue()) * 1.0f) / this.d.intValue())) * 255.0f)));
|
||||
this.g.set(i, Integer.valueOf(num2.intValue() + 2));
|
||||
} else if (num.intValue() < 0 && this.b + num2.intValue() > this.d.intValue()) {
|
||||
this.g.remove(i);
|
||||
this.f.remove(i);
|
||||
}
|
||||
}
|
||||
if (this.g.get(r9.size() - 1).intValue() >= this.c) {
|
||||
a();
|
||||
}
|
||||
if (this.e) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onWindowFocusChanged(boolean z) {
|
||||
super.onWindowFocusChanged(z);
|
||||
this.d = Integer.valueOf((getWidth() > getHeight() ? getHeight() : getWidth()) / 2);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setColor(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public void setFill(boolean z) {
|
||||
this.i = z;
|
||||
}
|
||||
|
||||
public void setImageRadius(int i) {
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
public void setMaxRadius(int i) {
|
||||
this.d = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
public void setWidth(int i) {
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public WaveView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public WaveView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.a = getResources().getColor(R.color.bg_robot_search_wave);
|
||||
this.b = 60;
|
||||
this.c = 3;
|
||||
this.d = 600;
|
||||
this.e = false;
|
||||
this.f = new ArrayList();
|
||||
this.g = new ArrayList();
|
||||
this.i = true;
|
||||
d();
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.WaveView, i, 0);
|
||||
this.a = obtainStyledAttributes.getColor(0, this.a);
|
||||
this.c = obtainStyledAttributes.getInt(2, this.c);
|
||||
this.b = obtainStyledAttributes.getInt(1, this.b);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user