Fix up account list item layouts

This commit is contained in:
Eugen Rochko 2017-03-07 14:32:07 +01:00
parent 2cf387bc21
commit bdc19efe3d
2 changed files with 16 additions and 11 deletions

View File

@ -20,10 +20,12 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView; import com.android.volley.toolbox.NetworkImageView;
import com.squareup.picasso.Picasso;
/** Both for follows and following lists. */ /** Both for follows and following lists. */
class FollowAdapter extends AccountAdapter { class FollowAdapter extends AccountAdapter {
@ -78,7 +80,7 @@ class FollowAdapter extends AccountAdapter {
private TextView username; private TextView username;
private TextView displayName; private TextView displayName;
private TextView note; private TextView note;
private NetworkImageView avatar; private ImageView avatar;
private String id; private String id;
AccountViewHolder(View itemView) { AccountViewHolder(View itemView) {
@ -87,9 +89,7 @@ class FollowAdapter extends AccountAdapter {
username = (TextView) itemView.findViewById(R.id.account_username); username = (TextView) itemView.findViewById(R.id.account_username);
displayName = (TextView) itemView.findViewById(R.id.account_display_name); displayName = (TextView) itemView.findViewById(R.id.account_display_name);
note = (TextView) itemView.findViewById(R.id.account_note); note = (TextView) itemView.findViewById(R.id.account_note);
avatar = (NetworkImageView) itemView.findViewById(R.id.account_avatar); avatar = (ImageView) itemView.findViewById(R.id.account_avatar);
avatar.setDefaultImageResId(R.drawable.avatar_default);
avatar.setErrorImageResId(R.drawable.avatar_error);
} }
void setupWithAccount(Account account) { void setupWithAccount(Account account) {
@ -100,8 +100,11 @@ class FollowAdapter extends AccountAdapter {
displayName.setText(account.displayName); displayName.setText(account.displayName);
note.setText(account.note); note.setText(account.note);
Context context = avatar.getContext(); Context context = avatar.getContext();
ImageLoader imageLoader = VolleySingleton.getInstance(context).getImageLoader(); Picasso.with(context)
avatar.setImageUrl(account.avatar, imageLoader); .load(account.avatar)
.placeholder(R.drawable.avatar_default)
.error(R.drawable.avatar_error)
.into(avatar);
} }
void setupActionListener(final AccountActionListener listener) { void setupActionListener(final AccountActionListener listener) {

View File

@ -3,19 +3,18 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:id="@+id/account_container"> android:id="@+id/account_container">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.android.volley.toolbox.NetworkImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/account_avatar" android:id="@+id/account_avatar"
android:layout_marginLeft="@dimen/account_avatar_margin" android:layout_marginRight="10dp" />
android:layout_marginRight="@dimen/account_avatar_margin"
android:layout_marginTop="@dimen/account_avatar_margin" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -28,11 +27,13 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/account_display_name" android:id="@+id/account_display_name"
android:textColor="?android:textColorPrimary"
android:textStyle="normal|bold" /> android:textStyle="normal|bold" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:id="@+id/account_username" /> android:id="@+id/account_username" />
</LinearLayout> </LinearLayout>
@ -43,6 +44,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/account_note" android:id="@+id/account_note"
android:layout_margin="@dimen/account_note_margin" /> android:paddingTop="4dp"
android:textColor="?android:textColorTertiary" />
</LinearLayout> </LinearLayout>