List of usage examples for android.os Bundle getBundle
@Nullable
public Bundle getBundle(@Nullable String key)
From source file:android.support.v7.media.RemotePlaybackClient.java
private void performSessionAction(final Intent intent, final String sessionId, Bundle extras, final SessionActionCallback callback) { intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); if (sessionId != null) { intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sessionId); }//from ww w . j a v a2 s .c o m if (extras != null) { intent.putExtras(extras); } logRequest(intent); mRoute.sendControlRequest(intent, new MediaRouter.ControlRequestCallback() { @Override public void onResult(Bundle data) { if (data != null) { String sessionIdResult = inferMissingResult(sessionId, data.getString(MediaControlIntent.EXTRA_SESSION_ID)); MediaSessionStatus sessionStatus = MediaSessionStatus .fromBundle(data.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); adoptSession(sessionIdResult); if (sessionIdResult != null) { if (DEBUG) { Log.d(TAG, "Received result from " + intent.getAction() + ": data=" + bundleToString(data) + ", sessionId=" + sessionIdResult + ", sessionStatus=" + sessionStatus); } try { callback.onResult(data, sessionIdResult, sessionStatus); } finally { if (intent.getAction().equals(MediaControlIntent.ACTION_END_SESSION) && sessionIdResult.equals(mSessionId)) { setSessionId(null); } } return; } } handleInvalidResult(intent, callback, data); } @Override public void onError(String error, Bundle data) { handleError(intent, callback, error, data); } }); }
From source file:org.mariotaku.twidere.fragment.DirectMessagesConversationFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mApplication = getApplication();/*from ww w.j a v a 2s .co m*/ mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mTwitterWrapper = getTwitterWrapper(); final LazyImageLoader imageloader = mApplication.getProfileImageLoader(); mAdapter = new DirectMessagesConversationAdapter(getActivity(), imageloader); setListAdapter(mAdapter); mListView = getListView(); mListView.setFastScrollEnabled(mPreferences.getBoolean(PREFERENCE_KEY_FAST_SCROLL_THUMB, false)); mListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); mListView.setStackFromBottom(true); mListView.setOnItemClickListener(this); mListView.setOnItemLongClickListener(this); final Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState.getBundle(INTENT_KEY_DATA); if (args != null) { mArguments.putAll(args); } setListShownNoAnimation(false); getLoaderManager().initLoader(0, mArguments, this); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); final String text = savedInstanceState != null ? savedInstanceState.getString(INTENT_KEY_TEXT) : null; if (text != null) { mEditText.setText(text); } mAccountsAdapter = new AccountsAdapter(getActivity()); mAccountSelector.setAdapter(mAccountsAdapter); mAccountSelector.setOnItemSelectedListener(this); mUserAutoCompleteAdapter = new AutoCompleteAdapter(getActivity()); mEditScreenName.addTextChangedListener(mScreenNameTextWatcher); mEditScreenName.setAdapter(mUserAutoCompleteAdapter); mSendButton.setOnClickListener(this); mSendButton.setEnabled(false); mScreenNameConfirmButton.setOnClickListener(this); mScreenNameConfirmButton.setEnabled(false); updateTextCount(); }
From source file:com.android.mail.ui.ConversationListFragment.java
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); // Initialize fragment constants from resources final Resources res = getResources(); TIMESTAMP_UPDATE_INTERVAL = res.getInteger(R.integer.timestamp_update_interval); LOADING_DELAY_MS = res.getInteger(R.integer.conversationview_show_loading_delay); MINIMUM_LOADING_DURATION = res.getInteger(R.integer.conversationview_min_show_loading); mUpdateTimestampsRunnable = new Runnable() { @Override//from w ww . ja v a2s . co m public void run() { mListView.invalidateViews(); mHandler.postDelayed(mUpdateTimestampsRunnable, TIMESTAMP_UPDATE_INTERVAL); } }; // Get the context from the arguments final Bundle args = getArguments(); mViewContext = ConversationListContext.forBundle(args.getBundle(CONVERSATION_LIST_KEY)); mAccount = mViewContext.account; setRetainInstance(false); }
From source file:com.near.chimerarevo.activities.PostContainerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true;/*from ww w.ja va 2 s .c o m*/ } else isLandscapeLarge = false; getToolbar().setNavigationIcon(getResources().getDrawable(R.drawable.ic_action_arrow_back)); getToolbar().setNavigationOnClickListener(this); if (!isLandscapeLarge) { pager = (ViewPager) findViewById(R.id.view_pager); pager.setOnPageChangeListener(this); } mLoading = (ProgressWheel) findViewById(R.id.post_progress); mShadow = findViewById(R.id.drop_shadow); args = getIntent().getExtras(); if (savedInstanceState != null) args = savedInstanceState.getBundle("arguments"); if (args.containsKey(Constants.KEY_DATE)) setToolbarStatusColor(args.getString(Constants.KEY_DATE).split("[\\x7C]")[1].trim()); if (getIntent().getData() != null) { List<String> params = getIntent().getData().getPathSegments(); if (params != null && params.size() > 0) { String ext_url = Constants.SITE_URL; for (String p : params) { ext_url += p + "/"; } if (ext_url.contains("/" + Constants.PRODOTTI + "/")) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(ext_url)); startActivity(i); finish(); } else { if (ext_url.contains("/" + Constants.RECENSIONI + "/")) args.putString(Constants.KEY_TYPE, Constants.RECENSIONI); else if (ext_url.contains("/" + Constants.VIDEO + "/")) args.putString(Constants.KEY_TYPE, Constants.VIDEO); OkHttpUtils.getInstance().newCall( new Request.Builder().url(URLUtils.getPostUrl(ext_url)).tag(ACTIVITY_TAG).build()) .enqueue(new GetPostCallback()); } } } if (args != null) { if (!args.containsKey("isLandscapeLarge")) args.putBoolean("isLandscapeLarge", isLandscapeLarge); if (args.containsKey(Constants.KEY_ID)) { int post_id = args.getInt(Constants.KEY_ID); OkHttpUtils.getInstance() .newCall(new Request.Builder().url(URLUtils.getPostUrl(post_id)).tag(ACTIVITY_TAG).build()) .enqueue(new GetPostCallback()); } else if (args.containsKey(Constants.KEY_URL)) { String post_url = args.getString(Constants.KEY_URL); OkHttpUtils.getInstance() .newCall(new Request.Builder().url(URLUtils.getPostUrl(post_url)).tag(ACTIVITY_TAG).build()) .enqueue(new GetPostCallback()); } } }
From source file:org.alfresco.mobile.android.application.activity.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); super.onCreate(savedInstanceState); // Loading progress requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.app_main);/*from ww w. j a v a 2 s . c o m*/ mdmManager = MDMManager.getInstance(this); if (capture != null) capture.setActivity(this); if (savedInstanceState != null) { MainActivityHelper helper = new MainActivityHelper( savedInstanceState.getBundle(MainActivityHelper.TAG)); currentAccount = helper.getCurrentAccount(); importParent = helper.getFolder(); fragmentQueue = helper.getFragmentQueue(); if (helper.getDeviceCapture() != null) { capture = helper.getDeviceCapture(); capture.setActivity(this); } } else { MainMenuFragment.with(this).display(); } // After account creation via welcome screen if (currentAccount != null) { requestSwapAccount = true; if (currentAccount.getIsPaidAccount() && !prefs.getBoolean(GeneralPreferences.HAS_ACCESSED_PAID_SERVICES, false)) { if (!mdmManager.hasConfig()) { // Check if we've prompted the user for Data Protection yet. // This is needed on new AlfrescoAccount creation, as the // Activity gets // re-created after the AlfrescoAccount is created. DataProtectionUserDialogFragment.newInstance(true).show(getFragmentManager(), DataProtectionUserDialogFragment.TAG); prefs.edit().putBoolean(GeneralPreferences.HAS_ACCESSED_PAID_SERVICES, true).commit(); } } } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (ViewGroup) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open_in, R.string.cancel) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { MainMenuFragment slidefragment = (MainMenuFragment) getFragment(MainMenuFragment.SLIDING_TAG); if (slidefragment != null) { slidefragment.refreshData(); } super.onDrawerOpened(drawerView); invalidateOptionsMenu(); } }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); if (AndroidVersion.isICSOrAbove()) { getActionBar().setHomeButtonEnabled(true); } }
From source file:li.barter.fragments.ChatDetailsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { init(container, savedInstanceState); setHasOptionsMenu(true);/* www. ja v a 2 s . c om*/ setActionBarTitle(R.string.app_name); mAvatarBitmapTransformation = new AvatarBitmapTransformation(AvatarBitmapTransformation.AvatarSize.AB_CHAT); final View view = inflater.inflate(R.layout.fragment_chat_details, container, false); mFormatter = new SimpleDateFormat(AppConstants.TIMESTAMP_FORMAT, Locale.getDefault()); mChatListView = (ListView) view.findViewById(R.id.list_chats); mChatDetailAdapter = new ChatDetailAdapter(getActivity(), null); mChatListView.setAdapter(mChatDetailAdapter); mChatListView.setOnItemClickListener(this); mSubmitChatEditText = (EditText) view.findViewById(R.id.edit_text_chat_message); mSubmitChatButton = (ImageButton) view.findViewById(R.id.button_send); mSubmitChatButton.setOnClickListener(this); if (savedInstanceState == null) { preloadMessage(); mUserInfo = getArguments(); } else { mUserInfo = savedInstanceState.getBundle(Keys.USER_INFO); } if (getArguments() != null) { mFinishOnBack = getArguments().getBoolean(Keys.FINISH_ON_BACK); } loadChatMessages(); return view; }
From source file:li.barter.fragments.BookDetailFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { init(container, savedInstanceState); setActionBarTitle(R.string.Book_Detail_fragment_title); final View view = inflater.inflate(R.layout.fragment_book_detail, container, false); view.setVerticalScrollBarEnabled(false); initViews(view);/* w ww. j a va 2s . com*/ getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); mDeleteBookDialogFragment = (AlertDialogFragment) getFragmentManager() .findFragmentByTag(FragmentTags.DIALOG_DELETE_BOOK); final AbstractBarterLiFragment fragment = ((AbstractBarterLiActivity) getActivity()) .getCurrentMasterFragment(); if (fragment != null && fragment instanceof BooksPagerFragment) { mLoadedIndividually = false; } else { mLoadedIndividually = true; } if (savedInstanceState == null) { mBookDetails = getArguments(); } else { mBookDetails = savedInstanceState.getBundle(Keys.BOOK_DETAILS); } setHasOptionsMenu(mLoadedIndividually); loadBookDetails(); return view; }
From source file:org.namelessrom.devicecontrol.modules.wizard.AddTaskActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wizard_activity); // setup action bar final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* w ww . j av a 2 s.c om*/ // setup material menu icon final MaterialMenuIconToolbar materialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, MaterialMenuDrawable.Stroke.THIN) { @Override public int getToolbarViewId() { return R.id.toolbar; } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { materialMenu.setNeverDrawTouch(true); } materialMenu.animateState(MaterialMenuDrawable.IconState.ARROW); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); mSetupData = (AbstractSetupData) getLastNonConfigurationInstance(); if (mSetupData == null) { mSetupData = new TaskerSetupWizardData(this); } if (savedInstanceState != null) { mSetupData.load(savedInstanceState.getBundle("data")); } final TaskerItem item = (TaskerItem) getIntent().getSerializableExtra(ARG_ITEM); Logger.v(this, "TaskerItem: %s", item == null ? "null" : item.toString()); if (item != null) { mSetupData.setSetupData(item); toolbar.setTitle(R.string.edit_task); } if (mSetupData.getSetupData() == null) { mSetupData.setSetupData(new TaskerItem()); } mNextButton = (Button) findViewById(R.id.next_button); mPrevButton = (Button) findViewById(R.id.prev_button); mSetupData.registerListener(this); mPagerAdapter = new CustomPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mPagerAdapter); mViewPager.setPageMargin(getResources().getDimensionPixelOffset(R.dimen.app_margin)); mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mStepPagerStrip.setCurrentPage(position); if (position < mPageList.size()) { onPageLoaded(mPageList.get(position)); } } }); mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip); mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() { @Override public void onPageStripSelected(int position) { position = Math.min(mPagerAdapter.getCount() - 1, position); if (mViewPager.getCurrentItem() != position) { mViewPager.setCurrentItem(position); } } }); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doNext(); } }); mPrevButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doPrevious(); } }); onPageTreeChanged(); }
From source file:org.namelessrom.devicecontrol.wizard.AddTaskActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wizard_activity); // setup action bar final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w.j ava 2s .c om // setup material menu icon final MaterialMenuIconToolbar materialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, MaterialMenuDrawable.Stroke.THIN) { @Override public int getToolbarViewId() { return R.id.toolbar; } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { materialMenu.setNeverDrawTouch(true); } materialMenu.animateState(MaterialMenuDrawable.IconState.ARROW); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); mSetupData = (AbstractSetupData) getLastNonConfigurationInstance(); if (mSetupData == null) { mSetupData = new TaskerSetupWizardData(this); } if (savedInstanceState != null) { mSetupData.load(savedInstanceState.getBundle("data")); } final TaskerItem item = (TaskerItem) getIntent().getSerializableExtra(ARG_ITEM); Logger.v(this, "TaskerItem: %s", item == null ? "null" : item.toString()); if (item != null) { mSetupData.setSetupData(item); toolbar.setTitle(R.string.edit_task); } if (mSetupData.getSetupData() == null) { mSetupData.setSetupData(new TaskerItem()); } mNextButton = (Button) findViewById(R.id.next_button); mPrevButton = (Button) findViewById(R.id.prev_button); mSetupData.registerListener(this); mPagerAdapter = new CustomPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mPagerAdapter); mViewPager.setPageMargin(getResources().getDimensionPixelOffset(R.dimen.app_margin)); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mStepPagerStrip.setCurrentPage(position); if (position < mPageList.size()) { onPageLoaded(mPageList.get(position)); } } }); mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip); mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() { @Override public void onPageStripSelected(int position) { position = Math.min(mPagerAdapter.getCount() - 1, position); if (mViewPager.getCurrentItem() != position) { mViewPager.setCurrentItem(position); } } }); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doNext(); } }); mPrevButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doPrevious(); } }); onPageTreeChanged(); }
From source file:com.android.talkback.eventprocessor.ProcessorEventQueue.java
/** * Provides feedback for the specified utterance. * * @param queueMode The queueMode of the Utterance. * @param utterance The utterance to provide feedback for. *//* w w w . j a va 2s . c o m*/ private void provideFeedbackForUtterance(int queueMode, Utterance utterance) { final Bundle metadata = utterance.getMetadata(); final float earconRate = metadata.getFloat(Utterance.KEY_METADATA_EARCON_RATE, 1.0f); final float earconVolume = metadata.getFloat(Utterance.KEY_METADATA_EARCON_VOLUME, 1.0f); final Bundle nonSpeechMetadata = new Bundle(); nonSpeechMetadata.putFloat(Utterance.KEY_METADATA_EARCON_RATE, earconRate); nonSpeechMetadata.putFloat(Utterance.KEY_METADATA_EARCON_VOLUME, earconVolume); // Perform cleanup of spoken text for each separate part of the utterance, e.g. we do not // want to combine repeated characters if they span different parts, and we still want to // expand single-character symbols if a certain part is a single character. final SpannableStringBuilder textToSpeak = new SpannableStringBuilder(); for (CharSequence text : utterance.getSpoken()) { if (!TextUtils.isEmpty(text)) { CharSequence processedText = SpeechCleanupUtils.collapseRepeatedCharactersAndCleanUp(mContext, text); StringBuilderUtils.appendWithSeparator(textToSpeak, processedText); } } // Get speech settings from utterance. final int flags = metadata.getInt(Utterance.KEY_METADATA_SPEECH_FLAGS, 0); final Bundle speechMetadata = metadata.getBundle(Utterance.KEY_METADATA_SPEECH_PARAMS); final int utteranceGroup = utterance.getMetadata().getInt(Utterance.KEY_UTTERANCE_GROUP, SpeechController.UTTERANCE_GROUP_DEFAULT); mSpeechController.speak(textToSpeak, utterance.getAuditory(), utterance.getHaptic(), queueMode, flags, utteranceGroup, speechMetadata, nonSpeechMetadata); }