use of com.keylesspalace.tusky.db.TootEntity in project Tusky by tuskyapp.
the class SavedTootAdapter method removeItem.
@Nullable
public TootEntity removeItem(int position) {
if (position < 0 || position >= list.size()) {
return null;
}
TootEntity toot = list.remove(position);
notifyItemRemoved(position);
return toot;
}
use of com.keylesspalace.tusky.db.TootEntity in project Tusky by tuskyapp.
the class ComposeActivity method saveTheToot.
@SuppressLint("StaticFieldLeak")
private boolean saveTheToot(String s, @Nullable String contentWarning) {
if (TextUtils.isEmpty(s)) {
return false;
}
// Get any existing file's URIs.
ArrayList<String> existingUris = null;
String savedJsonUrls = getIntent().getStringExtra("saved_json_urls");
if (!TextUtils.isEmpty(savedJsonUrls)) {
existingUris = new Gson().fromJson(savedJsonUrls, new TypeToken<ArrayList<String>>() {
}.getType());
}
String mediaUrlsSerialized = null;
if (!ListUtils.isEmpty(mediaQueued)) {
List<String> savedList = saveMedia(existingUris);
if (!ListUtils.isEmpty(savedList)) {
mediaUrlsSerialized = new Gson().toJson(savedList);
if (!ListUtils.isEmpty(existingUris)) {
deleteMedia(setDifference(existingUris, savedList));
}
} else {
return false;
}
} else if (!ListUtils.isEmpty(existingUris)) {
/* If there were URIs in the previous draft, but they've now been removed, those files
* can be deleted. */
deleteMedia(existingUris);
}
final TootEntity toot = new TootEntity(savedTootUid, s, mediaUrlsSerialized, contentWarning, inReplyToId, getIntent().getStringExtra(REPLYING_STATUS_CONTENT_EXTRA), getIntent().getStringExtra(REPLYING_STATUS_AUTHOR_USERNAME_EXTRA), statusVisibility);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
tootDao.insertOrReplace(toot);
return null;
}
}.execute();
return true;
}
Aggregations