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:com.tigerpenguin.places.model.Geometry.java

public Geometry(Parcel in) {
    location = in.readParcelable(PlaceLocation.class.getClassLoader());
    viewports = new HashMap<String, PlaceLocation>();
    Bundle bundle = in.readBundle(PlaceLocation.class.getClassLoader());
    if (bundle != null) {
        for (String key : bundle.keySet()) {
            viewports.put(key, (PlaceLocation) bundle.getParcelable(key));
        }/*from w  ww.  jav  a2 s.c om*/
    }
}

From source file:com.richtodd.android.quiltdesign.app.OpenRepositoryActivity.java

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

    Intent intent = getIntent();//  w  ww.  j a va2 s .c o m
    Bundle extras = intent.getExtras();
    if (extras.containsKey(Intent.EXTRA_STREAM)) {
        Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
        try {
            JSONObject jsonObject = JSONUtility.loadJSONObject(getContentResolver(), uri);

            m_repository = new JSONRepository(jsonObject, new QuiltDesignThumbnailProvider());
        } catch (RepositoryException e) {
            Handle.asRuntimeError(e);
        }
    }

    m_text_theme_count = (TextView) findViewById(R.id.text_theme_count);
    m_text_block_count = (TextView) findViewById(R.id.text_block_count);
    m_text_quilt_count = (TextView) findViewById(R.id.text_quilt_count);

    m_radio_import_new = (RadioButton) findViewById(R.id.radio_import_new);
    m_radio_import_replace = (RadioButton) findViewById(R.id.radio_import_replace);
    m_radio_import_merge = (RadioButton) findViewById(R.id.radio_import_merge);

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

        @Override
        public void onClick(View v) {

            try {
                Repository repository = Repository.getDefaultRepository(OpenRepositoryActivity.this);
                repository.merge(m_repository, getMergeMode());

                Toast.makeText(OpenRepositoryActivity.this, getString(R.string.toast_openRepository_success),
                        Toast.LENGTH_SHORT).show();

                finish();
            } catch (RepositoryException e) {
                Handle.asRuntimeError(e);
            }
        }
    });

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

        @Override
        public void onClick(View v) {
            finish();
        }
    });

    if (m_repository != null) {
        try {
            m_text_theme_count.setText(Integer.toString(m_repository.getThemes().getCount()));
            m_text_block_count.setText(Integer.toString(m_repository.getBlocks().getCount()));
            m_text_quilt_count.setText(Integer.toString(m_repository.getQuilts().getCount()));
        } catch (RepositoryException e) {
            Handle.asRuntimeError(e);
        }
    } else {
        m_text_theme_count.setText("0");
        m_text_block_count.setText("0");
        m_text_quilt_count.setText("0");
    }
}

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

public void assertReceivedContent(Uri expectedUri, final int expectedPageId) {
    mReplyLatch.assertHasItem(new Matcher<Pair<Integer, Cursor>>() {
        @Override/* ww  w . j a  v a  2  s . c o  m*/
        public boolean matches(Pair<Integer, Cursor> value) {
            return expectedPageId == value.first;
        }
    });
    List<Pair<Integer, Cursor>> collected = mReplyLatch.getCollected();
    Cursor cursor = null;

    for (Pair<Integer, Cursor> pair : collected) {
        if (expectedPageId == pair.first) {
            cursor = pair.second;
        }
    }

    assertEquals(0, cursor.getCount()); // we don't add any records to our test cursor.
    Bundle extras = cursor.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey(URI_KEY));
    assertEquals(extras.getParcelable(URI_KEY), expectedUri);
    assertTrue(extras.containsKey(URI_PAGE_ID));
    assertEquals(extras.getInt(URI_PAGE_ID), expectedPageId);
}

From source file:com.activiti.android.ui.fragments.comment.CommentsFoundationFragment.java

protected void onRetrieveParameters(Bundle bundle) {
    task = bundle.getParcelable(ARGUMENT_TASK);
    taskId = (task != null) ? task.id : BundleUtils.getString(bundle, ARGUMENT_TASK_ID);
    processId = BundleUtils.getString(bundle, ARGUMENT_PROCESS_ID);
    isCreate = BundleUtils.getBoolean(bundle, ARGUMENT_CREATE);
    isReadOnly = BundleUtils.getBoolean(bundle, ARGUMENT_RO);
}

From source file:angeloid.dreamnarae.TTS_Biling.java

void Biling_Friends() {
    try {//  w w  w  .  ja v a 2s  .c  om
        // Query Already Purchased
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        ArrayList<String> ownedSkus = null;

        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

        // Purchase it

        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));

        // Check
        ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

    } catch (Exception e) {
    }
}

From source file:angeloid.dreamnarae.TTS_Biling.java

void Biling_Narae() {
    try {//from   w  w w. j av  a2  s .  c  om
        // Query Already Purchased
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        ArrayList<String> ownedSkus = null;

        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

        // Purchase it

        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));

        // Check
        ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

    } catch (Exception e) {
    }
}

From source file:com.arminsam.sunshine.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
    }/*  w w  w  .  ja  va  2 s .  c o  m*/

    View 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);
    return rootView;
}

From source file:com.developers.pnp.lilly.app.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   ww  w.j av a 2  s  . c om

    View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    mIconView = (ImageView) rootView.findViewById(R.id.detail_icon);
    mNameView = (TextView) rootView.findViewById(R.id.detail_name_textview);
    mTypeView = (TextView) rootView.findViewById(R.id.detail_type_textview);
    mRatingView = (TextView) rootView.findViewById(R.id.detail_rating_textview);
    mLatLngView = (TextView) rootView.findViewById(R.id.detail_latlng_textview);

    mRatingBarView = (RatingBar) rootView.findViewById(R.id.rating_bar_view);

    mGoogleMapFrag = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
    if (mGoogleMapFrag != null)
        mGoogleMapFrag.getView().setVisibility(View.INVISIBLE);

    return rootView;
}

From source file:com.craftloom.android.sunshine.app.DetailFragment.java

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

    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
    }//www  .j  ava  2  s . co m
    View 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);
    return rootView;
}

From source file:fr.cph.stock.android.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "MainActivity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//  w  w w  .ja va 2s  .  c  o m

    Bundle b = getIntent().getExtras();
    portfolio = b.getParcelable("portfolio");

    ada = new MainListAdapter(this, portfolio);
    listView = (ListView) findViewById(R.id.mainList);
    listView.setAdapter(ada);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            Intent intent;
            switch (position) {
            case 0:
                intent = new Intent(getBaseContext(), AccountActivity.class);
                intent.putExtra("portfolio", portfolio);
                startActivityForResult(intent, MainActivity.ACCOUNT_REQUEST);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            case 1:
                intent = new Intent(getBaseContext(), EquityActivity.class);
                intent.putExtra("portfolio", portfolio);
                startActivityForResult(intent, MainActivity.EQUITY_REQUEST);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            case 2:
                intent = new Intent(getBaseContext(), OverallActivity.class);
                intent.putExtra("portfolio", portfolio);
                startActivityForResult(intent, MainActivity.OVERALL_REQUEST);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            }
        }

    });

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);

    errorView = (TextView) findViewById(R.id.errorMessage);
    errorView.setOnClickListener(new ErrorMainOnClickListener(listView, errorView));
    EasyTracker.getInstance().setContext(this);

    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}