List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:ru.orangesoftware.financisto.activity.AccountActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account);/* w ww. ja v a2s . c o m*/ accountTitle = new EditText(this); accountTitle.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); accountTitle.setSingleLine(); issuerName = new EditText(this); issuerName.setSingleLine(); numberText = new EditText(this); numberText.setHint(R.string.card_number_hint); numberText.setSingleLine(); sortOrderText = new EditText(this); sortOrderText.setInputType(InputType.TYPE_CLASS_NUMBER); sortOrderText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(3) }); sortOrderText.setSingleLine(); closingDayText = new EditText(this); closingDayText.setInputType(InputType.TYPE_CLASS_NUMBER); closingDayText.setHint(R.string.closing_day_hint); closingDayText.setSingleLine(); paymentDayText = new EditText(this); paymentDayText.setInputType(InputType.TYPE_CLASS_NUMBER); paymentDayText.setHint(R.string.payment_day_hint); paymentDayText.setSingleLine(); amountInput = AmountInput_.build(this); amountInput.setOwner(this); limitInput = AmountInput_.build(this); limitInput.setOwner(this); LinearLayout layout = findViewById(R.id.layout); accountTypeAdapter = new EntityEnumAdapter<>(this, AccountType.values(), false); accountTypeNode = x.addListNodeIcon(layout, R.id.account_type, R.string.account_type, R.string.account_type); ImageView icon = accountTypeNode.findViewById(R.id.icon); icon.setColorFilter(ContextCompat.getColor(this, R.color.holo_gray_light)); cardIssuerAdapter = new EntityEnumAdapter<>(this, CardIssuer.values(), false); cardIssuerNode = x.addListNodeIcon(layout, R.id.card_issuer, R.string.card_issuer, R.string.card_issuer); setVisibility(cardIssuerNode, View.GONE); electronicPaymentAdapter = new EntityEnumAdapter<>(this, ElectronicPaymentType.values(), false); electronicPaymentNode = x.addListNodeIcon(layout, R.id.electronic_payment_type, R.string.electronic_payment_type, R.string.card_issuer); setVisibility(electronicPaymentNode, View.GONE); issuerNode = x.addEditNode(layout, R.string.issuer, issuerName); setVisibility(issuerNode, View.GONE); numberNode = x.addEditNode(layout, R.string.card_number, numberText); setVisibility(numberNode, View.GONE); closingDayNode = x.addEditNode(layout, R.string.closing_day, closingDayText); setVisibility(closingDayNode, View.GONE); paymentDayNode = x.addEditNode(layout, R.string.payment_day, paymentDayText); setVisibility(paymentDayNode, View.GONE); currencyCursor = db.getAllCurrencies("name"); startManagingCursor(currencyCursor); currencyAdapter = TransactionUtils.createCurrencyAdapter(this, currencyCursor); x.addEditNode(layout, R.string.title, accountTitle); currencyText = x.addListNodePlus(layout, R.id.currency, R.id.currency_add, R.string.currency, R.string.select_currency); limitInput.setExpense(); limitInput.disableIncomeExpenseButton(); limitAmountView = x.addEditNode(layout, R.string.limit_amount, limitInput); setVisibility(limitAmountView, View.GONE); Intent intent = getIntent(); if (intent != null) { long accountId = intent.getLongExtra(ACCOUNT_ID_EXTRA, -1); if (accountId != -1) { this.account = db.getAccount(accountId); if (this.account == null) { this.account = new Account(); } } else { selectAccountType(AccountType.valueOf(account.type)); } } if (account.id == -1) { x.addEditNode(layout, R.string.opening_amount, amountInput); amountInput.setIncome(); } noteText = new EditText(this); noteText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); noteText.setLines(2); x.addEditNode(layout, R.string.note, noteText); x.addEditNode(layout, R.string.sort_order, sortOrderText); isIncludedIntoTotals = x.addCheckboxNode(layout, R.id.is_included_into_totals, R.string.is_included_into_totals, R.string.is_included_into_totals_summary, true); if (account.id > 0) { editAccount(); } Button bOK = findViewById(R.id.bOK); bOK.setOnClickListener(arg0 -> { if (account.currency == null) { Toast.makeText(AccountActivity.this, R.string.select_currency, Toast.LENGTH_SHORT).show(); return; } if (Utils.isEmpty(accountTitle)) { accountTitle.setError(getString(R.string.title)); return; } AccountType type = AccountType.valueOf(account.type); if (type.hasIssuer) { account.issuer = Utils.text(issuerName); } if (type.hasNumber) { account.number = Utils.text(numberText); } /********** validate closing and payment days **********/ if (type.isCreditCard) { String closingDay = Utils.text(closingDayText); account.closingDay = closingDay == null ? 0 : Integer.parseInt(closingDay); if (account.closingDay != 0) { if (account.closingDay > 31) { Toast.makeText(AccountActivity.this, R.string.closing_day_error, Toast.LENGTH_SHORT).show(); return; } } String paymentDay = Utils.text(paymentDayText); account.paymentDay = paymentDay == null ? 0 : Integer.parseInt(paymentDay); if (account.paymentDay != 0) { if (account.paymentDay > 31) { Toast.makeText(AccountActivity.this, R.string.payment_day_error, Toast.LENGTH_SHORT).show(); return; } } } account.title = text(accountTitle); account.creationDate = System.currentTimeMillis(); String sortOrder = text(sortOrderText); account.sortOrder = sortOrder == null ? 0 : Integer.parseInt(sortOrder); account.isIncludeIntoTotals = isIncludedIntoTotals.isChecked(); account.limitAmount = -Math.abs(limitInput.getAmount()); account.note = text(noteText); long accountId = db.saveAccount(account); long amount = amountInput.getAmount(); if (amount != 0) { Transaction t = new Transaction(); t.fromAccountId = accountId; t.categoryId = 0; t.note = getResources().getText(R.string.opening_amount) + " (" + account.title + ")"; t.fromAmount = amount; db.insertOrUpdate(t, null); } AccountWidget.updateWidgets(this); Intent intent1 = new Intent(); intent1.putExtra(ACCOUNT_ID_EXTRA, accountId); setResult(RESULT_OK, intent1); finish(); }); Button bCancel = findViewById(R.id.bCancel); bCancel.setOnClickListener(arg0 -> { setResult(RESULT_CANCELED); finish(); }); }
From source file:org.mariotaku.twidere.activity.DirectMessagesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { requestSupportWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTwidereApplication().getServiceInterface(); super.onCreate(savedInstanceState); final Intent intent = getIntent(); final Bundle args = savedInstanceState == null ? intent.getExtras() : savedInstanceState; mAccountId = args != null ? args.getLong(INTENT_KEY_ACCOUNT_ID, -1) : intent.getLongExtra(INTENT_KEY_ACCOUNT_ID, -1); mArguments.clear();//from ww w. j av a2 s . c o m if (args != null) { mArguments.putAll(args); } mService.clearNotification(NOTIFICATION_ID_DIRECT_MESSAGES); setContentView(R.layout.direct_messages); final ActionBar actionbar = getSupportActionBar(); actionbar.setDisplayShowTitleEnabled(true); actionbar.setDisplayHomeAsUpEnabled(true); final LazyImageLoader imageloader = getTwidereApplication().getProfileImageLoader(); mAdapter = new DirectMessagesEntryAdapter(this, imageloader); mDirectMessagesContainer = findViewById(R.id.direct_messages_content); mAccountSelectContainer = findViewById(R.id.account_select_container); mListView = (ListView) findViewById(android.R.id.list); mAccountConfirmButton = (Button) findViewById(R.id.account_confirm); mAccountConfirmButton.setOnClickListener(this); mAccountSelector = (Spinner) findViewById(R.id.account_selector); mListView.setAdapter(mAdapter); mListView.setOnScrollListener(this); mListView.setOnItemClickListener(this); final long[] activated_ids = getActivatedAccountIds(this); if (!isMyActivatedAccount(this, mAccountId) && activated_ids.length == 1) { mAccountId = activated_ids[0]; } final boolean is_my_activated_account = isMyActivatedAccount(this, mAccountId); if (is_my_activated_account) { mArguments.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); } mDirectMessagesContainer.setVisibility(is_my_activated_account ? View.VISIBLE : View.GONE); mAccountSelectContainer.setVisibility(!is_my_activated_account ? View.VISIBLE : View.GONE); if (!is_my_activated_account) { mAccountsAdapter = new AccountsAdapter(this); mAccountSelector.setAdapter(mAccountsAdapter); mAccountSelector.setOnItemSelectedListener(this); getSupportLoaderManager().initLoader(LOADER_ID_ACCOUNTS, null, this); } getSupportLoaderManager().initLoader(LOADER_ID_DIRECT_MESSAGES, null, this); }
From source file:de.vanita5.twittnuker.activity.support.UserProfileEditorActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); final Intent intent = getIntent(); final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); if (!isMyAccount(this, accountId)) { finish();//from w ww. j av a 2 s. co m return; } mAsyncTaskManager = TwittnukerApplication.getInstance(this).getAsyncTaskManager(); mLazyImageLoader = TwittnukerApplication.getInstance(this).getImageLoaderWrapper(); mAccountId = accountId; setContentView(R.layout.edit_user_profile); // setOverrideExitAniamtion(false); getActionBar().setDisplayHomeAsUpEnabled(true); mProfileImageBannerLayout.setOnSizeChangedListener(this); mEditName.addTextChangedListener(this); mEditDescription.addTextChangedListener(this); mEditLocation.addTextChangedListener(this); mEditUrl.addTextChangedListener(this); mProfileImageView.setOnClickListener(this); mProfileBannerView.setOnClickListener(this); if (savedInstanceState != null && savedInstanceState.getParcelable(EXTRA_USER) != null) { final ParcelableUser user = savedInstanceState.getParcelable(EXTRA_USER); displayUser(user); mEditName.setText(savedInstanceState.getString(EXTRA_NAME, user.name)); mEditLocation.setText(savedInstanceState.getString(EXTRA_LOCATION, user.location)); mEditDescription.setText(savedInstanceState.getString(EXTRA_DESCRIPTION, user.description_expanded)); mEditUrl.setText(savedInstanceState.getString(EXTRA_URL, user.url_expanded)); } else { getUserInfo(); } }
From source file:com.actinarium.nagbox.service.NagboxService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;//from w w w . j av a 2s. co m } // I know that only either of those is needed, but for the sake of nice code I'm pulling these here final Task task = intent.getParcelableExtra(EXTRA_TASK); final long id = intent.getLongExtra(EXTRA_TASK_ID, Task.NO_ID); switch (intent.getAction()) { case ACTION_UPDATE_TASK_STATUS: handleUpdateTaskStatus(task); break; case ACTION_ON_ALARM_FIRED: handleOnAlarmFired(); break; case ACTION_ON_NOTIFICATION_DISMISSED: handleOnNotificationDismissed(id); break; case ACTION_ON_NOTIFICATION_ACTION_STOP_TASK: int notificationIdToCancel = intent.getIntExtra(EXTRA_CANCEL_NOTIFICATION_ID, -1); handleStopTaskById(id, notificationIdToCancel); break; case ACTION_CREATE_TASK: handleCreateTask(task); break; case ACTION_UPDATE_TASK: handleUpdateTask(task); break; case ACTION_DELETE_TASK: handleDeleteTask(id); break; case ACTION_RESTORE_TASK: handleRestoreTask(task); break; } // Release the wake lock, if there was any. WakefulBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.demo.firebase.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initialize Firebase Auth mAuth = FirebaseAuth.getInstance();/* w w w . j a v a 2 s . co m*/ // Click listeners findViewById(R.id.button_camera).setOnClickListener(this); findViewById(R.id.button_sign_in).setOnClickListener(this); findViewById(R.id.button_download).setOnClickListener(this); // Restore instance state if (savedInstanceState != null) { mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI); mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL); } onNewIntent(getIntent()); // Local broadcast receiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive:" + intent); hideProgressDialog(); switch (intent.getAction()) { case MyDownloadService.DOWNLOAD_COMPLETED: // Get number of bytes downloaded long numBytes = intent.getLongExtra(MyDownloadService.EXTRA_BYTES_DOWNLOADED, 0); // Alert success showMessageDialog(getString(R.string.success), String.format(Locale.getDefault(), "%d bytes downloaded from %s", numBytes, intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH))); break; case MyDownloadService.DOWNLOAD_ERROR: // Alert failure showMessageDialog("Error", String.format(Locale.getDefault(), "Failed to download from %s", intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH))); break; case MyUploadService.UPLOAD_COMPLETED: case MyUploadService.UPLOAD_ERROR: onUploadResultIntent(intent); break; } } }; }
From source file:com.swetha.easypark.DisplayVacantParkingLots.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mapviewlistvacantparkinglots); Intent displayIntent = getIntent(); double usersCurrentLatitude = displayIntent.getDoubleExtra(GetParkingLots.LATITUDE, Constants.doubleDefaultValue); double usersCurrentLongitude = displayIntent.getDoubleExtra(GetParkingLots.LONGITUDE, Constants.doubleDefaultValue); fromTime = displayIntent.getLongExtra(GetParkingLots.FROMTIME, 0); toTime = displayIntent.getLongExtra(GetParkingLots.TOTIME, 0); isRadius = displayIntent.getBooleanExtra(GetParkingLots.RadiusOrZIPCODE, false); if (isRadius) { radius = displayIntent.getDoubleExtra(GetParkingLots.RADIUS, 0.0); } else {// w w w .j a va 2 s . c om zipcode = displayIntent.getLongExtra(GetParkingLots.ZIPCODE, 0); } Log.i("DisplayVacantParkingLots", "Before Calling Async task"); new GetParkingLotsFromWebService(this, usersCurrentLatitude, usersCurrentLongitude, fromTime, toTime) .execute(); Log.i("DisplayVacantParkingLots", "After Calling Async task"); btn_switchToListView = (Button) findViewById(R.id.switchtolistview); btn_switchToListView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (parkingLotsMapList != null) // fixed crashing of application when no parking data found { Intent intent = new Intent(DisplayVacantParkingLots.this, DisplayParkingLotsAsList.class); intent.putExtra(ARRAYLISTMAP, parkingLotsMapList); startActivity(intent); } } }); }
From source file:ru.orangesoftware.financisto.activity.AccountActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case NEW_CURRENCY_REQUEST: currencyCursor.requery();//from ww w .jav a 2 s . c o m long currencyId = data.getLongExtra(CurrencyActivity.CURRENCY_ID_EXTRA, -1); if (currencyId != -1) { selectCurrency(currencyId); } break; } } }
From source file:com.alchemiasoft.book.service.BookActionService.java
@Override protected void onHandleIntent(Intent intent) { final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, NOT_VALID_NOTIFICATION); // Cancelling any shown notification if (notificationId != NOT_VALID_NOTIFICATION) { Log.d(TAG_LOG, "Dismissing notification with id=" + notificationId); NotificationManagerCompat.from(this).cancel(notificationId); }//from ww w . j av a2 s . c o m final long bookId = intent.getLongExtra(EXTRA_BOOK_ID, NOT_VALID_BOOK); if (bookId != NOT_VALID_BOOK) { final ContentResolver cr = getContentResolver(); final Action action = Action.valueOf(intent.getAction()); Log.d(TAG_LOG, "Performing action=" + action + " on book with id=" + bookId); final ContentValues cv = new ContentValues(); switch (action) { case BUY: cv.put(BookDB.Book.OWNED, 1); if (cr.update(BookDB.Book.create(bookId), cv, null, null) == 1 && intent.getBooleanExtra(EXTRA_WEARABLE_INPUT, false)) { final Book book = getBook(bookId); if (book != null) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true) .setContentTitle(getString(R.string.book_purchased)) .setContentText(book.getTitle()); builder.setContentIntent(PendingIntent.getActivity(this, 0, HomeActivity.createFor(this, book), PendingIntent.FLAG_UPDATE_CURRENT)); // ONLY 4 WEARABLE(s) final NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); wearableExtender .setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.background)); // ACTION TO SELL A BOOK FROM A WEARABLE final PendingIntent sellIntent = PendingIntent.getService( this, 0, BookActionService.IntentBuilder.sell(this, book) .notificationId(NOTIFICATION_ID).wearableInput().build(), PendingIntent.FLAG_UPDATE_CURRENT); wearableExtender.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_action_sell, getString(R.string.action_sell), sellIntent).build()); // Finally extending the notification builder.extend(wearableExtender); NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, builder.build()); } } break; case SELL: cv.put(BookDB.Book.OWNED, 0); if (cr.update(BookDB.Book.create(bookId), cv, null, null) == 1 && intent.getBooleanExtra(EXTRA_WEARABLE_INPUT, false)) { final Book book = getBook(bookId); if (book != null) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true) .setContentTitle(getString(R.string.book_sold)).setContentText(book.getTitle()); builder.setContentIntent(PendingIntent.getActivity(this, 0, HomeActivity.createFor(this, book), PendingIntent.FLAG_UPDATE_CURRENT)); NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, builder.build()); } } break; case ADD_NOTE: final CharSequence notes = getExtraNotes(intent); if (!TextUtils.isEmpty(notes)) { cv.put(BookDB.Book.NOTES, notes.toString()); cr.update(BookDB.Book.create(bookId), cv, null, null); } break; default: break; } } }
From source file:org.getlantern.firetweet.activity.support.UserProfileEditorActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); if (!isMyAccount(this, accountId)) { finish();/*www .ja va2 s . c om*/ return; } mAsyncTaskManager = FiretweetApplication.getInstance(this).getAsyncTaskManager(); mLazyImageLoader = FiretweetApplication.getInstance(this).getMediaLoaderWrapper(); mAccountId = accountId; setContentView(R.layout.activity_user_profile_editor); setSupportActionBar(mToolbar); ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this)); ViewAccessor.setBackground(mToolbar, ThemeUtils.getActionBarBackground(mToolbar.getContext(), getCurrentThemeResourceId())); // setOverrideExitAniamtion(false); mEditName.addTextChangedListener(this); mEditDescription.addTextChangedListener(this); mEditLocation.addTextChangedListener(this); mEditUrl.addTextChangedListener(this); mProfileImageView.setOnClickListener(this); mProfileBannerView.setOnClickListener(this); mProfileImageCamera.setOnClickListener(this); mProfileImageGallery.setOnClickListener(this); mProfileBannerGallery.setOnClickListener(this); mProfileBannerRemove.setOnClickListener(this); mCancelButton.setOnClickListener(this); mDoneButton.setOnClickListener(this); mSetLinkColor.setOnClickListener(this); mSetBackgroundColor.setOnClickListener(this); if (savedInstanceState != null && savedInstanceState.getParcelable(EXTRA_USER) != null) { final ParcelableUser user = savedInstanceState.getParcelable(EXTRA_USER); displayUser(user); mEditName.setText(savedInstanceState.getString(EXTRA_NAME, user.name)); mEditLocation.setText(savedInstanceState.getString(EXTRA_LOCATION, user.location)); mEditDescription.setText(savedInstanceState.getString(EXTRA_DESCRIPTION, user.description_expanded)); mEditUrl.setText(savedInstanceState.getString(EXTRA_URL, user.url_expanded)); } else { getUserInfo(); } }
From source file:net.kjmaster.cookiemom.MainActivity.java
@OnActivityResult(Constants.ADD_BOOTH_REQUEST_CODE) void onBoothResult(int resultCode, Intent data) { if (resultCode == Constants.ADD_BOOTH_RESULT_OK) { if (data != null) { Main.daoSession.getBoothDao().insert(new Booth(null, data.getStringExtra("add_booth"), data.getStringExtra("address"), new Date(data.getLongExtra("booth_date", 0)))); } else {//www . j a va 2s .c o m Log.e("No data intent on booth result", "LOG00000:"); } } refreshAll(); }