aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java42
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java78
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java4
5 files changed, 67 insertions, 63 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 5145e413..4dcb03a6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,8 +6,8 @@ android {
applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21
targetSdkVersion 29
- versionCode 28
- versionName "2.2.2"
+ versionCode 29
+ versionName "2.2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
index 6db86514..7435e216 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
@@ -93,6 +93,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
bindView();
}
} else {
+ mSelectedSubscribedSubreddits = new ArrayList<>();
+ mSelectedOtherSubreddits = new ArrayList<>();
getCurrentAccountAndBindView();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java
index c76b726e..2c15fa33 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.AsyncTask;
import android.os.AsyncTask;
+import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
@@ -30,9 +31,10 @@ public class InsertMultiRedditAsyncTask extends AsyncTask<Void, Void, Void> {
List<MultiReddit> existingMultiReddits = multiRedditDao.getAllMultiRedditsList(accountName);
Collections.sort(multiReddits, (multiReddit, t1) -> multiReddit.getName().compareToIgnoreCase(t1.getName()));
List<String> deletedMultiredditNames = new ArrayList<>();
- compareTwoMultiRedditList(multiReddits, existingMultiReddits, deletedMultiredditNames, 0, 0);
+ compareTwoMultiRedditList(multiReddits, existingMultiReddits, deletedMultiredditNames);
for (String deleted : deletedMultiredditNames) {
+ Log.i("asdfasdfs", "s " + deleted + accountName);
multiRedditDao.deleteMultiReddit(deleted, accountName);
}
@@ -49,27 +51,27 @@ public class InsertMultiRedditAsyncTask extends AsyncTask<Void, Void, Void> {
}
private void compareTwoMultiRedditList(List<MultiReddit> newMultiReddits,
- List<MultiReddit> oldMultiReddits,
- List<String> deletedMultiReddits, int i1, int i2) {
- if (newMultiReddits.size() <= i1 && oldMultiReddits.size() <= i2) {
- return;
- }
-
- if (newMultiReddits.size() <= i1) {
- for (int i = 0; i < oldMultiReddits.size(); i++) {
- deletedMultiReddits.add(oldMultiReddits.get(i).getName());
+ List<MultiReddit> oldMultiReddits,
+ List<String> deletedMultiReddits) {
+ int newIndex = 0;
+ for (int oldIndex = 0; oldIndex < oldMultiReddits.size(); oldIndex++) {
+ if (newIndex >= newMultiReddits.size()) {
+ for (; oldIndex < oldMultiReddits.size(); oldIndex++) {
+ deletedMultiReddits.add(oldMultiReddits.get(oldIndex).getName());
+ }
+ return;
}
- return;
- }
- if (oldMultiReddits.size() > i2) {
- if (newMultiReddits.get(i1).getName().compareToIgnoreCase(oldMultiReddits.get(i2).getName()) == 0) {
- compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1 + 1, i2 + 1);
- } else if (newMultiReddits.get(i1).getName().compareToIgnoreCase(oldMultiReddits.get(i2).getName()) < 0) {
- compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1 + 1, i2);
- } else {
- deletedMultiReddits.add(oldMultiReddits.get(i2).getName());
- compareTwoMultiRedditList(newMultiReddits, oldMultiReddits, deletedMultiReddits, i1, i2 + 1);
+ MultiReddit old = oldMultiReddits.get(oldIndex);
+ for (; newIndex < newMultiReddits.size(); newIndex++) {
+ if (newMultiReddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
+ newIndex++;
+ break;
+ }
+ if (newMultiReddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
+ deletedMultiReddits.add(old.getName());
+ break;
+ }
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java
index a1ea1b68..0d46da69 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java
@@ -84,7 +84,7 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask<Void, Void, Void>
Collections.sort(subscribedSubredditDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName()));
List<String> unsubscribedSubreddits = new ArrayList<>();
compareTwoSubscribedSubredditList(subscribedSubredditDataList, existingSubscribedSubredditDataList,
- unsubscribedSubreddits, 0, 0);
+ unsubscribedSubreddits);
for (String unsubscribed : unsubscribedSubreddits) {
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()));
List<String> unsubscribedUsers = new ArrayList<>();
compareTwoSubscribedUserList(subscribedUserDataList, existingSubscribedUserDataList,
- unsubscribedUsers, 0, 0);
+ unsubscribedUsers);
for (String unsubscribed : unsubscribedUsers) {
mSubscribedUserDao.deleteSubscribedUser(unsubscribed, mAccountName);
@@ -128,52 +128,52 @@ public class InsertSubscribedThingsAsyncTask extends AsyncTask<Void, Void, Void>
private void compareTwoSubscribedSubredditList(List<SubscribedSubredditData> newSubscribedSubreddits,
List<SubscribedSubredditData> oldSubscribedSubreddits,
- List<String> unsubscribedSubredditNames, int i1, int i2) {
- if (newSubscribedSubreddits.size() <= i1 && oldSubscribedSubreddits.size() <= i2) {
- return;
- }
-
- if (newSubscribedSubreddits.size() <= i1) {
- for (int i = 0; i < oldSubscribedSubreddits.size(); i++) {
- unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(i).getName());
+ List<String> unsubscribedSubredditNames) {
+ int newIndex = 0;
+ for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
+ if (newIndex >= newSubscribedSubreddits.size()) {
+ for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
+ unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getName());
+ }
+ return;
}
- return;
- }
- if (oldSubscribedSubreddits.size() > i2) {
- if (newSubscribedSubreddits.get(i1).getName().compareToIgnoreCase(oldSubscribedSubreddits.get(i2).getName()) == 0) {
- compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1 + 1, i2 + 1);
- } else if (newSubscribedSubreddits.get(i1).getName().compareToIgnoreCase(oldSubscribedSubreddits.get(i2).getName()) < 0) {
- compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1 + 1, i2);
- } else {
- unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(i2).getName());
- compareTwoSubscribedSubredditList(newSubscribedSubreddits, oldSubscribedSubreddits, unsubscribedSubredditNames, i1, i2 + 1);
+ SubscribedSubredditData old = oldSubscribedSubreddits.get(oldIndex);
+ for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
+ if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
+ newIndex++;
+ break;
+ }
+ if (newSubscribedSubreddits.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
+ unsubscribedSubredditNames.add(old.getName());
+ break;
+ }
}
}
}
private void compareTwoSubscribedUserList(List<SubscribedUserData> newSubscribedUsers,
- List<SubscribedUserData> oldSubscribedUsers,
- List<String> unsubscribedUserNames, int i1, int i2) {
- if (newSubscribedUsers.size() <= i1 && oldSubscribedUsers.size() <= i2) {
- return;
- }
-
- if (newSubscribedUsers.size() <= i1) {
- for (int i = 0; i < oldSubscribedUsers.size(); i++) {
- unsubscribedUserNames.add(oldSubscribedUsers.get(i).getName());
+ List<SubscribedUserData> oldSubscribedUsers,
+ List<String> unsubscribedUserNames) {
+ int newIndex = 0;
+ for (int oldIndex = 0; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
+ if (newIndex >= newSubscribedUsers.size()) {
+ for (; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
+ unsubscribedUserNames.add(oldSubscribedUsers.get(oldIndex).getName());
+ }
+ return;
}
- return;
- }
- if (oldSubscribedUsers.size() > i2) {
- if (newSubscribedUsers.get(i1).getName().compareToIgnoreCase(oldSubscribedUsers.get(i2).getName()) == 0) {
- compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1 + 1, i2 + 1);
- } else if (newSubscribedUsers.get(i1).getName().compareToIgnoreCase(oldSubscribedUsers.get(i2).getName()) < 0) {
- compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1 + 1, i2);
- } else {
- unsubscribedUserNames.add(oldSubscribedUsers.get(i2).getName());
- compareTwoSubscribedUserList(newSubscribedUsers, oldSubscribedUsers, unsubscribedUserNames, i1, i2 + 1);
+ SubscribedUserData old = oldSubscribedUsers.get(oldIndex);
+ for (; newIndex < newSubscribedUsers.size(); newIndex++) {
+ if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
+ newIndex++;
+ break;
+ }
+ if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
+ unsubscribedUserNames.add(old.getName());
+ break;
+ }
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java
index 198e610e..7d3654c8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/MultiRedditDao.java
@@ -25,8 +25,8 @@ public interface MultiRedditDao {
@Query("SELECT * FROM multi_reddits WHERE name = :name AND username = :username COLLATE NOCASE LIMIT 1")
MultiReddit getMultiReddit(String name, String username);
- @Query("DELETE FROM multi_reddits WHERE path = :multipath AND username = :username")
- void deleteMultiReddit(String multipath, String username);
+ @Query("DELETE FROM multi_reddits WHERE name = :name AND username = :username")
+ void deleteMultiReddit(String name, String username);
@Query("DELETE FROM multi_reddits WHERE username = :username")
void deleteAllUserMultiReddits(String username);