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.oakonell.dndcharacter.views.character.CharacterActivity.java

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

    if (characterLoader != null) {
        characterLoader.cancel(true);/*ww w .j  av  a  2 s.  c  om*/
    }
    outState.putLong(CHARACTER_ID, id);
}

From source file:com.android.datetimepicker.date.DatePickerDialogCompat.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt(KEY_SELECTED_YEAR, mCalendar.get(Calendar.YEAR));
    outState.putInt(KEY_SELECTED_MONTH, mCalendar.get(Calendar.MONTH));
    outState.putInt(KEY_SELECTED_DAY, mCalendar.get(Calendar.DAY_OF_MONTH));
    outState.putInt(KEY_WEEK_START, mWeekStart);
    outState.putLong(KEY_START, mMinDate.getTimeInMillis());
    outState.putLong(KEY_END, mMaxDate.getTimeInMillis());
    outState.putInt(KEY_CURRENT_VIEW, mCurrentView);
    int listPosition = -1;
    if (mCurrentView == MONTH_AND_DAY_VIEW) {
        listPosition = mDayPickerView.getMostVisiblePosition();
    } else if (mCurrentView == YEAR_VIEW) {
        listPosition = mYearPickerView.getFirstVisiblePosition();
        outState.putInt(KEY_LIST_POSITION_OFFSET, mYearPickerView.getFirstPositionOffset());
    }// w  ww . j a va2s  .  c  om
    outState.putInt(KEY_LIST_POSITION, listPosition);
}

From source file:at.ac.tuwien.detlef.fragments.EpisodeListFragment.java

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

    /*//from   ww  w.  ja v  a2  s. c  o  m
     * Save the currently selected podcast's ID in order to be able to
     * restore filter settings later on.
     */
    outState.putSerializable(BUNDLE_FILTERS, getFilter());
    long id = (filteredByPodcast == null ? ID_NONE : filteredByPodcast.getId());
    outState.putLong(BUNDLE_SELECTED_PODCAST, id);
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mainActivity = (MainActivity) super.getActivity();
    v = inflater.inflate(R.layout.fragment_worlds, container, false);
    mainActivity.supportInvalidateOptionsMenu();

    // rescues parameters
    Bundle bundle = getArguments();
    if (bundle != null) {
        id_app = bundle.getLong("id_app");
    }//from   w w w . jav  a  2s . c  om

    notRegister = (TextView) v.findViewById(R.id.world_not_register);
    editMode = false;
    loadListView();

    worldsListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!editMode) {
                TextView idWorld = (TextView) view.findViewById(R.id.world_row_id);

                Bundle bundle = new Bundle();
                bundle.putLong("id_world", Long.valueOf(idWorld.getText().toString()));
                bundle.putString("name_world", idWorld.getText().toString());

                mFragment = new OneWorld();
                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 v;
}

From source file:com.aquatest.dbinterface.tools.DatabaseUpdater.java

/**
 * Run the updater to synchronise the device with the server. </p> Method
 * cycles through all the database tables, and for each one, it retrieves
 * records that have been added, changed or deleted.
 *//*  w  w  w. j av a2 s .c o  m*/
public void run() {
    try {
        long updateTime = System.currentTimeMillis();
        boolean result;

        Vector<String> tables = getTables();
        sendMessage("Table list downloaded: " + tables.size() + " tables found.", ITEM_COMPLETE);

        // begin database transaction
        dA.database.beginTransaction();

        try {

            // loop through all the tables
            int tableCount = tables.size();
            for (int i = 0; i < tableCount; i++) {
                String tableName = tables.get(i);
                int k = i + 1;

                // ignore authoritymanager table
                if (tableName.compareTo("authoritymanager") == 0) {
                    continue;
                } // if

                // retrieve ADDED rows
                sendMessage(tableName + " (table " + k + "/" + tableCount + "): retrieving new records...",
                        ITEM_COMPLETE);
                result = fetchAndExecuteQueries(TYPE_ADDED, tableName);

                if (!result) {
                    // Log.v("THREAD", "KILLING");
                    sendMessage("Update cancelled!", CANCELLED);
                    return;
                } // if

                // retrieve UPDATED rows
                sendMessage(tableName + " (table " + k + "/" + tableCount + "): retrieving updated records...",
                        ITEM_COMPLETE);
                result = fetchAndExecuteQueries(TYPE_UPDATED, tableName);

                if (!result) {
                    // Log.v("THREAD", "KILLING");
                    sendMessage("Update cancelled!", CANCELLED);
                    return;
                } // if

                // retrieve DELETED rows
                sendMessage(tableName + " (table " + k + "/" + tableCount + "): retrieving deleted rows...",
                        ITEM_COMPLETE);
                result = fetchAndExecuteQueries(TYPE_DELETED, tableName);

                if (!result) {
                    // Log.v("THREAD", "KILLING");
                    sendMessage("Update cancelled!", CANCELLED);
                    return;
                } // if
            } // for

            // signal transaction can be committed
            dA.database.setTransactionSuccessful();
        } finally {
            // commit or rollback transaction
            dA.database.endTransaction();

        }

        // return success in a Bundle
        Bundle b = new Bundle();
        b.putString("msg", "Update complete!");
        b.putLong("time", updateTime);
        sendMessage(b, COMPLETE);

    } catch (JSONException jE) {
        sendMessage(jE.getMessage(), ERROR);
        return;
    } catch (ClientProtocolException cE) {
        sendMessage(cE.getMessage() + " This is possibly caused by a lack of connectivity. "
                + "Restart the app and try again after ensuring you have a valid connection.", ERROR);
        return;
    } catch (IOException iE) {
        sendMessage(iE.getMessage() + " This is possibly caused by a lack of connectivity. "
                + "Restart the app and try again after ensuring you have a valid connection.", ERROR);
        return;
    } catch (SQLiteException sE) {
        sendMessage("A SQLite exception occured: " + sE.getMessage(), ERROR);
        return;
    } // catch
}

From source file:com.digitalarx.android.ui.activity.FileActivity.java

/**
 * {@inheritDoc}/* w w w .  j av a 2 s .c o m*/
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
    outState.putParcelable(FileActivity.EXTRA_ACCOUNT, mAccount);
    outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
    outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
}

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

@Override
public boolean onLongClick(final View view) {
    if (mUserList == null)
        return false;
    final boolean is_my_activated_account = isMyActivatedAccount(getActivity(), mUserId);
    if (!is_my_activated_account)
        return false;
    switch (view.getId()) {
    case R.id.name_container:
    case R.id.description_container:
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        args.putString(INTENT_KEY_LIST_NAME, mUserList.getName());
        args.putString(INTENT_KEY_DESCRIPTION, mUserList.getDescription());
        args.putString(INTENT_KEY_TITLE, getString(R.string.description));
        args.putBoolean(INTENT_KEY_IS_PUBLIC, mUserList.isPublic());
        args.putInt(INTENT_KEY_LIST_ID, mUserList.getId());
        mEditUserListDialogFragment.setArguments(args);
        mEditUserListDialogFragment.show(getFragmentManager(), "edit_user_list_details");
        return true;
    }/*from ww  w .  j a  va  2  s  .c  o m*/
    return false;
}

From source file:com.wirelessmoves.cl.MainActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    super.onSaveInstanceState(savedInstanceState);

    /* save variables */
    savedInstanceState.putLong("NumberOfSignalStrengthUpdates", NumberOfSignalStrengthUpdates);

    savedInstanceState.putLong("LastCellId", LastCellId);
    savedInstanceState.putLong("NumberOfCellChanges", NumberOfCellChanges);

    savedInstanceState.putLong("LastLacId", LastLacId);
    savedInstanceState.putLong("NumberOfLacChanges", NumberOfLacChanges);

    savedInstanceState.putLongArray("PreviousCells", PreviousCells);
    savedInstanceState.putInt("PreviousCellsIndex", PreviousCellsIndex);
    savedInstanceState.putLong("NumberOfUniqueCellChanges", NumberOfUniqueCellChanges);

    savedInstanceState.putBoolean("outputDebugInfo", outputDebugInfo);

    savedInstanceState.putDouble("CurrentLocationLong", CurrentLocationLong);
    savedInstanceState.putDouble("CurrentLocationLat", CurrentLocationLat);

    /* save the trace data still in the write buffer into a file */
    saveDataToFile(FileWriteBufferStr,//from   www. jav  a  2s. c o  m
            "---in save instance, " + DateFormat.getTimeInstance().format(new Date()) + "\r\n");
    FileWriteBufferStr = "";

}

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

public void getUserListInfo(final boolean init, final long account_id, final int list_id,
        final String list_name, final long user_id, final String screen_name) {
    mAccountId = account_id;/*from   w ww . j  ava2  s . co m*/
    mUserListId = list_id;
    mUserName = screen_name;
    getLoaderManager().destroyLoader(0);
    if (!isMyActivatedAccount(getActivity(), mAccountId)) {
        mListContainer.setVisibility(View.GONE);
        mErrorRetryContainer.setVisibility(View.GONE);
        return;
    }

    if (list_id > 0 || list_name != null && (user_id > 0 || screen_name != null)) {
    } else {
        mListContainer.setVisibility(View.GONE);
        mErrorRetryContainer.setVisibility(View.GONE);
        return;
    }

    final Bundle args = new Bundle();
    args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
    args.putLong(INTENT_KEY_USER_ID, user_id);
    args.putInt(INTENT_KEY_LIST_ID, list_id);
    args.putString(INTENT_KEY_LIST_NAME, list_name);
    args.putString(INTENT_KEY_SCREEN_NAME, screen_name);
    if (init) {
        getLoaderManager().initLoader(0, args, this);
    } else {
        getLoaderManager().restartLoader(0, args, this);
    }
}

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

@Override
public boolean onMenuItemClick(final MenuItem item) {
    final ParcelableStatus status = mSelectedStatus;
    if (status == null)
        return false;
    final long account_id = getDefaultAccountId(mApplication);
    switch (item.getItemId()) {
    case MENU_VIEW: {
        openStatus(getActivity(), status);
        break;/*ww w. j a  va 2  s. c  o m*/
    }
    case MENU_SHARE: {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "@" + status.screen_name + ": " + status.text_plain);
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
        break;
    }
    case MENU_TRANSLATE: {
        translate(status);
        break;
    }
    case MENU_RETWEET: {
        if (isMyRetweet(status)) {
            mService.destroyStatus(status.account_id, status.status_id);
        } else {
            final long id_to_retweet = mSelectedStatus.is_retweet && mSelectedStatus.retweet_id > 0
                    ? mSelectedStatus.retweet_id
                    : mSelectedStatus.status_id;
            mService.retweetStatus(status.account_id, id_to_retweet);
        }
        break;
    }
    case MENU_QUOTE: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putBoolean(INTENT_KEY_IS_QUOTE, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_QUOTE_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name);
        bundle.putBoolean(INTENT_KEY_IS_QUOTE, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_ADD_TO_BUFFER: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putBoolean(INTENT_KEY_IS_BUFFER, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        final List<String> mentions = new Extractor().extractMentionedScreennames(status.text_plain);
        mentions.remove(status.screen_name);
        mentions.add(0, status.screen_name);
        bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()]));
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_TWEET, status.text_plain);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name);
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_FAV: {
        if (mSelectedStatus.is_favorite) {
            mService.destroyFavorite(status.account_id, status.status_id);
        } else {
            mService.createFavorite(status.account_id, status.status_id);
        }
        break;
    }
    case MENU_CONVERSATION: {
        openConversation(getActivity(), status.account_id, status.status_id);
        break;
    }
    case MENU_DELETE: {
        mService.destroyStatus(status.account_id, status.status_id);
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_STATUS, status);
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    case MENU_MULTI_SELECT: {
        if (!mApplication.isMultiSelectActive()) {
            mApplication.startMultiSelect();
        }
        final NoDuplicatesLinkedList<Object> list = mApplication.getSelectedItems();
        if (!list.contains(status)) {
            list.add(status);
        }
        break;
    }
    case MENU_BLOCK: {
        mService.createBlock(account_id, status.user_id);
        break;
    }
    case MENU_REPORT_SPAM: {
        mService.reportSpam(account_id, status.user_id);
        break;
    }
    case MENU_MUTE_USER: {
        final String screen_name = status.screen_name;
        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_MAKE_GAP: {
        Uri uri = Statuses.CONTENT_URI;
        final Uri query_uri = buildQueryUri(uri, false);
        ContentResolver mResolver = getContentResolver();
        final ContentValues values = new ContentValues();
        values.put(Statuses.IS_GAP, 1);
        final StringBuilder where = new StringBuilder();
        where.append(Statuses.ACCOUNT_ID + "=" + account_id);
        where.append(" AND " + Statuses.STATUS_ID + "=" + status.status_id);
        mResolver.update(query_uri, values, where.toString(), null);
        getActivity().sendBroadcast(new Intent(BROADCAST_FILTERS_UPDATED).putExtra(INTENT_KEY_SUCCEED, true));
        break;
    }
    case MENU_COPY: {
        final CharSequence text = Html.fromHtml(status.text_html);
        if (ClipboardUtils.setText(getActivity(), text)) {
            Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show();
        }
        break;
    }
    }
    return true;
}