List of usage examples for android.os Bundle putLong
public void putLong(@Nullable String key, long value)
From source file:fr.eyal.lib.data.service.DataLibService.java
/** * Send the result of a request to the linked {@link ServiceHelper} * // w ww . j av a2 s . co m * @param request the request * @param response the response * @param code the status of the request */ protected void sendResult(final DataLibRequest request, final BusinessResponse response, final int code) { Out.d(TAG, "sendResult"); final Intent intent = request.intent; final ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra(INTENT_EXTRA_RECEIVER); if (receiver != null) { final Bundle b = new Bundle(); if (response != null && response.response != null) { //if the Business Object have to be transmit inside the Bundle if (request.isParcelableMethodEnabled()) b.putParcelable(ServiceHelper.RECEIVER_EXTRA_RESULT, response.response); //we add the request id to the response if (response.response instanceof ResponseBusinessObjectDAO) { ResponseBusinessObjectDAO r = (ResponseBusinessObjectDAO) response.response; b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, r._id); } else { //in case of no data cache, we set an invalid ID b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, BusinessObjectDAO.ID_INVALID); } } else { Out.e(TAG, "Unfined response"); } //we copy the content of the response in the intent's bundle b.putInt(ServiceHelper.RECEIVER_EXTRA_REQUEST_ID, intent.getIntExtra(INTENT_EXTRA_REQUEST_ID, -1)); b.putInt(ServiceHelper.RECEIVER_EXTRA_WEBSERVICE_TYPE, intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1)); b.putInt(ServiceHelper.RECEIVER_EXTRA_RETURN_CODE, response.returnCode); b.putInt(ServiceHelper.RECEIVER_EXTRA_RESULT_CODE, response.status); b.putString(ServiceHelper.RECEIVER_EXTRA_RESULT_MESSAGE, ""); receiver.send(code, b); } }
From source file:rpassmore.app.fillthathole.ViewHazardActivity.java
public void locateClickHandler(View view) { // display location map activity Intent myIntent = new Intent(view.getContext(), LocationActivity.class); Bundle bundle = new Bundle(); if (hazard.getState() != Hazard.State.UNSUBMITTED) { bundle.putBoolean(LocationActivity.LOCATION_CAN_DRAG, false); } else {/* ww w . j ava2s . c om*/ bundle.putBoolean(LocationActivity.LOCATION_CAN_DRAG, true); } if (hazard.getLattitude() != null && hazard.getLongitude() != null) { bundle.putLong(LocationActivity.LOCATION_LAT, (long) (hazard.getLattitude() * 1E6)); bundle.putLong(LocationActivity.LOCATION_LONG, (long) (hazard.getLongitude() * 1E6)); bundle.putBoolean(LocationActivity.LOCATION_CAN_CREATE, false); } else { bundle.putBoolean(LocationActivity.LOCATION_CAN_CREATE, true); } myIntent.putExtras(bundle); startActivityForResult(myIntent, LOCATION_MAP_ACTIVITY); }
From source file:com.heightechllc.breakify.MainActivity.java
/** * Skips to the next timer state// w ww .ja v a2s . co m */ private void skipToNextState() { int oldWorkState = getWorkState(); // Record the state we're about to skip from, in case the user chooses to undo Bundle undoStateBundle = new Bundle(); undoStateBundle.putLong("totalTime", circleTimer.getTotalTime()); undoStateBundle.putLong("remainingTime", circleTimer.getRemainingTime()); undoStateBundle.putInt("workState", oldWorkState); String toastMessage = getString(R.string.skip_toast); // Get duration from preferences, in minutes long duration; if (oldWorkState == WORK_STATE_WORKING) { // Means we're skipping to break duration = sharedPref.getInt(TimerDurationsSettingsFragment.KEY_BREAK_DURATION, 0); toastMessage += " break"; } else { // Means we're skipping to work duration = sharedPref.getInt(TimerDurationsSettingsFragment.KEY_WORK_DURATION, 0); toastMessage += " work"; } // Create and show the undo bar showUndoBar(toastMessage, undoStateBundle, new UndoBarController.UndoListener() { @Override public void onUndo(Parcelable parcelable) { if (parcelable == null) return; // Extract the saved state from the Parcelable Bundle undoStateBundle = (Bundle) parcelable; long prevTotalTime = undoStateBundle.getLong("totalTime"); long prevRemainingTime = undoStateBundle.getLong("remainingTime"); int prevWorkState = undoStateBundle.getInt("workState"); // Cause startTimer() to treat it like we're resuming (b/c we are) timerState = TIMER_STATE_PAUSED; setWorkState(prevWorkState); // Restore to the previous timer state, similar to how we restore a // running timer from SharedPreferences in onCreate() circleTimer.setTotalTime(prevTotalTime); circleTimer.updateTimeLbl(prevRemainingTime); // Record the total duration, so we can resume if the activity is destroyed sharedPref.edit().putLong("schedTotalTime", prevTotalTime).apply(); startTimer(prevRemainingTime); // Analytics if (mixpanel != null) mixpanel.track("Skip undone", null); } }); // Set the new state if (oldWorkState == WORK_STATE_WORKING) setWorkState(WORK_STATE_BREAKING); else setWorkState(WORK_STATE_WORKING); // We want to start the timer from scratch, not from a paused state timerState = TIMER_STATE_STOPPED; // Start the timer startTimer(duration * 60000); // Multiply into milliseconds // Analytics if (mixpanel != null) { JSONObject props = new JSONObject(); try { props.put("Duration", duration); } catch (JSONException e) { e.printStackTrace(); } String eventName = getWorkState() == WORK_STATE_WORKING ? "Skipped to work" : "Skipped to break"; mixpanel.track(eventName, props); } }
From source file:com.example.app_2.activities.ImageGridActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (!mDualPane) if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from ww w . jav a 2s . c o m // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_add_image:// TODO dodawanie nowych obrazkw Intent bind_intent = new Intent(this, BindImagesToCategoryActivity.class); if (actual_category_fk.getCategoryId() == Database.getMainRootFk()) { Toast.makeText(getApplicationContext(), "Tutaj nie mona dodawa obrazkw, wybierz najpierw uytkownika", Toast.LENGTH_LONG).show(); return true; } bind_intent.putExtra("executing_category_id", actual_category_fk.getCategoryId()); startActivity(bind_intent); return true; case R.id.action_add_new_image: Intent new_imageIntent = new Intent(this, AddImageActivity.class); Bundle bundle = new Bundle(); bundle.putLong("cat_fk", actual_category_fk.getCategoryId()); new_imageIntent.putExtras(bundle); startActivity(new_imageIntent); return true; case R.id.action_settings: Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); overridePendingTransition(R.anim.right_slide_in, R.anim.right_slide_out); finish(); return true; case R.id.action_logout: igf.mEditMode = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()); SharedPreferences sharedPref = getApplicationContext().getSharedPreferences("USER", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); //zapisanie usawie uytkownika do bazy Uri uri = Uri.parse(UserContract.CONTENT_URI + "/" + sharedPref.getLong("logged_user_id", 0)); ContentValues cv = new ContentValues(); cv.put(UserContract.Columns.FONT_SIZE, sp.getInt("pref_img_desc_font_size", 15)); cv.put(UserContract.Columns.IMG_SIZE, sp.getInt("pref_img_size", 100)); cv.put(UserContract.Columns.CAT_BACKGROUND, String.valueOf(sp.getInt("category_view_background", 0xff33b5e5))); cv.put(UserContract.Columns.CONTEXT_CAT_BACKGROUND, String.valueOf(sp.getInt("context_category_view_background", 0xffe446ff))); getContentResolver().update(uri, cv, null, null); editor.putLong("logged_user_root", Database.getMainRootFk()); editor.putLong("logged_user_id", 0); editor.commit(); fragmentsHistory.clear(); Intent i = getIntent(); finish(); startActivity(i); replaceCategory(Database.getMainRootFk(), 0, false); return true; case R.id.action_login_user: Intent login_intent = new Intent(this, UserLoginActivity.class); startActivity(login_intent); finish(); fragmentsHistory.clear(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:cl.ipp.katbag.fragment.Pages.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mainActivity = (MainActivity) super.getActivity(); v = inflater.inflate(R.layout.fragment_pages, container, false); mainActivity.supportInvalidateOptionsMenu(); // rescues parameters Bundle bundle = getArguments(); if (bundle != null) { id_app = bundle.getLong("id_app"); }//from w ww . j ava2 s . c om notRegister = (TextView) v.findViewById(R.id.page_not_register); editMode = false; loadListView(); pagesListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!editMode) { TextView pageld = (TextView) view.findViewById(R.id.page_row_id); Bundle bundle = new Bundle(); bundle.putLong("id_app", id_app); bundle.putLong("id_page", Long.valueOf(pageld.getText().toString())); bundle.putString("name_page", String.valueOf(position)); mFragment = new OnePage(); mFragment.setArguments(bundle); FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.addToBackStack(mFragment.getClass().getSimpleName()); t.commit(); } } }); return v; }
From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case MENU_FOLLOW: { if (mAccountId != mUserId) { if (mUserList.isFollowing()) { mService.destroyUserListSubscription(mAccountId, mUserList.getId()); } else { mService.createUserListSubscription(mAccountId, mUserList.getId()); }/*ww w . j av a 2 s . c om*/ } break; } case MENU_ADD: { final Bundle args = new Bundle(); args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); args.putString(INTENT_KEY_TEXT, ""); args.putInt(INTENT_KEY_LIST_ID, mUserList.getId()); mAddMemberDialogFragment.setArguments(args); mAddMemberDialogFragment.show(getFragmentManager(), "add_member"); break; } case MENU_ADD_TAB: { CustomTabsAdapter mAdapter; mAdapter = new CustomTabsAdapter(getActivity()); ContentResolver mResolver; mResolver = getContentResolver(); final String tabName = mListName; final String tabType = AUTHORITY_LIST_TIMELINE; final String tabIcon = "list"; final long account_id = mAccountId; final String tabScreenName = mUserScreenName; final String tabListName = mListName; final String tabArguments = "{\"account_id\":" + account_id + ",\"screen_name\":\"" + tabScreenName + "\",\"list_name\":" + JSONObject.quote(tabListName) + "}"; final ContentValues values = new ContentValues(); values.put(Tabs.ARGUMENTS, tabArguments); values.put(Tabs.NAME, tabName); values.put(Tabs.POSITION, mAdapter.getCount()); values.put(Tabs.TYPE, tabType); values.put(Tabs.ICON, tabIcon); mResolver.insert(Tabs.CONTENT_URI, values); Toast.makeText(this.getActivity(), R.string.list_tab_added, Toast.LENGTH_SHORT).show(); break; } case MENU_DELETE: { if (mUserId != mAccountId) return false; mService.destroyUserList(mAccountId, mUserListId); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_USER_LIST, new ParcelableUserList(mUserList, mAccountId)); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } } return true; }
From source file:com.ereinecke.eatsafe.MainActivity.java
private void launchProductFragment(long barcode) { // Pass barcode to ProductFragment if (barcode != Constants.BARCODE_NOT_FOUND) { Bundle args = new Bundle(); args.putLong(Constants.BARCODE_KEY, barcode); /* Set up back arrow */ Toolbar toolbar = findViewById(R.id.app_bar); setSupportActionBar(toolbar);/* w w w .j av a2s . com*/ ProductFragment ProductFragment = new ProductFragment(); ProductFragment.setArguments(args); if (!isTablet) { // productFragment replaces TabPagerFragment try { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); } catch (Exception e) { Logd(LOG_TAG, "Exception in launchProductFragment: " + e.getMessage()); } getSupportFragmentManager().beginTransaction().replace(R.id.tab_container, ProductFragment) .addToBackStack(null).commit(); } else { // productFragment replaces splashFragment try { getSupportActionBar().setDisplayShowTitleEnabled(false); } catch (Exception e) { Logd(LOG_TAG, "Exception in launchProductFragment: " + e.getMessage()); } getSupportFragmentManager().beginTransaction().replace(R.id.right_pane_container, ProductFragment) .addToBackStack(null).commit(); } } else { Logd(LOG_TAG, "Barcode not found, not launching product fragment."); } }
From source file:cl.ipp.katbag.fragment.Drawings.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mainActivity = (MainActivity) super.getActivity(); v = inflater.inflate(R.layout.fragment_drawings, container, false); mainActivity.supportInvalidateOptionsMenu(); // rescues parameters Bundle bundle = getArguments(); if (bundle != null) { id_app = bundle.getLong("id_app"); type_app = bundle.getString("type_app"); }/*www .jav a 2s. c om*/ notRegister = (TextView) v.findViewById(R.id.drawings_not_register); editMode = false; loadListView(); drawingsListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!editMode) { TextView idDrawing = (TextView) view.findViewById(R.id.drawing_row_id); Bundle bundle = new Bundle(); bundle.putLong("id_drawing", Long.valueOf(idDrawing.getText().toString())); bundle.putString("name_drawing", idDrawing.getText().toString()); bundle.putString("type_app", type_app); mFragment = new OneDrawing(); mFragment.setArguments(bundle); FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.addToBackStack(mFragment.getClass().getSimpleName()); t.commit(); } } }); return v; }
From source file:com.heightechllc.breakify.MainActivity.java
/** * Resets the CircleTimerView and reverts the Activity's UI to its initial state * @param isTimerComplete Whether the timer is complete *///from w ww . j a va 2 s. co m private void resetTimerUI(boolean isTimerComplete) { timerState = TIMER_STATE_STOPPED; // Reset the UI timeLbl.clearAnimation(); stateLbl.clearAnimation(); resetBtn.setVisibility(View.GONE); skipBtn.setVisibility(View.GONE); timeLbl.setText(""); // Record the state we're about to reset from, in case the user chooses to undo Bundle undoStateBundle = new Bundle(); if (isTimerComplete) { undoStateBundle.putLong("totalTime", 0); undoStateBundle.putLong("remainingTime", 0); } else { undoStateBundle.putLong("totalTime", circleTimer.getTotalTime()); undoStateBundle.putLong("remainingTime", circleTimer.getRemainingTime()); } undoStateBundle.putInt("workState", getWorkState()); // Back to initial state setWorkState(WORK_STATE_WORKING); // Update the start / stop label startStopLbl.setText(R.string.start); startStopLbl.setVisibility(View.VISIBLE); circleTimer.stopIntervalAnimation(); circleTimer.invalidate(); // Remove record of total timer duration and the time remaining for the paused timer sharedPref.edit().remove("schedTotalTime").remove("pausedTimeRemaining").apply(); // Create and show the undo bar showUndoBar(getString(R.string.reset_toast), undoStateBundle, new UndoBarController.UndoListener() { @Override public void onUndo(Parcelable parcelable) { if (parcelable == null) return; // Extract the saved state from the Parcelable Bundle undoStateBundle = (Bundle) parcelable; long prevTotalTime = undoStateBundle.getLong("totalTime"); long prevRemainingTime = undoStateBundle.getLong("remainingTime"); int prevWorkState = undoStateBundle.getInt("workState"); if (prevTotalTime > 0 && prevRemainingTime > 0) { // Cause startTimer() to treat it like we're resuming (b/c we are) timerState = TIMER_STATE_PAUSED; setWorkState(prevWorkState); // Restore to the previous timer state, similar to how we restore a // running timer from SharedPreferences in onCreate() circleTimer.setTotalTime(prevTotalTime); circleTimer.updateTimeLbl(prevRemainingTime); // Record the total duration, so we can resume if the activity is destroyed sharedPref.edit().putLong("schedTotalTime", prevTotalTime).apply(); startTimer(prevRemainingTime); } else { // Means the timer was complete when resetTimerUI() was called, so we // need to start the timer from the beginning of the next state if (prevWorkState == WORK_STATE_WORKING) setWorkState(WORK_STATE_BREAKING); else setWorkState(WORK_STATE_WORKING); startTimer(); } // Analytics if (mixpanel != null) mixpanel.track("Timer reset undone", null); } }); }
From source file:com.ichi2.anki.CardTemplateEditor.java
@Override public void onSaveInstanceState(Bundle outState) { if (mModelBackup != null) { outState.putString("modelBackup", mModelBackup.toString()); }/*from w w w .ja v a 2s. c o m*/ outState.putLong("modelId", mModelId); outState.putLong("noteId", mNoteId); super.onSaveInstanceState(outState); }