Example usage for android.os Bundle putByteArray

List of usage examples for android.os Bundle putByteArray

Introduction

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

Prototype

@Override
public void putByteArray(@Nullable String key, @Nullable byte[] value) 

Source Link

Document

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

Usage

From source file:com.evandroid.musica.MainLyricActivity.java

public void updateLyricsFragment(int outAnim, String... params) { // Should only be called from SearchFragment or IdDecoder
    String artist = params[0];//from w ww.  j  a  v  a  2  s .c o  m
    String song = params[1];
    String url = null;
    if (params.length > 2)
        url = params[2];
    LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager()
            .findFragmentByTag(LYRICS_FRAGMENT_TAG);
    if (lyricsViewFragment != null)
        lyricsViewFragment.fetchLyrics(artist, song, url);
    else {
        Lyrics lyrics = new Lyrics(Lyrics.SEARCH_ITEM);
        lyrics.setArtist(artist);
        lyrics.setTitle(song);
        lyrics.setURL(url);
        Bundle lyricsBundle = new Bundle();
        try {
            if (artist != null && song != null)
                lyricsBundle.putByteArray("lyrics", lyrics.toBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
        lyricsViewFragment = new LyricsViewFragment();
        lyricsViewFragment.setArguments(lyricsBundle);

        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        Fragment activeFragment = getDisplayedFragment(getActiveFragments());
        if (activeFragment != null) {
            prepareAnimations(activeFragment);
            fragmentTransaction.hide(activeFragment);
        }
        fragmentTransaction.add(R.id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG);
        lyricsViewFragment.isActiveFragment = true;
        fragmentTransaction.commit();
    }
}

From source file:org.comu.homescreen.Hackbook.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    /*/* www  . j av  a  2  s.  c  o  m*/
     * if this is the activity result from authorization flow, do a call back to authorizeCallback
     * Source Tag: login_tag
     */
    case AUTHORIZE_ACTIVITY_RESULT_CODE: {
        Utility.mFacebook.authorizeCallback(requestCode, resultCode, data);
        break;
    }
    /*
     * if this is the result for a photo picker from the gallery, upload the image after scaling it.
     * You can use the Utility.scaleImage() function for scaling
     */
    case PICK_EXISTING_PHOTO_RESULT_CODE: {
        if (resultCode == Activity.RESULT_OK) {
            Uri photoUri = data.getData();
            if (photoUri != null) {
                Bundle params = new Bundle();
                try {
                    params.putByteArray("photo", Utility.scaleImage(getApplicationContext(), photoUri));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                params.putString("caption", "FbAPIs Sample App photo upload");
                Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(), null);
            } else {
                Toast.makeText(getApplicationContext(), "Error selecting image from the gallery.",
                        Toast.LENGTH_SHORT).show();
            }
        } else {
            Toast.makeText(getApplicationContext(), "No image selected for upload.", Toast.LENGTH_SHORT).show();
        }
        break;
    }
    }
}

From source file:io.imoji.sdk.editor.fragment.ImojiEditorFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (mPreScaleBitmap != null && mBitmapRetainerFragment != null) {
        mBitmapRetainerFragment.mPreScaledBitmap = mPreScaleBitmap;
    }// w ww. j av a  2s. c om

    outState.putByteArray(EDITOR_STATE_BUNDLE_ARG_KEY, mStateData);
    outState.putBoolean(IS_PROCESSING_BUNDLE_ARG_KEY, mIsProcessing);

    super.onSaveInstanceState(outState);

}

From source file:app.com.example.android.sunshine.ItemChoiceManager.java

public void onSaveInstanceState(Bundle outState) {
    Parcel outParcel = Parcel.obtain();//from ww  w.  j  a  v  a2  s .com
    outParcel.writeSparseBooleanArray(mCheckStates);
    final int numStates = mCheckedIdStates.size();
    outParcel.writeInt(numStates);
    for (int i = 0; i < numStates; i++) {
        outParcel.writeLong(mCheckedIdStates.keyAt(i));
        outParcel.writeInt(mCheckedIdStates.valueAt(i));
    }
    byte[] states = outParcel.marshall();
    outState.putByteArray(SELECTED_ITEMS_KEY, states);
    outParcel.recycle();
}

From source file:com.facebook.android.Hackbook.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    /*//from w w w  .jav  a  2  s  . c o  m
     * if this is the activity result from authorization flow, do a call
     * back to authorizeCallback Source Tag: login_tag
     */
    case AUTHORIZE_ACTIVITY_RESULT_CODE: {
        Utility.mFacebook.authorizeCallback(requestCode, resultCode, data);
        break;
    }
    /*
     * if this is the result for a photo picker from the gallery, upload
     * the image after scaling it. You can use the Utility.scaleImage()
     * function for scaling
     */
    case PICK_EXISTING_PHOTO_RESULT_CODE: {
        if (resultCode == Activity.RESULT_OK) {
            Uri photoUri = data.getData();
            if (photoUri != null) {
                Bundle params = new Bundle();
                try {
                    params.putByteArray("photo", Utility.scaleImage(getApplicationContext(), photoUri));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                params.putString("caption", "FbAPIs Sample App photo upload");
                Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(), null);
            } else {
                Toast.makeText(getApplicationContext(), "Error selecting image from the gallery.",
                        Toast.LENGTH_SHORT).show();
            }
        } else {
            Toast.makeText(getApplicationContext(), "No image selected for upload.", Toast.LENGTH_SHORT).show();
        }
        break;
    }
    }
}

From source file:mobisocial.musubi.ui.FeedDetailsActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putString("name", mNameEditText.getText().toString());
    outState.putByteArray("thumbnailBytes", mThumbnailBytes);
    outState.putBoolean("detailsChanged", mDetailsChanged);
}

From source file:org.hopestarter.wallet.ui.send.SweepWalletFragment.java

private void saveInstanceState(final Bundle outState) {
    outState.putSerializable("state", state);
    if (walletToSweep != null)
        outState.putByteArray("wallet_to_sweep", WalletUtils.walletToByteArray(walletToSweep));
    if (sentTransaction != null)
        outState.putSerializable("sent_transaction_hash", sentTransaction.getHash());
}

From source file:org.sufficientlysecure.keychain.ui.CreateKeyActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putString(EXTRA_NAME, mName);
    outState.putString(EXTRA_EMAIL, mEmail);
    outState.putStringArrayList(EXTRA_ADDITIONAL_EMAILS, mAdditionalEmails);
    outState.putParcelable(EXTRA_PASSPHRASE, mPassphrase);
    outState.putBoolean(EXTRA_FIRST_TIME, mFirstTime);
    outState.putBoolean(EXTRA_CREATE_SECURITY_TOKEN, mCreateSecurityToken);
    outState.putByteArray(EXTRA_SECURITY_TOKEN_AID, mSecurityTokenAid);
    outState.putParcelable(EXTRA_SECURITY_TOKEN_PIN, mSecurityTokenPin);
    outState.putParcelable(EXTRA_SECURITY_TOKEN_ADMIN_PIN, mSecurityTokenAdminPin);
}

From source file:com.evandroid.musica.fragment.LyricsViewFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mLyrics != null)
        try {//from w  ww. ja v  a  2  s .  c o m
            outState.putByteArray("lyrics", mLyrics.toBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }

    outState.putBoolean("refreshFabEnabled", getActivity().findViewById(R.id.refresh_fab).isEnabled());

}