Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

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

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

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

Usage

From source file:com.tigerpenguin.places.model.Geometry.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeParcelable(location, flags);
    // Android documentation recommends using writeBundle() instead of writeMap()
    Bundle bundle = null;
    if (viewports != null && viewports.size() > 0) {
        bundle = new Bundle();
        for (Map.Entry<String, PlaceLocation> viewport : viewports.entrySet()) {
            bundle.putParcelable(viewport.getKey(), viewport.getValue());
        }//from   ww  w.j  av  a2  s  . c o  m
    }
    dest.writeBundle(bundle);
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java

/**
 * {@inheritDoc}//  ww  w .j  av  a 2s.  c  om
 */
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
        String[] requiredFeatures, Bundle options) {
    final Intent intent = getAuthenticator(mContext);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java

/**
 * {@inheritDoc}//  ww  w  .  j  a  va  2  s. c o m
 */
@Override
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType,
        Bundle loginOptions) {
    final Intent intent = getAuthenticator(mContext);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, false);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:edu.mit.mobile.android.locast.accounts.Authenticator.java

/**
 * {@inheritDoc}/*  w  ww .  j  av  a  2s  .c o m*/
 */
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
        String[] requiredFeatures, Bundle options) {
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.EXTRA_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:edu.mit.mobile.android.locast.accounts.Authenticator.java

/**
 * {@inheritDoc}//w w w  .  j  ava  2  s  .c o  m
 */
@Override
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType,
        Bundle loginOptions) {
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AuthenticatorActivity.EXTRA_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, false);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java

/**
 * {@inheritDoc}/*from   w w  w. j a  va  2s .  c o  m*/
 */
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
    if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) {
        final String password = options.getString(AccountManager.KEY_PASSWORD);
        final Bundle verified = onlineConfirmPassword(account, password);
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null);
        return result;
    }
    // Launch AuthenticatorActivity to confirm credentials
    final Intent intent = getAuthenticator(mContext);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:com.android.xbrowser.DownloadTouchIcon.java

@Override
public Void doInBackground(String... values) {
    if (mContentResolver != null) {
        mCursor = Bookmarks.queryCombinedForUrl(mContentResolver, mOriginalUrl, mUrl);
    }/*from w ww . j av a 2  s .  com*/

    boolean inDatabase = mCursor != null && mCursor.getCount() > 0;

    String url = values[0];

    if (inDatabase || mMessage != null) {
        AndroidHttpClient client = null;
        HttpGet request = null;

        try {
            client = AndroidHttpClient.newInstance(mUserAgent);
            HttpHost httpHost = Proxy.getPreferredHttpHost(mContext, url);
            if (httpHost != null) {
                ConnRouteParams.setDefaultProxy(client.getParams(), httpHost);
            }

            request = new HttpGet(url);

            // Follow redirects
            HttpClientParams.setRedirecting(client.getParams(), true);

            HttpResponse response = client.execute(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    InputStream content = entity.getContent();
                    if (content != null) {
                        Bitmap icon = BitmapFactory.decodeStream(content, null, null);
                        if (inDatabase) {
                            storeIcon(icon);
                        } else if (mMessage != null) {
                            Bundle b = mMessage.getData();
                            b.putParcelable(BrowserContract.Bookmarks.TOUCH_ICON, icon);
                        }
                    }
                }
            }
        } catch (Exception ex) {
            if (request != null) {
                request.abort();
            }
        } finally {
            if (client != null) {
                client.close();
            }
        }
    }

    if (mCursor != null) {
        mCursor.close();
    }

    if (mMessage != null) {
        mMessage.sendToTarget();
    }

    return null;
}

From source file:com.afg.MngProductContentProvider.Fragments.ListProduct_Fragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mList = getListView();//from  www  .ja va 2  s  . c  om
    setListAdapter(mAdapter);

    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int i, long l) {
            Bundle potatoe = new Bundle();
            potatoe.putParcelable(PRODUCT_KEY, (Product) parent.getItemAtPosition(i));
            mCallback.showManageProduct(potatoe);
        }
    });

    mList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            mItemParent = adapterView;
            mItemPos = i;

            popup = new PopupMenu(getContext(), view);
            popup.setGravity(Gravity.END);
            popup.getMenuInflater().inflate(R.menu.delete_menu, popup.getMenu());

            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    p = (Product) mItemParent.getItemAtPosition(mItemPos);
                    mCallback.showDeletePopUp(p);
                    return true;
                }
            });
            popup.show();
            return true;
        }
    });

    mFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCallback.showManageProduct(null);
        }
    });
}

From source file:edu.mit.mobile.android.locast.accounts.Authenticator.java

/**
 * {@inheritDoc}//from  w ww . j av a2  s  .  c  o  m
 */
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
    if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) {
        final String password = options.getString(AccountManager.KEY_PASSWORD);
        final Bundle verified = onlineConfirmPassword(account, password);
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null);
        return result;
    }
    // Launch AuthenticatorActivity to confirm credentials
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:cn.wjh1119.bestnews.ui.fragment.DetailFragment.java

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

    //??//www. j a va 2s .  co m
    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
        mTransitionAnimation = arguments.getBoolean(DetailFragment.DETAIL_TRANSITION_ANIMATION, false);
    }

    View rootView = inflater.inflate(R.layout.fragment_detail_start, container, false);

    //?reviewFragment?
    Fragment reviewFragment = getChildFragmentManager().findFragmentByTag(REVIEWFRAGMENT_TAG);
    if (reviewFragment == null) {
        Logger.i(LOG_TAG, "add new reviewFragment !!");
        Bundle args = new Bundle();
        args.putParcelable(ReviewFragment.REVIEW_URI, mUri);

        reviewFragment = new ReviewFragment();
        reviewFragment.setArguments(args);

        FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.container_review, reviewFragment, REVIEWFRAGMENT_TAG).commit();
    } else {
        Logger.i(LOG_TAG, "found existing reviewFragment, no need to add it again !!");
    }

    //view
    ButterKnife.bind(this, rootView);

    imageManager = ImageManager.getSingleton(getContext());

    return rootView;
}