List of usage examples for android.os Bundle getStringArray
@Nullable
public String[] getStringArray(@Nullable String key)
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.DisplayStopDataFragment.java
/** * {@inheritDoc}//from w ww . ja v a 2 s . com */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get the various resources we need. final Context context = getActivity().getApplicationContext(); bsd = BusStopDatabase.getInstance(context); sd = SettingsDatabase.getInstance(context); sp = context.getSharedPreferences(PreferencesActivity.PREF_FILE, 0); hitboxSize = getResources().getDimensionPixelOffset(R.dimen.star_hitbox_size); // Get the stop code from the arguments bundle. stopCode = getArguments().getString(ARG_STOPCODE); // Get preferences. try { numDepartures = Integer .parseInt(sp.getString(PreferencesActivity.PREF_NUMBER_OF_SHOWN_DEPARTURES_PER_SERVICE, "4")); } catch (NumberFormatException e) { numDepartures = 4; } if (savedInstanceState != null) { lastRefresh = savedInstanceState.getLong(STATE_KEY_LAST_REFRESH, 0); autoRefresh = savedInstanceState.getBoolean(STATE_KEY_AUTOREFRESH, false); if (savedInstanceState.containsKey(STATE_KEY_EXPANDED_ITEMS)) { expandedServices.clear(); Collections.addAll(expandedServices, savedInstanceState.getStringArray(STATE_KEY_EXPANDED_ITEMS)); } } else { autoRefresh = sp.getBoolean(PreferencesActivity.PREF_AUTO_REFRESH, false); } }
From source file:com.free.searcher.MainFragment.java
@Override public void onViewStateRestored(Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); if (savedInstanceState == null) { return;//from w ww. j a v a2s . co m } Log.i("SearcheFragment.onViewStateRestored();", savedInstanceState + "uuu"); selectedFiles = savedInstanceState.getStringArray("selectedFiles"); if (savedInstanceState.getSerializable("files") instanceof File[]) { files = (File[]) savedInstanceState.getSerializable("files"); } if (savedInstanceState.getString("currentSearching") instanceof String) { currentSearching = savedInstanceState.getString("currentSearching"); } if (savedInstanceState.getString("currentZipFileName") instanceof String) { currentZipFileName = savedInstanceState.getString("currentZipFileName"); if (currentZipFileName.length() > 0) { try { extractFile = new ExtractFile(currentZipFileName, MainFragment.PRIVATE_PATH + currentZipFileName); } catch (RarException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } if (savedInstanceState.getString("load") instanceof String) { load = savedInstanceState.getString("load"); } if (savedInstanceState.getString("currentUrl") instanceof String) { currentUrl = savedInstanceState.getString("currentUrl"); } // HtmlSourceViewJavaScriptInterface.source = savedInstanceState.getString("source"); if (currentUrl != null && currentUrl.length() > 0) { (webTask = new WebTask(MainFragment.this, webView, currentUrl)).execute(); } if (mSearchView != null && savedInstanceState.getCharSequence("query") != null) { mSearchView.setQuery(savedInstanceState.getCharSequence("query"), false); } if (savedInstanceState.getString("status") instanceof String) { status = savedInstanceState.getCharSequence("status"); } locX = savedInstanceState.getInt("locX"); locY = savedInstanceState.getInt("locY"); webViewBundle = savedInstanceState.getBundle("webViewBundle"); if (savedInstanceState.getString("home") instanceof String) { home = savedInstanceState.getString("home"); } // webView.setOnTouchListener(new View.OnTouchListener() { // @Override // public boolean onTouch(View p1, MotionEvent event) { // //Log.d("onClick", p1 + ""); // Log.d("MotionEvent", event + ""); // if ((event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_POINTER_UP) && statusView != null) { // int curVis = statusView.getSystemUiVisibility(); // Log.d("curVis", curVis + ", " + ((curVis&View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0)); // SHOW = !SHOW; // Log.d("SHOW", SHOW + ""); // setNavVisibility(SHOW); //((curVis&View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0); // } // return false; // } // }); /** if (savedInstanceState.getString("readTextFiles") != null) { String[] readTextFilesStr = savedInstanceState.getString("readTextFiles").split(";;;"); // , // Util.listToString(readTextFiles,false, ";;;")); for (String textFile : readTextFilesStr) { readTextFiles.add(new File(textFile)); } } if (savedInstanceState.getString("initFolderFiles") != null) { String[] initFolderFilesStr = savedInstanceState.getString("initFolderFiles").split(";;;"); // , // Util.listToString(initFolderFiles,false, ";;;")); for (String folderFile : initFolderFilesStr) { initFolderFiles.add(new File(folderFile)); } } **/ }
From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor./*from w w w . j a v a 2s. c o m*/ * * @see Activity#onCreate */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CookieSyncManager.createInstance(getApplicationContext()); mSettings.loadRedditPreferences(this, mClient); setRequestedOrientation(mSettings.getRotation()); setTheme(mSettings.getTheme()); requestWindowFeature(Window.FEATURE_PROGRESS); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.profile_list_content); if (savedInstanceState != null) { if (Constants.LOGGING) Log.d(TAG, "using savedInstanceState"); mUsername = savedInstanceState.getString(Constants.USERNAME_KEY); mAfter = savedInstanceState.getString(Constants.AFTER_KEY); mBefore = savedInstanceState.getString(Constants.BEFORE_KEY); mCount = savedInstanceState.getInt(Constants.THREAD_COUNT_KEY); mLastAfter = savedInstanceState.getString(Constants.LAST_AFTER_KEY); mLastBefore = savedInstanceState.getString(Constants.LAST_BEFORE_KEY); mLastCount = savedInstanceState.getInt(Constants.THREAD_LAST_COUNT_KEY); mKarma = savedInstanceState.getStringArray(Constants.KARMA_KEY); mSortByUrl = savedInstanceState.getString(Constants.CommentsSort.SORT_BY_KEY); mJumpToThreadId = savedInstanceState.getString(Constants.JUMP_TO_THREAD_ID_KEY); mVoteTargetThingInfo = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY); // try to restore mThingsList using getLastNonConfigurationInstance() // (separate function to avoid a compiler warning casting ArrayList<ThingInfo> restoreLastNonConfigurationInstance(); if (mThingsList == null) { // Load previous page of profile items if (mLastAfter != null) { new DownloadProfileTask(mUsername, mLastAfter, null, mLastCount).execute(); } else if (mLastBefore != null) { new DownloadProfileTask(mUsername, null, mLastBefore, mLastCount).execute(); } else { new DownloadProfileTask(mUsername).execute(); } } else { // Orientation change. Use prior instance. resetUI(new ThingsListAdapter(this, mThingsList)); setTitle(mUsername + "'s profile"); } return; } // Handle subreddit Uri passed via Intent else if (getIntent().getData() != null) { Matcher userPathMatcher = USER_PATH_PATTERN.matcher(getIntent().getData().getPath()); if (userPathMatcher.matches()) { mUsername = userPathMatcher.group(1); new DownloadProfileTask(mUsername).execute(); return; } } // No username specified by Intent, so load the logged in user's profile if (mSettings.isLoggedIn()) { mUsername = mSettings.getUsername(); new DownloadProfileTask(mUsername).execute(); return; } // Can't find a username to use. Quit. if (Constants.LOGGING) Log.e(TAG, "Could not find a username to use for ProfileActivity"); finish(); }
From source file:com.fenlisproject.elf.core.framework.ElfBinder.java
public static void bindFragmentArgument(Fragment receiver) { Field[] fields = receiver.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true);//w w w. j av a 2 s .c o m FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class); if (fragmentArgument != null) { try { Bundle bundle = receiver.getArguments(); if (bundle != null) { Class<?> type = field.getType(); if (type == Boolean.class || type == boolean.class) { field.set(receiver, bundle.getBoolean(fragmentArgument.value())); } else if (type == Byte.class || type == byte.class) { field.set(receiver, bundle.getByte(fragmentArgument.value())); } else if (type == Character.class || type == char.class) { field.set(receiver, bundle.getChar(fragmentArgument.value())); } else if (type == Double.class || type == double.class) { field.set(receiver, bundle.getDouble(fragmentArgument.value())); } else if (type == Float.class || type == float.class) { field.set(receiver, bundle.getFloat(fragmentArgument.value())); } else if (type == Integer.class || type == int.class) { field.set(receiver, bundle.getInt(fragmentArgument.value())); } else if (type == Long.class || type == long.class) { field.set(receiver, bundle.getLong(fragmentArgument.value())); } else if (type == Short.class || type == short.class) { field.set(receiver, bundle.getShort(fragmentArgument.value())); } else if (type == String.class) { field.set(receiver, bundle.getString(fragmentArgument.value())); } else if (type == Boolean[].class || type == boolean[].class) { field.set(receiver, bundle.getBooleanArray(fragmentArgument.value())); } else if (type == Byte[].class || type == byte[].class) { field.set(receiver, bundle.getByteArray(fragmentArgument.value())); } else if (type == Character[].class || type == char[].class) { field.set(receiver, bundle.getCharArray(fragmentArgument.value())); } else if (type == Double[].class || type == double[].class) { field.set(receiver, bundle.getDoubleArray(fragmentArgument.value())); } else if (type == Float[].class || type == float[].class) { field.set(receiver, bundle.getFloatArray(fragmentArgument.value())); } else if (type == Integer[].class || type == int[].class) { field.set(receiver, bundle.getIntArray(fragmentArgument.value())); } else if (type == Long[].class || type == long[].class) { field.set(receiver, bundle.getLongArray(fragmentArgument.value())); } else if (type == Short[].class || type == short[].class) { field.set(receiver, bundle.getShortArray(fragmentArgument.value())); } else if (type == String[].class) { field.set(receiver, bundle.getStringArray(fragmentArgument.value())); } else if (Serializable.class.isAssignableFrom(type)) { field.set(receiver, bundle.getSerializable(fragmentArgument.value())); } else if (type == Bundle.class) { field.set(receiver, bundle.getBundle(fragmentArgument.value())); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:net.naonedbus.activity.MenuDrawerActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_drawer_base); final ActionBar actionBar = getSupportActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); mTitle = getTitle();/*from w w w. ja va 2 s.c om*/ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mAdapter = buildMainMenuAdapter(); mDrawerList.setAdapter(mAdapter); mDrawerList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mDrawerList.setOnItemClickListener(mOnMenuItemClickListener); mDrawerLayout.setDrawerListener(new DrawerListener() { @Override public void onDrawerStateChanged(int arg0) { } @Override public void onDrawerSlide(View arg0, float arg1) { } @Override public void onDrawerOpened(View arg0) { invalidateOptionsMenu(); } @Override public void onDrawerClosed(View arg0) { invalidateOptionsMenu(); } }); mSectionsPagerAdapter = new TabsAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(final int position) { getSupportActionBar().setSelectedNavigationItem(position); } }); mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); mTabs.setViewPager(mViewPager); mTabs.setShouldExpand(!getResources().getBoolean(R.bool.isTablet)); mSingleFragmentContent = (FrameLayout) findViewById(R.id.singleFragmentContent); if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_MENU_POSITION)) { final String[] fragmentsTags = savedInstanceState.getStringArray(BUNDLE_FRAGMENTS_TAGS); final boolean singleFragmentMode = fragmentsTags.length == 1; if (singleFragmentMode) { mFragmentsTags = fragmentsTags; } mCurrentMenuItem = Math.max(0, savedInstanceState.getInt(BUNDLE_MENU_POSITION)); selectNavigationItem(mCurrentMenuItem, !singleFragmentMode); } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rom_detail); Intent intent = getIntent();/* w w w .j a v a 2 s .co m*/ mRomInfo = intent.getParcelableExtra(EXTRA_ROM_INFO); mBootedRomInfo = intent.getParcelableExtra(EXTRA_BOOTED_ROM_INFO); mActiveRomId = intent.getStringExtra(EXTRA_ACTIVE_ROM_ID); if (savedInstanceState != null) { mTaskIdCacheWallpaper = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_CACHE_WALLPAPER); mTaskIdSwitchRom = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_SWITCH_ROM); mTaskIdSetKernel = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_SET_KERNEL); mTaskIdUpdateRamdisk = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_UPDATE_RAMDISK); mTaskIdWipeRom = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_WIPE_ROM); mTaskIdCreateLauncher = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_CREATE_LAUNCHER); mTaskIdGetRomDetails = savedInstanceState.getInt(EXTRA_STATE_TASK_ID_GET_ROM_DETAILS); mTaskIdsToRemove = savedInstanceState.getIntegerArrayList(EXTRA_STATE_TASK_IDS_TO_REMOVE); mResultIntent = savedInstanceState.getParcelable(EXTRA_STATE_RESULT_INTENT); setResult(RESULT_OK, mResultIntent); mBackupTargets = savedInstanceState.getStringArray(EXTRA_STATE_BACKUP_TARGETS); } final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mCoordinator = (CoordinatorLayout) findViewById(R.id.coordinator); mCollapsing = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); mWallpaper = (ImageView) findViewById(R.id.wallpaper); mFab = (FloatingActionButton) findViewById(R.id.fab); mRV = (RecyclerView) findViewById(R.id.main_rv); mFab.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { switchRom(false); } }); updateTitle(); updateMbtoolStatus(); initializeRecyclerView(); populateRomCardItem(); populateInfoItems(); populateActionItems(); }
From source file:org.opendatakit.survey.android.fragments.InstanceUploaderListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(ID, container, false); // set up long click listener mUploadButton = (Button) view.findViewById(R.id.upload_button); mUploadButton.setOnClickListener(new OnClickListener() { @Override/*from w w w . j a v a 2 s . c om*/ public void onClick(View arg0) { ConnectivityManager connectivityManager = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); if (ni == null || !ni.isConnected()) { Toast.makeText(getActivity(), R.string.no_connection, Toast.LENGTH_SHORT).show(); } else { // items selected uploadSelectedFiles(); mToggled = false; mSelected.clear(); clearChoices(); } } }); mToggleButton = (Button) view.findViewById(R.id.toggle_button); mToggleButton.setLongClickable(true); mToggleButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // toggle selections of items to all or none ListView ls = getListView(); mToggled = !mToggled; // remove all items from selected list mSelected.clear(); for (int pos = 0; pos < ls.getCount(); pos++) { ls.setItemChecked(pos, mToggled); // add all items if mToggled sets to select all if (mToggled) { Cursor c = (Cursor) ls.getItemAtPosition(pos); String uuid = ODKDatabaseUtils.get().getIndexAsString(c, c.getColumnIndex(InstanceColumns._ID)); mSelected.add(uuid); } } mUploadButton.setEnabled(!(mSelected.size() == 0)); } }); mToggleButton.setOnLongClickListener(this); if (savedInstanceState != null) { String[] selectedArray = savedInstanceState.getStringArray(BUNDLE_SELECTED_ITEMS_KEY); for (int i = 0; i < selectedArray.length; i++) mSelected.add(selectedArray[i]); // indicating whether or not select-all is on or off. if (savedInstanceState.containsKey(BUNDLE_TOGGLED_KEY)) { mToggled = savedInstanceState.getBoolean(BUNDLE_TOGGLED_KEY); } // to restore alert dialog. if (savedInstanceState.containsKey(DIALOG_TITLE)) { mAlertTitle = savedInstanceState.getString(DIALOG_TITLE); } if (savedInstanceState.containsKey(DIALOG_MSG)) { mAlertMsg = savedInstanceState.getString(DIALOG_MSG); } if (savedInstanceState.containsKey(DIALOG_STATE)) { mDialogState = DialogState.valueOf(savedInstanceState.getString(DIALOG_STATE)); } if (savedInstanceState.containsKey(SHOW_UNSENT)) { mShowUnsent = savedInstanceState.getBoolean(SHOW_UNSENT); } if (savedInstanceState.containsKey(URL)) { mUrl = URI.create(savedInstanceState.getString(URL)); } } mUploadButton.setEnabled(!(mSelected.size() == 0)); return view; }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTweetingsApplication().getServiceInterface(); mResolver = getContentResolver();/* w w w.j av a 2 s .co m*/ super.onCreate(savedInstanceState); setContentView(R.layout.compose); mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1; mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null; mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1; mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null; mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null; mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null; mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false; mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false; mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null; final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null; final String account_username = getAccountUsername(this, account_id); int text_selection_start = -1; mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false; if (mInReplyToStatusId > 0) { if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null && (mentions == null || mentions.length < 1)) { mText = bundle.getString(INTENT_KEY_TEXT); } else if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); text_selection_start = mText.indexOf(' ') + 1; } mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false; final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String name = display_name ? mInReplyToName : mInReplyToScreenName; if (name != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } TextView replyText = (TextView) findViewById(R.id.reply_text); if (!isNullOrEmpty(mInReplyToText)) { replyText.setVisibility(View.VISIBLE); replyText.setText(mInReplyToText); } else { replyText.setVisibility(View.GONE); } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); } if (mAccountIds == null || mAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ','); final long[] activated_ids = getActivatedAccountIds(this); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids); mAccountIds = intersection.length > 0 ? intersection : activated_ids; } final String action = getIntent().getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { setTitle(R.string.share); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (mText == null) { final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT); final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT); mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text)); } else { mText = bundle.getString(INTENT_KEY_TEXT); } if (mImageUri == null) { final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM); final String content_type = getIntent().getType(); if (extra_stream != null && content_type != null && content_type.startsWith("image/")) { final String real_path = getImagePathFromUri(this, extra_stream); final File file = real_path != null ? new File(real_path) : null; if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsImageAttached = true; mIsPhotoAttached = false; } else { mImageUri = null; mIsImageAttached = false; } } } } } else if (bundle != null) { if (bundle.getString(INTENT_KEY_TEXT) != null) { mText = bundle.getString(INTENT_KEY_TEXT); } } } final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme()) ? new File(mImageUri.getPath()) : null; final boolean image_file_valid = image_file != null && image_file.exists(); mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE); if (image_file_valid) { reloadAttachedImageThumbnail(image_file); } mImageThumbnailPreview.setOnClickListener(this); mImageThumbnailPreview.setOnLongClickListener(this); mMenuBar.setOnMenuItemClickListener(this); mMenuBar.inflate(R.menu.menu_compose); mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance()); mEditText.setImeOptions(EditorInfo.IME_ACTION_GO); mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); if (mText != null) { mEditText.setText(mText); if (mIsQuote) { mEditText.setSelection(0); } else if (text_selection_start != -1 && text_selection_start < mEditText.length() && mEditText.length() > 0) { mEditText.setSelection(text_selection_start, mEditText.length() - 1); } else if (mEditText.length() > 0) { mEditText.setSelection(mEditText.length()); } } invalidateSupportOptionsMenu(); setMenu(); if (mColorIndicator != null) { mColorIndicator.setOrientation(ColorView.VERTICAL); mColorIndicator.setColor(getAccountColors(this, mAccountIds)); } mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED) : false; mIsPossiblySensitive = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE) : false; }
From source file:org.totschnig.myexpenses.activity.ExpenseEdit.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case METHODS_CURSOR: Account a = getCurrentAccount(); if (a == null) return null; return new CursorLoader(this, TransactionProvider.METHODS_URI.buildUpon() .appendPath(TransactionProvider.URI_SEGMENT_TYPE_FILTER) .appendPath(mType == INCOME ? "1" : "-1").appendPath(a.type.name()).build(), null, null, null, null); case ACCOUNTS_CURSOR: return new CursorLoader(this, TransactionProvider.ACCOUNTS_BASE_URI, null, null, null, null); case LAST_EXCHANGE_CURSOR: String[] currencies = args.getStringArray(KEY_CURRENCY); return new CursorLoader(this, Transaction.CONTENT_URI.buildUpon().appendPath(TransactionProvider.URI_SEGMENT_LAST_EXCHANGE) .appendPath(currencies[0]).appendPath(currencies[1]).build(), null, null, null, null); }/*from ww w . j a v a 2 s . c o m*/ return null; }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.InAppFlashingFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { ArrayList<MbtoolAction> savedActions = savedInstanceState.getParcelableArrayList(EXTRA_PENDING_ACTIONS); mPendingActions.addAll(savedActions); }/*from w w w . j a v a2s.c o m*/ mProgressBar = (ProgressBar) getActivity().findViewById(R.id.card_list_loading); RecyclerView cardListView = (RecyclerView) getActivity().findViewById(R.id.card_list); mAdapter = new PendingActionCardAdapter(getActivity(), mPendingActions); cardListView.setHasFixedSize(true); cardListView.setAdapter(mAdapter); DragSwipeItemTouchCallback itemTouchCallback = new DragSwipeItemTouchCallback(this); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchCallback); itemTouchHelper.attachToRecyclerView(cardListView); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); cardListView.setLayoutManager(llm); final FloatingActionMenu fabMenu = (FloatingActionMenu) getActivity().findViewById(R.id.fab_add_item_menu); FloatingActionButton fabAddPatchedFile = (FloatingActionButton) getActivity() .findViewById(R.id.fab_add_patched_file); FloatingActionButton fabAddBackup = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_backup); fabAddPatchedFile.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { addPatchedFile(); fabMenu.close(true); } }); fabAddBackup.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { addBackup(); fabMenu.close(true); } }); if (savedInstanceState != null) { mSelectedUri = savedInstanceState.getParcelable(EXTRA_SELECTED_URI); mSelectedUriFileName = savedInstanceState.getString(EXTRA_SELECTED_URI_FILE_NAME); mSelectedBackupDirUri = savedInstanceState.getParcelable(EXTRA_SELECTED_BACKUP_DIR_URI); mSelectedBackupName = savedInstanceState.getString(EXTRA_SELECTED_BACKUP_NAME); mSelectedBackupTargets = savedInstanceState.getStringArray(EXTRA_SELECTED_BACKUP_TARGETS); mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID); mZipRomId = savedInstanceState.getString(EXTRA_ZIP_ROM_ID); mAddType = (Type) savedInstanceState.getSerializable(EXTRA_ADD_TYPE); mTaskIdVerifyZip = savedInstanceState.getInt(EXTRA_TASK_ID_VERIFY_ZIP); mQueryingMetadata = savedInstanceState.getBoolean(EXTRA_QUERYING_METADATA); } try { mActivityCallback = (OnReadyStateChangedListener) getActivity(); } catch (ClassCastException e) { throw new ClassCastException(getActivity().toString() + " must implement OnReadyStateChangedListener"); } mActivityCallback.onReady(!mPendingActions.isEmpty()); mPrefs = getActivity().getSharedPreferences("settings", 0); if (savedInstanceState == null) { boolean shouldShow = mPrefs.getBoolean(PREF_SHOW_FIRST_USE_DIALOG, true); if (shouldShow) { FirstUseDialog d = FirstUseDialog.newInstance(this, R.string.in_app_flashing_title, R.string.in_app_flashing_dialog_first_use); d.show(getFragmentManager(), CONFIRM_DIALOG_FIRST_USE); } } getActivity().getLoaderManager().initLoader(0, null, this); }