Fixed crash due to Picasso being handed empty strings for missing avatars and header images.

main
Vavassor 8 years ago
parent 1ddb17f8d3
commit 7ae66a4ddc
  1. 4
      app/src/main/java/com/keylesspalace/tusky/Account.java
  2. 22
      app/src/main/java/com/keylesspalace/tusky/AccountActivity.java
  3. 14
      app/src/main/java/com/keylesspalace/tusky/BlocksAdapter.java
  4. 2
      app/src/main/java/com/keylesspalace/tusky/FollowAdapter.java
  5. 1
      app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java
  6. 2
      app/src/main/res/layout/item_blocked_user.xml

@ -50,13 +50,13 @@ class Account {
if (!avatarUrl.equals("/avatars/original/missing.png")) { if (!avatarUrl.equals("/avatars/original/missing.png")) {
account.avatar = avatarUrl; account.avatar = avatarUrl;
} else { } else {
account.avatar = ""; account.avatar = null;
} }
String headerUrl = object.getString("header"); String headerUrl = object.getString("header");
if (!headerUrl.equals("/headers/original/missing.png")) { if (!headerUrl.equals("/headers/original/missing.png")) {
account.header = headerUrl; account.header = headerUrl;
} else { } else {
account.header = ""; account.header = null;
} }
account.followersCount = object.getString("followers_count"); account.followersCount = object.getString("followers_count");
account.followingCount = object.getString("following_count"); account.followingCount = object.getString("following_count");

@ -219,19 +219,15 @@ public class AccountActivity extends BaseActivity {
note.setLinksClickable(true); note.setLinksClickable(true);
note.setMovementMethod(LinkMovementMethod.getInstance()); note.setMovementMethod(LinkMovementMethod.getInstance());
if (!account.avatar.isEmpty()) { Picasso.with(this)
Picasso.with(this) .load(account.avatar)
.load(account.avatar) .placeholder(R.drawable.avatar_default)
.placeholder(R.drawable.avatar_default) .error(R.drawable.avatar_error)
.error(R.drawable.avatar_error) .into(avatar);
.into(avatar); Picasso.with(this)
} .load(account.header)
if (!account.header.isEmpty()) { .placeholder(R.drawable.account_header_missing)
Picasso.with(this) .into(header);
.load(account.header)
.placeholder(R.drawable.account_header_missing)
.into(header);
}
openInWebUrl = account.url; openInWebUrl = account.url;
java.text.NumberFormat nf = java.text.NumberFormat.getInstance(); java.text.NumberFormat nf = java.text.NumberFormat.getInstance();

@ -20,9 +20,10 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.android.volley.toolbox.NetworkImageView; import com.squareup.picasso.Picasso;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -88,7 +89,7 @@ class BlocksAdapter extends AccountAdapter {
} }
private static class BlockedUserViewHolder extends RecyclerView.ViewHolder { private static class BlockedUserViewHolder extends RecyclerView.ViewHolder {
private NetworkImageView avatar; private ImageView avatar;
private TextView username; private TextView username;
private TextView displayName; private TextView displayName;
private Button unblock; private Button unblock;
@ -96,7 +97,7 @@ class BlocksAdapter extends AccountAdapter {
BlockedUserViewHolder(View itemView) { BlockedUserViewHolder(View itemView) {
super(itemView); super(itemView);
avatar = (NetworkImageView) itemView.findViewById(R.id.blocked_user_avatar); avatar = (ImageView) itemView.findViewById(R.id.blocked_user_avatar);
displayName = (TextView) itemView.findViewById(R.id.blocked_user_display_name); displayName = (TextView) itemView.findViewById(R.id.blocked_user_display_name);
username = (TextView) itemView.findViewById(R.id.blocked_user_username); username = (TextView) itemView.findViewById(R.id.blocked_user_username);
unblock = (Button) itemView.findViewById(R.id.blocked_user_unblock); unblock = (Button) itemView.findViewById(R.id.blocked_user_unblock);
@ -108,8 +109,11 @@ class BlocksAdapter extends AccountAdapter {
String format = username.getContext().getString(R.string.status_username_format); String format = username.getContext().getString(R.string.status_username_format);
String formattedUsername = String.format(format, account.username); String formattedUsername = String.format(format, account.username);
username.setText(formattedUsername); username.setText(formattedUsername);
avatar.setImageUrl(account.avatar, Picasso.with(avatar.getContext())
VolleySingleton.getInstance(avatar.getContext()).getImageLoader()); .load(account.avatar)
.error(R.drawable.avatar_error)
.placeholder(R.drawable.avatar_default)
.into(avatar);
} }
void setupActionListener(final AccountActionListener listener, final boolean blocked, void setupActionListener(final AccountActionListener listener, final boolean blocked,

@ -23,8 +23,6 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
/** Both for follows and following lists. */ /** Both for follows and following lists. */

@ -15,7 +15,6 @@
package com.keylesspalace.tusky; package com.keylesspalace.tusky;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;

@ -3,7 +3,7 @@
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="64dp" android:layout_width="64dp"
android:layout_height="64dp" android:layout_height="64dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"

Loading…
Cancel
Save