Remove card calls as it is now attached by default to statuses
This commit is contained in:
parent
1620bdc58f
commit
c6d10fcf0e
|
@ -27,7 +27,6 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
@ -49,7 +48,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveCardAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveContextAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
|
@ -354,9 +352,6 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
loader.setVisibility(View.GONE);
|
||||
lv_status.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
new RetrieveCardAsyncTask(getApplicationContext(), initialStatus.getId(), ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.asynctasks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import java.lang.ref.WeakReference;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Card;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveCardInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 20/12/2017.
|
||||
* Retrieves Card
|
||||
*/
|
||||
|
||||
public class RetrieveCardAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private String statusId;
|
||||
private Card card;
|
||||
private OnRetrieveCardInterface listener;
|
||||
private WeakReference<Context> contextReference;
|
||||
|
||||
public RetrieveCardAsyncTask(Context context, String statusId, OnRetrieveCardInterface onRetrieveCardInterface){
|
||||
this.contextReference = new WeakReference<>(context);
|
||||
this.statusId = statusId;
|
||||
this.listener = onRetrieveCardInterface;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
card = new API(contextReference.get()).getCard(statusId);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
listener.onRetrieveAccount(card);
|
||||
}
|
||||
|
||||
}
|
|
@ -2300,20 +2300,6 @@ public class API {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get card
|
||||
* @param statusId String, the id of the status
|
||||
* @return Card, the card (null if none)
|
||||
*/
|
||||
public Card getCard(String statusId){
|
||||
|
||||
Card card = null;
|
||||
try {
|
||||
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/statuses/%s/card", statusId)), 60, null, prefKeyOauthTokenT);
|
||||
card = parseCardResponse(new JSONObject(response));
|
||||
}catch (Exception ignored) {ignored.printStackTrace();}
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a list by its id
|
||||
|
@ -2452,7 +2438,7 @@ public class API {
|
|||
* @param resobj JSONObject
|
||||
* @return Card
|
||||
*/
|
||||
private Card parseCardResponse(JSONObject resobj){
|
||||
private static Card parseCardResponse(JSONObject resobj){
|
||||
|
||||
Card card = new Card();
|
||||
try {
|
||||
|
@ -2831,6 +2817,11 @@ public class API {
|
|||
attachments.add(attachment);
|
||||
}
|
||||
}
|
||||
try {
|
||||
status.setCard(parseCardResponse(resobj.getJSONObject("card")));
|
||||
}catch (Exception e){status.setCard(null);}
|
||||
|
||||
|
||||
status.setMedia_attachments(attachments);
|
||||
//Retrieves mentions
|
||||
List<Mention> mentions = new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue