List of usage examples for android.os Bundle getSerializable
@Override
@Nullable
public Serializable getSerializable(@Nullable String key)
From source file:com.brq.wallet.external.cashila.activity.CashilaNewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.ext_cashila_payments_fragment_new, container, false); unbinder = ButterKnife.bind(this, rootView); mbw = MbwManager.getInstance(this.getActivity()); cs = ((CashilaPaymentsActivity) getActivity()).getCashilaService(); eventBus = mbw.getEventBus();/*from w w w . j a v a 2s .c o m*/ int selItem = 0; if (savedInstanceState != null) { selItem = savedInstanceState.getInt("spRecipient", 0); currentAccountLimits = (AccountLimits.Limits) savedInstanceState.getSerializable("accountLimits"); showAccountLimits(); } // use cache if possible getRecentRecipientsList(selItem, true); return rootView; }
From source file:com.cgf.cardslisttest.RecyclerViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.recycler_view_frag, container, false); rootView.setTag(TAG);// w w w . ja va2 s. c om // BEGIN_INCLUDE(initializeRecyclerView) mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(getActivity()); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); mAdapter = new CustomAdapter(mDataset); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); // END_INCLUDE(initializeRecyclerView) mLinearLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.linear_layout_rb); mLinearLayoutRadioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER); } }); mGridLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.grid_layout_rb); mGridLayoutRadioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerViewLayoutManager(LayoutManagerType.GRID_LAYOUT_MANAGER); } }); return rootView; }
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java
@Override public void create() { try {/* ww w.j a v a 2 s . c om*/ setContentView(R.layout.grouped_contacts_details); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } person = (Person) store.getSerializable("person"); if (person == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } setTopBarTitle(widget.getTitle()); Boolean single = currentIntent.getBooleanExtra("single", true); setTopBarLeftButtonTextAndColor( single ? getResources().getString(R.string.common_home_upper) : getResources().getString(R.string.common_back_upper), getResources().getColor(android.R.color.black), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); setTopBarTitleColor(getResources().getColor(android.R.color.black)); setTopBarBackgroundColor(Statics.color1); if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) { ImageView shareButton = (ImageView) getLayoutInflater() .inflate(R.layout.grouped_contacts_share_button, null); shareButton.setLayoutParams( new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density), (int) (39 * getResources().getDisplayMetrics().density))); shareButton.setColorFilter(Color.BLACK); setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share), new View.OnClickListener() { @Override public void onClick(View v) { DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder(); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) sharingDialogBuilder .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_TEXT, message); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, getString(R.string.choose_email_client))); } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) sharingDialogBuilder .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); try { Utils.sendSms(ContactDetailsActivity.this, message); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT))) sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook, R.drawable.gc_add_to_contacts, true, new DialogSharing.Item.OnClickListener() { @Override public void onClick() { createNewContact(person.getName(), person.getPhone(), person.getEmail()); } }); showDialogSharing(sharingDialogBuilder.build()); } }); } boolean hasSchema = store.getBoolean("hasschema"); cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder(); contacts = person.getContacts(); if (widget.getTitle().length() > 0) { setTitle(widget.getTitle()); } root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root); if (hasSchema) { root.setBackgroundColor(Statics.color1); } else if (widget.isBackgroundURL()) { cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL()); File backgroundFile = new File(cacheBackgroundFile); if (backgroundFile.exists()) { root.setBackgroundDrawable( new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile)))); } else { BackgroundDownloadTask dt = new BackgroundDownloadTask(); dt.execute(widget.getBackgroundURL()); } } else if (widget.isBackgroundInAssets()) { AssetManager am = this.getAssets(); root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL()))); } if (contacts != null) { ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar); avatarImage.setImageResource(R.drawable.gc_profile_avatar); if (person.hasAvatar() && NetworkUtils.isOnline(this)) { avatarImage.setVisibility(View.VISIBLE); Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar) .dontAnimate().into(avatarImage); } else { avatarImage.setVisibility(View.VISIBLE); avatarImage.setImageResource(R.drawable.gc_profile_avatar); } String name = ""; neededContacts = new ArrayList<>(); for (Contact con : contacts) { if ((con.getType() == 5) || (con.getDescription().length() == 0)) { } else { if (con.getType() == 0) { name = con.getDescription(); } else neededContacts.add(con); } } if (neededContacts.isEmpty()) { handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA); return; } headSeparator = findViewById(R.id.gc_head_separator); bottomSeparator = findViewById(R.id.gc_bottom_separator); imageBottom = findViewById(R.id.gc_image_bottom_layout); personName = (TextView) findViewById(R.id.gc_details_description); if ("".equals(name)) personName.setVisibility(View.GONE); else { personName.setVisibility(View.VISIBLE); personName.setText(name); personName.setTextColor(Statics.color3); } if (Statics.isLight) { headSeparator.setBackgroundColor(Color.parseColor("#4d000000")); bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000")); } else { headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); } ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1); ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view); list.setDivider(null); ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this, R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1)); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { listViewItemClick(position); } }); } if (widget.hasParameter("add_contact")) { HashMap<String, String> hm = new HashMap<>(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { hm.put("contactName", contacts.get(i).getDescription()); } break; case 1: { hm.put("contactNumber", contacts.get(i).getDescription()); } break; case 2: { hm.put("contactEmail", contacts.get(i).getDescription()); } break; case 3: { hm.put("contactSite", contacts.get(i).getDescription()); } break; } } addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm); } if (widget.hasParameter("send_sms")) { HashMap<String, String> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { sb.append(contacts.get(i).getDescription()); if (i < contacts.size() - 1) { sb.append(", "); } } hm.put("text", sb.toString()); addNativeFeature(NATIVE_FEATURES.SMS, null, hm); } if (widget.hasParameter("send_mail")) { HashMap<String, CharSequence> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { sb.append("Name: "); } break; case 1: { sb.append("Phone: "); } break; case 2: { sb.append("Email: "); } break; case 3: { sb.append("Site: "); } break; case 4: { sb.append("Address: "); } break; } sb.append(contacts.get(i).getDescription()); sb.append("<br/>"); } if (widget.isHaveAdvertisement()) { sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)"); } hm.put("text", sb.toString()); hm.put("subject", "Contacts"); addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm); } } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } }
From source file:ch.blinkenlights.android.vanilla.LibraryPagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { Bundle in = (Bundle) state; mPendingArtistLimiter = (Limiter) in.getSerializable("limiter_artists"); mPendingAlbArtLimiter = (Limiter) in.getSerializable("limiter_albumartists"); mPendingComposerLimiter = (Limiter) in.getSerializable("limiter_composer"); mPendingAlbumLimiter = (Limiter) in.getSerializable("limiter_albums"); mPendingSongLimiter = (Limiter) in.getSerializable("limiter_songs"); mPendingFileLimiter = (Limiter) in.getSerializable("limiter_files"); }
From source file:com.pukulab.puku0x.gscalendar.CalendarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_calendar); // ?/*from www . j ava 2s . c o m*/ mBackKeyTimer = new CountDownTimer(2000, 2000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { mBackKeyPressed = false; } }; // ? Bundle extras = getIntent().getExtras(); // ? if (mLoginUser == null) { mLoginUser = (UserData) extras.getSerializable(ARGS_LOGIN_USER); } // if (mDisplayedUser == null) { mDisplayedUser = (UserData) extras.getSerializable(ARGS_DISPLAYED_USER); } // ? if (mDisplayedDate == null) { mDisplayedDate = (Date) extras.getSerializable(ARGS_DISPLAYED_DATE); mLastDisplayedDate = mDisplayedDate; } // ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // ????????? if (mDisplayedUser.usid != null && !mDisplayedUser.usid.equals(mLoginUser.usid)) { actionBar.setDisplayHomeAsUpEnabled(true); } // actionBar.setTitle(mDisplayedUser.name); actionBar.setSubtitle(DateFormat.format(getString(R.string.date_year_month_day), mDisplayedDate)); } // Retrieve the CalendarView mCalendarView = (MultiCalendarView) findViewById(R.id.calendarView); mProgressBar = (ProgressBar) findViewById(R.id.pb_detail); //mScheduleLayout = (LinearLayout) findViewById(R.id.scheduleList); // ? mScheduleDataList = new ArrayList<>(); mDailyScheduleList = new ArrayList<>(); mDailyScheduleaListAdapter = new ScheduleDataAdapter(CalendarActivity.this, 0, mDailyScheduleList); mDailyScheduleListView = (ListView) findViewById(R.id.lv_schedule); mDailyScheduleListView.setAdapter(mDailyScheduleaListAdapter); mDailyScheduleListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ListView listView = (ListView) parent; Schedule schedule = (Schedule) listView.getItemAtPosition(position); // ??? mLastSchedule = new Schedule(schedule); // ?? Intent intent = DetailActivity.createIntent(CalendarActivity.this, mLoginUser, mDisplayedUser, schedule); int requestCode = DetailActivity.REQUEST_DETAIL; startActivityForResult(intent, requestCode); } }); // Set the first valid day final Calendar firstValidDay = Calendar.getInstance(); firstValidDay.add(Calendar.YEAR, -1); firstValidDay.set(Calendar.DAY_OF_MONTH, 1); firstValidDay.set(Calendar.HOUR_OF_DAY, 0); firstValidDay.set(Calendar.MINUTE, 0); firstValidDay.set(Calendar.SECOND, 0); firstValidDay.set(Calendar.MILLISECOND, 0); mCalendarView.setFirstValidDay(firstValidDay); // Set the last valid day final Calendar lastValidDay = Calendar.getInstance(); lastValidDay.add(Calendar.YEAR, 1); lastValidDay.set(Calendar.HOUR_OF_DAY, 0); lastValidDay.set(Calendar.MINUTE, 0); lastValidDay.set(Calendar.SECOND, 0); lastValidDay.set(Calendar.MILLISECOND, 0); mCalendarView.setLastValidDay(lastValidDay); // ~ mCalendarView.setFirstDayOfWeek(Calendar.SUNDAY); mCalendarView.setLastDayOfWeek(Calendar.SATURDAY); // Create adapter final CustomDayAdapter adapter = new CustomDayAdapter(); // Set listener and adapter mCalendarView.setOnDayClickListener(this); mCalendarView.getIndicator().setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { //System.out.println("position:" + position); final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis((mCalendarView.getFirstValidDay().getTimeInMillis())); cal.add(Calendar.MONTH, position); mStartDate = cal.getTime(); cal.add(Calendar.MONTH, 1); mEndDate = cal.getTime(); mViewPagerPosition = position; new DisplaySchedulesTask(CalendarActivity.this, mDisplayedUser, mDisplayedDate).execute(mStartDate, mEndDate); } @Override public void onPageScrollStateChanged(int state) { } }); mCalendarView.setDayAdapter(adapter); // ???????? mCalendarView.setViewPagerPosition(12); }
From source file:brazole.com.secondtask.TabFragmentRecyclerView.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View mRootView = inflater.inflate(R.layout.tab_fragment_recycler_view, container, false); mRootView.setTag(TAG);//from www . java2s . c o m mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recycler_view); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(getActivity()); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); mAdapter = new RecyclerViewAdapter(mIssueList); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); // fab show / hide final FloatingActionButton fab = (FloatingActionButton) mRootView.findViewById(R.id.fab); fab.attachToRecyclerView(mRecyclerView, new ScrollDirectionListener() { @Override public void onScrollDown() { fab.show(); } @Override public void onScrollUp() { fab.hide(); } }); // Get Clicked item value and open detail activity mRecyclerView.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Intent intent = new Intent(getActivity(), SavedProblemActivity.class); intent.putExtra("issueId", mIssueList.get(position).getId()); startActivity(intent); } })); return mRootView; }
From source file:edu.iit.cs442.team7.iitbazaar.fragments.RecyclerViewItemListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.recycler_view_list_frag, container, false); rootView.setTag(TAG);//w w w .ja v a 2 s.c o m // BEGIN_INCLUDE(initializeRecyclerView) mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); // LinearLayoutManager is used here, this will layout the elements in a similar fashion // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how // elements are laid out. mLayoutManager = new LinearLayoutManager(getActivity()); mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER; if (savedInstanceState != null) { // Restore saved layout manager type. mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER); } setRecyclerViewLayoutManager(mCurrentLayoutManagerType); //mAdapter = new ItemAdapter(parentActivity,mDataset); Cursor mCursor = IITBazaar.getDBController().getCurrentItems(); mCursor.moveToFirst(); mAdapter = new ItemAdapter(parentActivity, mCursor); // Set ItemAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); // END_INCLUDE(initializeRecyclerView) DBController controller = IITBazaar.getDBController(); parentActivity.registerDataChangeListeners(mAdapter); //this is an asynchronous callback controller.syncRemoteItems(parentActivity); return rootView; }
From source file:com.dmsl.anyplace.SelectBuildingActivity.java
/** Called when the activity is first created. */ @Override//from w w w. j ava 2 s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature((int) Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_select_building); // get the AnyplaceCache instance mAnyplaceCache = AnyplaceCache.getInstance(this); btnRefreshWorldBuildings = (Button) findViewById(R.id.btnWorldBuildingsRefresh); btnRefreshWorldBuildings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isBuildingsJobRunning) { Toast.makeText(getBaseContext(), "Another building request is in process...", Toast.LENGTH_SHORT).show(); return; } startBuildingsFetch(false, true); } }); btnRefreshNearmeBuildings = (Button) findViewById(R.id.btnNearmeBuildingsRefresh); btnRefreshNearmeBuildings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isBuildingsJobRunning) { Toast.makeText(getBaseContext(), "Another building request is in process...", Toast.LENGTH_SHORT).show(); return; } startBuildingsFetch(true, false); } }); spinnerFloors = (Spinner) findViewById(R.id.floors); spinnerFloors.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { selectedFloorIndex = pos; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinnerBuildings = (Spinner) findViewById(R.id.buildings); spinnerBuildings.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (isFloorsJobRunning) { Toast.makeText(getBaseContext(), "Another request is in process...", Toast.LENGTH_SHORT).show(); return; } mAnyplaceCache.setSelectedBuildingIndex(pos); BuildingModel build = mAnyplaceCache.getSelectedBuilding(); if (build != null && build.isFloorsLoaded()) { setFloorSpinner(build.getFloors()); try { spinnerFloors.setSelection(build.getSelectedFloorIndex()); } catch (IndexOutOfBoundsException ex) { } onFloorsLoaded(build.getFloors()); } else { startFloorFetch(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); btnRefreshFloors = (Button) findViewById(R.id.btnFloorsRefresh); btnRefreshFloors.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isFloorsJobRunning) { Toast.makeText(getBaseContext(), "Another floor request is in process...", Toast.LENGTH_SHORT) .show(); return; } try { startFloorFetch(); } catch (IndexOutOfBoundsException ex) { Toast.makeText(getBaseContext(), "Check again the building selected...", Toast.LENGTH_SHORT) .show(); } } }); Button done = (Button) findViewById(R.id.btnDone); done.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startFloorPlanTask(); } }); Bundle b = this.getIntent().getExtras(); if (b == null) { mode = Mode.NONE; lat = "0.0"; lon = "0.0"; } else { mode = (Mode) b.getSerializable("mode"); if (mode == null) mode = Mode.NONE; lat = b.getString("coordinates_lat"); if (lat == null) { lat = "0.0"; mode = Mode.NONE; btnRefreshNearmeBuildings.setEnabled(false); } lon = b.getString("coordinates_lon"); if (lon == null) { lon = "0.0"; mode = Mode.NONE; btnRefreshNearmeBuildings.setEnabled(false); } } // start automatically the buildings task if invisible mode if (mode != Mode.NONE) { floorSelectorDialog = new ProgressDialog(SelectBuildingActivity.this); floorSelectorDialog.setIndeterminate(true); floorSelectorDialog.setTitle("Detecting floor"); floorSelectorDialog.setMessage("Please be patient..."); floorSelectorDialog.setCancelable(true); floorSelectorDialog.setCanceledOnTouchOutside(false); floorSelector = new Algo1Server(getApplicationContext()); floorSelector.addListener((FloorSelector.FloorAnyplaceFloorListener) this); floorSelector.addListener((FloorSelector.ErrorAnyplaceFloorListener) this); isBuildingsLoadingFinished = false; isfloorSelectorJobFinished = false; floorSelector.Start(lat, lon); startBuildingsFetch(true, false); } else { List<BuildingModel> buildings = mAnyplaceCache.getSpinnerBuildings(); if (buildings.size() == 0) { startBuildingsFetch(false, false); } else { setBuildingSpinner(buildings); spinnerBuildings.setSelection(mAnyplaceCache.getSelectedBuildingIndex()); } } }
From source file:com.facebook.samples.rps.RpsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { wins = savedInstanceState.getInt(WIN_KEY); losses = savedInstanceState.getInt(LOSS_KEY); ties = savedInstanceState.getInt(TIE_KEY); computerChoice = savedInstanceState.getInt(COMPUTER_CHOICE_KEY); playerChoice = savedInstanceState.getInt(PLAYER_CHOICE_KEY); currentState = (RpsState) savedInstanceState.getSerializable(STATE_KEY); result = (RpsResult) savedInstanceState.getSerializable(RESULT_KEY); pendingPublish = savedInstanceState.getBoolean(PENDING_PUBLISH_KEY); shouldImplicitlyPublish = savedInstanceState.getBoolean(IMPLICIT_PUBLISH_KEY); }/*from ww w .ja va2s. c o m*/ }
From source file:com.esri.arcgisruntime.sample.stretchrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState/*from www . j a va2 s . c o m*/ * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle stretchParameters = getArguments(); if (stretchParameters != null) { mMin = stretchParameters.getInt("min"); mMax = stretchParameters.getInt("max"); mPercentClipMin = stretchParameters.getInt("percent_clip_min"); mPercentClipMax = stretchParameters.getInt("percent_clip_max"); mStdDevFactor = stretchParameters.getInt("std_dev_factor"); mStretchType = (MainActivity.StretchType) stretchParameters.getSerializable("stretch_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") final View dialogView = inflater.inflate(R.layout.stretch_dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.stretch_rendering_parameters); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mMin, mMax, mPercentClipMin, mPercentClipMax, mStdDevFactor, mStretchType); } }); // min max ui elements mMinTextView = (TextView) dialogView.findViewById(R.id.min_value_text_view); mMaxTextView = (TextView) dialogView.findViewById(R.id.max_value_text_view); mMinSeekBar = (SeekBar) dialogView.findViewById(R.id.min_seek_bar); mMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.max_seek_bar); mMinSeekBar.setMax(255); mMaxSeekBar.setMax(255); mCurrMinTextView = (TextView) dialogView.findViewById(R.id.curr_min_text_view); mCurrMaxTextView = (TextView) dialogView.findViewById(R.id.curr_max_text_view); updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // percent clip ui elements mPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.percent_clip_min_value_text_view); mPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.percent_clip_max_value_text_view); mPercentClipMinSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_min_seek_bar); mPercentClipMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_max_seek_bar); mPercentClipMinSeekBar.setMax(99); mPercentClipMaxSeekBar.setMax(99); mCurrPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_min_text_view); mCurrPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_max_text_view); updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); // standard deviation ui elements mStdDevTextView = (TextView) dialogView.findViewById(R.id.std_dev_text_view); mStdDevSeekBar = (SeekBar) dialogView.findViewById(R.id.std_dev_seek_bar); mStdDevSeekBar.setMax(3); mCurrStdDevTextView = (TextView) dialogView.findViewById(R.id.curr_std_dev_text_view); updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); // set ui to previous selection if (mStretchType == MainActivity.StretchType.MIN_MAX) { setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.PERCENT_CLIP) { setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.STANDARD_DEVIATION) { setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); } // seek bar listeners mMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMin = progress; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); // move max to march min if max goes below min if (mMax < mMin) { mMax = mMin; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMax = progress; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // move min to match max if min goes above max if (mMin > mMax) { mMin = mMax; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMin = progress; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMax = 100 - mPercentClipMin; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMax = progress; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMin = 100 - mPercentClipMax; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mStdDevSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mStdDevFactor = progress; updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // stretch type spinner List<String> stretchTypeArray = new ArrayList<>(); stretchTypeArray.add(MainActivity.StretchType.MIN_MAX.toString()); //ordinals:0 stretchTypeArray.add(MainActivity.StretchType.PERCENT_CLIP.toString()); //1 stretchTypeArray.add(MainActivity.StretchType.STANDARD_DEVIATION.toString()); //2 ArrayAdapter<String> stretchTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.stretch_spinner_text_view, stretchTypeArray); Spinner stretchTypeSpinner = (Spinner) dialogView.findViewById(R.id.stretch_type_spinner); stretchTypeSpinner.setAdapter(stretchTypeSpinnerAdapter); stretchTypeSpinner.setSelection(mStretchType.ordinal()); stretchTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mStretchType = MainActivity.StretchType.MIN_MAX; setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); break; case 1: mStretchType = MainActivity.StretchType.PERCENT_CLIP; setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); break; case 2: mStretchType = MainActivity.StretchType.STANDARD_DEVIATION; setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }