List of usage examples for android.os Bundle putBoolean
public void putBoolean(@Nullable String key, boolean value)
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * Creates a new account through the Account Authenticator that started this * activity.// www . ja v a 2 s . c om * * This makes the account permanent. * * TODO Decide how to name the OAuth accounts */ private boolean createAccount() { // / create and save new ownCloud account boolean isOAuth = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType); boolean isSaml = AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType); Uri uri = Uri.parse(mHostBaseUrl); String username = mUsernameInput.getText().toString().trim(); username = username + "@" + location; if (isSaml) { username = getUserNameForSamlSso(); } else if (isOAuth) { username = "OAuth_user" + (new java.util.Random(System.currentTimeMillis())).nextLong(); } String accountName = username + "@" + uri.getHost(); if (uri.getPort() >= 0) { accountName += ":" + uri.getPort(); } mAccount = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE); if (AccountUtils.exists(mAccount, getApplicationContext())) { // fail - not a new account, but an existing one; disallow RemoteOperationResult result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_NEW); updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, result.getLogMessage()); return false; } else { if (isOAuth || isSaml) { mAccountMgr.addAccountExplicitly(mAccount, "", null); // with // external // authorizations, // the // password // is // never // input // in the // app } else { mAccountMgr.addAccountExplicitly(mAccount, mPasswordInput.getText().toString(), null); } // / add the new account as default in preferences, if there is none // already Account defaultAccount = AccountUtils.getCurrentOwnCloudAccount(this); if (defaultAccount == null) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putString("select_oc_account", accountName); editor.commit(); } // / prepare result to return to the Authenticator // TODO check again what the Authenticator makes with it; probably // has the same effect as addAccountExplicitly, but it's not well // done final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AccountAuthenticator.ACCOUNT_TYPE); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mAccount.name); /* * if (!isOAuth) intent.putExtra(AccountManager.KEY_AUTHTOKEN, * AccountAuthenticator.ACCOUNT_TYPE); */ intent.putExtra(AccountManager.KEY_USERDATA, username); if (isOAuth || isSaml) { mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken); } // / add user data to the new account; TODO probably can be done in // the last parameter addAccountExplicitly, or in KEY_USERDATA mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION, mDiscoveredVersion.toString()); mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL, mHostBaseUrl); if (isSaml) { mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); } else if (isOAuth) { mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2, "TRUE"); } setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); // / immediately request for the synchronization of the new account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(mAccount, AccountAuthenticator.AUTHORITY, bundle); syncAccount(); // Bundle bundle = new Bundle(); // bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); // ContentResolver.requestSync(mAccount, // AccountAuthenticator.AUTHORITY, bundle); return true; } }
From source file:com.android.dialer.DialtactsFragment.java
@Override public 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:com.drisoftie.cwdroid.act.MainSwitchActivity.java
/** * Most actions are created here.//from w w w .j ava2s .c o m */ @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:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * @param testPoint /*w ww .j a v a 2 s.co m*/ * @param mapType * */ public RMBTMapFragment showMap(String mapType, LatLng initialCenter, boolean clearFilter, int viewId, boolean popBackStack) { if (popBackStack) { popBackStackFull(); } FragmentTransaction ft; setCurrentMapType(mapType); if (clearFilter) { final List<MapListSection> mapFilterListSelectionList = getMapFilterListSelectionList(); if (mapFilterListSelectionList != null) { for (final MapListSection section : mapFilterListSelectionList) { for (final MapListEntry entry : section.getMapListEntryList()) entry.setChecked(entry.isDefault()); } updateMapFilter(); } } final RMBTMapFragment fragment = new RMBTMapFragment(); final Bundle bundle = new Bundle(); bundle.putParcelable("initialCenter", initialCenter); if (viewId >= 0) { bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_ALL_GESTURES, false); bundle.putBoolean(RMBTMapFragment.OPTION_SHOW_INFO_TOAST, false); bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_CONTROL_BUTTONS, false); bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_OVERLAY, false); fragment.setArguments(bundle); ft = fm.beginTransaction(); //replace the given viewgroup, but do not add to backstack ft.replace(viewId, fragment, AppConstants.PAGE_TITLE_MINI_MAP); //ft.addToBackStack(AppConstants.PAGE_TITLE_MINI_MAP); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); } else { System.out.println("SHOW MAP"); fragment.setArguments(bundle); ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_MAP); ft.addToBackStack(AppConstants.PAGE_TITLE_MAP); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_MAP); } return fragment; }
From source file:com.amaze.filemanager.fragments.Main.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); int index;/*from w w w. ja v a 2s .c om*/ View vi; if (listView != null) { if (IS_LIST) { index = (mLayoutManager).findFirstVisibleItemPosition(); vi = listView.getChildAt(0); } else { index = (mLayoutManagerGrid).findFirstVisibleItemPosition(); vi = listView.getChildAt(0); } int top = (vi == null) ? 0 : vi.getTop(); outState.putInt("index", index); outState.putInt("top", top); outState.putBoolean("IS_LIST", IS_LIST); outState.putParcelableArrayList("list", LIST_ELEMENTS); outState.putString("CURRENT_PATH", CURRENT_PATH); outState.putBoolean("selection", selection); outState.putInt("openMode", openMode); outState.putInt("folder_count", folder_count); outState.putInt("file_count", file_count); if (selection) { outState.putIntegerArrayList("position", adapter.getCheckedItemPositions()); } outState.putBoolean("results", results); outState.putParcelable("adapter", adapter); if (openMode == 1) { outState.putString("SmbPath", smbPath); } } }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ??/* w w w . j av a 2 s. co m*/ * * @param outState Bundle */ @Override protected void onSaveInstanceState(Bundle outState) { Field[] fields = this.getClass().getDeclaredFields(); Field.setAccessible(fields, true); Annotation[] ans; for (Field f : fields) { ans = f.getDeclaredAnnotations(); for (Annotation an : ans) { if (an instanceof SaveWithActivity) { try { Object o = f.get(this); if (o == null) { continue; } String fieldName = f.getName(); if (o instanceof Integer) { outState.putInt(fieldName, f.getInt(this)); } else if (o instanceof String) { outState.putString(fieldName, (String) f.get(this)); } else if (o instanceof Long) { outState.putLong(fieldName, f.getLong(this)); } else if (o instanceof Short) { outState.putShort(fieldName, f.getShort(this)); } else if (o instanceof Boolean) { outState.putBoolean(fieldName, f.getBoolean(this)); } else if (o instanceof Byte) { outState.putByte(fieldName, f.getByte(this)); } else if (o instanceof Character) { outState.putChar(fieldName, f.getChar(this)); } else if (o instanceof CharSequence) { outState.putCharSequence(fieldName, (CharSequence) f.get(this)); } else if (o instanceof Float) { outState.putFloat(fieldName, f.getFloat(this)); } else if (o instanceof Double) { outState.putDouble(fieldName, f.getDouble(this)); } else if (o instanceof String[]) { outState.putStringArray(fieldName, (String[]) f.get(this)); } else if (o instanceof Parcelable) { outState.putParcelable(fieldName, (Parcelable) f.get(this)); } else if (o instanceof Serializable) { outState.putSerializable(fieldName, (Serializable) f.get(this)); } else if (o instanceof Bundle) { outState.putBundle(fieldName, (Bundle) f.get(this)); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } super.onSaveInstanceState(outState); }
From source file:com.alibaba.android.layoutmanager.ExposeLinearLayoutManagerEx.java
@Override public Parcelable onSaveInstanceState() { if (mCurrentPendingSavedState != null) { return new Bundle(mCurrentPendingSavedState); }// w ww .j av a2s . c o m Bundle state = new Bundle(); if (getChildCount() > 0) { boolean didLayoutFromEnd = mLastStackFromEnd ^ mShouldReverseLayoutExpose; state.putBoolean("AnchorLayoutFromEnd", didLayoutFromEnd); if (didLayoutFromEnd) { final View refChild = getChildClosestToEndExpose(); state.putInt("AnchorOffset", mOrientationHelper.getEndAfterPadding() - mOrientationHelper.getDecoratedEnd(refChild)); state.putInt("AnchorPosition", getPosition(refChild)); } else { final View refChild = getChildClosestToStartExpose(); state.putInt("AnchorPosition", getPosition(refChild)); state.putInt("AnchorOffset", mOrientationHelper.getDecoratedStart(refChild) - mOrientationHelper.getStartAfterPadding()); } } else { state.putInt("AnchorPosition", RecyclerView.NO_POSITION); } return state; }
From source file:com.android.deskclock.AlarmClockFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(KEY_EXPANDED_ID, mAdapter.getExpandedId()); outState.putLongArray(KEY_REPEAT_CHECKED_IDS, mAdapter.getRepeatArray()); outState.putLongArray(KEY_SELECTED_ALARMS, mAdapter.getSelectedAlarmsArray()); outState.putBundle(KEY_RINGTONE_TITLE_CACHE, mRingtoneTitleCache); outState.putParcelable(KEY_DELETED_ALARM, mDeletedAlarm); outState.putBoolean(KEY_UNDO_SHOWING, mUndoShowing); outState.putBundle(KEY_PREVIOUS_DAY_MAP, mAdapter.getPreviousDaysOfWeekMap()); outState.putParcelable(KEY_SELECTED_ALARM, mSelectedAlarm); }
From source file:cl.ipp.katbag.fragment.Develop.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();/*from w ww . j a v a 2 s. c o m*/ inflater.inflate(R.menu.develop, menu); menuItemEdit = menu.findItem(R.id.develop_dropdown_menu_edit); menuItemAddWorld = menu.findItem(R.id.develop_dropdown_menu_add_world); menuItemAddDrawing = menu.findItem(R.id.develop_dropdown_menu_add_drawing); menuItemAddMotion = menu.findItem(R.id.develop_dropdown_menu_add_motion); menuItemAddLook = menu.findItem(R.id.develop_dropdown_menu_add_look); menuItemAddSound = menu.findItem(R.id.develop_dropdown_menu_add_sound); menuItemAddControl = menu.findItem(R.id.develop_dropdown_menu_add_control); menuItemAddSensing = menu.findItem(R.id.develop_dropdown_menu_add_sensing); menuItemPlayer = menu.findItem(R.id.develop_dropdown_menu_player); menuItemEdit.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (editMode) { editMode = false; menuItemEdit.setIcon(R.drawable.ic_action_edit); } else { editMode = true; menuItemEdit.setIcon(R.drawable.ic_action_accept); } loadListView(); return true; } }); menuItemAddWorld.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_WORLD, -1); return true; } }); menuItemAddDrawing.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_DRAWING, -1); return true; } }); menuItemAddMotion.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_MOTION, -1); return true; } }); menuItemAddLook.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_LOOK, -1); return true; } }); menuItemAddSound.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_SOUND, -1); return true; } }); menuItemAddControl.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_CONTROL, -1); return true; } }); menuItemAddSensing.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showAlertDialog(OBJECT_SENSING, -1); return true; } }); menuItemPlayer.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mFragment = new Player(); Bundle bundle = new Bundle(); bundle.putLong("id_app", id_app); bundle.putBoolean("editMode", true); bundle.putString("name_app", Add.name_app_text); mFragment.setArguments(bundle); FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction(); t.replace(R.id.fragment_main_container, mFragment); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.addToBackStack(mFragment.getClass().getSimpleName()); t.commit(); return true; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:cz.muni.fi.japanesedictionary.entity.Translation.java
/** * Adds Translation to given bundle.// www . j a v a 2 s.com * * @param bundle - bundle in which translation should be saved * - in case of null empty bundle is created * @return Bundle returns bundle which contains Translation */ public Bundle createBundleFromTranslation(Bundle bundle) { if (bundle == null) { bundle = new Bundle(); } if (this.getJapaneseKeb() != null && this.getJapaneseKeb().size() > 0) { bundle.putString(SAVE_JAPANESE_KEB, (new JSONArray(this.getJapaneseKeb())).toString()); } if (this.getJapaneseReb() != null && this.getJapaneseReb().size() > 0) { bundle.putString(SAVE_JAPANESE_REB, (new JSONArray(this.getJapaneseReb())).toString()); } if (this.getDutchSense() != null && this.getDutchSense().size() > 0) { JSONArray sense = convertToJSON(this.getDutchSense()); bundle.putString(SAVE_DUTCH, sense.toString()); } if (this.getEnglishSense() != null && this.getEnglishSense().size() > 0) { JSONArray sense = convertToJSON(this.getEnglishSense()); bundle.putString(SAVE_ENGLISH, sense.toString()); } if (this.getFrenchSense() != null && this.getFrenchSense().size() > 0) { JSONArray sense = convertToJSON(this.getFrenchSense()); bundle.putString(SAVE_FRENCH, sense.toString()); } if (this.getGermanSense() != null && this.getGermanSense().size() > 0) { JSONArray sense = convertToJSON(this.getGermanSense()); bundle.putString(SAVE_GERMAN, sense.toString()); } if (this.getRussianSense() != null && this.getRussianSense().size() > 0) { JSONArray sense = convertToJSON(this.getRussianSense()); bundle.putString(SAVE_RUSSIAN, sense.toString()); } bundle.putBoolean(SAVE_PRIORITIZED, mPrioritized); bundle.putString(SAVE_RUBY, mRuby); return bundle; }