List of usage examples for android.os Bundle getLongArray
@Nullable public long[] getLongArray(@Nullable String key)
From source file:com.aboveware.actionbar.honeycomb.ExpandableListFragment.java
/** * Attach to list view once the view hierarchy has been created. *///from w w w.jav a2 s . co m @TargetApi(13) @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ensureList(); if (savedInstanceState != null) { expandedIds = savedInstanceState.getLongArray(ExpandableListAdapter.EXPANDED_IDS); } }
From source file:com.andrew.apollo.menu.PlaylistDialog.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(new LinearLayout(this)); action = getIntent().getAction();/*www . j a v a2 s .c om*/ mRenameId = icicle != null ? icicle.getLong(INTENT_KEY_RENAME) : getIntent().getLongExtra(INTENT_KEY_RENAME, -1); mList = icicle != null ? icicle.getLongArray(INTENT_PLAYLIST_LIST) : getIntent().getLongArrayExtra(INTENT_PLAYLIST_LIST); if (INTENT_RENAME_PLAYLIST.equals(action)) { mOriginalName = nameForId(mRenameId); mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : mOriginalName; } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : makePlaylistName(); mOriginalName = mDefaultName; } DisplayMetrics dm = new DisplayMetrics(); dm = getResources().getDisplayMetrics(); mPlaylistDialog = new AlertDialog.Builder(this).create(); mPlaylistDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC); if (action != null && mRenameId >= 0 && mOriginalName != null || mDefaultName != null) { mPlaylist = new EditText(this); mPlaylist.setSingleLine(true); mPlaylist.setText(mDefaultName); mPlaylist.setSelection(mDefaultName.length()); mPlaylist.addTextChangedListener(this); mPlaylistDialog.setIcon(android.R.drawable.ic_dialog_info); String promptformat; String prompt = ""; if (INTENT_RENAME_PLAYLIST.equals(action)) { promptformat = getString(R.string.rename_playlist); prompt = String.format(promptformat, mOriginalName, mDefaultName); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { promptformat = getString(R.string.new_playlist); prompt = String.format(promptformat, mDefaultName); } mPlaylistDialog.setTitle(prompt); mPlaylistDialog.setView(mPlaylist, (int) (8 * dm.density), (int) (8 * dm.density), (int) (8 * dm.density), (int) (4 * dm.density)); if (INTENT_RENAME_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mRenamePlaylistListener); mPlaylistDialog.setOnShowListener(this); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mCreatePlaylistListener); } mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); mPlaylistDialog.setOnCancelListener(this); mPlaylistDialog.show(); } else { Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } }
From source file:org.musicmod.android.dialog.PlaylistDialog.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(new LinearLayout(this)); action = getIntent().getAction();/*w w w .j a va 2 s . c o m*/ mRenameId = icicle != null ? icicle.getLong(INTENT_KEY_RENAME) : getIntent().getLongExtra(INTENT_KEY_RENAME, -1); mList = icicle != null ? icicle.getLongArray(INTENT_KEY_LIST) : getIntent().getLongArrayExtra(INTENT_KEY_LIST); if (INTENT_RENAME_PLAYLIST.equals(action)) { mOriginalName = nameForId(mRenameId); mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : mOriginalName; } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : makePlaylistName(); mOriginalName = mDefaultName; } DisplayMetrics dm = new DisplayMetrics(); dm = getResources().getDisplayMetrics(); mPlaylistDialog = new AlertDialog.Builder(this).create(); mPlaylistDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC); if (action != null && mRenameId >= 0 && mOriginalName != null || mDefaultName != null) { mPlaylist = new EditText(this); mPlaylist.setSingleLine(true); mPlaylist.setText(mDefaultName); mPlaylist.setSelection(mDefaultName.length()); mPlaylist.addTextChangedListener(this); mPlaylistDialog.setIcon(android.R.drawable.ic_dialog_info); String promptformat; String prompt = ""; if (INTENT_RENAME_PLAYLIST.equals(action)) { promptformat = getString(R.string.rename_playlist_prompt); prompt = String.format(promptformat, mOriginalName, mDefaultName); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { promptformat = getString(R.string.create_playlist_prompt); prompt = String.format(promptformat, mDefaultName); } mPlaylistDialog.setTitle(prompt); mPlaylistDialog.setView(mPlaylist, (int) (8 * dm.density), (int) (8 * dm.density), (int) (8 * dm.density), (int) (4 * dm.density)); if (INTENT_RENAME_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mRenamePlaylistListener); mPlaylistDialog.setOnShowListener(this); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mCreatePlaylistListener); } mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); mPlaylistDialog.setOnCancelListener(this); mPlaylistDialog.show(); } else { Toast.makeText(this, R.string.error_bad_parameters, Toast.LENGTH_SHORT).show(); finish(); } }
From source file:org.mariotaku.twidere.activity.HomeActivity.java
@Override protected void onNewIntent(final Intent intent) { final Bundle bundle = intent.getExtras(); if (bundle != null) { final long[] refreshed_ids = bundle.getLongArray(INTENT_KEY_IDS); if (refreshed_ids != null) { // TODO should I refresh inbox too? mTwitterWrapper.refreshAll(); }/* ww w .jav a 2 s.c o m*/ final int initial_tab = bundle.getInt(INTENT_KEY_INITIAL_TAB, -1); if (initial_tab != -1 && mViewPager != null) { switch (initial_tab) { case TAB_POSITION_HOME: { if (mShowHomeTab) { mTwitterWrapper.clearNotification(NOTIFICATION_ID_HOME_TIMELINE); } break; } case TAB_POSITION_MENTIONS: { mTwitterWrapper.clearNotification(NOTIFICATION_ID_MENTIONS); break; } case TAB_POSITION_MESSAGES: { mTwitterWrapper.clearNotification(NOTIFICATION_ID_DIRECT_MESSAGES); break; } } if (initial_tab >= 0 || initial_tab < mViewPager.getChildCount()) { mViewPager.setCurrentItem(initial_tab); } } } super.onNewIntent(intent); }
From source file:info.shibafu528.gallerymultipicker.MultiPickerActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mSelectedIds.addAll(savedInstanceState.getLongArray(EXTRA_URIS)); updateLimitCount();/*from w w w . j av a 2s. c o m*/ }
From source file:org.yammp.dialog.PlaylistDialog.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mUtils = ((YAMMPApplication) getApplication()).getMediaUtils(); setContentView(new LinearLayout(this)); action = getIntent().getAction();//from w w w .j av a2 s. co m mRenameId = icicle != null ? icicle.getLong(INTENT_KEY_RENAME) : getIntent().getLongExtra(INTENT_KEY_RENAME, -1); mList = icicle != null ? icicle.getLongArray(INTENT_KEY_LIST) : getIntent().getLongArrayExtra(INTENT_KEY_LIST); if (INTENT_RENAME_PLAYLIST.equals(action)) { mOriginalName = nameForId(mRenameId); mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : mOriginalName; } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : makePlaylistName(); mOriginalName = mDefaultName; } DisplayMetrics dm = new DisplayMetrics(); dm = getResources().getDisplayMetrics(); mPlaylistDialog = new AlertDialog.Builder(this).create(); mPlaylistDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC); if (action != null && mRenameId >= 0 && mOriginalName != null || mDefaultName != null) { mPlaylist = new EditText(this); mPlaylist.setSingleLine(true); mPlaylist.setText(mDefaultName); mPlaylist.setSelection(mDefaultName.length()); mPlaylist.addTextChangedListener(this); mPlaylistDialog.setIcon(android.R.drawable.ic_dialog_info); String promptformat; String prompt = ""; if (INTENT_RENAME_PLAYLIST.equals(action)) { promptformat = getString(R.string.rename_playlist_prompt); prompt = String.format(promptformat, mOriginalName, mDefaultName); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { promptformat = getString(R.string.create_playlist_prompt); prompt = String.format(promptformat, mDefaultName); } mPlaylistDialog.setTitle(prompt); mPlaylistDialog.setView(mPlaylist, (int) (8 * dm.density), (int) (8 * dm.density), (int) (8 * dm.density), (int) (4 * dm.density)); if (INTENT_RENAME_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mRenamePlaylistListener); mPlaylistDialog.setOnShowListener(this); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mCreatePlaylistListener); } mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); mPlaylistDialog.setOnCancelListener(this); mPlaylistDialog.show(); } else { Toast.makeText(this, R.string.error_bad_parameters, Toast.LENGTH_SHORT).show(); finish(); } }
From source file:org.mariotaku.twidere.activity.HomeActivity.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { final ContentResolver resolver = getContentResolver(); ContentValues values;/*from www . j a va2s .c o m*/ switch (requestCode) { case REQUEST_SELECT_ACCOUNT: { if (resultCode == RESULT_OK) { if (intent == null || intent.getExtras() == null) { break; } final Bundle bundle = intent.getExtras(); if (bundle == null) { break; } final long[] account_ids = bundle.getLongArray(INTENT_KEY_IDS); if (account_ids != null) { values = new ContentValues(); values.put(Accounts.IS_ACTIVATED, 0); resolver.update(Accounts.CONTENT_URI, values, null, null); values = new ContentValues(); values.put(Accounts.IS_ACTIVATED, 1); for (final long account_id : account_ids) { final String where = Accounts.ACCOUNT_ID + " = " + account_id; resolver.update(Accounts.CONTENT_URI, values, where, null); } } setDefaultAccount(); } else if (resultCode == RESULT_CANCELED) { if (getActivatedAccountIds(this).length <= 0) { finish(); } else { setDefaultAccount(); } } break; } } super.onActivityResult(requestCode, resultCode, intent); }
From source file:com.ultramegasoft.flavordex2.dialog.ExportDialog.java
@NonNull @Override//from ww w . j av a2s . c o m @SuppressLint({ "InflateParams", "SetTextI18n" }) public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getContext(); if (context == null) { return super.onCreateDialog(savedInstanceState); } final Bundle args = getArguments(); if (args != null) { mEntryIDs = args.getLongArray(ARG_ENTRY_IDS); } mBasePath = getBasePath(); final View view = LayoutInflater.from(context).inflate(R.layout.dialog_export, null); ((TextView) view.findViewById(R.id.file_path)).setText(mBasePath + "/"); final TextView extension = view.findViewById(R.id.extension); extension.setText(FileUtils.EXT_CSV); ((AppCompatCheckBox) view.findViewById(R.id.include_images)) .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { extension.setText(isChecked ? FileUtils.EXT_ZIP : FileUtils.EXT_CSV); mIncludeImages = isChecked; } }); setupFileField((EditText) view.findViewById(R.id.file_name)); return new AlertDialog.Builder(context).setIcon(R.drawable.ic_export).setTitle(R.string.title_export) .setView(view).setPositiveButton(R.string.button_export, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { export(); } }).setNegativeButton(R.string.button_cancel, null).create(); }
From source file:org.mariotaku.twidere.activity.HomeActivity.java
/** Called when the activity is first created. */ @Override// w w w .java 2 s .c om public void onCreate(final Bundle savedInstanceState) { mApplication = getTwidereApplication(); mTwitterWrapper = mApplication.getTwitterWrapper(); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); super.onCreate(savedInstanceState); sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONCREATE)); final Resources res = getResources(); mDisplayAppIcon = res.getBoolean(R.bool.home_display_icon); final long[] account_ids = getAccountIds(this); if (account_ids.length <= 0) { final Intent intent = new Intent(INTENT_ACTION_TWITTER_LOGIN); intent.setClass(this, SignInActivity.class); startActivity(intent); finish(); return; } else { setDefaultAccount(); } final boolean refresh_on_start = mPreferences.getBoolean(PREFERENCE_KEY_REFRESH_ON_START, false); final Bundle bundle = getIntent().getExtras(); int initial_tab = -1; if (bundle != null) { final long[] refreshed_ids = bundle.getLongArray(INTENT_KEY_IDS); if (refreshed_ids != null && !refresh_on_start && savedInstanceState == null) { mTwitterWrapper.refreshAll(); } initial_tab = bundle.getInt(INTENT_KEY_INITIAL_TAB, -1); switch (initial_tab) { case TAB_POSITION_HOME: { mTwitterWrapper.clearNotification(NOTIFICATION_ID_HOME_TIMELINE); break; } case TAB_POSITION_MENTIONS: { mTwitterWrapper.clearNotification(NOTIFICATION_ID_MENTIONS); break; } case TAB_POSITION_MESSAGES: { mTwitterWrapper.clearNotification(NOTIFICATION_ID_DIRECT_MESSAGES); break; } } } mActionBar = getSupportActionBar(); mActionBar.setCustomView(R.layout.base_tabs); mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayShowCustomEnabled(true); mActionBar.setDisplayShowHomeEnabled(mDisplayAppIcon); if (mDisplayAppIcon) { ActivityAccessor.setHomeButtonEnabled(this, true); } final View view = mActionBar.getCustomView(); mProgress = (ProgressBar) view.findViewById(android.R.id.progress); mIndicator = (TabPageIndicator) view.findViewById(android.R.id.tabs); final boolean tab_display_label = res.getBoolean(R.bool.tab_display_label); mAdapter = new TabsAdapter(this, getSupportFragmentManager(), mIndicator); mShowHomeTab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_HOME_TAB, true); mShowMentionsTab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_MENTIONS_TAB, true); mShowMessagesTab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_MESSAGES_TAB, true); mShowAccountsTab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_ACCOUNTS_TAB, true); initTabs(getTabs(this)); mViewPager.setAdapter(mAdapter); mViewPager.setOffscreenPageLimit(3); mIndicator.setViewPager(mViewPager); mIndicator.setOnPageChangeListener(this); mIndicator.setDisplayLabel(tab_display_label); getSupportFragmentManager().addOnBackStackChangedListener(this); final boolean remember_position = mPreferences.getBoolean(PREFERENCE_KEY_REMEMBER_POSITION, true); final long[] activated_ids = getActivatedAccountIds(this); if (activated_ids.length <= 0) { startActivityForResult(new Intent(INTENT_ACTION_SELECT_ACCOUNT), REQUEST_SELECT_ACCOUNT); } else if (remember_position || initial_tab >= 0) { final int position = initial_tab >= 0 ? initial_tab : mPreferences.getInt(PREFERENCE_KEY_SAVED_TAB_POSITION, TAB_POSITION_HOME); if (position >= 0 || position < mViewPager.getChildCount()) { mViewPager.setCurrentItem(position); } } if (refresh_on_start && savedInstanceState == null) { mTwitterWrapper.refreshAll(); } if (!mPreferences.getBoolean(PREFERENCE_KEY_API_UPGRADE_CONFIRMED, false)) { final FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentByTag(FRAGMENT_TAG_API_UPGRADE_NOTICE) == null || !fm.findFragmentByTag(FRAGMENT_TAG_API_UPGRADE_NOTICE).isAdded()) { new APIUpgradeConfirmDialog().show(getSupportFragmentManager(), "api_upgrade_notice"); } } if (mPreferences.getBoolean(PREFERENCE_KEY_SHOW_UCD_DATA_PROFILING_REQUEST, true)) { final Intent intent = new Intent(this, DataProfilingSettingsActivity.class); final PendingIntent content_intent = PendingIntent.getActivity(this, 0, intent, 0); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setAutoCancel(true); builder.setSmallIcon(R.drawable.ic_stat_question_mark); builder.setTicker(getString(R.string.data_profiling_notification_ticker)); builder.setContentTitle(getString(R.string.data_profiling_notification_title)); builder.setContentText(getString(R.string.data_profiling_notification_desc)); builder.setContentIntent(content_intent); mNotificationManager.notify(NOTIFICATION_ID_DATA_PROFILING, builder.build()); } }
From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.backup_code_fragment, container, false); Bundle args = getArguments(); mBackupCode = args.getString(ARG_BACKUP_CODE); mMasterKeyIds = args.getLongArray(ARG_MASTER_KEY_IDS); mExportSecret = args.getBoolean(ARG_EXPORT_SECRET); mExecuteBackupOperation = args.getBoolean(ARG_EXECUTE_BACKUP_OPERATION, true); mCodeEditText = new EditText[6]; mCodeEditText[0] = (EditText) view.findViewById(R.id.backup_code_1); mCodeEditText[1] = (EditText) view.findViewById(R.id.backup_code_2); mCodeEditText[2] = (EditText) view.findViewById(R.id.backup_code_3); mCodeEditText[3] = (EditText) view.findViewById(R.id.backup_code_4); mCodeEditText[4] = (EditText) view.findViewById(R.id.backup_code_5); mCodeEditText[5] = (EditText) view.findViewById(R.id.backup_code_6); {//from w w w . j ava2 s . com TextView[] codeDisplayText = new TextView[6]; codeDisplayText[0] = (TextView) view.findViewById(R.id.backup_code_display_1); codeDisplayText[1] = (TextView) view.findViewById(R.id.backup_code_display_2); codeDisplayText[2] = (TextView) view.findViewById(R.id.backup_code_display_3); codeDisplayText[3] = (TextView) view.findViewById(R.id.backup_code_display_4); codeDisplayText[4] = (TextView) view.findViewById(R.id.backup_code_display_5); codeDisplayText[5] = (TextView) view.findViewById(R.id.backup_code_display_6); // set backup code in code TextViews char[] backupCode = mBackupCode.toCharArray(); for (int i = 0; i < codeDisplayText.length; i++) { codeDisplayText[i].setText(backupCode, i * 5, 4); } // set background to null in TextViews - this will retain padding from EditText style! for (TextView textView : codeDisplayText) { // noinspection deprecation, setBackground(Drawable) is API level >=16 textView.setBackgroundDrawable(null); } } setupEditTextFocusNext(mCodeEditText); setupEditTextSuccessListener(mCodeEditText); mStatusAnimator = (ToolableViewAnimator) view.findViewById(R.id.status_animator); mTitleAnimator = (ToolableViewAnimator) view.findViewById(R.id.title_animator); mCodeFieldsAnimator = (ToolableViewAnimator) view.findViewById(R.id.code_animator); View backupInput = view.findViewById(R.id.button_backup_input); backupInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { switchState(BackupCodeState.STATE_INPUT, true); } }); view.findViewById(R.id.button_backup_save).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mShareNotSave = false; startBackup(); } }); view.findViewById(R.id.button_backup_share).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mShareNotSave = true; startBackup(); } }); view.findViewById(R.id.button_backup_back).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentManager fragMan = getFragmentManager(); if (fragMan != null) { fragMan.popBackStack(); } } }); view.findViewById(R.id.button_faq).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showFaq(); } }); return view; }