[Android] Save current framgment ID on rotation
Geoffrey Métais
git at videolan.org
Tue Feb 10 12:34:38 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 10 12:33:23 2015 +0100| [cceb98ea461ec4a49dbde4d3c204063bc3a1515f] | committer: Geoffrey Métais
Save current framgment ID on rotation
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=cceb98ea461ec4a49dbde4d3c204063bc3a1515f
---
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 11 +++++++++++
vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java | 3 ++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index b0570df..804f558 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -214,6 +214,12 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
mSidebarAdapter = new SidebarAdapter(this);
mListView.setAdapter(mSidebarAdapter);
+ if (savedInstanceState != null){
+ mCurrentFragment = savedInstanceState.getString("current");
+ if (mCurrentFragment != null)
+ mSidebarAdapter.setCurrentFragment(mCurrentFragment);
+ }
+
/* Initialize UI variables */
mInfoLayout = v_main.findViewById(R.id.info_layout);
@@ -365,6 +371,11 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
mFocusedPrior = 0;
}
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString("current", mCurrentFragment);
+ }
+
@Override
protected void onDestroy() {
super.onDestroy();
diff --git a/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java b/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java
index 4daf635..913fa31 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java
@@ -35,6 +35,7 @@ import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment;
+import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -131,7 +132,7 @@ public class SidebarAdapter extends BaseAdapter {
textView.setCompoundDrawables(img, null, null, null);
}
// Set in bold the current item.
- if (mCurrentFragmentId.equals(sidebarEntry.id))
+ if (TextUtils.equals(mCurrentFragmentId,sidebarEntry.id))
textView.setTypeface(null, Typeface.BOLD);
else
textView.setTypeface(null, Typeface.NORMAL);
More information about the Android
mailing list