bug fix, added error message
This commit is contained in:
parent
9ef8c0a741
commit
181985dddc
|
@ -2,6 +2,8 @@ package org.nuclearfog.twidda.backend.async;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.database.AppDatabase;
|
import org.nuclearfog.twidda.database.AppDatabase;
|
||||||
import org.nuclearfog.twidda.model.Account;
|
import org.nuclearfog.twidda.model.Account;
|
||||||
import org.nuclearfog.twidda.ui.fragments.AccountFragment;
|
import org.nuclearfog.twidda.ui.fragments.AccountFragment;
|
||||||
|
@ -45,6 +47,7 @@ public class AccountLoader extends AsyncTask<Long, Void, List<Account>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Account> doInBackground(Long... param) {
|
protected List<Account> doInBackground(Long... param) {
|
||||||
|
try {
|
||||||
// get all logins
|
// get all logins
|
||||||
if (mode == MODE_LOAD) {
|
if (mode == MODE_LOAD) {
|
||||||
return db.getLogins();
|
return db.getLogins();
|
||||||
|
@ -54,18 +57,29 @@ public class AccountLoader extends AsyncTask<Long, Void, List<Account>> {
|
||||||
db.removeLogin(param[0]);
|
db.removeLogin(param[0]);
|
||||||
deleteId = param[0];
|
deleteId = param[0];
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Account> accounts) {
|
protected void onPostExecute(@Nullable List<Account> accounts) {
|
||||||
AccountFragment fragment = weakRef.get();
|
AccountFragment fragment = weakRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (mode == MODE_LOAD) {
|
if (mode == MODE_LOAD) {
|
||||||
|
if (accounts != null) {
|
||||||
fragment.onSuccess(accounts);
|
fragment.onSuccess(accounts);
|
||||||
|
} else {
|
||||||
|
fragment.onError();
|
||||||
|
}
|
||||||
} else if (mode == MODE_DELETE) {
|
} else if (mode == MODE_DELETE) {
|
||||||
|
if (deleteId > 0) {
|
||||||
fragment.onDelete(deleteId);
|
fragment.onDelete(deleteId);
|
||||||
|
} else {
|
||||||
|
fragment.onError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public class FilterLoader extends AsyncTask<String, Void, Void> {
|
public class FilterLoader extends AsyncTask<String, Void, Boolean> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* refresh exclude list
|
* refresh exclude list
|
||||||
|
@ -55,34 +55,36 @@ public class FilterLoader extends AsyncTask<String, Void, Void> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(String... names) {
|
protected Boolean doInBackground(String... names) {
|
||||||
try {
|
try {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case REFRESH:
|
case REFRESH:
|
||||||
List<Long> ids = connection.getIdBlocklist();
|
List<Long> ids = connection.getIdBlocklist();
|
||||||
db.setFilterlistUserIds(ids);
|
db.setFilterlistUserIds(ids);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case MUTE_USER:
|
case MUTE_USER:
|
||||||
connection.muteUser(names[0]);
|
connection.muteUser(names[0]);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case BLOCK_USER:
|
case BLOCK_USER:
|
||||||
connection.blockUser(names[0]);
|
connection.blockUser(names[0]);
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Boolean success) {
|
||||||
UsersActivity activity = weakRef.get();
|
UsersActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (exception == null) {
|
if (success) {
|
||||||
activity.onSuccess(mode);
|
activity.onSuccess(mode);
|
||||||
} else {
|
} else {
|
||||||
activity.onError(exception);
|
activity.onError(exception);
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.nuclearfog.twidda.ui.activities.ImageViewer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
@ -72,15 +71,15 @@ public class ImageLoader extends AsyncTask<Uri, Void, Uri> {
|
||||||
return Uri.fromFile(imageFile);
|
return Uri.fromFile(imageFile);
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
} catch (IOException exception) {
|
} catch (Exception e) {
|
||||||
exception.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Uri localUri) {
|
protected void onPostExecute(@Nullable Uri localUri) {
|
||||||
ImageViewer activity = weakRef.get();
|
ImageViewer activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (localUri != null) {
|
if (localUri != null) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.os.AsyncTask;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.ui.activities.MediaActivity;
|
import org.nuclearfog.twidda.ui.activities.MediaActivity;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
@ -43,11 +42,11 @@ public class ImageSaver extends AsyncTask<Void, Void, Boolean> {
|
||||||
}
|
}
|
||||||
mediaStream.close();
|
mediaStream.close();
|
||||||
fileStream.close();
|
fileStream.close();
|
||||||
} catch (IOException err) {
|
|
||||||
err.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -156,19 +156,21 @@ public class LinkLoader extends AsyncTask<Uri, Void, LinkLoader.DataHolder> {
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(DataHolder result) {
|
protected void onPostExecute(@Nullable DataHolder result) {
|
||||||
MainActivity activity = weakRef.get();
|
MainActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (exception != null) {
|
if (result != null) {
|
||||||
activity.onError(exception);
|
|
||||||
} else {
|
|
||||||
activity.onSuccess(result);
|
activity.onSuccess(result);
|
||||||
|
} else {
|
||||||
|
activity.onError(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.nuclearfog.twidda.backend.async;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.backend.api.Connection;
|
import org.nuclearfog.twidda.backend.api.Connection;
|
||||||
import org.nuclearfog.twidda.backend.api.ConnectionException;
|
import org.nuclearfog.twidda.backend.api.ConnectionException;
|
||||||
import org.nuclearfog.twidda.backend.api.ConnectionManager;
|
import org.nuclearfog.twidda.backend.api.ConnectionManager;
|
||||||
|
@ -77,13 +79,15 @@ public class ListAction extends AsyncTask<Void, Void, UserList> {
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(UserList userList) {
|
protected void onPostExecute(@Nullable UserList userList) {
|
||||||
UserlistActivity callback = this.weakRef.get();
|
UserlistActivity callback = this.weakRef.get();
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
if (userList != null) {
|
if (userList != null) {
|
||||||
|
|
|
@ -71,13 +71,15 @@ public class ListLoader extends AsyncTask<Long, Void, UserLists> {
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(UserLists result) {
|
protected void onPostExecute(@Nullable UserLists result) {
|
||||||
UserListFragment fragment = weakRef.get();
|
UserListFragment fragment = weakRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.lang.ref.WeakReference;
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public class ListManager extends AsyncTask<Void, Void, Void> {
|
public class ListManager extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add user to list
|
* add user to list
|
||||||
|
@ -57,29 +57,31 @@ public class ListManager extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... v) {
|
protected Boolean doInBackground(Void... v) {
|
||||||
try {
|
try {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ADD_USER:
|
case ADD_USER:
|
||||||
connection.addUserToList(listId, username);
|
connection.addUserToList(listId, username);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case DEL_USER:
|
case DEL_USER:
|
||||||
connection.removeUserFromList(listId, username);
|
connection.removeUserFromList(listId, username);
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Boolean success) {
|
||||||
UserlistActivity callback = weakRef.get();
|
UserlistActivity callback = weakRef.get();
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
if (exception == null) {
|
if (success) {
|
||||||
callback.onSuccess(action, username);
|
callback.onSuccess(action, username);
|
||||||
} else {
|
} else {
|
||||||
callback.onFailure(exception);
|
callback.onFailure(exception);
|
||||||
|
|
|
@ -48,13 +48,15 @@ public class ListUpdater extends AsyncTask<Void, Void, UserList> {
|
||||||
return connection.createUserlist(update);
|
return connection.createUserlist(update);
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(UserList result) {
|
protected void onPostExecute(@Nullable UserList result) {
|
||||||
UserlistEditor activity = weakRef.get();
|
UserlistEditor activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
|
@ -41,13 +41,15 @@ public class LocationLoader extends AsyncTask<Void, Void, List<Location>> {
|
||||||
return connection.getLocations();
|
return connection.getLocations();
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Location> locations) {
|
protected void onPostExecute(@Nullable List<Location> locations) {
|
||||||
SettingsActivity activity = weakRef.get();
|
SettingsActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (locations != null) {
|
if (locations != null) {
|
||||||
|
|
|
@ -94,13 +94,15 @@ public class LoginAction extends AsyncTask<String, Void, String> {
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String result) {
|
protected void onPostExecute(@Nullable String result) {
|
||||||
LoginActivity activity = weakRef.get();
|
LoginActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
|
@ -93,6 +93,8 @@ public class MessageLoader extends AsyncTask<Void, Void, Messages> {
|
||||||
if (exception.getErrorCode() == ConnectionException.RESOURCE_NOT_FOUND) {
|
if (exception.getErrorCode() == ConnectionException.RESOURCE_NOT_FOUND) {
|
||||||
db.removeMessage(messageId);
|
db.removeMessage(messageId);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -102,16 +104,23 @@ public class MessageLoader extends AsyncTask<Void, Void, Messages> {
|
||||||
protected void onPostExecute(@Nullable Messages messages) {
|
protected void onPostExecute(@Nullable Messages messages) {
|
||||||
MessageFragment fragment = weakRef.get();
|
MessageFragment fragment = weakRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (exception != null) {
|
switch (action) {
|
||||||
fragment.onError(exception, messageId);
|
case DB:
|
||||||
} else {
|
case LOAD:
|
||||||
if (action == DB || action == LOAD) {
|
|
||||||
if (messages != null) {
|
if (messages != null) {
|
||||||
fragment.setData(messages);
|
fragment.setData(messages);
|
||||||
|
} else {
|
||||||
|
fragment.onError(exception, messageId);
|
||||||
}
|
}
|
||||||
} else if (action == DEL) {
|
break;
|
||||||
|
|
||||||
|
case DEL:
|
||||||
|
if (exception == null) {
|
||||||
fragment.removeItem(messageId);
|
fragment.removeItem(messageId);
|
||||||
}
|
} else {
|
||||||
|
fragment.onError(exception, messageId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,8 @@ public class MessageUpdater extends AsyncTask<Void, Void, Boolean> {
|
||||||
return true;
|
return true;
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
// close all streams
|
// close all streams
|
||||||
message.close();
|
message.close();
|
||||||
|
|
|
@ -62,18 +62,21 @@ public class NotificationLoader extends AsyncTask<Long, Void, List<Notification>
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Notification> notifications) {
|
protected void onPostExecute(@Nullable List<Notification> notifications) {
|
||||||
NotificationFragment fragment = callback.get();
|
NotificationFragment fragment = callback.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (notifications != null) {
|
if (notifications != null) {
|
||||||
fragment.onSuccess(notifications, pos);
|
fragment.onSuccess(notifications, pos);
|
||||||
} else {
|
}
|
||||||
|
if (exception != null) {
|
||||||
fragment.onError(exception);
|
fragment.onError(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.lang.ref.WeakReference;
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
* @see StatusActivity
|
* @see StatusActivity
|
||||||
*/
|
*/
|
||||||
public class StatusAction extends AsyncTask<Long, Status, Void> {
|
public class StatusAction extends AsyncTask<Long, Status, Boolean> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load status
|
* Load status
|
||||||
|
@ -92,7 +92,7 @@ public class StatusAction extends AsyncTask<Long, Status, Void> {
|
||||||
* @param ids first value is the status ID. The second value is the repost status ID. Required for delete operations
|
* @param ids first value is the status ID. The second value is the repost status ID. Required for delete operations
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Long... ids) {
|
protected Boolean doInBackground(Long... ids) {
|
||||||
org.nuclearfog.twidda.model.Status status;
|
org.nuclearfog.twidda.model.Status status;
|
||||||
try {
|
try {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
@ -110,21 +110,21 @@ public class StatusAction extends AsyncTask<Long, Status, Void> {
|
||||||
// update status if there is a database entry
|
// update status if there is a database entry
|
||||||
db.updateStatus(status);
|
db.updateStatus(status);
|
||||||
}
|
}
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case DELETE:
|
case DELETE:
|
||||||
connection.deleteStatus(ids[0]);
|
connection.deleteStatus(ids[0]);
|
||||||
db.removeStatus(ids[0]);
|
db.removeStatus(ids[0]);
|
||||||
// removing repost reference to this status
|
// removing repost reference to this status
|
||||||
db.removeStatus(ids[1]);
|
db.removeStatus(ids[1]);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case REPOST:
|
case REPOST:
|
||||||
status = connection.repostStatus(ids[0]);
|
status = connection.repostStatus(ids[0]);
|
||||||
if (status.getEmbeddedStatus() != null)
|
if (status.getEmbeddedStatus() != null)
|
||||||
publishProgress(status.getEmbeddedStatus());
|
publishProgress(status.getEmbeddedStatus());
|
||||||
db.updateStatus(status);
|
db.updateStatus(status);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case REMOVE_REPOST:
|
case REMOVE_REPOST:
|
||||||
status = connection.removeRepost(ids[0]);
|
status = connection.removeRepost(ids[0]);
|
||||||
|
@ -133,29 +133,29 @@ public class StatusAction extends AsyncTask<Long, Status, Void> {
|
||||||
// removing repost reference to this status
|
// removing repost reference to this status
|
||||||
if (ids.length == 2)
|
if (ids.length == 2)
|
||||||
db.removeStatus(ids[1]);
|
db.removeStatus(ids[1]);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case FAVORITE:
|
case FAVORITE:
|
||||||
status = connection.favoriteStatus(ids[0]);
|
status = connection.favoriteStatus(ids[0]);
|
||||||
publishProgress(status);
|
publishProgress(status);
|
||||||
db.saveToFavorites(status);
|
db.saveToFavorites(status);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case UNFAVORITE:
|
case UNFAVORITE:
|
||||||
status = connection.unfavoriteStatus(ids[0]);
|
status = connection.unfavoriteStatus(ids[0]);
|
||||||
publishProgress(status);
|
publishProgress(status);
|
||||||
db.removeFavorite(status);
|
db.removeFavorite(status);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case HIDE:
|
case HIDE:
|
||||||
connection.muteConversation(ids[0]);
|
connection.muteConversation(ids[0]);
|
||||||
db.hideStatus(ids[0], true);
|
db.hideStatus(ids[0], true);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case UNHIDE:
|
case UNHIDE:
|
||||||
connection.unmuteConversation(ids[0]);
|
connection.unmuteConversation(ids[0]);
|
||||||
db.hideStatus(ids[0], false);
|
db.hideStatus(ids[0], false);
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
@ -167,8 +167,10 @@ public class StatusAction extends AsyncTask<Long, Status, Void> {
|
||||||
db.removeStatus(ids[1]);
|
db.removeStatus(ids[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,10 +184,10 @@ public class StatusAction extends AsyncTask<Long, Status, Void> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Boolean success) {
|
||||||
StatusActivity activity = weakRef.get();
|
StatusActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (exception == null) {
|
if (success) {
|
||||||
activity.OnSuccess(action);
|
activity.OnSuccess(action);
|
||||||
} else {
|
} else {
|
||||||
activity.onError(exception);
|
activity.onError(exception);
|
||||||
|
|
|
@ -202,12 +202,13 @@ public class StatusLoader extends AsyncTask<Long, Void, List<Status>> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<org.nuclearfog.twidda.model.Status> statuses) {
|
protected void onPostExecute(@Nullable List<org.nuclearfog.twidda.model.Status> statuses) {
|
||||||
StatusFragment fragment = weakRef.get();
|
StatusFragment fragment = weakRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (statuses != null) {
|
if (statuses != null) {
|
||||||
fragment.setData(statuses, pos);
|
fragment.setData(statuses, pos);
|
||||||
} else {
|
}
|
||||||
|
if (exception != null) {
|
||||||
fragment.onError(exception);
|
fragment.onError(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.lang.ref.WeakReference;
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
* @see StatusEditor
|
* @see StatusEditor
|
||||||
*/
|
*/
|
||||||
public class StatusUpdater extends AsyncTask<StatusUpdate, Void, Void> {
|
public class StatusUpdater extends AsyncTask<StatusUpdate, Void, Boolean> {
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
private ConnectionException exception;
|
private ConnectionException exception;
|
||||||
|
@ -36,7 +36,7 @@ public class StatusUpdater extends AsyncTask<StatusUpdate, Void, Void> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(StatusUpdate... statusUpdates) {
|
protected Boolean doInBackground(StatusUpdate... statusUpdates) {
|
||||||
StatusUpdate statusUpdate = statusUpdates[0];
|
StatusUpdate statusUpdate = statusUpdates[0];
|
||||||
try {
|
try {
|
||||||
// upload media first
|
// upload media first
|
||||||
|
@ -50,21 +50,24 @@ public class StatusUpdater extends AsyncTask<StatusUpdate, Void, Void> {
|
||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
connection.uploadStatus(statusUpdate, mediaIds);
|
connection.uploadStatus(statusUpdate, mediaIds);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
// close inputstreams
|
// close inputstreams
|
||||||
statusUpdate.close();
|
statusUpdate.close();
|
||||||
}
|
}
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Boolean success) {
|
||||||
StatusEditor activity = weakRef.get();
|
StatusEditor activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (exception == null) {
|
if (success) {
|
||||||
activity.onSuccess();
|
activity.onSuccess();
|
||||||
} else {
|
} else {
|
||||||
activity.onError(exception);
|
activity.onError(exception);
|
||||||
|
|
|
@ -59,18 +59,21 @@ public class TrendLoader extends AsyncTask<Void, Void, List<Trend>> {
|
||||||
return trends;
|
return trends;
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Trend> trends) {
|
protected void onPostExecute(@Nullable List<Trend> trends) {
|
||||||
TrendFragment fragment = weakRef.get();
|
TrendFragment fragment = weakRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (trends != null) {
|
if (trends != null) {
|
||||||
fragment.setData(trends);
|
fragment.setData(trends);
|
||||||
} else {
|
}
|
||||||
|
if (exception != null) {
|
||||||
fragment.onError(exception);
|
fragment.onError(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.nuclearfog.twidda.backend.async;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.backend.api.Connection;
|
import org.nuclearfog.twidda.backend.api.Connection;
|
||||||
import org.nuclearfog.twidda.backend.api.ConnectionException;
|
import org.nuclearfog.twidda.backend.api.ConnectionException;
|
||||||
import org.nuclearfog.twidda.backend.api.ConnectionManager;
|
import org.nuclearfog.twidda.backend.api.ConnectionManager;
|
||||||
|
@ -91,10 +93,8 @@ public class UserAction extends AsyncTask<Void, User, Relation> {
|
||||||
User user;
|
User user;
|
||||||
if (userId > 0) {
|
if (userId > 0) {
|
||||||
user = db.getUser(userId);
|
user = db.getUser(userId);
|
||||||
if (user != null) {
|
|
||||||
publishProgress(user);
|
publishProgress(user);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case PROFILE_lOAD:
|
case PROFILE_lOAD:
|
||||||
// load user information from twitter
|
// load user information from twitter
|
||||||
|
@ -151,6 +151,8 @@ public class UserAction extends AsyncTask<Void, User, Relation> {
|
||||||
return connection.getUserRelationship(userId);
|
return connection.getUserRelationship(userId);
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.error = exception;
|
this.error = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -159,14 +161,14 @@ public class UserAction extends AsyncTask<Void, User, Relation> {
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(User[] users) {
|
protected void onProgressUpdate(User[] users) {
|
||||||
ProfileActivity activity = weakRef.get();
|
ProfileActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null && users[0] != null) {
|
||||||
activity.setUser(users[0]);
|
activity.setUser(users[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Relation relation) {
|
protected void onPostExecute(@Nullable Relation relation) {
|
||||||
ProfileActivity activity = weakRef.get();
|
ProfileActivity activity = weakRef.get();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (relation != null) {
|
if (relation != null) {
|
||||||
|
|
|
@ -143,13 +143,15 @@ public class UserLoader extends AsyncTask<Long, Void, Users> {
|
||||||
}
|
}
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Users users) {
|
protected void onPostExecute(@Nullable Users users) {
|
||||||
UserFragment fragment = weakRef.get();
|
UserFragment fragment = weakRef.get();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (users != null) {
|
if (users != null) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class UserUpdater extends AsyncTask<Void, Void, User> {
|
||||||
private ConnectionException exception;
|
private ConnectionException exception;
|
||||||
private ProfileUpdate profile;
|
private ProfileUpdate profile;
|
||||||
|
|
||||||
|
|
||||||
public UserUpdater(ProfileEditor activity, ProfileUpdate profile) {
|
public UserUpdater(ProfileEditor activity, ProfileUpdate profile) {
|
||||||
super();
|
super();
|
||||||
db = new AppDatabase(activity);
|
db = new AppDatabase(activity);
|
||||||
|
@ -48,6 +49,8 @@ public class UserUpdater extends AsyncTask<Void, Void, User> {
|
||||||
return user;
|
return user;
|
||||||
} catch (ConnectionException exception) {
|
} catch (ConnectionException exception) {
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
// close image streams
|
// close image streams
|
||||||
profile.close();
|
profile.close();
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class ImageViewer extends MediaActivity {
|
||||||
*
|
*
|
||||||
* @param uri Uri of the cached image file
|
* @param uri Uri of the cached image file
|
||||||
*/
|
*/
|
||||||
public void onSuccess(Uri uri) {
|
public void onSuccess(@NonNull Uri uri) {
|
||||||
cacheUri = uri;
|
cacheUri = uri;
|
||||||
zoomImage.reset();
|
zoomImage.reset();
|
||||||
zoomImage.setImageURI(uri);
|
zoomImage.setImageURI(uri);
|
||||||
|
@ -144,7 +144,7 @@ public class ImageViewer extends MediaActivity {
|
||||||
/**
|
/**
|
||||||
* Called from {@link ImageLoader} when an error occurs
|
* Called from {@link ImageLoader} when an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(ConnectionException err) {
|
public void onError(@Nullable ConnectionException err) {
|
||||||
ErrorHandler.handleFailure(getApplicationContext(), err);
|
ErrorHandler.handleFailure(getApplicationContext(), err);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener,
|
||||||
/**
|
/**
|
||||||
* Called when the app is registered successfully
|
* Called when the app is registered successfully
|
||||||
*/
|
*/
|
||||||
public void onSuccess(int mode, String result) {
|
public void onSuccess(int mode, @NonNull String result) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case LoginAction.MODE_LOGIN:
|
case LoginAction.MODE_LOGIN:
|
||||||
setResult(RETURN_LOGIN_SUCCESSFUL);
|
setResult(RETURN_LOGIN_SUCCESSFUL);
|
||||||
|
|
|
@ -283,9 +283,8 @@ public class MainActivity extends AppCompatActivity implements OnTabSelectedList
|
||||||
*
|
*
|
||||||
* @param holder holder with activity information and extras
|
* @param holder holder with activity information and extras
|
||||||
*/
|
*/
|
||||||
public void onSuccess(@Nullable LinkLoader.DataHolder holder) {
|
public void onSuccess(@NonNull LinkLoader.DataHolder holder) {
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
if (holder != null) {
|
|
||||||
if (holder.activity == MainActivity.class) {
|
if (holder.activity == MainActivity.class) {
|
||||||
int page = holder.data.getInt(KEY_TAB_PAGE, 0);
|
int page = holder.data.getInt(KEY_TAB_PAGE, 0);
|
||||||
pager.setCurrentItem(page);
|
pager.setCurrentItem(page);
|
||||||
|
@ -294,16 +293,17 @@ public class MainActivity extends AppCompatActivity implements OnTabSelectedList
|
||||||
intent.putExtras(holder.data);
|
intent.putExtras(holder.data);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Toast.makeText(this, R.string.error_open_link, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called from {@link LinkLoader} when an error occurs
|
* called from {@link LinkLoader} when an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(ConnectionException error) {
|
public void onError(@Nullable ConnectionException error) {
|
||||||
|
if (error != null) {
|
||||||
ErrorHandler.handleFailure(this, error);
|
ErrorHandler.handleFailure(this, error);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, R.string.error_open_link, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -689,7 +689,7 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||||
*
|
*
|
||||||
* @param relation relation to an user
|
* @param relation relation to an user
|
||||||
*/
|
*/
|
||||||
public void onAction(Relation relation) {
|
public void onAction(@NonNull Relation relation) {
|
||||||
if (this.relation != null) {
|
if (this.relation != null) {
|
||||||
// check if block status changed
|
// check if block status changed
|
||||||
if (relation.isBlocked() != this.relation.isBlocked()) {
|
if (relation.isBlocked() != this.relation.isBlocked()) {
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, OnP
|
||||||
/**
|
/**
|
||||||
* called after user profile was updated successfully
|
* called after user profile was updated successfully
|
||||||
*/
|
*/
|
||||||
public void onSuccess(User user) {
|
public void onSuccess(@NonNull User user) {
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
data.putExtra(KEY_UPDATED_PROFILE, user);
|
data.putExtra(KEY_UPDATED_PROFILE, user);
|
||||||
Toast.makeText(this, R.string.info_profile_updated, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.info_profile_updated, Toast.LENGTH_SHORT).show();
|
||||||
|
@ -286,7 +286,7 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, OnP
|
||||||
*
|
*
|
||||||
* @param err Engine Exception
|
* @param err Engine Exception
|
||||||
*/
|
*/
|
||||||
public void onError(ConnectionException err) {
|
public void onError(@Nullable ConnectionException err) {
|
||||||
String message = ErrorHandler.getErrorMessage(this, err);
|
String message = ErrorHandler.getErrorMessage(this, err);
|
||||||
confirmDialog.show(ConfirmDialog.PROFILE_EDITOR_ERROR, message);
|
confirmDialog.show(ConfirmDialog.PROFILE_EDITOR_ERROR, message);
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
|
|
|
@ -572,7 +572,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||||
*
|
*
|
||||||
* @param data location data
|
* @param data location data
|
||||||
*/
|
*/
|
||||||
public void setLocationData(List<Location> data) {
|
public void setLocationData(@NonNull List<Location> data) {
|
||||||
locationAdapter.replaceItems(data);
|
locationAdapter.replaceItems(data);
|
||||||
int position = locationAdapter.indexOf(settings.getTrendLocation());
|
int position = locationAdapter.indexOf(settings.getTrendLocation());
|
||||||
if (position > 0)
|
if (position > 0)
|
||||||
|
@ -585,7 +585,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
||||||
*
|
*
|
||||||
* @param err exception from twitter
|
* @param err exception from twitter
|
||||||
*/
|
*/
|
||||||
public void onError(ConnectionException err) {
|
public void onError(@Nullable ConnectionException err) {
|
||||||
ErrorHandler.handleFailure(this, err);
|
ErrorHandler.handleFailure(this, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -651,7 +651,7 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
|
||||||
*
|
*
|
||||||
* @param status Tweet information
|
* @param status Tweet information
|
||||||
*/
|
*/
|
||||||
public void setStatus(Status status) {
|
public void setStatus(@NonNull Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
if (status.getEmbeddedStatus() != null) {
|
if (status.getEmbeddedStatus() != null) {
|
||||||
repostName.setVisibility(VISIBLE);
|
repostName.setVisibility(VISIBLE);
|
||||||
|
|
|
@ -395,7 +395,7 @@ public class UserlistActivity extends AppCompatActivity implements OnTabSelected
|
||||||
*
|
*
|
||||||
* @param userList userlist update
|
* @param userList userlist update
|
||||||
*/
|
*/
|
||||||
public void onSuccess(UserList userList, int action) {
|
public void onSuccess(@NonNull UserList userList, int action) {
|
||||||
this.userList = userList;
|
this.userList = userList;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ListAction.LOAD:
|
case ListAction.LOAD:
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
@ -164,17 +165,11 @@ public class UserlistEditor extends AppCompatActivity implements OnClickListener
|
||||||
/**
|
/**
|
||||||
* called when a list was updated successfully
|
* called when a list was updated successfully
|
||||||
*/
|
*/
|
||||||
public void onSuccess(UserList result) {
|
public void onSuccess(@NonNull UserList result) {
|
||||||
if (userList != null) {
|
Toast.makeText(getApplicationContext(), R.string.info_list_updated, Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(this, R.string.info_list_updated, Toast.LENGTH_SHORT).show();
|
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
data.putExtra(KEY_UPDATED_USERLIST, result);
|
data.putExtra(KEY_UPDATED_USERLIST, result);
|
||||||
setResult(RETURN_LIST_CHANGED, data);
|
setResult(RETURN_LIST_CHANGED, data);
|
||||||
} else {
|
|
||||||
// it's a new list, if no list is defined
|
|
||||||
Toast.makeText(this, R.string.info_list_created, Toast.LENGTH_SHORT).show();
|
|
||||||
setResult(RETURN_LIST_CREATED);
|
|
||||||
}
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.appcompat.widget.SearchView.OnQueryTextListener;
|
import androidx.appcompat.widget.SearchView.OnQueryTextListener;
|
||||||
|
@ -313,7 +314,7 @@ public class UsersActivity extends AppCompatActivity implements OnTabSelectedLis
|
||||||
/**
|
/**
|
||||||
* called from {@link FilterLoader} if an error occurs
|
* called from {@link FilterLoader} if an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(ConnectionException err) {
|
public void onError(@Nullable ConnectionException err) {
|
||||||
ErrorHandler.handleFailure(this, err);
|
ErrorHandler.handleFailure(this, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -118,7 +118,7 @@ public class AccountFragment extends ListFragment implements OnAccountClickListe
|
||||||
*
|
*
|
||||||
* @param result login information
|
* @param result login information
|
||||||
*/
|
*/
|
||||||
public void onSuccess(List<Account> result) {
|
public void onSuccess(@NonNull List<Account> result) {
|
||||||
adapter.replaceItems(result);
|
adapter.replaceItems(result);
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
|
@ -131,4 +131,11 @@ public class AccountFragment extends ListFragment implements OnAccountClickListe
|
||||||
public void onDelete(long id) {
|
public void onDelete(long id) {
|
||||||
adapter.removeItem(id);
|
adapter.removeItem(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called from {@link AccountLoader} when an error occurs
|
||||||
|
*/
|
||||||
|
public void onError() {
|
||||||
|
Toast.makeText(requireContext(), R.string.error_acc_loading, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -192,7 +192,7 @@ public class MessageFragment extends ListFragment implements OnMessageClickListe
|
||||||
*
|
*
|
||||||
* @param data list of direct messages
|
* @param data list of direct messages
|
||||||
*/
|
*/
|
||||||
public void setData(Messages data) {
|
public void setData(@NonNull Messages data) {
|
||||||
adapter.addItems(data);
|
adapter.addItems(data);
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
|
@ -212,9 +212,9 @@ public class MessageFragment extends ListFragment implements OnMessageClickListe
|
||||||
*
|
*
|
||||||
* @param messageId ID of the message assosiated with the error
|
* @param messageId ID of the message assosiated with the error
|
||||||
*/
|
*/
|
||||||
public void onError(@NonNull ConnectionException error, long messageId) {
|
public void onError(@Nullable ConnectionException error, long messageId) {
|
||||||
ErrorHandler.handleFailure(requireContext(), error);
|
ErrorHandler.handleFailure(requireContext(), error);
|
||||||
if (error.getErrorCode() == ConnectionException.RESOURCE_NOT_FOUND) {
|
if (error != null && error.getErrorCode() == ConnectionException.RESOURCE_NOT_FOUND) {
|
||||||
adapter.removeItem(messageId);
|
adapter.removeItem(messageId);
|
||||||
}
|
}
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class NotificationFragment extends ListFragment implements OnNotification
|
||||||
* @param notifications new items
|
* @param notifications new items
|
||||||
* @param position index where to insert the new items
|
* @param position index where to insert the new items
|
||||||
*/
|
*/
|
||||||
public void onSuccess(List<Notification> notifications, int position) {
|
public void onSuccess(@NonNull List<Notification> notifications, int position) {
|
||||||
adapter.addItems(notifications, position);
|
adapter.addItems(notifications, position);
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class NotificationFragment extends ListFragment implements OnNotification
|
||||||
/**
|
/**
|
||||||
* called from {@link NotificationLoader} if an error occurs
|
* called from {@link NotificationLoader} if an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(@Nullable ConnectionException exception) {
|
public void onError(ConnectionException exception) {
|
||||||
ErrorHandler.handleFailure(requireContext(), exception);
|
ErrorHandler.handleFailure(requireContext(), exception);
|
||||||
adapter.disableLoading();
|
adapter.disableLoading();
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class StatusFragment extends ListFragment implements StatusSelectListener
|
||||||
* @param statuses List of statuses
|
* @param statuses List of statuses
|
||||||
* @param pos position where statuses should be added
|
* @param pos position where statuses should be added
|
||||||
*/
|
*/
|
||||||
public void setData(List<Status> statuses, int pos) {
|
public void setData(@NonNull List<Status> statuses, int pos) {
|
||||||
if (pos == CLEAR_LIST) {
|
if (pos == CLEAR_LIST) {
|
||||||
adapter.replaceItems(statuses);
|
adapter.replaceItems(statuses);
|
||||||
} else {
|
} else {
|
||||||
|
@ -219,7 +219,7 @@ public class StatusFragment extends ListFragment implements StatusSelectListener
|
||||||
/**
|
/**
|
||||||
* called from {@link StatusLoader} if an error occurs
|
* called from {@link StatusLoader} if an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(@Nullable ConnectionException error) {
|
public void onError(ConnectionException error) {
|
||||||
ErrorHandler.handleFailure(requireContext(), error);
|
ErrorHandler.handleFailure(requireContext(), error);
|
||||||
adapter.disableLoading();
|
adapter.disableLoading();
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
|
|
|
@ -84,16 +84,6 @@ public class TrendFragment extends ListFragment implements TrendClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set trend data to list
|
|
||||||
*
|
|
||||||
* @param data Trend data
|
|
||||||
*/
|
|
||||||
public void setData(List<Trend> data) {
|
|
||||||
adapter.replaceItems(data);
|
|
||||||
setRefresh(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if list is empty
|
* check if list is empty
|
||||||
*
|
*
|
||||||
|
@ -103,10 +93,20 @@ public class TrendFragment extends ListFragment implements TrendClickListener {
|
||||||
return adapter.isEmpty();
|
return adapter.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set trend data to list
|
||||||
|
*
|
||||||
|
* @param data Trend data
|
||||||
|
*/
|
||||||
|
public void setData(@NonNull List<Trend> data) {
|
||||||
|
adapter.replaceItems(data);
|
||||||
|
setRefresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called from {@link TrendLoader} if an error occurs
|
* called from {@link TrendLoader} if an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(@Nullable ConnectionException error) {
|
public void onError(ConnectionException error) {
|
||||||
ErrorHandler.handleFailure(requireContext(), error);
|
ErrorHandler.handleFailure(requireContext(), error);
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class UserFragment extends ListFragment implements UserClickListener {
|
||||||
*
|
*
|
||||||
* @param data list of users
|
* @param data list of users
|
||||||
*/
|
*/
|
||||||
public void setData(Users data) {
|
public void setData(@NonNull Users data) {
|
||||||
adapter.addItems(data);
|
adapter.addItems(data);
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public class UserFragment extends ListFragment implements UserClickListener {
|
||||||
/**
|
/**
|
||||||
* called when an error occurs
|
* called when an error occurs
|
||||||
*/
|
*/
|
||||||
public void onError(ConnectionException exception) {
|
public void onError(@Nullable ConnectionException exception) {
|
||||||
ErrorHandler.handleFailure(requireContext(), exception);
|
ErrorHandler.handleFailure(requireContext(), exception);
|
||||||
adapter.disableLoading();
|
adapter.disableLoading();
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class UserListFragment extends ListFragment implements ListClickListener
|
||||||
/**
|
/**
|
||||||
* set data to list
|
* set data to list
|
||||||
*/
|
*/
|
||||||
public void setData(UserLists data) {
|
public void setData(@NonNull UserLists data) {
|
||||||
adapter.addItems(data);
|
adapter.addItems(data);
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
<string name="error_cant_reply_to_tweet">You can\'t reply to this status!</string>
|
<string name="error_cant_reply_to_tweet">You can\'t reply to this status!</string>
|
||||||
<string name="error_corrupt_api_key">Error, corrupt API key!</string>
|
<string name="error_corrupt_api_key">Error, corrupt API key!</string>
|
||||||
<string name="error_acc_update">Account update failed! Please check your input!</string>
|
<string name="error_acc_update">Account update failed! Please check your input!</string>
|
||||||
|
<string name="error_acc_loading">Error while loading login information!</string>
|
||||||
<string name="error_api_access_denied">Error, API access denied! Please check your API Keys.</string>
|
<string name="error_api_access_denied">Error, API access denied! Please check your API Keys.</string>
|
||||||
<string name="error_api_access_limited">Error, API access limited by Twitter!</string>
|
<string name="error_api_access_limited">Error, API access limited by Twitter!</string>
|
||||||
<string name="error_api_key_expired">Error, API Keys expired! Please update app!</string>
|
<string name="error_api_key_expired">Error, API Keys expired! Please update app!</string>
|
||||||
|
|
Loading…
Reference in New Issue