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.facebook.android.friendsmash.HomeFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == REAUTH_ACTIVITY_CODE) {
        // This ensures a session state change is recorded so that the tokenUpdated() callback is triggered
        // to attempt a post if the write permissions have been granted
        Log.i(FriendSmashApplication.TAG, "Reauthorized with publish permissions.");
        Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data);
    } else if (resultCode == Activity.RESULT_OK && data != null) {
        // Finished a game
        Bundle bundle = data.getExtras();
        application.setScore(bundle.getInt("score"));
        updateYouScoredTextView();//  w  w w  .j a v  a2  s . com
        updateButtonVisibility();
        completeGameOver(1500);
    } else if (resultCode == Activity.RESULT_FIRST_USER && data != null) {
        // Came from the ScoreboardFragment, so start a game with the specific user who has been clicked
        Intent i = new Intent(getActivity(), GameActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("user_id", data.getStringExtra("user_id"));
        i.putExtras(bundle);
        startActivityForResult(i, 0);
    } else if (resultCode == Activity.RESULT_CANCELED && data != null) {
        Bundle bundle = data.getExtras();
        ((HomeActivity) getActivity()).showError(bundle.getString("error"), false);
    } else if (resultCode == Activity.RESULT_CANCELED
            && ((FriendSmashApplication) getActivity().getApplication())
                    .getGameFragmentFBRequestError() != null) {
        ((HomeActivity) getActivity()).handleError(
                ((FriendSmashApplication) getActivity().getApplication()).getGameFragmentFBRequestError(),
                false);
        ((FriendSmashApplication) getActivity().getApplication()).setGameFragmentFBRequestError(null);
    }
}

From source file:com.autoparts.buyers.activity.InquiryModelActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.lnquiry_model);
    super.onCreate(savedInstanceState);
    context = this;
    String title = getString(R.string.inquiry_text_model);
    setTitle(title);/* ww  w  . j  a  v  a2 s .  c o m*/
    setRightView(getString(R.string.inquiry_text_history), -1);

    if (savedInstanceState != null) {
        currentState = savedInstanceState.getInt(STATE_URI);
        currentContentFragmentTag = savedInstanceState.getString(STATE_FRAGMENT_TAG);
    }

    init();
    initView();
    initOverlay();
}

From source file:com.autoparts.sellers.activity.InquiryModelActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.lnquiry_model);
    super.onCreate(savedInstanceState);
    context = this;
    String title = getString(R.string.inquiry_text_model);
    setTitle(title);//w ww  .  j a v a2 s  .com
    //        setRightView(getString(R.string.inquiry_text_history), -1);

    if (savedInstanceState != null) {
        currentState = savedInstanceState.getInt(STATE_URI);
        currentContentFragmentTag = savedInstanceState.getString(STATE_FRAGMENT_TAG);
    }

    init();
    initView();
    initOverlay();
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

@Override
protected void onCreate(Bundle arg0) {
    // TODO Auto-generated method stub
    super.onCreate(arg0);
    Bundle extras = getIntent().getExtras();
    job_id = extras.getString("job_id");
    tempLat = extras.getInt("tempLat");
    tempLongi = extras.getInt("tempLongi");

    try {//from   w w w. j  a  v  a2 s  . c  om
        driver_id = Query.getJobInfo(job_id).getString("driver_id");
    } catch (JSONException e) {
    }

    clientpng = getResources().getDrawable(R.drawable.greendot);
    taxipng = getResources().getDrawable(R.drawable.cabs);

    setContentView(R.layout.onroute);
    map = (MapView) findViewById(R.id.mvOnroute);
    map.setBuiltInZoomControls(true);
    overlayList = map.getOverlays();

    mySubmittedPosition = new GeoPoint(tempLat, tempLongi);
    map.getController().setCenter(mySubmittedPosition);
    map.getController().setZoom(17);
    localpos();

    TextView tvTaxiLicense = (TextView) findViewById(R.id.tvTaxiLicense);
    //TextView tvTaxiType = (TextView) findViewById(R.id.tvTaxiType);

    tvTaxiLicense.setText(Query.getDriverDetail("license", driver_id));
    //tvTaxiType.setText(job_id);

    tvORTop = (TextView) findViewById(R.id.tvORTop);
    tvORTop.setText(Query.getDriverDetail("name", driver_id) + " is en route");
    getDriverPosition(driver_id);

    handlerboolean = true;

    handler.postDelayed(r, 5000);

    // ///////////////////////////// CANCEL BUTTON ///////////////
    // ////////////////////////////////////////////////////////////
    Button cancel = (Button) findViewById(R.id.bOnrouteCancelCall);
    cancel.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            try {

                JSONObject json = Query.getJobInfo(job_id);

                int starttime = json.getInt("datetime");

                // ////////////////// CANCEL BUTTON - REPORT NO SHOW /////
                if (starttime + 300 <= Query.getServerTime()) {
                    handlerboolean = false;
                    handler.removeCallbacks(r);

                    AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
                    dcancelbuilder
                            .setMessage("Job has been cancelled.\nWould you like to report a driver no-show?.");

                    // ///////// NO button - normal client cancel ////////
                    button_cancelJob(dcancelbuilder);
                    // ///////// YES button - report driver NO SHOW ////////
                    button_cancelJob_driverNoShow(dcancelbuilder);

                    dcancelbuilder.show();

                } else {
                    handlerboolean = false;
                    handler.removeCallbacks(r);

                    alertdialog_canceljob();
                }

            } catch (JSONException e) {
            }

        }
    });
}

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

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    root = (FrameLayout) view;//  w  w w . j  a v  a  2s . com
    context = view.getContext();
    assert context != null;
    // This is how the fragment looks at first. Since the transition is one-way, we don't need to make
    // this a Scene.
    View item = LayoutInflater.from(context).inflate(R.layout.item_gridview, root, false);
    assert item != null;
    bind(item);
    // We adjust the position of the initial image with LayoutParams using the values supplied
    // as the fragment arguments.
    Bundle args = getArguments();
    FrameLayout.LayoutParams params = null;
    if (args != null) {
        params = new FrameLayout.LayoutParams(args.getInt(ARG_WIDTH), args.getInt(ARG_HEIGHT));
        params.topMargin = args.getInt(ARG_Y);
        params.leftMargin = args.getInt(ARG_X);
    }
    root.addView(item, params);
}

From source file:com.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPairsSpinner = (Spinner) LayoutInflater.from(getActivity()).inflate(R.layout.spinner, null);
    mPairsSpinner.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1,
            getResources().getStringArray(R.array.ExchangePairs)));
    //restoring spinner position
    if (savedInstanceState != null) {
        mPairsSpinner.setSelection(savedInstanceState.getInt("position"));
    }/*from   ww  w  . jav a 2s  . c o  m*/
    mPairsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String selected = parent.getSelectedItem().toString();
            Bundle bundle = new Bundle();
            bundle.putString("pair", selected);
            if (mFragmentOpenedFirstTime) {
                getLoaderManager().initLoader(LOADER_ID, bundle, OrdersBookFragment.this);
                mFragmentOpenedFirstTime = false;
            } else {
                getLoaderManager().restartLoader(LOADER_ID, bundle, OrdersBookFragment.this);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    mAsksAdapter = new OrdersBookAdapter(getActivity());
    mBidsAdapter = new OrdersBookAdapter(getActivity());
}

From source file:com.esri.arcgisruntime.sample.editfeatureattachments.EditAttachmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.attachments);

    Bundle bundle = getIntent().getExtras();
    String s = bundle.getString(getApplication().getString(R.string.attribute));
    noOfAttachments = bundle.getInt(getApplication().getString(R.string.noOfAttachments));

    // Build a alert dialog with specified style
    builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle);

    // inflate the floating action button
    addAttachmentFab = (FloatingActionButton) findViewById(R.id.addAttachmentFAB);

    // select an image to upload as an attachment
    addAttachmentFab.setOnClickListener(new View.OnClickListener() {
        @Override//  ww  w  . j  ava 2s  . c  o m
        public void onClick(View v) {

            if (!permissionsGranted) {
                getPermissions(requestCodeGallery);
            } else {
                selectAttachment();
            }

        }
    });

    mServiceFeatureTable = new ServiceFeatureTable(getResources().getString(R.string.sample_service_url));

    progressDialog = new ProgressDialog(this);

    // display progress dialog if selected feature has attachments
    if (noOfAttachments != 0) {
        progressDialog.setTitle(getApplication().getString(R.string.fetching_attachments));
        progressDialog.setMessage(getApplication().getString(R.string.wait));

        progressDialog.show();
    } else {
        Toast.makeText(EditAttachmentActivity.this,
                getApplication().getString(R.string.empty_attachment_message), Toast.LENGTH_LONG).show();
    }

    // inflate the list view
    list = (ListView) findViewById(R.id.listView);
    // create custom adapter
    adapter = new CustomList(EditAttachmentActivity.this, attachmentList);
    // set custom adapter on the list
    list.setAdapter(adapter);
    fetchAttachmentsFromServer(s);

    // listener on attachment items to download the attachment
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {

            listPosition = position;
            listView = view;
            if (!permissionsGranted) {
                getPermissions(requestCodeFolder);
            } else {
                fetchAttachmentAsync(position, view);
            }
        }
    });

    //set onlong click listener to delete the attachment
    list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int pos, long id) {

            builder.setMessage(getApplication().getString(R.string.delete_query));
            builder.setCancelable(true);

            builder.setPositiveButton(getResources().getString(R.string.yes),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            deleteAttachment(pos);
                            dialog.dismiss();
                        }
                    });
            builder.setNegativeButton(getResources().getString(R.string.no),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
            return true;
        }
    });
}

From source file:ir.aarani.bazaar.billing.BillingProcessor.java

private List<SkuDetails> getSkuDetails(ArrayList<String> productIdList, String purchaseType) {
    if (billingService != null && productIdList != null && productIdList.size() > 0) {
        try {//from  w w  w .  ja v  a  2s. c om
            Bundle products = new Bundle();
            products.putStringArrayList(Constants.PRODUCTS_LIST, productIdList);
            Bundle skuDetails = billingService.getSkuDetails(Constants.GOOGLE_API_VERSION, contextPackageName,
                    purchaseType, products);
            int response = skuDetails.getInt(Constants.RESPONSE_CODE);

            if (response == Constants.BILLING_RESPONSE_RESULT_OK) {
                ArrayList<SkuDetails> productDetails = new ArrayList<SkuDetails>();
                List<String> detailsList = skuDetails.getStringArrayList(Constants.DETAILS_LIST);
                if (detailsList != null)
                    for (String responseLine : detailsList) {
                        JSONObject object = new JSONObject(responseLine);
                        SkuDetails product = new SkuDetails(object);
                        productDetails.add(product);
                    }
                return productDetails;

            } else {
                if (eventHandler != null)
                    eventHandler.onBillingError(response, null);
                Log.e(LOG_TAG, String.format("Failed to retrieve info for %d products, %d",
                        productIdList.size(), response));
            }
        } catch (Exception e) {
            Log.e(LOG_TAG, "Failed to call getSkuDetails", e);
            if (eventHandler != null)
                eventHandler.onBillingError(Constants.BILLING_ERROR_SKUDETAILS_FAILED, e);
        }
    }
    return null;
}

From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java

@Override
public void onEvent(int eventType, Bundle params) {
    switch (eventType) {
    case EVENT_ERROR:
        String reason = params.get("reason") + "";
        showToast("EVENT_ERROR: " + reason);
        break;/*  w w w  . j a  va 2s . c o m*/
    case VoiceRecognitionService.EVENT_ENGINE_SWITCH:
        int type = params.getInt("engine_type");
        showToast("*?" + (type == 0 ? "" : ""));
        break;
    }
}

From source file:de.uhrenbastler.watchcheck.ui.LogDialog.java

public LogDialog(Context context, Bundle logData) {
    super(context);

    setContentView(R.layout.log_dialog);
    setTitle(getContext().getString(R.string.enterLog));
    setCancelable(true);/*from   w  w w. ja v a  2 s .co m*/

    Button buttonSave = (Button) findViewById(R.id.buttonSave);
    buttonSave.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            makeLogEntry();
            saved = true;
            dismiss();
        }
    });

    watchId = logData.getInt(ATTR_WATCH_ID);
    deviation = logData.getDouble(ATTR_DEVIATION);
    modeNtp = logData.getBoolean(ATTR_MODE_NTP);
    localTime = (GregorianCalendar) logData.get(ATTR_LOCAL_TIME);
    ntpTime = (GregorianCalendar) logData.get(ATTR_NTP_TIME);
    lastLog = (Log) logData.get(ATTR_LAST_LOG);

    Logger.debug("watchId=" + watchId + ", deviation=" + deviation + ", modeNtp=" + modeNtp + ", localTime="
            + localTime.getTime() + ", ntpTime=" + (ntpTime != null ? ntpTime.getTime() : "NULL") + ", lastLog="
            + lastLog);

    TextView textDeviation = (TextView) findViewById(R.id.textViewDeviationValue);
    DecimalFormat df = new DecimalFormat("#.#");

    textDeviation.setText(
            (deviation > 0 ? "+" : deviation < 0 ? "-" : "+-") + df.format(Math.abs(deviation)) + " sec.");

    positionSpinner = (Spinner) findViewById(R.id.logSpinnerPosition);
    ArrayAdapter<?> positionAdapter = ArrayAdapter.createFromResource(getContext(), R.array.positions,
            android.R.layout.simple_spinner_item);
    positionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    positionSpinner.setAdapter(positionAdapter);

    if (lastLog != null && lastLog.getPosition() != null)
        positionSpinner.setSelection(ArrayUtils.indexOf(POSITIONARR, lastLog.getPosition()));
    else
        positionSpinner.setSelection(0);

    temperatureSpinner = (Spinner) findViewById(R.id.logSpinnerTemperature);
    ArrayAdapter<?> temperatureAdapter = ArrayAdapter.createFromResource(getContext(), R.array.temperatures,
            android.R.layout.simple_spinner_item);
    temperatureAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    temperatureSpinner.setAdapter(temperatureAdapter);

    if (lastLog != null)
        temperatureSpinner.setSelection(ArrayUtils.indexOf(TEMPARR, lastLog.getTemperature()));
    else
        temperatureSpinner.setSelection(0);

    comment = (EditText) findViewById(R.id.logComment);

    startFlag = (CheckBox) findViewById(R.id.logCheckBoxNewPeriod);
    startFlag.setChecked(lastLog == null);
    startFlag.setEnabled(lastLog != null);
}