List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:com.skubit.android.billing.BillingServiceBinder.java
@Override public Bundle getBuyIntent(int apiVersion, String userId, String packageName, String sku, String type, String developerPayload) throws RemoteException { Bundle bundle = new Bundle(); if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(sku) || TextUtils.isEmpty(type)) { Log.d(TAG, "Missing required parameter"); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR); return bundle; }/*from www.j a v a 2 s. c om*/ if (apiVersion != 1) { Log.d(TAG, "Unsupported API: " + apiVersion); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE); return bundle; } if (!isValidType(type)) { Log.d(TAG, "Incorrect billing type: " + type); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE); return bundle; } int packValidate = validatePackageIsOwnedByCaller(packageName); if (packValidate != BillingResponseCodes.RESULT_OK) { Log.d(TAG, "Package is not owned by caller"); bundle.putInt("RESPONSE_CODE", packValidate); return bundle; } if (!hasAccess(userId, packageName)) { Log.d(TAG, "User account not configured"); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_USER_ACCESS); return bundle; } /** * DO we already own this product? method: userId, packageName, * productId bundle.putInt("RESPONSE_CODE", * BillingResponseCodes.RESULT_ITEM_ALREADY_OWNED) */ Intent purchaseIntent = null; if ("inapp".equals(type)) { purchaseIntent = makePurchaseIntent(apiVersion, userId, packageName, sku, developerPayload, type); } if (purchaseIntent == null) { bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR); return bundle; } Utils.changeAccount(mContext, userId); PendingIntent pending = PendingIntent.getActivity(mContext, (sku + userId).hashCode(), purchaseIntent, 0); bundle.putParcelable("BUY_INTENT", pending); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_OK); return bundle; }
From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { savedInstanceState.putInt("sched_year", mData.sched_time.get(Calendar.YEAR)); savedInstanceState.putInt("sched_month", mData.sched_time.get(Calendar.MONTH)); savedInstanceState.putInt("sched_day", mData.sched_time.get(Calendar.DAY_OF_MONTH)); savedInstanceState.putInt("sched_hour", mData.sched_time.get(Calendar.HOUR_OF_DAY)); savedInstanceState.putInt("sched_minute", mData.sched_time.get(Calendar.MINUTE)); savedInstanceState.putInt("depart_year", mData.depart_time.get(Calendar.YEAR)); savedInstanceState.putInt("depart_month", mData.depart_time.get(Calendar.MONTH)); savedInstanceState.putInt("depart_day", mData.depart_time.get(Calendar.DAY_OF_MONTH)); savedInstanceState.putInt("depart_hour", mData.depart_time.get(Calendar.HOUR_OF_DAY)); savedInstanceState.putInt("depart_minute", mData.depart_time.get(Calendar.MINUTE)); savedInstanceState.putInt("arrival_year", mData.arrival_time.get(Calendar.YEAR)); savedInstanceState.putInt("arrival_month", mData.arrival_time.get(Calendar.MONTH)); savedInstanceState.putInt("arrival_day", mData.arrival_time.get(Calendar.DAY_OF_MONTH)); savedInstanceState.putInt("arrival_hour", mData.arrival_time.get(Calendar.HOUR_OF_DAY)); savedInstanceState.putInt("arrival_minute", mData.arrival_time.get(Calendar.MINUTE)); super.onSaveInstanceState(savedInstanceState); }
From source file:de.sourcestream.movieDB.controller.MovieList.java
/** * Called to ask the fragment to save its current dynamic state, * so it can later be reconstructed in a new instance of its process is restarted. * * @param outState Bundle in which to place your saved state. *///from www . j ava2 s . c o m @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Used to avoid bug where we add item in the back stack // and if we change orientation twice the item from the back stack has null values if (save != null) outState.putBundle("save", save); else { Bundle send = new Bundle(); send.putInt("checkLoadMore", checkLoadMore); send.putInt("totalPages", totalPages); send.putString("currentListURL", getCurrentList()); send.putString("title", getTitle()); send.putBoolean("isLoading", isLoading); send.putInt("lastVisitedMovie", lastVisitedMovie); if (backState == 1) { send.putInt("backState", 1); send.putParcelableArrayList("listData", moviesList); // used to restore the scroll listener variables send.putInt("currentPage", endlessScrollListener.getCurrentPage()); send.putInt("oldCount", endlessScrollListener.getOldCount()); send.putBoolean("loading", endlessScrollListener.getLoading()); // Save scroll position if (listView != null) { Parcelable listState = listView.onSaveInstanceState(); send.putParcelable("listViewScroll", listState); } } else send.putInt("backState", 0); outState.putBundle("save", send); } }
From source file:com.openerp.MainActivity.java
protected void onSaveInstanceState(Bundle outState) { outState.putInt("current_drawer_item", mDrawerItemSelectedPosition); super.onSaveInstanceState(outState); }
From source file:com.irccloud.android.activity.UploadsActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("cid", cid); outState.putString("to", to); outState.putString("msg", msg); outState.putInt("page", page); adapter.saveInstanceState(outState); }
From source file:gov.sfmta.sfpark.MainScreenActivity.java
@Override public void onSaveInstanceState(Bundle outState) { // Serialize the current dropdown position. outState.putInt(STATE_SELECTED_NAVIGATION_ITEM, getSupportActionBar().getSelectedNavigationIndex()); }
From source file:com.github.yuukis.businessmap.app.ContactsTaskFragment.java
private void showProgress() { String title = getString(R.string.title_geocoding); String message = getString(R.string.message_geocoding); int max = mGeocodingResultCache.size(); Bundle args = new Bundle(); args.putString(ProgressDialogFragment.TITLE, title); args.putString(ProgressDialogFragment.MESSAGE, message); args.putBoolean(ProgressDialogFragment.CANCELABLE, true); args.putInt(ProgressDialogFragment.MAX, max); final DialogFragment dialog = ProgressDialogFragment.newInstance(); dialog.setArguments(args);// w w w. ja v a 2s. c o m if (getActivity() != null) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { dialog.show(getActivity().getSupportFragmentManager(), ProgressDialogFragment.TAG); } }); } }
From source file:app.sunstreak.yourpisd.ClassSwipeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_class_swipe); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);/*from www. j a v a2 s . c o m*/ } ProgressBar spinner = new ProgressBar(this); spinner.setIndeterminate(true); spinner.setId(R.id.action_bar_spinner); spinner.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); toolbar.addView(spinner); receivedClassIndex = getIntent().getExtras().getInt("classIndex"); classCount = getIntent().getExtras().getInt("classCount"); termIndex = getIntent().getExtras().getInt("termIndex"); studentIndex = getIntent().getExtras().getInt("studentIndex"); setTitle(TermFinder.Term.values()[termIndex].name); session = ((YPApplication) getApplication()).session; session.studentIndex = studentIndex; student = session.getCurrentStudent(); classesForTerm = student.getClassesForTerm(termIndex); System.out.println(classesForTerm); mFragments = new ArrayList<Fragment>(); for (int i = 0; i < classesForTerm.size(); i++) { Bundle args = new Bundle(); args.putInt(DescriptionFragment.ARG_SECTION_NUMBER, i); Fragment fragment = new DescriptionFragment(); fragment.setArguments(args); mFragments.add(fragment); } // Create the adapter that will return a fragment for each of the // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), mFragments); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // final ActionBar actionBar = getActionBar(); // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); /* for(int i = 0; i< classCount; i++) { actionBar.addTab(actionBar.newTab() .setText(session.getCurrentStudent() .getClassName(session.getCurrentStudent().getClassMatch()[i])) .setTabListener(this)); } */ // for (int classIndex : classesForTerm) // actionBar.addTab(actionBar.newTab().setText(student.getClassName(student.getClassMatch()[classIndex])) // .setTabListener(this)); ArrayList<String> temp = new ArrayList<>(); for (int classIndex : classesForTerm) { temp.add(student.getClassName(student.getClassMatch()[classIndex])); } setUpMaterialTabs(temp); // mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { // // @Override // public void onPageSelected(int position) { // // on changing the page // // make respected tab selected // actionBar.setSelectedNavigationItem(position); // } // // @Override // public void onPageScrolled(int arg0, float arg1, int arg2) { // } // // @Override // public void onPageScrollStateChanged(int arg0) { // } // }); // System.out.println("received class index = " + receivedClassIndex); if (receivedClassIndex > 0 && receivedClassIndex < classesForTerm.size()) mViewPager.setCurrentItem(receivedClassIndex); // otherwise, current item is defaulted to 0 // mViewPager.setOffscreenPageLimit(5); }
From source file:de.sourcestream.movieDB.controller.MovieList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *///from ww w.j a v a2s . c om @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { activity.setLastVisitedSimMovie(0); activity.resetMovieDetailsBundle(); activity.setRestoreMovieDetailsAdapterState(true); activity.setRestoreMovieDetailsState(false); activity.setOrientationChanged(false); activity.resetCastDetailsBundle(); if (movieDetails != null && lastVisitedMovie == moviesList.get(position).getId() && movieDetails.getTimeOut() == 0) { // Old movie details retrieve info and re-init component else crash movieDetails.onSaveInstanceState(new Bundle()); Bundle bundle = new Bundle(); bundle.putInt("id", moviesList.get(position).getId()); Bundle save = movieDetails.getSave(); movieDetails = new MovieDetails(); movieDetails.setTimeOut(0); movieDetails.setSave(save); movieDetails.setArguments(bundle); } else movieDetails = new MovieDetails(); lastVisitedMovie = moviesList.get(position).getId(); movieDetails.setTitle(moviesList.get(position).getTitle()); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle bundle = new Bundle(); bundle.putInt("id", moviesList.get(position).getId()); movieDetails.setArguments(bundle); transaction.replace(R.id.frame_container, movieDetails); // add the current transaction to the back stack: transaction.addToBackStack("movieList"); transaction.commit(); fragmentActive = true; activity.getMovieSlideTab().showInstantToolbar(); /* ValueAnimator anim = ValueAnimator.ofFloat(0, 1); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float slideOffset = (Float) valueAnimator.getAnimatedValue(); activity.getmDrawerToggle().onDrawerSlide(activity.getmDrawerLayout(), slideOffset); } }); anim.setInterpolator(new DecelerateInterpolator()); // You can change this duration to more closely match that of the default animation. anim.setDuration(700); anim.start();*/ }
From source file:com.nextgis.firereporter.ScanexHttpLogin.java
@Override protected Void doInBackground(String... urls) { if (HttpGetter.IsNetworkAvailible(mContext)) { String sUser = urls[0];/* w w w . j av a 2s .c o m*/ String sPass = urls[1]; try { // Create a new HttpClient HttpClient httpclient = new DefaultHttpClient(); // step 1. open login dialog String sRedirect = "http://fires.kosmosnimki.ru/SAPI/oAuthCallback.html&authServer=MyKosmosnimki"; String sURL = "http://fires.kosmosnimki.ru/SAPI/LoginDialog.ashx?redirect_uri=" + Uri.encode(sRedirect); HttpGet httpget = new HttpGet(sURL); HttpParams params = httpget.getParams(); params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); httpget.setParams(params); HttpResponse response = httpclient.execute(httpget); //2 get cookie and params Header head = response.getFirstHeader("Set-Cookie"); String sCookie = head.getValue(); head = response.getFirstHeader("Location"); String sLoc = head.getValue(); Uri uri = Uri.parse(sLoc); String sClientId = uri.getQueryParameter("client_id"); String sScope = uri.getQueryParameter("scope"); String sState = uri.getQueryParameter("state"); String sPostUri = "http://my.kosmosnimki.ru/Account/LoginDialog?redirect_uri=" + Uri.encode(sRedirect) + "&client_id=" + sClientId + "&scope=" + sScope + "&state=" + sState; HttpPost httppost = new HttpPost(sPostUri); params = httppost.getParams(); params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); httppost.setHeader("Cookie", sCookie); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("email", sUser)); nameValuePairs.add(new BasicNameValuePair("password", sPass)); nameValuePairs.add(new BasicNameValuePair("IsApproved", "true")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); response = httpclient.execute(httppost); head = response.getFirstHeader("Set-Cookie"); if (head == null) { mError = mContext.getString(R.string.noNetwork); return null; } sCookie += "; " + head.getValue(); head = response.getFirstHeader("Location"); sLoc = head.getValue(); uri = Uri.parse(sLoc); String sCode = uri.getQueryParameter("code"); sState = uri.getQueryParameter("state"); //3 get String sGetUri = "http://fires.kosmosnimki.ru/SAPI/Account/logon/?authServer=MyKosmosnimki&code=" + sCode + "&state=" + sState; httpget = new HttpGet(sGetUri); httpget.setHeader("Cookie", sCookie); params = httpget.getParams(); params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); httpget.setParams(params); response = httpclient.execute(httpget); head = response.getFirstHeader("Set-Cookie"); if (head == null) { mError = mContext.getString(R.string.noNetwork); return null; } sCookie += "; " + head.getValue(); Bundle bundle = new Bundle(); if (sCookie.length() > 0) { //if(bGetCookie){ bundle.putBoolean(GetFiresService.ERROR, false); bundle.putString(GetFiresService.JSON, sCookie); //bundle.putString("json", mContent); } else { bundle.putBoolean(GetFiresService.ERROR, true); } bundle.putInt(GetFiresService.SOURCE, mnType); Message msg = new Message(); msg.setData(bundle); if (mEventReceiver != null) { mEventReceiver.sendMessage(msg); } } catch (ClientProtocolException e) { mError = e.getMessage(); return null; } catch (IOException e) { mError = e.getMessage(); return null; } catch (Exception e) { mError = e.getMessage(); return null; } } else { Bundle bundle = new Bundle(); bundle.putBoolean(GetFiresService.ERROR, true); bundle.putString(GetFiresService.ERR_MSG, mContext.getString(R.string.noNetwork)); bundle.putInt(GetFiresService.SOURCE, mnType); Message msg = new Message(); msg.setData(bundle); if (mEventReceiver != null) { mEventReceiver.sendMessage(msg); } } return null; }