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.NearestStopsFragment.java
/** * {@inheritDoc}/*from w w w . j a va 2 s . c o m*/ */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); // Get references to required resources. locMan = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE); sp = activity.getSharedPreferences(PreferencesActivity.PREF_FILE, 0); bsd = BusStopDatabase.getInstance(activity.getApplicationContext()); sd = SettingsDatabase.getInstance(activity.getApplicationContext()); // Create the ArrayAdapter for the ListView. ad = new NearestStopsArrayAdapter(activity); // Initialise the services chooser Dialog. services = bsd.getBusServiceList(); if (savedInstanceState != null) { chosenServices = savedInstanceState.getStringArray(ARG_CHOSEN_SERVICES); } else { // Check to see if GPS is enabled then check to see if the GPS // prompt dialog has been disabled. if (!locMan.isProviderEnabled(LocationManager.GPS_PROVIDER) && !sp.getBoolean(PreferencesActivity.PREF_DISABLE_GPS_PROMPT, false)) { // Get the list of Activities which can handle the enabling of // location services. final List<ResolveInfo> packages = activity.getPackageManager() .queryIntentActivities(TurnOnGpsDialogFragment.TURN_ON_GPS_INTENT, 0); // If the list is not empty, this means Activities do exist. // Show Dialog asking users if they want to turn on GPS. if (packages != null && !packages.isEmpty()) { callbacks.onAskTurnOnGps(); } } } // Tell the underlying Activity that this Fragment contains an options // menu. setHasOptionsMenu(true); }
From source file:edu.stanford.junction.android.AndroidJunctionMaker.java
/** * Junction creator from a bundle passed from * a Junction Activity Director.//from w ww. j ava2 s . co m * * The bundle may contain the URI of an existing activity session * or an activity script for creating a new session. It may also * contain casting information. * * @param bundle * @param actor * @return */ public Junction newJunction(Bundle bundle, JunctionActor actor) throws JunctionException { if (bundle == null || !bundle.containsKey(Intents.EXTRA_JUNCTION_VERSION)) { Log.d("junction", "Could not launch from bundle (" + bundle + ")"); return null; } try { if (bundle.containsKey(Intents.EXTRA_ACTIVITY_SESSION_URI)) { // TODO: pass both activity script and uri if available? // TODO: still support casting? Log.d("junction", "joining existing session " + bundle.getString(Intents.EXTRA_ACTIVITY_SESSION_URI)); URI uri = new URI(bundle.getString(Intents.EXTRA_ACTIVITY_SESSION_URI)); Junction jx = newJunction(uri, actor); return jx; } else { JSONObject desc = new JSONObject(bundle.getString(Intents.EXTRA_ACTIVITY_SCRIPT)); ActivityScript activityDesc = new ActivityScript(desc); Junction jx; if (bundle.containsKey(Intents.EXTRA_CAST_ROLES)) { Log.d("junction", "casting roles"); String[] aroles = bundle.getStringArray(AndroidJunctionMaker.Intents.EXTRA_CAST_ROLES); String[] adirectors = bundle.getStringArray(AndroidJunctionMaker.Intents.EXTRA_CAST_DIRECTORS); List<String> roles = Arrays.asList(aroles); List<URI> directors = new LinkedList<URI>(); for (int i = 0; i < adirectors.length; i++) { directors.add(new URI(adirectors[i])); } Log.d("junction", "going to request casting for " + directors.size() + " roles"); Cast support = new Cast(roles, directors); jx = newJunction(activityDesc, actor, support); } else { jx = newJunction(activityDesc, actor); } return jx; } } catch (JunctionException e) { throw e; } catch (Exception e) { e.printStackTrace(System.err); throw new JunctionException(e); } }
From source file:github.popeen.dsub.activity.SubsonicActivity.java
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); int size = savedInstanceState.getInt(Constants.MAIN_BACK_STACK_SIZE); String[] ids = savedInstanceState.getStringArray(Constants.MAIN_BACK_STACK); FragmentManager fm = getSupportFragmentManager(); currentFragment = (SubsonicFragment) fm.findFragmentByTag(ids[0]); currentFragment.setPrimaryFragment(true); currentFragment.setSupportTag(ids[0]); supportInvalidateOptionsMenu();/*from w ww .j a v a 2s .c om*/ FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); for (int i = 1; i < size; i++) { SubsonicFragment frag = (SubsonicFragment) fm.findFragmentByTag(ids[i]); frag.setSupportTag(ids[i]); if (secondaryContainer != null) { frag.setPrimaryFragment(false, true); } trans.hide(frag); backStack.add(frag); } trans.commit(); // Current fragment is hidden in secondaryContainer if (secondaryContainer == null && !currentFragment.isVisible()) { trans = getSupportFragmentManager().beginTransaction(); trans.remove(currentFragment); trans.commit(); getSupportFragmentManager().executePendingTransactions(); trans = getSupportFragmentManager().beginTransaction(); trans.add(R.id.fragment_container, currentFragment, ids[0]); trans.commit(); } // Current fragment needs to be moved over to secondaryContainer else if (secondaryContainer != null && secondaryContainer.findViewById(currentFragment.getRootId()) == null && backStack.size() > 0) { trans = getSupportFragmentManager().beginTransaction(); trans.remove(currentFragment); trans.show(backStack.get(backStack.size() - 1)); trans.commit(); getSupportFragmentManager().executePendingTransactions(); trans = getSupportFragmentManager().beginTransaction(); trans.add(R.id.fragment_second_container, currentFragment, ids[0]); trans.commit(); secondaryContainer.setVisibility(View.VISIBLE); } lastSelectedPosition = savedInstanceState.getInt(Constants.FRAGMENT_POSITION); if (lastSelectedPosition != 0) { MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition); if (item != null) { item.setChecked(true); } } recreateSpinner(); checkIfServerOutdated(); }
From source file:org.odk.collect.android.activities.GoogleDriveActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarVisibility(true);/* w ww. j a v a 2s .com*/ setContentView(R.layout.drive_layout); listView = (ListView) findViewById(android.R.id.list); listView.setOnItemClickListener(this); emptyView = (TextView) findViewById(android.R.id.empty); initToolbar(); parentId = null; alertShowing = false; toDownload = new ArrayList<>(); if (savedInstanceState != null && savedInstanceState.containsKey(MY_DRIVE_KEY)) { // recover state on rotate myDrive = savedInstanceState.getBoolean(MY_DRIVE_KEY); String[] patharray = savedInstanceState.getStringArray(PATH_KEY); currentPath = buildPath(patharray); parentId = savedInstanceState.getString(PARENT_KEY); alertMsg = savedInstanceState.getString(ALERT_MSG_KEY); alertShowing = savedInstanceState.getBoolean(ALERT_SHOWING_KEY); ArrayList<DriveListItem> dl = savedInstanceState.getParcelableArrayList(DRIVE_ITEMS_KEY); adapter = new FileArrayAdapter(GoogleDriveActivity.this, R.layout.two_item_image, dl); listView.setAdapter(adapter); adapter.setEnabled(true); } else { // new myDrive = false; if (!isDeviceOnline()) { createAlertDialog(getString(R.string.no_connection)); } } // restore any task state if (getLastCustomNonConfigurationInstance() instanceof RetrieveDriveFileContentsAsyncTask) { retrieveDriveFileContentsAsyncTask = (RetrieveDriveFileContentsAsyncTask) getLastNonConfigurationInstance(); setProgressBarIndeterminateVisibility(true); } else { getFileTask = (GetFileTask) getLastNonConfigurationInstance(); if (getFileTask != null) { getFileTask.setGoogleDriveFormDownloadListener(this); } } if (getFileTask != null && getFileTask.getStatus() == AsyncTask.Status.FINISHED) { try { dismissDialog(PROGRESS_DIALOG); } catch (Exception e) { Timber.i("Exception was thrown while dismissing a dialog."); } } if (alertShowing) { try { dismissDialog(PROGRESS_DIALOG); } catch (Exception e) { // don't care... Timber.i("Exception was thrown while dismissing a dialog."); } createAlertDialog(alertMsg); } rootButton = (Button) findViewById(R.id.root_button); if (myDrive) { rootButton.setText(getString(R.string.go_shared)); } else { rootButton.setText(getString(R.string.go_drive)); } rootButton.setOnClickListener(this); backButton = (Button) findViewById(R.id.back_button); backButton.setEnabled(parentId != null); backButton.setOnClickListener(this); downloadButton = (Button) findViewById(R.id.download_button); downloadButton.setOnClickListener(this); searchText = (EditText) findViewById(R.id.search_text); searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { executeSearch(); return true; } return false; } }); searchButton = (ImageButton) findViewById(R.id.search_button); searchButton.setOnClickListener(this); // Initialize credentials and service object. credential = GoogleAccountCredential .usingOAuth2(getApplicationContext(), Collections.singletonList(DriveScopes.DRIVE)) .setBackOff(new ExponentialBackOff()); HttpTransport transport = AndroidHttp.newCompatibleTransport(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); driveService = new com.google.api.services.drive.Drive.Builder(transport, jsonFactory, credential) .setApplicationName("ODK-Collect").build(); getResultsFromApi(); }
From source file:android.support.v17.preference.LeanbackListPreferenceDialogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { final DialogPreference preference = getPreference(); mDialogTitle = preference.getDialogTitle(); mDialogMessage = preference.getDialogMessage(); if (preference instanceof ListPreference) { mMulti = false;// w w w .j a va 2s . c o m mEntries = ((ListPreference) preference).getEntries(); mEntryValues = ((ListPreference) preference).getEntryValues(); mInitialSelection = ((ListPreference) preference).getValue(); } else if (preference instanceof MultiSelectListPreference) { mMulti = true; mEntries = ((MultiSelectListPreference) preference).getEntries(); mEntryValues = ((MultiSelectListPreference) preference).getEntryValues(); mInitialSelections = ((MultiSelectListPreference) preference).getValues(); } else { throw new IllegalArgumentException( "Preference must be a ListPreference or " + "MultiSelectListPreference"); } } else { mDialogTitle = savedInstanceState.getCharSequence(SAVE_STATE_TITLE); mDialogMessage = savedInstanceState.getCharSequence(SAVE_STATE_MESSAGE); mMulti = savedInstanceState.getBoolean(SAVE_STATE_IS_MULTI); mEntries = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRIES); mEntryValues = savedInstanceState.getCharSequenceArray(SAVE_STATE_ENTRY_VALUES); if (mMulti) { final String[] initialSelections = savedInstanceState.getStringArray(SAVE_STATE_INITIAL_SELECTIONS); mInitialSelections = new ArraySet<>(initialSelections != null ? initialSelections.length : 0); if (initialSelections != null) { Collections.addAll(mInitialSelections, initialSelections); } } else { mInitialSelection = savedInstanceState.getString(SAVE_STATE_INITIAL_SELECTION); } } }
From source file:org.mariotaku.twidere.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mTwitterWrapper = getTwidereApplication().getTwitterWrapper(); mResolver = getContentResolver();/*w ww . j a v a 2 s .com*/ super.onCreate(savedInstanceState); 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; } setContentView(R.layout.compose); getSupportActionBar().setDisplayHomeAsUpEnabled(true); 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; 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 int notification_id = bundle != null ? bundle.getInt(INTENT_KEY_NOTIFICATION_ID, -1) : -1; if (notification_id != -1) { mTwitterWrapper.clearNotification(notification_id); } final String account_screen_name = getAccountScreenName(this, account_id); int text_selection_start = -1; 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_screen_name)) { builder.append('@' + account_screen_name + ' '); } else if (!mention.equalsIgnoreCase(account_screen_name)) { 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_screen_name = NAME_DISPLAY_OPTION_SCREEN_NAME .equals(mPreferences.getString(PREFERENCE_KEY_NAME_DISPLAY_OPTION, NAME_DISPLAY_OPTION_BOTH)); if (mInReplyToScreenName != null && mInReplyToName != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, display_screen_name ? mInReplyToScreenName : mInReplyToName)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_screen_name)) { builder.append('@' + account_screen_name + ' '); } else if (!mention.equalsIgnoreCase(account_screen_name)) { 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[] intersection = ArrayUtils.intersection(ids_in_prefs, account_ids); mAccountIds = intersection.length > 0 ? intersection : account_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); final Menu menu = mMenuBar.getMenu(); final MenuItem extensions = menu.findItem(MENU_EXTENSIONS_SUBMENU); if (extensions != null) { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_COMPOSE); final Bundle extras = new Bundle(); final String screen_name = mAccountIds != null && mAccountIds.length > 0 ? getAccountScreenName(this, mAccountIds[0]) : null; extras.putString(INTENT_KEY_TEXT, parseString(mEditText.getText())); extras.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, mInReplyToScreenName); extras.putString(INTENT_KEY_IN_REPLY_TO_NAME, mInReplyToName); extras.putString(INTENT_KEY_SCREEN_NAME, screen_name); extras.putLong(INTENT_KEY_IN_REPLY_TO_ID, mInReplyToStatusId); intent.putExtras(extras); addIntentToSubMenu(this, extensions.getSubMenu(), intent); } mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { 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()); } } setMenu(); mColorIndicator.setColors(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:com.ichi2.anki.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { Timber.d("onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.note_editor); Intent intent = getIntent();/* ww w . j a va 2s .com*/ if (savedInstanceState != null) { mCaller = savedInstanceState.getInt("caller"); mAddNote = savedInstanceState.getBoolean("addFact"); mCurrentDid = savedInstanceState.getLong("did"); mSelectedTags = new ArrayList<>(Arrays.asList(savedInstanceState.getStringArray("tags"))); mSavedFields = savedInstanceState.getBundle("editFields"); } else { mCaller = intent.getIntExtra(EXTRA_CALLER, CALLER_NOCALLER); if (mCaller == CALLER_NOCALLER) { String action = intent.getAction(); if (action != null && (ACTION_CREATE_FLASHCARD.equals(action) || ACTION_CREATE_FLASHCARD_SEND.equals(action))) { mCaller = CALLER_CARDEDITOR_INTENT_ADD; } } } startLoadingCollection(); }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java
@Override public void onActivityCreated(Bundle bundle) { if (null != bundle) { //Log.e("Saving","Found a bundle!!!!"); if (bundle.containsKey("eventStateAcknowledged") && bundle.getBoolean("eventStateAcknowledged")) { ackIcon.setImageResource(R.drawable.ic_acknowledged); isAcknowledged = true;/*w w w.j a v a 2 s .c o m*/ } if (bundle.containsKey("Title")) Title.setText(bundle.getString("Title")); if (bundle.containsKey("Component")) Component.setText(bundle.getString("Component")); if (bundle.containsKey("EventClass")) EventClass.setText(bundle.getString("EventClass")); if (bundle.containsKey("Summary")) Summary.setText(Html.fromHtml(bundle.getString("Summary"), null, null)); if (bundle.containsKey("FirstTime")) FirstTime.setText(bundle.getString("FirstTime")); if (bundle.containsKey("LastTime")) LastTime.setText(bundle.getString("LastTime")); if (bundle.containsKey("EventCount")) EventCount.setText(bundle.getString("EventCount")); if (bundle.containsKey("agent")) agent.setText(bundle.getString("agent")); if (bundle.containsKey("LogEntries")) { try { String[] LogEntries = bundle.getStringArray("LogEntries"); int LogEntryCount = LogEntries.length; for (int i = 0; i < LogEntryCount; i++) { TextView newLog = new TextView(getActivity()); newLog.setText(Html.fromHtml(LogEntries[i])); newLog.setPadding(0, 6, 0, 6); logList.addView(newLog); } } catch (Exception e) { e.printStackTrace(); BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "oncreate bundle", e); } } if (bundle.containsKey("img")) { try { img.setImageBitmap((Bitmap) bundle.getParcelable("img")); img.invalidate(); } catch (Exception e) { e.printStackTrace(); BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "oncreate bundle image", e); } } progressbar.setVisibility(View.INVISIBLE); } else { //Log.e("Saving","Didn't find any data so getting it"); preLoadData(); } super.onActivityCreated(bundle); }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@SuppressWarnings("unchecked") @Override/* ww w . j a v a 2s . c om*/ public void onCreate(Bundle savedState) { super.onCreate(savedState); initViews(); if (formLocation) queryLocation(true); if (savedState != null) { if (savedState.containsKey("tempfile")) tempFile = new File(savedState.getString("tempfile")); if (savedState.containsKey("target")) resolveTarget(savedState.getString("target")); if (savedState.containsKey("tempfiles")) tempFiles = savedState.getStringArrayList("tempfiles"); if (savedState.containsKey("contents")) { contents = new ArrayList<Uri>(); String[] carr = savedState.getStringArray("contents"); for (String s : carr) contents.add(Uri.parse(s)); } } postfix = "from <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; Button uploadVisit = (Button) findViewById(R.id.upload_visit); if (passThrough || target == null) uploadVisit.setEnabled(false); else uploadVisit.setEnabled(true); /* populate data by getting STREAM parameter */ Intent i = getIntent(); Bundle b = i.getExtras(); String action = i.getAction(); if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) { called = true; if (i.hasExtra(Intent.EXTRA_STREAM)) { Object o = b.get(Intent.EXTRA_STREAM); /* quick and dirty. any better idea? */ try { contents.add((Uri) o); } catch (Exception e1) { try { contents = (ArrayList<Uri>) ((ArrayList<Uri>) o).clone(); } catch (Exception e2) { } } boolean exceeded = false; if (contents.size() > 5) { exceeded = true; do { contents.remove(5); } while (contents.size() > 5); } galleryChanged = true; updateImageButtons(); resetThumbnails(); updateGallery(); if (exceeded) Toast.makeText(this, " 5 . 5 ??? ? ?.", Toast.LENGTH_LONG).show(); } if (i.hasExtra(Intent.EXTRA_TEXT)) { ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TEXT)); } } else if (action.equals("share")) { called = true; /* HTC web browser uses non-standard intent */ ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TITLE)); } else if (action.equals(Intent.ACTION_VIEW)) { Uri uri = i.getData(); if (i.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { passThrough = true; Pattern p = Pattern.compile("id=([\\-a-zA-Z0-9_]+)"); Matcher m = p.matcher(uri.toString()); if (m.find()) { resolveTarget(m.group(1)); } else { passThrough = false; } if (uri.getHost().equals(Application.HOST_DCMYS)) { destination = Application.DESTINATION_DCMYS; postfix = "from dc.m.dcmys.kr w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_MOOLZO)) { destination = Application.DESTINATION_MOOLZO; postfix = "- From m.oolzo.com w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_DCINSIDE)) { destination = Application.DESTINATION_DCINSIDE; } setDefaultImage(); } } reloadConfigurations(); }
From source file:com.github.michalbednarski.intentslab.providerlab.AdvancedQueryActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.advanced_query); Intent intent = getIntent();//from w w w . j a v a 2 s . c o m Bundle instanceStateOrExtras = savedInstanceState != null ? savedInstanceState : intent.getExtras(); if (instanceStateOrExtras == null) { instanceStateOrExtras = Bundle.EMPTY; } // Uri mUriTextView = (AutoCompleteTextView) findViewById(R.id.uri); if (intent.getData() != null) { mUriTextView.setText(intent.getDataString()); } mUriTextView.setAdapter(new UriAutocompleteAdapter(this)); // Projection { mSpecifyProjectionCheckBox = (CheckBox) findViewById(R.id.specify_projection); mProjectionLayout = (LinearLayout) findViewById(R.id.projection_columns); // Bind events for master CheckBox and add new button findViewById(R.id.new_projection_column).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new UserProjectionColumn(""); } }); mSpecifyProjectionCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mProjectionLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE); } }); // Get values to fill String[] availableProjectionColumns = intent.getStringArrayExtra(EXTRA_PROJECTION_AVAILABLE_COLUMNS); String[] specifiedProjectionColumns = instanceStateOrExtras.getStringArray(EXTRA_PROJECTION); if (specifiedProjectionColumns == null) { mSpecifyProjectionCheckBox.setChecked(false); } if (availableProjectionColumns != null && availableProjectionColumns.length == 0) { availableProjectionColumns = null; } if (availableProjectionColumns != null && specifiedProjectionColumns == null) { specifiedProjectionColumns = availableProjectionColumns; } // Create available column checkboxes int i = 0; if (availableProjectionColumns != null) { for (String availableProjectionColumn : availableProjectionColumns) { boolean isChecked = i < specifiedProjectionColumns.length && availableProjectionColumn.equals(specifiedProjectionColumns[i]); new DefaultProjectionColumn(availableProjectionColumn, isChecked); if (isChecked) { i++; } } } // Create user column text fields if (specifiedProjectionColumns != null && i < specifiedProjectionColumns.length) { for (int il = specifiedProjectionColumns.length; i < il; i++) { new UserProjectionColumn(specifiedProjectionColumns[i]); } } } // Selection { // Find views mSelectionCheckBox = (CheckBox) findViewById(R.id.selection_header); mSelectionText = (TextView) findViewById(R.id.selection); mSelectionLayout = findViewById(R.id.selection_layout); mSelectionArgsTable = (TableLayout) findViewById(R.id.selection_args); // Bind events for add button and master CheckBox findViewById(R.id.selection_add_arg).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new SelectionArg("", true); } }); mSelectionCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mSelectionLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE); } }); // Fill selection text view and CheckBox String selection = intent.getStringExtra(EXTRA_SELECTION); String[] selectionArgs = instanceStateOrExtras.getStringArray(EXTRA_SELECTION_ARGS); mSelectionCheckBox.setChecked(selection != null); if (selection != null) { mSelectionText.setText(selection); } // Fill selection arguments if ((selection != null || savedInstanceState != null) && selectionArgs != null && selectionArgs.length != 0) { for (String selectionArg : selectionArgs) { new SelectionArg(selectionArg); } } } // Content values { // Find views mContentValuesHeader = (TextView) findViewById(R.id.content_values_header); mContentValuesTable = (TableLayout) findViewById(R.id.content_values); mContentValuesTableHeader = (TableRow) findViewById(R.id.content_values_table_header); // Bind add new button event findViewById(R.id.new_content_value).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new ContentValue("", "", true); } }); // Create table ContentValues contentValues = instanceStateOrExtras.getParcelable(EXTRA_CONTENT_VALUES); if (contentValues != null) { contentValues.valueSet(); for (String key : Utils.getKeySet(contentValues)) { new ContentValue(key, contentValues.getAsString(key)); } } } // Order { // Find views mSpecifyOrderCheckBox = (CheckBox) findViewById(R.id.specify_order); mOrderTextView = (TextView) findViewById(R.id.order); // Bind events mSpecifyOrderCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mOrderTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE); } }); // Fill fields String order = intent.getStringExtra(EXTRA_SORT_ORDER); if (order == null) { mSpecifyOrderCheckBox.setChecked(false); } else { mOrderTextView.setText(order); } } // Method (affects previous views so they must be initialized first) mMethodSpinner = (Spinner) findViewById(R.id.method); mMethodSpinner .setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, METHOD_NAMES)); mMethodSpinner.setOnItemSelectedListener(onMethodSpinnerItemSelectedListener); mMethodSpinner.setSelection(intent.getIntExtra(EXTRA_METHOD, METHOD_QUERY)); }