Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

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

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.z.stproperty.PropertyDetailFragment.java

/**
 * /*w  w  w.j  a  v a 2 s.  c o m*/
 * @param position   :: Current page position
 * @param detailJson   :: Property details JSON
 * @param context 
 * @return   :: Return fragment for pager
 */
public static PropertyDetailFragment newInstance(int position, JSONObject detailJson, Context context) {
    detailsJson = detailJson;
    mContext = context;
    PropertyDetailFragment f = new PropertyDetailFragment();
    Bundle b = new Bundle();
    b.putInt(ARG_POSITION, position);
    f.setArguments(b);
    if (detailJson != null) {
        SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
        mPrefs.edit().putString("PropertyDetailJson", detailJson.toString()).commit();
    }
    return f;

}

From source file:com.nextgis.mobile.map.RemoteTMSLayer.java

protected static void create(final MapBase map, String layerName, String layerUrl, int tmsType) {
    String sErr = map.getContext().getString(R.string.error_occurred);
    try {//from ww w .  ja  v a2 s .c o m
        File outputPath = map.cretateLayerStorage();
        //create layer description file
        JSONObject oJSONRoot = new JSONObject();
        oJSONRoot.put(JSON_NAME_KEY, layerName);
        oJSONRoot.put(JSON_URL_KEY, layerUrl);
        oJSONRoot.put(JSON_VISIBILITY_KEY, true);
        oJSONRoot.put(JSON_TYPE_KEY, LAYERTYPE_TMS);
        oJSONRoot.put(JSON_TMSTYPE_KEY, tmsType);

        //send message to handler to show error or add new layer

        File file = new File(outputPath, LAYER_CONFIG);
        FileUtil.createDir(outputPath);
        FileUtil.writeToFile(file, oJSONRoot.toString());

        if (map.getMapEventsHandler() != null) {
            Bundle bundle = new Bundle();
            bundle.putBoolean(BUNDLE_HASERROR_KEY, false);
            bundle.putString(BUNDLE_MSG_KEY, map.getContext().getString(R.string.message_layer_added));
            bundle.putInt(BUNDLE_TYPE_KEY, MSGTYPE_LAYER_ADDED);
            bundle.putSerializable(BUNDLE_PATH_KEY, outputPath);

            Message msg = new Message();
            msg.setData(bundle);
            map.getMapEventsHandler().sendMessage(msg);
        }
        return;

    } catch (FileNotFoundException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (JSONException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (IOException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    }
    //if we here something wrong occurred
    Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
}

From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java

/**
 * Static factory method//from ww w.j  av  a2 s . c o m
 *
 * @param sectionNumber
 * @return
 */
public static AccionesDetalleServicioFragment newInstance(int sectionNumber) {
    AccionesDetalleServicioFragment fragment = new AccionesDetalleServicioFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_SECTION_NUMBER, sectionNumber);
    fragment.setArguments(args);
    return fragment;

}

From source file:com.nononsenseapps.filepicker.sample.ftp.FtpPickerFragment.java

public static AbstractFilePickerFragment<FtpFile> newInstance(String startPath, int mode, boolean allowMultiple,
        boolean allowCreateDir, boolean allowExistingFile, boolean singleClick, String server, int port,
        String username, String password, String rootDir) {
    FtpPickerFragment fragment = new FtpPickerFragment();
    // Add arguments
    fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
    Bundle args = fragment.getArguments();

    // Add ftp related stuff
    args.putString(KEY_FTP_ROOTDIR, rootDir);
    args.putString(KEY_FTP_SERVER, server);
    args.putInt(KEY_FTP_PORT, port);
    if (username != null && password != null) {
        args.putString(KEY_FTP_USERNAME, username);
        args.putString(KEY_FTP_PASSWORD, password);
    }/* ww w  .j  ava 2 s.com*/

    return fragment;
}

From source file:fr.cph.chicago.core.fragment.NearbyFragment.java

@NonNull
public static NearbyFragment newInstance(final int sectionNumber) {
    final NearbyFragment fragment = new NearbyFragment();
    final Bundle args = new Bundle();
    args.putInt(ARG_SECTION_NUMBER, sectionNumber);
    fragment.setArguments(args);/* w w w . ja  v a  2s  .co  m*/
    return fragment;
}

From source file:com.spoiledmilk.ibikecph.util.HttpUtils.java

public static Message JSONtoUserDataMessage(JsonNode result, UserData userData) {
    Message ret = new Message();
    Bundle data = new Bundle();
    if (result != null) {
        data.putBoolean("success", result.get("success").asBoolean());
        data.putString("info", result.get("info").asText());
        JsonNode dataNode = result.get("data");
        if (dataNode != null) {
            data.putInt("id", dataNode.get("id").asInt());
            data.putString("name", dataNode.get("name").asText());
            data.putString("email", dataNode.get("email").asText());
            if (dataNode.has("image_url"))
                data.putString("image_url", dataNode.get("image_url").asText());
        }//from  ww w .jav a  2 s .com
        ret.setData(data);
    }
    return ret;
}

From source file:org.anhonesteffort.flock.ErrorToaster.java

protected static void handleBundleError(Exception e, Bundle bundle) {
    Log.e(TAG, "handleBundleError() - ", e);

    if (e instanceof AuthorizationException)
        bundle.putInt(KEY_STATUS_CODE, CODE_UNAUTHORIZED);
    else if (e instanceof RegistrationApiClientException)
        bundle.putInt(KEY_STATUS_CODE, CODE_REGISTRATION_API_CLIENT_ERROR);
    else if (e instanceof RegistrationApiException)
        bundle.putInt(KEY_STATUS_CODE, CODE_REGISTRATION_API_SERVER_ERROR);

    else if (e instanceof DavException) {
        DavException ex = (DavException) e;

        if (ex.getErrorCode() == DavServletResponse.SC_UNAUTHORIZED)
            bundle.putInt(KEY_STATUS_CODE, CODE_UNAUTHORIZED);
        else if (ex.getErrorCode() == OwsWebDav.STATUS_PAYMENT_REQUIRED)
            bundle.putInt(KEY_STATUS_CODE, CODE_SUBSCRIPTION_EXPIRED);
        else//  ww  w .  j  a v a 2  s . c  om
            bundle.putInt(KEY_STATUS_CODE, CODE_DAV_SERVER_ERROR);
    }

    else if (e instanceof PropertyParseException) {
        PropertyParseException ex = (PropertyParseException) e;
        bundle.putInt(KEY_STATUS_CODE, CODE_DAV_SERVER_ERROR);
    }

    else if (e instanceof InvalidComponentException) {
        InvalidComponentException ex = (InvalidComponentException) e;
        if (ex instanceof InvalidRemoteComponentException)
            bundle.putInt(KEY_STATUS_CODE, CODE_DAV_SERVER_ERROR);
        else
            bundle.putInt(KEY_STATUS_CODE, CODE_DAV_CLIENT_ERROR);
    }

    else if (e instanceof RemoteException || e instanceof OperationApplicationException)
        bundle.putInt(KEY_STATUS_CODE, CODE_DAV_CLIENT_ERROR);

    else if (e instanceof SSLException)
        bundle.putInt(KEY_STATUS_CODE, CODE_CERTIFICATE_ERROR);

    else if (e instanceof IOException) {
        IOException ex = (IOException) e;
        if (ex instanceof SocketException || ex instanceof UnknownHostException
                || ex instanceof SocketTimeoutException)
            bundle.putInt(KEY_STATUS_CODE, CODE_CONNECTION_ERROR);
        else
            bundle.putInt(KEY_STATUS_CODE, CODE_UNKNOWN_IO_ERROR);
    }

    else if (e instanceof InvalidMacException)
        bundle.putInt(KEY_STATUS_CODE, CODE_INVALID_MAC_ERROR);
    else if (e instanceof GeneralSecurityException)
        bundle.putInt(KEY_STATUS_CODE, CODE_CRYPTO_ERROR);

    else if (e instanceof CardException) {
        final String CODE_INVALID_CARD_NUMBER = "incorrect_number";
        final String CODE_INVALID_EXPIRATION_MONTH = "invalid_expiry_month";
        final String CODE_INVALID_EXPIRATION_YEAR = "invalid_expiry_year";
        final String CODE_INVALID_CVC = "invalid_cvc";

        if (((CardException) e).getCode().equals(CODE_INVALID_CARD_NUMBER))
            bundle.putInt(KEY_STATUS_CODE, CODE_CARD_NUMBER_INVALID);
        else if (((CardException) e).getCode().equals(CODE_INVALID_EXPIRATION_MONTH))
            bundle.putInt(KEY_STATUS_CODE, CODE_CARD_EXPIRATION_INVALID);
        else if (((CardException) e).getCode().equals(CODE_INVALID_EXPIRATION_YEAR))
            bundle.putInt(KEY_STATUS_CODE, CODE_CARD_EXPIRATION_INVALID);
        else if (((CardException) e).getCode().equals(CODE_INVALID_CVC))
            bundle.putInt(KEY_STATUS_CODE, CODE_CARD_CVC_INVALID);
        else
            bundle.putInt(KEY_STATUS_CODE, CODE_STRIPE_REJECTED_CARD);
    } else if (e instanceof APIConnectionException)
        bundle.putInt(KEY_STATUS_CODE, CODE_STRIPE_CONNECTION_ERROR);
    else if (e instanceof StripeException)
        bundle.putInt(KEY_STATUS_CODE, CODE_STRIPE_API_ERROR);

    else
        Log.e(TAG, "DID NOT HANDLE THIS EXCEPTION :(", e);
}

From source file:com.max2idea.android.fwknop.Fwknop.java

public static void sendHandlerMessage(Handler handler, int message_type) {
    Message msg1 = handler.obtainMessage();
    Bundle b = new Bundle();
    b.putInt("message_type", message_type);
    msg1.setData(b);// w w  w .jav a2 s. c  om
    handler.sendMessage(msg1);
}

From source file:com.max2idea.android.fwknop.Fwknop.java

public static void sendHandlerMessage(Handler handler, int message_type, String message_var,
        String message_value) {/*from  www. j  a  v a2 s.co m*/
    Message msg1 = handler.obtainMessage();
    Bundle b = new Bundle();
    b.putInt("message_type", message_type);
    b.putString(message_var, message_value);
    msg1.setData(b);
    handler.sendMessage(msg1);
}

From source file:com.sunho.nating.fragments.DetailPlaceFragment.java

/**
 * Create a new instance of DetailFragment.
 *
 * @param resourceId The resource ID of the Drawable image to show
 * @param title The title of the image//from ww  w .j  a v a 2 s. co  m
 * @param x The horizontal position of the grid item in pixel
 * @param y The vertical position of the grid item in pixel
 * @param width The width of the grid item in pixel
 * @param height The height of the grid item in pixel
 * @return a new instance of DetailFragment
 */
public static DetailPlaceFragment newInstance(int resourceId, String title, int x, int y, int width, int height,
        int position, String locationLat, String locationLong) {
    myLocationLat = locationLat;
    myLocationLong = locationLong;
    intentPosition = position;
    DetailPlaceFragment fragment = new DetailPlaceFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_RESOURCE_ID, resourceId);
    args.putString(ARG_TITLE, title);
    args.putInt(ARG_X, x);
    args.putInt(ARG_Y, y);
    args.putInt(ARG_WIDTH, width);
    args.putInt(ARG_HEIGHT, height);
    fragment.setArguments(args);
    return fragment;
}