List of usage examples for android.os Bundle getLongArray
@Nullable public long[] getLongArray(@Nullable String key)
From source file:org.mariotaku.twidere.activity.SelectAccountActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); final Bundle extras = getIntent().getExtras(); setContentView(R.layout.select_account); mListView = (ListView) findViewById(android.R.id.list); mAdapter = new AccountsAdapter(this, true); mListView.setAdapter(mAdapter);//from w w w . j a v a2 s . c om mListView.setOnItemClickListener(this); mListView.setOnScrollListener(this); final long[] activated_ids; if (savedInstanceState != null) { activated_ids = savedInstanceState.getLongArray(INTENT_KEY_IDS); } else if (extras != null) { activated_ids = extras.getLongArray(INTENT_KEY_IDS); } else { activated_ids = null; } mAllowSelectNone = extras != null ? extras.getBoolean(INTENT_KEY_ALLOW_SELECT_NONE, false) : false; mOAuthOnly = extras != null ? extras.getBoolean(INTENT_KEY_OAUTH_ONLY, false) : false; mSelectedIds.clear(); if (activated_ids != null) { for (final long id : activated_ids) { mSelectedIds.add(id); } } getSupportLoaderManager().initLoader(0, null, this); }
From source file:org.mariotaku.twidere.activity.AccountSelectorActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); final Bundle extras = getIntent().getExtras(); setContentView(R.layout.select_account); mListView = (ListView) findViewById(android.R.id.list); mAdapter = new AccountsAdapter(this, true); mListView.setAdapter(mAdapter);/* w w w .j a v a 2s . co m*/ mListView.setOnItemClickListener(this); mListView.setOnScrollListener(this); final long[] activated_ids; if (savedInstanceState != null) { activated_ids = savedInstanceState.getLongArray(INTENT_KEY_IDS); } else if (extras != null) { activated_ids = extras.getLongArray(INTENT_KEY_IDS); } else { activated_ids = null; } mAllowSelectNone = extras != null ? extras.getBoolean(INTENT_KEY_ALLOW_SELECT_NONE, false) : false; mOAuthOnly = extras != null ? extras.getBoolean(INTENT_KEY_OAUTH_ONLY, false) : false; mSelectedIds.clear(); if (activated_ids != null) { for (final long id : activated_ids) { mSelectedIds.add(id); } } getSupportLoaderManager().initLoader(0, null, this); }
From source file:org.mariotaku.twidere.extension.timescape.ExtensionSettingsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); super.onCreate(savedInstanceState); setContentView(R.layout.main);/*w w w . j ava 2s .c o m*/ mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, null, FROM, TO, 0); mListView = (ListView) findViewById(android.R.id.list); mEmptyView = findViewById(android.R.id.empty); mListView.setAdapter(mAdapter); mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); mListView.setOnItemClickListener(this); getSupportLoaderManager().initLoader(0, null, this); final long[] activated_ids = savedInstanceState != null ? savedInstanceState.getLongArray(Twidere.INTENT_KEY_IDS) : Utils.getSelectedIdsInPreferences(this); mSelectedIds.clear(); if (activated_ids != null) { for (final long id : activated_ids) { mSelectedIds.add(id); } } }
From source file:info.guardianproject.gpg.KeyListFragment.java
public void handleIntent(String action, Bundle extras) { // Why doesn't java have default parameters :( if (extras == null) extras = new Bundle(); mCurrentAction = action;//from w w w. ja v a 2 s . co m mCurrentExtras = extras; String searchString = null; if (Intent.ACTION_SEARCH.equals(action)) { searchString = extras.getString(SearchManager.QUERY); if (searchString != null && searchString.trim().length() == 0) { searchString = null; } } long selectedKeyIds[] = null; selectedKeyIds = extras.getLongArray(Apg.EXTRA_SELECTION); if (selectedKeyIds == null) { Vector<Long> vector = new Vector<Long>(); for (int i = 0; i < mListView.getCount(); ++i) { if (mListView.isItemChecked(i)) { vector.add(mListView.getItemIdAtPosition(i)); } } selectedKeyIds = new long[vector.size()]; for (int i = 0; i < vector.size(); ++i) { selectedKeyIds[i] = vector.get(i); } } if (action.equals(Action.FIND_KEYS)) { if (mKeyserverAdapter == null) mKeyserverAdapter = new KeyListKeyserverAdapter(mListView, searchString); setListAdapter(mKeyserverAdapter); } else { mShowKeysAdapter = new KeyListContactsAdapter(mListView, action, searchString, selectedKeyIds); setListAdapter(mShowKeysAdapter); if (selectedKeyIds != null) { for (int i = 0; i < mShowKeysAdapter.getCount(); ++i) { long keyId = mShowKeysAdapter.getItemId(i); for (int j = 0; j < selectedKeyIds.length; ++j) { if (keyId == selectedKeyIds[j]) { mListView.setItemChecked(i, true); break; } } } } } }
From source file:ca.marklauman.dominionpicker.MarketActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_market); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get View items but_draw = findViewById(R.id.market_draw); choice_panel = findViewById(R.id.market_choices); sold_out = findViewById(R.id.market_sold_out); // Setup the list & adapter ListView card_list = (ListView) findViewById(R.id.card_list); adapter = new CardAdapter(this); adapter.changeCursor(null);/*from ww w .j a v a2 s .co m*/ card_list.setAdapter(adapter); card_list.setOnItemClickListener(this); // Restore app state or set it up stock = null; choices = null; if (savedInstanceState != null) { long[] arrStock = savedInstanceState.getLongArray(KEY_STOCK); stock = new LinkedList<>(); for (long id : arrStock) stock.add(id); choices = savedInstanceState.getLongArray(KEY_CHOICES); } else setupMarketStall(); // Setup the display based off of app state if (choices == null) { if (stock == null || stock.size() < 1) { but_draw.setVisibility(View.GONE); sold_out.setVisibility(View.VISIBLE); } } else { but_draw.setVisibility(View.GONE); choice_panel.setVisibility(View.VISIBLE); getSupportLoaderManager().restartLoader(4, null, this); } }
From source file:com.dwdesign.tweetings.activity.SelectAccountActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); setContentView(R.layout.select_account); mListView = (ListView) findViewById(android.R.id.list); final String[] from = new String[] { Accounts.USERNAME }; final int[] to = new int[] { android.R.id.text1 }; mCursor = getAccountsCursor(bundle != null ? bundle.getBoolean(INTENT_KEY_ACTIVATED_ONLY, false) : false); if (mCursor == null) { finish();// ww w .j a v a2s. co m return; } mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, mCursor, from, to, 0); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); final long[] activated_ids = bundle != null ? bundle.getLongArray(Constants.INTENT_KEY_IDS) : null; mActivatedUsersId.clear(); if (activated_ids == null) { mCursor.moveToFirst(); while (!mCursor.isAfterLast()) { final boolean is_activated = mCursor .getInt(mCursor.getColumnIndexOrThrow(Accounts.IS_ACTIVATED)) == 1; final long user_id = mCursor.getLong(mCursor.getColumnIndexOrThrow(Accounts.USER_ID)); if (is_activated) { mActivatedUsersId.add(user_id); } mListView.setItemChecked(mCursor.getPosition(), is_activated); mCursor.moveToNext(); } } else { for (final long id : activated_ids) { mCursor.moveToFirst(); while (!mCursor.isAfterLast()) { final long user_id = mCursor.getLong(mCursor.getColumnIndexOrThrow(Accounts.USER_ID)); if (id == user_id) { mListView.setItemChecked(mCursor.getPosition(), true); mActivatedUsersId.add(user_id); } mCursor.moveToNext(); } } } }
From source file:com.almarsoft.GroundhogReader.MessageActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getApplicationContext();/*w w w .ja v a 2 s . c o m*/ setContentView(R.layout.message); // Config checker alert dialog mConfigAlert = new AlertDialog.Builder(this).create(); mConfigAlert.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { startActivity(new Intent(MessageActivity.this, OptionsActivity.class)); } }); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mOfflineMode = mPrefs.getBoolean("offlineMode", true); Bundle extras = getIntent().getExtras(); mMsgIndexInArray = extras.getInt("msgIndexInArray"); mArticleNumbersArray = extras.getLongArray("articleNumbers"); mGroup = extras.getString("group"); mMainLayout = (LinearLayout) this.findViewById(R.id.main_message_layout); //mLayoutAuthor = (LinearLayout) this.findViewById(R.id.layout_author); mLayoutSubject = (LinearLayout) this.findViewById(R.id.layout_subject); mLayoutDate = (LinearLayout) this.findViewById(R.id.layout_date); mAuthor = (TextView) this.findViewById(R.id.text_author); mHeart = (ImageView) this.findViewById(R.id.img_love); //mHeart.setVisibility(ImageView.INVISIBLE); mDate = (TextView) this.findViewById(R.id.text_date); mSubject = (TextView) this.findViewById(R.id.text_subject); mSubjectText = null; mLastSubject = null; mContent = (WebView) this.findViewById(R.id.text_content); mWebSettings = mContent.getSettings(); mWebSettings.setDefaultTextEncodingName("utf-8"); mWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); mWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); mWebSettings.setJavaScriptEnabled(false); mWebSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); mWebSettings.setSupportZoom(false); this.setWebViewSizeFromPrefs(0); mScroll = (ScrollView) this.findViewById(R.id.textAreaScroller); // Conectar los botones next y prev (sumar/restar 1 a mMsgIndexInArray y // llamar a loadMessage(); mButton_Prev = (ImageButton) this.findViewById(R.id.btn_prev); mButton_Prev.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { if (mMsgIndexInArray > 0) { mMsgIndexInArray--; loadMessage(); } else { Toast.makeText(MessageActivity.this, getString(R.string.at_first_message), Toast.LENGTH_SHORT) .show(); } } }); mButton_Next = (ImageButton) this.findViewById(R.id.btn_next); mButton_Next.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { if (mMsgIndexInArray + 1 < mArticleNumbersArray.length) { mMsgIndexInArray++; loadMessage(); } else { Toast.makeText(MessageActivity.this, getString(R.string.no_more_messages), Toast.LENGTH_SHORT) .show(); } } }); mButton_GoGroup = (ImageButton) this.findViewById(R.id.btn_gogroup); mButton_GoGroup.setOnClickListener(new OnClickListener() { public void onClick(View v) { /* Intent intent_MsgList = new Intent(MessageActivity.this, MessageListActivity.class); intent_MsgList.putExtra("selectedGroup", mGroup); MessageActivity.this.startActivity(intent_MsgList); */ MessageActivity.this.finish(); } }); mServerManager = new ServerManager(mContext); loadMessage(); mButton_Prev.setFocusable(false); mButton_Next.setFocusable(false); mContent.requestFocus(); }
From source file:org.mariotaku.twidere.activity.ComposeActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { switch (requestCode) { case REQUEST_TAKE_PHOTO: { if (resultCode == Activity.RESULT_OK) { final File file = new File(mImageUri.getPath()); if (file.exists()) { mIsImageAttached = false; mIsPhotoAttached = true; mImageThumbnailPreview.setVisibility(View.VISIBLE); reloadAttachedImageThumbnail(file); } else { mIsPhotoAttached = false; }/*from ww w. j a va 2 s . co m*/ setMenu(); } else { mImageUri = null; } break; } case REQUEST_PICK_IMAGE: { if (resultCode == Activity.RESULT_OK) { final Uri uri = intent.getData(); final String path = getImagePathFromUri(this, uri); final File file = path == null ? null : new File(path); if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsPhotoAttached = false; mIsImageAttached = true; mImageThumbnailPreview.setVisibility(View.VISIBLE); reloadAttachedImageThumbnail(file); } else { mIsImageAttached = false; } setMenu(); } break; } case REQUEST_SELECT_ACCOUNT: { if (resultCode == Activity.RESULT_OK) { final Bundle bundle = intent.getExtras(); if (bundle == null) { break; } final long[] account_ids = bundle.getLongArray(INTENT_KEY_IDS); if (account_ids != null) { mAccountIds = account_ids; if (mInReplyToStatusId <= 0) { final SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, ArrayUtils.toString(mAccountIds, ',', false)); editor.commit(); } mColorIndicator.setColors(getAccountColors(this, account_ids)); } } break; } case REQUEST_EDIT_IMAGE: { if (resultCode == Activity.RESULT_OK) { final Uri uri = intent.getData(); final File file = uri == null ? null : new File(getImagePathFromUri(this, uri)); if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); reloadAttachedImageThumbnail(file); } else { break; } setMenu(); } break; } case REQUEST_EXTENSION_COMPOSE: { if (resultCode == Activity.RESULT_OK) { final Bundle extras = intent.getExtras(); if (extras == null) { break; } final String text = extras.getString(INTENT_KEY_TEXT); final String append = extras.getString(INTENT_KEY_APPEND_TEXT); final Uri image_uri = extras.getParcelable(INTENT_KEY_IMAGE_URI); if (text != null) { mEditText.setText(text); mText = parseString(mEditText.getText()); } else if (append != null) { mEditText.append(append); mText = parseString(mEditText.getText()); } final File file = image_uri == null ? null : new File(getImagePathFromUri(this, image_uri)); if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); reloadAttachedImageThumbnail(file); } setMenu(); } break; } } }
From source file:com.dwdesign.tweetings.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); final int initial_tab = bundle.getInt(INTENT_KEY_INITIAL_TAB, -1); if (initial_tab != -1 && mViewPager != null) { switch (initial_tab) { case TAB_POSITION_HOME: { mService.clearNotification(NOTIFICATION_ID_HOME_TIMELINE); break; }/*ww w . j a va 2 s . com*/ case TAB_POSITION_MENTIONS: { mService.clearNotification(NOTIFICATION_ID_MENTIONS); break; } case TAB_POSITION_MESSAGES: { mService.clearNotification(NOTIFICATION_ID_DIRECT_MESSAGES); break; } } if (initial_tab >= 0 || initial_tab < mViewPager.getChildCount()) { mViewPager.setCurrentItem(initial_tab); } } if (refreshed_ids != null) { mService.getHomeTimelineWithSinceId(refreshed_ids, null, getNewestStatusIdsFromDatabase(this, Statuses.CONTENT_URI)); mService.getMentionsWithSinceId(refreshed_ids, null, getNewestStatusIdsFromDatabase(this, Mentions.CONTENT_URI)); mService.getReceivedDirectMessagesWithSinceId(refreshed_ids, null, getNewestMessageIdsFromDatabase(this, Inbox.CONTENT_URI)); //mService.getReceivedDirectMessages(refreshed_ids, null); } } super.onNewIntent(intent); }
From source file:com.android.mail.ui.AnimatedAdapter.java
public void onRestoreInstanceState(Bundle outState) { if (outState.containsKey(LAST_DELETING_ITEMS)) { final long[] lastDeleting = outState.getLongArray(LAST_DELETING_ITEMS); for (final long aLastDeleting : lastDeleting) { mLastDeletingItems.add(aLastDeleting); }/*from w w w. j av a 2s . co m*/ } if (outState.containsKey(LEAVE_BEHIND_ITEM_DATA)) { LeaveBehindData left = (LeaveBehindData) outState.getParcelable(LEAVE_BEHIND_ITEM_DATA); mLeaveBehindItems.put(outState.getLong(LEAVE_BEHIND_ITEM_ID), setupLeaveBehind(left.data, left.op, left.data.position, left.height)); } }