List of usage examples for android.os Bundle putBoolean
public void putBoolean(@Nullable String key, boolean value)
From source file:app.hacked.ProjectDetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.project_details_activity); // Set up the action bar. final ActionBar actionBar = getActionBar(); getActionBar().setIcon(R.drawable.ic_ab_logo); getActionBar().setDisplayHomeAsUpEnabled(true); // savedInstanceState is non-null when there is fragment state // saved from previous configurations of this activity // (e.g. when rotating the screen from portrait to landscape). // In this case, the fragment will automatically be re-added // to its container so we don't need to manually add it. // For more information, see the Fragments API guide at: ///*from ww w . java 2 s. com*/ // http://developer.android.com/guide/components/fragments.html // if (savedInstanceState == null) { // Create the detail fragment and add it to the activity // using a fragment transaction. Bundle arguments = new Bundle(); arguments.putInt(ProjectDetailsFragment.PROJECTID, getIntent().getIntExtra(ProjectDetailsFragment.PROJECTID, 0)); arguments.putString(ProjectDetailsFragment.NAME, getIntent().getStringExtra(ProjectDetailsFragment.NAME)); arguments.putString(ProjectDetailsFragment.SYNOPSIS, getIntent().getStringExtra(ProjectDetailsFragment.SYNOPSIS)); arguments.putString(ProjectDetailsFragment.DESCRIPTION, getIntent().getStringExtra(ProjectDetailsFragment.DESCRIPTION)); arguments.putString(ProjectDetailsFragment.LOCATION, getIntent().getStringExtra(ProjectDetailsFragment.LOCATION)); arguments.putString(ProjectDetailsFragment.TECHNOLOGIES, getIntent().getStringExtra(ProjectDetailsFragment.TECHNOLOGIES)); arguments.putInt(ProjectDetailsFragment.POPULARITY, getIntent().getIntExtra(ProjectDetailsFragment.POPULARITY, 1)); //arguments.putString(ProjectDetailsFragment.TEAMMEMBERS, getIntent().getStringExtra(ProjectDetailsFragment.TEAMMEMBERS)); arguments.putParcelableArrayList(ProjectDetailsFragment.TEAMMEMBERS, getIntent().getParcelableArrayListExtra(ProjectDetailsFragment.TEAMMEMBERS)); arguments.putBoolean(ProjectDetailsFragment.ARG_2PANE, getIntent().getBooleanExtra(ProjectDetailsFragment.ARG_2PANE, false)); ProjectDetailsFragment fragment = new ProjectDetailsFragment(); fragment.setArguments(arguments); fragment.setHasOptionsMenu(true); getSupportFragmentManager().beginTransaction().replace(R.id.ProjectDetails, fragment).commit(); } }
From source file:com.android.dialer.DialtactsActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(KEY_SEARCH_QUERY, mSearchQuery); outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch); outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch); outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); mActionBarController.saveInstanceState(outState); mStateSaved = true;// w w w . j a va 2 s.co m }
From source file:se.leap.bitmaskclient.ProviderAPI.java
private Bundle authFailedNotification(JSONObject result, String username) { Bundle user_notification_bundle = new Bundle(); try {/*from www . jav a2s . c o m*/ JSONObject error_message = result.getJSONObject(ERRORS); String error_type = error_message.keys().next().toString(); String message = error_message.get(error_type).toString(); user_notification_bundle.putString(getResources().getString(R.string.user_message), message); } catch (JSONException e) { } if (!username.isEmpty()) user_notification_bundle.putString(SessionDialog.USERNAME, username); user_notification_bundle.putBoolean(RESULT_KEY, false); return user_notification_bundle; }
From source file:com.android.calendar.event.EditEventFragment.java
@Override public void onSaveInstanceState(Bundle outState) { mView.prepareForSave();/* ww w.ja va 2 s. co m*/ outState.putSerializable(BUNDLE_KEY_MODEL, mModel); outState.putInt(BUNDLE_KEY_EDIT_STATE, mModification); if (mEventBundle == null && mEvent != null) { mEventBundle = new EventBundle(); mEventBundle.id = mEvent.id; if (mEvent.startTime != null) { mEventBundle.start = mEvent.startTime.toMillis(true); } if (mEvent.endTime != null) { mEventBundle.end = mEvent.startTime.toMillis(true); } } outState.putBoolean(BUNDLE_KEY_EDIT_ON_LAUNCH, mShowModifyDialogOnLaunch); outState.putSerializable(BUNDLE_KEY_EVENT, mEventBundle); outState.putBoolean(BUNDLE_KEY_READ_ONLY, mIsReadOnly); outState.putBoolean(BUNDLE_KEY_SHOW_COLOR_PALETTE, mView.isColorPaletteVisible()); outState.putBoolean("EditEventView_timebuttonclicked", mView.mTimeSelectedWasStartTime); outState.putBoolean(BUNDLE_KEY_DATE_BUTTON_CLICKED, mView.mDateSelectedWasStartDate); }
From source file:org.planetmono.dcuploader.SignOnRealName.java
public Runnable getMethodSignOn(final Application app, final Bundle b, final Handler resultHandler) { return new Runnable() { public void run() { Message m = resultHandler.obtainMessage(); Bundle bm = m.getData(); Log.d("dcuploader", "authenticating..."); String encdata = b.getString("enc_data"); String name = b.getString("name"); String code1 = b.getString("code1"); String code2 = b.getString("code2"); HttpPost post = new HttpPost(AUTH_URL); List<NameValuePair> vlist = new ArrayList<NameValuePair>(); vlist.add(new BasicNameValuePair("enc_data", encdata)); vlist.add(new BasicNameValuePair("result_code", "1")); vlist.add(new BasicNameValuePair("contract_type", "S")); vlist.add(new BasicNameValuePair("au_chk", "F")); vlist.add(new BasicNameValuePair("name", name)); vlist.add(new BasicNameValuePair("juminid1", code1)); vlist.add(new BasicNameValuePair("juminid2", code2)); try { post.setEntity(new UrlEncodedFormEntity(vlist)); } catch (UnsupportedEncodingException e) { e.printStackTrace();/*from w w w . j a v a 2s.com*/ } HttpResponse response = null; try { response = app.sendPostRequest(post); } catch (Exception e) { e.printStackTrace(); bm.putBoolean("result", false); bm.putString("resultString", " "); resultHandler.sendMessage(m); return; } HttpEntity entity = response.getEntity(); BufferedReader r; try { r = new BufferedReader(new InputStreamReader(entity.getContent(), "EUC-KR")); while (true) { String line = r.readLine(); if (line == null) break; if (line.contains(" ?? ")) { bm.putBoolean("result", false); bm.putString("resultString", "?? "); resultHandler.sendMessage(m); return; } } } catch (Exception e) { bm.putBoolean("result", false); bm.putString("resultString", " "); resultHandler.sendMessage(m); return; } /* abnormal status. traffic limit exceeded? */ bm.putBoolean("result", true); resultHandler.sendMessage(m); } }; }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
private void showTopTracks() { SubsonicFragment fragment = new SelectDirectoryFragment(); Bundle args = new Bundle(getArguments()); args.putBoolean(Constants.INTENT_EXTRA_TOP_TRACKS, true); fragment.setArguments(args);//from w w w. j a v a2s . c o m replaceFragment(fragment, true); }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
private void setShowAll() { SubsonicFragment fragment = new SelectDirectoryFragment(); Bundle args = new Bundle(getArguments()); args.putBoolean(Constants.INTENT_EXTRA_SHOW_ALL, true); fragment.setArguments(args);//from w w w. j a v a2 s.c o m replaceFragment(fragment, true); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void setEnabled(boolean value) { // Don't set a state that we're already in. Log.i(TAG, "- Enable: " + isEnabled + " " + value); Activity activity = cordova.getActivity(); boolean wasEnabled = isEnabled; isEnabled = value;/* ww w . j a v a 2 s. c o m*/ isMoving = null; Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.hasExtra("location")) { try { JSONObject location = new JSONObject(launchIntent.getStringExtra("location")); onLocationChange(location); } catch (JSONException e) { Log.w(TAG, e); } } } SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("enabled", isEnabled); editor.apply(); EventBus eventBus = EventBus.getDefault(); if (isEnabled) { synchronized (eventBus) { if (!eventBus.isRegistered(this)) { eventBus.register(this); } } if (!BackgroundGeolocationService.isInstanceCreated()) { activity.startService(backgroundServiceIntent); } else { final Bundle event = new Bundle(); if (!wasEnabled) { event.putString("name", BackgroundGeolocationService.ACTION_START); } else { event.putString("name", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION); } event.putBoolean("request", true); postEvent(event); onStarted(event); } } else { Bundle event = new Bundle(); event.putString("name", BackgroundGeolocationService.ACTION_STOP); event.putBoolean("request", true); postEvent(event); synchronized (eventBus) { if (eventBus.isRegistered(this)) { eventBus.unregister(this); } } //activity.stopService(backgroundServiceIntent); backgroundServiceIntent = null; } }
From source file:app.hacked.AddProjectFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.add_project_fragment, null); ((TextView) view.findViewById(R.id.Title)).setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL)); ProjectNameET = (EditText) view.findViewById(R.id.ProjectNameET); SynopsisET = (EditText) view.findViewById(R.id.SynopsisET); DescET = (EditText) view.findViewById(R.id.DescET); TeamMemberET = (EditText) view.findViewById(R.id.TeamMemberET); TechET = (EditText) view.findViewById(R.id.ProjectNameET); ((Button) view.findViewById(R.id.CancelButton)).setOnClickListener(new View.OnClickListener() { @Override/*from www . j av a2 s . c om*/ public void onClick(View view) { getActivity().finish(); } }); ((Button) view.findViewById(R.id.addProjectButton)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ProjectNameET.getText().toString().equals("")) { Toast.makeText(getActivity(), "A project needs a name for people to recognise!", Toast.LENGTH_SHORT).show(); return; } JSONObject post = new JSONObject(); try { post.put("project_name", ProjectNameET.getText().toString()); post.put("project_synopsis", SynopsisET.getText().toString()); post.put("project_desc", DescET.getText().toString()); post.put("project_team", TeamMemberET.getText().toString()); post.put("project_tech", TechET.getText().toString()); post.put("auth", API.md5(API.BETTER_THAN_NOTHING_STUFF_TO_PREVENT_INJECTION_ATTEMPTS + ProjectNameET.getText().toString())); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getActivity(), "An Error Was encountered parsing the entered details: " + e.getMessage(), Toast.LENGTH_SHORT).show(); return; } JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST, "http://hackedioapp.networksaremadeofstring.co.uk/addproject.php", post, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.e("response", response.toString()); try { if (response.has("success") && response.getBoolean("success")) { Toast.makeText(getActivity(), "Project added successfully!", Toast.LENGTH_SHORT).show(); if (getActivity().findViewById(R.id.ProjectDetails) != null) { Bundle arguments = new Bundle(); arguments.putInt(ProjectDetailsFragment.PROJECTID, response.getInt("uuid")); arguments.putString(ProjectDetailsFragment.NAME, ProjectNameET.getText().toString()); arguments.putString(ProjectDetailsFragment.SYNOPSIS, SynopsisET.getText().toString()); arguments.putString(ProjectDetailsFragment.DESCRIPTION, DescET.getText().toString()); arguments.putString(ProjectDetailsFragment.TECHNOLOGIES, TechET.getText().toString()); arguments.putInt(ProjectDetailsFragment.POPULARITY, 1); arguments.putString(ProjectDetailsFragment.TEAMMEMBERS, TeamMemberET.getText().toString()); arguments.putBoolean(ProjectDetailsFragment.ARG_2PANE, true); ProjectDetailsFragment fragment = new ProjectDetailsFragment(); fragment.setArguments(arguments); fragment.setHasOptionsMenu(true); getActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.ProjectDetails, fragment).commit(); } else { getActivity().finish(); Intent detailIntent = new Intent(getActivity(), ProjectDetailsActivity.class); detailIntent.putExtra(ProjectDetailsFragment.PROJECTID, response.getInt("uuid")); detailIntent.putExtra(ProjectDetailsFragment.NAME, ProjectNameET.getText().toString()); detailIntent.putExtra(ProjectDetailsFragment.SYNOPSIS, SynopsisET.getText().toString()); detailIntent.putExtra(ProjectDetailsFragment.DESCRIPTION, DescET.getText().toString()); detailIntent.putExtra(ProjectDetailsFragment.TECHNOLOGIES, TechET.getText().toString()); detailIntent.putExtra(ProjectDetailsFragment.POPULARITY, 1); detailIntent.putExtra(ProjectDetailsFragment.TEAMMEMBERS, TeamMemberET.getText().toString()); detailIntent.putExtra(ProjectDetailsFragment.ARG_2PANE, true); startActivity(detailIntent); } } else { String error = ""; if (response.has("error")) error = ": " + response.getString("error"); Toast.makeText(getActivity(), "An Error Was encountered" + error, Toast.LENGTH_SHORT).show(); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getActivity(), "An Error Was encountered: " + e.getMessage(), Toast.LENGTH_SHORT).show(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub Toast.makeText(getActivity(), "An Error Was encountered: " + error.getMessage(), Toast.LENGTH_SHORT).show(); } }); queue.add(jsObjRequest); } }); return view; }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
private void startEditFragment(final View view, final int position) { sourceList.setOnItemClickListener(null); sourceList.setEnabled(false);/*from w w w .ja va 2 s .c om*/ listAdapter.saveData(); Source dataItem = listAdapter.getItem(position); final SourceInfoFragment sourceInfoFragment = new SourceInfoFragment(); sourceInfoFragment.setImageDrawable(((ImageView) view.findViewById(R.id.source_image)).getDrawable()); Bundle arguments = new Bundle(); arguments.putInt("position", position); arguments.putString("type", dataItem.getType()); arguments.putString("title", dataItem.getTitle()); arguments.putString("data", dataItem.getData()); arguments.putInt("num", dataItem.getNum()); arguments.putBoolean("use", dataItem.isUse()); arguments.putBoolean("preview", dataItem.isPreview()); String imageFileName = dataItem.getImageFile().getAbsolutePath(); if (imageFileName != null && imageFileName.length() > 0) { arguments.putString("image", imageFileName); } else { arguments.putString("image", ""); } arguments.putBoolean("use_time", dataItem.isUseTime()); arguments.putString("time", dataItem.getTime()); sourceInfoFragment.setArguments(arguments); final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container); final CardView sourceCard = (CardView) view.findViewById(R.id.source_card); final View imageOverlay = view.findViewById(R.id.source_image_overlay); final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title); final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container); final float cardStartShadow = sourceCard.getPaddingLeft(); final float viewStartHeight = sourceContainer.getHeight(); final float viewStartY = view.getY(); final int viewStartPadding = view.getPaddingLeft(); final float textStartX = sourceTitle.getX(); final float textStartY = sourceTitle.getY(); final float textTranslationY = sourceTitle.getHeight(); /*+ TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());*/ Animation animation = new Animation() { private boolean needsFragment = true; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (needsFragment && interpolatedTime >= 1) { needsFragment = false; getFragmentManager().beginTransaction() .add(R.id.content_frame, sourceInfoFragment, "source_info_fragment") .addToBackStack(null).setTransition(FragmentTransaction.TRANSIT_NONE).commit(); } int newPadding = Math.round(viewStartPadding * (1 - interpolatedTime)); int newShadowPadding = (int) (cardStartShadow * (1.0f - interpolatedTime)); sourceCard.setShadowPadding(newShadowPadding, 0, newShadowPadding, 0); ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).topMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).bottomMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).leftMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).rightMargin = newShadowPadding; view.setPadding(newPadding, 0, newPadding, 0); view.setY(viewStartY - interpolatedTime * viewStartY); ViewGroup.LayoutParams params = sourceContainer.getLayoutParams(); params.height = (int) (viewStartHeight + (screenHeight - viewStartHeight) * interpolatedTime); sourceContainer.setLayoutParams(params); sourceTitle.setY(textStartY + interpolatedTime * textTranslationY); sourceTitle.setX(textStartX + viewStartPadding - newPadding); deleteButton.setAlpha(1.0f - interpolatedTime); viewButton.setAlpha(1.0f - interpolatedTime); editButton.setAlpha(1.0f - interpolatedTime); sourceExpandContainer.setAlpha(1.0f - interpolatedTime); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } @Override public void onAnimationRepeat(Animation animation) { } }); ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getDialogColor(appContext), getResources().getColor(AppSettings.getBackgroundColorResource())); cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue()); } }); ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), sourceTitle.getCurrentTextColor(), getResources().getColor(R.color.BLUE_OPAQUE)); titleColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceTitle.setTextColor((Integer) animation.getAnimatedValue()); } }); ValueAnimator titleShadowAlphaAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getColorFilterInt(appContext), getResources().getColor(android.R.color.transparent)); titleShadowAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceTitle.setShadowLayer(4, 0, 0, (Integer) animation.getAnimatedValue()); } }); ValueAnimator imageOverlayAlphaAnimation = ValueAnimator.ofFloat(imageOverlay.getAlpha(), 0f); imageOverlayAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { imageOverlay.setAlpha((Float) animation.getAnimatedValue()); } }); int transitionTime = INFO_ANIMATION_TIME; DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f); animation.setDuration(transitionTime); cardColorAnimation.setDuration(transitionTime); titleColorAnimation.setDuration(transitionTime); titleShadowAlphaAnimation.setDuration(transitionTime); animation.setInterpolator(decelerateInterpolator); cardColorAnimation.setInterpolator(decelerateInterpolator); titleColorAnimation.setInterpolator(decelerateInterpolator); titleShadowAlphaAnimation.setInterpolator(decelerateInterpolator); if (imageOverlay.getAlpha() > 0) { imageOverlayAlphaAnimation.start(); } handler.postDelayed(new Runnable() { @Override public void run() { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } }, (long) (transitionTime * 1.1f)); needsListReset = true; view.startAnimation(animation); cardColorAnimation.start(); titleColorAnimation.start(); titleShadowAlphaAnimation.start(); }