Fixes a couple of crashes.

1.) When on the account page, if the request for user info beats the call that initialises the header image, it can touch a header image with illegal dimensions that get handed to Picasso and cause an exception.
2.) A crash due to a few retrofit responses not being handled properly.
This commit is contained in:
Vavassor 2017-03-20 22:53:46 -04:00
parent 4b73ec3585
commit 3229907fc6
2 changed files with 17 additions and 7 deletions

View file

@ -35,6 +35,7 @@ import java.util.List;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response;
public class AccountFragment extends BaseFragment implements AccountActionListener { public class AccountFragment extends BaseFragment implements AccountActionListener {
private static final String TAG = "Account"; // logging tag private static final String TAG = "Account"; // logging tag
@ -160,8 +161,12 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
private void fetchAccounts(final String fromId, String uptoId) { private void fetchAccounts(final String fromId, String uptoId) {
Callback<List<Account>> cb = new Callback<List<Account>>() { Callback<List<Account>> cb = new Callback<List<Account>>() {
@Override @Override
public void onResponse(Call<List<Account>> call, retrofit2.Response<List<Account>> response) { public void onResponse(Call<List<Account>> call, Response<List<Account>> response) {
onFetchAccountsSuccess(response.body(), fromId); if (response.isSuccessful()) {
onFetchAccountsSuccess(response.body(), fromId);
} else {
onFetchAccountsFailure(new Exception(response.message()));
}
} }
@Override @Override
@ -229,8 +234,12 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
public void onBlock(final boolean block, final String id, final int position) { public void onBlock(final boolean block, final String id, final int position) {
Callback<Relationship> cb = new Callback<Relationship>() { Callback<Relationship> cb = new Callback<Relationship>() {
@Override @Override
public void onResponse(Call<Relationship> call, retrofit2.Response<Relationship> response) { public void onResponse(Call<Relationship> call, Response<Relationship> response) {
onBlockSuccess(block, position); if (response.isSuccessful()) {
onBlockSuccess(block, position);
} else {
onBlockFailure(block, id);
}
} }
@Override @Override

View file

@ -93,9 +93,6 @@ public class MainActivity extends BaseActivity {
ButterKnife.bind(this); ButterKnife.bind(this);
// Fetch user info while we're doing other things.
fetchUserInfo();
floatingBtn.setOnClickListener(new View.OnClickListener() { floatingBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -107,6 +104,10 @@ public class MainActivity extends BaseActivity {
setupDrawer(); setupDrawer();
setupSearchView(); setupSearchView();
/* Fetch user info while we're doing other things. This has to be after setting up the
* drawer, though, because its callback touches the header in the drawer. */
fetchUserInfo();
// Setup the tabs and timeline pager. // Setup the tabs and timeline pager.
TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager()); TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager());
String[] pageTitles = { String[] pageTitles = {