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.hotstar.player.adplayer.player.PlayerFragment.java

/**
 * Called from main activity.// www.  j a  v  a 2 s  .  co  m
 */
protected void onFragmentSaveInstanceState(Bundle outState) {
    AdVideoApplication.logger.i(LOG_TAG + "#onSaveInstanceState", "Saving activity state.");

    outState.putLong(CURRENT_PLAYER_POSITION, lastKnownTime);
    AdVideoApplication.logger.i(LOG_TAG + "#onSaveInstanceState",
            "Current player time [" + lastKnownTime + "] saved.");

    outState.putSerializable(CURRENT_PLAYER_STATE, savedPlayerState);
    AdVideoApplication.logger.i(LOG_TAG + "#onSaveInstanceState",
            "Current player state [" + savedPlayerState + "] saved.");
}

From source file:com.android.email.activity.MessageView.java

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    if (mMessageId != -1) {
        state.putLong(STATE_MESSAGE_ID, mMessageId);
    }/*w  ww  . j a va  2s.c o  m*/
}

From source file:com.ichi2.anki.NoteEditor.java

@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    Timber.i("Saving instance");
    savedInstanceState.putInt("caller", mCaller);
    savedInstanceState.putBoolean("addFact", mAddNote);
    savedInstanceState.putLong("did", mCurrentDid);
    savedInstanceState.putStringArray("tags", mSelectedTags.toArray(new String[mSelectedTags.size()]));
    Bundle fields = new Bundle();
    // Save the content of all the note fields. We use the field's ord as the key to
    // easily map the fields correctly later.
    for (FieldEditText e : mEditFields) {
        fields.putString(Integer.toString(e.getOrd()), e.getText().toString());
    }/*from   ww  w  .  j  ava 2 s .c  o  m*/
    savedInstanceState.putBundle("editFields", fields);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:androidx.media.MediaController2.java

/**
 * Move to a new location in the media stream.
 *
 * @param pos Position to move to, in milliseconds.
 *//*from   w  w  w  .ja v a 2 s . c  o  m*/
public void seekTo(long pos) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle args = new Bundle();
        args.putLong(ARGUMENT_SEEK_POSITION, pos);
        sendCommand(COMMAND_CODE_PLAYBACK_SEEK_TO, args);
    }
}

From source file:com.mantz_it.rfanalyzer.ui.activity.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);
    // todo: also save source settings? definitely in need of interface handling settings
    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 w w  . j  a va  2 s .c  om
}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

/**
 * ??//from w ww.  j  av a 2  s  .c  om
 *
 * @param outState Bundle
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    Field[] fields = this.getClass().getDeclaredFields();
    Field.setAccessible(fields, true);
    Annotation[] ans;
    for (Field f : fields) {
        ans = f.getDeclaredAnnotations();
        for (Annotation an : ans) {
            if (an instanceof SaveWithActivity) {
                try {
                    Object o = f.get(this);
                    if (o == null) {
                        continue;
                    }
                    String fieldName = f.getName();
                    if (o instanceof Integer) {
                        outState.putInt(fieldName, f.getInt(this));
                    } else if (o instanceof String) {
                        outState.putString(fieldName, (String) f.get(this));
                    } else if (o instanceof Long) {
                        outState.putLong(fieldName, f.getLong(this));
                    } else if (o instanceof Short) {
                        outState.putShort(fieldName, f.getShort(this));
                    } else if (o instanceof Boolean) {
                        outState.putBoolean(fieldName, f.getBoolean(this));
                    } else if (o instanceof Byte) {
                        outState.putByte(fieldName, f.getByte(this));
                    } else if (o instanceof Character) {
                        outState.putChar(fieldName, f.getChar(this));
                    } else if (o instanceof CharSequence) {
                        outState.putCharSequence(fieldName, (CharSequence) f.get(this));
                    } else if (o instanceof Float) {
                        outState.putFloat(fieldName, f.getFloat(this));
                    } else if (o instanceof Double) {
                        outState.putDouble(fieldName, f.getDouble(this));
                    } else if (o instanceof String[]) {
                        outState.putStringArray(fieldName, (String[]) f.get(this));
                    } else if (o instanceof Parcelable) {
                        outState.putParcelable(fieldName, (Parcelable) f.get(this));
                    } else if (o instanceof Serializable) {
                        outState.putSerializable(fieldName, (Serializable) f.get(this));
                    } else if (o instanceof Bundle) {
                        outState.putBundle(fieldName, (Bundle) f.get(this));
                    }
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    super.onSaveInstanceState(outState);
}

From source file:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java

/**
 * When the Fragment is being saved in order to change activity state, save the
 * currently-selected contact./*from   w  w  w .j  a v  a2  s  . c o  m*/
 */
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Saves the contact Uri
    outState.putParcelable(EXTRA_CONTACT_URI, mContactUri);

    //save the displayed address
    outState.putString(BUNDLE_CONTACT_ADDRESS, mAddressViewButton.getText().toString());

    //save the event notes
    outState.putString(BUNDLE_EVENT_NOTES, mEventNotes.getText().toString());

    //save the event date/time
    outState.putLong(BUNDLE_EVENT_DATE_TIME, mEventDate);

}

From source file:com.android.calendar.event.EditEventView.java

private void showTimezoneDialog() {
    Bundle b = new Bundle();
    b.putLong(TimeZonePickerDialog.BUNDLE_START_TIME_MILLIS, mStartTime.toMillis(false));
    b.putString(TimeZonePickerDialog.BUNDLE_TIME_ZONE, mTimezone);

    FragmentManager fm = mActivity.getSupportFragmentManager();
    TimeZonePickerDialog tzpd = (TimeZonePickerDialog) fm.findFragmentByTag(FRAG_TAG_TIME_ZONE_PICKER);
    if (tzpd != null) {
        tzpd.dismiss();//  w w w.  j  a  v a 2  s  . c o m
    }
    tzpd = new TimeZonePickerDialog();
    tzpd.setArguments(b);
    tzpd.setOnTimeZoneSetListener(EditEventView.this);
    tzpd.show(fm, FRAG_TAG_TIME_ZONE_PICKER);
}

From source file:com.android.calendar.event.EditEventView.java

@Override
public void onClick(View view) {
    if (view == mRruleButton) {
        Bundle b = new Bundle();
        b.putLong(RecurrencePickerDialog.BUNDLE_START_TIME_MILLIS, mStartTime.toMillis(false));
        b.putString(RecurrencePickerDialog.BUNDLE_TIME_ZONE, mStartTime.timezone);

        // TODO may be more efficient to serialize and pass in
        // EventRecurrence
        b.putString(RecurrencePickerDialog.BUNDLE_RRULE, mRrule);

        FragmentManager fm = mActivity.getSupportFragmentManager();
        RecurrencePickerDialog rpd = (RecurrencePickerDialog) fm.findFragmentByTag(FRAG_TAG_RECUR_PICKER);
        if (rpd != null) {
            rpd.dismiss();//from w w  w . java 2s. c o  m
        }
        rpd = new RecurrencePickerDialog();
        rpd.setArguments(b);
        rpd.setOnRecurrenceSetListener(EditEventView.this);
        rpd.show(fm, FRAG_TAG_RECUR_PICKER);
        return;
    }

    // This must be a click on one of the "remove reminder" buttons
    LinearLayout reminderItem = (LinearLayout) view.getParent();
    LinearLayout parent = (LinearLayout) reminderItem.getParent();
    parent.removeView(reminderItem);
    mReminderItems.remove(reminderItem);
    updateRemindersVisibility(mReminderItems.size());
    EventViewUtils.updateAddReminderButton(mView, mReminderItems, mModel.mCalendarMaxReminders);
}