Open drawer on first launch

This commit is contained in:
daniel oeh 2014-05-17 14:58:21 +02:00
parent 2186055c2d
commit 583361b19f
1 changed files with 22 additions and 0 deletions

View File

@ -1,11 +1,13 @@
package de.danoeh.antennapod.activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.media.AudioManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@ -40,6 +42,9 @@ public class MainActivity extends ActionBarActivity {
| EventDistributor.FEED_LIST_UPDATE
| EventDistributor.UNREAD_ITEMS_UPDATE;
private static final String PREF_NAME = "MainActivityPrefs";
private static final String PREF_IS_FIRST_LAUNCH = "prefMainActivityIsFirstLaunch";
public static final String EXTRA_NAV_INDEX = "nav_index";
public static final String EXTRA_NAV_TYPE = "nav_type";
public static final String EXTRA_FRAGMENT_ARGS = "fragment_args";
@ -119,6 +124,23 @@ public class MainActivity extends ActionBarActivity {
navList.setAdapter(navAdapter);
navList.setOnItemClickListener(navListClickListener);
checkFirstLaunch();
}
private void checkFirstLaunch() {
SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
if (prefs.getBoolean(PREF_IS_FIRST_LAUNCH, true)) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
drawerLayout.openDrawer(navList);
}
}, 1500);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(PREF_IS_FIRST_LAUNCH, false);
edit.commit();
}
}
public ActionBar getMainActivtyActionBar() {