List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragment.java
/** * Get data retrieved with the intent, or restore state * @param savedInstanceState the previously saved state *///from w w w . j av a 2 s .c om @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // initialize the producten & vaste producten values String[] productParams = getResources().getStringArray(R.array.array_product_param); for (String product : productParams) { mProducten.put(product, -1); mProductenVast.put(product, -1); } // get settings from the shared preferences SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); mMarktId = settings.getInt(getString(R.string.sharedpreferences_key_markt_id), 0); mActiveAccountId = settings.getInt(getString(R.string.sharedpreferences_key_account_id), 0); mActiveAccountNaam = settings.getString(getString(R.string.sharedpreferences_key_account_naam), null); // get the date of today for the dag param SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.date_format_dag)); mDagToday = sdf.format(new Date()); // only on fragment creation, not on rotation/re-creation if (savedInstanceState == null) { // check if we are editing an existing dagvergunning or making a new one Intent intent = getActivity().getIntent(); if ((intent != null) && (intent.hasExtra( MakkelijkeMarktProvider.mTableDagvergunning + MakkelijkeMarktProvider.Dagvergunning.COL_ID))) { int dagvergunningId = intent.getIntExtra( MakkelijkeMarktProvider.mTableDagvergunning + MakkelijkeMarktProvider.Dagvergunning.COL_ID, 0); if (dagvergunningId != 0) { mId = dagvergunningId; } } // init loader if an existing dagvergunning was selected if (mId > 0) { // create an argument bundle with the dagvergunning id and initialize the loader Bundle args = new Bundle(); args.putInt(MakkelijkeMarktProvider.Dagvergunning.COL_ID, mId); getLoaderManager().initLoader(DAGVERGUNNING_LOADER, args, this); // show the progressbar (because we are fetching the koopman from the api later in the onloadfinished) mProgressbar.setVisibility(View.VISIBLE); } else { // check time in hours since last fetched the sollicitaties for selected markt long diffInHours = getResources() .getInteger(R.integer.makkelijkemarkt_api_sollicitaties_fetch_interval_hours); if (settings .contains(getContext().getString(R.string.sharedpreferences_key_sollicitaties_last_fetched) + mMarktId)) { long lastFetchTimestamp = settings.getLong( getContext().getString(R.string.sharedpreferences_key_sollicitaties_last_fetched) + mMarktId, 0); long differenceMs = new Date().getTime() - lastFetchTimestamp; diffInHours = TimeUnit.MILLISECONDS.toHours(differenceMs); } // if last sollicitaties fetched more than 12 hours ago, fetch them again if (diffInHours >= getResources() .getInteger(R.integer.makkelijkemarkt_api_sollicitaties_fetch_interval_hours)) { // show progress dialog mGetSollicitatiesProcessDialog.show(); ApiGetSollicitaties getSollicitaties = new ApiGetSollicitaties(getContext()); getSollicitaties.setMarktId(mMarktId); getSollicitaties.enqueue(); } } } else { // restore dagvergunning data from saved state mMarktId = savedInstanceState.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_MARKT_ID); mDag = savedInstanceState.getString(MakkelijkeMarktProvider.Dagvergunning.COL_DAG); mId = savedInstanceState.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_ID); mErkenningsnummer = savedInstanceState .getString(MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_WAARDE); mErkenningsnummerInvoerMethode = savedInstanceState .getString(MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_METHODE); mRegistratieDatumtijd = savedInstanceState .getString(MakkelijkeMarktProvider.Dagvergunning.COL_REGISTRATIE_DATUMTIJD); mRegistratieGeolocatieLatitude = savedInstanceState .getDouble(MakkelijkeMarktProvider.Dagvergunning.COL_REGISTRATIE_GEOLOCATIE_LAT); mRegistratieGeolocatieLongitude = savedInstanceState .getDouble(MakkelijkeMarktProvider.Dagvergunning.COL_REGISTRATIE_GEOLOCATIE_LONG); mTotaleLengte = savedInstanceState.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_TOTALE_LENGTE); mSollicitatieStatus = savedInstanceState .getString(MakkelijkeMarktProvider.Dagvergunning.COL_STATUS_SOLLICITATIE); mKoopmanAanwezig = savedInstanceState.getString(MakkelijkeMarktProvider.Dagvergunning.COL_AANWEZIG); mKoopmanId = savedInstanceState.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_KOOPMAN_ID); mKoopmanVoorletters = savedInstanceState.getString(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS); mKoopmanAchternaam = savedInstanceState.getString(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM); mKoopmanFoto = savedInstanceState.getString(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL); mRegistratieAccountId = savedInstanceState .getInt(MakkelijkeMarktProvider.Dagvergunning.COL_REGISTRATIE_ACCOUNT_ID); mRegistratieAccountNaam = savedInstanceState.getString(MakkelijkeMarktProvider.Account.COL_NAAM); mSollicitatieId = savedInstanceState.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_SOLLICITATIE_ID); mSollicitatieNummer = savedInstanceState .getInt(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER); mNotitie = savedInstanceState.getString(MakkelijkeMarktProvider.Dagvergunning.COL_NOTITIE); mProducten = (HashMap<String, Integer>) savedInstanceState.getSerializable(STATE_BUNDLE_KEY_PRODUCTS); mProductenVast = (HashMap<String, Integer>) savedInstanceState .getSerializable(STATE_BUNDLE_KEY_PRODUCTS_VAST); mVervangerId = savedInstanceState.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_VERVANGER_ID); mVervangerErkenningsnummer = savedInstanceState .getString(MakkelijkeMarktProvider.Dagvergunning.COL_VERVANGER_ERKENNINGSNUMMER); // select tab of viewpager from saved fragment state (if it's different) if (mViewPager.getCurrentItem() != mCurrentTab) { mViewPager.setCurrentItem(mCurrentTab); } } // set the right wizard menu depending on the current tab position setWizardMenu(mCurrentTab); // prevent the keyboard from popping up on first pager fragment load Utility.hideKeyboard(getActivity()); // // TODO: get credentials and payleven api-key from mm api // // decrypt loaded credentials // String paylevenMerchantEmail = "marco@langebeeke.com"; // String paylevenMerchantPassword = "unknown"; // String paylevenApiKey = "unknown"; // // // register with payleven api // PaylevenFactory.registerAsync( // getContext(), // paylevenMerchantEmail, // paylevenMerchantPassword, // paylevenApiKey, // new PaylevenRegistrationListener() { // @Override // public void onRegistered(Payleven payleven) { // mPaylevenApi = payleven; // Utility.log(getContext(), LOG_TAG, "Payleven Registered!"); // } // @Override // public void onError(PaylevenError error) { // Utility.log(getContext(), LOG_TAG, "Payleven registration Error: " + error.getMessage()); // } // }); // TODO: in the overzicht step change 'Opslaan' into 'Afrekenen' and show a payment dialog when clicked // TODO: if the bluetooth payleven cardreader has not been paired yet inform the toezichthouder, show instructions and open the bluetooth settings // TODO: give the toezichthouder the option in the payment dialog to save without payleven and make the payment with an old pin device? // TODO: the payment dialog shows: // - logo's of the accepted debit card standards // - total amount to pay // (this can be the difference between a changed dagvergunning and an already paid amount, // or the total amount if it is a new dagvergunning. we don't pay refunds using the app? // refunds can be done by the beheerder using the dashboard? // or do we allow refunds in the app? In that case we need to inform the toezichthouder // that a refund will be made, and keep him informed about the status of the trasnaction) // - 'start payment/refund' button? // - instructions for making the payment using the payleven cardreader // - optionally a selection list to select the bluetooth cardreader if it was not yet selected before // (if it was already selected before, show the selected reader with a 'wiebertje' in front. when // clicked it will show the list of cardreaders that can be selected) // - status of the transaction // TODO: when the payment is done succesfully we safe the dagvergunning and close the dialog and the dagvergunning activity }
From source file:com.androzic.MapActivity.java
@Override protected void onNewIntent(Intent intent) { Log.e(TAG, "onNewIntent()"); if (intent.hasExtra("launch")) { Serializable object = intent.getExtras().getSerializable("launch"); if (Class.class.isInstance(object)) { Intent launch = new Intent(this, (Class<?>) object); launch.putExtras(intent);/*from ww w.jav a 2 s . c om*/ launch.removeExtra("launch"); startActivity(launch); } } else if (intent.hasExtra("lat") && intent.hasExtra("lon")) { Androzic application = (Androzic) getApplication(); application.ensureVisible(intent.getExtras().getDouble("lat"), intent.getExtras().getDouble("lon")); } }
From source file:eu.faircode.adblocker.ServiceSinkhole.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null && intent.hasExtra(EXTRA_COMMAND) && intent.getSerializableExtra(EXTRA_COMMAND) == Command.set) { set(intent);/*from w w w .j av a 2 s . co m*/ return START_STICKY; } // Keep awake getLock(this).acquire(); // Handle service restart if (intent == null) { Log.i(TAG, "Restart"); // Get enabled SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean enabled = prefs.getBoolean("enabled", false); // Recreate intent intent = new Intent(this, ServiceSinkhole.class); intent.putExtra(EXTRA_COMMAND, enabled ? Command.start : Command.stop); } if (ACTION_HOUSE_HOLDING.equals(intent.getAction())) intent.putExtra(EXTRA_COMMAND, Command.householding); Command cmd = (Command) intent.getSerializableExtra(EXTRA_COMMAND); String reason = intent.getStringExtra(EXTRA_REASON); Log.i(TAG, "Start intent=" + intent + " command=" + cmd + " reason=" + reason + " vpn=" + (vpn != null) + " user=" + (Process.myUid() / 100000)); commandHandler.queue(intent); return START_STICKY; }
From source file:com.ichi2.anki.CardBrowser.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // FIXME:/* w ww.java 2 s. c o m*/ Timber.d("onActivityResult(requestCode=%d, resultCode=%d)", requestCode, resultCode); super.onActivityResult(requestCode, resultCode, data); if (resultCode == DeckPicker.RESULT_DB_ERROR) { closeCardBrowser(DeckPicker.RESULT_DB_ERROR); } if (requestCode == EDIT_CARD && resultCode != RESULT_CANCELED) { Timber.i("CardBrowser:: CardBrowser: Saving card..."); DeckTask.launchDeckTask(DeckTask.TASK_TYPE_UPDATE_FACT, mUpdateCardHandler, new DeckTask.TaskData(sCardBrowserCard, false)); } else if (requestCode == ADD_NOTE && resultCode == RESULT_OK) { if (mSearchView != null) { mSearchTerms = mSearchView.getQuery().toString(); searchCards(); } else { Timber.w("Note was added from browser and on return mSearchView == null"); } } if (requestCode == EDIT_CARD && data != null && data.hasExtra("reloadRequired")) { // if reloadRequired flag was sent from note editor then reload card list searchCards(); // keep track of changes for reviewer if (currentCardInUseByReviewer()) { mReloadRequired = true; } } }
From source file:com.fvd.nimbus.PaintActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { ContentResolver cr;//ww w.j ava 2s .c om InputStream is; if (requestCode == TAKE_PHOTO) { showProgress(false); if (resultCode == -1) { try { if (data != null) { if (data.hasExtra("data")) { //Bitmap bm = ; drawView.setVisibility(View.INVISIBLE); drawView.recycle(); drawView.setBitmap((Bitmap) data.getParcelableExtra("data"), 0); drawView.setVisibility(View.VISIBLE); } } else { if (outputFileUri != null) { cr = getContentResolver(); try { is = cr.openInputStream(outputFileUri); Bitmap bmp = BitmapFactory.decodeStream(is); if (bmp.getWidth() != -1 && bmp.getHeight() != -1) { drawView.setVisibility(View.INVISIBLE); drawView.recycle(); drawView.setBitmap(bmp, 0); drawView.setVisibility(View.VISIBLE); } } catch (Exception e) { appSettings.appendLog("paint:onCreate " + e.getMessage()); } } } } catch (Exception e) { appSettings.appendLog("main:onActivityResult: exception - " + e.getMessage()); } } ((ViewAnimator) findViewById(R.id.top_switcher)).setDisplayedChild(0); } else if (requestCode == TAKE_PICTURE) { showProgress(false); if (resultCode == -1 && data != null) { boolean temp = false; try { Uri resultUri = data.getData(); String drawString = resultUri.getPath(); InputStream input = getContentResolver().openInputStream(resultUri); drawView.setVisibility(View.INVISIBLE); drawView.recycle(); drawView.setBitmap(BitmapFactory.decodeStream(input), 0); //drawView.forceRedraw(); drawView.setVisibility(View.VISIBLE); } catch (Exception e) { appSettings.appendLog("main:onActivityResult " + e.getMessage()); } } ((ViewAnimator) findViewById(R.id.top_switcher)).setDisplayedChild(0); } else if (requestCode == SHOW_SETTINGS) { switch (resultCode) { case RESULT_FIRST_USER + 1: Intent i = new Intent(getApplicationContext(), PrefsActivity.class); startActivity(i); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 2: if (appSettings.sessionId.length() == 0) showLogin(); else { appSettings.sessionId = ""; //serverHelper.getInstance().setSessionId(appSettings.sessionId); Editor e = prefs.edit(); e.putString("userMail", userMail); e.putString("userPass", ""); e.putString("sessionId", appSettings.sessionId); e.commit(); showLogin(); } break; case RESULT_FIRST_USER + 3: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationInfo().packageName))); } catch (Exception e) { } case RESULT_FIRST_USER + 4: Uri uri = Uri.parse( "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 5: final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // no alert dialog shown //alertDialogShown = null; // canceled setResult(RESULT_CANCELED); // and finish //finish(); } }); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setTitle(getString(R.string.license_title)); // and show //alertDialogShown = alertDialog; try { alertDialog.show(); } catch (final java.lang.Exception e) { // nothing to do } catch (final java.lang.Error e) { // nothing to do } break; default: break; } } if (requestCode == 3) { if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) { userMail = data.getStringExtra("userMail"); userPass = data.getStringExtra("userPass"); if (resultCode == RESULT_OK) sendRequest("user:auth", String.format("\"email\":\"%s\",\"password\":\"%s\"", userMail, userPass)); else serverHelper.getInstance().sendOldRequest("user_register", String.format( "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}", userMail, userPass), ""); } } else if (requestCode == 11) { if (appSettings.sessionId != "") { sessionId = appSettings.sessionId; userPass = appSettings.userPass; sendShot(); } } else if (requestCode == 4) { if (resultCode == RESULT_OK) { String id = data.getStringExtra("id").toString(); serverHelper.getInstance().shareShot(id); } } else if (resultCode == RESULT_OK) { drawView.setColour(dColor); setPaletteColor(dColor); Uri resultUri = data.getData(); String drawString = resultUri.getPath(); String galleryString = getGalleryPath(resultUri); if (galleryString != null) { drawString = galleryString; } // else another file manager was used else { if (drawString.contains("//")) { drawString = drawString.substring(drawString.lastIndexOf("//")); } } // set the background to the selected picture if (drawString.length() > 0) { Drawable drawBackground = Drawable.createFromPath(drawString); drawView.setBackgroundDrawable(drawBackground); } } }
From source file:com.kncwallet.wallet.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container, false); contactsListView = (ListView) view.findViewById(R.id.send_coins_contacts_list); viewBalanceBtc = (CurrencyTextView) view.findViewById(R.id.wallet_balance_btc); txText = (EditText) view.findViewById(R.id.send_coins_text); viewBalanceLocal = (CurrencyTextView) view.findViewById(R.id.wallet_balance_local); viewBalanceLocal.setPrecision(Constants.LOCAL_PRECISION, 0); viewBalanceLocal.setStrikeThru(Constants.TEST); viewBalanceBtc.setOnClickListener(new OnClickListener() { @Override// w ww.java 2 s . co m public void onClick(final View v) { SendCoinsFragment.this.switchBalance(); } }); viewBalanceLocal.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { SendCoinsFragment.this.switchBalance(); } }); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { startReceivingAddressActionMode(); } else { clearActionMode(); } } }); btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(DenominationUtil.getCurrencyCode(btcShift)); btcAmountView.setInputPrecision(DenominationUtil.getMaxPrecision(btcShift)); btcAmountView.setHintPrecision(btcPrecision); btcAmountView.setShift(btcShift); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable); bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); validateAmounts(true); if (everythingValid()) handleGo(); } }); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) initStateFromBitcoinUri(intentUri); else if (intent.hasExtra(SendCoinsFragment.INTENT_EXTRA_ADDRESS)) initStateFromIntentExtras(intent.getExtras()); } TextView header = ((TextView) view.findViewById(R.id.header_text)); header.setText(R.string.send_heading); contactListAdapter = new SimpleCursorAdapter(activity, R.layout.address_book_row_small, null, new String[] { AddressBookProvider.KEY_ADDRESS, AddressBookProvider.KEY_LABEL, AddressBookProvider.KEY_ADDRESS, AddressBookProvider.KEY_ADDRESS }, new int[] { R.id.address_book_contact_image, R.id.address_book_row_label, R.id.address_book_row_address, R.id.address_book_row_source_image }); contactListAdapter.setViewBinder(new ViewBinder() { @Override public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) { if (view.getId() == R.id.address_book_contact_image) { //... SmartImageView img = (SmartImageView) view; //img.setImageBitmap(bm); String address = cursor.getString(columnIndex); Bitmap contactImage = AddressBookProvider.bitmapForAddress(SendCoinsFragment.this.getActivity(), address); if (contactImage != null) { img.setImageBitmap(contactImage); } else { String imageUrl = ContactImage.getImageUrl(activity, AddressBookProvider.resolveRowId(activity, address)); if (imageUrl != null) { img.setImageUrl(imageUrl, R.drawable.contact_placeholder); } else { img.setImageResource(R.drawable.contact_placeholder); } } return true; //true because the data was bound to the view } else if (view.getId() == R.id.address_book_row_source_image) { ((ImageView) view).setImageResource(cachedSourceImageResource(cursor.getString(columnIndex))); return true; } //Constants.ADDRESS_FORMAT_LINE_SIZE)); return false; } }); boolean smallScreen = getResources().getBoolean(R.bool.values_small); if (!smallScreen) { ListView list = (ListView) contactsListView; Drawable divider = getResources().getDrawable(R.drawable.transaction_list_divider); list.setDivider(divider); list.setDividerHeight(1); list.setAdapter(contactListAdapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //to save a lookup TextView addr = (TextView) view.findViewById(R.id.address_book_row_address); TextView label = (TextView) view.findViewById(R.id.address_book_row_label); if (setSendAddress(addr.getText().toString(), label.getText().toString())) { startReceivingAddressActionMode(); } else { informInvalidAddress(addr.getText().toString(), label.getText().toString()); } } }); } else { contactsListView.setVisibility(View.GONE); } return view; }
From source file:com.pindroid.activity.Main.java
private void processIntent(Intent intent) { String action = intent.getAction(); String path = intent.getData() != null ? intent.getData().getPath() : ""; String lastPath = (intent.getData() != null && intent.getData().getLastPathSegment() != null) ? intent.getData().getLastPathSegment() : ""; String intentUsername = (intent.getData() != null && intent.getData().getUserInfo() != null) ? intent.getData().getUserInfo() : ""; if (!intentUsername.equals("") && !app.getUsername().equals(intentUsername)) { setAccount(intentUsername);//w w w .j av a 2s . c o m } if (Intent.ACTION_VIEW.equals(action)) { if (lastPath.equals("bookmarks")) { if (intent.getData().getQueryParameter("unread") != null && intent.getData().getQueryParameter("unread").equals("1")) { onMyUnreadSelected(); } else { onMyBookmarksSelected(intent.getData().getQueryParameter("tagname")); } } else if (lastPath.equals("notes")) { onMyNotesSelected(); } } else if (Intent.ACTION_SEND.equals(action)) { Bookmark b = loadBookmarkFromShareIntent(); b = findExistingBookmark(b); onBookmarkAdd(b); } else if (Constants.ACTION_SEARCH_SUGGESTION_VIEW.equals(action)) { if (path.contains("bookmarks") && TextUtils.isDigitsOnly(lastPath) && intent.hasExtra(SearchManager.USER_QUERY)) { try { String defaultAction = SettingsHelper.getDefaultAction(this); BookmarkViewType viewType = null; try { viewType = BookmarkViewType.valueOf(defaultAction.toUpperCase(Locale.US)); } catch (Exception e) { viewType = BookmarkViewType.VIEW; } onBookmarkSelected(BookmarkManager.GetById(Integer.parseInt(lastPath), this), viewType); } catch (NumberFormatException e) { e.printStackTrace(); } catch (ContentNotFoundException e) { e.printStackTrace(); } } else if (path.contains("bookmarks") && intent.hasExtra(SearchManager.USER_QUERY)) { if (intent.getData() != null && intent.getData().getQueryParameter("tagname") != null) onTagSelected(intent.getData().getQueryParameter("tagname"), true); } else if (path.contains("notes") && TextUtils.isDigitsOnly(lastPath) && intent.hasExtra(SearchManager.USER_QUERY)) { try { onNoteView(NoteManager.GetById(Integer.parseInt(lastPath), this)); } catch (NumberFormatException e) { e.printStackTrace(); } catch (ContentNotFoundException e) { e.printStackTrace(); } } } }
From source file:com.folioreader.ui.folio.activity.FolioActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RequestCode.SEARCH.value) { Log.v(LOG_TAG, "-> onActivityResult -> " + RequestCode.SEARCH); if (resultCode == RESULT_CANCELED) return; searchAdapterDataBundle = data.getBundleExtra(SearchAdapter.DATA_BUNDLE); searchQuery = data.getCharSequenceExtra(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY); if (resultCode == SearchActivity.ResultCode.ITEM_SELECTED.getValue()) { searchItem = data.getParcelableExtra(EXTRA_SEARCH_ITEM); // In case if SearchActivity is recreated due to screen rotation then FolioActivity // will also be recreated, so mFolioPageViewPager might be null. if (mFolioPageViewPager == null) return; currentChapterIndex = getChapterIndex(Constants.HREF, searchItem.getHref()); mFolioPageViewPager.setCurrentItem(currentChapterIndex); FolioPageFragment folioPageFragment = getCurrentFragment(); if (folioPageFragment == null) return; folioPageFragment.highlightSearchItem(searchItem); searchItem = null;//from w w w.j a v a 2 s .c o m } } else if (requestCode == RequestCode.CONTENT_HIGHLIGHT.value && resultCode == RESULT_OK && data.hasExtra(TYPE)) { String type = data.getStringExtra(TYPE); if (type.equals(CHAPTER_SELECTED)) { goToChapter(data.getStringExtra(SELECTED_CHAPTER_POSITION)); } else if (type.equals(HIGHLIGHT_SELECTED)) { HighlightImpl highlightImpl = data.getParcelableExtra(HIGHLIGHT_ITEM); currentChapterIndex = highlightImpl.getPageNumber(); mFolioPageViewPager.setCurrentItem(currentChapterIndex); FolioPageFragment folioPageFragment = getCurrentFragment(); if (folioPageFragment == null) return; folioPageFragment.scrollToHighlightId(highlightImpl.getRangy()); } } }
From source file:com.guldencoin.androidwallet.nlg.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); payeeNameView = (TextView) view.findViewById(R.id.send_coins_payee_name); payeeOrganizationView = (TextView) view.findViewById(R.id.send_coins_payee_organization); payeeVerifiedByView = (TextView) view.findViewById(R.id.send_coins_payee_verified_by); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override//from ww w. j ava 2 s . com public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) { final Address address = paymentIntent.hasAddress() ? paymentIntent.getAddress() : (validatedAddress != null ? validatedAddress.address : null); if (address != null) actionMode = activity.startActionMode(new ReceivingAddressActionMode(address)); } else { actionMode.finish(); } } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(config.getBtcPrefix()); btcAmountView.setInputPrecision(config.getBtcMaxPrecision()); btcAmountView.setHintPrecision(config.getBtcPrecision()); btcAmountView.setShift(config.getBtcShift()); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection()); directPaymentEnableView = (CheckBox) view.findViewById(R.id.send_coins_direct_payment_enable); directPaymentEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); directPaymentEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); directPaymentMessageView = (TextView) view.findViewById(R.id.send_coins_direct_payment_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); isAmountValid(); if (everythingValid()) handleGo(); else requestFocusFirst(); } }); amountCalculatorLink.setNextFocusId(viewGo.getId()); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; final String mimeType = intent.getType(); if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) { initStateFromBitcoinUri(intentUri); } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && Constants.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final NdefMessage ndefMessage = (NdefMessage) intent .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; final byte[] ndefMessagePayload = Nfc.extractMimePayload(Constants.MIMETYPE_PAYMENTREQUEST, ndefMessage); initStateFromPaymentRequest(mimeType, ndefMessagePayload); } else if ((Intent.ACTION_VIEW.equals(action)) && intentUri != null && Constants.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { initStateFromIntentUri(mimeType, intentUri); } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) { initStateFromIntentExtras(intent.getExtras()); } else { updateStateFrom(PaymentIntent.blank()); } } return view; }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private void readVideoPreferences(SharedPreferences prefs) { Intent intent = ApplicationScreen.instance.getIntent(); // Set video duration limit. The limit is read from the preference, // unless it is specified in the intent. if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) { int seconds = intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0); mMaxVideoDurationInMs = 1000 * seconds; } else//ww w .j a v a 2s . c o m mMaxVideoDurationInMs = 0; }