diff options
51 files changed, 169 insertions, 201 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java index a15536a9..239effc5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java @@ -31,13 +31,12 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.AsyncTask.ParseAndInsertNewAccountAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -144,12 +143,10 @@ public class LoginActivity extends BaseActivity { String accessToken = responseJSON.getString(APIUtils.ACCESS_TOKEN_KEY); String refreshToken = responseJSON.getString(APIUtils.REFRESH_TOKEN_KEY); - FetchMyInfo.fetchAccountInfo(mOauthRetrofit, accessToken, new FetchMyInfo.FetchUserMyListener() { - @Override - public void onFetchMyInfoSuccess(String response) { - ParseAndSaveAccountInfo.parseAndSaveAccountInfo(response, mRedditDataRoomDatabase, new ParseAndSaveAccountInfo.ParseAndSaveAccountInfoListener() { + FetchMyInfo.fetchAccountInfo(mOauthRetrofit, mRedditDataRoomDatabase, + accessToken, new FetchMyInfo.FetchMyInfoListener() { @Override - public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) { + public void onFetchMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) { new ParseAndInsertNewAccountAsyncTask(name, accessToken, refreshToken, profileImageUrl, bannerImageUrl, karma, authCode, mRedditDataRoomDatabase.accountDao(), () -> { @@ -160,18 +157,15 @@ public class LoginActivity extends BaseActivity { } @Override - public void onParseMyInfoFail() { - Toast.makeText(LoginActivity.this, R.string.parse_user_info_error, Toast.LENGTH_SHORT).show(); + public void onFetchMyInfoFailed(boolean parseFailed) { + if (parseFailed) { + Toast.makeText(LoginActivity.this, R.string.parse_user_info_error, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show(); + } + finish(); } - }); - } - - @Override - public void onFetchMyInfoFail() { - Toast.makeText(LoginActivity.this, R.string.cannot_fetch_user_info, Toast.LENGTH_SHORT).show(); - finish(); - } }); } catch (JSONException e) { e.printStackTrace(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 1c840c63..4b488bfa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -78,17 +78,16 @@ import ml.docilealligator.infinityforreddit.FetchMyInfo; import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; +import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.PullNotificationWorker; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; @@ -673,12 +672,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb private void loadUserData() { if (!mFetchUserInfoSuccess) { - FetchMyInfo.fetchAccountInfo(mOauthRetrofit, mAccessToken, new FetchMyInfo.FetchUserMyListener() { - @Override - public void onFetchMyInfoSuccess(String response) { - ParseAndSaveAccountInfo.parseAndSaveAccountInfo(response, mRedditDataRoomDatabase, new ParseAndSaveAccountInfo.ParseAndSaveAccountInfoListener() { + FetchMyInfo.fetchAccountInfo(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, + new FetchMyInfo.FetchMyInfoListener() { @Override - public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) { + public void onFetchMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) { mAccountName = name; mProfileImageUrl = profileImageUrl; mBannerImageUrl = bannerImageUrl; @@ -687,16 +684,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } @Override - public void onParseMyInfoFail() { + public void onFetchMyInfoFailed(boolean parseFailed) { mFetchUserInfoSuccess = false; } - }); - } - - @Override - public void onFetchMyInfoFail() { - mFetchUserInfoSuccess = false; - } }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java index 18aeed17..c3a1e4f8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java @@ -42,7 +42,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java index 18601f89..4bf4234c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java @@ -39,8 +39,8 @@ import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListing import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java index cf8e5bfc..797a1b63 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java @@ -52,8 +52,8 @@ import ml.docilealligator.infinityforreddit.MultiReddit.FetchMyMultiReddits; import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 000e677d..50c85c54 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -73,8 +73,8 @@ import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivit import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Comment.FetchComment; -import ml.docilealligator.infinityforreddit.FetchRemovedComment; -import ml.docilealligator.infinityforreddit.FetchRemovedPost; +import ml.docilealligator.infinityforreddit.Comment.FetchRemovedComment; +import ml.docilealligator.infinityforreddit.Post.FetchRemovedPost; import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Comment.ParseComment; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index aa42d49a..638ca37e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -66,7 +66,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.GoBackToMainPageEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; -import ml.docilealligator.infinityforreddit.FetchSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.SidebarFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; @@ -77,9 +77,9 @@ import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel; -import ml.docilealligator.infinityforreddit.SubredditSubscription; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditViewModel; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditSubscription; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index 8134ebcf..30891f38 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -60,7 +60,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.DeleteThing; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; -import ml.docilealligator.infinityforreddit.FetchUserData; +import ml.docilealligator.infinityforreddit.User.FetchUserData; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; @@ -78,7 +78,7 @@ import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUse import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.User.UserData; import ml.docilealligator.infinityforreddit.User.UserViewModel; -import ml.docilealligator.infinityforreddit.UserFollowing; +import ml.docilealligator.infinityforreddit.User.UserFollowing; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java index 7d038fa0..4e2f5b7f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java @@ -25,7 +25,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.Account.Account; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import pl.droidsonroids.gif.GifImageView; public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java index 52caf4e1..964ecd5d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java @@ -30,8 +30,8 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubredditSubscription; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditSubscription; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java index 25b57611..6c2d0b87 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java @@ -23,8 +23,8 @@ import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.SubredditWithSelection; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditWithSelection; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import pl.droidsonroids.gif.GifImageView; public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java index d5cb996a..3e557594 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java @@ -27,7 +27,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.FavoriteThing; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java index 33867a0d..fad8c30a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java @@ -33,7 +33,7 @@ import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.User.UserData; -import ml.docilealligator.infinityforreddit.UserFollowing; +import ml.docilealligator.infinityforreddit.User.UserFollowing; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/CheckIsSubscribedToSubredditAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/CheckIsSubscribedToSubredditAsyncTask.java index 2965f6de..a9388bf5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/CheckIsSubscribedToSubredditAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/CheckIsSubscribedToSubredditAsyncTask.java @@ -3,7 +3,7 @@ package ml.docilealligator.infinityforreddit.AsyncTask; import android.os.AsyncTask; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; public class CheckIsSubscribedToSubredditAsyncTask extends AsyncTask<Void, Void, Void> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubredditDataAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubredditDataAsyncTask.java index 8f7bb88e..7b3e40f9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubredditDataAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubredditDataAsyncTask.java @@ -3,8 +3,8 @@ package ml.docilealligator.infinityforreddit.AsyncTask; import android.os.AsyncTask; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditDao; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; public class InsertSubredditDataAsyncTask extends AsyncTask<Void, Void, Void> { private SubredditDao mSubredditDao; 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 0d46da69..0a73135e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertSubscribedThingsAsyncTask.java @@ -9,10 +9,10 @@ import java.util.Collections; import java.util.List; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditDao; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditDao; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditDao; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadSubredditIconAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadSubredditIconAsyncTask.java index 0c2d289a..a89f1064 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadSubredditIconAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadSubredditIconAsyncTask.java @@ -4,10 +4,10 @@ import android.os.AsyncTask; import java.util.ArrayList; -import ml.docilealligator.infinityforreddit.FetchSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditDao; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; import retrofit2.Retrofit; public class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadUserDataAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadUserDataAsyncTask.java index 6bfb922b..30c9e039 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadUserDataAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/LoadUserDataAsyncTask.java @@ -2,7 +2,7 @@ package ml.docilealligator.infinityforreddit.AsyncTask; import android.os.AsyncTask; -import ml.docilealligator.infinityforreddit.FetchUserData; +import ml.docilealligator.infinityforreddit.User.FetchUserData; import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.User.UserData; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/FetchRemovedComment.java index 658ddc88..ad774da9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Comment/FetchRemovedComment.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Comment; import android.os.AsyncTask; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java index c0d429f7..0333a6df 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FavoriteThing.java @@ -7,7 +7,7 @@ import java.util.Map; import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import retrofit2.Call; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java index 3467599e..1bf1b8a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchMyInfo.java @@ -1,17 +1,24 @@ package ml.docilealligator.infinityforreddit; +import android.os.AsyncTask; +import android.text.Html; + import androidx.annotation.NonNull; +import org.json.JSONException; +import org.json.JSONObject; + import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.Utils.APIUtils; +import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; public class FetchMyInfo { - public static void fetchAccountInfo(final Retrofit retrofit, String accessToken, - final FetchUserMyListener fetchUserMyListener) { + public static void fetchAccountInfo(final Retrofit retrofit, RedditDataRoomDatabase redditDataRoomDatabase, + String accessToken, final FetchMyInfoListener fetchMyInfoListener) { RedditAPI api = retrofit.create(RedditAPI.class); Call<String> userInfo = api.getMyInfo(APIUtils.getOAuthHeader(accessToken)); @@ -19,22 +26,74 @@ public class FetchMyInfo { @Override public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { if (response.isSuccessful()) { - fetchUserMyListener.onFetchMyInfoSuccess(response.body()); + new ParseAndSaveAccountInfoAsyncTask(response.body(), redditDataRoomDatabase, fetchMyInfoListener).execute(); } else { - fetchUserMyListener.onFetchMyInfoFail(); + fetchMyInfoListener.onFetchMyInfoFailed(false); } } @Override public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { - fetchUserMyListener.onFetchMyInfoFail(); + fetchMyInfoListener.onFetchMyInfoFailed(false); } }); } - public interface FetchUserMyListener { - void onFetchMyInfoSuccess(String response); + public interface FetchMyInfoListener { + void onFetchMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma); + + void onFetchMyInfoFailed(boolean parseFailed); + } - void onFetchMyInfoFail(); + private static class ParseAndSaveAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> { + private JSONObject jsonResponse; + private RedditDataRoomDatabase redditDataRoomDatabase; + private FetchMyInfoListener fetchMyInfoListener; + private boolean parseFailed; + + private String name; + private String profileImageUrl; + private String bannerImageUrl; + private int karma; + + ParseAndSaveAccountInfoAsyncTask(String response, RedditDataRoomDatabase redditDataRoomDatabase, + FetchMyInfoListener fetchMyInfoListener) { + try { + jsonResponse = new JSONObject(response); + this.redditDataRoomDatabase = redditDataRoomDatabase; + this.fetchMyInfoListener = fetchMyInfoListener; + parseFailed = false; + } catch (JSONException e) { + fetchMyInfoListener.onFetchMyInfoFailed(true); + } + } + + @Override + protected Void doInBackground(Void... voids) { + try { + name = jsonResponse.getString(JSONUtils.NAME_KEY); + profileImageUrl = Html.fromHtml(jsonResponse.getString(JSONUtils.ICON_IMG_KEY)).toString(); + if (!jsonResponse.isNull(JSONUtils.SUBREDDIT_KEY)) { + bannerImageUrl = Html.fromHtml(jsonResponse.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.BANNER_IMG_KEY)).toString(); + } + int linkKarma = jsonResponse.getInt(JSONUtils.LINK_KARMA_KEY); + int commentKarma = jsonResponse.getInt(JSONUtils.COMMENT_KARMA_KEY); + karma = linkKarma + commentKarma; + + redditDataRoomDatabase.accountDao().updateAccountInfo(name, profileImageUrl, bannerImageUrl, karma); + } catch (JSONException e) { + parseFailed = true; + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + if (!parseFailed) { + fetchMyInfoListener.onFetchMyInfoSuccess(name, profileImageUrl, bannerImageUrl, karma); + } else { + fetchMyInfoListener.onFetchMyInfoFailed(true); + } + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java index 0fbfd856..7f2a4773 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubscribedThing.java @@ -5,8 +5,8 @@ import androidx.annotation.NonNull; import java.util.ArrayList; import ml.docilealligator.infinityforreddit.API.RedditAPI; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import retrofit2.Call; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java index 6e070c5e..c7431b20 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java @@ -43,12 +43,12 @@ import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.FetchSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.FetchSubredditData; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditViewModel; import retrofit2.Retrofit; public class SidebarFragment extends Fragment { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java index 80cb6541..3fefdb2d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java @@ -41,9 +41,8 @@ import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.SubredditListingViewModel; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditListingViewModel; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; -import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java index 728b80ce..63d6aade 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java @@ -39,7 +39,7 @@ import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditViewModel; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java index 532346c5..62019b81 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java @@ -38,9 +38,8 @@ import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; -import ml.docilealligator.infinityforreddit.UserListingViewModel; +import ml.docilealligator.infinityforreddit.User.UserListingViewModel; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; -import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java deleted file mode 100644 index 387b75f4..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseAndSaveAccountInfo.java +++ /dev/null @@ -1,74 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -import android.os.AsyncTask; -import android.text.Html; - -import org.json.JSONException; -import org.json.JSONObject; - -import ml.docilealligator.infinityforreddit.Utils.JSONUtils; - -public class ParseAndSaveAccountInfo { - public static void parseAndSaveAccountInfo(String response, RedditDataRoomDatabase redditDataRoomDatabase, - ParseAndSaveAccountInfoListener parseAndSaveAccountInfoListener) { - new ParseAndSaveAccountInfoAsyncTask(response, redditDataRoomDatabase, parseAndSaveAccountInfoListener).execute(); - } - - public interface ParseAndSaveAccountInfoListener { - void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma); - - void onParseMyInfoFail(); - } - - private static class ParseAndSaveAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> { - private JSONObject jsonResponse; - private RedditDataRoomDatabase redditDataRoomDatabase; - private ParseAndSaveAccountInfoListener parseAndSaveAccountInfoListener; - private boolean parseFailed; - - private String name; - private String profileImageUrl; - private String bannerImageUrl; - private int karma; - - ParseAndSaveAccountInfoAsyncTask(String response, RedditDataRoomDatabase redditDataRoomDatabase, - ParseAndSaveAccountInfoListener parseAndSaveAccountInfoListener) { - try { - jsonResponse = new JSONObject(response); - this.redditDataRoomDatabase = redditDataRoomDatabase; - this.parseAndSaveAccountInfoListener = parseAndSaveAccountInfoListener; - parseFailed = false; - } catch (JSONException e) { - parseAndSaveAccountInfoListener.onParseMyInfoFail(); - } - } - - @Override - protected Void doInBackground(Void... voids) { - try { - name = jsonResponse.getString(JSONUtils.NAME_KEY); - profileImageUrl = Html.fromHtml(jsonResponse.getString(JSONUtils.ICON_IMG_KEY)).toString(); - if (!jsonResponse.isNull(JSONUtils.SUBREDDIT_KEY)) { - bannerImageUrl = Html.fromHtml(jsonResponse.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.BANNER_IMG_KEY)).toString(); - } - int linkKarma = jsonResponse.getInt(JSONUtils.LINK_KARMA_KEY); - int commentKarma = jsonResponse.getInt(JSONUtils.COMMENT_KARMA_KEY); - karma = linkKarma + commentKarma; - - redditDataRoomDatabase.accountDao().updateAccountInfo(name, profileImageUrl, bannerImageUrl, karma); - } catch (JSONException e) { - parseFailed = true; - } - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - if (!parseFailed) { - parseAndSaveAccountInfoListener.onParseMyInfoSuccess(name, profileImageUrl, bannerImageUrl, karma); - } else { - parseAndSaveAccountInfoListener.onParseMyInfoFail(); - } - } - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java index 97da7db6..c8666fa7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java @@ -8,8 +8,8 @@ import org.json.JSONObject; import java.util.ArrayList; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/FetchRemovedPost.java index 646dfe19..f24e995b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRemovedPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/FetchRemovedPost.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Post; import android.net.Uri; import android.os.AsyncTask; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java index 3bac4b1b..d2d0d079 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java @@ -16,10 +16,10 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeDao; import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditDao; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditDao; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditDao; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditDao; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; import ml.docilealligator.infinityforreddit.User.UserDao; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/FetchSubredditData.java index b9623b91..c6bc2914 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/FetchSubredditData.java @@ -1,11 +1,10 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import androidx.annotation.NonNull; import java.util.ArrayList; import ml.docilealligator.infinityforreddit.API.RedditAPI; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/ParseSubredditData.java index 23bd9910..7c75b35d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/ParseSubredditData.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import android.os.AsyncTask; @@ -8,7 +8,7 @@ import org.json.JSONObject; import java.util.ArrayList; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; +import ml.docilealligator.infinityforreddit.Subreddit.SubredditData; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditDao.java index bb058295..d6b07312 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditDao.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubredditDatabase; +package ml.docilealligator.infinityforreddit.Subreddit; import androidx.lifecycle.LiveData; import androidx.room.Dao; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditData.java index 6c73f459..1fb628bf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditData.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubredditDatabase; +package ml.docilealligator.infinityforreddit.Subreddit; import androidx.annotation.NonNull; import androidx.room.ColumnInfo; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditListingDataSource.java index 32bde86d..05a0b7d2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditListingDataSource.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; @@ -6,7 +6,8 @@ import androidx.paging.PageKeyedDataSource; import java.util.ArrayList; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class SubredditListingDataSource extends PageKeyedDataSource<String, SubredditData> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditListingDataSourceFactory.java index fa683f47..f18b3691 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditListingDataSourceFactory.java @@ -1,9 +1,10 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; import androidx.paging.DataSource; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class SubredditListingDataSourceFactory extends DataSource.Factory { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditListingViewModel.java index b2023541..ed8df032 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditListingViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import androidx.annotation.NonNull; import androidx.lifecycle.LiveData; @@ -9,7 +9,8 @@ import androidx.lifecycle.ViewModelProvider; import androidx.paging.LivePagedListBuilder; import androidx.paging.PagedList; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class SubredditListingViewModel extends ViewModel { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditRepository.java index 2978fdca..66817e40 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditRepository.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditRepository.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubredditDatabase; +package ml.docilealligator.infinityforreddit.Subreddit; import android.os.AsyncTask; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditSubscription.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditSubscription.java index 3f2225e8..5475e319 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditSubscription.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditSubscription.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import android.os.AsyncTask; @@ -8,8 +8,8 @@ import java.util.HashMap; import java.util.Map; import ml.docilealligator.infinityforreddit.API.RedditAPI; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import retrofit2.Call; import retrofit2.Callback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditViewModel.java index ee152d09..46829c3b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubredditDatabase; +package ml.docilealligator.infinityforreddit.Subreddit; import android.app.Application; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditWithSelection.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditWithSelection.java index bb95c446..a8cd289f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditWithSelection.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Subreddit/SubredditWithSelection.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Subreddit; import android.os.Parcel; import android.os.Parcelable; @@ -8,8 +8,7 @@ import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.List; -import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; -import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData; +import ml.docilealligator.infinityforreddit.SubscribedSubreddit.SubscribedSubredditData; public class SubredditWithSelection implements Parcelable { private String name; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditDao.java index cc0434d7..aa62e088 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditDao.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase; +package ml.docilealligator.infinityforreddit.SubscribedSubreddit; import androidx.lifecycle.LiveData; import androidx.room.Dao; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditData.java index 04b8700e..167e6423 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditData.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase; +package ml.docilealligator.infinityforreddit.SubscribedSubreddit; import androidx.annotation.NonNull; import androidx.room.ColumnInfo; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditRepository.java index 3f2da07d..aa5fbc0f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditRepository.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditRepository.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase; +package ml.docilealligator.infinityforreddit.SubscribedSubreddit; import android.os.AsyncTask; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditViewModel.java index 56ff6c5e..79e3dd2b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditDatabase/SubscribedSubredditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubreddit/SubscribedSubredditViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase; +package ml.docilealligator.infinityforreddit.SubscribedSubreddit; import android.app.Application; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/FetchUserData.java index b698d8d1..5d9a35d9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/FetchUserData.java @@ -1,11 +1,10 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.User; import androidx.annotation.NonNull; import java.util.ArrayList; import ml.docilealligator.infinityforreddit.API.RedditAPI; -import ml.docilealligator.infinityforreddit.User.UserData; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/ParseUserData.java index f3766d05..65e32933 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/ParseUserData.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.User; import android.os.AsyncTask; @@ -8,7 +8,6 @@ import org.json.JSONObject; import java.util.ArrayList; -import ml.docilealligator.infinityforreddit.User.UserData; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; public class ParseUserData { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserFollowing.java index 93ec3bc3..d49acf25 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserFollowing.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserFollowing.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.User; import android.os.AsyncTask; @@ -10,7 +10,6 @@ import java.util.Map; import ml.docilealligator.infinityforreddit.API.RedditAPI; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData; -import ml.docilealligator.infinityforreddit.User.UserData; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import retrofit2.Call; import retrofit2.Callback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserListingDataSource.java index 0d181035..a7606588 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserListingDataSource.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.User; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; @@ -6,7 +6,8 @@ import androidx.paging.PageKeyedDataSource; import java.util.ArrayList; -import ml.docilealligator.infinityforreddit.User.UserData; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class UserListingDataSource extends PageKeyedDataSource<String, UserData> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserListingDataSourceFactory.java index d391514f..e0bf6288 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserListingDataSourceFactory.java @@ -1,9 +1,10 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.User; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; import androidx.paging.DataSource; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class UserListingDataSourceFactory extends DataSource.Factory { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserListingViewModel.java index abe3cef2..d15bbd62 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserListingViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.User; import androidx.annotation.NonNull; import androidx.lifecycle.LiveData; @@ -9,7 +9,8 @@ import androidx.lifecycle.ViewModelProvider; import androidx.paging.LivePagedListBuilder; import androidx.paging.PagedList; -import ml.docilealligator.infinityforreddit.User.UserData; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class UserListingViewModel extends ViewModel { |