Fix crashes

This commit is contained in:
stom79 2018-09-09 09:37:15 +02:00
parent f05a39f328
commit 0ebbb7b648
3 changed files with 9 additions and 4 deletions

View File

@ -2219,7 +2219,8 @@ public class API {
while (i < jsonArray.length() ) {
JSONObject resobj = jsonArray.getJSONObject(i);
Filters filter = parseFilter(resobj);
filters.add(filter);
if( filter != null)
filters.add(filter);
i++;
}
} catch (JSONException e) {
@ -2233,10 +2234,12 @@ public class API {
* @param resobj JSONObject
* @return Filter
*/
private fr.gouv.etalab.mastodon.client.Entities.Filters parseFilter(JSONObject resobj){
fr.gouv.etalab.mastodon.client.Entities.Filters filter = new fr.gouv.etalab.mastodon.client.Entities.Filters();
private Filters parseFilter(JSONObject resobj){
Filters filter = new fr.gouv.etalab.mastodon.client.Entities.Filters();
try {
filter.setId(resobj.get("id").toString());
if( resobj.get("phrase").toString() == null)
return null;
filter.setPhrase(resobj.get("phrase").toString());
filter.setSetExpires_at(Helper.mstStringToDate(context, resobj.get("expires_at").toString()));
filter.setWhole_word(Boolean.parseBoolean(resobj.get("whole_word").toString()));

View File

@ -382,6 +382,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, true);
int HIDDEN_STATUS = 0;
//If account related to status is null, the toot is hidden
if( status.getAccount() == null )
return HIDDEN_STATUS;
String filter;
if( type == RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS)
return isCompactMode?COMPACT_STATUS:DISPLAYED_STATUS;

View File

@ -229,7 +229,6 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
}
if( actionType == ManageFiltersAsyncTask.action.GET_ALL_FILTER) {
if (apiResponse.getFilters() != null && apiResponse.getFilters().size() > 0) {
this.filters.addAll(apiResponse.getFilters());
filterAdapter.notifyDataSetChanged();
textviewNoAction.setVisibility(View.GONE);