diff options
Diffstat (limited to 'app/src/main/java/ml')
25 files changed, 70 insertions, 58 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java index ad93f0c1..ede80722 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java @@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java index 44f4014d..1e1e7447 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java @@ -40,7 +40,7 @@ import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java index 6fc27fb1..71123450 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java @@ -38,8 +38,8 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.Post; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.Post; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; 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 d6eeba0c..c5eb9ac2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -85,7 +85,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.PullNotificationWorker; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; @@ -211,6 +211,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb private String mNewAccountName; private Menu mMenu; private boolean isInLazyMode = false; + private boolean showBottomAppBar; @Override protected void onCreate(Bundle savedInstanceState) { @@ -310,6 +311,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams(); + showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); + if (savedInstanceState != null) { mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE); mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE); @@ -454,7 +457,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bottomNavigationView.setVisibility(View.GONE); fab.setVisibility(View.GONE); } else { - if (mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false)) { + if (showBottomAppBar) { bottomNavigationView.setVisibility(View.VISIBLE); } else { CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); @@ -489,8 +492,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Override public void onPageSelected(int position) { - bottomNavigationView.performShow(); - fab.show(); + if (mAccessToken != null && showBottomAppBar) { + bottomNavigationView.performShow(); + fab.show(); + } if (isInLazyMode) { if (position == sectionsPagerAdapter.getCurrentLazyModeFragmentPosition()) { sectionsPagerAdapter.resumeLazyMode(); @@ -943,14 +948,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } public void postScrollUp() { - if (mAccessToken != null) { + if (mAccessToken != null && showBottomAppBar) { bottomNavigationView.performShow(); fab.show(); } } public void postScrollDown() { - if (mAccessToken != null) { + if (mAccessToken != null && showBottomAppBar) { fab.hide(); bottomNavigationView.performHide(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java index 03684be1..f077ee54 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java @@ -44,7 +44,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment; import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java index 34ee2e1e..b5bca5b5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java @@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; 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 11cc629d..c5dfed9f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -72,7 +72,7 @@ import ml.docilealligator.infinityforreddit.HidePost; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.ParseComment; import ml.docilealligator.infinityforreddit.ParsePost; -import ml.docilealligator.infinityforreddit.Post; +import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditAPI; 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 62ab002e..1dc855f8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -55,7 +55,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; 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 5ffaa717..90695fde 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -61,7 +61,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index ea37f174..edaefc75 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -76,8 +76,8 @@ import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager; import ml.docilealligator.infinityforreddit.FetchComment; import ml.docilealligator.infinityforreddit.Fragment.ModifyCommentBottomSheetFragment; -import ml.docilealligator.infinityforreddit.Post; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.Post; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SaveThing; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index a4e897de..ca3d7111 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -55,8 +55,8 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask; import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity; import ml.docilealligator.infinityforreddit.NetworkState; -import ml.docilealligator.infinityforreddit.Post; -import ml.docilealligator.infinityforreddit.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.Post; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SaveThing; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java index fac8ddd4..e82115ec 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentDataSource.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToDetailActivity.java index 0d502aa6..bb935590 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToDetailActivity.java @@ -1,6 +1,6 @@ package ml.docilealligator.infinityforreddit.Event; -import ml.docilealligator.infinityforreddit.Post; +import ml.docilealligator.infinityforreddit.Post.Post; public class PostUpdateEventToDetailActivity { public final Post post; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToPostList.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToPostList.java index 10dadb7d..f37ae7bc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToPostList.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/PostUpdateEventToPostList.java @@ -1,6 +1,6 @@ package ml.docilealligator.infinityforreddit.Event; -import ml.docilealligator.infinityforreddit.Post; +import ml.docilealligator.infinityforreddit.Post.Post; public class PostUpdateEventToPostList { public final Post post; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/SubmitTextOrLinkPostEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/SubmitTextOrLinkPostEvent.java index 3d43664e..0e164b60 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/SubmitTextOrLinkPostEvent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/SubmitTextOrLinkPostEvent.java @@ -1,6 +1,6 @@ package ml.docilealligator.infinityforreddit.Event; -import ml.docilealligator.infinityforreddit.Post; +import ml.docilealligator.infinityforreddit.Post.Post; public class SubmitTextOrLinkPostEvent { public boolean postSuccess; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java index 07523722..9f0c93ba 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java @@ -4,6 +4,7 @@ import androidx.annotation.NonNull; import java.util.Locale; +import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 37d48957..5052234e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -59,9 +59,9 @@ import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.NetworkState; -import ml.docilealligator.infinityforreddit.Post; -import ml.docilealligator.infinityforreddit.PostDataSource; -import ml.docilealligator.infinityforreddit.PostViewModel; +import ml.docilealligator.infinityforreddit.Post.Post; +import ml.docilealligator.infinityforreddit.Post.PostDataSource; +import ml.docilealligator.infinityforreddit.Post.PostViewModel; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; @@ -318,8 +318,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false); boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false); - PostViewModel.Factory factory; - if (postType == PostDataSource.TYPE_SEARCH) { String subredditName = getArguments().getString(EXTRA_NAME); String query = getArguments().getString(EXTRA_QUERY); @@ -349,13 +347,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); if (accessToken == null) { - factory = new PostViewModel.Factory(mRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, null, getResources().getConfiguration().locale, subredditName, query, postType, - sortType, filter, nsfw); + sortType, filter, nsfw)).get(PostViewModel.class); } else { - factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken, getResources().getConfiguration().locale, subredditName, query, postType, - sortType, filter, nsfw); + sortType, filter, nsfw)).get(PostViewModel.class); } } else if (postType == PostDataSource.TYPE_SUBREDDIT) { String subredditName = getArguments().getString(EXTRA_NAME); @@ -411,13 +409,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); if (accessToken == null) { - factory = new PostViewModel.Factory(mRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, accessToken, getResources().getConfiguration().locale, subredditName, postType, sortType, - filter, nsfw); + filter, nsfw)).get(PostViewModel.class); } else { - factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken, getResources().getConfiguration().locale, subredditName, postType, sortType, - filter, nsfw); + filter, nsfw)).get(PostViewModel.class); } } else if(postType == PostDataSource.TYPE_MULTI_REDDIT) { String multiRedditPath = getArguments().getString(EXTRA_NAME); @@ -459,13 +457,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); if (accessToken == null) { - factory = new PostViewModel.Factory(mRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, null, getResources().getConfiguration().locale, multiRedditPath, postType, sortType, - filter, nsfw); + filter, nsfw)).get(PostViewModel.class); } else { - factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken, getResources().getConfiguration().locale, multiRedditPath, postType, sortType, - filter, nsfw); + filter, nsfw)).get(PostViewModel.class); } } else if (postType == PostDataSource.TYPE_USER) { String username = getArguments().getString(EXTRA_USER_NAME); @@ -506,13 +504,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { }); if (accessToken == null) { - factory = new PostViewModel.Factory(mRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, accessToken, getResources().getConfiguration().locale, username, postType, sortType, where, - filter, nsfw); + filter, nsfw)).get(PostViewModel.class); } else { - factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken, getResources().getConfiguration().locale, username, postType, sortType, where, - filter, nsfw); + filter, nsfw)).get(PostViewModel.class); } } else { String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name()); @@ -543,13 +541,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } }); - factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, - getResources().getConfiguration().locale, postType, sortType, filter, nsfw); + mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken, + getResources().getConfiguration().locale, postType, sortType, filter, nsfw)).get(PostViewModel.class); } mPostRecyclerView.setAdapter(mAdapter); - - mPostViewModel = new ViewModelProvider(this, factory).get(PostViewModel.class); mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts)); mPostViewModel.hasPost().observe(this, hasPost -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkState.java b/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkState.java index 264fea2f..319de6b2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkState.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkState.java @@ -1,8 +1,8 @@ package ml.docilealligator.infinityforreddit; public class NetworkState { - static final NetworkState LOADED; - static final NetworkState LOADING; + public static final NetworkState LOADED; + public static final NetworkState LOADING; static { LOADED = new NetworkState(Status.SUCCESS, "Success"); @@ -12,7 +12,7 @@ public class NetworkState { private final Status status; private final String msg; - NetworkState(Status status, String msg) { + public NetworkState(Status status, String msg) { this.status = status; this.msg = msg; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index 2cdf4be1..25a0e1cd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -13,6 +13,7 @@ import java.util.Calendar; import java.util.Locale; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; +import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; @@ -21,8 +22,8 @@ import ml.docilealligator.infinityforreddit.Utils.Utils; */ public class ParsePost { - static void parsePosts(String response, Locale locale, int nPosts, int filter, boolean nsfw, - ParsePostsListingListener parsePostsListingListener) { + public static void parsePosts(String response, Locale locale, int nPosts, int filter, boolean nsfw, + ParsePostsListingListener parsePostsListingListener) { new ParsePostDataAsyncTask(response, locale, nPosts, filter, nsfw, parsePostsListingListener).execute(); } @@ -284,7 +285,7 @@ public class ParsePost { return post; } - interface ParsePostsListingListener { + public interface ParsePostsListingListener { void onParsePostsListingSuccess(ArrayList<Post> newPostData, String lastItem); void onParsePostsListingFail(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java index 58c1ccea..e16893c2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Post; import android.os.Parcel; import android.os.Parcelable; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java index 7244cb85..19536c47 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Post; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; @@ -7,6 +7,10 @@ import androidx.paging.PageKeyedDataSource; import java.util.ArrayList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.ParsePost; +import ml.docilealligator.infinityforreddit.RedditAPI; +import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import retrofit2.Call; import retrofit2.Callback; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSourceFactory.java index 568efbf0..eb953d7d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSourceFactory.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Post; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; @@ -6,6 +6,7 @@ import androidx.paging.DataSource; import java.util.Locale; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; class PostDataSourceFactory extends DataSource.Factory { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostViewModel.java index ffba16c7..6c7464d3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostViewModel.java @@ -1,4 +1,4 @@ -package ml.docilealligator.infinityforreddit; +package ml.docilealligator.infinityforreddit.Post; import androidx.annotation.NonNull; import androidx.core.util.Pair; @@ -13,6 +13,8 @@ import androidx.paging.PagedList; import java.util.Locale; +import ml.docilealligator.infinityforreddit.NetworkState; +import ml.docilealligator.infinityforreddit.SortType; import retrofit2.Retrofit; public class PostViewModel extends ViewModel { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java index 2b6ad9ce..0fd5e8dc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java @@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent; import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.NotificationUtils; -import ml.docilealligator.infinityforreddit.Post; +import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SubmitPost; import retrofit2.Retrofit; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java index ace57b38..6a93edf1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import ml.docilealligator.infinityforreddit.Post.Post; import ml.docilealligator.infinityforreddit.Utils.JSONUtils; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import okhttp3.MediaType; |