Java Code Examples for android.os.bundle#getLong()

The following examples show how to use android.os.bundle#getLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlbumPlayBaseFlow.java    From letv with Apache License 2.0 6 votes vote down vote up
protected void initDataWithLaunchMode(Bundle bundle) {
    if (this.mLaunchMode == 1 || this.mLaunchMode == 3) {
        this.mAid = Math.max(0, bundle.getLong("aid"));
        this.mVid = Math.max(0, bundle.getLong("vid"));
        if (bundle.getSerializable(PlayConstant.VIDEO_TYPE) instanceof VideoType) {
            this.mVideoType = (VideoType) bundle.getSerializable(PlayConstant.VIDEO_TYPE);
        }
    } else if (this.mLaunchMode == 2) {
        this.mVid = Math.max(0, bundle.getLong("vid"));
        if (bundle.getSerializable(PlayConstant.VIDEO_TYPE) instanceof VideoType) {
            this.mVideoType = (VideoType) bundle.getSerializable(PlayConstant.VIDEO_TYPE);
        }
        if (this.mVideoType != VideoType.Normal || this.mFrom == 20) {
            this.mAid = bundle.getLong("aid", 0);
        }
    } else if (this.mLaunchMode == 4) {
        this.mBoxBean = (LeboxVideoBean) bundle.getSerializable(PlayConstant.LEBOX_VIDEO);
    } else {
        this.mAlbumUrl.realUrl = bundle.getString(PlayConstant.URI);
    }
    this.mSeek = bundle.getLong("seek");
}
 
Example 2
Source File: CalendarFragment.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    mGestureDetector = new GestureDetectorCompat(getActivity(), new GestureListener());

    if ( mLandscape ) {
        mainActivity.mViewPagerListeners.add(this);
    }

    if ( savedInstanceState != null ) {
        long date = savedInstanceState.getLong(SAVE_DATE, -1);

        if ( date > 0 )
            mCalendar.setTimeInMillis(date);
    }
}
 
Example 3
Source File: ProgressScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private boolean handleArgs(Bundle args) {
    if (args == null) {
        return false;
    }

    mAction = args.getString(KEY_ACTION);
    if (ACTION_GALLERY_TOKEN.equals(mAction)) {
        mGid = args.getLong(KEY_GID, -1);
        mPToken = args.getString(KEY_PTOKEN, null);
        mPage = args.getInt(KEY_PAGE, -1);
        if (mGid == -1 || mPToken == null || mPage == -1) {
            return false;
        }
        return true;
    }

    return false;
}
 
Example 4
Source File: LocationDetailFragment.java    From MonsterHunter4UDatabase with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	setRetainInstance(true);
	
	// Check for a Item ID as an argument, and find the item
	Bundle args = getArguments();
	if (args != null) {
		long locationId = args.getLong(ARG_LOCATION_ID, -1);
		if (locationId != -1) {
			LoaderManager lm = getLoaderManager();
			lm.initLoader(R.id.location_detail_fragment, args, new LocationLoaderCallbacks());
		}
	}
}
 
Example 5
Source File: MediaActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public MediaActivity(Bundle args, int[] media, SharedMediaLayout.SharedMediaData[] mediaData, int initTab) {
    super(args);
    hasMedia = media;
    initialTab = initTab;
    dialog_id = args.getLong("dialog_id", 0);
    for (int a = 0; a < sharedMediaData.length; a++) {
        sharedMediaData[a] = new SharedMediaLayout.SharedMediaData();
        sharedMediaData[a].max_id[0] = ((int) dialog_id) == 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE;
        if (mergeDialogId != 0 && info != null) {
            sharedMediaData[a].max_id[1] = info.migrated_from_max_id;
            sharedMediaData[a].endReached[1] = false;
        }
        if (mediaData != null) {
            sharedMediaData[a].totalCount = mediaData[a].totalCount;
            sharedMediaData[a].messages.addAll(mediaData[a].messages);
            sharedMediaData[a].sections.addAll(mediaData[a].sections);
            for (HashMap.Entry<String, ArrayList<MessageObject>> entry : mediaData[a].sectionArrays.entrySet()) {
                sharedMediaData[a].sectionArrays.put(entry.getKey(), new ArrayList<>(entry.getValue()));
            }
            for (int i = 0; i < 2; i++) {
                sharedMediaData[a].endReached[i] = mediaData[a].endReached[i];
                sharedMediaData[a].messagesDict[i] = mediaData[a].messagesDict[i].clone();
                sharedMediaData[a].max_id[i] = mediaData[a].max_id[i];
            }
        }
    }
}
 
Example 6
Source File: MovieDetailsFragment.java    From android-mvvm-sample with MIT License 5 votes vote down vote up
private void retrieveMovieId(@Nullable Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        mMovieId = getArguments() != null ? getArguments().getLong(ARG_MOVIE_ID, -1) : -1;
    } else {
        mMovieId = savedInstanceState.getLong(ARG_MOVIE_ID, -1);
    }
    if (mMovieId == -1) {
        throw new IllegalArgumentException("You either passed a wrong value of movie id,"
                + " or you did not use the newInstance convenience method");
    }
}
 
Example 7
Source File: UserTimelineFragment.java    From catnut with MIT License 5 votes vote down vote up
@Override
public void onConfirm(Bundle args) {
	final long id = args.getLong(TAG);
	mRequestQueue.add(new CatnutRequest(
			getActivity(),
			TweetAPI.destroy(id),
			new CatnutProcessor<JSONObject>() {
				@Override
				public void asyncProcess(Context context, JSONObject data) throws Exception {
					context.getContentResolver().delete(
							CatnutProvider.parse(Status.MULTIPLE),
							BaseColumns._ID + "=" + id, null
					);
					// 更新用户数据 -1
					String update = CatnutUtils.increment(false, User.TABLE, User.statuses_count, mUid);
					context.getContentResolver().update(CatnutProvider.parse(User.MULTIPLE), null, update, null);
				}
			},
			null,
			new Response.ErrorListener() {
				@Override
				public void onErrorResponse(VolleyError error) {
					Log.e(TAG, "error deleting tweet id[" + id + "]", error);
					WeiboAPIError weiboAPIError = WeiboAPIError.fromVolleyError(error);
					Toast.makeText(getActivity(), weiboAPIError.error, Toast.LENGTH_LONG).show();
				}
			}
	)).setTag(TAG);
}
 
Example 8
Source File: TokenCachingStrategy.java    From Klyph with MIT License 5 votes vote down vote up
static Date getDate(Bundle bundle, String key) {
    if (bundle == null) {
        return null;
    }

    long n = bundle.getLong(key, INVALID_BUNDLE_MILLISECONDS);
    if (n == INVALID_BUNDLE_MILLISECONDS) {
        return null;
    }

    return new Date(n);
}
 
Example 9
Source File: EditCommentActivity.java    From droidddle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onMyCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_edit_comment);
    ButterKnife.inject(this);
    Bundle extra = getIntent().getExtras();
    mShotId = extra.getLong(UiUtils.ARG_SHOT_ID);
    mComment = extra.getParcelable(UiUtils.ARG_COMMENT);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, EditCommentFragment.newInstance(mShotId, mComment))
                .commit();
    }
}
 
Example 10
Source File: TimeZoneDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Restore the dialog state from the provided bundle.
 * @param bundle a Bundle containing the dialog state
 */
protected void loadSettings(Bundle bundle)
{
    String modeString = bundle.getString(KEY_TIMEZONE_MODE);
    if (modeString != null)
    {
        WidgetSettings.TimezoneMode timezoneMode = WidgetSettings.TimezoneMode.valueOf(modeString);
        spinner_timezoneMode.setSelection(timezoneMode.ordinal());
    }

    customTimezoneID = bundle.getString(KEY_TIMEZONE_ID);
    if (customTimezoneID != null)
    {
        WidgetTimezones.selectTimeZone(spinner_timezone, spinner_timezone_adapter, customTimezoneID);
    }

    String solarModeString = bundle.getString(KEY_SOLARTIME_MODE);
    if (solarModeString != null)
    {
        WidgetSettings.SolarTimeMode solartimeMode = WidgetSettings.SolarTimeMode.valueOf(solarModeString);
        spinner_solartime.setSelection(solartimeMode.ordinal());
    }

    long nowMillis = bundle.getLong(KEY_NOW, Calendar.getInstance().getTimeInMillis());
    now = Calendar.getInstance();
    now.setTimeInMillis(nowMillis);

    longitude = bundle.getDouble(KEY_LONGITUDE);
}
 
Example 11
Source File: GalleryCommentsScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void handleArgs(Bundle args) {
    if (args == null) {
        return;
    }

    mApiUid = args.getLong(KEY_API_UID, -1L);
    mApiKey = args.getString(KEY_API_KEY);
    mGid = args.getString(KEY_GID);
    mToken = args.getString(KEY_TOKEN, null);
    Parcelable[] parcelables = args.getParcelableArray(KEY_COMMENTS);
    if (parcelables instanceof GalleryComment[]) {
        mComments = (GalleryComment[]) parcelables;
    }
}
 
Example 12
Source File: ProgressScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void onRestore(@NonNull Bundle savedInstanceState) {
    mValid = savedInstanceState.getBoolean(KEY_VALID);
    mError = savedInstanceState.getString(KEY_ERROR);

    mAction = savedInstanceState.getString(KEY_ACTION);

    mGid = savedInstanceState.getLong(KEY_GID, -1);
    mPToken = savedInstanceState.getString(KEY_PTOKEN, null);
    mPage = savedInstanceState.getInt(KEY_PAGE, -1);
}
 
Example 13
Source File: HomePageActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
public void updateContentView(Bundle savedInstanceState) {
	LocalAccount currentAccount = null;
	int contentType = Skeleton.TYPE_MY_HOME;

	if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(Constants.PREFS_KEY_CURRENT_ACCOUNT)) {
			long currentAccountId = savedInstanceState.getLong(Constants.PREFS_KEY_CURRENT_ACCOUNT);
			currentAccount = GlobalVars.getAccount(currentAccountId);
		}
        if (savedInstanceState.containsKey("CONTENT_TYPE")) {
        	contentType = savedInstanceState.getInt("CONTENT_TYPE");
        }
	}

	if (currentAccount == null) {
		currentAccount = sheJiaoMao.getCurrentAccount();
	}

	if (currentAccount == null) {
		Intent accountsIntent = new Intent();
		accountsIntent.setClass(this, AccountsActivity.class);
		startActivityForResult(accountsIntent, Constants.REQUEST_CODE_ACCOUNTS);
	} else {
		setContentView(skeleton);
		sheJiaoMao.setCurrentAccount(currentAccount);
		skeleton.setCurrentAccount(currentAccount, true);
		skeleton.setContentType(contentType);

	    if (!currentAccount.isVerified()) {
			VerifyCredentialsTask task = new VerifyCredentialsTask(this, currentAccount);
			task.execute();
	    }
	}
}
 
Example 14
Source File: ArmorDetailFragment.java    From MonsterHunter4UDatabase with MIT License 4 votes vote down vote up
@Override
public Loader<Armor> onCreateLoader(int id, Bundle args) {
	return new ArmorLoader(getActivity(),
			args.getLong(ARG_ARMOR_ID));
}
 
Example 15
Source File: ConversationFragment.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
  return new ConversationLoader(getActivity(), threadId, args.getLong("limit", PARTIAL_CONVERSATION_LIMIT), lastSeen);
}
 
Example 16
Source File: LongProcessor.java    From LiveEventBus with Apache License 2.0 4 votes vote down vote up
@Override
public Object createFromBundle(Bundle bundle) {
    return bundle.getLong(IpcConst.KEY_VALUE);
}
 
Example 17
Source File: KVUtils.java    From letv with Apache License 2.0 4 votes vote down vote up
public static long getLong(Bundle bundle, String key, long defaultValue) {
    if (bundle == null || TextUtils.empty(key)) {
        return defaultValue;
    }
    return bundle.getLong(key, defaultValue);
}
 
Example 18
Source File: TabSwitcherModel.java    From ChromeLikeTabSwitcher with Apache License 2.0 4 votes vote down vote up
@Override
public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        referenceTabIndex = savedInstanceState.getInt(REFERENCE_TAB_INDEX_EXTRA, -1);
        referenceTabPosition = savedInstanceState.getFloat(REFERENCE_TAB_POSITION_EXTRA, -1);
        logLevel = (LogLevel) savedInstanceState.getSerializable(LOG_LEVEL_EXTRA);
        tabs = savedInstanceState.getParcelableArrayList(TABS_EXTRA);
        switcherShown = savedInstanceState.getBoolean(SWITCHER_SHOWN_EXTRA);
        int selectedTabIndex = savedInstanceState.getInt(SELECTED_TAB_INDEX_EXTRA);
        selectedTab = selectedTabIndex != -1 ? tabs.get(selectedTabIndex) : null;
        padding = savedInstanceState.getIntArray(PADDING_EXTRA);
        applyPaddingToTabs = savedInstanceState.getBoolean(APPLY_PADDING_TO_TABS_EXTRA);
        tabIconId = savedInstanceState.getInt(TAB_ICON_ID_EXTRA);
        tabIconBitmap = savedInstanceState.getParcelable(TAB_ICON_BITMAP_EXTRA);
        tabIconTintList = savedInstanceState.getParcelable(TAB_ICON_TINT_LIST_EXTRA);
        tabIconTintMode =
                (PorterDuff.Mode) savedInstanceState.getSerializable(TAB_ICON_TINT_MODE_EXTRA);
        tabBackgroundColor = savedInstanceState.getParcelable(TAB_BACKGROUND_COLOR_EXTRA);
        tabContentBackgroundColor =
                savedInstanceState.getInt(TAB_CONTENT_BACKGROUND_COLOR_EXTRA);
        tabTitleTextColor = savedInstanceState.getParcelable(TAB_TITLE_TEXT_COLOR_EXTRA);
        tabCloseButtonIconId = savedInstanceState.getInt(TAB_CLOSE_BUTTON_ICON_ID_EXTRA);
        tabCloseButtonIconBitmap =
                savedInstanceState.getParcelable(TAB_CLOSE_BUTTON_ICON_BITMAP_EXTRA);
        tabCloseButtonIconTintList =
                savedInstanceState.getParcelable(TAB_CLOSE_BUTTON_ICON_TINT_LIST_EXTRA);
        tabCloseButtonIconTintMode = (PorterDuff.Mode) savedInstanceState
                .getSerializable(TAB_CLOSE_BUTTON_ICON_TINT_MODE_EXTRA);
        tabProgressBarColor = savedInstanceState.getInt(TAB_PROGRESS_BAR_COLOR_EXTRA, -1);
        showToolbars = savedInstanceState.getBoolean(SHOW_TOOLBARS_EXTRA);
        toolbarTitle = savedInstanceState.getCharSequence(TOOLBAR_TITLE_EXTRA);
        toolbarNavigationIconTintList =
                savedInstanceState.getParcelable(TOOLBAR_NAVIGATION_ICON_TINT_LIST_EXTRA);
        toolbarNavigationIconTintMode = (PorterDuff.Mode) savedInstanceState
                .getSerializable(TOOLBAR_NAVIGATION_ICON_TINT_MODE_EXTRA);
        tabPreviewFadeThreshold = savedInstanceState.getLong(TAB_PREVIEW_FADE_THRESHOLD_EXTRA);
        tabPreviewFadeDuration = savedInstanceState.getLong(TAB_PREVIEW_FADE_DURATION);
        clearSavedStatesWhenRemovingTabs =
                savedInstanceState.getBoolean(CLEAR_SAVED_STATES_WHEN_REMOVING_TABS_EXTRA);
        getContentRecyclerAdapter().restoreInstanceState(savedInstanceState);
    }
}
 
Example 19
Source File: ContextualUndoAdapter.java    From ALLGO with Apache License 2.0 2 votes vote down vote up
/**
 * This method should be called in your {@link Activity#onRestoreInstanceState(Bundle)} to remember dismissed statuses.
 * @param savedInstanceState
 */
public void onRestoreInstanceState(Bundle savedInstanceState) {
	mCurrentRemovedId = savedInstanceState.getLong(EXTRA_ACTIVE_REMOVED_ID, -1);
}
 
Example 20
Source File: TokenCachingStrategy.java    From Abelana-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the cached expiration date from a Bundle.
 * 
 * @param bundle
 *            A Bundle in which the expiration date was stored.
 * @return the long representing the cached expiration date in milliseconds
 *         since the epoch, or 0.
 *
 * @throws NullPointerException if the passed in Bundle is null
 */
public static long getExpirationMilliseconds(Bundle bundle) {
    Validate.notNull(bundle, "bundle");
    return bundle.getLong(EXPIRATION_DATE_KEY);
}