Example usage for android.os Bundle putLong

List of usage examples for android.os Bundle putLong

Introduction

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

Prototype

public void putLong(@Nullable String key, long value) 

Source Link

Document

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

Usage

From source file:cm.aptoide.pt.ApkInfo.java

@SuppressLint("NewApi")
private void loadElements(long id) {
    viewComments = (ViewGroup) findViewById(R.id.commentContainer);
    viewComments.removeAllViews();/*from w  w w  . j a v  a2  s.co m*/
    viewLikes = (ViewGroup) findViewById(R.id.likesLayout);
    loading = LayoutInflater.from(context).inflate(R.layout.loadingfootercomments, null);
    viewComments.addView(loading, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    installString = getString(R.string.install);
    viewLikesButton = (ViewGroup) findViewById(R.id.ratings);
    ((TextView) viewLikes.findViewById(R.id.likes)).setText(context.getString(R.string.loading_likes));
    ((TextView) viewLikes.findViewById(R.id.dislikes)).setText("");

    findViewById(R.id.downloading_icon).setVisibility(View.GONE);
    findViewById(R.id.downloading_name).setVisibility(View.GONE);
    findViewById(R.id.download_progress).setVisibility(View.GONE);
    ProgressBar progress = (ProgressBar) findViewById(R.id.downloading_progress);
    progress.setIndeterminate(true);
    Bundle b = new Bundle();
    b.putLong("_id", id);

    //      findViewById(R.id.inst_version).setVisibility(View.VISIBLE);
    getSupportLoaderManager().restartLoader(20, b, new LoaderCallbacks<ViewApk>() {

        @Override
        public Loader<ViewApk> onCreateLoader(int arg0, final Bundle arg1) {
            pd.show();
            pd.setMessage(getString(R.string.please_wait));
            pd.setCancelable(false);
            return new ViewApkLoader(ApkInfo.this) {

                @Override
                public ViewApk loadInBackground() {
                    return db.getApk(arg1.getLong("_id"), category);
                }
            };

        }

        @Override
        public void onLoadFinished(Loader<ViewApk> arg0, ViewApk arg1) {
            //                AdView adView = (AdView)findViewById(R.id.adView);
            //                adView.loadAd(new AdRequest());

            mAdView = (MoPubView) findViewById(R.id.adview);
            mAdView.setAdUnitId(ApplicationAptoide.ADUNITID); // Enter your Ad Unit ID from www.mopub.com
            mAdView.loadAd();
            pd.dismiss();
            viewApk = arg1;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    loadDescription();
                }
            }).start();

            mainObbUrl = viewApk.getMainObbUrl();
            mainObbMd5 = viewApk.getMainObbMd5();
            mainObbName = viewApk.getMainObbFileName();
            mainObbSize = viewApk.getMainObbFileSize();

            patchObbUrl = viewApk.getPatchObbUrl();
            patchObbMd5 = viewApk.getPatchObbMd5();
            patchObbName = viewApk.getPatchObbFileName();
            patchObbSize = viewApk.getPatchObbFileSize();

            if (viewApk.getLikes() != -1) {
                setLikes(viewApk.getLikes() + "", viewApk.getDislikes() + "");
            }

            if (viewApk.getComments().size() > 0) {
                setComments(viewApk.getComments());
                loading.setVisibility(View.GONE);
            }

            loadScreenshots();

            //viewApk.getWebservicePath

            int installedVercode = db.getInstalledAppVercode(viewApk.getApkid());

            if (installedVercode <= viewApk.getVercode() && installedVercode != 0) {
                findViewById(R.id.inst_version).setVisibility(View.VISIBLE);
                ((TextView) findViewById(R.id.inst_version)).setText(getString(R.string.installed_version)
                        + ": " + db.getInstalledAppVername(viewApk.getApkid()));
                if (installedVercode < viewApk.getVercode() && !getIntent().hasExtra("installed")) {
                    installString = getString(R.string.update);
                } else if (getIntent().hasExtra("installed")) {
                    installString = getString(R.string.open);
                }
                ((Button) findViewById(R.id.btinstall)).setText(installString);

            } else if (installedVercode > viewApk.getVercode()) {
                if (getIntent().hasExtra("installed")) {
                    installString = getString(R.string.open);
                } else {
                    installString = getString(R.string.install);

                }
                ((Button) findViewById(R.id.btinstall)).setText(installString);

                findViewById(R.id.inst_version).setVisibility(View.GONE);
            }

            if (installedVercode == viewApk.getVercode()) {
                if (getIntent().hasExtra("installed")) {
                    installString = getString(R.string.open);
                } else {
                    installString = getString(R.string.install);
                }
                ((Button) findViewById(R.id.btinstall)).setText(installString);
                findViewById(R.id.inst_version).setVisibility(View.GONE);
            }

            repo_string = viewApk.getRepoName();
            checkDownloadStatus();
            webservicespath = viewApk.getWebservicesPath();

            try {
                ((RatingBar) findViewById(R.id.ratingbar)).setRating(Float.parseFloat(viewApk.getRating()));
                ((RatingBar) findViewById(R.id.ratingbar)).setIsIndicator(true);
            } catch (Exception e) {
                ((RatingBar) findViewById(R.id.ratingbar)).setRating(0);
                ((RatingBar) findViewById(R.id.ratingbar)).setIsIndicator(true);
            }
            ((TextView) findViewById(R.id.app_store)).setText(getString(R.string.store) + ": " + repo_string);
            ((TextView) findViewById(R.id.versionInfo)).setText(getString(R.string.clear_dwn_title) + ": "
                    + viewApk.getDownloads() + " " + getString(R.string.size) + ": "
                    + withSuffix((Long.parseLong(viewApk.getSize()) * 1024 + mainObbSize + patchObbSize)));
            ((TextView) findViewById(R.id.version_label))
                    .setText(getString(R.string.version) + " " + viewApk.getVername());
            ((TextView) findViewById(R.id.app_name)).setText(viewApk.getName());
            //            ImageLoader imageLoader = ImageLoader.getInstance(context);
            //            imageLoader.DisplayImage(viewApk.getIcon(),(ImageView) findViewById(R.id.app_icon), context, (viewApk.getApkid()+"|"+viewApk.getVercode()));
            DisplayImageOptions options = new DisplayImageOptions.Builder()
                    .displayer(new FadeInBitmapDisplayer(1000))
                    .showStubImage(android.R.drawable.sym_def_app_icon).resetViewBeforeLoading().cacheInMemory()
                    .cacheOnDisc().build();
            ImageLoader.getInstance().displayImage(viewApk.getIcon(), (ImageView) findViewById(R.id.app_icon),
                    options, null, (viewApk.getApkid() + "|" + viewApk.getVercode()));

            new GetApkInfo().execute();

            /*Comments comments = new Comments(context,webservicespath);
            comments.getComments(repo_string, viewApk.getApkid(),viewApk.getVername(),(LinearLayout) findViewById(R.id.commentContainer), false);*/
            likes = new Likes(context, webservicespath);
            /*likes.getLikes(repo_string, viewApk.getApkid(), viewApk.getVername(),(ViewGroup) findViewById(R.id.likesLayout),(ViewGroup) findViewById(R.id.ratings));*/

            ItemBasedApks items = new ItemBasedApks(context, viewApk);
            items.getItems((LinearLayout) findViewById(R.id.itembasedapks_container),
                    (LinearLayout) findViewById(R.id.itembasedapks_maincontainer),
                    (TextView) findViewById(R.id.itembasedapks_label));

            if (!spinnerInstanciated) {
                loadApkVersions();
            }
            setClickListeners();

            //Malware badges
            loadMalwareBadges();
            if (Build.VERSION.SDK_INT >= 11) {
                invalidateOptionsMenu();
            }

            //                if(!getIntent().hasExtra("installed")){
            //                    new checkPaymentTask().execute();
            //                }

        }

        private void loadMalwareBadges() {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        loadMalware(viewApk.getMalwareStatus());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();

        }

        @Override
        public void onLoaderReset(Loader<ViewApk> arg0) {

        }
    });

    //

    //

    //      Button serch_mrkt = (Button)findViewById(R.id.btmarket);
    //      serch_mrkt.setOnClickListener(new OnClickListener() {
    //
    //         public void onClick(View v) {

    //         }
    //
    //      });

    //

    //
    //

}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

@Override
public boolean onLongClick(final View view) {
    if (mUser == null)
        return false;
    final boolean is_my_activated_account = isMyActivatedAccount(getActivity(), mUser.getId());
    if (!is_my_activated_account)
        return false;
    switch (view.getId()) {
    case R.id.profile_image_container: {
        mPopupMenu = PopupMenu.getInstance(getActivity(), view);
        mPopupMenu.inflate(R.menu.action_profile_image);
        mPopupMenu.setOnMenuItemClickListener(this);
        mPopupMenu.show();//w w w.j  a va  2s  . c  o  m
        return true;
    }
    case R.id.name_container: {
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mUser.getId());
        args.putString(INTENT_KEY_TEXT, mUser.getName());
        args.putString(INTENT_KEY_TITLE, getString(R.string.name));
        args.putInt(INTENT_KEY_TYPE, TYPE_NAME);
        mDialogFragment.setArguments(args);
        mDialogFragment.show(getFragmentManager(), "edit_name");
        return true;
    }
    case R.id.description_container: {
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mUser.getId());
        args.putString(INTENT_KEY_TEXT, mUser.getDescription());
        args.putString(INTENT_KEY_TITLE, getString(R.string.description));
        args.putInt(INTENT_KEY_TYPE, TYPE_DESCRIPTION);
        mDialogFragment.setArguments(args);
        mDialogFragment.show(getFragmentManager(), "edit_description");
        return true;
    }
    case R.id.location_container: {
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mUser.getId());
        args.putString(INTENT_KEY_TEXT, mUser.getLocation());
        args.putString(INTENT_KEY_TITLE, getString(R.string.location));
        args.putInt(INTENT_KEY_TYPE, TYPE_LOCATION);
        mDialogFragment.setArguments(args);
        mDialogFragment.show(getFragmentManager(), "edit_location");
        return true;
    }
    case R.id.url_container: {
        final URL url = mUser.getURL();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mUser.getId());
        args.putString(INTENT_KEY_TEXT, url != null ? url.toString() : null);
        args.putString(INTENT_KEY_TITLE, getString(R.string.url));
        args.putInt(INTENT_KEY_TYPE, TYPE_URL);
        mDialogFragment.setArguments(args);
        mDialogFragment.show(getFragmentManager(), "edit_url");
        return true;
    }
    }
    return false;
}

From source file:com.digitalarx.android.authentication.AuthenticatorActivity.java

/**
 * Saves relevant state before {@link #onPause()}
 * //  w ww .j a v a  2 s  .co m
 * Do NOT save {@link #mNewCapturedUriFromOAuth2Redirection}; it keeps a temporal flag, intended to defer the 
 * processing of the redirection caught in {@link #onNewIntent(Intent)} until {@link #onResume()} 
 * 
 * See {@link #loadSavedInstanceState(Bundle)}
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    //Log_OC.wtf(TAG, "onSaveInstanceState init" );
    super.onSaveInstanceState(outState);

    /// global state
    outState.putString(KEY_AUTH_TOKEN_TYPE, mAuthTokenType);
    outState.putLong(KEY_WAITING_FOR_OP_ID, mWaitingForOpId);

    /// Server PRE-fragment state
    outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);
    outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon);
    outState.putBoolean(KEY_SERVER_CHECKED, mServerIsChecked);
    outState.putBoolean(KEY_SERVER_VALID, mServerIsValid);
    outState.putBoolean(KEY_IS_SSL_CONN, mServerInfo.mIsSslConn);
    outState.putString(KEY_HOST_URL_TEXT, mServerInfo.mBaseUrl);
    if (mServerInfo.mVersion != null) {
        outState.putString(KEY_OC_VERSION, mServerInfo.mVersion.getVersion());
    }
    outState.putString(KEY_SERVER_AUTH_METHOD, mServerInfo.mAuthMethod.name());

    /// Authentication PRE-fragment state
    outState.putBoolean(KEY_PASSWORD_EXPOSED, isPasswordVisible());
    outState.putInt(KEY_AUTH_STATUS_ICON, mAuthStatusIcon);
    outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText);
    outState.putString(KEY_AUTH_TOKEN, mAuthToken);

    //Log_OC.wtf(TAG, "onSaveInstanceState end" );
}

From source file:com.dwdesign.tweetings.activity.ComposeActivity.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    mText = parseString(mEditText.getText());
    outState.putLongArray(INTENT_KEY_IDS, mAccountIds);
    outState.putString(INTENT_KEY_TEXT, mText);
    outState.putLong(INTENT_KEY_IN_REPLY_TO_ID, mInReplyToStatusId);
    outState.putString(INTENT_KEY_IN_REPLY_TO_NAME, mInReplyToName);
    outState.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, mInReplyToScreenName);
    outState.putBoolean(INTENT_KEY_IS_QUOTE, mIsQuote);
    outState.putBoolean(INTENT_KEY_IS_IMAGE_ATTACHED, mIsImageAttached);
    outState.putBoolean(INTENT_KEY_IS_PHOTO_ATTACHED, mIsPhotoAttached);
    outState.putParcelable(INTENT_KEY_IMAGE_URI, mImageUri);
    outState.putBoolean(INTENT_KEY_CONTENT_MODIFIED, mContentModified);
    outState.putBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE, mIsPossiblySensitive);
    super.onSaveInstanceState(outState);
}

From source file:com.narkii.security.info.BaseDataFragment.java

private void initListener() {
    addResponButton.setOnClickListener(new OnClickListener() {

        @Override//w  w w. j  a v a  2  s. c o  m
        public void onClick(View v) {
            // TODO Auto-generated method stub
            addPersonInfoView(addResponButton, null);
        }
    });
    addManagerButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            addPersonInfoView(addManagerButton, null);
        }
    });
    saveButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "save button");
            boolean add = isEnterpriseAdd(), change = isEnterpriseChanged();
            Bundle bundle = new Bundle();
            if ((enterpriseId == 0 && add) || (enterpriseId != 0 && change)) {
                ContentValues values = new ContentValues();
                values.put(Enterprise.COLUMN_NAME, enameText.getText().toString());
                values.put(Enterprise.COLUMN_ADDRESS, addressText.getText().toString());
                values.put(Enterprise.COLUMN_ORGANIZATION_CODE, orgaText.getText().toString());
                values.put(Enterprise.COLUMN_FILE_NUMBER, fileText.getText().toString());
                values.put(Enterprise.COLUMN_TELEPHONE, ephoneText.getText().toString());
                values.put(Enterprise.COLUMN_FAX, efaxText.getText().toString());
                values.put(Enterprise.COLUMN_EMAIL, emailText.getText().toString());
                values.put(Enterprise.COLUMN_SPECIAL, specialId + 1);

                values.put(Enterprise.COLUMN_AREA, areaSpinner.getSelectedItemId());
                values.put(Enterprise.COLUMN_FK_ENTERPRISE_TYPE, typeSpinner.getSelectedItemId());

                if (enterpriseId == 0) {//
                    enterpriseId = DbOperations.getInstance(getActivity()).insert(Enterprise.TABLE_NAME,
                            values);
                    Log.d(TAG, "add enterprise message rowId:" + enterpriseId);
                    bundle.putLong("id", enterpriseId);
                } else {//
                    int result = DbOperations.getInstance(getActivity()).update(Enterprise.TABLE_NAME, values,
                            Enterprise._ID + "=?", new String[] { "" + enterpriseId });
                    Log.d(TAG, "update enterprise message result:" + result);
                    bundle.putLong("id", enterpriseId);
                }
                getLoaderManager().restartLoader(Constants.ENTERPRISE_INFO_ID, bundle, BaseDataFragment.this);
            }
            //person
            if (deleteViews.size() > 0) {
                String[][] param = new String[deleteViews.size()][];
                for (int i = 0; i < deleteViews.size(); i++) {
                    param[i] = new String[] { "" + deleteViews.get(i) };
                }
                int result = DbOperations.getInstance(getActivity()).delete(EnterprisePerson.TABLE_NAME,
                        EnterprisePerson._ID + "=?", param);
                Log.d(TAG, "delete person :" + result);
                if (result > 0)
                    deleteViews.clear();
            }
            int total = 0;
            //personupdate
            for (View person : personViews) {
                int result = savePersonMessage(person);
                total += result;
                Log.d(TAG, "update Person: " + result);
            }
            //personadd
            for (View person : addPersonViews) {
                int result = savePersonMessage(person);
                total += result;
                Log.d(TAG, "add person save: " + result);
            }
            if (total > 0) {
                bundle.putLong("id", enterpriseId);
                getLoaderManager().restartLoader(Constants.ENTERPRISE_PERSON_ID, bundle, BaseDataFragment.this);
            }
        }
    });
    for (CheckBox checkBox : specialBox) {
        checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO Auto-generated method stub
                if (isChecked) {
                    Log.d(TAG, "checked change " + isChecked);
                    for (int i = 0; i < specialBox.size(); i++)
                        if (!specialBox.get(i).equals(buttonView)) {
                            specialBox.get(i).setChecked(false);
                        } else {
                            specialId = i;
                        }
                }
                //
                int t = 0;
                for (int i = 0; i < specialBox.size(); i++) {
                    if (specialBox.get(i).isChecked())
                        t++;
                }
                if (t == 0)
                    specialId = -1;

            }
        });
    }
}

From source file:com.cerema.cloud2.authentication.AuthenticatorActivity.java

/**
 * Saves relevant state before {@link #onPause()}
 * /*from  ww w .  j  av a  2s .  c om*/
 * Do NOT save {@link #mNewCapturedUriFromOAuth2Redirection}; it keeps a temporal flag, 
 * intended to defer the processing of the redirection caught in 
 * {@link #onNewIntent(Intent)} until {@link #onResume()} 
 * 
 * See {@link super#onSaveInstanceState(Bundle)}
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    //Log_OC.wtf(TAG, "onSaveInstanceState init" );
    super.onSaveInstanceState(outState);

    /// global state
    outState.putString(KEY_AUTH_TOKEN_TYPE, mAuthTokenType);
    outState.putLong(KEY_WAITING_FOR_OP_ID, mWaitingForOpId);

    /// Server PRE-fragment state
    outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);
    outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon);
    outState.putBoolean(KEY_SERVER_CHECKED, mServerIsChecked);
    outState.putBoolean(KEY_SERVER_VALID, mServerIsValid);
    outState.putBoolean(KEY_IS_SSL_CONN, mServerInfo.mIsSslConn);
    outState.putString(KEY_HOST_URL_TEXT, mServerInfo.mBaseUrl);
    if (mServerInfo.mVersion != null) {
        outState.putString(KEY_OC_VERSION, mServerInfo.mVersion.getVersion());
    }
    outState.putString(KEY_SERVER_AUTH_METHOD, mServerInfo.mAuthMethod.name());

    /// Authentication PRE-fragment state
    outState.putBoolean(KEY_PASSWORD_EXPOSED, isPasswordVisible());
    outState.putInt(KEY_AUTH_STATUS_ICON, mAuthStatusIcon);
    outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText);
    outState.putString(KEY_AUTH_TOKEN, mAuthToken);

    /// authentication
    outState.putBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG, mIsFirstAuthAttempt);

    /// AsyncTask (User and password)
    outState.putString(KEY_USERNAME, mUsernameInput.getText().toString());
    outState.putString(KEY_PASSWORD, mPasswordInput.getText().toString());

    if (mAsyncTask != null) {
        mAsyncTask.cancel(true);
        outState.putBoolean(KEY_ASYNC_TASK_IN_PROGRESS, true);
    } else {
        outState.putBoolean(KEY_ASYNC_TASK_IN_PROGRESS, false);
    }
    mAsyncTask = null;

    //Log_OC.wtf(TAG, "onSaveInstanceState end" );
}

From source file:com.mantz_it.rfanalyzer.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(getString(R.string.save_state_running), running);
    outState.putInt(getString(R.string.save_state_demodulatorMode), demodulationMode);
    if (analyzerSurface != null) {
        outState.putLong(getString(R.string.save_state_channelFrequency),
                analyzerSurface.getChannelFrequency());
        outState.putInt(getString(R.string.save_state_channelWidth), analyzerSurface.getChannelWidth());
        outState.putFloat(getString(R.string.save_state_squelch), analyzerSurface.getSquelch());
        outState.putLong(getString(R.string.save_state_virtualFrequency),
                analyzerSurface.getVirtualFrequency());
        outState.putInt(getString(R.string.save_state_virtualSampleRate),
                analyzerSurface.getVirtualSampleRate());
        outState.putFloat(getString(R.string.save_state_minDB), analyzerSurface.getMinDB());
        outState.putFloat(getString(R.string.save_state_maxDB), analyzerSurface.getMaxDB());
    }//from  w  ww.jav  a  2s.c o  m
}

From source file:cl.ipp.katbag.fragment.Develop.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/* ww  w  . j av a  2s .  co m*/
    inflater.inflate(R.menu.develop, menu);

    menuItemEdit = menu.findItem(R.id.develop_dropdown_menu_edit);
    menuItemAddWorld = menu.findItem(R.id.develop_dropdown_menu_add_world);
    menuItemAddDrawing = menu.findItem(R.id.develop_dropdown_menu_add_drawing);
    menuItemAddMotion = menu.findItem(R.id.develop_dropdown_menu_add_motion);
    menuItemAddLook = menu.findItem(R.id.develop_dropdown_menu_add_look);
    menuItemAddSound = menu.findItem(R.id.develop_dropdown_menu_add_sound);
    menuItemAddControl = menu.findItem(R.id.develop_dropdown_menu_add_control);
    menuItemAddSensing = menu.findItem(R.id.develop_dropdown_menu_add_sensing);
    menuItemPlayer = menu.findItem(R.id.develop_dropdown_menu_player);

    menuItemEdit.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (editMode) {
                editMode = false;
                menuItemEdit.setIcon(R.drawable.ic_action_edit);
            } else {
                editMode = true;
                menuItemEdit.setIcon(R.drawable.ic_action_accept);
            }

            loadListView();

            return true;
        }
    });

    menuItemAddWorld.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_WORLD, -1);
            return true;
        }
    });

    menuItemAddDrawing.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_DRAWING, -1);
            return true;
        }
    });

    menuItemAddMotion.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_MOTION, -1);
            return true;
        }
    });

    menuItemAddLook.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_LOOK, -1);
            return true;
        }
    });

    menuItemAddSound.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_SOUND, -1);
            return true;
        }
    });

    menuItemAddControl.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_CONTROL, -1);
            return true;
        }
    });

    menuItemAddSensing.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAlertDialog(OBJECT_SENSING, -1);
            return true;
        }
    });

    menuItemPlayer.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            mFragment = new Player();

            Bundle bundle = new Bundle();
            bundle.putLong("id_app", id_app);
            bundle.putBoolean("editMode", true);
            bundle.putString("name_app", Add.name_app_text);
            mFragment.setArguments(bundle);

            FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
            t.replace(R.id.fragment_main_container, mFragment);
            t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            t.addToBackStack(mFragment.getClass().getSimpleName());
            t.commit();
            return true;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mUser == null || mService == null)
        return false;
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO: {
        takePhoto();// w ww .  jav a  2 s.c o  m
        break;
    }
    case MENU_ADD_IMAGE: {
        pickImage();
        break;
    }
    case MENU_BANNER_TAKE_PHOTO: {
        takeBannerPhoto();
        break;
    }
    case MENU_BANNER_ADD_IMAGE: {
        pickBannerImage();
        break;
    }
    case MENU_TRACKING: {
        UpdateTrackingTask task = new UpdateTrackingTask(!tracking);
        task.execute();
        break;
    }
    case MENU_BLOCK: {
        if (mService == null || mFriendship == null) {
            break;
        }
        if (mFriendship.isSourceBlockingTarget()) {
            mService.destroyBlock(mAccountId, mUser.getId());
        } else {
            mService.createBlock(mAccountId, mUser.getId());
        }
        break;
    }
    case MENU_REPORT_SPAM: {
        mService.reportSpam(mAccountId, mUser.getId());
        break;
    }
    case MENU_MUTE_USER: {
        final String screen_name = mUser.getScreenName();
        final Uri uri = Filters.Users.CONTENT_URI;
        final ContentValues values = new ContentValues();
        final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME,
                Context.MODE_PRIVATE).edit();
        final ContentResolver resolver = getContentResolver();
        values.put(Filters.Users.TEXT, screen_name);
        resolver.delete(uri, Filters.Users.TEXT + " = '" + screen_name + "'", null);
        resolver.insert(uri, values);
        editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit();
        Toast.makeText(getActivity(), R.string.user_muted, Toast.LENGTH_SHORT).show();
        break;
    }
    case MENU_MENTION: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        final String name = mUser.getName();
        final String screen_name = mUser.getScreenName();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        bundle.putString(INTENT_KEY_TEXT, "@" + screen_name + " ");
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name);
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_SEND_DIRECT_MESSAGE: {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(mAccountId));
        builder.appendQueryParameter(QUERY_PARAM_CONVERSATION_ID, String.valueOf(mUser.getId()));
        startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
        break;
    }
    case MENU_VIEW_ON_TWITTER: {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://twitter.com/" + mUser.getScreenName()));
        startActivity(browserIntent);
        break;
    }
    case MENU_WANT_RETWEETS: {
        updateFriendship();
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_USER, new ParcelableUser(mUser, mAccountId));
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    case MENU_SET_COLOR: {
        final Intent intent = new Intent(INTENT_ACTION_SET_COLOR);
        startActivityForResult(intent, REQUEST_SET_COLOR);
        break;
    }
    case MENU_CLEAR_COLOR: {
        clearUserColor(getActivity(), mUserId);
        updateUserColor();
        break;
    }
    }
    return true;
}

From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java

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

    if (mAction != null) {
        outState.putString(KEY_ACTION, mAction);
    }/*from   w w w . j a  v a2 s  .co m*/
    if (mGalleryInfo != null) {
        outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo);
    }
    outState.putLong(KEY_GID, mGid);
    if (mToken != null) {
        outState.putString(KEY_TOKEN, mAction);
    }
    if (mGalleryDetail != null) {
        outState.putParcelable(KEY_GALLERY_DETAIL, mGalleryDetail);
    }
    outState.putInt(KEY_REQUEST_ID, mRequestId);
}