Example usage for android.content SharedPreferences contains

List of usage examples for android.content SharedPreferences contains

Introduction

In this page you can find the example usage for android.content SharedPreferences contains.

Prototype

boolean contains(String key);

Source Link

Document

Checks whether the preferences contains a preference.

Usage

From source file:com.krayzk9s.imgurholo.activities.MainActivity.java

private void loadDefaultPage() {
    SharedPreferences settings = getSettings();
    if (!apiCall.loggedin || !settings.contains("DefaultPage")
            || settings.getString("DefaultPage", "").equals("Gallery")) {
        selectItem(0);/*from w ww. j a  va 2s  . com*/
    } else if (settings.getString("DefaultPage", "").equals("Albums")) {
        selectItem(4);
    } else if (settings.getString("DefaultPage", "").equals("Images")) {
        selectItem(3);
    } else if (settings.getString("DefaultPage", "").equals("Favorites")) {
        selectItem(5);
    } else if (settings.getString("DefaultPage", "").equals("Account")) {
        selectItem(2);
    }
}

From source file:com.ijsbrandslob.appirater.Appirater.java

private void loadSettings() {
    SharedPreferences settings = mContext.getSharedPreferences(mContext.getPackageName(), Context.MODE_PRIVATE);

    // Did we save settings before?
    if (settings.contains(APPIRATER_FIRST_USE_DATE)) {
        long firstUseDate = settings.getLong(APPIRATER_FIRST_USE_DATE, -1);
        if (-1 != firstUseDate) {
            mFirstUseDate = new Date(firstUseDate);
        } else {//  www.  j  av a 2  s.  com
            mFirstUseDate = new Date();
        }

        long reminderRequestDate = settings.getLong(APPIRATER_REMINDER_REQUEST_DATE, -1);
        if (-1 != reminderRequestDate)
            mReminderRequestDate = new Date(reminderRequestDate);

        mUseCount = settings.getInt(APPIRATER_USE_COUNT, 0);
        mSignificantEventCount = settings.getInt(APPIRATER_SIG_EVENT_COUNT, 0);
        mCurrentVersion = settings.getString(APPIRATER_CURRENT_VERSION_NAME, NO_VERSION);
        if (mCurrentVersion == null || mCurrentVersion.equals("")) {
            mCurrentVersion = NO_VERSION;
        }
        mRatedCurrentVersion = settings.getBoolean(APPIRATER_RATED_CURRENT_VERSION, false);
        mDeclinedToRate = settings.getBoolean(APPIRATER_DECLINED_TO_RATE, false);
    } else {
        mCurrentVersion = appVersion();
        mFirstUseDate = new Date();

        if (mConfig.debug)
            System.out.println(String.format("APPIRATER Tracking version: %d", mCurrentVersion));
    }

    if (newAppVersion())
        resetTrackingForNewVersion();
    saveSettings();
}

From source file:com.ubercab.client.feature.notification.handler.TripNotificationHandler.java

public void start() {
      super.start();
      SharedPreferences localSharedPreferences = getPreferences();
      if (localSharedPreferences.contains("trip_last_data"))
          ;/*from w w  w .j a  va 2 s.c  om*/
      try {
          this.mLastData = ((TripNotificationData) this.mGson.fromJson(
                  localSharedPreferences.getString("trip_last_data", null), TripNotificationData.class));
          return;
      } catch (JsonParseException localJsonParseException) {
      }
  }

From source file:com.amsterdam.marktbureau.makkelijkemarkt.LoginFragment.java

/**
 * Set the login fragment layout and initialize the login logic
 * @param inflater inflater object to inflate the layout
 * @param container the parent view container
 * @param savedInstanceState fragment state bundle
 * @return the inflated view//from   w w w .ja va 2s  . c om
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // inflate the login fragment layout
    View mainView = inflater.inflate(R.layout.login_fragment, container, false);

    // bind the elements to the view
    ButterKnife.bind(this, mainView);

    if (savedInstanceState == null) {

        // check if there is a newer build of the app available
        Utility.checkForUpdate(getActivity(), UPDATE_FRAGMENT_TAG, true);

        // TODO: if there is no internet connection and accounts were never loaded: keep checking for an internet connection and try again

        // check time in hours since last fetched the accounts
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
        long diffInHours = getResources()
                .getInteger(R.integer.makkelijkemarkt_api_accounts_fetch_interval_hours);
        if (settings.contains(getContext().getString(R.string.sharedpreferences_key_accounts_last_fetched))) {
            long lastFetchTimestamp = settings
                    .getLong(getContext().getString(R.string.sharedpreferences_key_accounts_last_fetched), 0);
            long differenceMs = new Date().getTime() - lastFetchTimestamp;
            diffInHours = TimeUnit.MILLISECONDS.toHours(differenceMs);
        }

        // update the local accounts by reloading them from the api
        if (diffInHours >= getResources()
                .getInteger(R.integer.makkelijkemarkt_api_accounts_fetch_interval_hours)) {

            // show the progressbar
            mAccountsProgressBar.setVisibility(View.VISIBLE);

            // call the api
            ApiGetAccounts getAccounts = new ApiGetAccounts(getContext());
            if (!getAccounts.enqueue()) {
                mAccountsProgressBar.setVisibility(View.GONE);
            }
        }
    }

    // create an adapter for the account spinner
    mAccountsAdapter = new SimpleCursorAdapter(getContext(), android.R.layout.simple_list_item_activated_1,
            null, new String[] { MakkelijkeMarktProvider.Account.COL_NAAM }, new int[] { android.R.id.text1 },
            0);

    // attach the adapter to the account spinner
    mAccount.setAdapter(mAccountsAdapter);

    // initiate loading the accounts from the database
    getLoaderManager().initLoader(ACCOUNTS_LOADER, null, this);

    // disable all caps for the button title
    mLoginButton.setTransformationMethod(null);

    // create the login progress dialog
    mLoginProcessDialog = new ProgressDialog(getContext());
    mLoginProcessDialog.setIndeterminate(true);
    mLoginProcessDialog
            .setIndeterminateDrawable(ContextCompat.getDrawable(getContext(), R.drawable.progressbar_circle));
    mLoginProcessDialog.setMessage(getString(R.string.login) + "...");
    mLoginProcessDialog.setCancelable(false);

    return mainView;
}

From source file:se.hakanostrom.traveldiary.DEPRECATED.Internet.java

private long readHash() {

    SharedPreferences settings = mContext.getSharedPreferences("InternetPreferences", 0);
    SharedPreferences.Editor prefEditor = settings.edit();

    // If it does not exists i shared prefs?
    if (!settings.contains("hash")) {

        // Create and write it
        prefEditor.putLong("hash", System.currentTimeMillis());
        // prefEditor.putLong("hash", 42);
        prefEditor.commit();/*from ww w .  j a va 2s  .  c o m*/
    }

    // Fetch and return it
    return settings.getLong("hash", 0);

}

From source file:a.dev.mobile.thread.MainActivity.java

private int loadIntFromFile() {
    SharedPreferences sharedPreferences;
    int i = 1;//  w  w w  .j  av a  2 s.  com
    sharedPreferences = getSharedPreferences(AppConst.SHARED_PREFERENCES, Context.MODE_PRIVATE);
    if (sharedPreferences.contains(AppConst.PREF_ISO_OR_UN)) {
        i = sharedPreferences.getInt(AppConst.PREF_ISO_OR_UN, i);
    }
    return i;
}

From source file:com.concentriclivers.mms.com.android.mms.transaction.MessagingNotification.java

/**
 * updateNotification is *the* main function for building the actual notification handed to
 * the NotificationManager/*from www .j av a2s  . co m*/
 * @param context
 * @param isNew if we've got a new message, show the ticker
 * @param uniqueThreadCount
 */
private static void updateNotification(Context context, boolean isNew, int uniqueThreadCount) {
    // TDH
    Log.d("NotificationDebug", "updateNotification()");

    // If the user has turned off notifications in settings, don't do any notifying.
    if (!MessagingPreferenceActivity.getNotificationEnabled(context)) {
        if (DEBUG) {
            Log.d(TAG, "updateNotification: notifications turned off in prefs, bailing");
        }
        // TDH
        Log.d("NotificationDebug", "Notifications not enabled!");

        return;
    }

    // Figure out what we've got -- whether all sms's, mms's, or a mixture of both.
    int messageCount = sNotificationSet.size();

    // TDH:
    Log.d("NotificationDebug", "messageCount: " + messageCount);
    if (messageCount == 0) {
        Log.d("NotificationDebug", "WTF. Should have at least one message.");
        return;
    }

    NotificationInfo mostRecentNotification = sNotificationSet.first();

    // TDH: Use NotificationCompat2 (and in other places but it is obvious where).
    final NotificationCompat2.Builder noti = new NotificationCompat2.Builder(context)
            .setWhen(mostRecentNotification.mTimeMillis);

    if (isNew) {
        noti.setTicker(mostRecentNotification.mTicker);
    }
    // TDH
    Log.d("NotificationDebug", "Creating TaskStackBuilder");

    TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
    // TDH
    Log.d("NotificationDebug", "Created TaskStackBuilder. UniqueThreadCount: " + uniqueThreadCount);

    // If we have more than one unique thread, change the title (which would
    // normally be the contact who sent the message) to a generic one that
    // makes sense for multiple senders, and change the Intent to take the
    // user to the conversation list instead of the specific thread.

    // Cases:
    //   1) single message from single thread - intent goes to ComposeMessageActivity
    //   2) multiple messages from single thread - intent goes to ComposeMessageActivity
    //   3) messages from multiple threads - intent goes to ConversationList

    final Resources res = context.getResources();
    String title = null;
    Bitmap avatar = null;
    if (uniqueThreadCount > 1) { // messages from multiple threads
        Intent mainActivityIntent = new Intent(Intent.ACTION_MAIN);

        mainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_CLEAR_TOP);

        mainActivityIntent.setType("vnd.android-dir/mms-sms");
        taskStackBuilder.addNextIntent(mainActivityIntent);
        title = context.getString(R.string.message_count_notification, messageCount);
    } else { // same thread, single or multiple messages
        title = mostRecentNotification.mTitle;
        BitmapDrawable contactDrawable = (BitmapDrawable) mostRecentNotification.mSender.getAvatar(context,
                null);
        if (contactDrawable != null) {
            // Show the sender's avatar as the big icon. Contact bitmaps are 96x96 so we
            // have to scale 'em up to 128x128 to fill the whole notification large icon.
            avatar = contactDrawable.getBitmap();
            if (avatar != null) {
                final int idealIconHeight = res
                        .getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
                final int idealIconWidth = res
                        .getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
                if (avatar.getHeight() < idealIconHeight) {
                    // Scale this image to fit the intended size
                    avatar = Bitmap.createScaledBitmap(avatar, idealIconWidth, idealIconHeight, true);
                }
                if (avatar != null) {
                    noti.setLargeIcon(avatar);
                }
            }
        }

        taskStackBuilder.addParentStack(ComposeMessageActivity.class);
        taskStackBuilder.addNextIntent(mostRecentNotification.mClickIntent);
    }

    // TDH
    Log.d("NotificationDebug", "title: " + title);

    // Always have to set the small icon or the notification is ignored
    noti.setSmallIcon(R.drawable.stat_notify_sms);

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    // Update the notification.
    noti.setContentTitle(title)
            .setContentIntent(taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
    // TDH: Can't do these yet.
    //            .addKind(Notification.KIND_MESSAGE)
    //            .setPriority(Notification.PRIORITY_DEFAULT);     // TODO: set based on contact coming
    //                                                             // from a favorite.

    int defaults = 0;

    if (isNew) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
        String vibrateWhen;
        if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) {
            vibrateWhen = sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null);
        } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) {
            vibrateWhen = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false)
                    ? context.getString(R.string.prefDefault_vibrate_true)
                    : context.getString(R.string.prefDefault_vibrate_false);
        } else {
            vibrateWhen = context.getString(R.string.prefDefault_vibrateWhen);
        }

        boolean vibrateAlways = vibrateWhen.equals("always");
        boolean vibrateSilent = vibrateWhen.equals("silent");
        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        boolean nowSilent = audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE;

        if (vibrateAlways || vibrateSilent && nowSilent) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }

        String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null);
        noti.setSound(TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr));
        if (DEBUG) {
            Log.d(TAG, "updateNotification: new message, adding sound to the notification");
        }
    }

    defaults |= Notification.DEFAULT_LIGHTS;

    noti.setDefaults(defaults);

    // set up delete intent
    noti.setDeleteIntent(PendingIntent.getBroadcast(context, 0, sNotificationOnDeleteIntent, 0));

    final Notification notification;

    if (messageCount == 1) {
        // We've got a single message

        // TDH
        Log.d("NotificationDebug",
                "Single message, with text: " + mostRecentNotification.formatBigMessage(context));

        // This sets the text for the collapsed form:
        noti.setContentText(mostRecentNotification.formatBigMessage(context));

        if (mostRecentNotification.mAttachmentBitmap != null) {
            // The message has a picture, show that

            notification = new NotificationCompat2.BigPictureStyle(noti)
                    .bigPicture(mostRecentNotification.mAttachmentBitmap)
                    // This sets the text for the expanded picture form:
                    .setSummaryText(mostRecentNotification.formatPictureMessage(context)).build();
        } else {
            // Show a single notification -- big style with the text of the whole message
            notification = new NotificationCompat2.BigTextStyle(noti)
                    .bigText(mostRecentNotification.formatBigMessage(context)).build();
        }
    } else {
        // We've got multiple messages
        if (uniqueThreadCount == 1) {
            // We've got multiple messages for the same thread.
            // Starting with the oldest new message, display the full text of each message.
            // Begin a line for each subsequent message.
            SpannableStringBuilder buf = new SpannableStringBuilder();
            NotificationInfo infos[] = sNotificationSet.toArray(new NotificationInfo[sNotificationSet.size()]);
            int len = infos.length;
            for (int i = len - 1; i >= 0; i--) {
                NotificationInfo info = infos[i];

                buf.append(info.formatBigMessage(context));

                if (i != 0) {
                    buf.append('\n');
                }
            }

            noti.setContentText(context.getString(R.string.message_count_notification, messageCount));

            // Show a single notification -- big style with the text of all the messages
            notification = new NotificationCompat2.BigTextStyle(noti).bigText(buf)
                    // Forcibly show the last line, with the app's smallIcon in it, if we 
                    // kicked the smallIcon out with an avatar bitmap
                    .setSummaryText((avatar == null) ? null : " ").build();
        } else {
            // Build a set of the most recent notification per threadId.
            HashSet<Long> uniqueThreads = new HashSet<Long>(sNotificationSet.size());
            ArrayList<NotificationInfo> mostRecentNotifPerThread = new ArrayList<NotificationInfo>();
            Iterator<NotificationInfo> notifications = sNotificationSet.iterator();
            while (notifications.hasNext()) {
                NotificationInfo notificationInfo = notifications.next();
                if (!uniqueThreads.contains(notificationInfo.mThreadId)) {
                    uniqueThreads.add(notificationInfo.mThreadId);
                    mostRecentNotifPerThread.add(notificationInfo);
                }
            }
            // When collapsed, show all the senders like this:
            //     Fred Flinstone, Barry Manilow, Pete...
            noti.setContentText(formatSenders(context, mostRecentNotifPerThread));
            NotificationCompat2.InboxStyle inboxStyle = new NotificationCompat2.InboxStyle(noti);

            // We have to set the summary text to non-empty so the content text doesn't show
            // up when expanded.
            inboxStyle.setSummaryText(" ");

            // At this point we've got multiple messages in multiple threads. We only
            // want to show the most recent message per thread, which are in
            // mostRecentNotifPerThread.
            int uniqueThreadMessageCount = mostRecentNotifPerThread.size();
            int maxMessages = Math.min(MAX_MESSAGES_TO_SHOW, uniqueThreadMessageCount);

            for (int i = 0; i < maxMessages; i++) {
                NotificationInfo info = mostRecentNotifPerThread.get(i);
                inboxStyle.addLine(info.formatInboxMessage(context));
            }
            notification = inboxStyle.build();
            if (DEBUG) {
                Log.d(TAG, "updateNotification: multi messages," + " showing inboxStyle notification");
            }
        }
    }

    // TDH
    Log.d("NotificationDebug", "Showing notification: " + notification);

    nm.notify(NOTIFICATION_ID, notification);
}

From source file:fr.pasteque.client.Configure.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    // Set default values
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!prefs.contains("payleven")) {
        SharedPreferences.Editor edit = prefs.edit();
        edit.putBoolean("payleven", Compat.hasPaylevenApp(this));
        edit.apply();/*from   w  w w  .j av  a  2s  . c o  m*/
    }
    // Load preferences
    this.addPreferencesFromResource(R.xml.configure);
    this.printerDrivers = (ListPreference) this.findPreference("printer_driver");
    this.printerModels = (ListPreference) this.findPreference("printer_model");
    this.printerDrivers.setOnPreferenceChangeListener(this);
    this.updatePrinterPrefs(null);

    ListPreference card_processor = (ListPreference) this.findPreference("card_processor");
    card_processor.setOnPreferenceChangeListener(this);
    this.updateCardProcessorPreferences(null);
    if (this.comesFromError()) {
        this.showError(this.getError());
    }
    if (Configure.isDemo(this)) {
        findPreference("user").setEnabled(false);
        findPreference("password").setEnabled(false);
    }
}

From source file:org.transdroid.core.app.settings.SettingsPersistence.java

private JSONObject exportSettings(SharedPreferences prefs) throws JSONException {

    // Create a single JSON object that will contain all settings
    JSONObject json = new JSONObject();

    // Convert server settings into JSON
    JSONArray servers = new JSONArray();
    int i = 0;//from  w  w  w.  j av  a 2  s  . c  o  m
    String postfixi = "0";
    while (prefs.contains("server_type_" + postfixi)) {

        JSONObject server = new JSONObject();
        server.put("name", prefs.getString("server_name_" + postfixi, null));
        server.put("type", prefs.getString("server_type_" + postfixi, null));
        server.put("host", prefs.getString("server_address_" + postfixi, null));
        server.put("local_network", prefs.getString("server_localnetwork_" + postfixi, null));
        server.put("local_host", prefs.getString("server_localaddress_" + postfixi, null));
        server.put("port", prefs.getString("server_port_" + postfixi, null));
        server.put("ssl", prefs.getBoolean("server_sslenabled_" + postfixi, false));
        server.put("ssl_accept_all", prefs.getBoolean("server_ssltrustall_" + postfixi, false));
        server.put("ssl_trust_key", prefs.getString("server_ssltrustkey_" + postfixi, null));
        server.put("folder", prefs.getString("server_folder_" + postfixi, null));
        server.put("use_auth", !prefs.getBoolean("server_disableauth_" + postfixi, false));
        server.put("username", prefs.getString("server_user_" + postfixi, null));
        server.put("password", prefs.getString("server_pass_" + postfixi, null));
        server.put("extra_password", prefs.getString("server_extrapass_" + postfixi, null));
        server.put("os_type", prefs.getString("server_os_" + postfixi, null));
        server.put("downloads_dir", prefs.getString("server_downloaddir_" + postfixi, null));
        server.put("base_ftp_url", prefs.getString("server_ftpurl_" + postfixi, null));
        server.put("ftp_password", prefs.getString("server_ftppass_" + postfixi, null));
        server.put("server_timeout", prefs.getString("server_timeout_" + postfixi, null));
        server.put("download_alarm", prefs.getBoolean("server_alarmfinished_" + postfixi, false));
        server.put("new_torrent_alarm", prefs.getBoolean("server_alarmnew_" + postfixi, false));

        servers.put(server);
        i++;
        postfixi = Integer.toString(i);
    }
    json.put("servers", servers);

    // Convert web search settings into JSON
    JSONArray sites = new JSONArray();
    int j = 0;
    String postfixj = "0";
    while (prefs.contains("websearch_baseurl_" + postfixj)) {

        JSONObject site = new JSONObject();
        site.put("name", prefs.getString("websearch_name_" + postfixj, null));
        site.put("url", prefs.getString("websearch_baseurl_" + postfixj, null));
        site.put("cookies", prefs.getString("websearch_cookies_" + postfixj, null));

        sites.put(site);
        j++;
        postfixj = Integer.toString(j);
    }
    json.put("websites", sites);

    // Convert RSS feed settings into JSON
    JSONArray feeds = new JSONArray();
    int k = 0;
    String postfixk = "0";
    while (prefs.contains("rssfeed_url_" + postfixk)) {

        JSONObject feed = new JSONObject();
        feed.put("name", prefs.getString("rssfeed_name_" + postfixk, null));
        feed.put("url", prefs.getString("rssfeed_url_" + postfixk, null));
        feed.put("needs_auth", prefs.getBoolean("rssfeed_reqauth_" + postfixk, false));
        feed.put("new_item_alarm", prefs.getBoolean("rssfeed_alarmnew_" + postfixk, false));
        feed.put("last_seen", prefs.getString("rssfeed_lastnew_" + postfixk, null));

        feeds.put(feed);
        k++;
        postfixk = Integer.toString(k);
    }
    json.put("rssfeeds", feeds);

    // Convert background service and system settings into JSON
    json.put("alarm_enabled", prefs.getBoolean("notifications_enabled", true));
    json.put("alarm_interval", prefs.getString("notifications_interval", null));
    json.put("alarm_sound_uri", prefs.getString("notifications_sound", null));
    json.put("alarm_vibrate", prefs.getBoolean("notifications_vibrate", false));
    json.put("alarm_ledcolour", prefs.getInt("notifications_ledcolour", -1));
    json.put("alarm_adwnotifications", prefs.getBoolean("notifications_adwnotify", false));
    json.put("system_dormantasinactive", prefs.getBoolean("system_dormantasinactive", false));
    json.put("system_autorefresh", prefs.getString("system_autorefresh", "0"));
    json.put("system_usedarktheme", prefs.getBoolean("system_usedarktheme", false));
    json.put("system_checkupdates", prefs.getBoolean("system_checkupdates", true));

    return json;

}

From source file:com.snake.salarycounter.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);//from   w w w  .ja  va  2s.  com

    Fabric.with(this, new Crashlytics());

    SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (!mSharedPreferences.contains(PASSWORD_PREFERENCE_KEY)) {
        Intent intent = new Intent(MainActivity.this, CustomPinActivity.class);
        intent.putExtra(AppLock.EXTRA_TYPE, AppLock.ENABLE_PINLOCK);
        startActivityForResult(intent, REQUEST_CODE_ENABLE);
    }
    /*else
    {
    Intent intent = new Intent(MainActivity.this, CustomPinActivity.class);
    intent.putExtra(AppLock.EXTRA_TYPE, AppLock.UNLOCK_PIN);
    startActivity(intent);
    }*/

    // TODO: Move this to where you establish a user session
    //logUser();

    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ButterKnife.bind(this);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //getSupportActionBar().setTitle("Setted title");

    // Create the AccountHeader
    buildHeader(false, savedInstanceState);

    final Context that = this;

    authDrawerItem = new PrimaryDrawerItem().withSelectable(false).withName(R.string.account_title)
            .withIcon(CommunityMaterial.Icon.cmd_plus).withIdentifier(II_ACCOUNT);

    //Create the drawer
    result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
            .addDrawerItems(
                    /*new PrimaryDrawerItem()
                            .withName(R.string.drawer_item_home)
                            .withIcon(CommunityMaterial.Icon.cmd_home)
                            .withIdentifier(10)
                            .withBadge("100")
                            .withDescription("Description"),*/
                    new PrimaryDrawerItem().withName(R.string.drawer_item_shift_types).withSelectable(false)
                            .withIcon(CommunityMaterial.Icon.cmd_calendar_multiple)
                            .withIdentifier(II_SHIFT_TYPES),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_tabel).withSelectable(false)
                            .withIcon(CommunityMaterial.Icon.cmd_calendar_clock).withIdentifier(II_TABLE),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_finance_conditions)
                            .withSelectable(false).withIcon(CommunityMaterial.Icon.cmd_diamond)
                            .withIdentifier(II_FINANCE_CONDITIONS),
                    new PrimaryDrawerItem().withName(R.string.drawer_item_calendar).withSelectable(false)
                            .withIcon(CommunityMaterial.Icon.cmd_calendar_text).withIdentifier(II_CALENDAR)
            //here we use a customPrimaryDrawerItem we defined in our sample app
            //this custom DrawerItem extends the PrimaryDrawerItem so it just overwrites some methods
            /* new OverflowMenuDrawerItem()
                     .withName(R.string.drawer_item_menu_drawer_item)
                     .withDescription(R.string.drawer_item_menu_drawer_item_desc)
                     .withMenu(R.menu.menu_main)
                     .withOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                         @Override
                         public boolean onMenuItemClick(MenuItem item) {
                             Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
                             return false;
                         }
                     })
                     .withIcon(GoogleMaterial.Icon.gmd_filter_center_focus)
                     .withIdentifier(20),
             new CustomPrimaryDrawerItem()
                     .withBackgroundRes(R.color.accent)
                     .withName(R.string.drawer_item_free_play)
                     .withIcon(FontAwesome.Icon.faw_gamepad),
             new PrimaryDrawerItem()
                     .withName(R.string.drawer_item_custom)
                     .withDescription("This is a description")
                     .withIcon(FontAwesome.Icon.faw_eye)
                     .withIdentifier(30),
             new CustomUrlPrimaryDrawerItem()
                     .withName(R.string.drawer_item_fragment_drawer)
                     .withDescription(R.string.drawer_item_fragment_drawer_desc)
                     .withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460")
                     .withIdentifier(40),
             new SectionDrawerItem()
                     .withName(R.string.drawer_item_section_header),
             new SecondaryDrawerItem()
                     .withName(R.string.drawer_item_settings)
                     .withIcon(FontAwesome.Icon.faw_cart_plus)
                     .withIdentifier(50),
             new SecondaryDrawerItem()
                     .withName(R.string.drawer_item_help)
                     .withIcon(FontAwesome.Icon.faw_database)
                     .withEnabled(false)
                     .withIdentifier(60),
             new SecondaryDrawerItem()
                     .withName(R.string.drawer_item_open_source)
                     .withIcon(FontAwesome.Icon.faw_github)
                     .withIdentifier(70),
             new SecondaryDrawerItem()
                     .withName(R.string.drawer_item_contact)
                     .withSelectedIconColor(Color.RED)
                     .withIconTintingEnabled(true)
                     .withIcon(
                             new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus_one)
                                     .actionBar()
                                     .paddingDp(5)
                                     .colorRes(R.color.material_drawer_dark_primary_text))
                     .withTag("Bullhorn")
                     .withIdentifier(80),
             new SecondaryDrawerItem()
                     .withName(R.string.drawer_item_help)
                     .withIcon(FontAwesome.Icon.faw_question)
                     .withEnabled(false)
                     .withIdentifier(90)*/
            ) // add the items we want to use with our Drawer
            .withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() {
                @Override
                public boolean onNavigationClickListener(View clickedView) {
                    //this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer
                    //if the back arrow is shown. close the activity
                    MainActivity.this.finish();
                    //return true if we have consumed the event
                    return true;
                }
            }).addStickyDrawerItems(
                    //authDrawerItem,
                    new SecondaryDrawerItem().withSelectable(false).withName(R.string.drawer_item_settings)
                            .withIcon(CommunityMaterial.Icon.cmd_settings).withIdentifier(II_SETTINGS),
                    new SecondaryDrawerItem().withSelectable(false).withName(R.string.drawer_item_about)
                            .withIcon(CommunityMaterial.Icon.cmd_help).withIdentifier(II_ABOUT))
            .withSelectedItem(-1).withSavedInstance(savedInstanceState)
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    Intent intent = new Intent();

                    switch ((int) drawerItem.getIdentifier()) {
                    case 1000:
                        intent.setClass(that, CustomPinActivity.class);
                        intent.putExtra(AppLock.EXTRA_TYPE, AppLock.ENABLE_PINLOCK);
                        startActivity(intent);
                        break;
                    case 2000:
                        intent.setClass(that, ListShiftTypeActivity.class);
                        intent.putExtra(AppLock.EXTRA_TYPE, AppLock.UNLOCK_PIN);
                        startActivity(intent);
                        break;
                    case II_SHIFT_TYPES:
                        intent.setClass(that, ListShiftTypeActivity.class);
                        startActivity(intent);
                        break;
                    case II_FINANCE_CONDITIONS:
                        intent.setClass(that, ListFinanceConditionActivity.class);
                        startActivity(intent);
                        break;
                    case II_TABLE:
                        intent.setClass(that, ListTabelActivity.class);
                        startActivity(intent);
                        break;
                    case II_CALENDAR:
                        intent.setClass(that, CalendarActivity.class);
                        startActivity(intent);
                        break;
                    case II_SETTINGS:
                        intent.setClass(that, SettingsActivity.class);
                        startActivity(intent);
                        break;
                    case II_ABOUT:
                        showAbout(that);
                        break;
                    case II_ACCOUNT:

                        break;
                    default:
                        Snackbar.make(view, "Clicked " + String.valueOf(drawerItem.getIdentifier()),
                                Snackbar.LENGTH_LONG).setAction("Action", null).show();
                        return false;
                    }

                    return true;
                }
            }).build();
}