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.sababado.network.AsyncServiceCallTask.java

@Override
protected void onPostExecute(Bundle result) {
    String errMsg = result.getString(EXTRA_ERR_MSG);
    if (errMsg == null) {
        mAsyncServiceListener.onServiceCallSuccess(result);
    } else {//from w w w .ja  v  a  2s .  c o  m
        int errCd = result.getInt(EXTRA_ERR_CODE, ERR_CODE_MISSING_ERR_CODE);
        mAsyncServiceListener.onServiceCallFailure(errMsg, errCd);
    }
    mRunning = false;
}

From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Uri action = intent.getData();//from w  w w  .ja va2 s.  c o m
    Bundle extras = intent.getExtras();

    if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) {
        Log.e(TAG, "You did not pass extras or data with the Intent.");
        return;
    }

    int verb = extras.getInt(EXTRA_HTTP_VERB, GET);
    Bundle params = extras.getParcelable(EXTRA_PARAMS);
    Bundle headers = extras.getParcelable(EXTRA_HEADERS);
    ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER);

    try {
        HttpRequestBase request = null;

        // Get query params from Bundle and build URL
        switch (verb) {
        case GET: {
            request = new HttpGet();
            attachUriWithQuery(request, action, params);
        }
            break;

        case DELETE: {
            request = new HttpDelete();
            attachUriWithQuery(request, action, params);
        }
            break;

        case POST: {
            request = new HttpPost();
            request.setURI(new URI(action.toString()));

            HttpPost postRequest = (HttpPost) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                postRequest.setEntity(formEntity);
            }
        }
            break;

        case PUT: {
            request = new HttpPut();
            request.setURI(new URI(action.toString()));

            HttpPut putRequest = (HttpPut) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                putRequest.setEntity(formEntity);
            }
        }
            break;
        }

        // Get Headers from Bundle
        for (BasicNameValuePair header : paramsToList(headers)) {
            request.setHeader(header.getName(), header.getValue());
        }

        if (request != null) {
            HttpClient client = new DefaultHttpClient();

            Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString());

            HttpResponse response = client.execute(request);

            HttpEntity responseEntity = response.getEntity();
            StatusLine responseStatus = response.getStatusLine();
            int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0;

            if ((responseEntity != null) && (responseStatus.getStatusCode() == 200)) {
                Bundle resultData = new Bundle();
                resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity));
                receiver.send(statusCode, resultData);
            } else {
                receiver.send(statusCode, null);
            }
        }
    } catch (URISyntaxException e) {
        Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e);
        receiver.send(0, null);
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e);
        receiver.send(0, null);
    } catch (ClientProtocolException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (IOException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cm.aptoide.ptdev.ScreenshotsViewer.java

@Override
protected void onCreate(Bundle arg0) {
    Aptoide.getThemePicker().setAptoideTheme(this);
    super.onCreate(arg0);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.page_screenshots_viewer);

    if (arg0 == null) {
        currentItem = getIntent().getIntExtra("position", 0);
    } else {//from   ww w  .  j  a  va2 s.c om
        currentItem = arg0.getInt("position", 0);
    }

    getIntent().getIntExtra("position", 0);
    //      getSupportActionBar().hide();
    context = this;
    final ViewPager screenshots = (ViewPager) findViewById(R.id.screenShotsPager);
    //      final CirclePageIndicator pi = (CirclePageIndicator) findViewById(R.id.indicator);
    //      pi.setCentered(true);
    //      pi.setSnap(true);
    //      pi.setRadius(7.5f);
    //      TypedValue a = new TypedValue();
    //      getTheme().resolveAttribute(R.attr.custom_color, a, true);
    //      pi.setFillColor(a.data);
    ArrayList<String> uri = getIntent().getStringArrayListExtra("url");
    hashCode = getIntent().getStringExtra("hashCode");
    if (uri != null) {
        images = uri.toArray(images);
    }
    if (images != null && images.length > 0) {
        screenshots.setAdapter(new ViewPagerAdapterScreenshots(context, uri, hashCode, true));
        screenshots.setCurrentItem(currentItem);
    }

}

From source file:com.frostwire.android.gui.fragments.ImageViewerFragment.java

private void loadPicture(Bundle stateBundle) {
    if (stateBundle != null) {
        Bundle data = stateBundle.getBundle(EXTRA_FILE_DESCRIPTOR_BUNDLE);
        int position = stateBundle.getInt(ImageViewerFragment.EXTRA_ADAPTER_FILE_OFFSET, -1);
        if (data != null) {
            inFullScreenMode = stateBundle.getBoolean(EXTRA_IN_FULL_SCREEN_MODE);
            updateData(new FileDescriptor(data), position);
        }//from  w  w  w. java2s  .  c  o m
    }
}

From source file:com.github.jimcoven.nodeauth.GoogleLoginManager.java

public void restoreState(Bundle state) {
    if (state != null) {
        mLoginState = state.getInt(LOGIN_STATE_KEY, STATE_DEFAULT);
    }
}

From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java

@Override
public void setSettingsFromBundle(Bundle inState) {
    super.setSettingsFromBundle(inState);
    if (inState != null) {
        setRadiusInMeters(inState.getInt(RADIUS_IN_METERS_BUNDLE_KEY, radiusInMeters));
        setResultsLimit(inState.getInt(RESULTS_LIMIT_BUNDLE_KEY, resultsLimit));
        if (inState.containsKey(SEARCH_TEXT_BUNDLE_KEY)) {
            setSearchText(inState.getString(SEARCH_TEXT_BUNDLE_KEY));
        }//  w w  w.j a v a2s.co m
        if (inState.containsKey(LOCATION_BUNDLE_KEY)) {
            Location location = inState.getParcelable(LOCATION_BUNDLE_KEY);
            setLocation(location);
        }
        showSearchBox = inState.getBoolean(SHOW_SEARCH_BOX_BUNDLE_KEY, showSearchBox);
    }
}

From source file:android.support.content.Query.java

@VisibleForTesting
Query(@NonNull Uri uri, @Nullable String[] projection, @NonNull Bundle args,
        @Nullable CancellationSignal cancellationSignal, @NonNull ContentPager.ContentCallback callback) {

    checkArgument(uri != null);// w  w w.  j a  va 2s . c  o m
    checkArgument(args != null);
    checkArgument(callback != null);

    this.mUri = uri;
    this.mProjection = projection;
    this.mQueryArgs = args;
    this.mCancellationSignal = cancellationSignal;
    this.mCallback = callback;

    this.mOffset = args.getInt(ContentPager.QUERY_ARG_OFFSET, -1);
    this.mLimit = args.getInt(ContentPager.QUERY_ARG_LIMIT, -1);

    // NOTE: We omit mProjection and other details from ID. If a client wishes
    // to request a page with a different mProjection or sorting, they should
    // wait for first request to finish. Same goes for mCallback.
    this.mId = uri.hashCode() << 16 | (mOffset | (mLimit << 8));

    checkArgument(mOffset >= 0); // mOffset must be set, mLimit is optional.
}

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

@Override
public void setArguments(Bundle args) {
    cid = args.getInt("cid", 0);
    bid = args.getInt("bid", 0);
    channel = args.getString("name");
    if (tapTimer == null)
        tapTimer = new Timer("users-tap-timer");

    tapTimer.schedule(new TimerTask() {
        @Override/*www  .ja va 2s  .  co m*/
        public void run() {
            if (getActivity() != null)
                getActivity().runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        ArrayList<UsersDataSource.User> users = null;
                        if (ChannelsDataSource.getInstance().getChannelForBuffer(bid) != null)
                            users = UsersDataSource.getInstance().getUsersForBuffer(bid);
                        refresh(users);
                        try {
                            if (getListView() != null)
                                getListView().setSelection(0);
                        } catch (Exception e) { //Sometimes the list view isn't available yet
                        }
                    }

                });
        }
    }, 100);
}

From source file:android.support.mediacompat.client.ClientBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    MediaControllerCompat controller;/*from   w w w . j av  a 2s.c  o  m*/
    try {
        controller = new MediaControllerCompat(context,
                (MediaSessionCompat.Token) extras.getParcelable(KEY_SESSION_TOKEN));
    } catch (RemoteException ex) {
        // Do nothing.
        return;
    }
    int method = extras.getInt(KEY_METHOD_ID, 0);

    if (ACTION_CALL_MEDIA_CONTROLLER_METHOD.equals(intent.getAction()) && extras != null) {
        Bundle arguments;
        switch (method) {
        case SEND_COMMAND:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controller.sendCommand(arguments.getString("command"), arguments.getBundle("extras"),
                    new ResultReceiver(null));
            break;
        case ADD_QUEUE_ITEM:
            controller.addQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT));
            break;
        case ADD_QUEUE_ITEM_WITH_INDEX:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controller.addQueueItem((MediaDescriptionCompat) arguments.getParcelable("description"),
                    arguments.getInt("index"));
            break;
        case REMOVE_QUEUE_ITEM:
            controller.removeQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT));
            break;
        case SET_VOLUME_TO:
            controller.setVolumeTo(extras.getInt(KEY_ARGUMENT), 0);
            break;
        case ADJUST_VOLUME:
            controller.adjustVolume(extras.getInt(KEY_ARGUMENT), 0);
            break;
        }
    } else if (ACTION_CALL_TRANSPORT_CONTROLS_METHOD.equals(intent.getAction()) && extras != null) {
        TransportControls controls = controller.getTransportControls();
        Bundle arguments;
        switch (method) {
        case PLAY:
            controls.play();
            break;
        case PAUSE:
            controls.pause();
            break;
        case STOP:
            controls.stop();
            break;
        case FAST_FORWARD:
            controls.fastForward();
            break;
        case REWIND:
            controls.rewind();
            break;
        case SKIP_TO_PREVIOUS:
            controls.skipToPrevious();
            break;
        case SKIP_TO_NEXT:
            controls.skipToNext();
            break;
        case SEEK_TO:
            controls.seekTo(extras.getLong(KEY_ARGUMENT));
            break;
        case SET_RATING:
            controls.setRating((RatingCompat) extras.getParcelable(KEY_ARGUMENT));
            break;
        case PLAY_FROM_MEDIA_ID:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.playFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras"));
            break;
        case PLAY_FROM_SEARCH:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.playFromSearch(arguments.getString("query"), arguments.getBundle("extras"));
            break;
        case PLAY_FROM_URI:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.playFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras"));
            break;
        case SEND_CUSTOM_ACTION:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.sendCustomAction(arguments.getString("action"), arguments.getBundle("extras"));
            break;
        case SEND_CUSTOM_ACTION_PARCELABLE:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.sendCustomAction((PlaybackStateCompat.CustomAction) arguments.getParcelable("action"),
                    arguments.getBundle("extras"));
            break;
        case SKIP_TO_QUEUE_ITEM:
            controls.skipToQueueItem(extras.getLong(KEY_ARGUMENT));
            break;
        case PREPARE:
            controls.prepare();
            break;
        case PREPARE_FROM_MEDIA_ID:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.prepareFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras"));
            break;
        case PREPARE_FROM_SEARCH:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.prepareFromSearch(arguments.getString("query"), arguments.getBundle("extras"));
            break;
        case PREPARE_FROM_URI:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.prepareFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras"));
            break;
        case SET_CAPTIONING_ENABLED:
            controls.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT));
            break;
        case SET_REPEAT_MODE:
            controls.setRepeatMode(extras.getInt(KEY_ARGUMENT));
            break;
        case SET_SHUFFLE_MODE:
            controls.setShuffleMode(extras.getInt(KEY_ARGUMENT));
            break;
        }
    }
}