List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:ca.rmen.android.scrumchatter.team.Teams.java
/** * Shows a confirmation dialog to the user to delete a team. */// w ww . j ava 2s . c om @MainThread public void confirmDeleteTeam(final Team team) { Log.v(TAG, "confirmDeleteTeam, team = " + team); getTeamCount().subscribe(teamCount -> { // We need at least one team in the app. if (teamCount <= 1) { DialogFragmentFactory.showInfoDialog(mActivity, R.string.action_team_delete, R.string.dialog_error_one_team_required); } // Delete this team else if (team != null) { Bundle extras = new Bundle(1); extras.putParcelable(EXTRA_TEAM_URI, team.teamUri); DialogFragmentFactory.showConfirmDialog(mActivity, mActivity.getString(R.string.action_team_delete), mActivity.getString(R.string.dialog_message_delete_team_confirm, team.teamName), R.id.action_team_delete, extras); } }); }
From source file:co.nerdart.ourss.adapter.CursorLoaderExpandableListAdapter.java
@Override public int getChildrenCount(int groupPosition) { Pair<Cursor, Boolean> childCursor = mChildrenCursors.get(groupPosition); // We need to restart the loader if ((childCursor == null || childCursor.second) && mGroupCursor != null && !mGroupCursor.isClosed() && mGroupCursor.moveToPosition(groupPosition)) { Bundle args = new Bundle(); args.putParcelable(URI_ARG, getChildrenUri(mGroupCursor)); mLoaderMgr.restartLoader(groupPosition + 1, args, mChildrenLoaderCallback); }/* w w w . ja v a2 s . c om*/ if (childCursor != null && !childCursor.first.isClosed()) { return childCursor.first.getCount(); } return 0; }
From source file:com.chao.facebookzc.UiLifecycleHelper.java
/** * To be called from an Activity or Fragment's onSaveInstanceState method. * * @param outState the bundle to save state in *//* w w w . j a v a2 s. c om*/ public void onSaveInstanceState(Bundle outState) { Session.saveSession(Session.getActiveSession(), outState); outState.putParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY, pendingFacebookDialogCall); }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void saveAndNotify(Intent intent, String result) { Context context = getApplicationContext(); int rep_code = -1; String desc;// w w w . j a va 2 s . co m try { JSONObject jsonObject = new JSONObject(result); rep_code = jsonObject.getInt("code"); desc = jsonObject.getString("desc"); } catch (JSONException e) { e.printStackTrace(); desc = context.getString(R.string.chat_error_json); } Messenger messenger; if (intent.hasExtra("messenger")) messenger = (Messenger) intent.getExtras().get("messenger"); else messenger = null; Message repMsg = Message.obtain(); repMsg.what = MSG_END_SENDING; ChatItem item = intent.getParcelableExtra("pass_item"); ChatItem newItem = null; if (item != null) { if (rep_code == 200) { item.setState(Constants.CHATITEM_STATE_SUCCESS); DBStaticManager.updateChatItem(context, item); } else { if (rep_code == 415) { item.setState(Constants.CHATITEM_STATE_SUCCESS); } else { item.setState(Constants.CHATITEM_STATE_ERROR); } DBStaticManager.updateChatItem(context, item); newItem = new ChatItem(); newItem.setContent(desc); newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_ERROR); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } else { if (rep_code != 200) { Log.d(TAG, result); newItem = new ChatItem(); newItem.setContent(getString(R.string.loc_send_error) + ":" + desc); // TODO - not only loc report newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_SUCCESS); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } Log.d(TAG, "dequeue item: " + item); if (item == null) return; Bundle bundle = new Bundle(); bundle.putParcelable("item", item); if (newItem != null) bundle.putParcelable("new_item", newItem); bundle.putInt("rep_code", rep_code); if (messenger != null) { repMsg.setData(bundle); try { messenger.send(repMsg); } catch (RemoteException e) { e.printStackTrace(); } } else { Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_END); Intent newIntent = new Intent(ACTION_SEND_MSG_END); newIntent.putExtras(bundle); sendBroadcast(newIntent); } }
From source file:net.naonedbus.card.impl.CommentairesCard.java
private View createView(final LayoutInflater inflater, final ViewGroup root, final Commentaire commentaire) { final View view = inflater.inflate(R.layout.card_item_commentaire, root, false); final TextView itemTitle = (TextView) view.findViewById(R.id.itemTitle); final TextView itemDate = (TextView) view.findViewById(R.id.itemTime); final TextView itemDescription = (TextView) view.findViewById(R.id.itemDescription); String title = ""; if (NaonedbusClient.NAONEDBUS.name().equals(commentaire.getSource())) { if (commentaire.getArret() == null && commentaire.getSens() == null && commentaire.getLigne() == null) { title = view.getContext().getString(R.string.commentaire_tout); } else {//from w w w.j ava 2s .co m if (commentaire.getArret() != null) { title = commentaire.getArret().getNomArret() + " "; } if (commentaire.getSens() != null) { title = title + "\u2192 " + commentaire.getSens().text; } } } else { title = getString(CommentaireFomatter.getTitleResId(commentaire.getSource())); } itemDescription.setText(commentaire.getMessage(), BufferType.SPANNABLE); itemDate.setText(commentaire.getDelay()); if (title.trim().length() == 0) { itemTitle.setVisibility(View.GONE); } else { itemTitle.setVisibility(View.VISIBLE); itemTitle.setText(title.trim()); } view.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final Bundle bundle = new Bundle(); bundle.putParcelable(CommentaireDetailDialogFragment.PARAM_COMMENTAIRE, commentaire); final DialogFragment dialogFragment = new CommentaireDetailDialogFragment(); dialogFragment.setArguments(bundle); dialogFragment.show(getFragmentManager(), "CommentaireDetailFragment"); } }); return view; }
From source file:com.linkedin.android.eventsapp.EventFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final String eventNameArg = getArguments().getString(EXTRA_EVENT_NAME); final long eventDateArg = getArguments().getLong(EXTRA_EVENT_DATE); final String eventLocationArg = getArguments().getString(EXTRA_EVENT_LOCATION); int pictureIdArg = getArguments().getInt(EXTRA_PICTURE_ID); boolean isAttendingArg = getArguments().getBoolean(EXTRA_EVENT_ATTENDING); Person[] attendeesArg = (Person[]) getArguments().getParcelableArray(EXTRA_EVENT_ATTENDEES); SimpleDateFormat dateFormat = new SimpleDateFormat("E dd MMM yyyy 'at' hh:00 a"); final String dateString = dateFormat.format(new Date(eventDateArg)); View v = inflater.inflate(R.layout.layout_event_fragment, container, false); boolean accessTokenValid = LISessionManager.getInstance(getActivity()).getSession().isValid(); if (!accessTokenValid) { ViewStub linkedinLogin = (ViewStub) v.findViewById(R.id.connectWithLinkedInStub); linkedinLogin.inflate();// w w w . ja va 2s .co m Button loginButton = (Button) v.findViewById(R.id.connectWithLinkedInButton); loginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i(TAG, "clicked login button"); LISessionManager.getInstance(getActivity()).init(getActivity(), Constants.scope, new AuthListener() { @Override public void onAuthSuccess() { Intent intent = new Intent(getActivity(), MainActivity.class); startActivity(intent); getActivity().finish(); } @Override public void onAuthError(LIAuthError error) { } }, false); } }); } TextView eventNameView = (TextView) v.findViewById(R.id.eventName); eventNameView.setText(eventNameArg); TextView eventLocationAndDateView = (TextView) v.findViewById(R.id.eventLocationAndDate); eventLocationAndDateView.setText(eventLocationArg + " " + dateString); TextView eventAttendeeCount = (TextView) v.findViewById(R.id.attendeeCount); eventAttendeeCount.setText("Other Attendees (" + attendeesArg.length + ")"); ImageView eventImageView = (ImageView) v.findViewById(R.id.eventImage); eventImageView.setImageResource(pictureIdArg); final Button attendButton = (Button) v.findViewById(R.id.attendButton); final Button declineButton = (Button) v.findViewById(R.id.declineButton); if (isAttendingArg) { attendButton.setText("Attending"); attendButton.setEnabled(false); declineButton.setText("Decline"); declineButton.setEnabled(true); } attendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((Button) v).setText("Attending"); v.setEnabled(false); declineButton.setText("Decline"); declineButton.setEnabled(true); if (LISessionManager.getInstance(getActivity()).getSession().isValid()) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setTitle("Share on LinkedIn?"); alertDialogBuilder.setCancelable(true) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { JSONObject shareObject = new JSONObject(); try { JSONObject visibilityCode = new JSONObject(); visibilityCode.put("code", "anyone"); shareObject.put("visibility", visibilityCode); shareObject.put("comment", "I am attending " + eventNameArg + " in " + eventLocationArg + " on " + dateString); } catch (JSONException e) { } APIHelper.getInstance(getActivity()).postRequest(getActivity(), Constants.shareBaseUrl, shareObject, new ApiListener() { @Override public void onApiSuccess(ApiResponse apiResponse) { Toast.makeText(getActivity(), "Your share was successful!", Toast.LENGTH_LONG); } @Override public void onApiError(LIApiError apiError) { Log.e(TAG, apiError.toString()); Toast.makeText(getActivity(), "Your share was unsuccessful. Try again later!", Toast.LENGTH_LONG); } }); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } } }); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((Button) v).setText("Declined"); v.setEnabled(false); attendButton.setText("Attend"); attendButton.setEnabled(true); } }); ListView attendeesListView = (ListView) v.findViewById(R.id.attendeesList); AttendeeAdapter adapter = new AttendeeAdapter(getActivity(), R.layout.attendee_list_item, attendeesArg, accessTokenValid); attendeesListView.setAdapter(adapter); attendeesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ArrayAdapter adapter = (ArrayAdapter) parent.getAdapter(); Person person = (Person) adapter.getItem(position); Intent intent = new Intent(getActivity(), ProfileActivity.class); Bundle extras = new Bundle(); extras.putParcelable("person", person); intent.putExtras(extras); startActivity(intent); } }); return v; }
From source file:com.krayzk9s.imgurholo.activities.ImageActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getActionBar() != null) getActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { Intent intent = getIntent();//from w w w. j a v a2 s.com Log.d("intent", intent.getExtras().getParcelable("id").toString()); JSONObject id = ((JSONParcelable) intent.getExtras().getParcelable("id")).getJSONObject(); try { if (id.has("is_album") && id.getBoolean("is_album")) { ImagesFragment fragment = new ImagesFragment(); Bundle bundle = new Bundle(); bundle.putString("imageCall", "3/album/" + id.getString("id")); bundle.putString("id", id.getString("id")); JSONParcelable data = new JSONParcelable(); data.setJSONObject(id); bundle.putParcelable("albumData", data); fragment.setArguments(bundle); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_layout, fragment).commitAllowingStateLoss(); } else { SingleImageFragment singleImageFragment = new SingleImageFragment(); Bundle bundle = new Bundle(); bundle.putBoolean("gallery", true); JSONParcelable data = new JSONParcelable(); data.setJSONObject(id); bundle.putParcelable("imageData", data); singleImageFragment.setArguments(bundle); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_layout, singleImageFragment).commitAllowingStateLoss(); } } catch (JSONException e) { Log.e("Error!", e.toString()); } } }
From source file:com.scrachx.foodfacts.checker.ui.main.MainActivity.java
@Override public void openPageProduct(State stateProduct) { Bundle args = new Bundle(); args.putParcelable("state", stateProduct); startActivity(ProductActivity.getStartIntent(this, args)); }
From source file:com.brucetoo.imagebrowse.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imgList.add(0, "http://cdn.at.cn/upload/146336617940.jpg"); imgList.add(1, "http://cdn.at.cn/upload/146540079128.jpg"); imgList.add(2, "http://cdn.at.cn/upload/146528287960.jpg"); imgList.add(3, "http://cdn.at.cn/upload/146271377052.jpg"); imgList.add(4, "http://cdn.at.cn/upload/146502027460.jpg"); imgList.add(5, "http://cdn.at.cn/upload/146296005117.jpg"); imgList.add(6, "http://cdn.at.cn/upload/146386101517.jpg"); imgList.add(7, "http://cdn.at.cn/upload/146289180072.jpg"); imgList.add(8, "http://cdn.at.cn/upload/146378563799.jpg"); // imgList.add(0, "http://img6.cache.netease.com/3g/2015/9/30/20150930091938133ad.jpg"); // imgList.add(1, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg"); // imgList.add(2, "http://img5.cache.netease.com/3g/2015/9/30/20150930075225737e5.jpg"); // imgList.add(3, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg"); // imgList.add(4, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg"); // imgList.add(5, "http://img2.cache.netease.com/3g/2015/9/30/20150930091208cf03c.jpg"); // imgList.add(6, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg"); // imgList.add(7, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg"); // imgList.add(8, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg"); gridView = (GridView) findViewById(R.id.gridview); root = findViewById(R.id.layout_root); final ImageAdapter adapter = new ImageAdapter(); gridView.setAdapter(adapter);//from w w w . j a v a 2s . c o m gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, long id) { if (view.isEnabled()) { //Use of ImageBrowseFragment Bundle bundle = new Bundle(); bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList); bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, ((PhotoView) view).getInfo()); bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position); imgImageInfos.clear(); //NOTE:if imgList.size >= the visible count in single screen,i will cause NullPointException //because item out of screen have been replaced/reused for (int i = 0; i < imgList.size(); i++) { imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo()); } parent.getChildAt(position); bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos); getSupportFragmentManager() .beginTransaction().replace(Window.ID_ANDROID_CONTENT, ImageBrowseFragment.newInstance(bundle), "ViewPagerFragment") .addToBackStack(null).commit(); //Use of ImageBrowseDialogFragment // root.post(new Runnable() { // in case root view not inflate complete // @Override // public void run() { // Bundle bundle = new Bundle(); // bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList); // final ImageInfo preImgInfo = ((PhotoView) view).getInfo(); // bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, preImgInfo); // bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position); // imgImageInfos.clear(); // for (int i = 0; i < imgList.size(); i++) { // imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo()); // } // bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos); // int[] position = new int[2]; // root.getLocationOnScreen(position); // //Must correct the ImageInfo in DialogFragment // preImgInfo.correct(position, getStatusBarHeight()); // for (ImageInfo item : imgImageInfos) { // item.correct(position,getStatusBarHeight()); // } // ImageBrowseDialogFragment.newInstance(bundle).show(getSupportFragmentManager(), ImageBrowseDialogFragment.class.getSimpleName()); // } // }); } } }); }
From source file:com.artemchep.horario.ui.fragments.master.ExamsFragment.java
@Override public void onItemClick(@NonNull View view, @NonNull Exam item) { super.onItemClick(view, item); Bundle args = new Bundle(); args.putBoolean(EXTRA_EDITABLE, mEditable); args.putString(ModelFragment.EXTRA_TIMETABLE_PATH, mTimetablePath); args.putParcelable(MooDetailsFragment.EXTRA_MODEL, item); Fragment fragment = new ExamDetailsFragment(); fragment.setArguments(args);/*from w w w .jav a2 s . c o m*/ MainActivity activity = (MainActivity) getActivity(); activity.navigateDetailsFrame(fragment); }