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")) {
account.avatar = avatarUrl;
} else {
account.avatar = "";
account.avatar = null;
}
String headerUrl = object.getString("header");
if (!headerUrl.equals("/headers/original/missing.png")) {
account.header = headerUrl;
} else {
account.header = "";
account.header = null;
}
account.followersCount = object.getString("followers_count");
account.followingCount = object.getString("following_count");

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

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

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

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

@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.android.volley.toolbox.NetworkImageView
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:scaleType="fitCenter"

Loading…
Cancel
Save