mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-23 06:07:16 +00:00
change PartyMemberRecyclerViewAdapter to use AvatarView
This commit is contained in:
parent
7de73c589f
commit
30b72cf8f4
3 changed files with 20 additions and 27 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp">
|
||||
|
|
@ -10,13 +11,14 @@
|
|||
android:layout_margin="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/avatar"
|
||||
android:layout_marginRight="5dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="147dp" />
|
||||
android:layout_height="147dp"
|
||||
android:layout_marginRight="5dp"
|
||||
app:showBackground="true"
|
||||
app:showMount="true"
|
||||
app:showPet="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/CardView.Default">
|
||||
|
|
@ -10,13 +11,14 @@
|
|||
style="@style/CardContent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/avatar"
|
||||
android:layout_marginRight="5dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="103dp"
|
||||
android:layout_height="90dp" />
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginRight="5dp"
|
||||
app:showBackground="false"
|
||||
app:showMount="false"
|
||||
app:showPet="false" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.habitrpg.android.habitica.R;
|
|||
import com.habitrpg.android.habitica.databinding.ValueBarBinding;
|
||||
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
|
||||
import com.habitrpg.android.habitica.ui.helpers.ViewHelper;
|
||||
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
||||
import com.habitrpg.android.habitica.ui.AvatarView;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -12,11 +12,9 @@ import android.content.res.Resources;
|
|||
import android.databinding.DataBindingUtil;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -56,8 +54,8 @@ public class PartyMemberRecyclerViewAdapter extends RecyclerView.Adapter<PartyMe
|
|||
|
||||
class MemberViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.avatar)
|
||||
ImageView imageView;
|
||||
@BindView(R.id.avatarView)
|
||||
AvatarView avatarView;
|
||||
|
||||
@BindView(R.id.username)
|
||||
TextView userName;
|
||||
|
|
@ -74,7 +72,6 @@ public class PartyMemberRecyclerViewAdapter extends RecyclerView.Adapter<PartyMe
|
|||
ValueBarBinding hpBar;
|
||||
|
||||
Resources resources;
|
||||
UserPicture userPicture;
|
||||
|
||||
public MemberViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
|
@ -87,20 +84,12 @@ public class PartyMemberRecyclerViewAdapter extends RecyclerView.Adapter<PartyMe
|
|||
hpBar.setPartyMembers(true);
|
||||
|
||||
resources = itemView.getResources();
|
||||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
||||
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
|
||||
if (dpWidth >= 320) {
|
||||
userPicture = new UserPicture(itemView.getContext(), true, true);
|
||||
} else {
|
||||
userPicture = new UserPicture(itemView.getContext(), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(HabitRPGUser user) {
|
||||
android.content.Context ctx = itemView.getContext();
|
||||
|
||||
userPicture.setUser(user);
|
||||
userPicture.setPictureOn(imageView);
|
||||
avatarView.setUser(user);
|
||||
|
||||
AvatarWithBarsViewModel.setHpBarData(hpBar, user.getStats(), ctx);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue