Fixes intermittent crashes when clicking the reply button and opening a thread. Closes #26

This commit is contained in:
Vavassor 2017-03-15 15:27:49 -04:00
parent 7b5c1fdd90
commit 19e2725824
4 changed files with 19 additions and 12 deletions

View File

@ -22,6 +22,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@ -41,7 +42,7 @@ import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
public class LoginActivity extends BaseActivity { public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity"; // logging tag private static final String TAG = "LoginActivity"; // logging tag
private static String OAUTH_SCOPES = "read write follow"; private static String OAUTH_SCOPES = "read write follow";

View File

@ -19,7 +19,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
@ -74,7 +73,7 @@ public class SFragment extends BaseFragment {
mentionedUsernames.remove(loggedInUsername); mentionedUsernames.remove(loggedInUsername);
Intent intent = new Intent(getContext(), ComposeActivity.class); Intent intent = new Intent(getContext(), ComposeActivity.class);
intent.putExtra("in_reply_to_id", inReplyToId); intent.putExtra("in_reply_to_id", inReplyToId);
intent.putExtra("reply_visibility", status.visibility.toString().toLowerCase()); intent.putExtra("reply_visibility", status.getVisibility().toString().toLowerCase());
intent.putExtra("mentioned_usernames", mentionedUsernames.toArray(new String[0])); intent.putExtra("mentioned_usernames", mentionedUsernames.toArray(new String[0]));
startActivity(intent); startActivity(intent);
} }

View File

@ -125,15 +125,18 @@ public class ViewThreadFragment extends SFragment implements StatusActionListene
} }
private void onThreadRequestFailure(final String id) { private void onThreadRequestFailure(final String id) {
Snackbar.make(recyclerView, R.string.error_view_thread, Snackbar.LENGTH_LONG) View view = getView();
.setAction(R.string.action_retry, new View.OnClickListener() { if (view != null) {
@Override Snackbar.make(view, R.string.error_view_thread, Snackbar.LENGTH_LONG)
public void onClick(View v) { .setAction(R.string.action_retry, new View.OnClickListener() {
sendThreadRequest(id); @Override
sendStatusRequest(id); public void onClick(View v) {
} sendThreadRequest(id);
}) sendStatusRequest(id);
.show(); }
})
.show();
}
} }
public void onReply(int position) { public void onReply(int position) {

View File

@ -77,6 +77,10 @@ public class Status {
public Visibility visibility; public Visibility visibility;
public Visibility getVisibility() {
return visibility == null ? Visibility.UNLISTED : visibility;
}
@SerializedName("media_attachments") @SerializedName("media_attachments")
public MediaAttachment[] attachments; public MediaAttachment[] attachments;