Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume scroll position #429

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

wakwak3125
Copy link

Issue

Overview (Required)

  • Save the last position to SharedPreferences.

Links

Screenshot

Before After

@@ -68,4 +68,8 @@ public Context getContext() {
return context;
}

@Override
public Iterator<T> iterator() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Android Lint] reported by reviewdog 🐶
error: cannot find symbol

@@ -116,6 +121,9 @@ public void onResume() {
@Override
public void onStop() {
super.onStop();
int position = binding.recyclerView.getFirstVisiblePosition();
Log.d(TAG, "onStop: " + position);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Android Lint] reported by reviewdog 🐶
Error: Using 'Log' instead of 'Timber' [LogNotTimber]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

@@ -116,6 +121,8 @@ public void onResume() {
@Override
public void onStop() {
super.onStop();
int position = binding.recyclerView.getFirstVisiblePosition();
sharedPreferences.edit().putInt("last_position", position).apply();
Copy link
Contributor

@konifar konifar Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this app uses kvs-schema.
So you can use auto generated method to access shared preferences.
Can you follow the steps below?

1. Add key to DefaultPrefsSchema

@Table(name = "io.github.droidkaigi.confsched_preferences")
public interface DefaultPrefsSchema {
    ...
    @Key(name = "last_sessions_view_position")
    int lastSessionsViewPosition;
}

2. Use generated method.

DefaultPrefs prefs = DefaultPrefs.get(context);
int lastPosition = prefs.getLastSessionsViewPosition();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK! Thank you 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants