mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +01:00
Long press the toolbar to go to top.
This commit is contained in:
parent
a9d2108c00
commit
8311507acd
@ -25,6 +25,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||
@ -40,7 +41,8 @@ import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||
|
||||
public class AccountPostsActivity extends BaseActivity implements SortTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
public class AccountPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
||||
|
||||
static final String EXTRA_USER_WHERE = "EUW";
|
||||
|
||||
@ -118,6 +120,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||
|
||||
@ -288,4 +291,11 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
|
||||
((FragmentCommunicator) mFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mFragment != null) {
|
||||
((PostFragment) mFragment).goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||
@ -43,7 +44,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class AccountSavedThingActivity extends BaseActivity {
|
||||
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||
private static final String ACCESS_TOKEN_STATE = "ATS";
|
||||
@ -109,6 +110,7 @@ public class AccountSavedThingActivity extends BaseActivity {
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||
|
||||
@ -275,6 +277,13 @@ public class AccountSavedThingActivity extends BaseActivity {
|
||||
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
private PostFragment postFragment;
|
||||
private CommentsListingFragment commentsListingFragment;
|
||||
@ -383,5 +392,13 @@ public class AccountSavedThingActivity extends BaseActivity {
|
||||
postFragment.changeNSFW(nsfw);
|
||||
}
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
postFragment.goBackToTop();
|
||||
} else {
|
||||
commentsListingFragment.goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
|
||||
import ml.docilealligator.infinityforreddit.ContentFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
@ -183,6 +184,18 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
return immersiveInterface;
|
||||
}
|
||||
|
||||
protected void setToolbarGoToTop(Toolbar toolbar) {
|
||||
toolbar.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
if (BaseActivity.this instanceof ActivityToolbarInterface) {
|
||||
((ActivityToolbarInterface) BaseActivity.this).onLongPress();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void adjustToolbar(Toolbar toolbar) {
|
||||
int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (statusBarResourceId > 0) {
|
||||
|
@ -25,6 +25,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||
@ -45,7 +46,7 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||
|
||||
public class FilteredThingActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_NAME = "ESN";
|
||||
public static final String EXTRA_QUERY = "EQ";
|
||||
@ -123,6 +124,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||
|
||||
@ -429,4 +431,11 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
||||
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mFragment != null) {
|
||||
((PostFragment) mFragment).goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.Account.AccountViewModel;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.NavigationDrawerRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
||||
@ -97,7 +98,8 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
|
||||
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
|
||||
|
||||
public class MainActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
||||
ActivityToolbarInterface {
|
||||
|
||||
static final String EXTRA_POST_TYPE = "EPT";
|
||||
static final String EXTRA_MESSSAGE_FULLNAME = "ENF";
|
||||
@ -247,6 +249,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
drawer = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
@ -921,6 +924,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
mLockBottomAppBar = changeLockBottomAppBarEvent.lockBottomAppBar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
private PostFragment tab1;
|
||||
private PostFragment tab2;
|
||||
@ -1341,5 +1351,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
tab1.goBackToTop();
|
||||
} else if (viewPager.getCurrentItem() == 1) {
|
||||
tab2.goBackToTop();
|
||||
} else {
|
||||
tab3.goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||
@ -51,7 +52,7 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||
|
||||
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
||||
static final String EXTRA_QUERY = "QK";
|
||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
|
||||
@ -121,6 +122,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
getCurrentAccountAndInitializeViewPager();
|
||||
@ -295,6 +297,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private PostFragment postFragment;
|
||||
@ -417,7 +426,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
}
|
||||
}
|
||||
|
||||
public void changeNSFW(boolean nsfw) {
|
||||
void changeNSFW(boolean nsfw) {
|
||||
if (postFragment != null) {
|
||||
postFragment.changeNSFW(nsfw);
|
||||
}
|
||||
@ -429,5 +438,15 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
||||
void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
postFragment.goBackToTop();
|
||||
} else if (viewPager.getCurrentItem() == 1) {
|
||||
subredditListingFragment.goBackToTop();
|
||||
} else {
|
||||
userListingFragment.goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||
@ -32,7 +33,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
|
||||
public class SearchSubredditsResultActivity extends BaseActivity {
|
||||
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
static final String EXTRA_QUERY = "EQ";
|
||||
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
||||
@ -90,6 +91,7 @@ public class SearchSubredditsResultActivity extends BaseActivity {
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
String query = getIntent().getExtras().getString(EXTRA_QUERY);
|
||||
|
||||
@ -180,4 +182,11 @@ public class SearchSubredditsResultActivity extends BaseActivity {
|
||||
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mFragment != null) {
|
||||
((SubredditListingFragment) mFragment).goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,13 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.SelectedSubredditsRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
|
||||
public class SelectedSubredditsActivity extends BaseActivity {
|
||||
public class SelectedSubredditsActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_SELECTED_SUBREDDITS = "ESS";
|
||||
public static final String EXTRA_RETURN_SELECTED_SUBREDDITS = "ERSS";
|
||||
@ -51,6 +52,7 @@ public class SelectedSubredditsActivity extends BaseActivity {
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
private LinearLayoutManager linearLayoutManager;
|
||||
private SelectedSubredditsRecyclerViewAdapter adapter;
|
||||
private ArrayList<String> subreddits;
|
||||
|
||||
@ -65,6 +67,7 @@ public class SelectedSubredditsActivity extends BaseActivity {
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
subreddits = savedInstanceState.getStringArrayList(SELECTED_SUBREDDITS_STATE);
|
||||
@ -73,7 +76,8 @@ public class SelectedSubredditsActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
adapter = new SelectedSubredditsRecyclerViewAdapter(mCustomThemeWrapper, subreddits);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
linearLayoutManager = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
@ -154,4 +158,11 @@ public class SelectedSubredditsActivity extends BaseActivity {
|
||||
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
||||
applyFABTheme(fab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (linearLayoutManager != null) {
|
||||
linearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.SubredditMultiselectionRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
@ -43,7 +44,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class SubredditMultiselectionActivity extends BaseActivity {
|
||||
public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
static final String EXTRA_RETURN_SELECTED_SUBREDDITS = "ERSS";
|
||||
|
||||
@ -82,6 +83,7 @@ public class SubredditMultiselectionActivity extends BaseActivity {
|
||||
private boolean mNullAccessToken = false;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
private SubredditMultiselectionRecyclerViewAdapter mAdapter;
|
||||
private RequestManager mGlide;
|
||||
@Override
|
||||
@ -149,7 +151,8 @@ public class SubredditMultiselectionActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mLinearLayoutManager = new LinearLayoutManager(this);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
mAdapter = new SubredditMultiselectionRecyclerViewAdapter(this, mCustomThemeWrapper);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
|
||||
@ -240,4 +243,11 @@ public class SubredditMultiselectionActivity extends BaseActivity {
|
||||
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
|
||||
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
@ -42,7 +43,7 @@ import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.Subscrib
|
||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class SubredditSelectionActivity extends BaseActivity {
|
||||
public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
|
||||
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
||||
@ -274,4 +275,11 @@ public class SubredditSelectionActivity extends BaseActivity {
|
||||
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mFragment != null) {
|
||||
((SubscribedSubredditsListingFragment) mFragment).goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
@ -46,7 +47,7 @@ import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.Subscrib
|
||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class SubscribedThingListingActivity extends BaseActivity {
|
||||
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
|
||||
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||
@ -108,6 +109,7 @@ public class SubscribedThingListingActivity extends BaseActivity {
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
|
||||
@ -225,6 +227,13 @@ public class SubscribedThingListingActivity extends BaseActivity {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private SubscribedSubredditsListingFragment subscribedSubredditsListingFragment;
|
||||
@ -287,7 +296,7 @@ public class SubscribedThingListingActivity extends BaseActivity {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void stopRefreshProgressbar() {
|
||||
void stopRefreshProgressbar() {
|
||||
if (subscribedSubredditsListingFragment != null) {
|
||||
((FragmentCommunicator) subscribedSubredditsListingFragment).stopRefreshProgressbar();
|
||||
}
|
||||
@ -295,5 +304,13 @@ public class SubscribedThingListingActivity extends BaseActivity {
|
||||
((FragmentCommunicator) followedUsersListingFragment).stopRefreshProgressbar();
|
||||
}
|
||||
}
|
||||
|
||||
void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
subscribedSubredditsListingFragment.goBackToTop();
|
||||
} else {
|
||||
followedUsersListingFragment.goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.MessageRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
||||
@ -48,7 +49,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewMessageActivity extends BaseActivity {
|
||||
public class ViewMessageActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||
|
||||
@ -90,6 +91,7 @@ public class ViewMessageActivity extends BaseActivity {
|
||||
private String mNewAccountName;
|
||||
private MessageRecyclerViewAdapter mAdapter;
|
||||
private RequestManager mGlide;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -127,6 +129,7 @@ public class ViewMessageActivity extends BaseActivity {
|
||||
|
||||
mToolbar.setTitle(R.string.inbox);
|
||||
setSupportActionBar(mToolbar);
|
||||
setToolbarGoToTop(mToolbar);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||
@ -199,10 +202,10 @@ public class ViewMessageActivity extends BaseActivity {
|
||||
private void bindView() {
|
||||
mAdapter = new MessageRecyclerViewAdapter(this, mOauthRetrofit, mCustomThemeWrapper,
|
||||
mAccessToken, () -> mMessageViewModel.retryLoadingMore());
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mLinearLayoutManager = new LinearLayoutManager(this);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, layoutManager.getOrientation());
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, mLinearLayoutManager.getOrientation());
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
MessageViewModel.Factory factory = new MessageViewModel.Factory(mOauthRetrofit,
|
||||
@ -296,4 +299,11 @@ public class ViewMessageActivity extends BaseActivity {
|
||||
private void onRefresh() {
|
||||
mMessageViewModel.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Event.RefreshMultiRedditsEvent;
|
||||
@ -46,7 +47,7 @@ import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewMultiRedditDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_MULTIREDDIT_DATA = "EMD";
|
||||
public static final String EXTRA_MULTIREDDIT_PATH = "EMP";
|
||||
@ -136,6 +137,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||
@ -337,4 +339,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mFragment != null) {
|
||||
((PostFragment) mFragment).goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ import butterknife.ButterKnife;
|
||||
import im.ene.toro.exoplayer.ExoCreator;
|
||||
import im.ene.toro.media.PlaybackInfo;
|
||||
import im.ene.toro.media.VolumeInfo;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.CommentAndPostRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
||||
@ -98,7 +99,7 @@ import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.RETU
|
||||
import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.WRITE_COMMENT_REQUEST_CODE;
|
||||
|
||||
public class ViewPostDetailActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||
SortTypeSelectionCallback {
|
||||
SortTypeSelectionCallback, ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_POST_DATA = "EPD";
|
||||
public static final String EXTRA_POST_LIST_POSITION = "EPLI";
|
||||
@ -242,6 +243,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
||||
|
||||
mToolbar.setTitle("");
|
||||
setSupportActionBar(mToolbar);
|
||||
setToolbarGoToTop(mToolbar);
|
||||
|
||||
mVolumeKeysNavigateComments = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOLUME_KEYS_NAVIGATE_COMMENTS, false);
|
||||
mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
|
||||
@ -1629,4 +1631,11 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
||||
mSlidrInterface.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import io.noties.markwon.recycler.table.TableEntry;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.FetchSubredditData;
|
||||
@ -53,7 +54,7 @@ import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
||||
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewSidebarActivity extends BaseActivity {
|
||||
public class ViewSidebarActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
@BindView(R.id.coordinator_layout_view_sidebar_activity)
|
||||
@ -77,6 +78,7 @@ public class ViewSidebarActivity extends BaseActivity {
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
public SubredditViewModel mSubredditViewModel;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
private String subredditName;
|
||||
private int markdownColor;
|
||||
|
||||
@ -123,6 +125,7 @@ public class ViewSidebarActivity extends BaseActivity {
|
||||
toolbar.setTitle("r/" + subredditName);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
Markwon markwon = Markwon.builder(this)
|
||||
.usePlugin(new AbstractMarkwonPlugin() {
|
||||
@ -161,7 +164,8 @@ public class ViewSidebarActivity extends BaseActivity {
|
||||
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
|
||||
.build();
|
||||
|
||||
markdownRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mLinearLayoutManager = new LinearLayoutManager(this);
|
||||
markdownRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
markdownRecyclerView.setAdapter(markwonAdapter);
|
||||
|
||||
mSubredditViewModel = new ViewModelProvider(this,
|
||||
@ -237,4 +241,11 @@ public class ViewSidebarActivity extends BaseActivity {
|
||||
swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
|
||||
markdownColor = mCustomThemeWrapper.getSecondaryTextColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsSubscribedToSubredditAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
@ -81,7 +82,8 @@ import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewSubredditDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback,
|
||||
ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_SUBREDDIT_NAME_KEY = "ESN";
|
||||
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
|
||||
@ -327,6 +329,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
toolbar.setTitle(title);
|
||||
adjustToolbar(toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
glide = Glide.with(this);
|
||||
Locale locale = getResources().getConfiguration().locale;
|
||||
@ -843,6 +846,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
private PostFragment postFragment;
|
||||
private SidebarFragment sidebarFragment;
|
||||
@ -965,5 +975,17 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
||||
void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
if (postFragment != null) {
|
||||
postFragment.goBackToTop();
|
||||
}
|
||||
} else {
|
||||
if (sidebarFragment != null) {
|
||||
sidebarFragment.goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
@ -81,7 +82,7 @@ import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ViewUserDetailActivity extends BaseActivity implements SortTypeSelectionCallback,
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface {
|
||||
|
||||
public static final String EXTRA_USER_NAME_KEY = "EUNK";
|
||||
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
|
||||
@ -220,6 +221,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
toolbar.setTitle(title);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
setToolbarGoToTop(toolbar);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Window window = getWindow();
|
||||
@ -711,6 +713,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.goBackToTop();
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private UserDao userDao;
|
||||
@ -876,5 +885,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
((FragmentCommunicator) postFragment).changePostLayout(postLayout);
|
||||
}
|
||||
}
|
||||
|
||||
void goBackToTop() {
|
||||
if (viewPager.getCurrentItem() == 0) {
|
||||
if (postFragment != null) {
|
||||
postFragment.goBackToTop();
|
||||
}
|
||||
} else {
|
||||
if (commentsListingFragment != null) {
|
||||
commentsListingFragment.goBackToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package ml.docilealligator.infinityforreddit;
|
||||
|
||||
public interface ActivityToolbarInterface {
|
||||
void onLongPress();
|
||||
}
|
@ -95,6 +95,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
private String mAccessToken;
|
||||
private RequestManager mGlide;
|
||||
private Activity mActivity;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
private CommentsListingRecyclerViewAdapter mAdapter;
|
||||
private boolean mShowElapsedTime;
|
||||
private boolean mShowCommentDivider;
|
||||
@ -162,7 +163,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
}
|
||||
|
||||
private void bindView(Resources resources) {
|
||||
mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
||||
mCommentRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
|
||||
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||
mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper,
|
||||
@ -265,4 +267,10 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
mGlide.load(R.drawable.error_image).into(mFetchCommentInfoImageView);
|
||||
}
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
|
||||
SubscribedUserViewModel mSubscribedUserViewModel;
|
||||
private Activity mActivity;
|
||||
private RequestManager mGlide;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
|
||||
public FollowedUsersListingFragment() {
|
||||
// Required empty public constructor
|
||||
@ -104,7 +105,8 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
|
||||
|
||||
mGlide = Glide.with(this);
|
||||
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity,
|
||||
mOauthRetrofit, mRedditDataRoomDatabase, customThemeWrapper,
|
||||
getArguments().getString(EXTRA_ACCESS_TOKEN));
|
||||
@ -164,4 +166,10 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
|
||||
}
|
||||
mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -923,6 +923,20 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
if (isInLazyMode) {
|
||||
lazyModeRunnable.resetOldPosition();
|
||||
}
|
||||
} else if (mStaggeredGridLayoutManager != null) {
|
||||
mStaggeredGridLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
if (isInLazyMode) {
|
||||
lazyModeRunnable.resetOldPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
@ -63,6 +63,7 @@ public class SidebarFragment extends Fragment {
|
||||
private Activity activity;
|
||||
private String subredditName;
|
||||
public SubredditViewModel mSubredditViewModel;
|
||||
private LinearLayoutManager linearLayoutManager;
|
||||
private int markdownColor;
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
@ -133,7 +134,8 @@ public class SidebarFragment extends Fragment {
|
||||
.textLayoutIsRoot(R.layout.view_table_entry_cell)))
|
||||
.build();
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(activity));
|
||||
linearLayoutManager = new LinearLayoutManager(activity);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
recyclerView.setAdapter(markwonAdapter);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
@ -188,4 +190,10 @@ public class SidebarFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (linearLayoutManager != null) {
|
||||
linearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,4 +221,10 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
||||
mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent());
|
||||
mFetchSubredditListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
public SubscribedSubredditViewModel mSubscribedSubredditViewModel;
|
||||
private Activity mActivity;
|
||||
private RequestManager mGlide;
|
||||
private LinearLayoutManager mLinearLayoutManager;
|
||||
|
||||
public SubscribedSubredditsListingFragment() {
|
||||
// Required empty public constructor
|
||||
@ -110,7 +111,8 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
|
||||
mGlide = Glide.with(this);
|
||||
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
|
||||
SubscribedSubredditsRecyclerViewAdapter adapter;
|
||||
if (getArguments().getBoolean(EXTRA_IS_SUBREDDIT_SELECTION)) {
|
||||
@ -180,4 +182,10 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,4 +201,10 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
||||
mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent());
|
||||
mFetchUserListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
|
||||
}
|
||||
|
||||
public void goBackToTop() {
|
||||
if (mLinearLayoutManager != null) {
|
||||
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user