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:com.hichinaschool.flashcards.anki.DeckPicker.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putLong("mCurrentDid", mCurrentDid);
    //      savedInstanceState.putSerializable("mDeckList", mDeckList);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openMedia(final Context context, final long accountId, final boolean isPossiblySensitive,
        final ParcelableStatus status, final ParcelableDirectMessage message, final ParcelableMedia current,
        final ParcelableMedia[] media) {
    if (context == null || media == null)
        return;/*from w ww  .java2 s. c  o m*/
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && isPossiblySensitive
            && !prefs.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false)) {
        final FragmentActivity activity = (FragmentActivity) context;
        final FragmentManager fm = activity.getSupportFragmentManager();
        final DialogFragment fragment = new SensitiveContentWarningDialogFragment();
        final Bundle args = new Bundle();
        args.putLong(EXTRA_ACCOUNT_ID, accountId);
        args.putParcelable(EXTRA_CURRENT_MEDIA, current);
        if (status != null) {
            args.putParcelable(EXTRA_STATUS, status);
        }
        if (message != null) {
            args.putParcelable(EXTRA_MESSAGE, message);
        }
        args.putParcelableArray(EXTRA_MEDIA, media);
        fragment.setArguments(args);
        fragment.show(fm, "sensitive_content_warning");
    } else {
        openMediaDirectly(context, accountId, status, message, current, media);
    }
}

From source file:com.android.mail.compose.ComposeActivity.java

/**
 * Use the {@link ContentResolver#call} method to send or save the message.
 *
 * If this was successful, this method will return an non-null Bundle instance
 *///from  ww w.  j  av  a 2s. c o m
private static Bundle callAccountSendSaveMethod(final ContentResolver resolver, final Account account,
        final String method, final SendOrSaveMessage sendOrSaveMessage) {
    // Copy all of the values from the content values to the bundle
    final Bundle methodExtras = new Bundle(sendOrSaveMessage.mValues.size());
    final Set<Entry<String, Object>> valueSet = sendOrSaveMessage.mValues.valueSet();

    for (Entry<String, Object> entry : valueSet) {
        final Object entryValue = entry.getValue();
        final String key = entry.getKey();
        if (entryValue instanceof String) {
            methodExtras.putString(key, (String) entryValue);
        } else if (entryValue instanceof Boolean) {
            methodExtras.putBoolean(key, (Boolean) entryValue);
        } else if (entryValue instanceof Integer) {
            methodExtras.putInt(key, (Integer) entryValue);
        } else if (entryValue instanceof Long) {
            methodExtras.putLong(key, (Long) entryValue);
        } else {
            LogUtils.wtf(LOG_TAG, "Unexpected object type: %s", entryValue.getClass().getName());
        }
    }

    // If the SendOrSaveMessage has some opened fds, add them to the bundle
    final Bundle fdMap = sendOrSaveMessage.attachmentFds();
    if (fdMap != null) {
        methodExtras.putParcelable(UIProvider.SendOrSaveMethodParamKeys.OPENED_FD_MAP, fdMap);
    }

    return resolver.call(account.uri, method, account.uri.toString(), methodExtras);
}

From source file:edu.cens.loci.ui.PlaceListActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    Intent intent;//www.ja v  a2  s.  c  o m
    Bundle extras;

    switch (mMode) {
    case MODE_VIEW:
        //Log.i(TAG, "onListItemClick : position=" + position + ", id=" + id);
        if ((mFilterState & FILTER_STATE_SUGGESTED) != 0) {
            if (position == 0) {
                intent = new Intent(Constants.Intents.UI.ACTION_VIEW_SUGGESTED_GPS_PLACES);
                Toast.makeText(this, "Not supported yet", Toast.LENGTH_SHORT).show();
                return;
            } else {
                intent = new Intent(Intent.ACTION_VIEW, getSelectedUri(position - 1));
            }
        } else {
            intent = new Intent(Intent.ACTION_VIEW, getSelectedUri(position));
        }
        startActivity(intent);
        break;
    case MODE_INSERT:
        extras = getIntent().getExtras();
        if (position == 0) {
            intent = new Intent(Intent.ACTION_INSERT, Places.CONTENT_URI);
            if (extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_KEY)
                    && extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY)) {
                String wifiJson = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_KEY);
                String timestamp = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY);
                intent.putExtra(Insert.WIFI_FINTERPRINT, wifiJson);
                intent.putExtra(Insert.TIME, timestamp);
            }
            //intent = new Intent(Intent.ACTION_EDIT, getSelectedUri(position));
        } else {
            intent = new Intent(Intent.ACTION_EDIT, getSelectedUri(position - 1));
            if (extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_KEY)
                    && extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY)) {
                String wifiJson = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_KEY);
                String timestamp = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY);
                intent.putExtra(Insert.WIFI_FINTERPRINT, wifiJson);
                intent.putExtra(Insert.TIME, timestamp);
            }
        }
        //extras = getIntent().getExtras();
        //if (extras != null) 
        //   intent.putExtras(extras);

        startActivityForResult(intent, SUBACTIVITY_NEW_PLACE);
        break;
    case MODE_REGISTER_SUGGESTED:
        extras = getIntent().getExtras();
        if (position == 0) {
            intent = new Intent(Intents.UI.ACTION_CREATE_FROM_SUGGESTED_PLACE, getIntent().getData());
        } else {
            //intent = new Intent(Intents.UI.ACTION_ADDTO_FROM_SUGESTED_PLACE, getIntent().getData());
            //extras.putLong(Intents.UI.SELECTED_PLACE_ID_EXTRA_KEY, getSelectedPlaceId(position-1));
            intent = new Intent(Intents.UI.ACTION_ADDTO_FROM_SUGESTED_PLACE, getSelectedUri(position - 1));
            extras.putLong(Intents.UI.SELECTED_PLACE_ID_EXTRA_KEY, ContentUris.parseId(getIntent().getData()));
        }
        if (extras != null)
            intent.putExtras(extras);

        startActivityForResult(intent, SUBACTIVITY_NEW_PLACE);
        break;
    case MODE_PICK:
        final Uri uri = getSelectedUri(position);
        intent = new Intent();
        setResult(RESULT_OK, intent.setData(uri));
        finish();
        break;
    }

}

From source file:org.getlantern.firetweet.util.Utils.java

public static Fragment createFragmentForIntent(final Context context, final int linkId, final Intent intent) {
    intent.setExtrasClassLoader(context.getClassLoader());
    final Bundle extras = intent.getExtras();
    final Uri uri = intent.getData();
    final Fragment fragment;
    if (uri == null)
        return null;
    final Bundle args = new Bundle();
    if (extras != null) {
        args.putAll(extras);//from   w  w  w  .jav a 2  s .c om
    }
    switch (linkId) {
    case LINK_ID_STATUS: {
        fragment = new StatusFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id));
        }
        break;
    }
    case LINK_ID_USER: {
        fragment = new UserFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        break;
    }
    case LINK_ID_USER_LIST_MEMBERSHIPS: {
        fragment = new UserListMembershipsListFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        break;
    }
    case LINK_ID_USER_TIMELINE: {
        fragment = new UserTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (isEmpty(paramScreenName) && isEmpty(paramUserId))
            return null;
        break;
    }
    case LINK_ID_USER_MEDIA_TIMELINE: {
        fragment = new UserMediaTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (isEmpty(paramScreenName) && isEmpty(paramUserId))
            return null;
        break;
    }
    case LINK_ID_USER_FAVORITES: {
        fragment = new UserFavoritesFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (!args.containsKey(EXTRA_SCREEN_NAME) && !args.containsKey(EXTRA_USER_ID))
            return null;
        break;
    }
    case LINK_ID_USER_FOLLOWERS: {
        fragment = new UserFollowersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_FRIENDS: {
        fragment = new UserFriendsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_BLOCKS: {
        fragment = new UserBlocksListFragment();
        break;
    }
    case LINK_ID_MUTES_USERS: {
        fragment = new MutesUsersListFragment();
        break;
    }
    case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
        fragment = new MessagesConversationFragment();
        final String paramRecipientId = uri.getQueryParameter(QUERY_PARAM_RECIPIENT_ID);
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final long conversationId = ParseUtils.parseLong(paramRecipientId);
        if (conversationId > 0) {
            args.putLong(EXTRA_RECIPIENT_ID, conversationId);
        } else if (paramScreenName != null) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        break;
    }
    case LINK_ID_USER_LIST: {
        fragment = new UserListFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LISTS: {
        fragment = new UserListsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (isEmpty(paramScreenName) && isEmpty(paramUserId))
            return null;
        break;
    }
    case LINK_ID_USER_LIST_TIMELINE: {
        fragment = new UserListTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERS: {
        fragment = new UserListMembersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LIST_SUBSCRIBERS: {
        fragment = new UserListSubscribersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_SAVED_SEARCHES: {
        fragment = new SavedSearchesListFragment();
        break;
    }
    case LINK_ID_USER_MENTIONS: {
        fragment = new UserMentionsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        if (!args.containsKey(EXTRA_SCREEN_NAME) && !isEmpty(paramScreenName)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (isEmpty(args.getString(EXTRA_SCREEN_NAME)))
            return null;
        break;
    }
    case LINK_ID_INCOMING_FRIENDSHIPS: {
        fragment = new IncomingFriendshipsFragment();
        break;
    }
    case LINK_ID_USERS: {
        fragment = new UsersListFragment();
        break;
    }
    case LINK_ID_STATUSES: {
        fragment = new StatusesListFragment();
        break;
    }
    case LINK_ID_STATUS_RETWEETERS: {
        fragment = new StatusRetweetersListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        break;
    }
    case LINK_ID_STATUS_FAVORITERS: {
        fragment = new StatusFavoritersListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        break;
    }
    case LINK_ID_STATUS_REPLIES: {
        fragment = new StatusRepliesListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        break;
    }
    case LINK_ID_SEARCH: {
        final String param_query = uri.getQueryParameter(QUERY_PARAM_QUERY);
        if (isEmpty(param_query))
            return null;
        args.putString(EXTRA_QUERY, param_query);
        fragment = new SearchFragment();
        break;
    }
    default: {
        return null;
    }
    }
    final String paramAccountId = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID);
    if (paramAccountId != null) {
        args.putLong(EXTRA_ACCOUNT_ID, ParseUtils.parseLong(paramAccountId));
    } else {
        final String paramAccountName = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME);
        if (paramAccountName != null) {
            args.putLong(EXTRA_ACCOUNT_ID, getAccountId(context, paramAccountName));
        } else {
            final long accountId = getDefaultAccountId(context);
            if (isMyAccount(context, accountId)) {
                args.putLong(EXTRA_ACCOUNT_ID, accountId);
            }
        }
    }
    fragment.setArguments(args);
    return fragment;
}

From source file:com.facebook.Session.java

private void logAuthorizationComplete(AuthorizationClient.Result.Code result, Map<String, String> resultExtras,
        Exception exception) {/*from   w  w w.j  av a 2  s  .c  o m*/
    Bundle bundle = null;
    if (pendingAuthorizationRequest == null) {
        // We don't expect this to happen, but if it does, log an event for diagnostic purposes.
        bundle = AuthorizationClient.newAuthorizationLoggingBundle("");
        bundle.putString(AuthorizationClient.EVENT_PARAM_LOGIN_RESULT,
                AuthorizationClient.Result.Code.ERROR.getLoggingValue());
        bundle.putString(AuthorizationClient.EVENT_PARAM_ERROR_MESSAGE,
                "Unexpected call to logAuthorizationComplete with null pendingAuthorizationRequest.");
    } else {
        bundle = AuthorizationClient.newAuthorizationLoggingBundle(pendingAuthorizationRequest.getAuthId());
        if (result != null) {
            bundle.putString(AuthorizationClient.EVENT_PARAM_LOGIN_RESULT, result.getLoggingValue());
        }
        if (exception != null && exception.getMessage() != null) {
            bundle.putString(AuthorizationClient.EVENT_PARAM_ERROR_MESSAGE, exception.getMessage());
        }

        // Combine extras from the request and from the result.
        JSONObject jsonObject = null;
        if (pendingAuthorizationRequest.loggingExtras.isEmpty() == false) {
            jsonObject = new JSONObject(pendingAuthorizationRequest.loggingExtras);
        }
        if (resultExtras != null) {
            if (jsonObject == null) {
                jsonObject = new JSONObject();
            }
            try {
                for (Map.Entry<String, String> entry : resultExtras.entrySet()) {
                    jsonObject.put(entry.getKey(), entry.getValue());
                }
            } catch (JSONException e) {
            }
        }
        if (jsonObject != null) {
            bundle.putString(AuthorizationClient.EVENT_PARAM_EXTRAS, jsonObject.toString());
        }
    }
    bundle.putLong(AuthorizationClient.EVENT_PARAM_TIMESTAMP, System.currentTimeMillis());

    AppEventsLogger logger = getAppEventsLogger();
    logger.logSdkEvent(AuthorizationClient.EVENT_NAME_LOGIN_COMPLETE, null, bundle);
}

From source file:com.android.launcher2.Launcher.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getNextPage());
    super.onSaveInstanceState(outState);

    outState.putInt(RUNTIME_STATE, mState.ordinal());
    // We close any open folder since it will not be re-opened, and we need to make sure
    // this state is reflected.
    closeFolder();//w  w w .j  a  va 2s .c o  m

    if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screen > -1 && mWaitingForResult) {
        outState.putLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, mPendingAddInfo.container);
        outState.putInt(RUNTIME_STATE_PENDING_ADD_SCREEN, mPendingAddInfo.screen);
        outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX);
        outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY);
        outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX);
        outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY);
        outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo);
    }

    if (mFolderInfo != null && mWaitingForResult) {
        outState.putBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, true);
        outState.putLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID, mFolderInfo.id);
    }

    // Save the current AppsCustomize tab
    if (mAppsCustomizeTabHost != null) {
        String currentTabTag = mAppsCustomizeTabHost.getCurrentTabTag();
        if (currentTabTag != null) {
            outState.putString("apps_customize_currentTab", currentTabTag);
        }
        int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex();
        outState.putInt("apps_customize_currentIndex", currentIndex);
    }
}

From source file:br.org.funcate.dynamicforms.FragmentDetailActivity.java

private void saveAction() throws Exception {

    FragmentDetail detailFragment = (FragmentDetail) getSupportFragmentManager()
            .findFragmentById(R.id.detailFragment);
    if (detailFragment != null) {
        detailFragment.storeFormItems(false);
    }//from ww w.  j  av  a  2s . co  m

    if (sectionObject == null) {
        throw new Exception(this.getString(R.string.session_object_exception));
    }

    // extract and check constraints
    List<String> availableFormNames = TagsManager.getFormNames4Section(sectionObject);
    Bundle formData = null;

    if (availableFormNames.isEmpty()) {
        throw new Exception(this.getString(R.string.session_object_exception));
    }

    for (String formNameIt : availableFormNames) {
        JSONObject formObject = TagsManager.getForm4Name(formNameIt, sectionObject);
        JSONArray formItemsArray = TagsManager.getFormItems(formObject);

        int length = formItemsArray != null ? formItemsArray.length() : 0;
        formData = new Bundle(length);
        ArrayList<String> keys = new ArrayList<String>(length);
        ArrayList<String> types = new ArrayList<String>(length);

        String key = "";
        String value = "";
        String type = "";
        boolean insertKey;// This control flag is used to ignore some types because are simply ignored or are manipulated in other time.

        for (int i = 0; i < length; i++) {
            JSONObject jsonObject = formItemsArray.getJSONObject(i);

            if (jsonObject.has(TAG_KEY))
                key = jsonObject.getString(TAG_KEY).trim();

            if (jsonObject.has(TAG_VALUE)) {
                value = jsonObject.getString(TAG_VALUE).trim();
            }

            if (jsonObject.has(TAG_TYPE)) {
                type = jsonObject.getString(TAG_TYPE).trim();
            }

            if (!key.equals("") && !value.equals("") && !type.equals("")) {

                insertKey = true;

                if (type.equals(TYPE_STRING)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_STRINGAREA)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_DOUBLE)) {
                    formData.putDouble(key, Double.valueOf(value));
                } else if (type.equals(TYPE_INTEGER)) {
                    formData.putInt(key, Integer.valueOf(value));
                } else if (type.equals(TYPE_DATE)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_TIME)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_LABEL)) {
                    insertKey = false;
                    //formData.putString(key, value);
                } else if (type.equals(TYPE_LABELWITHLINE)) {
                    insertKey = false;
                    //formData.putString(key, value);
                } else if (type.equals(TYPE_BOOLEAN)) {
                    formData.putBoolean(key, Boolean.valueOf(value));
                } else if (type.equals(TYPE_STRINGCOMBO)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_CONNECTEDSTRINGCOMBO)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_STRINGMULTIPLECHOICE)) {
                    insertKey = false;
                    //formData.putString(key,value);
                } else if (type.equals(TYPE_PICTURES)) {
                    insertKey = false;
                    // Using the new key to represent a list of image paths. It is manipulated on posterior time.
                    //formData.putString(key,value);
                    decodeFromJson(value, formData);
                }

                if (insertKey) {
                    keys.add(key);
                    types.add(type);
                }

            }
        }
        formData.putStringArrayList(LibraryConstants.FORM_TYPES, types);
        formData.putStringArrayList(LibraryConstants.FORM_KEYS, keys);

        if (sectionObject.has(FormUtilities.ATTR_GEOJSON_TAGS)) {
            JSONObject geojsonGeometry = sectionObject.getJSONObject(FormUtilities.ATTR_GEOJSON_TAGS);
            formData.putString(FormUtilities.ATTR_GEOJSON_TAGS, geojsonGeometry.toString());
        }

        if (pointId >= 0) {
            formData.putLong(FormUtilities.GEOM_ID, pointId);
        }

        if (existingFeatureData != null) {
            formData.putBundle(FormUtilities.ATTR_DATA_VALUES, existingFeatureData);
        }
    }

    if (formData == null) {
        throw new Exception(this.getString(R.string.session_object_exception));
    }
    Intent intent = getIntent();
    intent.putExtra(LibraryConstants.PREFS_KEY_FORM, formData);
    setResult(Activity.RESULT_OK, intent);
    finish();
}

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

@Override
public void onClick(View v) {
    Context context = getContext2();
    MainActivity activity = getActivity2();
    if (null == context || null == activity) {
        return;//from  w w w .j  ava2s . c om
    }

    if (mTip == v) {
        if (request()) {
            adjustViewVisibility(STATE_REFRESH, true);
        }
    } else if (mOtherActions == v) {
        ensurePopMenu();
        if (mPopupMenu != null) {
            mPopupMenu.show();
        }
    } else if (mUploader == v) {
        String uploader = getUploader();
        if (TextUtils.isEmpty(uploader)) {
            return;
        }
        ListUrlBuilder lub = new ListUrlBuilder();
        lub.setMode(ListUrlBuilder.MODE_UPLOADER);
        lub.setKeyword(uploader);
        GalleryListScene.startScene(this, lub);
    } else if (mCategory == v) {
        int category = getCategory();
        if (category == -1) {
            return;
        }
        ListUrlBuilder lub = new ListUrlBuilder();
        lub.setCategory(category);
        GalleryListScene.startScene(this, lub);
    } else if (mDownload == v) {
        GalleryInfo galleryInfo = getGalleryInfo();
        if (galleryInfo != null) {
            CommonOperations.startDownload(activity, galleryInfo, false);
        }
    } else if (mRead == v) {
        GalleryInfo galleryInfo = null;
        if (mGalleryInfo != null) {
            galleryInfo = mGalleryInfo;
        } else if (mGalleryDetail != null) {
            galleryInfo = mGalleryDetail;
        }
        if (galleryInfo != null) {
            Intent intent = new Intent(activity, GalleryActivity.class);
            intent.setAction(GalleryActivity.ACTION_EH);
            intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo);
            startActivity(intent);
        }
    } else if (mInfo == v) {
        Bundle args = new Bundle();
        args.putParcelable(GalleryInfoScene.KEY_GALLERY_DETAIL, mGalleryDetail);
        startScene(new Announcer(GalleryInfoScene.class).setArgs(args));
    } else if (mHeartGroup == v) {
        if (mGalleryDetail != null && !mModifingFavorites) {
            boolean remove = false;
            if (EhDB.containLocalFavorites(mGalleryDetail.gid)) {
                EhDB.removeLocalFavorites(mGalleryDetail.gid);
                remove = true;
            }
            if (mGalleryDetail.isFavorited) {
                mModifingFavorites = true;
                CommonOperations.removeFromFavorites(activity, mGalleryDetail,
                        new ModifyFavoritesListener(context, activity.getStageId(), getTag(), true));
                remove = true;
            }
            if (!remove) {
                mModifingFavorites = true;
                CommonOperations.addToFavorites(activity, mGalleryDetail,
                        new ModifyFavoritesListener(context, activity.getStageId(), getTag(), false));
            }
            // Update UI
            updateFavoriteDrawable();
        }
    } else if (mShare == v) {
        String url = getGalleryDetailUrl(false);
        if (url != null) {
            AppHelper.share(activity, url);
        }
    } else if (mTorrent == v) {
        if (mGalleryDetail != null) {
            TorrentListDialogHelper helper = new TorrentListDialogHelper();
            Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.torrents)
                    .setView(R.layout.dialog_torrent_list).setOnDismissListener(helper).show();
            helper.setDialog(dialog, mGalleryDetail.torrentUrl);
        }
    } else if (mRate == v) {
        if (mGalleryDetail == null) {
            return;
        }
        if (mGalleryDetail.apiUid < 0) {
            showTip(R.string.sign_in_first, LENGTH_SHORT);
            return;
        }
        RateDialogHelper helper = new RateDialogHelper();
        Dialog dialog = new AlertDialog.Builder(context).setTitle(R.string.rate).setView(R.layout.dialog_rate)
                .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, helper)
                .show();
        helper.setDialog(dialog, mGalleryDetail.rating);
    } else if (mSimilar == v) {
        showSimilarGalleryList();
    } else if (mSearchCover == v) {
        showCoverGalleryList();
    } else if (mComments == v) {
        if (mGalleryDetail == null) {
            return;
        }
        Bundle args = new Bundle();
        args.putLong(GalleryCommentsScene.KEY_API_UID, mGalleryDetail.apiUid);
        args.putString(GalleryCommentsScene.KEY_API_KEY, mGalleryDetail.apiKey);
        args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.gid);
        args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.token);
        args.putParcelableArray(GalleryCommentsScene.KEY_COMMENTS, mGalleryDetail.comments);
        startScene(new Announcer(GalleryCommentsScene.class).setArgs(args).setRequestCode(this,
                REQUEST_CODE_COMMENT_GALLERY));
    } else if (mPreviews == v) {
        if (null != mGalleryDetail) {
            Bundle args = new Bundle();
            args.putParcelable(GalleryPreviewsScene.KEY_GALLERY_INFO, mGalleryDetail);
            startScene(new Announcer(GalleryPreviewsScene.class).setArgs(args));
        }
    } else {
        Object o = v.getTag(R.id.tag);
        if (o instanceof String) {
            String tag = (String) o;
            ListUrlBuilder lub = new ListUrlBuilder();
            lub.setMode(ListUrlBuilder.MODE_TAG);
            lub.setKeyword(tag);
            GalleryListScene.startScene(this, lub);
            return;
        }

        GalleryInfo galleryInfo = getGalleryInfo();
        o = v.getTag(R.id.index);
        if (null != galleryInfo && o instanceof Integer) {
            int index = (Integer) o;
            Intent intent = new Intent(context, GalleryActivity.class);
            intent.setAction(GalleryActivity.ACTION_EH);
            intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo);
            intent.putExtra(GalleryActivity.KEY_PAGE, index);
            startActivity(intent);
            return;
        }
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
    for (Prediction prediction : predictions) {
        if (prediction.score > mGestureSensitivity) {
            Bundle b = new Bundle();
            b.putLong("id", Long.parseLong(prediction.name));
            getLoaderManager().initLoader(LOAD_TEMPLATE_BY_ID, b, this);
        }//from   w  w w  .j  av  a 2s .  c o m
    }
}