List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("level", mStackLevel); }
From source file:com.drisoftie.cwdroid.act.MainSwitchActivity.java
/** * Most actions are created here./*from www.j ava 2 s . c om*/ */ @SuppressWarnings("unchecked") private void initActions() { List<Fragment> frags = getSupportFragmentManager().getFragments(); if (actionUserLogin == null) { actionUserLogin = new ActionBuilder().with(txtUserName, imgUserIcon, btnLogin) .reg(View.OnClickListener.class, RegActionMethod.SET_ONCLICK) .reg(IGenericAction.class, RegActionMethod.NONE).reg(IResultHandler.class, RegActionMethod.NONE) .pack(new AndroidAction<View, AuthenticatedUser, Void, Void, Void>(null, null) { private DiagLogin diag; @Override public Object onActionPrepare(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { if (ActionMethod.INVOKE_ACTION.matches(methodName)) { Object[] args = stripMethodArgs(methodArgs); if (ArrayUtils.isEmpty(args)) { if (diag == null) { diag = new DiagLogin(); Bundle bundle = new Bundle(); bundle.putInt(getString(R.string.bundl_diag_layout), R.layout.diag_login); bundle.putInt(getString(R.string.bundl_diag_title), R.string.diag_travel_bags_add); if (CwApp.domain().hasUser()) { CwUser user = CwApp.domain().getLoggedInUser(); bundle.putString(getString(R.string.bundl_diag_input_name), user.getName()); bundle.putString(getString(R.string.bundl_diag_input_password), user.getPwHash()); } bundle.putInt(getString(R.string.bundl_diag_btn_positive), R.string.save); bundle.putInt(getString(R.string.bundl_diag_btn_negative), R.string.cancel); bundle.putBoolean(diag.getClass().getName(), true); diag.setArguments(bundle); diag.setResultHandler(actionUserLogin.getHandlerImpl(IResultHandler.class)); diag.show(getSupportFragmentManager(), diag.getClass().getName()); } } else { for (Object arg : args) { if (arg instanceof DiagLogin) { diag = (DiagLogin) arg; } } } skipWorkThreadOnce(); } else if (ActionMethod.ON_CLICK.matches(methodName)) { if (diag == null) { diag = new DiagLogin(); Bundle bundle = new Bundle(); bundle.putInt(getString(R.string.bundl_diag_layout), R.layout.diag_login); bundle.putInt(getString(R.string.bundl_diag_title), R.string.diag_login); if (CwApp.domain().hasUser()) { CwUser user = CwApp.domain().getLoggedInUser(); bundle.putString(getString(R.string.bundl_diag_input_name), user.getName()); bundle.putString(getString(R.string.bundl_diag_input_password), user.getPwHash()); } bundle.putInt(getString(R.string.bundl_diag_btn_positive), R.string.login); bundle.putInt(getString(R.string.bundl_diag_btn_negative), R.string.cancel); bundle.putBoolean(diag.getClass().getName(), true); diag.setArguments(bundle); diag.setResultHandler(actionUserLogin.getHandlerImpl(IResultHandler.class)); diag.show(getSupportFragmentManager(), diag.getClass().getName()); } skipWorkThreadOnce(); } return null; } @Override public AuthenticatedUser onActionDoWork(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { if (ActionMethod.ON_RESULT_READY.matches(methodName)) { postActionProgress(null, methodName, methodArgs); if (!ArrayUtils.isEmpty(methodArgs) && methodArgs[0] != null) { String[] inputs = (String[]) methodArgs[0]; AuthenticatedUser result = CwApi.authenticate(inputs[0], inputs[1], true); if (result != null) { switch (result.getSuccess()) { case YES: byte[] key = CredentialUtils.generateKeyBytes(); String obfPw = CredentialUtils.obfuscateToBase64(key, inputs[1]); String obfHash = CredentialUtils.obfuscateToBase64(key, result.getPasswordHash()); CwUser user; if (CwApp.domain().hasUser()) { user = CwApp.domain().getLoggedInUser(); } else { user = new CwUser(); } user.setName(inputs[0]); user.setPassword(obfPw); user.setPwHash(obfHash); user.setKeyData(key); user.setDate(GregorianCalendar.getInstance().getTime()); DomainHelper.createOrUpdate(CwUser.class, user); if (!CwApp.domain().hasUser()) { CwApp.domain().setLoggedInUser(user); } CwApp.domain().setLoggedIn(true); break; } } return result; } } return null; } @Override public void onActionProgress(String methodName, Void progress, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { progLoad.show(); } @Override public void onActionAfterWork(String methodName, Object[] methodArgs, AuthenticatedUser result, Void tag1, Void tag2, Object[] additionalTags) { if (ActionMethod.ON_RESULT_READY.matches(methodName)) { if (result != null) { switch (result.getSuccess()) { case YES: uiLoggedIn(result.getUsername(), result.getUid()); break; case NO: Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_login_failed), Toast.LENGTH_SHORT).show(); break; case BANNED: Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_login_banned), Toast.LENGTH_SHORT).show(); break; } } else if (!ArrayUtils.isEmpty(methodArgs) && methodArgs[0] != null) { Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_login_failed_extra), Toast.LENGTH_SHORT) .show(); } progLoad.hide(); } diag = null; } }); } else { actionUserLogin.replaceViewTargets(txtUserName, imgUserIcon, btnLogin); actionUserLogin.registerAction(); } actionCheckLogin = new ActionBuilder().with().reg(IGenericAction.class, RegActionMethod.NONE) .pack(new AndroidAction<View, AuthenticatedUser, CwUser, Void, Void>(null, null) { @Override public Object onActionPrepare(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { progLoad.setVisibility(View.VISIBLE); progLoad.show(); return null; } @Override public AuthenticatedUser onActionDoWork(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { AuthenticatedUser loginResult = null; CwUser user; if (CwApp.domain().hasValidUser()) { user = CwApp.domain().getLoggedInUser(); } else { user = DomainHelper.getFirst(CwUser.class); CwApp.domain().setLoggedInUser(user); } if (user != null) { String pw = CredentialUtils.deobfuscateFromBase64(user.getKeyData(), user.getPassword()); if (StringUtils.isNotEmpty(pw)) { loginResult = CwApi.authenticate(user.getName(), pw, true); if (loginResult != null) { switch (loginResult.getSuccess()) { case YES: CwApp.domain().setLoggedIn(true); break; case NO: case BANNED: CwApp.domain().setLoggedIn(false); break; } } } } return loginResult; } @Override public void onActionProgress(String methodName, CwUser progress, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { uiLoggedIn(progress.getName(), progress.getId()); } @Override public void onActionAfterWork(String methodName, Object[] methodArgs, AuthenticatedUser result, Void tag1, Void tag2, Object[] additionalTags) { if (result != null) { switch (result.getSuccess()) { case YES: uiLoggedIn(result.getUsername(), result.getUid()); break; case NO: Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_login_failed), Toast.LENGTH_SHORT).show(); uiLoggedOut(); break; case BANNED: Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_login_banned), Toast.LENGTH_SHORT).show(); uiLoggedOut(); break; } } else if (CwApp.domain().hasUser()) { Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_login_failed), Toast.LENGTH_SHORT).show(); uiLoggedOut(); } else { uiLoggedOut(); } progLoad.hide(); } }); actionLogout = new ActionBuilder().with(btnLogout) .reg(View.OnClickListener.class, RegActionMethod.SET_ONCLICK) .reg(IGenericAction.class, RegActionMethod.NONE) .pack(new AndroidAction<View, Void, Void, Void, Void>(null, null) { @Override public Object onActionPrepare(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { return null; } @Override public Void onActionDoWork(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { CwApp.domain().setLoggedIn(false); CwApp.domain().getLoggedInUser().resetCredentials(); DomainHelper.createOrUpdate(CwUser.class, CwApp.domain().getLoggedInUser()); return null; } @Override public void onActionAfterWork(String methodName, Object[] methodArgs, Void result, Void tag1, Void tag2, Object[] additionalTags) { uiLoggedOut(); Toast.makeText(MainSwitchActivity.this, getString(R.string.toast_logout), Toast.LENGTH_SHORT).show(); } }); actionNavigationClick = new ActionBuilder().with(listDrawer) .reg(AdapterView.OnItemClickListener.class, RegActionMethod.SET_ONITEMCLICKLISTENER) .pack(new AndroidAction<View, Void, Void, Void, Void>(null, null) { NavItemType currentType = NavItemType.NEWS; @Override public Object onActionPrepare(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { int pos = (Integer) methodArgs[2]; CwNavItem formerItem = CwApp.domain().getSelectedNavigation(); NavItemType type = listAdaptDrawer.getItem(pos).getNavType(); listDrawer.setItemChecked(pos, true); CwApp.domain().setSelectedNavigation(listAdaptDrawer.getItem(pos)); if (!type.equals(currentType)) { switch (type) { case NEWS: getSupportFragmentManager().beginTransaction() .replace(R.id.frag_space, new FragPagerNews()).commit(); break; case BLOGS: getSupportFragmentManager().beginTransaction() .replace(R.id.frag_space, new FragPagerBlogs()).commit(); break; case MESSAGES: getSupportFragmentManager().beginTransaction() .replace(R.id.frag_space, new FragPagerNews()).commit(); break; case BOARD: if (NavItemType.BOARD.equals(formerItem.getNavType()) || NavItemType.SHOUTBOX.equals(formerItem.getNavType())) { ((FragManagedPaging) getSupportFragmentManager() .findFragmentById(R.id.frag_space)).setPage(0); } else { Bundle args = new Bundle(); args.putInt(FragPagerWeb.class.getName(), 0); FragPagerWeb f = new FragPagerWeb(); f.setArguments(args); getSupportFragmentManager().beginTransaction().replace(R.id.frag_space, f) .commit(); } break; case SHOUTBOX: if (NavItemType.BOARD.equals(formerItem.getNavType()) || NavItemType.SHOUTBOX.equals(formerItem.getNavType())) { ((FragManagedPaging) getSupportFragmentManager() .findFragmentById(R.id.frag_space)).setPage(1); } else { Bundle args = new Bundle(); args.putInt(FragPagerWeb.class.getName(), 1); FragPagerWeb f = new FragPagerWeb(); f.setArguments(args); getSupportFragmentManager().beginTransaction().replace(R.id.frag_space, f) .commit(); } break; case SETTINGS: getSupportFragmentManager().beginTransaction() .replace(R.id.frag_space, new FragPagerNews()).commit(); break; } currentType = type; } drawer.closeDrawers(); skipWorkThreadOnce(); return null; } @Override public Void onActionDoWork(String methodName, Object[] methodArgs, Void tag1, Void tag2, Object[] additionalTags) { return null; } @Override public void onActionAfterWork(String methodName, Object[] methodArgs, Void result, Void tag1, Void tag2, Object[] additionalTags) { } }); if (frags != null) { for (Fragment fragment : frags) { if (fragment != null && fragment.getArguments() != null && fragment.getArguments().containsKey(DiagLogin.class.getName())) { actionUserLogin.invokeSelf(fragment); ((DiagLogin) fragment).setResultHandler(actionUserLogin.getHandlerImpl(IResultHandler.class)); } } } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelableArrayList(EXTRA_PENDING_ACTIONS, mPendingActions); outState.putString(EXTRA_SELECTED_FILE, mSelectedFile); outState.putString(EXTRA_SELECTED_ROM_ID, mSelectedRomId); outState.putString(EXTRA_ZIP_ROM_ID, mZipRomId); outState.putInt(EXTRA_TASK_ID_VERIFY_ZIP, mTaskIdVerifyZip); }
From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case MENU_FOLLOW: { if (mAccountId != mUserId) { if (mUserList.isFollowing()) { mService.destroyUserListSubscription(mAccountId, mUserList.getId()); } else { mService.createUserListSubscription(mAccountId, mUserList.getId()); }/*from ww w . j a v a2s. co m*/ } break; } case MENU_ADD: { final Bundle args = new Bundle(); args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); args.putString(INTENT_KEY_TEXT, ""); args.putInt(INTENT_KEY_LIST_ID, mUserList.getId()); mAddMemberDialogFragment.setArguments(args); mAddMemberDialogFragment.show(getFragmentManager(), "add_member"); break; } case MENU_ADD_TAB: { CustomTabsAdapter mAdapter; mAdapter = new CustomTabsAdapter(getActivity()); ContentResolver mResolver; mResolver = getContentResolver(); final String tabName = mListName; final String tabType = AUTHORITY_LIST_TIMELINE; final String tabIcon = "list"; final long account_id = mAccountId; final String tabScreenName = mUserScreenName; final String tabListName = mListName; final String tabArguments = "{\"account_id\":" + account_id + ",\"screen_name\":\"" + tabScreenName + "\",\"list_name\":" + JSONObject.quote(tabListName) + "}"; final ContentValues values = new ContentValues(); values.put(Tabs.ARGUMENTS, tabArguments); values.put(Tabs.NAME, tabName); values.put(Tabs.POSITION, mAdapter.getCount()); values.put(Tabs.TYPE, tabType); values.put(Tabs.ICON, tabIcon); mResolver.insert(Tabs.CONTENT_URI, values); Toast.makeText(this.getActivity(), R.string.list_tab_added, Toast.LENGTH_SHORT).show(); break; } case MENU_DELETE: { if (mUserId != mAccountId) return false; mService.destroyUserList(mAccountId, mUserListId); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_USER_LIST, new ParcelableUserList(mUserList, mAccountId)); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } } return true; }
From source file:com.hackensack.umc.activity.ProfileSelfiewithCropActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.proceed_btn: profileInsuranceInfoFragment = new ProfileInsuranceInfoFragment(); FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.fragmentIcContainer, profileInsuranceInfoFragment, "IsuranceFragment"); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();/*from w ww . j ava 2s . c om*/ break; case R.id.manual_btn: Intent intent = new Intent(ProfileSelfiewithCropActivity.this, RegistrationDetailsActivity.class); Bundle b = new Bundle(); b.putInt(Constant.REGISTRATION_MODE, Constant.MANUAL); intent.putExtra(Constant.BUNDLE, b); startActivity(intent); break; case R.id.selfie_img: selectedImageView = Constant.SELFIE; imageUri = dispatchTakePictureIntent(ProfileSelfiewithCropActivity.this, 1, Constant.SELFIE); break; } }
From source file:arc.noaa.weather.activities.MainActivity.java
private void updateLongTermWeatherUI() { if (destroyed) { return;//from w w w .j a v a 2 s . c o m } ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); Bundle bundleToday = new Bundle(); bundleToday.putInt("day", 0); RecyclerViewFragment recyclerViewFragmentToday = new RecyclerViewFragment(); recyclerViewFragmentToday.setArguments(bundleToday); viewPagerAdapter.addFragment(recyclerViewFragmentToday, getString(R.string.today)); Bundle bundleTomorrow = new Bundle(); bundleTomorrow.putInt("day", 1); RecyclerViewFragment recyclerViewFragmentTomorrow = new RecyclerViewFragment(); recyclerViewFragmentTomorrow.setArguments(bundleTomorrow); viewPagerAdapter.addFragment(recyclerViewFragmentTomorrow, getString(R.string.tomorrow)); Bundle bundle = new Bundle(); bundle.putInt("day", 2); RecyclerViewFragment recyclerViewFragment = new RecyclerViewFragment(); recyclerViewFragment.setArguments(bundle); viewPagerAdapter.addFragment(recyclerViewFragment, getString(R.string.later)); int currentPage = viewPager.getCurrentItem(); viewPagerAdapter.notifyDataSetChanged(); viewPager.setAdapter(viewPagerAdapter); tabLayout.setupWithViewPager(viewPager); if (currentPage == 0 && longTermTodayWeather.isEmpty()) { currentPage = 1; } viewPager.setCurrentItem(currentPage, false); }
From source file:com.hackensack.umc.activity.ProfileSelfieActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.proceed_btn: profileInsuranceInfoFragment = new ProfileInsuranceInfoFragment(); FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.fragmentIcContainer, profileInsuranceInfoFragment, "IsuranceFragment"); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();/*from w w w .j a v a 2s.com*/ break; case R.id.manual_btn: Intent intent = new Intent(ProfileSelfieActivity.this, RegistrationDetailsActivity.class); Bundle b = new Bundle(); b.putInt(Constant.REGISTRATION_MODE, Constant.MANUAL); intent.putExtra(Constant.BUNDLE, b); startActivity(intent); break; case R.id.selfie_img: if (!isMessageShown) { showAlert(ProfileSelfieActivity.this, getString(R.string.suggestion), getString(R.string.selfie_suggestion_message)); } else { selectedImageView = Constant.SELFIE; imageUri = CameraFunctionality.dispatchTakePictureIntent(ProfileSelfieActivity.this, 1, Constant.SELFIE); } break; } }
From source file:com.dsna.android.main.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(BUNDLE_SELECTEDFRAGMENT, mSelectedFragment); }
From source file:com.appfeel.cordova.admob.AdMobAds.java
@SuppressLint("DefaultLocale") private AdRequest buildAdRequest() { AdRequest.Builder request_builder = new AdRequest.Builder(); if (isTesting) { // This will request test ads on the emulator and deviceby passing this hashed device ID. String ANDROID_ID = Settings.Secure.getString(cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); String deviceId = md5(ANDROID_ID).toUpperCase(); request_builder = request_builder.addTestDevice(deviceId).addTestDevice(AdRequest.DEVICE_ID_EMULATOR); }/* w w w. jav a 2 s . c o m*/ Bundle bundle = new Bundle(); bundle.putInt("cordova", 1); if (adExtras != null) { Iterator<String> it = adExtras.keys(); while (it.hasNext()) { String key = it.next(); try { bundle.putString(key, adExtras.get(key).toString()); } catch (JSONException exception) { Log.w(ADMOBADS_LOGTAG, String.format("Caught JSON Exception: %s", exception.getMessage())); } } } AdMobExtras adextras = new AdMobExtras(bundle); request_builder = request_builder.addNetworkExtras(adextras); AdRequest request = request_builder.build(); return request; }
From source file:cw.kop.autobackground.sources.SourceInfoFragment.java
private void showAlbumFragment(String type, int position, ArrayList<String> names, ArrayList<String> images, ArrayList<String> links, ArrayList<String> nums, boolean use) { AlbumFragment albumFragment = new AlbumFragment(); Bundle arguments = new Bundle(); arguments.putString("type", type); arguments.putInt("position", position); arguments.putBoolean("use", use); arguments.putStringArrayList("album_names", names); arguments.putStringArrayList("album_images", images); arguments.putStringArrayList("album_links", links); arguments.putStringArrayList("album_nums", nums); albumFragment.setArguments(arguments); albumFragment.setTargetFragment(this, -1); FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager != null) { fragmentManager.beginTransaction().add(R.id.content_frame, albumFragment, "album_fragment") .addToBackStack(null).commit(); }/* www.ja v a 2 s . c om*/ }