mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-14 06:22:50 +01:00
Fix the fab in MainActivity shows in wrong places. Put all classes related to Post to Package Post.
This commit is contained in:
parent
4d6782107d
commit
a143501f9f
@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
@ -40,7 +40,7 @@ import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment;
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
@ -38,8 +38,8 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
@ -85,7 +85,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo;
|
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.PullNotificationWorker;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.ReadMessage;
|
||||||
@ -211,6 +211,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
private String mNewAccountName;
|
private String mNewAccountName;
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
|
private boolean showBottomAppBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -310,6 +311,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||||
|
|
||||||
|
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||||
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
|
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
|
||||||
@ -454,7 +457,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
bottomNavigationView.setVisibility(View.GONE);
|
bottomNavigationView.setVisibility(View.GONE);
|
||||||
fab.setVisibility(View.GONE);
|
fab.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false)) {
|
if (showBottomAppBar) {
|
||||||
bottomNavigationView.setVisibility(View.VISIBLE);
|
bottomNavigationView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
||||||
@ -489,8 +492,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
bottomNavigationView.performShow();
|
if (mAccessToken != null && showBottomAppBar) {
|
||||||
fab.show();
|
bottomNavigationView.performShow();
|
||||||
|
fab.show();
|
||||||
|
}
|
||||||
if (isInLazyMode) {
|
if (isInLazyMode) {
|
||||||
if (position == sectionsPagerAdapter.getCurrentLazyModeFragmentPosition()) {
|
if (position == sectionsPagerAdapter.getCurrentLazyModeFragmentPosition()) {
|
||||||
sectionsPagerAdapter.resumeLazyMode();
|
sectionsPagerAdapter.resumeLazyMode();
|
||||||
@ -943,14 +948,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void postScrollUp() {
|
public void postScrollUp() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null && showBottomAppBar) {
|
||||||
bottomNavigationView.performShow();
|
bottomNavigationView.performShow();
|
||||||
fab.show();
|
fab.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postScrollDown() {
|
public void postScrollDown() {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null && showBottomAppBar) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
bottomNavigationView.performHide();
|
bottomNavigationView.performHide();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment
|
|||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
|
@ -72,7 +72,7 @@ import ml.docilealligator.infinityforreddit.HidePost;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.ParseComment;
|
import ml.docilealligator.infinityforreddit.ParseComment;
|
||||||
import ml.docilealligator.infinityforreddit.ParsePost;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.RedditAPI;
|
||||||
|
@ -55,7 +55,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
@ -61,7 +61,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.UserThingSortTypeBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
@ -76,8 +76,8 @@ import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
|
|||||||
import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager;
|
import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager;
|
||||||
import ml.docilealligator.infinityforreddit.FetchComment;
|
import ml.docilealligator.infinityforreddit.FetchComment;
|
||||||
import ml.docilealligator.infinityforreddit.Fragment.ModifyCommentBottomSheetFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.ModifyCommentBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
|
@ -55,8 +55,8 @@ import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
|
|||||||
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
|
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
|
||||||
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
|
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
|
@ -14,6 +14,7 @@ import org.json.JSONObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Event;
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
|
|
||||||
public class PostUpdateEventToDetailActivity {
|
public class PostUpdateEventToDetailActivity {
|
||||||
public final Post post;
|
public final Post post;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Event;
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
|
|
||||||
public class PostUpdateEventToPostList {
|
public class PostUpdateEventToPostList {
|
||||||
public final Post post;
|
public final Post post;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Event;
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
|
|
||||||
public class SubmitTextOrLinkPostEvent {
|
public class SubmitTextOrLinkPostEvent {
|
||||||
public boolean postSuccess;
|
public boolean postSuccess;
|
||||||
|
@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -59,9 +59,9 @@ import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
|
|||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.PostViewModel;
|
import ml.docilealligator.infinityforreddit.Post.PostViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
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 voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||||
boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
|
|
||||||
PostViewModel.Factory factory;
|
|
||||||
|
|
||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
String subredditName = getArguments().getString(EXTRA_NAME);
|
String subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
String query = getArguments().getString(EXTRA_QUERY);
|
String query = getArguments().getString(EXTRA_QUERY);
|
||||||
@ -349,13 +347,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
factory = new PostViewModel.Factory(mRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, null,
|
||||||
getResources().getConfiguration().locale, subredditName, query, postType,
|
getResources().getConfiguration().locale, subredditName, query, postType,
|
||||||
sortType, filter, nsfw);
|
sortType, filter, nsfw)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, subredditName, query, postType,
|
getResources().getConfiguration().locale, subredditName, query, postType,
|
||||||
sortType, filter, nsfw);
|
sortType, filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
||||||
String subredditName = getArguments().getString(EXTRA_NAME);
|
String subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
@ -411,13 +409,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
factory = new PostViewModel.Factory(mRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, subredditName, postType, sortType,
|
getResources().getConfiguration().locale, subredditName, postType, sortType,
|
||||||
filter, nsfw);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, subredditName, postType, sortType,
|
getResources().getConfiguration().locale, subredditName, postType, sortType,
|
||||||
filter, nsfw);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
} else if(postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
} else if(postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
||||||
String multiRedditPath = getArguments().getString(EXTRA_NAME);
|
String multiRedditPath = getArguments().getString(EXTRA_NAME);
|
||||||
@ -459,13 +457,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
factory = new PostViewModel.Factory(mRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mRetrofit, null,
|
||||||
getResources().getConfiguration().locale, multiRedditPath, postType, sortType,
|
getResources().getConfiguration().locale, multiRedditPath, postType, sortType,
|
||||||
filter, nsfw);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, multiRedditPath, postType, sortType,
|
getResources().getConfiguration().locale, multiRedditPath, postType, sortType,
|
||||||
filter, nsfw);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
} else if (postType == PostDataSource.TYPE_USER) {
|
} else if (postType == PostDataSource.TYPE_USER) {
|
||||||
String username = getArguments().getString(EXTRA_USER_NAME);
|
String username = getArguments().getString(EXTRA_USER_NAME);
|
||||||
@ -506,13 +504,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (accessToken == null) {
|
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,
|
getResources().getConfiguration().locale, username, postType, sortType, where,
|
||||||
filter, nsfw);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, username, postType, sortType, where,
|
getResources().getConfiguration().locale, username, postType, sortType, where,
|
||||||
filter, nsfw);
|
filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name());
|
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,
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, postType, sortType, filter, nsfw);
|
getResources().getConfiguration().locale, postType, sortType, filter, nsfw)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostRecyclerView.setAdapter(mAdapter);
|
mPostRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
mPostViewModel = new ViewModelProvider(this, factory).get(PostViewModel.class);
|
|
||||||
mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts));
|
mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts));
|
||||||
|
|
||||||
mPostViewModel.hasPost().observe(this, hasPost -> {
|
mPostViewModel.hasPost().observe(this, hasPost -> {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
public class NetworkState {
|
public class NetworkState {
|
||||||
static final NetworkState LOADED;
|
public static final NetworkState LOADED;
|
||||||
static final NetworkState LOADING;
|
public static final NetworkState LOADING;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
LOADED = new NetworkState(Status.SUCCESS, "Success");
|
LOADED = new NetworkState(Status.SUCCESS, "Success");
|
||||||
@ -12,7 +12,7 @@ public class NetworkState {
|
|||||||
private final Status status;
|
private final Status status;
|
||||||
private final String msg;
|
private final String msg;
|
||||||
|
|
||||||
NetworkState(Status status, String msg) {
|
public NetworkState(Status status, String msg) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.util.Calendar;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
|
|
||||||
@ -21,8 +22,8 @@ import ml.docilealligator.infinityforreddit.Utils.Utils;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class ParsePost {
|
public class ParsePost {
|
||||||
static void parsePosts(String response, Locale locale, int nPosts, int filter, boolean nsfw,
|
public static void parsePosts(String response, Locale locale, int nPosts, int filter, boolean nsfw,
|
||||||
ParsePostsListingListener parsePostsListingListener) {
|
ParsePostsListingListener parsePostsListingListener) {
|
||||||
new ParsePostDataAsyncTask(response, locale, nPosts, filter, nsfw, parsePostsListingListener).execute();
|
new ParsePostDataAsyncTask(response, locale, nPosts, filter, nsfw, parsePostsListingListener).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +285,7 @@ public class ParsePost {
|
|||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParsePostsListingListener {
|
public interface ParsePostsListingListener {
|
||||||
void onParsePostsListingSuccess(ArrayList<Post> newPostData, String lastItem);
|
void onParsePostsListingSuccess(ArrayList<Post> newPostData, String lastItem);
|
||||||
|
|
||||||
void onParsePostsListingFail();
|
void onParsePostsListingFail();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Post;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Post;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
@ -7,6 +7,10 @@ import androidx.paging.PageKeyedDataSource;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
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 ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Post;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
@ -6,6 +6,7 @@ import androidx.paging.DataSource;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
class PostDataSourceFactory extends DataSource.Factory {
|
class PostDataSourceFactory extends DataSource.Factory {
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.Post;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.util.Pair;
|
import androidx.core.util.Pair;
|
||||||
@ -13,6 +13,8 @@ import androidx.paging.PagedList;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class PostViewModel extends ViewModel {
|
public class PostViewModel extends ViewModel {
|
@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
|
|||||||
import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent;
|
import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.NotificationUtils;
|
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.R;
|
||||||
import ml.docilealligator.infinityforreddit.SubmitPost;
|
import ml.docilealligator.infinityforreddit.SubmitPost;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
@ -20,6 +20,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
Loading…
Reference in New Issue
Block a user