103 lines
2.6 KiB
Java
103 lines
2.6 KiB
Java
package com.ubtech.view.widget;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import com.ubtech.R$id;
|
|
import com.ubtech.R$layout;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class ErrorView extends LinearLayout {
|
|
private ImageView a;
|
|
private TextView b;
|
|
private ResAgent c;
|
|
private Observable d;
|
|
private View[] e;
|
|
|
|
public interface Observable {
|
|
boolean a();
|
|
}
|
|
|
|
public interface ResAgent {
|
|
ResData[] a();
|
|
}
|
|
|
|
public static class ResData {
|
|
public int a;
|
|
public int b;
|
|
public int c;
|
|
|
|
public ResData(int i, int i2, int i3) {
|
|
this.a = i;
|
|
this.b = i2;
|
|
this.c = i3;
|
|
}
|
|
}
|
|
|
|
public ErrorView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void a(Context context, AttributeSet attributeSet) {
|
|
setOrientation(1);
|
|
setGravity(17);
|
|
LayoutInflater.from(context).inflate(R$layout.comm_error, this);
|
|
this.a = (ImageView) findViewById(R$id.iv_icon);
|
|
this.b = (TextView) findViewById(R$id.tv_msg);
|
|
}
|
|
|
|
public void setType(int i) {
|
|
ResData[] a = this.c.a();
|
|
if (a == null) {
|
|
return;
|
|
}
|
|
for (ResData resData : a) {
|
|
if (resData != null && resData.a == i) {
|
|
this.a.setBackgroundResource(resData.b);
|
|
this.b.setText(resData.c);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public ErrorView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public ErrorView(Context context, AttributeSet attributeSet, int i) {
|
|
this(context, attributeSet, i, 0);
|
|
}
|
|
|
|
public ErrorView(Context context, AttributeSet attributeSet, int i, int i2) {
|
|
super(context, attributeSet, i, i2);
|
|
a(context, attributeSet);
|
|
}
|
|
|
|
public void a(ResAgent resAgent) {
|
|
this.c = resAgent;
|
|
}
|
|
|
|
public void a(Observable observable, View... viewArr) {
|
|
this.d = observable;
|
|
this.e = viewArr;
|
|
}
|
|
|
|
public void a() {
|
|
Observable observable = this.d;
|
|
boolean a = observable != null ? observable.a() : false;
|
|
setVisibility(a ? 0 : 8);
|
|
View[] viewArr = this.e;
|
|
if (viewArr != null) {
|
|
for (View view : viewArr) {
|
|
if (view != null) {
|
|
view.setVisibility(!a ? 0 : 8);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|