bug fix, dependency update

This commit is contained in:
nuclearfog 2023-03-09 10:38:42 +01:00
parent 05fdb84375
commit ad8815e792
No known key found for this signature in database
GPG Key ID: 03488A185C476379
9 changed files with 58 additions and 28 deletions

View File

@ -60,7 +60,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'org.jsoup:jsoup:1.15.3'
implementation 'org.jsoup:jsoup:1.15.4'
//noinspection GradleDependency
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
//noinspection GradleDependency

View File

@ -5,6 +5,7 @@ import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import java.lang.ref.WeakReference;
import java.util.Queue;
@ -108,6 +109,7 @@ public abstract class AsyncExecutor<Parameter, Result> {
* @return result of the background task
*/
@NonNull
@WorkerThread
protected abstract Result doInBackground(@NonNull Parameter param);
/**

View File

@ -47,9 +47,13 @@ public class NotificationAction extends AsyncExecutor<NotificationAction.Notific
case NotificationParam.DISMISS:
connection.dismissNotification(param.id);
db.removeNotification(param.id);
return new NotificationResult(NotificationResult.DISMISS, null, null);
}
} catch (ConnectionException exception) {
if (exception.getErrorCode() == ConnectionException.RESOURCE_NOT_FOUND) {
db.removeNotification(param.id);
}
return new NotificationResult(NotificationResult.ERROR, null, exception);
} catch (Exception exception) {
exception.printStackTrace();

View File

@ -313,7 +313,12 @@ public class AppDatabase {
/**
* select notification from notification table using status ID
*/
private static final String NOTIFICATION_SELECT = NotificationTable.NAME + "." + NotificationTable.ITEM + "=?";
private static final String NOTIFICATION_SELECT = NotificationTable.NAME + "." + NotificationTable.ID + "=?";
/**
* select notification from notification table using status ID
*/
private static final String NOTIFICATION_STATUS_SELECT = NotificationTable.NAME + "." + NotificationTable.ITEM + "=?";
/**
* selection to get status flag register
@ -990,13 +995,28 @@ public class AppDatabase {
SQLiteDatabase db = adapter.getDbWrite();
db.delete(StatusTable.NAME, STATUS_SELECT, args);
db.delete(NotificationTable.NAME, NOTIFICATION_SELECT, args);
db.delete(NotificationTable.NAME, NOTIFICATION_STATUS_SELECT, args);
db.delete(FavoriteTable.NAME, FAVORITE_SELECT_STATUS, args);
db.delete(BookmarkTable.NAME, BOOKMARK_SELECT_STATUS, args);
adapter.commit();
}
}
/**
* remove status from database
*
* @param id status ID
*/
public void removeNotification(long id) {
synchronized (LOCK) {
String[] args = {Long.toString(id)};
SQLiteDatabase db = adapter.getDbWrite();
db.delete(NotificationTable.NAME, NOTIFICATION_SELECT, args);
adapter.commit();
}
}
/**
* remove status from favorites
*
@ -1480,7 +1500,7 @@ public class AppDatabase {
} else {
flags &= ~BOOKMARK_MASK;
}
ContentValues column = new ContentValues(18);
ContentValues column = new ContentValues(19);
column.put(StatusTable.ID, status.getId());
column.put(StatusTable.USER, user.getId());
column.put(StatusTable.TIME, status.getTimestamp());
@ -1491,6 +1511,7 @@ public class AppDatabase {
column.put(StatusTable.REPLYSTATUS, status.getRepliedStatusId());
column.put(StatusTable.REPOST, status.getRepostCount());
column.put(StatusTable.FAVORITE, status.getFavoriteCount());
column.put(StatusTable.REPLY, status.getReplyCount());
column.put(StatusTable.REPLYUSER, status.getRepliedUserId());
column.put(StatusTable.REPLYUSER, status.getRepliedUserId());
column.put(StatusTable.REPLYNAME, status.getReplyName());

View File

@ -225,7 +225,7 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
user = (User) o;
userId = user.getId();
} else {
userId = i.getLongExtra(KEY_PROFILE_ID, 0);
userId = i.getLongExtra(KEY_PROFILE_ID, 0L);
}
adapter.setupProfilePage(userId);
if (settings.likeEnabled()) {
@ -233,6 +233,9 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
} else {
tabIndicator = AppStyles.setTabIconsWithText(tabLayout, settings, R.array.profile_tab_icons);
}
if (user != null) {
setUser(user);
}
tabLayout.addOnTabSelectedListener(this);
following.setOnClickListener(this);
follower.setOnClickListener(this);
@ -253,9 +256,6 @@ public class ProfileActivity extends AppCompatActivity implements ActivityResult
} else if (user instanceof DatabaseUser) {
UserParam param = new UserParam(UserParam.ONLINE, userId);
userLoader.execute(param, this::setUserResult);
setUser(user);
} else {
setUser(user);
}
if (relation == null && userId != settings.getLogin().getId()) {
RelationParam param = new RelationParam(userId, RelationParam.LOAD);

View File

@ -132,6 +132,12 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
*/
public static final String KEY_STATUS_ID = "status_id";
/**
* key for the status author's name. alternative to {@link #KEY_STATUS_DATA}
* value type is String
*/
public static final String KEY_STATUS_NAME = "status_author";
/**
* key for the notification ID value, alternative to {@link #KEY_NOTIFICATION_DATA}
* value type is long
@ -139,10 +145,10 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
public static final String KEY_NOTIFICATION_ID = "notification_id";
/**
* key for the status author's name. alternative to {@link #KEY_STATUS_DATA}
* key for the (notification) status author's name. alternative to {@link #KEY_STATUS_DATA}
* value type is String
*/
public static final String KEY_STATUS_NAME = "status_author";
public static final String KEY_NOTIFICATION_NAME = "notification_status_author";
/**
* key to return updated status information
@ -245,6 +251,7 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
Object notificationObject = getIntent().getSerializableExtra(KEY_NOTIFICATION_DATA);
if (statusObject instanceof Status) {
status = (Status) statusObject;
setStatus(status);
Status embedded = status.getEmbeddedStatus();
if (embedded != null) {
id = embedded.getId();
@ -257,11 +264,12 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
} else if (notificationObject instanceof Notification) {
notification = (Notification) notificationObject;
if (notification.getStatus() != null) {
setStatus(notification.getStatus());
id = notification.getStatus().getId();
replyUsername = notification.getStatus().getAuthor().getScreenname();
} else {
id = 0L;
replyUsername = "";
id = getIntent().getLongExtra(KEY_NOTIFICATION_ID, 0L);
replyUsername = getIntent().getStringExtra(KEY_NOTIFICATION_NAME);
}
} else {
id = getIntent().getLongExtra(KEY_STATUS_ID, 0L);
@ -315,8 +323,12 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
@Override
protected void onStart() {
super.onStart();
if (status != null) {
setStatus(status);
if (notification != null) {
if (notification instanceof DatabaseNotification) {
NotificationParam param = new NotificationParam(NotificationParam.ONLINE, notification.getId());
notificationAsync.execute(param, this::onNotificationResult);
}
} else if (status != null) {
if (status instanceof DatabaseStatus) {
StatusParam param = new StatusParam(StatusParam.ONLINE, status.getId());
statusAsync.execute(param, this::onStatusResult);
@ -324,21 +336,13 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
VoteParam param = new VoteParam(VoteParam.LOAD, status.getPoll(), new int[0]);
voteAsync.execute(param, this::setPollResult);
}
} else if (notification != null) {
if (notification.getStatus() != null) {
setStatus(notification.getStatus());
}
if (notification instanceof DatabaseNotification) {
NotificationParam param = new NotificationParam(NotificationParam.ONLINE, notification.getId());
notificationAsync.execute(param, this::onNotificationResult);
}
} else {
long statusId = getIntent().getLongExtra(KEY_STATUS_ID, 0L);
long notificationId = getIntent().getLongExtra(KEY_NOTIFICATION_ID, 0L);
if (statusId != 0) {
if (statusId != 0L) {
StatusParam param = new StatusParam(StatusParam.DATABASE, statusId);
statusAsync.execute(param, this::onStatusResult);
} else if (notificationId != 0) {
} else if (notificationId != 0L) {
NotificationParam param = new NotificationParam(NotificationParam.ONLINE, notificationId);
notificationAsync.execute(param, this::onNotificationResult);
}
@ -967,7 +971,6 @@ public class StatusActivity extends AppCompatActivity implements OnClickListener
* @param result notification containing status information
*/
public void onNotificationResult(NotificationResult result) {
switch (result.mode) {
case NotificationResult.DATABASE:
if (result.notification != null) {

View File

@ -79,7 +79,7 @@ public class UserlistsActivity extends AppCompatActivity implements ActivityResu
tabLayout.setupWithViewPager(pager);
tabLayout.addOnTabSelectedListener(this);
long ownerId = getIntent().getLongExtra(KEY_USERLIST_OWNER_ID, -1L);
long ownerId = getIntent().getLongExtra(KEY_USERLIST_OWNER_ID, 0L);
isHome = ownerId == settings.getLogin().getId();
adapter.setupListPage(ownerId);

View File

@ -130,7 +130,7 @@ public class UsersActivity extends AppCompatActivity implements OnTabSelectedLis
pager.setAdapter(adapter);
mode = getIntent().getIntExtra(KEY_USERS_MODE, 0);
long id = getIntent().getLongExtra(KEY_USERS_ID, -1L);
long id = getIntent().getLongExtra(KEY_USERS_ID, 0L);
switch (mode) {
case USERS_FRIENDS:

View File

@ -118,7 +118,7 @@ public class UserListFragment extends ListFragment implements ListClickListener,
if (intent != null) {
// check if userlist was removed
if (result.getResultCode() == UserlistActivity.RETURN_LIST_REMOVED) {
long removedListId = intent.getLongExtra(UserlistActivity.RESULT_REMOVED_LIST_ID, 0);
long removedListId = intent.getLongExtra(UserlistActivity.RESULT_REMOVED_LIST_ID, 0L);
adapter.removeItem(removedListId);
}
// check if userlist was updated