Fix crashes with tags

This commit is contained in:
stom79 2018-12-05 09:58:15 +01:00
parent a697fc808b
commit 953cff9ad3
3 changed files with 7 additions and 2 deletions

View File

@ -66,7 +66,7 @@ public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
results = api.search(query);
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<String> cachedTags = new TagsCacheDAO(contextReference.get(), db).getBy(query);
if( results.getHashtags() != null){
if( results != null && results.getHashtags() != null){
//If cache contains matching tags
if( cachedTags != null){
for(String apiTag: results.getHashtags()){
@ -78,6 +78,8 @@ public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
results.setHashtags(cachedTags);
}
}else if( cachedTags != null) {
if( results == null)
results = new Results();
results.setHashtags(cachedTags);
}
}

View File

@ -2880,7 +2880,9 @@ public class API {
status.setIn_reply_to_account_id(resobj.get("in_reply_to_account_id").toString());
status.setSensitive(Boolean.parseBoolean(resobj.get("sensitive").toString()));
status.setSpoiler_text(resobj.get("spoiler_text").toString());
status.setVisibility(resobj.get("visibility").toString());
try {
status.setVisibility(resobj.get("visibility").toString());
}catch (Exception e){status.setVisibility("public");}
status.setLanguage(resobj.get("language").toString());
status.setUrl(resobj.get("url").toString());
//TODO: replace by the value

View File

@ -84,6 +84,7 @@ public class TagsEditAdapter extends RecyclerView.Adapter {
holder.delete_tag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.tag_name.clearFocus();
new TagsCacheDAO(context, db).removeTag(tag[0]);
tags.remove(tag[0]);
tagsEditAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());