75 lines
2.4 KiB
Java
75 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.ImageView;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
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.db.user.UserDbHandler;
|
|
import com.ubt.jimu.base.entities.User;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class UserEntryView extends RelativeLayout {
|
|
private ImageView a;
|
|
private TextView b;
|
|
private ProgressBar c;
|
|
|
|
public UserEntryView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void a(Context context) {
|
|
LayoutInflater.from(context).inflate(R.layout.lay_user_entry, this);
|
|
this.a = (ImageView) findViewById(R.id.portrait);
|
|
this.b = (TextView) findViewById(R.id.name);
|
|
this.c = (ProgressBar) findViewById(R.id.level);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowFocusChanged(boolean z) {
|
|
super.onWindowFocusChanged(z);
|
|
if (z) {
|
|
a();
|
|
}
|
|
}
|
|
|
|
public UserEntryView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public UserEntryView(Context context, AttributeSet attributeSet, int i) {
|
|
this(context, attributeSet, i, 0);
|
|
}
|
|
|
|
public UserEntryView(Context context, AttributeSet attributeSet, int i, int i2) {
|
|
super(context, attributeSet, i, i2);
|
|
a(context);
|
|
}
|
|
|
|
public void a() {
|
|
User user = UserDbHandler.getUser();
|
|
if (user == null) {
|
|
this.b.setVisibility(8);
|
|
this.c.setVisibility(8);
|
|
RequestBuilder<Drawable> a = Glide.e(getContext()).a(Integer.valueOf(R.drawable.default_photo));
|
|
a.a(RequestOptions.O().h().b());
|
|
a.a(this.a);
|
|
return;
|
|
}
|
|
this.b.setVisibility(0);
|
|
this.c.setVisibility(0);
|
|
this.c.setProgress((int) ((user.getCurExp() / user.getExpLength()) * 100.0f));
|
|
this.b.setText(user.getNickName());
|
|
RequestBuilder<Drawable> a2 = Glide.e(getContext()).a(user.getUserImage());
|
|
a2.a(RequestOptions.N().b().b(R.drawable.default_photo).a(R.drawable.default_photo));
|
|
a2.a(this.a);
|
|
}
|
|
}
|