Example usage for android.os Bundle getInt

List of usage examples for android.os Bundle getInt

Introduction

In this page you can find the example usage for android.os Bundle getInt.

Prototype

public int getInt(String key, int defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Usage

From source file:com.google.sample.castcompanionlibrary.cast.player.VideoCastControllerFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mCastConsumer = new MyCastConsumer();
    Bundle bundle = getArguments();//  w ww .jav a 2s.co m
    if (null == bundle) {
        return;
    }
    Bundle extras = bundle.getBundle(EXTRAS);
    Bundle mediaWrapper = extras.getBundle(VideoCastManager.EXTRA_MEDIA);

    // Retain this fragment across configuration changes.
    setRetainInstance(true);

    if (extras.getBoolean(VideoCastManager.EXTRA_HAS_AUTH)) {
        mOverallState = OverallState.AUTHORIZING;
        mMediaAuthService = mCastManager.getMediaAuthService();
        handleMediaAuthTask(mMediaAuthService);
        showImage(Utils.getImageUri(mMediaAuthService.getMediaInfo(), 1));
    } else if (null != mediaWrapper) {
        mOverallState = OverallState.PLAYBACK;
        boolean shouldStartPlayback = extras.getBoolean(VideoCastManager.EXTRA_SHOULD_START);
        String customDataStr = extras.getString(VideoCastManager.EXTRA_CUSTOM_DATA);
        JSONObject customData = null;
        if (!TextUtils.isEmpty(customDataStr)) {
            try {
                customData = new JSONObject(customDataStr);
            } catch (JSONException e) {
                LOGE(TAG, "Failed to unmarshalize custom data string: customData=" + customDataStr, e);
            }
        }
        MediaInfo info = Utils.toMediaInfo(mediaWrapper);
        int startPoint = extras.getInt(VideoCastManager.EXTRA_START_POINT, 0);
        onReady(info, shouldStartPlayback, startPoint, customData);
    }
}

From source file:android.app.FragmentManager.java

@Override
public Fragment getFragment(Bundle bundle, String key) {
    int index = bundle.getInt(key, -1);
    if (index == -1) {
        return null;
    }//from   w  ww.j a v  a  2 s  .c o m
    if (index >= mActive.size()) {
        throwException(
                new IllegalStateException("Fragement no longer exists for key " + key + ": index " + index));
    }
    Fragment f = mActive.get(index);
    if (f == null) {
        throwException(
                new IllegalStateException("Fragement no longer exists for key " + key + ": index " + index));
    }
    return f;
}

From source file:com.oakesville.mythling.MediaActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    selItemIndex = savedInstanceState.getInt(SEL_ITEM_INDEX, 0);
    currentTop = savedInstanceState.getInt(CURRENT_TOP, 0);
    topOffset = savedInstanceState.getInt(TOP_OFFSET, 0);
}

From source file:com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setImmersive();//from   w  w  w  . j  a v  a  2s. co m
    mCastConsumer = new MyCastConsumer();
    Bundle bundle = getArguments();
    if (bundle == null) {
        return;
    }
    Bundle extras = bundle.getBundle(EXTRAS);
    Bundle mediaWrapper = extras.getBundle(VideoCastManager.EXTRA_MEDIA);

    // Retain this fragment across configuration changes.
    setRetainInstance(true);
    mCastManager.addTracksSelectedListener(this);
    boolean explicitStartActivity = mCastManager.getPreferenceAccessor()
            .getBooleanFromPreference(VideoCastManager.PREFS_KEY_START_ACTIVITY, false);
    if (explicitStartActivity) {
        mIsFresh = true;
    }
    mCastManager.getPreferenceAccessor().saveBooleanToPreference(VideoCastManager.PREFS_KEY_START_ACTIVITY,
            false);
    if (extras.getBoolean(VideoCastManager.EXTRA_HAS_AUTH)) {
        if (mIsFresh) {
            mOverallState = OverallState.AUTHORIZING;
            mMediaAuthService = mCastManager.getMediaAuthService();
            handleMediaAuthTask(mMediaAuthService);
            showImage(Utils.getImageUri(mMediaAuthService.getMediaInfo(), 1));
        }
    } else if (mediaWrapper != null) {
        mOverallState = OverallState.PLAYBACK;
        boolean shouldStartPlayback = extras.getBoolean(VideoCastManager.EXTRA_SHOULD_START);
        String customDataStr = extras.getString(VideoCastManager.EXTRA_CUSTOM_DATA);
        int nextPreviousVisibilityPolicy = extras.getInt(VideoCastManager.EXTRA_NEXT_PREVIOUS_VISIBILITY_POLICY,
                VideoCastController.NEXT_PREV_VISIBILITY_POLICY_DISABLED);
        mCastController.setNextPreviousVisibilityPolicy(nextPreviousVisibilityPolicy);
        JSONObject customData = null;
        if (!TextUtils.isEmpty(customDataStr)) {
            try {
                customData = new JSONObject(customDataStr);
            } catch (JSONException e) {
                LOGE(TAG, "Failed to unmarshalize custom data string: customData=" + customDataStr, e);
            }
        }
        MediaInfo info = Utils.bundleToMediaInfo(mediaWrapper);
        int startPoint = extras.getInt(VideoCastManager.EXTRA_START_POINT, 0);
        onReady(info, shouldStartPlayback && explicitStartActivity, startPoint, customData);
    }
}

From source file:android.support.v7.preference.PreferenceDialogFragmentCompat.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Fragment rawFragment = getTargetFragment();
    if (!(rawFragment instanceof DialogPreference.TargetFragment)) {
        throw new IllegalStateException("Target fragment must implement TargetFragment" + " interface");
    }/*w  w  w .j a va  2  s . co  m*/

    final DialogPreference.TargetFragment fragment = (DialogPreference.TargetFragment) rawFragment;

    final String key = getArguments().getString(ARG_KEY);
    if (savedInstanceState == null) {
        mPreference = (DialogPreference) fragment.findPreference(key);
        mDialogTitle = mPreference.getDialogTitle();
        mPositiveButtonText = mPreference.getPositiveButtonText();
        mNegativeButtonText = mPreference.getNegativeButtonText();
        mDialogMessage = mPreference.getDialogMessage();
        mDialogLayoutRes = mPreference.getDialogLayoutResource();

        final Drawable icon = mPreference.getDialogIcon();
        if (icon == null || icon instanceof BitmapDrawable) {
            mDialogIcon = (BitmapDrawable) icon;
        } else {
            final Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
                    Bitmap.Config.ARGB_8888);
            final Canvas canvas = new Canvas(bitmap);
            icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            icon.draw(canvas);
            mDialogIcon = new BitmapDrawable(getResources(), bitmap);
        }
    } else {
        mDialogTitle = savedInstanceState.getCharSequence(SAVE_STATE_TITLE);
        mPositiveButtonText = savedInstanceState.getCharSequence(SAVE_STATE_POSITIVE_TEXT);
        mNegativeButtonText = savedInstanceState.getCharSequence(SAVE_STATE_NEGATIVE_TEXT);
        mDialogMessage = savedInstanceState.getCharSequence(SAVE_STATE_MESSAGE);
        mDialogLayoutRes = savedInstanceState.getInt(SAVE_STATE_LAYOUT, 0);
        final Bitmap bitmap = savedInstanceState.getParcelable(SAVE_STATE_ICON);
        if (bitmap != null) {
            mDialogIcon = new BitmapDrawable(getResources(), bitmap);
        }
    }
}

From source file:android.app.FragmentManager.java

@Override
public Fragment getFragment(Bundle bundle, String key) {
    int index = bundle.getInt(key, -1);
    if (index == -1) {
        return null;
    }/*ww  w  .j  a  v a  2s . co m*/
    if (index >= mActive.size()) {
        throwException(
                new IllegalStateException("Fragment no longer exists for key " + key + ": index " + index));
    }
    Fragment f = mActive.get(index);
    if (f == null) {
        throwException(
                new IllegalStateException("Fragment no longer exists for key " + key + ": index " + index));
    }
    return f;
}

From source file:com.hybris.mobile.app.commerce.fragment.CheckoutFragmentBase.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mPlaceOrderButton = (Button) view.findViewById(R.id.checkout_place_order_button);

    mTermsConditionsLayout = (LinearLayout) view.findViewById(R.id.checkout_terms_conditions_layout);
    mTermsConditionsText = (TextView) view.findViewById(R.id.checkout_terms_conditions_text);
    mTermsConditionsCheckbox = (CheckBox) view.findViewById(R.id.checkout_terms_conditions_checkbox);

    mToolTip = new ToolTip(getActivity(), getString(R.string.checkout_payment_number_button_description,
            getString(R.string.name_storefront)));

    mPlacingOrderErrorMsgLayout = (LinearLayout) view
            .findViewById(R.id.checkout_placing_order_error_msg_layout);
    mTermsConditionsErroMsgLayout = (LinearLayout) view
            .findViewById(R.id.checkout_terms_conditions_error_msg_layout);

    mDeliveryAddressAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
            new ArrayList<String>());

    mDeliveryMethodAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
            new ArrayList<String>());

    mDeliveryAddressSpinner = (Spinner) view.findViewById(R.id.checkout_delivery_address_spinner);
    mDeliveryMethodSpinner = (Spinner) view.findViewById(R.id.checkout_delivery_method_spinner);

    // Listeners/*  w  w w  . j  av a 2 s  .  co m*/
    mTermsConditionsText.setOnClickListener(mTermsConditionsTextListener);
    mToolTip.setOnClickListener(mTooltipListener);
    mPlaceOrderButton.setOnClickListener(mPlaceOrderButtonListener);

    initDeliveryAddressSpinner();
    initDeliveryMethodSpinner();

    // Disable all spinners except the payment type and cost center
    mDeliveryAddressSpinner.setClickable(false);
    mDeliveryMethodSpinner.setClickable(false);

    // Restore the current spinner selection
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(SAVED_INSTANCE_DELIVERY_METHOD)) {
            indexSelectedDeliveryMethod = savedInstanceState.getInt(SAVED_INSTANCE_DELIVERY_METHOD, 0);
        }
        if (savedInstanceState.containsKey(SAVED_INSTANCE_DELIVERY_ADDRESS)) {
            indexSelectedDeliveryAddress = savedInstanceState.getInt(SAVED_INSTANCE_DELIVERY_ADDRESS, 0);
        }
    }

}

From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    Bundle args = getArguments();
    if (args != null) {
        id = args.getString(Constants.INTENT_EXTRA_NAME_ID);
        name = args.getString(Constants.INTENT_EXTRA_NAME_NAME);
        directory = (Entry) args.getSerializable(Constants.INTENT_EXTRA_NAME_DIRECTORY);
        playlistId = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID);
        playlistName = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME);
        playlistOwner = args.getBoolean(Constants.INTENT_EXTRA_NAME_PLAYLIST_OWNER, false);
        podcastId = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_ID);
        podcastName = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_NAME);
        podcastDescription = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_DESCRIPTION);
        Object shareObj = args.getSerializable(Constants.INTENT_EXTRA_NAME_SHARE);
        share = (shareObj != null) ? (Share) shareObj : null;
        albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
        albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
        albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
        refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
        artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
        lookupEntry = args.getString(Constants.INTENT_EXTRA_SEARCH_SONG);
        topTracks = args.getBoolean(Constants.INTENT_EXTRA_TOP_TRACKS);
        showAll = args.getBoolean(Constants.INTENT_EXTRA_SHOW_ALL);

        String childId = args.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID);
        if (childId != null) {
            id = childId;//ww  w.  j  a  v a  2s  . c  o  m
            lookupParent = true;
        }
        if (entries == null) {
            entries = (List<Entry>) args.getSerializable(Constants.FRAGMENT_LIST);
            albums = (List<Entry>) args.getSerializable(Constants.FRAGMENT_LIST2);

            if (albums == null) {
                albums = new ArrayList<Entry>();
            }
        }
    }

    rootView = inflater.inflate(R.layout.abstract_recycler_fragment, container, false);

    refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
    refreshLayout.setOnRefreshListener(this);

    if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_LARGE_ALBUM_ART, true)) {
        largeAlbums = true;
    }

    recyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_recycler);
    recyclerView.setHasFixedSize(true);
    fastScroller = (FastScroller) rootView.findViewById(R.id.fragment_fast_scroller);
    setupScrollList(recyclerView);
    setupLayoutManager(recyclerView, largeAlbums);

    if (entries == null) {
        if (primaryFragment || secondaryFragment) {
            load(false);
        } else {
            invalidated = true;
        }
    } else {

        licenseValid = true;
        finishLoading();
    }

    if (name != null) {
        setTitle(name);
    }

    return rootView;
}

From source file:com.irccloud.android.fragment.MessageViewFragment.java

@Override
public void setArguments(Bundle args) {
    ready = false;/*  w  ww .  j  av a2 s  .c  om*/
    if (heartbeatTask != null)
        heartbeatTask.cancel(true);
    heartbeatTask = null;
    if (tapTimerTask != null)
        tapTimerTask.cancel();
    tapTimerTask = null;
    if (buffer != null && buffer.bid != args.getInt("bid", -1) && adapter != null)
        adapter.clearLastSeenEIDMarker();
    buffer = BuffersDataSource.getInstance().getBuffer(args.getInt("bid", -1));
    if (buffer != null) {
        server = ServersDataSource.getInstance().getServer(buffer.cid);
        Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: switched to bid: " + buffer.bid);
    } else {
        Crashlytics.log(Log.WARN, "IRCCloud", "MessageViewFragment: couldn't find buffer to switch to");
    }
    requestingBacklog = false;
    avgInsertTime = 0;
    newMsgs = 0;
    newMsgTime = 0;
    newHighlights = 0;
    earliest_eid = 0;
    backlog_eid = 0;
    currentCollapsedEid = -1;
    lastCollapsedDay = -1;
    if (server != null) {
        ignore.setIgnores(server.ignores);
        if (server.away != null && server.away.length() > 0) {
            awayTxt.setText(ColorFormatter
                    .html_to_spanned(
                            ColorFormatter.irc_to_html(TextUtils.htmlEncode("Away (" + server.away + ")")))
                    .toString());
            awayView.setVisibility(View.VISIBLE);
        } else {
            awayView.setVisibility(View.GONE);
        }
        collapsedEvents.setServer(server);
        update_status(server.status, server.fail_info);
    }
    if (unreadTopView != null)
        unreadTopView.setVisibility(View.GONE);
    backlogFailed.setVisibility(View.GONE);
    loadBacklogButton.setVisibility(View.GONE);
    try {
        if (getListView().getHeaderViewsCount() == 0) {
            getListView().addHeaderView(headerViewContainer);
        }
    } catch (IllegalStateException e) {
    }
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) headerView.getLayoutParams();
    lp.topMargin = 0;
    headerView.setLayoutParams(lp);
    lp = (ViewGroup.MarginLayoutParams) backlogFailed.getLayoutParams();
    lp.topMargin = 0;
    backlogFailed.setLayoutParams(lp);
    if (buffer != null && EventsDataSource.getInstance().getEventsForBuffer(buffer.bid) != null) {
        requestingBacklog = true;
        if (refreshTask != null)
            refreshTask.cancel(true);
        refreshTask = new RefreshTask();
        if (args.getBoolean("fade")) {
            Crashlytics.log(Log.DEBUG, "IRCCloud",
                    "MessageViewFragment: Loading message contents in the background");
            refreshTask.execute((Void) null);
        } else {
            Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: Loading message contents");
            refreshTask.onPreExecute();
            refreshTask.onPostExecute(refreshTask.doInBackground());
        }
    } else {
        if (buffer == null || buffer.min_eid == 0 || earliest_eid == buffer.min_eid
                || conn.getState() != NetworkConnection.STATE_CONNECTED || !conn.ready) {
            headerView.setVisibility(View.GONE);
        } else {
            headerView.setVisibility(View.VISIBLE);
        }
        if (adapter != null) {
            adapter.clear();
            adapter.notifyDataSetInvalidated();
        }
        mListener.onMessageViewReady();
        ready = true;
    }
}