Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:co.carlosjimenez.android.currencyalerts.app.AddAlertFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater

    LayoutInflater inflater = getActivity().getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_add_alarm, null);
    ButterKnife.bind(this, dialogView);

    Bundle arguments = getArguments();
    if (arguments != null) {
        mCurrencyFrom = arguments.getParcelable(DetailActivityFragment.CURRENCY_FROM);
        mCurrencyTo = arguments.getParcelable(DetailActivityFragment.CURRENCY_TO);
    }// w  ww .j a  v  a2 s  .  c om

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.alarm_period_labels, R.layout.spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    mSpPeriod.setAdapter(adapter);

    alertValues = Utility.getAlertSettings(getContext(), false);

    if (alertValues.getCurrencyFrom().equals(mCurrencyFrom)
            && alertValues.getCurrencyTo().equals(mCurrencyTo)) {
        setSelectedPeriod(String.valueOf(alertValues.getPeriod()));
        mTvFluctuation.setText(String.valueOf(alertValues.getFluctuation()));
    } else {
        alertValues = Utility.getAlertSettings(getContext(), true);
        alertValues.clearAverage();
    }

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(dialogView)
            // Add action buttons
            .setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    alertValues.setEnabled(true);
                    alertValues.setCurrencyFrom(mCurrencyFrom);
                    alertValues.setCurrencyTo(mCurrencyTo);
                    alertValues.setPeriod(Integer.parseInt(mSelectedPeriod));
                    alertValues.setFluctuation(Float.parseFloat(mTvFluctuation.getText().toString()));

                    new UpdateAlarmTask(getActivity()).execute(alertValues);
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    AddAlertFragment.this.getDialog().cancel();
                }
            });

    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();

    return alertDialog;
}

From source file:ca.qc.bdeb.info.horus.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
    }//from  w  ww  . j  av a  2  s  .com

    rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    mIconView = (ImageView) rootView.findViewById(R.id.detail_icon);
    mDateView = (TextView) rootView.findViewById(R.id.detail_date_textview);
    mFriendlyDateView = (TextView) rootView.findViewById(R.id.detail_day_textview);
    mDescriptionView = (TextView) rootView.findViewById(R.id.detail_forecast_textview);
    mHighTempView = (TextView) rootView.findViewById(R.id.detail_high_textview);
    mLowTempView = (TextView) rootView.findViewById(R.id.detail_low_textview);
    mHumidityView = (TextView) rootView.findViewById(R.id.detail_humidity_textview);
    mWindView = (TextView) rootView.findViewById(R.id.detail_wind_textview);
    mPressureView = (TextView) rootView.findViewById(R.id.detail_pressure_textview);
    mScrollView = (ScrollView) rootView.findViewById(R.id.scrollViewDetail);

    return rootView;
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_trainer.SignTrainerPassiveFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.d(TAG, "onActivityCreated " + hashCode());
    super.onActivityCreated(savedInstanceState);
    if (null != savedInstanceState) {
        final Sign parcelledSign = savedInstanceState.getParcelable(KEY_CURRENT_SIGN);
        if (null != parcelledSign) {
            this.currentSign = parcelledSign;
            try {
                setupVideoView(this.currentSign, SOUND.OFF, CONTROLS.SHOW);
            } catch (VideoSetupException ex) {
                handleVideoCouldNotBeLoaded(ex);
            }// w  w w  . j  a v  a 2  s.com
        }
        final Boolean answerVisible = savedInstanceState.getBoolean(KEY_ANSWER_VISIBLE);
        Validate.notNull(answerVisible, "AnswerVisible should always be non-null in savedInstance bundle.");
        if (answerVisible && (null != this.currentSign)) {
            setVisibility(this.questionViews, View.GONE);
            setVisibility(this.answerViews, View.VISIBLE);
            setAnswerTextViews();
        } else {
            setVisibility(this.questionViews, View.VISIBLE);
            setVisibility(this.answerViews, View.GONE);
        }
    } else {
        this.loadRandomSignTask = new LoadRandomSignTask(getActivity());
        this.loadRandomSignTask.execute(this.currentSign);
    }
}

From source file:com.appeaser.sublimepicker.SublimePickerFragment.java

@Nullable
@Override// ww w.j  a va2s . com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*try {
    //getActivity().getLayoutInflater()
            //.inflate(R.layout.sublime_recurrence_picker, new FrameLayout(getActivity()), true);
    getActivity().getLayoutInflater()
            .inflate(R.layout.sublime_date_picker, new FrameLayout(getActivity()), true);
    } catch (Exception e) {
    e.printStackTrace();
    throw new RuntimeException();
    }*/

    mSublimePicker = (SublimePicker) getActivity().getLayoutInflater().inflate(R.layout.sublime_picker,
            container);

    // Retrieve SublimeOptions
    Bundle arguments = getArguments();
    SublimeOptions options = null;

    // Options can be null, in which case, default
    // options are used.
    if (arguments != null) {
        options = arguments.getParcelable("SUBLIME_OPTIONS");
    }

    mSublimePicker.initializePicker(options, mListener);
    return mSublimePicker;
}

From source file:com.tangrainc.inappbilling.InAppBillingHelper.java

public void startBuyIntent(Activity foregroundActivity, String productIdentifier, String payload)
        throws Exception {
    Bundle buyIntentBundle = _service.getBuyIntent(3, _context.getPackageName(), productIdentifier, "inapp",
            payload);//from  w w w.  j av  a2 s. c o  m
    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

    if (pendingIntent == null) {
        throw new Exception("Product already purchased!");
    }

    foregroundActivity.startIntentSenderForResult(pendingIntent.getIntentSender(), BUY_INTENT_REQUEST_CODE,
            new Intent(), 0, 0, 0);
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_trainer.SignTrainerActiveFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.d(TAG, "onActivityCreated " + hashCode());
    super.onActivityCreated(savedInstanceState);
    if (null != savedInstanceState) {
        final Sign parcelledSign = savedInstanceState.getParcelable(KEY_CURRENT_SIGN);
        if (null != parcelledSign)
            this.currentSign = parcelledSign;
        final Boolean answerVisible = savedInstanceState.getBoolean(KEY_ANSWER_VISIBLE);
        Validate.notNull(answerVisible, "AnswerVisible should always be non-null in savedInstance bundle.");
        if (answerVisible && (null != this.currentSign)) {
            setVisibility(this.questionViews, View.GONE);
            setVisibility(this.answerViews, View.VISIBLE);
            try {
                setupVideoView(this.currentSign, SOUND.ON, CONTROLS.SHOW);
            } catch (VideoSetupException ex) {
                handleVideoCouldNotBeLoaded(ex);
            }/*  w  w  w  .  j  av a  2 s  .  c om*/
            setAnswerTextViews();
        } else {
            setVisibility(this.questionViews, View.VISIBLE);
            if (null != this.currentSign)
                this.signQuestionTextDetail.setText(this.currentSign.getNameLocaleDe());
            setVisibility(this.answerViews, View.GONE);
        }
    } else {
        this.loadRandomSignTask = new LoadRandomSignTask(getActivity());
        this.loadRandomSignTask.execute(this.currentSign);
    }
}

From source file:com.cafe.fragment.SublimePickerFragment.java

@Nullable
@Override/*from  w w w. java 2s  . co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*try {
    //getActivity().getLayoutInflater()
            //.inflate(R.layout.sublime_recurrence_picker, new FrameLayout(getActivity()), true);
    getActivity().getLayoutInflater()
            .inflate(R.layout.sublime_date_picker, new FrameLayout(getActivity()), true);
    } catch (Exception e) {
    e.printStackTrace();
    throw new RuntimeException();
    }*/

    mSublimePicker = (SublimePicker) getActivity().getLayoutInflater().inflate(R.layout.sublime_picker,
            container);

    // Retrieve SublimeOptions
    Bundle arguments = getArguments();
    SublimeOptions options = null;

    // Options can be null, in which case, default
    // options are used.
    if (arguments != null) {
        options = arguments.getParcelable(KEY_SUBLIME_PICKER);
    }

    mSublimePicker.initializePicker(options, mListener);
    return mSublimePicker;
}

From source file:com.qrcode.app.zxing.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }/* ww w.  j  a v a  2  s . c o m*/
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//??????????

        try {
            activity.handleDecode((Result) message.obj, barcode);//???????        /***********************************************************************/
        } catch (JSONException e) {
            e.printStackTrace();
        }
        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    case R.id.launch_product_query:
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
        break;
    }
}

From source file:com.onebus.zxing.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }// w w  w  . j a  v  a2  s.com
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//

        try {
            activity.handleDecode((Result) message.obj, barcode);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } //?        /***********************************************************************/
        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    case R.id.launch_product_query:
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
        break;
    }
}

From source file:com.zxing.qrcode.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        // Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the
        // closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what
        // else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }/* w  w w .  j a  va  2  s  .  c  o  m*/
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);
        final String str_result = ((Result) message.obj).getText();
        System.out.println("====str_result====" + str_result);
        String match = "^[0-9]{13}";
        boolean b = str_result.matches(match);
        // Toast.makeText(activity, ""+b, 1).show();
        // activity.handleDecode((Result) message.obj, barcode);
        if (b) {
            String url = RequestUrls.TIAOXING_CODE_URL.replace("[code]", str_result);
            FinalHttp fh = new FinalHttp();
            fh.get(url, new AjaxCallBack<Object>() {
                @Override
                public void onSuccess(Object t) {
                    // TODO Auto-generated method stub
                    super.onSuccess(t);
                    try {

                        System.out.println("===TIAOXING_CODE_URL====" + new JSONObject(t.toString()));
                        Intent tagIntent = new Intent(activity, TagdetialActivity.class);
                        tagIntent.putExtra("jsonStr", t.toString());
                        tagIntent.putExtra("barcodes", str_result);
                        tagIntent.putExtra("eid", eid);
                        tagIntent.putExtra("tag_ids", tag_ids);
                        activity.startActivity(tagIntent);
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                @Override
                public void onFailure(Throwable t, String strMsg) {
                    // TODO Auto-generated method stub
                    super.onFailure(t, strMsg);
                }
            });
        } else {
            try {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                // //// intent.setPackage("com.tencent.mm");//
                intent.putExtra(Intent.EXTRA_SUBJECT, "share");
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                // // 
                // intent.setData(Uri.parse("http://weixin.qq.com/r/o3w_sRvEMSVOhwrSnyCH"));
                intent.setData(Uri.parse(str_result));
                activity.startActivity(intent);
            } catch (Exception e) {
                Toast.makeText(activity, R.string.no_wechat_rem, Toast.LENGTH_SHORT).show();
            }
        }

        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails,
        // start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    }
}