mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-13 05:52:48 +01:00
Fix stack overflow error when syncing subscribed subreddits and users and multireddits. Fix app crashes when creating multireddits without selecting any subreddits. Version 2.2.3.
This commit is contained in:
parent
c0c24a2613
commit
6433014679
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "ml.docilealligator.infinityforreddit"
|
applicationId "ml.docilealligator.infinityforreddit"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 28
|
versionCode 29
|
||||||
versionName "2.2.2"
|
versionName "2.2.3"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -93,6 +93,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
bindView();
|
bindView();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
mSelectedSubscribedSubreddits = new ArrayList<>();
|
||||||
|
mSelectedOtherSubreddits = new ArrayList<>();
|
||||||
getCurrentAccountAndBindView();
|
getCurrentAccountAndBindView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ml.docilealligator.infinityforreddit.AsyncTask;
|
package ml.docilealligator.infinityforreddit.AsyncTask;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -30,9 +31,10 @@ public class InsertMultiRedditAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
List<MultiReddit> existingMultiReddits = multiRedditDao.getAllMultiRedditsList(accountName);
|
List<MultiReddit> existingMultiReddits = multiRedditDao.getAllMultiRedditsList(accountName);
|
||||||
Collections.sort(multiReddits, (multiReddit, t1) -> multiReddit.getName().compareToIgnoreCase(t1.getName()));
|
Collections.sort(multiReddits, (multiReddit, t1) -> multiReddit.getName().compareToIgnoreCase(t1.getName()));
|
||||||
List<String> deletedMultiredditNames = new ArrayList<>();
|
List<String> deletedMultiredditNames = new ArrayList<>();
|
||||||
compareTwoMultiRedditList(multiReddits, existingMultiReddits, deletedMultiredditNames, 0, 0);
|
compareTwoMultiRedditList(multiReddits, existingMultiReddits, deletedMultiredditNames);
|
||||||
|
|
||||||
for (String deleted : deletedMultiredditNames) {
|
for (String deleted : deletedMultiredditNames) {
|
||||||
|
Log.i("asdfasdfs", "s " + deleted + accountName);
|
||||||
multiRedditDao.deleteMultiReddit(deleted, accountName);
|
multiRedditDao.deleteMultiReddit(deleted, accountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,27 +51,27 @@ public class InsertMultiRedditAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void compareTwoMultiRedditList(List<MultiReddit> newMultiReddits,
|
private void compareTwoMultiRedditList(List<MultiReddit> newMultiReddits,
|
||||||
List<MultiReddit> oldMultiReddits,
|
List<MultiReddit> oldMultiReddits,
|
||||||
List<String> deletedMultiReddits, int i1, int i2) {
|
List<String> deletedMultiReddits) {
|
||||||
if (newMultiReddits.size() <= i1 && oldMultiReddits.size() <= i2) {
|
int newIndex = 0;
|
||||||
return;
|
for (int oldIndex = 0; oldIndex < oldMultiReddits.size(); oldIndex++) {
|
||||||
}
|
if (newIndex >= newMultiReddits.size()) {
|
||||||
|
for (; oldIndex < oldMultiReddits.size(); oldIndex++) {
|
||||||
if (newMultiReddits.size() <= i1) {
|
deletedMultiReddits.add(oldMultiReddits.get(oldIndex).getName());
|
||||||
for (int i = 0; i < oldMultiReddits.size(); i++) {
|
}
|
||||||
deletedMultiReddits.add(oldMultiReddits.get(i).getName());
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldMultiReddits.size() > i2) {
|
MultiReddit old = oldMultiReddits.get(oldIndex);
|
||||||
if (newMultiReddits.get(i1).getName().compareToIgnoreCase(oldMultiReddits.get(i2).getName()) == 0) {
|
for (; newIndex < newMultiReddits.size(); newIndex++) {
|
||||||
compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1 + 1, i2 + 1);
|
if (newMultiReddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
|
||||||
} else if (newMultiReddits.get(i1).getName().compareToIgnoreCase(oldMultiReddits.get(i2).getName()) < 0) {
|
newIndex++;
|
||||||
compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1 + 1, i2);
|
break;
|
||||||
} else {
|
}
|
||||||
deletedMultiReddits.add(oldMultiReddits.get(i2).getName());
|
if (newMultiReddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
|
||||||
compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1, i2 + 1);
|
deletedMultiReddits.add(old.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||||||
Collections.sort(subscribedSubredditDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName()));
|
Collections.sort(subscribedSubredditDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName()));
|
||||||
List<String> unsubscribedSubreddits = new ArrayList<>();
|
List<String> unsubscribedSubreddits = new ArrayList<>();
|
||||||
compareTwoSubscribedSubredditList(subscribedSubredditDataList, existingSubscribedSubredditDataList,
|
compareTwoSubscribedSubredditList(subscribedSubredditDataList, existingSubscribedSubredditDataList,
|
||||||
unsubscribedSubreddits, 0, 0);
|
unsubscribedSubreddits);
|
||||||
|
|
||||||
for (String unsubscribed : unsubscribedSubreddits) {
|
for (String unsubscribed : unsubscribedSubreddits) {
|
||||||
mSubscribedSubredditDao.deleteSubscribedSubreddit(unsubscribed, mAccountName);
|
mSubscribedSubredditDao.deleteSubscribedSubreddit(unsubscribed, mAccountName);
|
||||||
@ -101,7 +101,7 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||||||
Collections.sort(subscribedUserDataList, (subscribedUserData, t1) -> subscribedUserData.getName().compareToIgnoreCase(t1.getName()));
|
Collections.sort(subscribedUserDataList, (subscribedUserData, t1) -> subscribedUserData.getName().compareToIgnoreCase(t1.getName()));
|
||||||
List<String> unsubscribedUsers = new ArrayList<>();
|
List<String> unsubscribedUsers = new ArrayList<>();
|
||||||
compareTwoSubscribedUserList(subscribedUserDataList, existingSubscribedUserDataList,
|
compareTwoSubscribedUserList(subscribedUserDataList, existingSubscribedUserDataList,
|
||||||
unsubscribedUsers, 0, 0);
|
unsubscribedUsers);
|
||||||
|
|
||||||
for (String unsubscribed : unsubscribedUsers) {
|
for (String unsubscribed : unsubscribedUsers) {
|
||||||
mSubscribedUserDao.deleteSubscribedUser(unsubscribed, mAccountName);
|
mSubscribedUserDao.deleteSubscribedUser(unsubscribed, mAccountName);
|
||||||
@ -128,52 +128,52 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask<Void, Void, Void>
|
|||||||
|
|
||||||
private void compareTwoSubscribedSubredditList(List<SubscribedSubredditData> newSubscribedSubreddits,
|
private void compareTwoSubscribedSubredditList(List<SubscribedSubredditData> newSubscribedSubreddits,
|
||||||
List<SubscribedSubredditData> oldSubscribedSubreddits,
|
List<SubscribedSubredditData> oldSubscribedSubreddits,
|
||||||
List<String> unsubscribedSubredditNames, int i1, int i2) {
|
List<String> unsubscribedSubredditNames) {
|
||||||
if (newSubscribedSubreddits.size() <= i1 && oldSubscribedSubreddits.size() <= i2) {
|
int newIndex = 0;
|
||||||
return;
|
for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
|
||||||
}
|
if (newIndex >= newSubscribedSubreddits.size()) {
|
||||||
|
for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
|
||||||
if (newSubscribedSubreddits.size() <= i1) {
|
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getName());
|
||||||
for (int i = 0; i < oldSubscribedSubreddits.size(); i++) {
|
}
|
||||||
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(i).getName());
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldSubscribedSubreddits.size() > i2) {
|
SubscribedSubredditData old = oldSubscribedSubreddits.get(oldIndex);
|
||||||
if (newSubscribedSubreddits.get(i1).getName().compareToIgnoreCase(oldSubscribedSubreddits.get(i2).getName()) == 0) {
|
for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
|
||||||
compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1 + 1, i2 + 1);
|
if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
|
||||||
} else if (newSubscribedSubreddits.get(i1).getName().compareToIgnoreCase(oldSubscribedSubreddits.get(i2).getName()) < 0) {
|
newIndex++;
|
||||||
compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1 + 1, i2);
|
break;
|
||||||
} else {
|
}
|
||||||
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(i2).getName());
|
if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
|
||||||
compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1, i2 + 1);
|
unsubscribedSubredditNames.add(old.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compareTwoSubscribedUserList(List<SubscribedUserData> newSubscribedUsers,
|
private void compareTwoSubscribedUserList(List<SubscribedUserData> newSubscribedUsers,
|
||||||
List<SubscribedUserData> oldSubscribedUsers,
|
List<SubscribedUserData> oldSubscribedUsers,
|
||||||
List<String> unsubscribedUserNames, int i1, int i2) {
|
List<String> unsubscribedUserNames) {
|
||||||
if (newSubscribedUsers.size() <= i1 && oldSubscribedUsers.size() <= i2) {
|
int newIndex = 0;
|
||||||
return;
|
for (int oldIndex = 0; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
|
||||||
}
|
if (newIndex >= newSubscribedUsers.size()) {
|
||||||
|
for (; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
|
||||||
if (newSubscribedUsers.size() <= i1) {
|
unsubscribedUserNames.add(oldSubscribedUsers.get(oldIndex).getName());
|
||||||
for (int i = 0; i < oldSubscribedUsers.size(); i++) {
|
}
|
||||||
unsubscribedUserNames.add(oldSubscribedUsers.get(i).getName());
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldSubscribedUsers.size() > i2) {
|
SubscribedUserData old = oldSubscribedUsers.get(oldIndex);
|
||||||
if (newSubscribedUsers.get(i1).getName().compareToIgnoreCase(oldSubscribedUsers.get(i2).getName()) == 0) {
|
for (; newIndex < newSubscribedUsers.size(); newIndex++) {
|
||||||
compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1 + 1, i2 + 1);
|
if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
|
||||||
} else if (newSubscribedUsers.get(i1).getName().compareToIgnoreCase(oldSubscribedUsers.get(i2).getName()) < 0) {
|
newIndex++;
|
||||||
compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1 + 1, i2);
|
break;
|
||||||
} else {
|
}
|
||||||
unsubscribedUserNames.add(oldSubscribedUsers.get(i2).getName());
|
if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
|
||||||
compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1, i2 + 1);
|
unsubscribedUserNames.add(old.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ public interface MultiRedditDao {
|
|||||||
@Query("SELECT * FROM multi_reddits WHERE name = :name AND username = :username COLLATE NOCASE LIMIT 1")
|
@Query("SELECT * FROM multi_reddits WHERE name = :name AND username = :username COLLATE NOCASE LIMIT 1")
|
||||||
MultiReddit getMultiReddit(String name, String username);
|
MultiReddit getMultiReddit(String name, String username);
|
||||||
|
|
||||||
@Query("DELETE FROM multi_reddits WHERE path = :multipath AND username = :username")
|
@Query("DELETE FROM multi_reddits WHERE name = :name AND username = :username")
|
||||||
void deleteMultiReddit(String multipath, String username);
|
void deleteMultiReddit(String name, String username);
|
||||||
|
|
||||||
@Query("DELETE FROM multi_reddits WHERE username = :username")
|
@Query("DELETE FROM multi_reddits WHERE username = :username")
|
||||||
void deleteAllUserMultiReddits(String username);
|
void deleteAllUserMultiReddits(String username);
|
||||||
|
Loading…
Reference in New Issue
Block a user