Skip to content

Commit

Permalink
bug fix, layout fix, added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Mar 16, 2024
1 parent 1534af4 commit 6ef4982
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ public ScheduledStatuses getScheduledStatuses(long minId, long maxId) throws Con
try {
List<String> params = new ArrayList<>();
if (minId != 0L)
params.add("since_id=" + minId);
params.add("min_id=" + minId);
if (maxId != 0L)
params.add("max_id=" + maxId);
params.add("limit=" + settings.getListSize());
Expand Down Expand Up @@ -1399,7 +1399,7 @@ else if (pushUpdate.getPolicy() == WebPush.POLICY_NONE)
public Notifications getNotifications(long minId, long maxId) throws ConnectionException {
List<String> params = new ArrayList<>();
if (minId != 0L)
params.add("since_id=" + minId);
params.add("min_id=" + minId);
if (maxId != 0L)
params.add("max_id=" + maxId);
params.add("limit=" + settings.getListSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public AccountAction(Context context) {

@Override
protected Result doInBackground(@NonNull Param param) {
switch (param.mode) {
switch (param.action) {
case Param.SELECT:
database.resetDatabase();
WebPush webPush = database.getWebPush(param.account);
Expand Down Expand Up @@ -60,10 +60,14 @@ public static class Param {
public static final int REMOVE = 2;

final Account account;
final int mode;

public Param(int mode, Account account) {
this.mode = mode;
final int action;

/**
* @param action action to apply on selected account {@link #SELECT,#REMOVE}
* @param account account with login information
*/
public Param(int action, Account account) {
this.action = action;
this.account = account;
}
}
Expand All @@ -74,13 +78,17 @@ public Param(int mode, Account account) {
public static class Result {

public static final int SELECT = 10;
public static final int REMOVE = 20;
public static final int REMOVE = 11;

public final Account account;
public final int mode;

Result(int mode, Account account) {
this.mode = mode;
public final int action;

/**
* @param action action applied on selected account {@link #SELECT,#REMOVE}
* @param account account with login information
*/
Result(int action, Account account) {
this.action = action;
this.account = account;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ public AnnouncementAction(Context context) {
@Override
protected Result doInBackground(@NonNull Param param) {
try {
switch (param.mode) {
case Param.MODE_DISMISS:
connection.dismissAnnouncement(param.id);
return new Result(Result.MODE_DISMISS, param.id, null);
if (param.action == Param.DISMISS) {
connection.dismissAnnouncement(param.id);
return new Result(Result.DISMISS, null);
}
} catch (ConnectionException exception) {
return new Result(Result.MODE_ERROR, param.id, exception);
return new Result(Result.ERROR, exception);
}
return null;
}
Expand All @@ -45,13 +44,17 @@ protected Result doInBackground(@NonNull Param param) {
*/
public static class Param {

public static final int MODE_DISMISS = 1;
public static final int DISMISS = 1;

final int mode;
final int action;
final long id;

public Param(int mode, long id) {
this.mode = mode;
/**
* @param action action to apply on announcement {@link #DISMISS}
* @param id ID of the announcement
*/
public Param(int action, long id) {
this.action = action;
this.id = id;
}
}
Expand All @@ -61,17 +64,18 @@ public Param(int mode, long id) {
*/
public static class Result {

public static final int MODE_ERROR = -1;
public static final int MODE_DISMISS = 10;
public static final int ERROR = -1;
public static final int DISMISS = 10;

public final int mode;
public final long id;
public final int action;
@Nullable
public final ConnectionException exception;

public Result(int mode, long id, @Nullable ConnectionException exception) {
this.mode = mode;
this.id = id;
/**
* @param action action applied on announcement
*/
public Result(int action, @Nullable ConnectionException exception) {
this.action = action;
this.exception = exception;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ protected Result doInBackground(@NonNull Void param) {
*
*/
public static class Result {

@Nullable
public final Announcements announcements;
@Nullable
public final ConnectionException exception;

/**
* @param announcements a list of announcements of the instance server or null if an error occured
*/
public Result(@Nullable Announcements announcements, @Nullable ConnectionException exception) {
this.announcements = announcements;
this.exception = exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public static class Result {
@Nullable
public final ConnectionException exception;

/**
* @param user current user's information or null if an error occured
* @param credentials current user's credentials or null if an error occured
*/
public Result(@Nullable User user, @Nullable Credentials credentials, @Nullable ConnectionException exception) {
this.exception = exception;
this.credentials = credentials;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static class Result {
@Nullable
public final ConnectionException exception;

/**
* @param user updated information from the current user or null if an error occured
*/
Result(@Nullable User user, @Nullable ConnectionException exception) {
this.user = user;
this.exception = exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DatabaseAction(Context context) {
@Override
protected Result doInBackground(@NonNull Param param) {
try {
switch (param.mode) {
switch (param.action) {
case Param.DELETE:
db.resetDatabase();
return new Result(Result.DELETE);
Expand All @@ -54,10 +54,13 @@ public static class Param {
public static final int DELETE = 1;
public static final int LOGOUT = 2;

final int mode;
final int action;

public Param(int mode) {
this.mode = mode;
/**
* @param action action performed on the app database {@link #DELETE,#LOGOUT}
*/
public Param(int action) {
this.action = action;
}
}

Expand All @@ -70,10 +73,13 @@ public static class Result {
public static final int DELETE = 10;
public static final int LOGOUT = 11;

public final int mode;
public final int action;

Result(int mode) {
this.mode = mode;
/**
* @param action action performed on the database {@link #DELETE,#LOGOUT} or {@link #ERROR} if an error occured
*/
Result(int action) {
this.action = action;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public DomainAction(Context context) {
@Override
protected Result doInBackground(@NonNull Param param) {
try {
switch (param.mode) {
case Param.MODE_BLOCK:
switch (param.action) {
case Param.BLOCK:
connection.blockDomain(param.domain);
return new Result(Result.MODE_BLOCK, param.domain, null);
return new Result(Result.BLOCK, param.domain, null);

case Param.MODE_UNBLOCK:
case Param.UNBLOCK:
connection.unblockDomain(param.domain);
return new Result(Result.MODE_UNBLOCK, param.domain, null);
return new Result(Result.UNBLOCK, param.domain, null);

default:
return null;
Expand All @@ -51,14 +51,18 @@ protected Result doInBackground(@NonNull Param param) {
*/
public static class Param {

public static final int MODE_BLOCK = 2;
public static final int MODE_UNBLOCK = 3;
public static final int BLOCK = 2;
public static final int UNBLOCK = 3;

final String domain;
final int mode;

public Param(int mode, String domain) {
this.mode = mode;
final int action;

/**
* @param action action performed on instance domain {@link #BLOCK,#UNBLOCK}
* @param domain instance domain name
*/
public Param(int action, String domain) {
this.action = action;
this.domain = domain;
}
}
Expand All @@ -69,19 +73,23 @@ public Param(int mode, String domain) {
public static class Result {

public static final int ERROR = -1;
public static final int MODE_BLOCK = 5;
public static final int MODE_UNBLOCK = 6;
public static final int BLOCK = 5;
public static final int UNBLOCK = 6;

public final int mode;
public final int action;
@Nullable
public final ConnectionException exception;
@Nullable
public final String domain;

Result(int mode, @Nullable String domain, @Nullable ConnectionException exception) {
/**
* @param action action performed on a domain instance {@link #BLOCK,#UNBLOCK}
* @param domain instance domain name
*/
Result(int action, @Nullable String domain, @Nullable ConnectionException exception) {
this.domain = domain;
this.exception = exception;
this.mode = mode;
this.action = action;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ protected Result doInBackground(@NonNull Param param) {
*/
public static class Param {

public static final long NO_CURSOR = 0L;

final long cursor;
final int index;

/**
* @param cursor list cursor or '0' to start at the beginning of the domain list
* @param index index where to insert new items in the list/adapter
*/
public Param(long cursor, int index) {
this.cursor = cursor;
this.index = index;
Expand All @@ -64,6 +66,10 @@ public static class Result {
@Nullable
public final ConnectionException exception;

/**
* @param domains list of domains or null if an error occured
* @param index index where to insert new items in the list/adapter
*/
Result(@Nullable Domains domains, int index, @Nullable ConnectionException exception) {
this.domains = domains;
this.index = index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public static class Result {
@Nullable
public final ConnectionException exception;

/**
* @param history a list of previous versions of a status or null if an error occured
*/
Result(@Nullable StatusEditHistory history, @Nullable ConnectionException exception) {
this.history = history;
this.exception = exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public FollowRequestAction(Context context) {
@Override
protected Result doInBackground(@NonNull Param param) {
try {
switch (param.mode) {
switch (param.action) {
case Param.ACCEPT:
connection.acceptFollowRequest(param.user_id);
return new Result(Result.ACCEPT, param.notification_id, null);
Expand All @@ -53,12 +53,17 @@ public static class Param {
public static final int ACCEPT = 1;
public static final int REJECT = 2;

final int mode;
final int action;
final long user_id;
final long notification_id;

public Param(int mode, long user_id, long notification_id) {
this.mode = mode;
/**
* @param action actzion to perform on a follow request
* @param user_id if of the user requesting to follow
* @param notification_id notification ID containing the follow request
*/
public Param(int action, long user_id, long notification_id) {
this.action = action;
this.user_id = user_id;
this.notification_id = notification_id;
}
Expand All @@ -73,14 +78,18 @@ public static class Result {
public static final int ACCEPT = 10;
public static final int REJECT = 20;

public final int mode;
public final int action;
public final long notification_id;
@Nullable
public final ConnectionException exception;

Result(int mode, long notification_id, @Nullable ConnectionException exception) {
/**
* @param action action performed on the follow request {@link #ACCEPT,#REJECT} or {@link #ERROR} if an error occured
* @param notification_id notification ID containing the follow request
*/
Result(int action, long notification_id, @Nullable ConnectionException exception) {
this.exception = exception;
this.mode = mode;
this.action = action;
this.notification_id = notification_id;
}
}
Expand Down
Loading

0 comments on commit 6ef4982

Please sign in to comment.