Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

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

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

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

Usage

From source file:fr.eyal.lib.data.service.DataLibService.java

/**
 * Send the result of a request to the linked {@link ServiceHelper}
 * //from w w w  . jav a 2 s .c o m
 * @param request the request
 * @param response the response
 * @param code the status of the request
 */
protected void sendResult(final DataLibRequest request, final BusinessResponse response, final int code) {
    Out.d(TAG, "sendResult");

    final Intent intent = request.intent;
    final ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra(INTENT_EXTRA_RECEIVER);

    if (receiver != null) {
        final Bundle b = new Bundle();

        if (response != null && response.response != null) {

            //if the Business Object have to be transmit inside the Bundle
            if (request.isParcelableMethodEnabled())
                b.putParcelable(ServiceHelper.RECEIVER_EXTRA_RESULT, response.response);

            //we add the request id to the response
            if (response.response instanceof ResponseBusinessObjectDAO) {
                ResponseBusinessObjectDAO r = (ResponseBusinessObjectDAO) response.response;
                b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, r._id);
            } else {
                //in case of no data cache, we set an invalid ID
                b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, BusinessObjectDAO.ID_INVALID);
            }

        } else {
            Out.e(TAG, "Unfined response");
        }

        //we copy the content of the response in the intent's bundle
        b.putInt(ServiceHelper.RECEIVER_EXTRA_REQUEST_ID, intent.getIntExtra(INTENT_EXTRA_REQUEST_ID, -1));
        b.putInt(ServiceHelper.RECEIVER_EXTRA_WEBSERVICE_TYPE,
                intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1));
        b.putInt(ServiceHelper.RECEIVER_EXTRA_RETURN_CODE, response.returnCode);
        b.putInt(ServiceHelper.RECEIVER_EXTRA_RESULT_CODE, response.status);
        b.putString(ServiceHelper.RECEIVER_EXTRA_RESULT_MESSAGE, "");

        receiver.send(code, b);
    }
}

From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java

public void addservice(String schoolid, String principal, String contact, String schoolcode, String address,
        String phone, String aedemail, String principalemail, String serviceid, int pos, String contactphone,
        String state, String city, String zip) {
    ll3.setBackgroundColor(getResources().getColor(R.color.White));
    ll2.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    ll5.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    ll4.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    ll1.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    ServiceCallsFragment myf = new ServiceCallsFragment();
    Bundle bundle = new Bundle();
    bundle.putString("schoolid", schoolid);
    bundle.putString("principal", principal);
    bundle.putString("contact", contact);
    bundle.putString("schoolcode", schoolcode);
    bundle.putString("address", address);
    bundle.putString("phone", phone);
    bundle.putString("servicecallid", serviceid);
    bundle.putString("contactemail", aedemail);
    bundle.putString("principalemail", principalemail);
    bundle.putInt("pos", pos);
    bundle.putString("contactphone", contactphone);
    bundle.putString("state", state);
    bundle.putString("city", city);
    bundle.putString("zip", zip);
    myf.setArguments(bundle);/*from   w  w w. ja  v  a 2s .  co  m*/
    transaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
    transaction.replace(R.id.frame, myf, "Servicecall");
    transaction.addToBackStack(null);
    transaction.commit();
}

From source file:fr.cobaltians.cobalt.fragments.CobaltFragment.java

/*************************************************************************************
  * DATE PICKER/*from   www  .j a  v a  2  s  .  c  o m*/
  ************************************************************************************/

private void showDatePickerDialog(int year, int month, int day, String title, String delete, String cancel,
        String validate, String callbackID) {
    Bundle args = new Bundle();
    args.putInt(CobaltDatePickerFragment.ARG_YEAR, year);
    args.putInt(CobaltDatePickerFragment.ARG_MONTH, month);
    args.putInt(CobaltDatePickerFragment.ARG_DAY, day);
    args.putString(CobaltDatePickerFragment.ARG_TITLE, title);
    args.putString(CobaltDatePickerFragment.ARG_DELETE, delete);
    args.putString(CobaltDatePickerFragment.ARG_CANCEL, cancel);
    args.putString(CobaltDatePickerFragment.ARG_VALIDATE, validate);
    args.putString(CobaltDatePickerFragment.ARG_CALLBACK_ID, callbackID);

    CobaltDatePickerFragment fragment = new CobaltDatePickerFragment();
    fragment.setArguments(args);
    fragment.setListener(this);

    fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "datePicker");
}

From source file:cw.kop.autobackground.sources.SourceListFragment.java

private void startEditFragment(final View view, final int position) {
    sourceList.setOnItemClickListener(null);
    sourceList.setEnabled(false);//from   w ww  . j av a  2  s.co  m
    listAdapter.saveData();

    Source dataItem = listAdapter.getItem(position);
    final SourceInfoFragment sourceInfoFragment = new SourceInfoFragment();
    sourceInfoFragment.setImageDrawable(((ImageView) view.findViewById(R.id.source_image)).getDrawable());
    Bundle arguments = new Bundle();
    arguments.putInt("position", position);
    arguments.putString("type", dataItem.getType());
    arguments.putString("title", dataItem.getTitle());
    arguments.putString("data", dataItem.getData());
    arguments.putInt("num", dataItem.getNum());
    arguments.putBoolean("use", dataItem.isUse());
    arguments.putBoolean("preview", dataItem.isPreview());
    String imageFileName = dataItem.getImageFile().getAbsolutePath();
    if (imageFileName != null && imageFileName.length() > 0) {
        arguments.putString("image", imageFileName);
    } else {
        arguments.putString("image", "");
    }

    arguments.putBoolean("use_time", dataItem.isUseTime());
    arguments.putString("time", dataItem.getTime());

    sourceInfoFragment.setArguments(arguments);

    final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container);
    final CardView sourceCard = (CardView) view.findViewById(R.id.source_card);
    final View imageOverlay = view.findViewById(R.id.source_image_overlay);
    final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title);
    final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button);
    final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button);
    final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button);
    final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container);

    final float cardStartShadow = sourceCard.getPaddingLeft();
    final float viewStartHeight = sourceContainer.getHeight();
    final float viewStartY = view.getY();
    final int viewStartPadding = view.getPaddingLeft();
    final float textStartX = sourceTitle.getX();
    final float textStartY = sourceTitle.getY();
    final float textTranslationY = sourceTitle.getHeight(); /*+ TypedValue.applyDimension(
                                                            TypedValue.COMPLEX_UNIT_DIP,
                                                            8,
                                                            getResources().getDisplayMetrics());*/

    Animation animation = new Animation() {

        private boolean needsFragment = true;

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {

            if (needsFragment && interpolatedTime >= 1) {
                needsFragment = false;
                getFragmentManager().beginTransaction()
                        .add(R.id.content_frame, sourceInfoFragment, "source_info_fragment")
                        .addToBackStack(null).setTransition(FragmentTransaction.TRANSIT_NONE).commit();
            }
            int newPadding = Math.round(viewStartPadding * (1 - interpolatedTime));
            int newShadowPadding = (int) (cardStartShadow * (1.0f - interpolatedTime));
            sourceCard.setShadowPadding(newShadowPadding, 0, newShadowPadding, 0);
            ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).topMargin = newShadowPadding;
            ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).bottomMargin = newShadowPadding;
            ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).leftMargin = newShadowPadding;
            ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).rightMargin = newShadowPadding;
            view.setPadding(newPadding, 0, newPadding, 0);
            view.setY(viewStartY - interpolatedTime * viewStartY);
            ViewGroup.LayoutParams params = sourceContainer.getLayoutParams();
            params.height = (int) (viewStartHeight + (screenHeight - viewStartHeight) * interpolatedTime);
            sourceContainer.setLayoutParams(params);
            sourceTitle.setY(textStartY + interpolatedTime * textTranslationY);
            sourceTitle.setX(textStartX + viewStartPadding - newPadding);
            deleteButton.setAlpha(1.0f - interpolatedTime);
            viewButton.setAlpha(1.0f - interpolatedTime);
            editButton.setAlpha(1.0f - interpolatedTime);
            sourceExpandContainer.setAlpha(1.0f - interpolatedTime);
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (needsListReset) {
                Parcelable state = sourceList.onSaveInstanceState();
                sourceList.setAdapter(null);
                sourceList.setAdapter(listAdapter);
                sourceList.onRestoreInstanceState(state);
                sourceList.setOnItemClickListener(SourceListFragment.this);
                sourceList.setEnabled(true);
                needsListReset = false;
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
            AppSettings.getDialogColor(appContext),
            getResources().getColor(AppSettings.getBackgroundColorResource()));
    cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue());
        }

    });

    ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
            sourceTitle.getCurrentTextColor(), getResources().getColor(R.color.BLUE_OPAQUE));
    titleColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            sourceTitle.setTextColor((Integer) animation.getAnimatedValue());
        }

    });

    ValueAnimator titleShadowAlphaAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
            AppSettings.getColorFilterInt(appContext), getResources().getColor(android.R.color.transparent));
    titleShadowAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            sourceTitle.setShadowLayer(4, 0, 0, (Integer) animation.getAnimatedValue());
        }
    });

    ValueAnimator imageOverlayAlphaAnimation = ValueAnimator.ofFloat(imageOverlay.getAlpha(), 0f);
    imageOverlayAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            imageOverlay.setAlpha((Float) animation.getAnimatedValue());
        }
    });

    int transitionTime = INFO_ANIMATION_TIME;

    DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f);

    animation.setDuration(transitionTime);
    cardColorAnimation.setDuration(transitionTime);
    titleColorAnimation.setDuration(transitionTime);
    titleShadowAlphaAnimation.setDuration(transitionTime);

    animation.setInterpolator(decelerateInterpolator);
    cardColorAnimation.setInterpolator(decelerateInterpolator);
    titleColorAnimation.setInterpolator(decelerateInterpolator);
    titleShadowAlphaAnimation.setInterpolator(decelerateInterpolator);

    if (imageOverlay.getAlpha() > 0) {
        imageOverlayAlphaAnimation.start();
    }

    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (needsListReset) {
                Parcelable state = sourceList.onSaveInstanceState();
                sourceList.setAdapter(null);
                sourceList.setAdapter(listAdapter);
                sourceList.onRestoreInstanceState(state);
                sourceList.setOnItemClickListener(SourceListFragment.this);
                sourceList.setEnabled(true);
                needsListReset = false;
            }
        }
    }, (long) (transitionTime * 1.1f));

    needsListReset = true;
    view.startAnimation(animation);
    cardColorAnimation.start();
    titleColorAnimation.start();
    titleShadowAlphaAnimation.start();
}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults)
        throws JSONException {
    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            int errorCode = BackgroundGeolocationService.LOCATION_ERROR_DENIED;
            PluginResult result = new PluginResult(PluginResult.Status.ERROR, errorCode);
            if (requestCode == REQUEST_ACTION_START) {
                if (startCallback != null) {
                    startCallback.sendPluginResult(result);
                    startCallback = null;
                }//from  w  ww  .j a v a2  s .c  o m
            } else if (requestCode == REQUEST_ACTION_GET_CURRENT_POSITION) {
                Bundle event = new Bundle();
                event.putString("name", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION);
                event.putInt("code", errorCode);
                onLocationError(event);
            }
            return;
        }
    }
    switch (requestCode) {
    case REQUEST_ACTION_START:
        setEnabled(true);
        break;
    case REQUEST_ACTION_GET_CURRENT_POSITION:
        startService(requestCode);
        break;
    }
}

From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java

public void addnewinstall(ArrayList serialnums, String schoolid, String principal, String contact,
        String schoolcode, String address, String phone, String aedemail, String principalemail, String drillis,
        int pos, String contactphone, String state, String city, String zip) {
    ll4.setBackgroundColor(getResources().getColor(R.color.White));
    ll2.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    ll3.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    ll1.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    ll5.setBackgroundColor(getResources().getColor(R.color.FullTransparent));
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    Addnewinstall myf = new Addnewinstall();
    Bundle bundle = new Bundle();
    bundle.putString("schoolid", schoolid);
    bundle.putString("principal", principal);
    bundle.putString("contact", contact);
    bundle.putString("schoolcode", schoolcode);
    bundle.putString("address", address);
    bundle.putString("phone", phone);
    bundle.putString("contactemail", aedemail);
    bundle.putString("principalemail", principalemail);
    bundle.putString("installid", drillis);
    bundle.putStringArrayList("serialnumbers", serialnums);
    bundle.putInt("pos", pos);
    bundle.putString("contactphone", contactphone);
    bundle.putString("state", state);
    bundle.putString("city", city);
    bundle.putString("zip", zip);
    myf.setArguments(bundle);/* w w  w .  ja va  2 s .  co  m*/
    transaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
    transaction.replace(R.id.frame, myf, "Newinstall");
    transaction.addToBackStack(null);
    transaction.commit();
}

From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putString(Constants.MAIN_NOW_PLAYING, nowPlayingFragment.getTag());
    if (secondaryFragment != null) {
        savedInstanceState.putString(Constants.MAIN_NOW_PLAYING_SECONDARY, secondaryFragment.getTag());
    }/*from  w w w .j av  a2 s. co  m*/
    savedInstanceState.putInt(Constants.MAIN_SLIDE_PANEL_STATE, slideUpPanel.getPanelState().hashCode());
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * ??//from ww w  . j  a v  a2s.  c o m
 */
private void recogniseLicense() {
    //
    String selectPath = AppCommon.licensePhotoPath;
    boolean cutBoolean = cut;

    try {
        Intent intent = new Intent("wintone.idcard");
        Bundle bundle = new Bundle();
        int nSubID[] = null;
        bundle.putInt("nTypeInitIDCard", 0); //?0??
        bundle.putString("lpFileName", selectPath);//?
        bundle.putInt("nTypeLoadImageToMemory", 0);//0???1??24
        bundle.putInt("nMainID", nMainID); //?6?2????????ID?????
        bundle.putIntArray("nSubID", nSubID); //????ID????????nSubID[0]=nullnMainID?

        //sn
        File file = new File(AppCommon.licenseUtilPath);
        String snString = null;
        if (file.exists()) {
            String filePATH = AppCommon.licenseUtilPath + "/IdCard.sn";
            File newFile = new File(filePATH);
            if (newFile.exists()) {
                BufferedReader bfReader = new BufferedReader(new FileReader(newFile));
                snString = bfReader.readLine().toUpperCase();
                bfReader.close();
            } else {
                bundle.putString("sn", "");
            }
            if (snString != null && !snString.equals("")) {
                bundle.putString("sn", snString);
            } else {
                bundle.putString("sn", "");
            }
        } else {
            bundle.putString("sn", "");
        }

        bundle.putString("authfile", ""); //?  /mnt/sdcard/AndroidWT/357816040594713_zj.txt
        bundle.putString("logo", ""); //logologo??
        bundle.putBoolean("isCut", cutBoolean); //??
        bundle.putString("returntype", "withvalue");//?withvalue???
        intent.putExtras(bundle);
        ((Activity) getContext()).startActivityForResult(intent, 8);
    } catch (Exception e) {
        Toast.makeText(getContext(), "?" + "wintone.idcard", Toast.LENGTH_SHORT).show();
    }
}

From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        String fragmentType = getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE);
        boolean firstRun = false;
        if (fragmentType == null) {
            fragmentType = Util.openToTab(this);
            if (fragmentType != null) {
                firstRun = true;/*ww  w . j  a  v  a  2  s. c o m*/
            }
        }

        if ("".equals(fragmentType) || fragmentType == null || firstRun) {
            // Initial startup stuff
            if (!sessionInitialized) {
                loadSession();
            }
        }
    }

    super.onCreate(savedInstanceState);
    if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_EXIT)) {
        stopService(new Intent(this, DownloadService.class));
        finish();
        getImageLoader().clearCache();
        DrawableTint.clearCache();
    } else if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) {
        getIntent().putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, "Download");
        lastSelectedPosition = R.id.drawer_downloading;
    }
    setContentView(R.layout.abstract_fragment_activity);

    if (findViewById(R.id.fragment_container) != null && savedInstanceState == null) {
        String fragmentType = getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE);
        if (fragmentType == null) {
            fragmentType = Util.openToTab(this);
            if (fragmentType != null) {
                getIntent().putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
                lastSelectedPosition = getDrawerItemId(fragmentType);
            } else {
                lastSelectedPosition = R.id.drawer_home;
            }

            MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition);
            if (item != null) {
                item.setChecked(true);
            }
        } else {
            lastSelectedPosition = getDrawerItemId(fragmentType);
        }

        currentFragment = getNewFragment(fragmentType);
        if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_ID)) {
            Bundle currentArguments = currentFragment.getArguments();
            if (currentArguments == null) {
                currentArguments = new Bundle();
            }
            currentArguments.putString(Constants.INTENT_EXTRA_NAME_ID,
                    getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID));
            currentFragment.setArguments(currentArguments);
        }
        currentFragment.setPrimaryFragment(true);
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "").commit();

        if (getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) {
            SearchFragment fragment = new SearchFragment();
            replaceFragment(fragment, fragment.getSupportTag());
        }

        // If a album type is set, switch to that album type view
        String albumType = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
        if (albumType != null) {
            SubsonicFragment fragment = new SelectDirectoryFragment();

            Bundle args = new Bundle();
            args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, albumType);
            args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 20);
            args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0);

            fragment.setArguments(args);
            replaceFragment(fragment, fragment.getSupportTag());
        }
    }

    slideUpPanel = (SlidingUpPanelLayout) findViewById(R.id.slide_up_panel);
    panelSlideListener = new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {

        }

        @Override
        public void onPanelCollapsed(View panel) {
            isPanelClosing = false;
            if (bottomBar.getVisibility() == View.GONE) {
                bottomBar.setVisibility(View.VISIBLE);
                nowPlayingToolbar.setVisibility(View.GONE);
                nowPlayingFragment.setPrimaryFragment(false);
                setSupportActionBar(mainToolbar);
                recreateSpinner();
            }
        }

        @Override
        public void onPanelExpanded(View panel) {
            isPanelClosing = false;
            currentFragment.stopActionMode();

            // Disable custom view before switching
            getSupportActionBar().setDisplayShowCustomEnabled(false);
            getSupportActionBar().setDisplayShowTitleEnabled(true);

            bottomBar.setVisibility(View.GONE);
            nowPlayingToolbar.setVisibility(View.VISIBLE);
            setSupportActionBar(nowPlayingToolbar);

            if (secondaryFragment == null) {
                nowPlayingFragment.setPrimaryFragment(true);
            } else {
                secondaryFragment.setPrimaryFragment(true);
            }

            drawerToggle.setDrawerIndicatorEnabled(false);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }

        @Override
        public void onPanelAnchored(View panel) {

        }

        @Override
        public void onPanelHidden(View panel) {
        }
    };
    slideUpPanel.setPanelSlideListener(panelSlideListener);

    if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD)) {
        // Post this later so it actually runs
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                openNowPlaying();
            }
        }, 200);

        getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD);
    }

    bottomBar = findViewById(R.id.bottom_bar);
    mainToolbar = (Toolbar) findViewById(R.id.main_toolbar);
    nowPlayingToolbar = (Toolbar) findViewById(R.id.now_playing_toolbar);
    coverArtView = (ImageView) bottomBar.findViewById(R.id.album_art);
    trackView = (TextView) bottomBar.findViewById(R.id.track_name);
    artistView = (TextView) bottomBar.findViewById(R.id.artist_name);

    setSupportActionBar(mainToolbar);

    if (findViewById(R.id.fragment_container) != null && savedInstanceState == null) {
        nowPlayingFragment = new NowPlayingFragment();
        FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
        trans.add(R.id.now_playing_fragment_container, nowPlayingFragment, nowPlayingFragment.getTag() + "");
        trans.commit();
    }

    rewindButton = (ImageButton) findViewById(R.id.download_rewind);
    rewindButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
                @Override
                protected Void doInBackground() throws Throwable {
                    if (getDownloadService() == null) {
                        return null;
                    }

                    getDownloadService().rewind();
                    return null;
                }
            }.execute();
        }
    });

    previousButton = (ImageButton) findViewById(R.id.download_previous);
    previousButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
                @Override
                protected Void doInBackground() throws Throwable {
                    if (getDownloadService() == null) {
                        return null;
                    }

                    getDownloadService().previous();
                    return null;
                }
            }.execute();
        }
    });

    startButton = (ImageButton) findViewById(R.id.download_start);
    startButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
                @Override
                protected Void doInBackground() throws Throwable {
                    PlayerState state = getDownloadService().getPlayerState();
                    if (state == PlayerState.STARTED) {
                        getDownloadService().pause();
                    } else if (state == PlayerState.IDLE) {
                        getDownloadService().play();
                    } else {
                        getDownloadService().start();
                    }

                    return null;
                }
            }.execute();
        }
    });

    nextButton = (ImageButton) findViewById(R.id.download_next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
                @Override
                protected Void doInBackground() throws Throwable {
                    if (getDownloadService() == null) {
                        return null;
                    }

                    getDownloadService().next();
                    return null;
                }
            }.execute();
        }
    });

    fastforwardButton = (ImageButton) findViewById(R.id.download_fastforward);
    fastforwardButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
                @Override
                protected Void doInBackground() throws Throwable {
                    if (getDownloadService() == null) {
                        return null;
                    }

                    getDownloadService().fastForward();
                    return null;
                }
            }.execute();
        }
    });
}

From source file:fr.univsavoie.ltp.client.MainActivity.java

protected void onSaveInstanceState(Bundle outState) {
    outState.putParcelable("start", startPoint);
    outState.putParcelable("destination", destinationPoint);
    outState.putParcelableArrayList("viapoints", viaPoints);
    outState.putParcelable("road", mRoad);
    outState.putInt("zoom_level", map.getZoomLevel());
    GeoPoint c = (GeoPoint) map.getMapCenter();
    outState.putParcelable("map_center", c);
    outState.putParcelableArrayList("poi", mPOIs);
}