208 lines
6.0 KiB
Java
208 lines
6.0 KiB
Java
package com.ubt.jimu.widgets;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.R$styleable;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class NavigationBarView extends RelativeLayout {
|
|
private ImageView a;
|
|
private TextView b;
|
|
private ImageView c;
|
|
private TextView d;
|
|
private OnActionClickListener e;
|
|
private int f;
|
|
private View.OnClickListener g;
|
|
|
|
public interface OnActionClickListener {
|
|
|
|
public static class Stub implements OnActionClickListener {
|
|
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R.id.iv_left) {
|
|
onLeftClick(view);
|
|
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
|
onRightClick(view);
|
|
}
|
|
}
|
|
|
|
public void onLeftClick(View view) {
|
|
if (view.getContext() instanceof Activity) {
|
|
((Activity) view.getContext()).finish();
|
|
}
|
|
}
|
|
|
|
public void onRightClick(View view) {
|
|
}
|
|
}
|
|
|
|
void onClick(View view);
|
|
}
|
|
|
|
public NavigationBarView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void a() {
|
|
setOnClickListener(new View.OnClickListener(this) { // from class: com.ubt.jimu.widgets.NavigationBarView.1
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
}
|
|
});
|
|
}
|
|
|
|
public View getRightIcon() {
|
|
return this.c;
|
|
}
|
|
|
|
public void setLeftIcon(int i) {
|
|
this.a.setBackgroundResource(i);
|
|
}
|
|
|
|
public void setLeftIvSrc(int i) {
|
|
this.a.setImageResource(i);
|
|
}
|
|
|
|
public void setListener(OnActionClickListener onActionClickListener) {
|
|
this.e = onActionClickListener;
|
|
}
|
|
|
|
public void setMode(int i) {
|
|
this.f = i;
|
|
if (i == 0) {
|
|
this.c.setVisibility(8);
|
|
this.d.setVisibility(8);
|
|
} else if (i == 1) {
|
|
this.c.setVisibility(0);
|
|
this.d.setVisibility(8);
|
|
} else if (i == 2) {
|
|
this.c.setVisibility(8);
|
|
this.d.setVisibility(0);
|
|
}
|
|
}
|
|
|
|
public void setRightAlpha(float f) {
|
|
int i = this.f;
|
|
if (i == 1) {
|
|
this.c.setAlpha(f);
|
|
} else if (i == 2) {
|
|
this.d.setAlpha(f);
|
|
}
|
|
}
|
|
|
|
public void setRightEnabled(boolean z) {
|
|
int i = this.f;
|
|
if (i == 1) {
|
|
this.c.setEnabled(z);
|
|
} else if (i == 2) {
|
|
this.d.setEnabled(z);
|
|
}
|
|
}
|
|
|
|
public void setRightIcon(int i) {
|
|
this.c.setVisibility(0);
|
|
this.d.setVisibility(8);
|
|
this.c.setBackgroundResource(i);
|
|
}
|
|
|
|
public void setRightIvSrc(int i) {
|
|
this.c.setVisibility(0);
|
|
this.d.setVisibility(8);
|
|
this.c.setImageResource(i);
|
|
}
|
|
|
|
public void setRightIvVisibility(int i) {
|
|
this.c.setVisibility(i);
|
|
}
|
|
|
|
public void setRightText(int i) {
|
|
this.c.setVisibility(8);
|
|
this.d.setVisibility(0);
|
|
this.d.setText(i);
|
|
}
|
|
|
|
public void setTitle(int i) {
|
|
this.b.setText(i);
|
|
}
|
|
|
|
public void setTitleColor(int i) {
|
|
this.b.setTextColor(i);
|
|
}
|
|
|
|
public NavigationBarView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
private void a(Context context, AttributeSet attributeSet) {
|
|
String str;
|
|
int i;
|
|
int i2 = 0;
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.NavigationBarView);
|
|
i = obtainStyledAttributes.getInt(1, 0);
|
|
str = obtainStyledAttributes.getString(4);
|
|
i2 = obtainStyledAttributes.getInt(3, 0);
|
|
obtainStyledAttributes.recycle();
|
|
} else {
|
|
str = "";
|
|
i = 0;
|
|
}
|
|
if (i2 == 0) {
|
|
LayoutInflater.from(context).inflate(R.layout.lay_navigation_bar, this);
|
|
} else if (i2 == 2) {
|
|
LayoutInflater.from(context).inflate(R.layout.lay_navigation_bar_min_round, this);
|
|
} else if (i2 == 3) {
|
|
LayoutInflater.from(context).inflate(R.layout.lay_navigation_bar_middle_round, this);
|
|
} else {
|
|
LayoutInflater.from(context).inflate(R.layout.lay_navigation_bar_large, this);
|
|
}
|
|
this.a = (ImageView) findViewById(R.id.iv_left);
|
|
this.a.setOnClickListener(this.g);
|
|
this.a.bringToFront();
|
|
this.b = (TextView) findViewById(R.id.tv_title);
|
|
this.b.setText(str);
|
|
this.c = (ImageView) findViewById(R.id.iv_right);
|
|
this.c.setOnClickListener(this.g);
|
|
this.d = (TextView) findViewById(R.id.tv_right);
|
|
this.d.setOnClickListener(this.g);
|
|
setMode(i);
|
|
setListener(new OnActionClickListener.Stub());
|
|
}
|
|
|
|
public void setTitle(String str) {
|
|
this.b.setText(str);
|
|
}
|
|
|
|
public NavigationBarView(Context context, AttributeSet attributeSet, int i) {
|
|
this(context, attributeSet, i, 0);
|
|
}
|
|
|
|
public NavigationBarView(Context context, AttributeSet attributeSet, int i, int i2) {
|
|
super(context, attributeSet, i, i2);
|
|
this.g = new View.OnClickListener() { // from class: com.ubt.jimu.widgets.h
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
NavigationBarView.this.a(view);
|
|
}
|
|
};
|
|
a(context, attributeSet);
|
|
a();
|
|
}
|
|
|
|
public /* synthetic */ void a(View view) {
|
|
OnActionClickListener onActionClickListener = this.e;
|
|
if (onActionClickListener != null) {
|
|
onActionClickListener.onClick(view);
|
|
}
|
|
}
|
|
}
|