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.github.gorbin.asne.twitter.TwitterSocialNetwork.java

/**
 * Request user {@link com.github.gorbin.asne.twitter.TwitterPerson} by userId - detailed user data
 * @param userId id of Twitter user/*from   w  w  w .  j a  va2  s.  com*/
 * @param onRequestDetailedSocialPersonCompleteListener listener for request detailed social person
 */
@Override
public void requestDetailedSocialPerson(String userId,
        OnRequestDetailedSocialPersonCompleteListener onRequestDetailedSocialPersonCompleteListener) {
    super.requestDetailedSocialPerson(userId, onRequestDetailedSocialPersonCompleteListener);
    Bundle args = new Bundle();
    if (userId != null) {
        try {
            args.putLong(RequestGetDetailedPersonAsyncTask.PARAM_USER_ID, Long.parseLong(userId));
        } catch (NumberFormatException e) {
            throw new SocialNetworkException("userID should be long number");
        }
    }
    executeRequest(new RequestGetDetailedPersonAsyncTask(), args, REQUEST_GET_DETAIL_PERSON);
}

From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java

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

    Log.v(TAG, "In fragment save instance state");
    // Store amount.
    outState.putDouble(AMOUNT_KEY, getInputAmount());
    // Store selected account.
    outState.putInt(ACCOUNT_KEY, mAccountsSpinner.getSelectedItemPosition());
    // Store date.
    outState.putLong(DATE_KEY, getInputDate());
    // Store notes.
    outState.putString(NOTES_KEY, getInputNotes());

}

From source file:com.android.calendar.agenda.AgendaFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mAgendaListView == null) {
        return;//from  ww w .j  ava 2s. co m
    }
    if (mShowEventDetailsWithAgenda) {
        long timeToSave;
        if (mLastHandledEventTime != null) {
            timeToSave = mLastHandledEventTime.toMillis(true);
            mTime.set(mLastHandledEventTime);
        } else {
            timeToSave = System.currentTimeMillis();
            mTime.set(timeToSave);
        }
        outState.putLong(BUNDLE_KEY_RESTORE_TIME, timeToSave);
        mController.setTime(timeToSave);
    } else {
        AgendaWindowAdapter.AgendaItem item = mAgendaListView.getFirstVisibleAgendaItem();
        if (item != null) {
            long firstVisibleTime = mAgendaListView.getFirstVisibleTime(item);
            if (firstVisibleTime > 0) {
                mTime.set(firstVisibleTime);
                mController.setTime(firstVisibleTime);
                outState.putLong(BUNDLE_KEY_RESTORE_TIME, firstVisibleTime);
            }
            // Tell AllInOne the event id of the first visible event in the list. The id will be
            // used in the GOTO when AllInOne is restored so that Agenda Fragment can select a
            // specific event and not just the time.
            mLastShownEventId = item.id;
        }
    }
    if (DEBUG) {
        Log.v(TAG, "onSaveInstanceState " + mTime.toString());
    }

    long selectedInstance = mAgendaListView.getSelectedInstanceId();
    if (selectedInstance >= 0) {
        outState.putLong(BUNDLE_KEY_RESTORE_INSTANCE_ID, selectedInstance);
    }
}

From source file:com.psiphon3.psiphonlibrary.TunnelManager.java

private Bundle getDataTransferStatsBundle() {
    Bundle data = new Bundle();
    data.putLong(DATA_TRANSFER_STATS_CONNECTED_TIME,
            DataTransferStats.getDataTransferStatsForService().m_connectedTime);
    data.putLong(DATA_TRANSFER_STATS_TOTAL_BYTES_SENT,
            DataTransferStats.getDataTransferStatsForService().m_totalBytesSent);
    data.putLong(DATA_TRANSFER_STATS_TOTAL_BYTES_RECEIVED,
            DataTransferStats.getDataTransferStatsForService().m_totalBytesReceived);
    data.putParcelableArrayList(DATA_TRANSFER_STATS_SLOW_BUCKETS,
            DataTransferStats.getDataTransferStatsForService().m_slowBuckets);
    data.putLong(DATA_TRANSFER_STATS_SLOW_BUCKETS_LAST_START_TIME,
            DataTransferStats.getDataTransferStatsForService().m_slowBucketsLastStartTime);
    data.putParcelableArrayList(DATA_TRANSFER_STATS_FAST_BUCKETS,
            DataTransferStats.getDataTransferStatsForService().m_fastBuckets);
    data.putLong(DATA_TRANSFER_STATS_FAST_BUCKETS_LAST_START_TIME,
            DataTransferStats.getDataTransferStatsForService().m_fastBucketsLastStartTime);
    return data;//from  w w w . j a  va  2  s.c o  m
}

From source file:com.example.android.snake.SnakeView.java

/**
 * Save game state so that the user does not lose anything
 * if the game process is killed while we are in the
 * background.// ww  w.  ja v  a 2 s.co  m
 *
 * @return a Bundle with this view's state
 */
public Bundle saveState() {
    Bundle map = new Bundle();

    map.putIntArray("mAppleList", coordArrayListToArray(mAppleList));
    map.putInt("mDirection", Integer.valueOf(mDirection));
    map.putInt("mNextDirection", Integer.valueOf(mNextDirection));
    map.putLong("mMoveDelay", Long.valueOf(mMoveDelay));
    map.putLong("mScore", Long.valueOf(mScore));
    map.putIntArray("mSnakeTrail", coordArrayListToArray(mSnakeTrail));

    return map;
}

From source file:com.example.app_2.activities.ImageGridActivity.java

@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
    if (actual_category_fk == null) {
        return false;
    }/* w  w w  .  j  av  a2 s  . c  o m*/
    Bundle args = new Bundle();
    if (igf.getActivity() != null) {
        switch (itemPosition) {

        case 0: // alfabetycznie 
            ImageGridFragment.sortOrder = "i." + ImageContract.Columns.DESC + " COLLATE LOCALIZED ASC";
            args.putLong("CATEGORY_ID", actual_category_fk.getCategoryId());
            igf.getLoaderManager().restartLoader(1, args, (LoaderCallbacks<Cursor>) igf);
            break;
        case 1: // ostatnio zmodyfikowane
            ImageGridFragment.sortOrder = "i." + ImageContract.Columns.MODIFIED + " DESC";
            args.putLong("CATEGORY_ID", actual_category_fk.getCategoryId());
            igf.getLoaderManager().restartLoader(1, args, (LoaderCallbacks<Cursor>) igf);
            break;
        case 2: // najczciej uywane
            ImageGridFragment.sortOrder = "i." + ImageContract.Columns.TIME_USED + " DESC";
            args.putLong("CATEGORY_ID", actual_category_fk.getCategoryId());
            igf.getLoaderManager().restartLoader(1, args, (LoaderCallbacks<Cursor>) igf);
            break;

        default:
            break;
        }
    }

    return false;
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.TaskDetailFragment.java

@Override
public void onActivityCreated(final Bundle state) {
    super.onActivityCreated(state);

    if (dontLoad) {
        return;/*  w ww . ja v a  2s. c  o m*/
    }

    boolean openKb = false;

    final Bundle args = new Bundle();

    long idToOpen = mListener.getEditorTaskId();

    getArguments().putLong(ARG_ITEM_ID, idToOpen);
    if (idToOpen > 0) {
        // Load data from database
        args.putLong(ARG_ITEM_ID, idToOpen);
        getLoaderManager().restartLoader(LOADER_EDITOR_TASK, args, loaderCallbacks);
    } else {
        // If not valid, find a valid list
        long listId = mListener.getListOfTask();
        if (listId < 1) {
            listId = getARealList(getActivity(), -1);
        }
        // Fail if still not valid
        if (listId < 1) {
            // throw new InvalidParameterException(
            // "Must specify a list id to create a note in!");
            Toast.makeText(getActivity(), "Must specify a list id to create a note in!", Toast.LENGTH_SHORT)
                    .show();
            getActivity().finish();
            return;
        }
        getArguments().putLong(ARG_ITEM_LIST_ID, listId);
        args.putLong(ARG_ITEM_LIST_ID, listId);
        getLoaderManager().restartLoader(LOADER_EDITOR_TASKLISTS, args, loaderCallbacks);

        openKb = true;
        mTaskOrg = new Task();
        mTask = new Task();
        mTask.dblist = listId;
        // New note but start with the text given
        mTask.setText(mListener.getInitialTaskText());
        fillUIFromTask();
    }

    if (openKb) {
        /**
         * Only show keyboard for new/empty notes But not if the showcase
         * view is showing
         */
        taskText.requestFocus();
        inputManager.showSoftInput(taskText, InputMethodManager.SHOW_IMPLICIT);
    }
}

From source file:com.guayaba.tapir.ui.fragments.PlaylistFragment.java

/**
 * {@inheritDoc}/*from  w  w w.java 2  s. c  om*/
 */
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    final Bundle bundle = new Bundle();
    mPlaylist = mAdapter.getItem(position);
    String playlistName;
    // Favorites list
    if (position == 0) {
        playlistName = getString(R.string.playlist_favorites);
        bundle.putString(Config.MIME_TYPE, getString(R.string.playlist_favorites));
        // Last added
    } else if (position == 1) {
        playlistName = getString(R.string.playlist_last_added);
        bundle.putString(Config.MIME_TYPE, getString(R.string.playlist_last_added));
    } else {
        // User created
        playlistName = mPlaylist.mPlaylistName;
        bundle.putString(Config.MIME_TYPE, MediaStore.Audio.Playlists.CONTENT_TYPE);
        bundle.putLong(Config.ID, mPlaylist.mPlaylistId);
    }

    bundle.putString(Config.NAME, playlistName);

    // Create the intent to launch the profile activity
    final Intent intent = new Intent(getActivity(), ProfileActivity.class);
    intent.putExtras(bundle);
    startActivity(intent);
}

From source file:ca.spencerelliott.mercury.Changesets.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    this.requestWindowFeature(Window.FEATURE_PROGRESS);
    this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.changesets);

    //Cancel any notifications previously setup
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(1);//from w  w  w  . j  a v a 2s  .com

    //Create a new array list for the changesets
    changesets_list = new ArrayList<Map<String, ?>>();
    changesets_data = new ArrayList<Beans.ChangesetBean>();

    //Get the list view to store the changesets
    changesets_listview = (ListView) findViewById(R.id.changesets_list);

    TextView empty_text = (TextView) findViewById(R.id.changesets_empty_text);

    //Set the empty view
    changesets_listview.setEmptyView(empty_text);

    //Use a simple adapter to display the changesets based on the array list made earlier
    changesets_listview.setAdapter(new SimpleAdapter(this, changesets_list, R.layout.changeset_item,
            new String[] { COMMIT, FORMATTED_INFO },
            new int[] { R.id.changesets_commit, R.id.changesets_info }));

    //Set the on click listener
    changesets_listview.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {
            Intent intent = new Intent(Changesets.this, ChangesetViewer.class);

            //Pass the changeset information to the changeset viewer
            Bundle params = new Bundle();
            params.putString("changeset_commit_text", changesets_data.get(position).getTitle());
            params.putString("changeset_changes", changesets_data.get(position).getContent());
            params.putLong("changeset_updated", changesets_data.get(position).getUpdated());
            params.putString("changeset_authors", changesets_data.get(position).getAuthor());
            params.putString("changeset_link", changesets_data.get(position).getLink());
            //params.putBoolean("is_https", is_https);

            intent.putExtras(params);

            startActivity(intent);
        }

    });

    //Register the list view for opening the context menu
    registerForContextMenu(changesets_listview);

    //Get the intent passed by the program
    if (getIntent() != null) {
        //Check to see if this is a search window
        if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
            //Change the title of the activity and the empty text of the list so it looks like a search window
            this.setTitle(R.string.search_results_label);
            empty_text.setText(R.string.search_results_empty);

            //Retrieve the query the user entered
            String query = getIntent().getStringExtra(SearchManager.QUERY);

            //Convert the query to lower case
            query = query.toLowerCase();

            //Retrieve the bundle data
            Bundle retrieved_data = getIntent().getBundleExtra(SearchManager.APP_DATA);

            //If the bundle was passed, grab the changeset data
            if (retrieved_data != null) {
                changesets_data = retrieved_data
                        .getParcelableArrayList("ca.spencerelliott.mercury.SEARCH_DATA");
            }

            //If we're missing changeset data, stop here
            if (changesets_data == null)
                return;

            //Create a new array list to store the changesets that were a match
            ArrayList<Beans.ChangesetBean> search_beans = new ArrayList<Beans.ChangesetBean>();

            //Loop through each changeset
            for (Beans.ChangesetBean b : changesets_data) {
                //Check to see if any changesets match
                if (b.getTitle().toLowerCase().contains(query)) {
                    //Get the title and date of the commit
                    String commit_text = b.getTitle();
                    Date commit_date = new Date(b.getUpdated());

                    //Add a new changeset to display in the list view
                    changesets_list.add(createChangeset(
                            (commit_text.length() > 30 ? commit_text.substring(0, 30) + "..." : commit_text),
                            b.getRevisionID() + " - " + commit_date.toLocaleString()));

                    //Add this bean to the list of found search beans
                    search_beans.add(b);
                }
            }

            //Switch the changeset data over to the changeset data that was a match
            changesets_data = search_beans;

            //Update the list in the activity
            list_handler.sendEmptyMessage(SUCCESSFUL);

            //Notify the activity that it is a search window
            is_search_window = true;

            //Stop loading here
            return;
        }

        //Get the data from the intent
        Uri data = getIntent().getData();

        if (data != null) {
            //Extract the path in the intent
            String path_string = data.getEncodedPath();

            //Split it by the forward slashes
            String[] split_path = path_string.split("/");

            //Make sure a valid path was passed
            if (split_path.length == 3) {
                //Get the repository id from the intent
                repo_id = Long.parseLong(split_path[2].toString());
            } else {
                //Notify the user if there was a problem
                Toast.makeText(this, R.string.invalid_intent, 1000).show();
            }
        }
    }

    //Retrieve the changesets
    refreshChangesets();
}

From source file:com.andrew.apollo.ui.fragments.PlaylistFragment.java

/**
 * {@inheritDoc}/*  ww  w  .j av  a  2  s  .c  o  m*/
 */
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    final Bundle bundle = new Bundle();
    mPlaylist = mAdapter.getItem(position);
    String playlistName;
    // Favorites list
    if (position == 0) {
        playlistName = getString(R.string.playlist_favorites);
        bundle.putString(Config.MIME_TYPE, getString(R.string.playlist_favorites));
        // Last added
    } else if (position == 1) {
        playlistName = getString(R.string.playlist_last_added);
        bundle.putString(Config.MIME_TYPE, getString(R.string.playlist_last_added));
    } else {
        // User created
        playlistName = mPlaylist.mPlaylistName;
        bundle.putString(Config.MIME_TYPE, MediaStore.Audio.Playlists.CONTENT_TYPE);
        bundle.putLong(Config.ID, Long.valueOf(mPlaylist.mPlaylistId));
    }

    bundle.putString(Config.NAME, playlistName);

    // Create the intent to launch the profile activity
    final Intent intent = new Intent(getSherlockActivity(), ProfileActivity.class);
    intent.putExtras(bundle);
    startActivity(intent);
}