Java Code Examples for android.os.Bundle#putInt()

The following examples show how to use android.os.Bundle#putInt() . These examples are extracted from open source projects. 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
@Override
public void onDataSourceSelected(@NonNull DataSource source) {
    Bundle args = new Bundle(3);
    if (mLocationState != LocationState.DISABLED && mLocationService != null) {
        Location location = mLocationService.getLocation();
        args.putDouble(DataList.ARG_LATITUDE, location.getLatitude());
        args.putDouble(DataList.ARG_LONGITUDE, location.getLongitude());
        args.putBoolean(DataList.ARG_CURRENT_LOCATION, true);
    } else {
        MapPosition position = mMap.getMapPosition();
        args.putDouble(DataList.ARG_LATITUDE, position.getLatitude());
        args.putDouble(DataList.ARG_LONGITUDE, position.getLongitude());
        args.putBoolean(DataList.ARG_CURRENT_LOCATION, false);
    }
    args.putInt(DataList.ARG_HEIGHT, mViews.extendPanel.getHeight());
    DataList fragment = (DataList) Fragment.instantiate(this, DataList.class.getName(), args);
    fragment.setDataSource(source);
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    fragment.setEnterTransition(new Fade());
    ft.add(R.id.extendPanel, fragment, "dataList");
    ft.addToBackStack("dataList");
    ft.commit();
}
 
Example 2
Source Project: AssistantBySDK   File: TingPagerAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Fragment getItem(int position) {

    Category category = categorys.get(position);
    TingAlbumFragment fragment = new TingAlbumFragment();
    Bundle args = new Bundle();
    switch (position) {
        case 0:
            args.putInt(TingAlbumFragment.FRAG_TYPE, TingAlbumFragment.FRAG_SUBSCRIBE);
            break;
        default:
            args.putInt(TingAlbumFragment.FRAG_TYPE, TingAlbumFragment.FRAG_CATEGORY);
            args.putLong(TingAlbumFragment.CATEGORY_ID, category.getId());
            break;
    }
    fragment.setArguments(args);
    return fragment;
}
 
Example 3
Source Project: Pasta-Music   File: TutorialFragment.java    License: Apache License 2.0 6 votes vote down vote up
private static TutorialFragment getInstance(String name, String description, int imageResource, int imageResourceBackground, int imageResourceForeground, boolean hasAnimatedImageResource, boolean hasAnimatedImageResourceBackground, boolean hasAnimatedImageResourceForeground, int customActionIcon, PendingIntent pendingIntent, String customActionTitle) {
    Bundle bundle = new Bundle();
    bundle.putInt(ARGUMENTS_TUTORIAL_IMAGE, imageResource);
    bundle.putInt(ARGUMENTS_TUTORIAL_IMAGE_BACKGROUND, imageResourceBackground);
    bundle.putInt(ARGUMENTS_TUTORIAL_IMAGE_FOREGROUND, imageResourceForeground);
    bundle.putString(ARGUMENTS_TUTORIAL_NAME, name);
    bundle.putString(ARGUMENTS_TUTORIAL_DESCRIPTION, description);
    bundle.putBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE, hasAnimatedImageResource);
    bundle.putBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_BACKGROUND, hasAnimatedImageResourceBackground);
    bundle.putBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_FOREGROUND, hasAnimatedImageResourceForeground);
    bundle.putInt(ARGUMENTS_CUSTOM_ACTION_ICON, customActionIcon);
    bundle.putParcelable(ARGUMENTS_CUSTOM_ACTION_PENDING_INTENT, pendingIntent);
    bundle.putString(ARGUMENTS_CUSTOM_ACTION_TITLE, customActionTitle);

    TutorialFragment tutorialFragment = new TutorialFragment();
    tutorialFragment.setArguments(bundle);
    return tutorialFragment;
}
 
Example 4
@NonNull public static SortedMultiModelPopup newInstance(
      List<String> modelIDs,
      @StringRes @Nullable Integer titleRes,
      @Nullable List<String> preSelected,
      @Nullable Boolean allowMultipleSelections
) {
    SortedMultiModelPopup fragment = new SortedMultiModelPopup();
    ArrayList<String> modelsSelectedList = new ArrayList<>();
    if (preSelected != null) {
        modelsSelectedList.addAll(preSelected);
    }

    ArrayList<String> modelAddressList = new ArrayList<>();
    if (modelIDs != null) {
        modelAddressList.addAll(modelIDs);
    }

    Bundle bundle = new Bundle(2);
    bundle.putInt(POPUP_TITLE, titleRes == null ? R.string.choose_devices_text : titleRes);
    bundle.putStringArrayList(MODELS_SELECTED, modelsSelectedList);
    bundle.putStringArrayList(MODEL_LIST, modelAddressList);
    bundle.putBoolean(MULTIPLE_MODELS_SELECTABLE, Boolean.TRUE.equals(allowMultipleSelections));
    fragment.setArguments(bundle);

    return fragment;
}
 
Example 5
public static CloudChooseFragment newInstance(int type, int limit) {

        Bundle args = new Bundle();
        args.putInt(CloudChooseActivity.TYPE, type);
        args.putInt(CloudChooseActivity.LIMIT, limit);

        CloudChooseFragment fragment = new CloudChooseFragment();
        fragment.setArguments(args);
        return fragment;
    }
 
Example 6
public static BottomSheetVendorDialogFragment getInstance(final int modelId, final int appKeyIndex) {
    final BottomSheetVendorDialogFragment fragment = new BottomSheetVendorDialogFragment();
    final Bundle args = new Bundle();
    args.putInt(MODEL_ID, modelId);
    args.putInt(KEY_INDEX, appKeyIndex);
    fragment.setArguments(args);
    return fragment;
}
 
Example 7
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mResultData != null) {
        outState.putInt(STATE_RESULT_CODE, mResultCode);
        outState.putParcelable(STATE_RESULT_DATA, mResultData);
    }
}
 
Example 8
Source Project: KinoCast   File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(STATE_TITLE, mTitle.toString());
    outState.putBoolean(STATE_IS_SEARCHVIEW, mIsSearchView);
    outState.putInt(NAV_ITEM_ID, mNavItemId);
}
 
Example 9
/**
 * Use this factory method to create a new instance of
 * this fragment using the provided parameters.
 *
 * @param param1 Parameter 1.
 * @return A new instance of fragment OnboardingAsrCalculationMethod.
 */
public static OnboardingTimeFormatFragment newInstance(int param1) {
  OnboardingTimeFormatFragment fragment = new OnboardingTimeFormatFragment();
  Bundle args = new Bundle();
  args.putInt(ARG_PARAM1, param1);
  fragment.setArguments(args);
  return fragment;
}
 
Example 10
/**
 * Create a new instance of DetailsFragment, initialized to
 * show the text at 'index'.
 */
public static WeightFragment newInstance(String name, int id) {
    WeightFragment f = new WeightFragment();

    // Supply index input as an argument.
    Bundle args = new Bundle();
    args.putString("name", name);
    args.putInt("id", id);
    f.setArguments(args);

    return f;
}
 
Example 11
Source Project: SystemUITuner2   File: SetupActivity.java    License: MIT License 5 votes vote down vote up
public static NoRoot newInstance(String title, String description, @SuppressWarnings("SameParameterValue") @DrawableRes int drawable, @ColorInt int color) {
    NoRoot fragment = new NoRoot();
    Bundle args = new Bundle();
    args.putString(ARG_TITLE, title);
    args.putString(ARG_DESC, description);
    args.putInt(ARG_DRAWABLE, drawable);
    args.putInt(ARG_BG_COLOR, color);
    fragment.setArguments(args);
    return fragment;
}
 
Example 12
Source Project: PhotoPicker   File: TouchImageView.java    License: Apache License 2.0 5 votes vote down vote up
@Override public Parcelable onSaveInstanceState() {
  Bundle bundle = new Bundle();
  bundle.putParcelable("instanceState", super.onSaveInstanceState());
  bundle.putFloat("saveScale", normalizedScale);
  bundle.putFloat("matchViewHeight", matchViewHeight);
  bundle.putFloat("matchViewWidth", matchViewWidth);
  bundle.putInt("viewWidth", viewWidth);
  bundle.putInt("viewHeight", viewHeight);
  matrix.getValues(m);
  bundle.putFloatArray("matrix", m);
  bundle.putBoolean("imageRendered", imageRenderedAtLeastOnce);
  return bundle;
}
 
Example 13
private PreferenceFragment buildPreferenceFragment(int preferenceResId, String root) {
    PreferenceFragment fragment = new PrefFragment();
    Bundle args = new Bundle();
    args.putInt(PREFERENCE_RESOURCE_ID, preferenceResId);
    args.putString(PREFERENCE_ROOT, root);
    fragment.setArguments(args);
    return fragment;
}
 
Example 14
Source Project: ProgressView   File: CircleProgressView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Parcelable onSaveInstanceState() {
  final Bundle bundle = new Bundle();
  bundle.putParcelable(STATE, super.onSaveInstanceState());
  // 保存当前样式
  bundle.putInt(PROGRESS_STYLE, getProgressStyle());
  bundle.putInt(RADIUS, getRadius());
  bundle.putBoolean(IS_REACH_CAP_ROUND, isReachCapRound());
  bundle.putInt(START_ARC, getStartArc());
  bundle.putInt(INNER_BG_COLOR, getInnerBackgroundColor());
  bundle.putInt(INNER_PADDING, getInnerPadding());
  bundle.putInt(OUTER_COLOR, getOuterColor());
  bundle.putInt(OUTER_SIZE, getOuterSize());
  // 保存text信息
  bundle.putInt(TEXT_COLOR, getTextColor());
  bundle.putInt(TEXT_SIZE, getTextSize());
  bundle.putFloat(TEXT_SKEW_X, getTextSkewX());
  bundle.putBoolean(TEXT_VISIBLE, isTextVisible());
  bundle.putString(TEXT_SUFFIX, getTextSuffix());
  bundle.putString(TEXT_PREFIX, getTextPrefix());
  // 保存已到达进度信息
  bundle.putInt(REACH_BAR_COLOR, getReachBarColor());
  bundle.putInt(REACH_BAR_SIZE, getReachBarSize());

  // 保存未到达进度信息
  bundle.putInt(NORMAL_BAR_COLOR, getNormalBarColor());
  bundle.putInt(NORMAL_BAR_SIZE, getNormalBarSize());
  return bundle;
}
 
Example 15
Source Project: SimpleFTP   File: ListServerViewModel.java    License: MIT License 5 votes vote down vote up
/**
 * Edit a FTP server.
 * @param view The current view.
 */
public void editServer(View view) {
    if(selectedServer.get() != null) {
        Intent intent = new Intent(context, EditServerActivity.class);

        Bundle bundle = new Bundle();
        bundle.putInt("serverId", selectedServer.get().getId());
        intent.putExtras(bundle);

        context.startActivityForResult(intent, ListServerActivity.KEY_EDIT_SERVER);
    }
}
 
Example 16
Source Project: DeviceConnect-Android   File: PhoneProfile.java    License: MIT License 5 votes vote down vote up
/**
 * レスポンスのphoneStatusイベントオブジェクトに通話状態を設定する.
 * 
 * @param phoneStatus イベントオブジェクトのパラメータ
 * @param state 通話状態
 */
public static void setState(final Bundle phoneStatus, final CallState state) {

    if (state == CallState.UNKNOWN) {
        throw new IllegalArgumentException("State should not be UNKNOWN.");
    }

    phoneStatus.putInt(PARAM_STATE, state.getValue());
}
 
Example 17
private void initializeFragment() {
    mFragment = new PostFragment();
    Bundle bundle = new Bundle();
    bundle.putString(PostFragment.EXTRA_NAME, multiPath);
    bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_MULTI_REDDIT);
    bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER);
    bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
    mFragment.setArguments(bundle);
    getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit();
}
 
Example 18
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    int lastScrollPosition = linearLayoutManager.findLastCompletelyVisibleItemPosition();
    int itemsCount = reposListAdapter.getItemCount();
    Log.v(TAG, "onScrolled - imetsCount = " + itemsCount);
    Log.v(TAG, "onScrolled - lastScrollPosition = " + lastScrollPosition);
    if (lastScrollPosition == itemsCount - 1 && !reposExhausted && !loading) {
        loading = true;
        Bundle bundle = new Bundle();
        bundle.putInt("page", currentPage++);
        getLoaderManager().initLoader(0, bundle, new RepositoriesListFragment.ReposLoaderCallbacks());
    }
}
 
Example 19
Source Project: Taskbar   File: DashboardController.java    License: Apache License 2.0 4 votes vote down vote up
private void addWidget(int appWidgetId, int cellId, boolean shouldSave) {
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);

    final DashboardCell cellLayout = cells.get(cellId);
    final AppWidgetHostView hostView = mAppWidgetHost.createView(context, appWidgetId, appWidgetInfo);
    hostView.setAppWidget(appWidgetId, appWidgetInfo);

    Bundle bundle = new Bundle();
    bundle.putInt("cellId", cellId);
    hostView.setTag(bundle);

    cellLayout.findViewById(R.id.empty).setVisibility(View.GONE);
    cellLayout.findViewById(R.id.placeholder).setVisibility(View.GONE);
    cellLayout.setOnLongClickListener(olcl);
    cellLayout.setOnGenericMotionListener(ogml);
    cellLayout.setOnInterceptedLongPressListener(listener);

    LinearLayout linearLayout = cellLayout.findViewById(R.id.dashboard);
    linearLayout.addView(hostView);

    Bundle bundle2 = (Bundle) cellLayout.getTag();
    bundle2.putInt("appWidgetId", appWidgetId);
    cellLayout.setTag(bundle2);

    widgets.put(cellId, hostView);

    if(shouldSave) {
        SharedPreferences pref = U.getSharedPreferences(context);
        SharedPreferences.Editor editor = pref.edit();
        editor.putInt("dashboard_widget_" + cellId, appWidgetId);
        editor.putString("dashboard_widget_" + cellId + "_provider", appWidgetInfo.provider.flattenToString());
        editor.remove("dashboard_widget_" + cellId + "_placeholder");
        editor.apply();
    }

    new Handler().post(() -> {
        ViewGroup.LayoutParams params = hostView.getLayoutParams();
        params.width = cellLayout.getWidth();
        params.height = cellLayout.getHeight();
        hostView.setLayoutParams(params);
        hostView.updateAppWidgetSize(null, cellLayout.getWidth(), cellLayout.getHeight(), cellLayout.getWidth(), cellLayout.getHeight());
    });
}
 
Example 20
/**
 * Finishes activity with {@link Activity#RESULT_OK}.
 * 
 * @param pattern
 *            the pattern, if this is in mode creating pattern. In any
 *            cases, it can be set to {@code null}.
 */
private void finishWithResultOk(char[] pattern) {
    if (ACTION_CREATE_PATTERN.equals(getIntent().getAction()))
        mIntentResult.putExtra(EXTRA_PATTERN, pattern);
    else {
        /*
         * If the user was "logging in", minimum try count can not be zero.
         */
        mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount + 1);
    }

    setResult(RESULT_OK, mIntentResult);

    /*
     * ResultReceiver
     */
    ResultReceiver receiver = getIntent().getParcelableExtra(
            EXTRA_RESULT_RECEIVER);
    if (receiver != null) {
        Bundle bundle = new Bundle();
        if (ACTION_CREATE_PATTERN.equals(getIntent().getAction()))
            bundle.putCharArray(EXTRA_PATTERN, pattern);
        else {
            /*
             * If the user was "logging in", minimum try count can not be
             * zero.
             */
            bundle.putInt(EXTRA_RETRY_COUNT, mRetryCount + 1);
        }
        receiver.send(RESULT_OK, bundle);
    }

    /*
     * PendingIntent
     */
    PendingIntent pi = getIntent().getParcelableExtra(
            EXTRA_PENDING_INTENT_OK);
    if (pi != null) {
        try {
            pi.send(this, RESULT_OK, mIntentResult);
        } catch (Throwable t) {
            Log.e(CLASSNAME, "Error sending PendingIntent: " + pi, t);
        }
    }

    finish();
}