Show conversation when clicking on a toot of a remote instance
This commit is contained in:
parent
3e0acb6b2a
commit
e53fc096e6
|
@ -617,35 +617,43 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
});
|
||||
//Click on a conversation
|
||||
if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && (getItemViewType(position) == DISPLAYED_STATUS || getItemViewType(position) == COMPACT_STATUS)) {
|
||||
if( (getItemViewType(position) == DISPLAYED_STATUS || getItemViewType(position) == COMPACT_STATUS)) {
|
||||
holder.status_content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (status.getReblog() == null)
|
||||
b.putString("statusId", status.getId());
|
||||
else
|
||||
b.putString("statusId", status.getReblog().getId());
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
if(type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (status.getReblog() == null)
|
||||
b.putString("statusId", status.getId());
|
||||
else
|
||||
b.putString("statusId", status.getReblog().getId());
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
}else {
|
||||
CrossActions.doCrossConversation(context,status);
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.main_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (status.getReblog() == null)
|
||||
b.putString("statusId", status.getId());
|
||||
else
|
||||
b.putString("statusId", status.getReblog().getId());
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
if(type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if (status.getReblog() == null)
|
||||
b.putString("statusId", status.getId());
|
||||
else
|
||||
b.putString("statusId", status.getReblog().getId());
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
}else {
|
||||
CrossActions.doCrossConversation(context,status);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -236,6 +236,43 @@ public class CrossActions {
|
|||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR );
|
||||
}
|
||||
|
||||
public static void doCrossConversation(final Context context, Status remoteStatus){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private WeakReference<Context> contextReference = new WeakReference<>(context);
|
||||
Results response;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
Toast.makeText(contextReference.get(), R.string.retrieve_remote_conversation, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
API api = new API(contextReference.get(), account.getInstance(), account.getToken());
|
||||
response = api.search(remoteStatus.getUrl());
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if( response == null){
|
||||
return;
|
||||
}
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses = response.getStatuses();
|
||||
if( statuses != null && statuses.size() > 0) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("statusId", statuses.get(0).getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -621,6 +621,7 @@
|
|||
<string name="select_sound">Select Tone</string>
|
||||
<string name="set_enable_time_slot">Enable time slot</string>
|
||||
<string name="how_to_videos">How To Videos</string>
|
||||
<string name="retrieve_remote_conversation">Fetching remote thread!</string>
|
||||
|
||||
<string-array name="filter_expire">
|
||||
<item>Never</item>
|
||||
|
|
Loading…
Reference in New Issue