[Android] Scroll current pref fragment to top
Geoffrey Métais
git at videolan.org
Thu Mar 9 17:13:55 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 9 17:12:24 2017 +0100| [42185cf878337ce5852e77bf95bfd8fc02505750] | committer: Geoffrey Métais
Scroll current pref fragment to top
Close #228
> https://code.videolan.org/videolan/vlc-android/commit/42185cf878337ce5852e77bf95bfd8fc02505750
---
vlc-android/res/layout/preferences_activity.xml | 1 +
.../org/videolan/vlc/gui/preferences/BasePreferenceFragment.java | 4 ++--
.../src/org/videolan/vlc/gui/preferences/PreferencesActivity.java | 7 +++++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/vlc-android/res/layout/preferences_activity.xml b/vlc-android/res/layout/preferences_activity.xml
index b32ed3d..5e25f59 100644
--- a/vlc-android/res/layout/preferences_activity.xml
+++ b/vlc-android/res/layout/preferences_activity.xml
@@ -7,6 +7,7 @@
<include layout="@layout/toolbar"/>
<android.support.v4.widget.NestedScrollView
+ android:id="@+id/nestedscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
vlc:layout_behavior="@string/appbar_scrolling_view_behavior" >
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java b/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java
index 7f0c7e2..5773c60 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java
@@ -27,7 +27,6 @@ import android.os.Bundle;
import android.support.v14.preference.MultiSelectListPreference;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
@@ -50,7 +49,8 @@ public abstract class BasePreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onStart() {
super.onStart();
- final AppCompatActivity activity = (AppCompatActivity)getActivity();
+ final PreferencesActivity activity = (PreferencesActivity)getActivity();
+ activity.scrollUp();
if (activity != null && activity.getSupportActionBar() != null) {
activity.getSupportActionBar().setTitle(getString(getTitleId()));
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
index af4c665..990f940 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
@@ -55,6 +56,7 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
private PlaybackService.Client mClient = new PlaybackService.Client(this, this);
private PlaybackService mService;
+ private NestedScrollView nestedScrollView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -70,6 +72,11 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
.replace(R.id.fragment_placeholder, new PreferencesFragment())
.commit();
}
+ nestedScrollView = (NestedScrollView) findViewById(R.id.nestedscrollview);
+ }
+
+ void scrollUp() {
+ nestedScrollView.scrollTo(0,0);
}
@Override
More information about the Android
mailing list