67 lines
2.4 KiB
Java
67 lines
2.4 KiB
Java
package com.ubt.jimu.main.widget;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
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.cache.SharePreferenceHelper;
|
|
import com.ubt.jimu.unity.bluetooth.ConnectionStatus;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class RobotSwitchView extends FrameLayout {
|
|
private ImageView a;
|
|
private ImageView b;
|
|
|
|
public RobotSwitchView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void a(Context context, AttributeSet attributeSet) {
|
|
LayoutInflater.from(context).inflate(R.layout.lay_robot_switch, this);
|
|
this.a = (ImageView) findViewById(R.id.robot);
|
|
this.b = (ImageView) findViewById(R.id.status);
|
|
a(getResources().getColor(R.color.image_foreground_filter), ConnectionStatus.DIS_CONNECT.getStatus());
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowFocusChanged(boolean z) {
|
|
super.onWindowFocusChanged(z);
|
|
if (z) {
|
|
a();
|
|
}
|
|
}
|
|
|
|
public RobotSwitchView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public RobotSwitchView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
a(context, attributeSet);
|
|
}
|
|
|
|
private void a() {
|
|
int i = new SharePreferenceHelper().getInt(SharePreferenceHelper.SP_KEY_CONNECTION_STATUS, ConnectionStatus.DIS_CONNECT.getStatus());
|
|
for (ConnectionStatus connectionStatus : ConnectionStatus.values()) {
|
|
if (connectionStatus.getStatus() == i) {
|
|
a(getResources().getColor(R.color.image_foreground_filter), i);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(int i, int i2) {
|
|
setBackgroundResource(R.drawable.connection_status_bg);
|
|
this.b.setImageResource(R.drawable.robot_can_change);
|
|
RequestBuilder<Drawable> a = Glide.e(getContext()).a(new SharePreferenceHelper(false).getString(SharePreferenceHelper.SP_KEY_ROBOT_IMAGE, ""));
|
|
a.a(new RequestOptions().b(R.drawable.default_robot_logo).a(R.drawable.default_robot_logo));
|
|
a.a(this.a);
|
|
}
|
|
}
|