Divide searches
This commit is contained in:
parent
2622a75906
commit
18cc3a13f9
|
@ -383,9 +383,9 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
protected Void doInBackground(Void... voids) {
|
||||
|
||||
if (peertube != null) {
|
||||
Results search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
|
||||
if (search != null) {
|
||||
remoteStatuses = search.getStatuses();
|
||||
APIResponse search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
|
||||
if (search != null && search.getResults() != null) {
|
||||
remoteStatuses = search.getResults().getStatuses();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -139,21 +139,24 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
|
|||
|
||||
|
||||
@Override
|
||||
public void onRetrieveSearch(Results results, Error error) {
|
||||
public void onRetrieveSearch(APIResponse apiResponse) {
|
||||
loader.setVisibility(View.GONE);
|
||||
if( error != null){
|
||||
Toasty.error(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
|
||||
if( apiResponse.getError() != null){
|
||||
if( apiResponse.getError().getError() != null)
|
||||
Toasty.error(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toasty.error(getApplicationContext(), getString(R.string.toast_error),Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if( results == null || (results.getAccounts().size() == 0 && results.getStatuses().size() == 0 && results.getHashtags().size() == 0)){
|
||||
if( apiResponse.getResults() == null || ( apiResponse.getResults().getAccounts().size() == 0 && apiResponse.getResults().getStatuses().size() == 0 && apiResponse.getResults().getHashtags().size() == 0)){
|
||||
RelativeLayout no_result = findViewById(R.id.no_result);
|
||||
no_result.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
lv_search.setVisibility(View.VISIBLE);
|
||||
List<String> tags = results.getHashtags();
|
||||
List<Account> accounts = results.getAccounts();
|
||||
List<Status> statuses = results.getStatuses();
|
||||
List<String> tags = apiResponse.getResults().getHashtags();
|
||||
List<Account> accounts = apiResponse.getResults().getAccounts();
|
||||
List<Status> statuses = apiResponse.getResults().getStatuses();
|
||||
|
||||
SearchListAdapter searchListAdapter = new SearchListAdapter(SearchResultActivity.this, statuses, accounts, tags);
|
||||
lv_search.setAdapter(searchListAdapter);
|
||||
|
|
|
@ -17,11 +17,13 @@ package fr.gouv.etalab.mastodon.activities;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
@ -30,12 +32,14 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplaySearchTagsFragment;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
||||
|
@ -53,8 +57,6 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
|
||||
|
||||
private String search;
|
||||
private ListView lv_search;
|
||||
private RelativeLayout loader;
|
||||
private TabLayout tabLayout;
|
||||
private ViewPager search_viewpager;
|
||||
private DisplayStatusFragment displayStatusFragment;
|
||||
|
@ -81,8 +83,18 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
|
||||
setContentView(R.layout.activity_search_result_tabs);
|
||||
|
||||
loader = findViewById(R.id.loader);
|
||||
lv_search = findViewById(R.id.lv_search);
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
if(b != null){
|
||||
search = b.getString("search");
|
||||
if( search == null)
|
||||
Toasty.error(this,getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
|
||||
}else{
|
||||
Toasty.error(this,getString(R.string.toast_error_search),Toast.LENGTH_LONG).show();
|
||||
}
|
||||
if( search == null)
|
||||
finish();
|
||||
|
||||
tabLayout = findViewById(R.id.search_tabLayout);
|
||||
search_viewpager = findViewById(R.id.search_viewpager);
|
||||
|
||||
|
@ -111,8 +123,61 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
setTitle(search);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
lv_search.setVisibility(View.GONE);
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.tags)));
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.accounts)));
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.toots)));
|
||||
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
search_viewpager.setAdapter(mPagerAdapter);
|
||||
|
||||
search_viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
||||
if( tab != null)
|
||||
tab.select();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
search_viewpager.setCurrentItem(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
Fragment fragment;
|
||||
if( search_viewpager.getAdapter() != null) {
|
||||
fragment = (Fragment) search_viewpager.getAdapter().instantiateItem(search_viewpager, tab.getPosition());
|
||||
if (fragment instanceof DisplayAccountsFragment) {
|
||||
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
||||
displayAccountsFragment.scrollToTop();
|
||||
} else if (fragment instanceof DisplayStatusFragment) {
|
||||
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
displayStatusFragment.scrollToTop();
|
||||
} else if (fragment instanceof DisplaySearchTagsFragment) {
|
||||
DisplaySearchTagsFragment displaySearchTagsFragment = ((DisplaySearchTagsFragment) fragment);
|
||||
displaySearchTagsFragment.scrollToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -144,22 +209,22 @@ public class SearchResultTabActivity extends BaseActivity {
|
|||
switch (position){
|
||||
case 0:
|
||||
DisplaySearchTagsFragment displaySearchTagsFragment = new DisplaySearchTagsFragment();
|
||||
bundle.putSerializable("tagsOnly", true);
|
||||
displaySearchTagsFragment.setArguments(bundle);
|
||||
bundle.putSerializable("search", search);
|
||||
return displaySearchTagsFragment;
|
||||
case 1:
|
||||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.SEARCH);
|
||||
bundle.putSerializable("tag", search);
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
case 2:
|
||||
DisplayStatusFragment displayStatusFragment = new DisplayStatusFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.SEARCH);
|
||||
bundle.putSerializable("tag", search);
|
||||
displayStatusFragment.setArguments(bundle);
|
||||
return displayStatusFragment;
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -2183,14 +2183,14 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveSearch(Results results, Error error) {
|
||||
public void onRetrieveSearch(APIResponse apiResponse) {
|
||||
if( pp_progress != null && pp_actionBar != null) {
|
||||
pp_progress.setVisibility(View.GONE);
|
||||
pp_actionBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if( results == null)
|
||||
if( apiResponse == null || apiResponse.getResults() == null)
|
||||
return;
|
||||
|
||||
Results results = apiResponse.getResults();
|
||||
final List<String> tags = results.getHashtags();
|
||||
if( tags != null && tags.size() > 0){
|
||||
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(TootActivity.this, tags);
|
||||
|
|
|
@ -50,6 +50,7 @@ import java.util.List;
|
|||
import es.dmoral.toasty.Toasty;
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.helper.CountDrawable;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
|
@ -288,9 +289,9 @@ public class WebviewActivity extends BaseActivity {
|
|||
protected Void doInBackground(Void... voids) {
|
||||
|
||||
if(url != null) {
|
||||
Results search = new API(contextReference.get()).search(peertubeLinkToFetch);
|
||||
if (search != null) {
|
||||
remoteStatuses = search.getStatuses();
|
||||
APIResponse search = new API(contextReference.get()).search(peertubeLinkToFetch);
|
||||
if (search != null && search.getResults() != null) {
|
||||
remoteStatuses = search.getResults().getStatuses();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
|
@ -139,9 +140,9 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
else
|
||||
uri = remoteStatus.getUrl();
|
||||
}
|
||||
Results search = api.search(uri);
|
||||
if (search != null) {
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.Status> remoteStatuses = search.getStatuses();
|
||||
APIResponse search = api.search(uri);
|
||||
if (search != null && search.getResults() != null) {
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.Status> remoteStatuses = search.getResults().getStatuses();
|
||||
if (remoteStatuses != null && remoteStatuses.size() > 0) {
|
||||
fr.gouv.etalab.mastodon.client.Entities.Status statusTmp = remoteStatuses.get(0);
|
||||
this.targetedId = statusTmp.getId();
|
||||
|
@ -150,9 +151,9 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
} else if (remoteAccount != null) {
|
||||
String searchString = remoteAccount.getAcct().contains("@") ? "@" + remoteAccount.getAcct() : "@" + remoteAccount.getAcct() + "@" + Helper.getLiveInstance(contextReference.get());
|
||||
Results search = api.search(searchString);
|
||||
if (search != null) {
|
||||
List<Account> accounts = search.getAccounts();
|
||||
APIResponse search = api.search(searchString);
|
||||
if (search != null && search.getResults() != null) {
|
||||
List<Account> accounts = search.getResults().getAccounts();
|
||||
if (accounts != null && accounts.size() > 0) {
|
||||
Account accountTmp = accounts.get(0);
|
||||
this.targetedId = accountTmp.getId();
|
||||
|
|
|
@ -93,6 +93,10 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
apiResponse = gnuapi.getRebloggedBy(targetedId, max_id);
|
||||
}
|
||||
break;
|
||||
case SEARCH:
|
||||
api = new API(this.contextReference.get());
|
||||
apiResponse = api.search2(targetedId, API.searchType.ACCOUNTS, max_id);
|
||||
break;
|
||||
case FAVOURITED:
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA){
|
||||
assert api != null;
|
||||
|
|
|
@ -18,6 +18,7 @@ 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.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
||||
|
@ -53,7 +54,9 @@ public class RetrieveRemoteDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
API api = new API(this.contextReference.get());
|
||||
results = api.search(this.url);
|
||||
APIResponse apiResponse = api.search(this.url);
|
||||
if( apiResponse.getResults() != null)
|
||||
results = apiResponse.getResults();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.content.SharedPreferences;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
@ -3414,7 +3415,7 @@ public class API {
|
|||
List<String> list_tmp = new ArrayList<>();
|
||||
for(int i = 0; i < jsonArray.length(); i++){
|
||||
try {
|
||||
list_tmp.add(jsonArray.getString(i));
|
||||
list_tmp.add(jsonArray.getJSONObject(i).getString("name"));
|
||||
} catch (JSONException ignored) {}
|
||||
}
|
||||
return list_tmp;
|
||||
|
|
|
@ -69,7 +69,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
private boolean swiped;
|
||||
private RecyclerView lv_accounts;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
|
@ -80,7 +79,10 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
accounts = new ArrayList<>();
|
||||
if (bundle != null) {
|
||||
type = (RetrieveAccountsAsyncTask.Type) bundle.get("type");
|
||||
targetedId = bundle.getString("targetedid", null);
|
||||
if( bundle.containsKey("tag"))
|
||||
targetedId = bundle.getString("tag", null);
|
||||
else
|
||||
targetedId = bundle.getString("targetedid", null);
|
||||
instance = bundle.getString("instance", null);
|
||||
name = bundle.getString("name", null);
|
||||
}
|
||||
|
@ -113,7 +115,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||
if (!flag_loading) {
|
||||
flag_loading = true;
|
||||
if (type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING || type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if (type == RetrieveAccountsAsyncTask.Type.CHANNELS)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -135,7 +137,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
firstLoad = true;
|
||||
flag_loading = true;
|
||||
swiped = true;
|
||||
if (type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING|| type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING|| type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if (type == RetrieveAccountsAsyncTask.Type.CHANNELS)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -166,7 +168,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
break;
|
||||
}
|
||||
|
||||
if (type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING|| type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
if (type == RetrieveAccountsAsyncTask.Type.SEARCH || type == RetrieveAccountsAsyncTask.Type.FOLLOWERS || type == RetrieveAccountsAsyncTask.Type.FOLLOWING|| type == RetrieveAccountsAsyncTask.Type.REBLOGGED || type == RetrieveAccountsAsyncTask.Type.FAVOURITED)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, type, targetedId, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if (type == RetrieveAccountsAsyncTask.Type.CHANNELS)
|
||||
asyncTask = new RetrieveAccountsAsyncTask(context, instance, name, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -213,7 +215,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
return;
|
||||
}
|
||||
flag_loading = (apiResponse.getMax_id() == null );
|
||||
List<Account> accounts = apiResponse.getAccounts();
|
||||
|
||||
List<Account> accounts;
|
||||
if( apiResponse.getResults() != null && apiResponse.getResults().getAccounts() != null)
|
||||
accounts = apiResponse.getResults().getAccounts();
|
||||
else
|
||||
accounts = apiResponse.getAccounts();
|
||||
if( !swiped && firstLoad && (accounts == null || accounts.size() == 0))
|
||||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
else
|
||||
|
|
|
@ -59,10 +59,10 @@ public class DisplaySearchTagsFragment extends Fragment implements OnRetrieveSea
|
|||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
View rootView = inflater.inflate(R.layout.fragment_search, container, false);
|
||||
View rootView = inflater.inflate(R.layout.fragment_search_tag, container, false);
|
||||
context = getContext();
|
||||
|
||||
lv_search_tags = rootView.findViewById(R.id.lv_search_toots);
|
||||
lv_search_tags = rootView.findViewById(R.id.lv_search_tags);
|
||||
loader = rootView.findViewById(R.id.loader);
|
||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -499,7 +499,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
apiResponse.setStatuses(statusesConversations);
|
||||
}
|
||||
int previousPosition = this.statuses.size();
|
||||
List<Status> statuses = apiResponse.getStatuses();
|
||||
List<Status> statuses;
|
||||
|
||||
if( apiResponse.getResults() != null && apiResponse.getResults().getStatuses() != null)
|
||||
statuses = apiResponse.getResults().getStatuses();
|
||||
else
|
||||
statuses = apiResponse.getStatuses();
|
||||
//At this point all statuses are in "List<Status> statuses"
|
||||
//Pagination for Pixelfed
|
||||
if(instanceType.equals("PIXELFED")) {
|
||||
|
@ -984,7 +989,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
if (type == RetrieveFeedsAsyncTask.Type.USER || type == RetrieveFeedsAsyncTask.Type.CHANNEL)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, showReply,DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
//Tag timelines
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.TAG)
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.TAG || type == RetrieveFeedsAsyncTask.Type.SEARCH)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
else if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
|
||||
//Remote instances
|
||||
|
|
|
@ -41,6 +41,7 @@ import fr.gouv.etalab.mastodon.activities.TootActivity;
|
|||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
|
@ -287,7 +288,8 @@ public class CrossActions {
|
|||
API api = new API(contextReference.get());
|
||||
String url;
|
||||
url = "https://" + remoteAccount.getHost() + "/video-channels/" + remoteAccount.getAcct().split("@")[0];
|
||||
response = api.search(url);
|
||||
APIResponse apiResponse = api.search(url);
|
||||
response = apiResponse.getResults();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
@ -328,7 +330,8 @@ public class CrossActions {
|
|||
else
|
||||
url = "https://" + remoteAccount.getInstance() + "/@" + remoteAccount.getAcct();
|
||||
}
|
||||
response = api.search(url);
|
||||
APIResponse apiResponse = api.search(url);
|
||||
response = apiResponse.getResults();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
@ -369,7 +372,8 @@ public class CrossActions {
|
|||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
API api = new API(contextReference.get(), account.getInstance(), account.getToken());
|
||||
response = api.search(remoteStatus.getUrl());
|
||||
APIResponse apiResponse = api.search(remoteStatus.getUrl());
|
||||
response = apiResponse.getResults();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
@ -408,7 +412,8 @@ public class CrossActions {
|
|||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
API api = new API(contextReference.get(), account.getInstance(), account.getToken());
|
||||
response = api.search(url);
|
||||
APIResponse apiResponse = api.search(url);
|
||||
response = apiResponse.getResults();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
@ -479,7 +484,8 @@ public class CrossActions {
|
|||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
API api = new API(contextReference.get(), account.getInstance(), account.getToken());
|
||||
response = api.search(status.getUrl());
|
||||
APIResponse apiResponse = api.search(status.getUrl());
|
||||
response = apiResponse.getResults();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
@ -574,9 +580,9 @@ public class CrossActions {
|
|||
else
|
||||
uri = status.getUrl();
|
||||
}
|
||||
Results search = api.search(uri);
|
||||
if (search != null) {
|
||||
remoteStatuses = search.getStatuses();
|
||||
APIResponse search = api.search(uri);
|
||||
if (search != null && search.getResults() != null) {
|
||||
remoteStatuses = search.getResults().getStatuses();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -649,9 +655,9 @@ public class CrossActions {
|
|||
else
|
||||
uri = status.getUrl();
|
||||
}
|
||||
Results search = api.search(uri);
|
||||
if( search != null){
|
||||
remoteStatuses = search.getStatuses();
|
||||
APIResponse search = api.search(uri);
|
||||
if( search != null && search.getResults() != null){
|
||||
remoteStatuses = search.getResults().getStatuses();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue