Java Code Examples for android.os.Bundle.putLong()

The following are Jave code examples for showing how to use putLong() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: letv   File: KVUtils.java   View Source Code Vote up 7 votes
public static Bundle put(Bundle to, Intent from, String key) {
    if (!(to == null || from == null || TextUtils.empty(key) || !from.hasExtra(key))) {
        Object value = from.getExtras().get(key);
        if (value instanceof Boolean) {
            to.putBoolean(key, ((Boolean) value).booleanValue());
        } else if (value instanceof Byte) {
            to.putByte(key, ((Byte) value).byteValue());
        } else if (value instanceof Character) {
            to.putChar(key, ((Character) value).charValue());
        } else if (value instanceof Short) {
            to.putShort(key, ((Short) value).shortValue());
        } else if (value instanceof Integer) {
            to.putInt(key, ((Integer) value).intValue());
        } else if (value instanceof Long) {
            to.putLong(key, ((Long) value).longValue());
        } else if (value instanceof Float) {
            to.putFloat(key, ((Float) value).floatValue());
        } else if (value instanceof Double) {
            to.putDouble(key, ((Double) value).doubleValue());
        } else if (value instanceof String) {
            to.putString(key, (String) value);
        }
    }
    return to;
}
 
Example 2
Project: rental-calc   File: PropertyNotesActivityTest.java   View Source Code Vote up 6 votes
@Test
public void startWithMissingProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", 0);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyNotesActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
Example 3
Project: RNLearn_Project1   File: DatePickerDialogModule.java   View Source Code Vote up 6 votes
private Bundle createFragmentArguments(ReadableMap options) {
  final Bundle args = new Bundle();
  if (options.hasKey(ARG_DATE) && !options.isNull(ARG_DATE)) {
    args.putLong(ARG_DATE, (long) options.getDouble(ARG_DATE));
  }
  if (options.hasKey(ARG_MINDATE) && !options.isNull(ARG_MINDATE)) {
    args.putLong(ARG_MINDATE, (long) options.getDouble(ARG_MINDATE));
  }
  if (options.hasKey(ARG_MAXDATE) && !options.isNull(ARG_MAXDATE)) {
    args.putLong(ARG_MAXDATE, (long) options.getDouble(ARG_MAXDATE));
  }
  if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) {
    args.putString(ARG_MODE, options.getString(ARG_MODE));
  }
  return args;
}
 
Example 4
Project: admob-rewarded-video   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putBoolean(GAME_PAUSE_KEY, mGamePaused);
    outState.putBoolean(GAME_OVER_KEY, mGameOver);
    outState.putLong(TIME_REMAINING_KEY, mTimeRemaining);
    outState.putInt(COIN_COUNT_KEY, mCoinCount);
    super.onSaveInstanceState(outState);
}
 
Example 5
Project: buildAPKsApps   File: AlarmClockActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case R.id.default_options:
    AlarmOptions options = new AlarmOptions();
    Bundle b = new Bundle();
    b.putLong(AlarmNotificationService.ALARM_ID, DbUtil.Settings.DEFAULTS_ID);
    options.setArguments(b);
    options.show(getFragmentManager(), "default_alarm_options");
    return true;

  case R.id.display_notification:
    boolean new_val = !item.isChecked();
    item.setChecked(new_val);
    PreferenceManager.getDefaultSharedPreferences(this)
      .edit()
      .putBoolean(AlarmNotificationService.DISPLAY_NOTIFICATION, new_val)
      .commit();
    AlarmNotificationService.refreshNotificationBar(this);
    return true;

  case R.id.delete_all:
    new DeleteAllConfirmation()
      .show(getFragmentManager(), "confirm_delete_all");

    return true;
  default:
    return super.onOptionsItemSelected(item);
  }
}
 
Example 6
Project: chat-sdk-android-push-firebase   File: AuthorizationClient.java   View Source Code Vote up 5 votes
private void logAuthorizationMethodComplete(String method, String result, String errorMessage, String errorCode,
        Map<String, String> loggingExtras) {
    Bundle bundle = null;
    if (pendingRequest == null) {
        // We don't expect this to happen, but if it does, log an event for diagnostic purposes.
        bundle = newAuthorizationLoggingBundle("");
        bundle.putString(EVENT_PARAM_LOGIN_RESULT, Result.Code.ERROR.getLoggingValue());
        bundle.putString(EVENT_PARAM_ERROR_MESSAGE,
                "Unexpected call to logAuthorizationMethodComplete with null pendingRequest.");
    } else {
        bundle = newAuthorizationLoggingBundle(pendingRequest.getAuthId());
        if (result != null) {
            bundle.putString(EVENT_PARAM_LOGIN_RESULT, result);
        }
        if (errorMessage != null) {
            bundle.putString(EVENT_PARAM_ERROR_MESSAGE, errorMessage);
        }
        if (errorCode != null) {
            bundle.putString(EVENT_PARAM_ERROR_CODE, errorCode);
        }
        if (loggingExtras != null && !loggingExtras.isEmpty()) {
            JSONObject jsonObject = new JSONObject(loggingExtras);
            bundle.putString(EVENT_PARAM_EXTRAS, jsonObject.toString());
        }
    }
    bundle.putString(EVENT_PARAM_METHOD, method);
    bundle.putLong(EVENT_PARAM_TIMESTAMP, System.currentTimeMillis());

    getAppEventsLogger().logSdkEvent(EVENT_NAME_LOGIN_METHOD_COMPLETE, null, bundle);
}
 
Example 7
Project: Todule-android   File: ToduleLabelAddFragment.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if(selected_color != null) {
        outState.putInt("selected_color", selected_color);
    }
    outState.putLong("label_id", labelId);
}
 
Example 8
Project: robird-reborn   File: TimelineFragment.java   View Source Code Vote up 5 votes
public static TimelineFragment create(Account account, long timelineId) {
    Bundle args = new Bundle();
    args.putLong("timeline_id", timelineId);
    args.putParcelable("account", account);

    TimelineFragment fragment = new TimelineFragment();
    fragment.setArguments(args);

    return fragment;
}
 
Example 9
Project: TrainPonctuality   File: InputDepartureActivity.java   View Source Code Vote up 5 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putParcelable("departureStation", departureStation);
    outState.putString("selectedLine", selectedLine.getCode());
    outState.putLong("departureDate", departureDate.getTimeInMillis());
    outState.putString("trip", tripId);
}
 
Example 10
Project: xyz-reader-2   File: ArticleDetailFragment.java   View Source Code Vote up 5 votes
public static ArticleDetailFragment newInstance(long itemId) {
    Bundle arguments = new Bundle();
    arguments.putLong(ARG_ITEM_ID, itemId);
    ArticleDetailFragment fragment = new ArticleDetailFragment();
    fragment.setArguments(arguments);
    return fragment;
}
 
Example 11
Project: tumblrlikes   File: PhotoFragment.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    if (_photoUrl != null) {
        outState.putString(KEY_PHOTO_URL, _photoUrl);
    }
    if (_photoId != null) {
        outState.putLong(KEY_PHOTO_ID, _photoId);
    }
}
 
Example 12
Project: AndiCar   File: SearchDialogFragment.java   View Source Code Vote up 5 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (tvDateToSearch.getText().length() > 0) {
        outState.putLong(DATE_TO_IN_MILLIS_KEY, mDateToCalendar.getTimeInMillis());
    }
    if (tvDateFromSearch.getText().length() > 0) {
        outState.putLong(DATE_FROM_IN_MILLIS_KEY, mDateFromCalendar.getTimeInMillis());
    }
}
 
Example 13
Project: MusicX-music-player   File: MusicXService.java   View Source Code Vote up 5 votes
@Override
public void updateService(String updateservices) {
    Intent intent = new Intent(updateservices);
    if (updateservices.equals(PLAYSTATE_CHANGED) && intent.getAction().equals(PLAYSTATE_CHANGED)) {
        sendBroadcast(intent);
    } else if (updateservices.equals(META_CHANGED) && intent.getAction().equals(META_CHANGED)) {
        Bundle bundle = new Bundle();
        bundle.putString(SONG_TITLE, getsongTitle());
        bundle.putString(SONG_ALBUM, getsongAlbumName());
        bundle.putLong(SONG_ALBUM_ID, getsongAlbumID());
        bundle.putString(SONG_ARTIST, getsongArtistName());
        bundle.putLong(SONG_ID, getsongId());
        bundle.putString(SONG_PATH, getsongData());
        bundle.putInt(SONG_TRACK_NUMBER, getsongNumber());
        bundle.putInt(POSITION_CHANGED, returnpos());
        intent.putExtras(bundle);
        Log.d(TAG, "broadcast song metadata");
        sendBroadcast(intent);
    } else if ((updateservices.equals(QUEUE_CHANGED) || updateservices.equals(ORDER_CHANGED) || updateservices.equals(ITEM_ADDED)) && (intent.getAction().equals(QUEUE_CHANGED) || intent.getAction().equals(ORDER_CHANGED) || intent.getAction().equals(ITEM_ADDED))) {
        sendBroadcast(intent);
        saveState(true);
    }
    if (onPlayNotify) {
        if (!Extras.getInstance().hideNotify()) {
            NotificationHandler.buildNotification(MusicXService.this, updateservices);
        }
    }
    musicxWidget.notifyChange(this, updateservices);
    musicXwidget4x4.notifyChange(this, updateservices);
    musicXWidget5x5.notifyChange(this, updateservices);
    if (!Extras.getInstance().hideLockscreen()) {
        MediaSession.lockscreenMedia(getMediaSession(), MusicXService.this, updateservices);
    }
}
 
Example 14
Project: Rey-MusicPlayer   File: SearchAdapter.java   View Source Code Vote up 5 votes
@Override
public void onClick(View v) {
    Bundle bundle = new Bundle();
    Genre genre = (Genre) mData.get(getAdapterPosition());
    bundle.putString(Constants.HEADER_TITLE, genre._genreName);
    bundle.putInt(Constants.HEADER_SUB_TITLE, genre._noOfAlbumsInGenre);
    bundle.putString(Constants.FROM_WHERE, "GENRES");
    bundle.putLong(Constants.SELECTION_VALUE, genre._genreId);
    bundle.putString(Constants.COVER_PATH, genre._genreAlbumArt);

    TracksSubGridViewFragment tracksSubGridViewFragment = new TracksSubGridViewFragment();
    tracksSubGridViewFragment.setArguments(bundle);
    mSearchActivity.addFragment(tracksSubGridViewFragment);
}
 
Example 15
Project: BizareChat   File: NewChatFragment.java   View Source Code Vote up 5 votes
@Override
public void showPublicChatRoom(DialogModel dialogModel) {
    String tag = CHAT_ROOM_FR_TAG + dialogModel.getDialogId();
    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
    Fragment fragment = getActivity().getSupportFragmentManager().findFragmentByTag(tag);
    getActivity().getSupportFragmentManager().popBackStackImmediate();
    if (fragment != null) {
        transaction.replace(R.id.main_screen_container, fragment, tag)
                .commit();
        return;
    }

    fragment = new ChatRoomFragment();
    Bundle args = new Bundle();
    args.putString(ChatRoomFragment.DIALOG_ID_BUNDLE_KEY, dialogModel.getDialogId());
    args.putLong(ChatRoomFragment.DIALOG_ADMIN_BUNDLE_KEY, dialogModel.getAdminId());
    args.putString(ChatRoomFragment.DIALOG_NAME_BUNDLE_KEY, dialogModel.getName());
    args.putInt(ChatRoomFragment.DIALOG_TYPE_BUNDLE_KEY, dialogModel.getType());
    args.putString(ChatRoomFragment.DIALOG_ROOM_JID_BUNDLE_KEY, dialogModel.getXmppRoomJid());
    ArrayList<Integer> list = new ArrayList<>(dialogModel.getOccupantsIds());
    args.putIntegerArrayList(ChatRoomFragment.OCCUPANTS_IDS_BUNDLE_KEY, list);

    fragment.setArguments(args);
    transaction.replace(R.id.main_screen_container, fragment, tag)
            .addToBackStack(null)
            .commit();
}
 
Example 16
Project: chat-sdk-android-push-firebase   File: ChatSDKBaseThreadActivity.java   View Source Code Vote up 5 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(THREAD_ID, threadID);
    outState.putString(THREAD_ENTITY_ID, threadEntityId);
    outState.putInt(MODE, mode);
    outState.putBoolean(ChatSDKAbstractChatActivity.ANIMATE_EXIT, animateExit);
}
 
Example 17
Project: CSipSimple   File: AccountFiltersListFragment.java   View Source Code Vote up 4 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(CURRENT_CHOICE, curCheckFilterId);
}
 
Example 18
Project: Chidori   File: EventBus.java   View Source Code Vote up 4 votes
public void postRemote(String remotePkg, long event) {
    Bundle bundle = new Bundle();
    bundle.putLong(ChidoriClient.CHIDORI_EVENT, event);
    send(remotePkg, bundle);
}
 
Example 19
Project: RxRemote   File: RemoteEventController.java   View Source Code Vote up 4 votes
private void addDataToBundle(Bundle remoteData, Object data, RemoteDataType dataType, String keyPrefix) throws Exception {
    remoteData.putString(RemoteEventManager.REMOTE_DATA_TYPE + keyPrefix, dataType.name());
    switch (dataType) {
        case List:
            List listData = (List) data;
            int dataSize = listData != null ? listData.size() : 0;
            remoteData.putInt(RemoteEventManager.REMOTE_DATA_LIST_SIZE + keyPrefix, dataSize);
            RemoteDataType itemDataType = null;
            for (int i = 0; i < dataSize; i++) {
                Object item = listData.get(i);
                if (itemDataType == null) {
                    itemDataType = findDataType(item);
                }
                addDataToBundle(remoteData, item, itemDataType, keyPrefix + i);
            }
            break;

        case Parcelable:
            remoteData.putParcelable(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Parcelable) data);
            break;
        case Parceler:
            writeParceler(data, remoteData, keyPrefix);
            break;
        case Remoter:
            writeRemoter(data, remoteData, keyPrefix);
            break;
        case Byte:
            remoteData.putByte(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Byte) data);
            break;
        case Short:
            remoteData.putShort(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Short) data);
            break;
        case Integer:
            remoteData.putInt(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Integer) data);
            break;
        case Float:
            remoteData.putFloat(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Float) data);
            break;
        case Double:
            remoteData.putDouble(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Double) data);
            break;
        case String:
            remoteData.putString(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (String) data);
            break;
        case Char:
            remoteData.putChar(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Character) data);
            break;
        case Long:
            remoteData.putLong(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, (Long) data);
            break;
        case Boolean:
            remoteData.putInt(RemoteEventManager.REMOTE_DATA_KEY + keyPrefix, ((Boolean) data).booleanValue() ? 1 : 0);
            break;
        case UnKnown:
            Log.w(TAG, "Ignoring unsupported type " + data);
            break;

    }
}
 
Example 20
Project: OSchina_resources_android   File: UIHelper.java   View Source Code Vote up 2 votes
/**
 * 显示用户的问答列表
 *
 * @param context context
 * @param uid     authorId
 */
public static void showUserQuestion(Context context, long uid) {
    Bundle args = new Bundle();
    args.putLong(UserQuestionFragment.BUNDLE_KEY_AUTHOR_ID, uid);
    showSimpleBack(context, SimpleBackPage.MY_QUESTION, args);
}