[Android] MainActivity: order of initialisation

Edward Wang git at videolan.org
Fri Oct 12 01:54:50 CEST 2012


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Oct 11 19:54:15 2012 -0400| [3fa3d5fe401fdf801fde861bff68440150e4af2a] | committer: Edward Wang

MainActivity: order of initialisation

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=3fa3d5fe401fdf801fde861bff68440150e4af2a
---

 .../src/org/videolan/vlc/gui/MainActivity.java     |   44 +++++++++++---------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 0889327..eafc6d6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -110,34 +110,15 @@ public class MainActivity extends SherlockFragmentActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
         if (!Util.hasCompatibleCPU()) {
             Log.e(TAG, Util.getErrorMsg());
             Intent i = new Intent(this, CompatErrorActivity.class);
             startActivity(i);
             finish();
+            super.onCreate(savedInstanceState);
             return;
         }
 
-        /* Enable the indeterminate progress feature */
-        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
-
-        // Set up the sliding menu
-        setContentView(R.layout.sliding_menu);
-        mMenu = (SlidingMenu) findViewById(R.id.sliding_menu);
-        changeMenuOffset();
-
-        View v_main = LayoutInflater.from(this).inflate(R.layout.main, null);
-        mMenu.setContent(v_main);
-
-        View sidebar = LayoutInflater.from(this).inflate(R.layout.sidebar, null);
-        final ListView listView = (ListView)sidebar.findViewById(android.R.id.list);
-        listView.setFooterDividersEnabled(true);
-        mSidebarAdapter = new SidebarAdapter();
-        listView.setAdapter(mSidebarAdapter);
-        mMenu.setMenu(sidebar);
-
         /* Get the current version from package */
         PackageInfo pinfo = null;
         try {
@@ -172,9 +153,32 @@ public class MainActivity extends SherlockFragmentActivity {
             i.putExtra("message", "LibVLC failed to initialize (LibVlcException)");
             startActivity(i);
             finish();
+            super.onCreate(savedInstanceState);
             return;
         }
 
+        super.onCreate(savedInstanceState);
+
+        /*** Start initializing the UI ***/
+
+        /* Enable the indeterminate progress feature */
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+
+        // Set up the sliding menu
+        setContentView(R.layout.sliding_menu);
+        mMenu = (SlidingMenu) findViewById(R.id.sliding_menu);
+        changeMenuOffset();
+
+        View v_main = LayoutInflater.from(this).inflate(R.layout.main, null);
+        mMenu.setContent(v_main);
+
+        View sidebar = LayoutInflater.from(this).inflate(R.layout.sidebar, null);
+        final ListView listView = (ListView)sidebar.findViewById(android.R.id.list);
+        listView.setFooterDividersEnabled(true);
+        mSidebarAdapter = new SidebarAdapter();
+        listView.setAdapter(mSidebarAdapter);
+        mMenu.setMenu(sidebar);
+
         /* Initialize UI variables */
         mInfoLayout = v_main.findViewById(R.id.info_layout);
         mInfoProgress = (ProgressBar) v_main.findViewById(R.id.info_progress);



More information about the Android mailing list