List of usage examples for android.os Bundle getSerializable
@Override
@Nullable
public Serializable getSerializable(@Nullable String key)
From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_save: Database.init(getApplicationContext()); Database.setEmail(email);//w ww. j a v a2s .c o m if (getMathAlarm().getId() < 1) { getMathAlarm().setEmail(email); Database.create(getMathAlarm()); Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey("user")) { User user = (User) bundle.getSerializable("user"); Group group = new Group(getMathAlarm(), user); Database.addGroup(group); } params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("email", email)); Log.d("??? ? : ", "" + email); params.add(new BasicNameValuePair("time", getMathAlarm().getAlarmTimeString())); params.add(new BasicNameValuePair("difficulty", Integer.toString(getMathAlarm().getDifficulty().ordinal()))); params.add(new BasicNameValuePair("tone", getMathAlarm().getAlarmTonePath())); params.add(new BasicNameValuePair("vibrate", Boolean.toString(getMathAlarm().getVibrate()))); params.add(new BasicNameValuePair("name", getMathAlarm().getAlarmName())); //params.add(new BasicNameValuePair("days", Arrays.toString(getMathAlarm().getDays()))); for (int i = 0; i < getMathAlarm().getDays().length; i++) { params.add(new BasicNameValuePair("days", getMathAlarm().getDays()[i].toString())); } ServerRequest sr = new ServerRequest(); JSONObject json = sr.getJSON("http://168.188.123.218:8080/alarmdata", params); if (json != null) { try { String jsonstr = json.getString("response"); //JSONObject json2 = sr.getJSON("http://168.188.123.218:8080/useralarm", params); } catch (JSONException e) { e.printStackTrace(); } } } else { Database.update(getMathAlarm()); Database.setEmail(email); } callMathAlarmScheduleService(); Toast.makeText(AlarmPreferencesActivity.this, getMathAlarm().getTimeUntilNextAlarmMessage(), Toast.LENGTH_LONG).show(); finish(); break; case R.id.menu_item_delete: AlertDialog.Builder dialog = new AlertDialog.Builder(AlarmPreferencesActivity.this); dialog.setTitle("Delete"); dialog.setMessage("Delete this alarm?"); dialog.setPositiveButton("Ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Database.init(getApplicationContext()); Database.setEmail(email); if (getMathAlarm().getId() < 1) { // Alarm not saved } else { params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("email", email)); params.add(new BasicNameValuePair("time", alarm.getAlarmTimeString())); Log.d("??? ? : ", "" + email); ServerRequest sr = new ServerRequest(); JSONObject json = sr.getJSON("http://168.188.123.218:8080/deletealarm", params); Database.deleteEntry(alarm); callMathAlarmScheduleService(); } finish(); } }); dialog.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); break; } return super.onOptionsItemSelected(item); }
From source file:ca.rmen.android.scrumchatter.dialog.InputDialogFragment.java
@Override @NonNull//from ww w .j a v a 2s.co m public Dialog onCreateDialog(Bundle savedInstanceState) { Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState); if (savedInstanceState != null) mEnteredText = savedInstanceState.getString(DialogFragmentFactory.EXTRA_ENTERED_TEXT); Bundle arguments = getArguments(); final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID); final InputDialogEditTextBinding binding = DataBindingUtil.inflate(LayoutInflater.from(getActivity()), R.layout.input_dialog_edit_text, null, false); final Bundle extras = arguments.getBundle(DialogFragmentFactory.EXTRA_EXTRAS); final Class<?> inputValidatorClass = (Class<?>) arguments .getSerializable(DialogFragmentFactory.EXTRA_INPUT_VALIDATOR_CLASS); final String prefilledText = arguments.getString(DialogFragmentFactory.EXTRA_ENTERED_TEXT); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(arguments.getString(DialogFragmentFactory.EXTRA_TITLE)); builder.setView(binding.getRoot()); binding.edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); binding.edit.setHint(arguments.getString(DialogFragmentFactory.EXTRA_INPUT_HINT)); binding.edit.setText(prefilledText); if (!TextUtils.isEmpty(mEnteredText)) binding.edit.setText(mEnteredText); // Notify the activity of the click on the OK button. OnClickListener listener = null; if ((getActivity() instanceof DialogInputListener)) { listener = (dialog, which) -> { FragmentActivity activity = getActivity(); if (activity == null) Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?"); else ((DialogInputListener) activity).onInputEntered(actionId, binding.edit.getText().toString(), extras); }; } builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, listener); final AlertDialog dialog = builder.create(); // Show the keyboard when the EditText gains focus. binding.edit.setOnFocusChangeListener((v, hasFocus) -> { if (hasFocus) { Window window = dialog.getWindow(); if (window != null) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); final Context context = getActivity(); try { final InputValidator validator = inputValidatorClass == null ? null : (InputValidator) inputValidatorClass.newInstance(); Log.v(TAG, "input validator = " + validator); // Validate the text as the user types. binding.edit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { mEnteredText = binding.edit.getText().toString(); if (validator != null) validateText(context, dialog, binding.edit, validator, actionId, extras); } }); dialog.setOnShowListener(dialogInterface -> { Log.v(TAG, "onShow"); validateText(context, dialog, binding.edit, validator, actionId, extras); }); } catch (Exception e) { Log.e(TAG, "Could not instantiate validator " + inputValidatorClass + ": " + e.getMessage(), e); } return dialog; }
From source file:com.coinblesk.client.ui.dialogs.ProgressSuccessOrFailDialog.java
@Override @NonNull//from www.j a v a2 s . c om public Dialog onCreateDialog(Bundle savedInstanceState) { View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_progress_success_fail, null); viewProgress = view.findViewById(R.id.viewProgress); viewSuccess = view.findViewById(R.id.viewSuccess); viewFailure = view.findViewById(R.id.viewFailure); viewMessage = view.findViewById(R.id.viewMessage); txtMessage = (TextView) view.findViewById(R.id.txtMessage); if (savedInstanceState != null) { setState((State) savedInstanceState.getSerializable(ARG_STATE)); title = savedInstanceState.getString(ARG_TITLE); setMessage(savedInstanceState.getString(ARG_MESSAGE, "")); } else if (getArguments() != null) { setState((State) getArguments().getSerializable(ARG_STATE)); title = getArguments().getString(ARG_TITLE); setMessage(getArguments().getString(ARG_MESSAGE, "")); } AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.AlertDialogAccent); Dialog dialog = builder.setTitle(title).setCancelable(true) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setView(view).create(); return dialog; }
From source file:com.prasanna.android.stacknetwork.QuestionActivity.java
protected void addMyCommentToPost(Bundle resultData) { SharedPreferencesUtil.setLong(this, WritePermission.PREF_LAST_COMMENT_WRITE, System.currentTimeMillis()); Comment comment = (Comment) resultData.getSerializable(StringConstants.COMMENT); int viewPagerPosition = resultData.getInt(StringConstants.VIEW_PAGER_POSITION, -1); if (viewPagerPosition == 0) { if (question.comments == null) question.comments = new ArrayList<Comment>(); question.comments.add(comment);/*from ww w . ja v a2 s .c om*/ questionFragment.setComments(question.comments); } else { AnswerFragment answerFragment = findFragmentByTag(getViewPagerFragmentTag(viewPagerPosition), AnswerFragment.class); answerFragment.onCommentAdd(comment); } }
From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java
@Override public Loader<List<Language>> onCreateLoader(int id, Bundle args) { LoadingType loadingType = (LoadingType) args.getSerializable(LOADING_TYPE_KEY); return new LanguageLoader(this, mLocation, loadingType); }
From source file:colorpicker.ColorPickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mTitle = getArguments().getString(KEY_TITLE_ID); mMessage = getArguments().getString(KEY_MESSAGE_ID); mColumns = getArguments().getInt(KEY_COLUMNS); mSize = getArguments().getInt(KEY_SIZE); }/*from w w w.j av a 2 s . c o m*/ if (savedInstanceState != null) { mColors = savedInstanceState.getIntArray(KEY_COLORS); Serializable obj = savedInstanceState.getSerializable(KEY_SELECTED_COLOR); if (obj != null && obj instanceof Integer) { mSelectedColor = (Integer) obj; } } }
From source file:com.bt.heliniumstudentapp.DayActivity.java
@SuppressWarnings("ConstantConditions") @Override// w ww . j a v a 2s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_day); final Toolbar toolbarTB = (Toolbar) findViewById(R.id.tb_toolbar_ad); setSupportActionBar(toolbarTB); toolbarTB.setBackgroundResource(MainActivity.primaryColor); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbarTB.getNavigationIcon().setColorFilter(ContextCompat.getColor(this, MainActivity.primaryTextColor), PorterDuff.Mode.SRC_ATOP); getWindow().getDecorView().setBackgroundResource(MainActivity.themeColor); MainActivity.setStatusBar(this); ViewPager daysVP = (ViewPager) findViewById(R.id.vp_days_ad); Bundle bundle = getIntent().getExtras(); schedule = (ScheduleFragment.week) bundle.getSerializable("schedule"); lastPosition = (Integer) bundle.get("pos"); daysVP.setAdapter(new DaysAdapter(this, getSupportFragmentManager())); daysVP.setOffscreenPageLimit(1); daysVP.setCurrentItem(lastPosition); compactView = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pref_customization_compact", false); MainActivity.setToolbarTitle(this, schedule.day_get(schedule.day_get_index(lastPosition) + 2).day, schedule.day_get(schedule.day_get_index(lastPosition) + 2).date); daysVP.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { MainActivity.setToolbarTitle(DayActivity.this, schedule.day_get(schedule.day_get_index(position) + 2).day, schedule.day_get(schedule.day_get_index(position) + 2).date); hw_floating = (schedule.day_get(schedule.day_get_index(position) + 2).floatings_get() != 0); invalidateOptionsMenu(); lastPosition = position; } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } }); }
From source file:com.sayar.requests.RequestArguments.java
@SuppressWarnings("unchecked") private RequestArguments(final Parcel bundle) { this.method = RequestMethod.fromValue(bundle.readString()); this.url = bundle.readString(); this.userAgent = bundle.readString(); this.parseAs = bundle.readString(); final Bundle params = bundle.readBundle(); this.params = (Map<String, String>) params.getSerializable("map"); final Bundle headers = bundle.readBundle(); this.headers = (Map<String, String>) headers.getSerializable("map"); }