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:
parent
4b73ec3585
commit
3229907fc6
|
@ -35,6 +35,7 @@ import java.util.List;
|
|||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class AccountFragment extends BaseFragment implements AccountActionListener {
|
||||
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) {
|
||||
Callback<List<Account>> cb = new Callback<List<Account>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<Account>> call, retrofit2.Response<List<Account>> response) {
|
||||
onFetchAccountsSuccess(response.body(), fromId);
|
||||
public void onResponse(Call<List<Account>> call, Response<List<Account>> response) {
|
||||
if (response.isSuccessful()) {
|
||||
onFetchAccountsSuccess(response.body(), fromId);
|
||||
} else {
|
||||
onFetchAccountsFailure(new Exception(response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,8 +234,12 @@ public class AccountFragment extends BaseFragment implements AccountActionListen
|
|||
public void onBlock(final boolean block, final String id, final int position) {
|
||||
Callback<Relationship> cb = new Callback<Relationship>() {
|
||||
@Override
|
||||
public void onResponse(Call<Relationship> call, retrofit2.Response<Relationship> response) {
|
||||
onBlockSuccess(block, position);
|
||||
public void onResponse(Call<Relationship> call, Response<Relationship> response) {
|
||||
if (response.isSuccessful()) {
|
||||
onBlockSuccess(block, position);
|
||||
} else {
|
||||
onBlockFailure(block, id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -93,9 +93,6 @@ public class MainActivity extends BaseActivity {
|
|||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
// Fetch user info while we're doing other things.
|
||||
fetchUserInfo();
|
||||
|
||||
floatingBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -107,6 +104,10 @@ public class MainActivity extends BaseActivity {
|
|||
setupDrawer();
|
||||
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.
|
||||
TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager());
|
||||
String[] pageTitles = {
|
||||
|
|
Loading…
Reference in New Issue