From c663d46d77bcad8fbf62dc2905a5da94fabaee00 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 18 Nov 2018 18:06:45 +0100 Subject: Prepares release 1.30.0 --- .../gouv/etalab/mastodon/helper/CrossActions.java | 76 ++++++++++++---------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java index 382b5c2bf..56da9b628 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java @@ -449,14 +449,15 @@ public class CrossActions { @Override public void onClick(final DialogInterface dialog, int which) { final Account account = accountArray[which]; - new AsyncTask() { - private List remoteStatuses; - private WeakReference contextReference = new WeakReference<>(context); + if(status != null) { + new AsyncTask() { + private List remoteStatuses; + private WeakReference contextReference = new WeakReference<>(context); + + @Override + protected Void doInBackground(Void... voids) { - @Override - protected Void doInBackground(Void... voids) { - if(status != null) { API api = new API(contextReference.get(), account.getInstance(), account.getToken()); String uri; if (status.getReblog() != null) { @@ -474,40 +475,47 @@ public class CrossActions { if (search != null) { remoteStatuses = search.getStatuses(); } + return null; } - return null; - } - @Override - protected void onPostExecute(Void result) { - Intent intent = new Intent(contextReference.get(), TootActivity.class); - Bundle b = new Bundle(); - if( remoteStatuses == null || remoteStatuses.size() == 0){ - dialog.dismiss(); + @Override + protected void onPostExecute(Void result) { + Intent intent = new Intent(contextReference.get(), TootActivity.class); + Bundle b = new Bundle(); + if (remoteStatuses == null || remoteStatuses.size() == 0) { + dialog.dismiss(); + intent.putExtras(b); //Put your id to your next Intent + contextReference.get().startActivity(intent); + return; + } + if (remoteStatuses.get(0).getReblog() != null) { + b.putParcelable("tootReply", remoteStatuses.get(0).getReblog()); + b.putParcelable("idRedirect", status.getReblog()); + } else { + b.putParcelable("tootReply", remoteStatuses.get(0)); + b.putParcelable("idRedirect", status); + } + b.putString("accountReplyToken", account.getToken()); intent.putExtras(b); //Put your id to your next Intent contextReference.get().startActivity(intent); - return; - } - if( remoteStatuses.get(0).getReblog() != null ) { - b.putParcelable("tootReply", remoteStatuses.get(0).getReblog()); - b.putParcelable("idRedirect", status.getReblog()); - }else { - b.putParcelable("tootReply", remoteStatuses.get(0)); - b.putParcelable("idRedirect", status); - } - b.putString("accountReplyToken", account.getToken()); - intent.putExtras(b); //Put your id to your next Intent - contextReference.get().startActivity(intent); - if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){ - try { - //Avoid to open multi activities when replying in a conversation - ((ShowConversationActivity)contextReference.get()).finish(); - }catch (Exception ignored){} + if (type == RetrieveFeedsAsyncTask.Type.CONTEXT) { + try { + //Avoid to open multi activities when replying in a conversation + ((ShowConversationActivity) contextReference.get()).finish(); + } catch (Exception ignored) { + } + } + dialog.dismiss(); } - dialog.dismiss(); - } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR ); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + }else{ + Intent intent = new Intent(context, TootActivity.class); + Bundle b = new Bundle(); + b.putString("accountReplyToken", account.getToken()); + intent.putExtras(b); //Put your id to your next Intent + context.startActivity(intent); + } } }); -- cgit v1.2.3