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) 

Source Link

Document

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

Usage

From source file:com.optimusinfo.elasticpath.cortex.profile.address.AddressActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set the content view
    setContentView(R.layout.activity_address);
    // Initialize the params objects
    super.initializeParams();
    // Disable the title
    mObjActionBar.setDisplayShowTitleEnabled(false);
    mObjActionBar.setDisplayHomeAsUpEnabled(false);

    mObjAddress = (AddressElement) getIntent().getSerializableExtra(Constants.PageUrl.INTENT_ADRESS);
    // Initialize views
    initializeViews();//  w  ww. j a va 2  s.c o m

    if (savedInstanceState != null) {
        mGeographies = (Geographies) savedInstanceState.getSerializable(KEY_GEOGRAPHIES);
        mRegions = (Regions) savedInstanceState.getSerializable(KEY_REGIONS);
        posCountry = savedInstanceState.getInt(KEY_POSITION_COUNTRIES);
        posRegion = savedInstanceState.getInt(KEY_POSITION_REGIONS);
        mAddressPostUrl = savedInstanceState.getString(KEY_ADDRESS_POST);

    }

    if (mGeographies == null) {
        // Populate the geographies views
        getGeographies();
    } else {
        setUpCountries(mGeographies);
        setUpRegions(mRegions);
    }

    if (mObjAddress != null) {
        bindContent();
    }
    if (mAddressPostUrl == null) {
        getAddressForm();
    }
}

From source file:fr.cobaltians.cobalt.fragments.CobaltFragment.java

private int getInfiniteScrollOffset() {
    Bundle args = getArguments();
    if (args != null) {
        return args.getInt(Cobalt.kInfiniteScrollOffset);
    } else {//from  w  ww . j a  va 2s  .c  om
        return Cobalt.INFINITE_SCROLL_OFFSET_DEFAULT_VALUE;
    }
}

From source file:io.n7.calendar.caldav.CalDAVService.java

private void setupAcc(Message msg) {
    Log.d(TAG, "setupAcc");
    // validate args
    Bundle bndl = (Bundle) msg.obj;
    String calname = null;/*from w w  w.  ja  v  a  2 s.c om*/
    String username = null;
    String password = null;
    String host = null;
    String protocol = null;
    String home = null;
    String coll = null;
    int port = -1;
    int err = 0;
    int suberr = 0;
    String errstr = null;

    if (bndl != null) {
        calname = bndl.getString(CAL_NAME);
        username = bndl.getString(CAL_USER);
        password = bndl.getString(CAL_PSWD);
        host = bndl.getString(CAL_HOST);
        protocol = bndl.getString(CAL_PROT);
        port = bndl.getInt(CAL_PORT);
        home = bndl.getString(CAL_HOME);
        coll = bndl.getString(CAL_COLL);
    }
    if (calname == null || username == null || password == null || host == null || protocol == null || port <= 0
            || home == null || coll == null) {
        err = ERR_SETUP_INVALID_ARGS;
    }
    Log.d(TAG, "Setting up CalDAV acc name " + calname + " user " + username + " password " + password
            + " host " + host + " protocol " + protocol + " port " + port + " home " + home + " coll " + coll);

    Account acc = new Account(this, calname, username, password, host, protocol, home, coll, port);
    if (acc == null || Preferences.getPreferences(this).accountExists(acc)) {
        err = ERR_SETUP_ACC_EXISTS;
    }
    //TODO add a system account

    // test connection
    CalDAV4jIf caldavif = null;
    if (err == 0) {
        caldavif = new CalDAV4jIf(getAssets());
        try {
            caldavif.setCredentials(new CaldavCredential(protocol, host, port, home, coll, username, password));
            suberr = caldavif.testConnection();
            if (suberr != HttpStatus.SC_OK) {
                err = ERR_SETUP_CONN;
            } else
                suberr = 0;
        } catch (Exception e) {
            e.printStackTrace();
            err = ERR_SETUP_CONN;
            errstr = e.toString();
        }
    }

    long calid = -1;
    if (err == 0) {
        // store the details persistently.
        acc.save(Preferences.getPreferences(this));

        // add calendar to provider DB
        calid = createCalendar(acc);
        if (calid < 0)
            err = ERR_SETUP_PROVIDER;
    }

    if (err == 0)
        try {
            doSyncCalendar(acc, calid);
        } catch (Exception e) {
            e.printStackTrace();
            err = ERR_SYNC_SERVER;
            errstr = e.toString();
        }

    try {
        if (err != 0 && errstr == null)
            errstr = errString(err);
        msg.replyTo.send(Message.obtain(null, MSG_SETUP_ACC, err, suberr, errstr));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.teleca.jamendo.activity.SearchActivity.java

@SuppressWarnings("unchecked")
@Override//w  w  w  .j  a va 2s  .c o m
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    mSearchMode = (SearchMode) savedInstanceState.getSerializable("mode");
    if (mSearchMode != null) {
        if (mSearchMode.equals(SearchMode.Artist) || mSearchMode.equals(SearchMode.Tag)
                || mSearchMode.equals(SearchMode.UserStarredAlbums)) {
            AlbumAdapter adapter = new AlbumAdapter(this);
            adapter.setList((ArrayList<Album>) savedInstanceState.get("values"));
            mSearchListView.setAdapter(adapter);
            mSearchListView.setOnItemClickListener(mAlbumClickListener);
        }

        if (mSearchMode.equals(SearchMode.UserPlaylist)) {
            PlaylistRemoteAdapter adapter = new PlaylistRemoteAdapter(this);
            adapter.setList((ArrayList<PlaylistRemote>) savedInstanceState.get("values"));
            mSearchListView.setAdapter(adapter);
            mSearchListView.setOnItemClickListener(mPlaylistClickListener);
        }

        mViewFlipper.setDisplayedChild(savedInstanceState.getInt("flipper_page"));
    }
    super.onRestoreInstanceState(savedInstanceState);
}

From source file:androidx.media.MediaSession2StubImplBase.java

@Override
public void onCommand(String command, final Bundle extras, final ResultReceiver cb) {
    switch (command) {
    case CONTROLLER_COMMAND_CONNECT:
        connect(extras, cb);//  www.  j  a  v  a2  s . c o  m
        break;
    case CONTROLLER_COMMAND_DISCONNECT:
        disconnect(extras);
        break;
    case CONTROLLER_COMMAND_BY_COMMAND_CODE: {
        final int commandCode = extras.getInt(ARGUMENT_COMMAND_CODE);
        IMediaControllerCallback caller = (IMediaControllerCallback) extras
                .getBinder(ARGUMENT_ICONTROLLER_CALLBACK);
        if (caller == null) {
            return;
        }

        onCommand2(caller.asBinder(), commandCode, new Session2Runnable() {
            @Override
            public void run(ControllerInfo controller) {
                switch (commandCode) {
                case COMMAND_CODE_PLAYBACK_PLAY:
                    mSession.play();
                    break;
                case COMMAND_CODE_PLAYBACK_PAUSE:
                    mSession.pause();
                    break;
                case COMMAND_CODE_PLAYBACK_RESET:
                    mSession.reset();
                    break;
                case COMMAND_CODE_PLAYBACK_PREPARE:
                    mSession.prepare();
                    break;
                case COMMAND_CODE_PLAYBACK_SEEK_TO: {
                    long seekPos = extras.getLong(ARGUMENT_SEEK_POSITION);
                    mSession.seekTo(seekPos);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE: {
                    int repeatMode = extras.getInt(ARGUMENT_REPEAT_MODE);
                    mSession.setRepeatMode(repeatMode);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE: {
                    int shuffleMode = extras.getInt(ARGUMENT_SHUFFLE_MODE);
                    mSession.setShuffleMode(shuffleMode);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SET_LIST: {
                    List<MediaItem2> list = MediaUtils2
                            .fromMediaItem2ParcelableArray(extras.getParcelableArray(ARGUMENT_PLAYLIST));
                    MediaMetadata2 metadata = MediaMetadata2
                            .fromBundle(extras.getBundle(ARGUMENT_PLAYLIST_METADATA));
                    mSession.setPlaylist(list, metadata);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SET_LIST_METADATA: {
                    MediaMetadata2 metadata = MediaMetadata2
                            .fromBundle(extras.getBundle(ARGUMENT_PLAYLIST_METADATA));
                    mSession.updatePlaylistMetadata(metadata);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_ADD_ITEM: {
                    int index = extras.getInt(ARGUMENT_PLAYLIST_INDEX);
                    MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM));
                    mSession.addPlaylistItem(index, item);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_REMOVE_ITEM: {
                    MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM));
                    mSession.removePlaylistItem(item);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_REPLACE_ITEM: {
                    int index = extras.getInt(ARGUMENT_PLAYLIST_INDEX);
                    MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM));
                    mSession.replacePlaylistItem(index, item);
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM: {
                    mSession.skipToNextItem();
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM: {
                    mSession.skipToPreviousItem();
                    break;
                }
                case COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM: {
                    MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM));
                    mSession.skipToPlaylistItem(item);
                    break;
                }
                case COMMAND_CODE_VOLUME_SET_VOLUME: {
                    int value = extras.getInt(ARGUMENT_VOLUME);
                    int flags = extras.getInt(ARGUMENT_VOLUME_FLAGS);
                    VolumeProviderCompat vp = mSession.getVolumeProvider();
                    if (vp == null) {
                        // TODO: Revisit
                    } else {
                        vp.onSetVolumeTo(value);
                    }
                    break;
                }
                case COMMAND_CODE_VOLUME_ADJUST_VOLUME: {
                    int direction = extras.getInt(ARGUMENT_VOLUME_DIRECTION);
                    int flags = extras.getInt(ARGUMENT_VOLUME_FLAGS);
                    VolumeProviderCompat vp = mSession.getVolumeProvider();
                    if (vp == null) {
                        // TODO: Revisit
                    } else {
                        vp.onAdjustVolume(direction);
                    }
                    break;
                }
                case COMMAND_CODE_SESSION_REWIND: {
                    mSession.getCallback().onRewind(mSession.getInstance(), controller);
                    break;
                }
                case COMMAND_CODE_SESSION_FAST_FORWARD: {
                    mSession.getCallback().onFastForward(mSession.getInstance(), controller);
                    break;
                }
                case COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID: {
                    String mediaId = extras.getString(ARGUMENT_MEDIA_ID);
                    Bundle extra = extras.getBundle(ARGUMENT_EXTRAS);
                    mSession.getCallback().onPlayFromMediaId(mSession.getInstance(), controller, mediaId,
                            extra);
                    break;
                }
                case COMMAND_CODE_SESSION_PLAY_FROM_SEARCH: {
                    String query = extras.getString(ARGUMENT_QUERY);
                    Bundle extra = extras.getBundle(ARGUMENT_EXTRAS);
                    mSession.getCallback().onPlayFromSearch(mSession.getInstance(), controller, query, extra);
                    break;
                }
                case COMMAND_CODE_SESSION_PLAY_FROM_URI: {
                    Uri uri = extras.getParcelable(ARGUMENT_URI);
                    Bundle extra = extras.getBundle(ARGUMENT_EXTRAS);
                    mSession.getCallback().onPlayFromUri(mSession.getInstance(), controller, uri, extra);
                    break;
                }
                case COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID: {
                    String mediaId = extras.getString(ARGUMENT_MEDIA_ID);
                    Bundle extra = extras.getBundle(ARGUMENT_EXTRAS);
                    mSession.getCallback().onPrepareFromMediaId(mSession.getInstance(), controller, mediaId,
                            extra);
                    break;
                }
                case COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH: {
                    String query = extras.getString(ARGUMENT_QUERY);
                    Bundle extra = extras.getBundle(ARGUMENT_EXTRAS);
                    mSession.getCallback().onPrepareFromSearch(mSession.getInstance(), controller, query,
                            extra);
                    break;
                }
                case COMMAND_CODE_SESSION_PREPARE_FROM_URI: {
                    Uri uri = extras.getParcelable(ARGUMENT_URI);
                    Bundle extra = extras.getBundle(ARGUMENT_EXTRAS);
                    mSession.getCallback().onPrepareFromUri(mSession.getInstance(), controller, uri, extra);
                    break;
                }
                case COMMAND_CODE_SESSION_SET_RATING: {
                    String mediaId = extras.getString(ARGUMENT_MEDIA_ID);
                    Rating2 rating = Rating2.fromBundle(extras.getBundle(ARGUMENT_RATING));
                    mSession.getCallback().onSetRating(mSession.getInstance(), controller, mediaId, rating);
                    break;
                }
                case COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO: {
                    mSession.getCallback().onSubscribeRoutesInfo(mSession.getInstance(), controller);
                    break;
                }
                case COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO: {
                    mSession.getCallback().onUnsubscribeRoutesInfo(mSession.getInstance(), controller);
                    break;
                }
                case COMMAND_CODE_SESSION_SELECT_ROUTE: {
                    Bundle route = extras.getBundle(ARGUMENT_ROUTE_BUNDLE);
                    mSession.getCallback().onSelectRoute(mSession.getInstance(), controller, route);
                    break;
                }
                case COMMAND_CODE_PLAYBACK_SET_SPEED: {
                    float speed = extras.getFloat(ARGUMENT_PLAYBACK_SPEED);
                    mSession.setPlaybackSpeed(speed);
                    break;
                }
                }
            }
        });
        break;
    }
    case CONTROLLER_COMMAND_BY_CUSTOM_COMMAND: {
        final SessionCommand2 customCommand = SessionCommand2
                .fromBundle(extras.getBundle(ARGUMENT_CUSTOM_COMMAND));
        IMediaControllerCallback caller = (IMediaControllerCallback) extras
                .getBinder(ARGUMENT_ICONTROLLER_CALLBACK);
        if (caller == null || customCommand == null) {
            return;
        }

        final Bundle args = extras.getBundle(ARGUMENT_ARGUMENTS);
        onCommand2(caller.asBinder(), customCommand, new Session2Runnable() {
            @Override
            public void run(ControllerInfo controller) throws RemoteException {
                mSession.getCallback().onCustomCommand(mSession.getInstance(), controller, customCommand, args,
                        cb);
            }
        });
        break;
    }
    }
}

From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);/*from  w  w  w  . ja  va2 s  .c om*/
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    actionBar = activity.getActionBar();
    SharedPreferences settings = activity.getApiCall().settings;
    Bundle bundle = getArguments();
    if (savedInstanceState != null) {
        urls = savedInstanceState.getStringArrayList("urls");
        ids = savedInstanceState.getParcelableArrayList("ids");
        page = savedInstanceState.getInt("page");
    } else {
        urls = new ArrayList<String>();
        ids = new ArrayList<JSONParcelable>();
        page = 0;
    }
    if (bundle != null && bundle.containsKey("id"))
        isGridView = settings.getString("GalleryLayout", getString(R.string.card_view))
                .equals(getString(R.string.grid_view));
    else {
        isGridView = settings.getString("ImagesLayout", getString(R.string.grid_view))
                .equals(getString(R.string.grid_view));
    }
    if (bundle == null) {
        return;
    }
    if (bundle.containsKey("id"))
        albumId = bundle.getString("id");
    else
        albumId = null;
    if (bundle.containsKey("imageCall"))
        imageCall = bundle.getString("imageCall");
    if (bundle.containsKey("albumData")) {
        JSONParcelable dataParcel = bundle.getParcelable("albumData");
        if (dataParcel != null)
            galleryAlbumData = dataParcel.getJSONObject();
    }
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void onChangePace(Bundle event) {
    Boolean success = event.getBoolean("success");
    if (success) {
        int state = event.getBoolean("isMoving") ? 1 : 0;
        paceChangeCallback.success(state);
    } else {//w ww .j  a  v  a 2s  . c o  m
        paceChangeCallback.error(event.getInt("code"));
    }
}

From source file:aksha.upcomingdemo.HorizontalListView.java

@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;

        // Restore our state from the bundle
        mRestoreX = Integer.valueOf((bundle.getInt(BUNDLE_ID_CURRENT_X)));

        // Restore out parent's state from the bundle
        super.onRestoreInstanceState(bundle.getParcelable(BUNDLE_ID_PARENT_STATE));
    }/*from   w w w .  ja  va  2s  .  co  m*/
}

From source file:android.dstyo.com.androidtest.page.cars.CarsAddActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Inflate the layout for this fragment
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Intent intent = getIntent();/*  w w w . j  a  v a 2 s. co  m*/
    Bundle bundle = intent.getExtras();
    setContentView(R.layout.activity_add_car);
    textInputBrand = (TextInputLayout) findViewById(R.id.text_input_car_brand);
    textInputModel = (TextInputLayout) findViewById(R.id.text_input_car_model);
    textInputPlat = (TextInputLayout) findViewById(R.id.text_input_car_plat);
    textInputFare = (TextInputLayout) findViewById(R.id.text_input_car_fare);
    imageViewCar = (ImageView) findViewById(R.id.iv_car);

    btnSave = (Button) findViewById(R.id.btnSave);
    btnSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (validateForm()) {
                setParam(false);
            }
        }
    });

    imageViewCar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intents = new Intent(CarsAddActivity.this, CropActivity.class);
            startActivityForResult(intents, RequestConstant.ADD_IMAGE);
        }
    });

    if (bundle != null) {
        int carId = bundle.getInt(RequestConstant.CAR_ID);
        getDetailCar(carId);
        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (validateForm()) {
                    setParam(true);
                }
            }
        });
    }
}