Some fixes with pagination
This commit is contained in:
parent
18cc3a13f9
commit
101849a07c
|
@ -261,6 +261,9 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
case ONESTATUS:
|
||||
apiResponse = api.getStatusbyId(targetedID);
|
||||
break;
|
||||
case SEARCH:
|
||||
apiResponse = api.search2(tag, API.searchType.STATUSES, max_id);
|
||||
break;
|
||||
case TAG:
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
List<TagTimeline> tagTimelines = new SearchDAO(contextReference.get(), db).getTimelineInfo(tag);
|
||||
|
|
|
@ -2556,7 +2556,7 @@ public class API {
|
|||
* @param query String search
|
||||
* @return Results
|
||||
*/
|
||||
public APIResponse search2(String query, searchType type, String max_id) {
|
||||
public APIResponse search2(String query, searchType type, String offset) {
|
||||
apiResponse = new APIResponse();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
|
@ -2567,8 +2567,8 @@ public class API {
|
|||
} catch (UnsupportedEncodingException e) {
|
||||
params.put("q", query);
|
||||
}
|
||||
if( max_id != null)
|
||||
params.put("max_id", max_id);
|
||||
if( offset != null)
|
||||
params.put("offset", offset);
|
||||
switch (type){
|
||||
case TAGS:
|
||||
params.put("type", "hashtags");
|
||||
|
@ -2580,7 +2580,7 @@ public class API {
|
|||
params.put("type", "statuses");
|
||||
break;
|
||||
}
|
||||
params.put("limite", "40");
|
||||
params.put("limit", "20");
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUr2l("/search"), 60, params, prefKeyOauthTokenT);
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.gson.JsonObject;
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.support.v4.widget.SwipeRefreshLayout;
|
|||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -38,6 +39,7 @@ import es.dmoral.toasty.Toasty;
|
|||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveManyRelationshipsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
|
@ -225,7 +227,14 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
|||
textviewNoAction.setVisibility(View.VISIBLE);
|
||||
else
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
max_id = apiResponse.getMax_id();
|
||||
|
||||
if( type == RetrieveAccountsAsyncTask.Type.SEARCH) {
|
||||
if(max_id == null)
|
||||
max_id = "0";
|
||||
max_id = String.valueOf(Integer.valueOf(max_id) + 20);
|
||||
}else {
|
||||
max_id = apiResponse.getMax_id();
|
||||
}
|
||||
if( swiped ){
|
||||
accountsListAdapter = new AccountsListAdapter(context, type,targetedId, this.accounts);
|
||||
lv_accounts.setAdapter(accountsListAdapter);
|
||||
|
|
|
@ -132,7 +132,6 @@ public class DisplaySearchTagsFragment extends Fragment implements OnRetrieveSea
|
|||
public void onRetrieveSearch(APIResponse apiResponse) {
|
||||
|
||||
searchTagsAdapter = new SearchTagsAdapter(context, tags);
|
||||
this.max_id = apiResponse.getMax_id();
|
||||
loader.setVisibility(View.GONE);
|
||||
if (apiResponse.getError() != null) {
|
||||
if( apiResponse.getError().getError() != null)
|
||||
|
@ -141,6 +140,9 @@ public class DisplaySearchTagsFragment extends Fragment implements OnRetrieveSea
|
|||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if(max_id == null)
|
||||
max_id = "0";
|
||||
max_id = String.valueOf(Integer.valueOf(max_id) + 20);
|
||||
lv_search_tags.setVisibility(View.VISIBLE);
|
||||
List<String> newTags = apiResponse.getResults().getHashtags();
|
||||
tags.addAll(newTags);
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -512,9 +513,14 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
max_id = "1";
|
||||
//max_id needs to work like an offset
|
||||
max_id = String.valueOf(Integer.valueOf(max_id) + 1);
|
||||
}else{
|
||||
}else if( type == RetrieveFeedsAsyncTask.Type.SEARCH) {
|
||||
if(max_id == null)
|
||||
max_id = "0";
|
||||
max_id = String.valueOf(Integer.valueOf(max_id) + 20);
|
||||
} else{
|
||||
max_id = apiResponse.getMax_id();
|
||||
}
|
||||
|
||||
//while max_id is different from null, there are some more toots to load when scrolling
|
||||
flag_loading = (max_id == null );
|
||||
//If it's the first load and the reply doesn't contain any toots, a message is displayed.
|
||||
|
|
Loading…
Reference in New Issue