當前位置: 首頁>>代碼示例>>Java>>正文


Java IntRange類代碼示例

本文整理匯總了Java中android.support.annotation.IntRange的典型用法代碼示例。如果您正苦於以下問題:Java IntRange類的具體用法?Java IntRange怎麽用?Java IntRange使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IntRange類屬於android.support.annotation包,在下文中一共展示了IntRange類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPermissionsResult

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void onPermissionsResult(@IntRange(from = 0, to = 127) final int code, @NonNull final Set<String> granted, @NonNull final Set<String> denied) {
    super.onPermissionsResult(code, granted, denied);
    switch (code) {
        case 10: {
            if (granted.contains(Manifest.permission.ACCESS_WIFI_STATE) && granted.contains(Manifest.permission.ACCESS_NETWORK_STATE)) {
                printInfo();
            } else {
                toastLong(R.string.toast_permission_missing);
            }
            break;
        }
        default: {
            Log.e(TAG, "onPermissionsResult: Unknown request code " + code);
            break;
        }
    }
}
 
開發者ID:milosmns,項目名稱:silly-android,代碼行數:22,代碼來源:MainActivity.java

示例2: setEndDate

import android.support.annotation.IntRange; //導入依賴的package包/類
public void setEndDate(@IntRange(from = 0) long endTime) {

        Calendar endDate = Calendar.getInstance();
        endDate.setTime(new Date(endTime));
        int year = endDate.get(Calendar.YEAR);
        int month = endDate.get(Calendar.MONTH) + 1;
        int day = endDate.get(Calendar.DAY_OF_MONTH);

        if (year > startYear) {
            this.endYear = year;
            this.endMonth = month;
            this.endDay = day;
        } else if (year == startYear) {
            if (month > startMonth) {
                this.endYear = year;
                this.endMonth = month;
                this.endDay = day;
            } else if (month == startMonth) {
                if (day > startDay) {
                    this.endYear = year;
                    this.endMonth = month;
                    this.endDay = day;
                }
            }
        }
    }
 
開發者ID:crazysunj,項目名稱:Android-PickerDialog,代碼行數:27,代碼來源:WheelTime.java

示例3: runWithDelay

import android.support.annotation.IntRange; //導入依賴的package包/類
@Override
public int runWithDelay(@NonNull final Runnable runnable, @IntRange(from = 0) long delayInMillis) {
    final int taskId = getTaskId(scheduledTasks);

    CountDownTimer scheduledTask = new CountDownTimer(delayInMillis, delayInMillis) {

        @Override
        public void onTick(long l) {
            // do nothing (is disabled anyway because "countDownInterval" is set to "millisInFuture")
        }

        @Override
        public void onFinish() {
            scheduledTasks.remove(taskId);
            runnable.run();
        }
    }.start();

    scheduledTasks.put(taskId, scheduledTask);

    return taskId;
}
 
開發者ID:BioID-GmbH,項目名稱:BWS-Android,代碼行數:23,代碼來源:AsynchronousBackgroundHandler.java

示例4: setRangeDate

import android.support.annotation.IntRange; //導入依賴的package包/類
public void setRangeDate(@IntRange(from = 0) long startTime, @IntRange(from = 0) long endTime) {

        if (startTime < endTime) {
            Calendar startDate = Calendar.getInstance();
            startDate.setTime(new Date(startTime));

            Calendar endDate = Calendar.getInstance();
            endDate.setTime(new Date(endTime));

            this.startYear = startDate.get(Calendar.YEAR);
            this.endYear = endDate.get(Calendar.YEAR);
            this.startMonth = startDate.get(Calendar.MONTH) + 1;
            this.endMonth = endDate.get(Calendar.MONTH) + 1;
            this.startDay = startDate.get(Calendar.DAY_OF_MONTH);
            this.endDay = endDate.get(Calendar.DAY_OF_MONTH);
        }
    }
 
開發者ID:crazysunj,項目名稱:Android-PickerDialog,代碼行數:18,代碼來源:WheelTime.java

示例5: setColor

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * 設置狀態欄顏色
 *
 * @param activity       需要設置的activity
 * @param color          狀態欄顏色值
 * @param statusBarAlpha 狀態欄透明度
 */

public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
        if (fakeStatusBarView != null) {
            if (fakeStatusBarView.getVisibility() == View.GONE) {
                fakeStatusBarView.setVisibility(View.VISIBLE);
            }
            fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        } else {
            decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
        }
        setRootView(activity);
    }
}
 
開發者ID:wheat7,項目名稱:VRPlayer,代碼行數:29,代碼來源:StatusBarUtil.java

示例6: setStatusBarColor4Drawer

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * 為DrawerLayout設置狀態欄顏色
 * <p>DrawLayout需設置 {@code android:fitsSystemWindows="true"}</p>
 *
 * @param activity      activity
 * @param drawer        drawerLayout
 * @param fakeStatusBar 偽造狀態欄
 * @param color         狀態欄顏色值
 * @param alpha         狀態欄透明度,此透明度並非顏色中的透明度
 * @param isTop         drawerLayout是否在頂層
 */
public static void setStatusBarColor4Drawer(@NonNull final Activity activity,
                                            @NonNull final DrawerLayout drawer,
                                            @NonNull final View fakeStatusBar,
                                            @ColorInt final int color,
                                            @IntRange(from = 0, to = 255) final int alpha,
                                            final boolean isTop) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    drawer.setFitsSystemWindows(false);
    transparentStatusBar(activity);
    setStatusBarColor(fakeStatusBar, color, isTop ? alpha : 0);
    for (int i = 0, len = drawer.getChildCount(); i < len; i++) {
        drawer.getChildAt(i).setFitsSystemWindows(false);
    }
    if (isTop) {
        hideAlphaView(activity);
    } else {
        addStatusBarAlpha(activity, alpha, false);
    }
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:31,代碼來源:BarUtils.java

示例7: collapse

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * Collapse an expandable item that has been expanded..
 *
 * @param position the position of the item, which includes the header layout count.
 * @param animate  collapse with animation or not.
 * @param notify   notify the recyclerView refresh UI or not.
 * @return the number of subItems collapsed.
 */
public int collapse(@IntRange(from = 0) int position, boolean animate, boolean notify) {
    position -= getHeaderLayoutCount();

    IExpandable expandable = getExpandableItem(position);
    if (expandable == null) {
        return 0;
    }
    int subItemCount = recursiveCollapse(position);
    expandable.setExpanded(false);
    int parentPos = position + getHeaderLayoutCount();
    if (notify) {
        if (animate) {
            notifyItemChanged(parentPos);
            notifyItemRangeRemoved(parentPos + 1, subItemCount);
        } else {
            notifyDataSetChanged();
        }
    }
    return subItemCount;
}
 
開發者ID:Skivi0605,項目名稱:ThreeExpandItem,代碼行數:29,代碼來源:BaseQuickAdapter.java

示例8: compressByQuality

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * 按質量壓縮
 *
 * @param src     源圖片
 * @param quality 質量
 * @param recycle 是否回收
 * @return 質量壓縮後的圖片
 */
public static Bitmap compressByQuality(final Bitmap src, @IntRange(from = 0, to = 100) final int quality, final boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    src.compress(CompressFormat.JPEG, quality, baos);
    byte[] bytes = baos.toByteArray();
    if (recycle && !src.isRecycled()) src.recycle();
    return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:17,代碼來源:ImageUtils.java

示例9: setHeightIfNeed

import android.support.annotation.IntRange; //導入依賴的package包/類
private void setHeightIfNeed(CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, @Nullable Paint.FontMetricsInt fm) {
  if (fm != null && text.length() == end - start) {
    // Extending classes can set the height of the span by updating
    // attributes of {@link android.graphics.Paint.FontMetricsInt}. If the span covers the whole
    // text, and the height is not set,
    // {@link #draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)} will not be
    // called for the span.
    fm.top = mRect.top;
    fm.bottom = mRect.bottom;
  }
}
 
開發者ID:lsjwzh,項目名稱:FastTextView,代碼行數:12,代碼來源:ItalicReplacementSpan.java

示例10: setStatusBarAlpha

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * 設置狀態欄透明度
 *
 * @param fakeStatusBar 偽造狀態欄
 * @param alpha         狀態欄透明度
 */
public static void setStatusBarAlpha(@NonNull final View fakeStatusBar,
                                     @IntRange(from = 0, to = 255) final int alpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    fakeStatusBar.setVisibility(View.VISIBLE);
    transparentStatusBar((Activity) fakeStatusBar.getContext());
    ViewGroup.LayoutParams layoutParams = fakeStatusBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    layoutParams.height = BarUtils.getStatusBarHeight();
    fakeStatusBar.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:BarUtils.java

示例11: build

import android.support.annotation.IntRange; //導入依賴的package包/類
public PlaceOptions build(@IntRange(from = 1, to = 2) int mode) {

      if (!countries.isEmpty()) {
        country(TextUtils.join(",", countries.toArray()));
      }

      injectedPlaces(injectedPlaces);
      viewMode(mode);

      return autoBuild();
    }
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:12,代碼來源:PlaceOptions.java

示例12: registerView

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * Register Recycler view for product list tracking. Please call {@link #unregisterView(RecyclerView)}
 * after RecyclerView is hided
 * @param view RecyclerView instance
 * @param timeoutMilliseconds timeout that is used when list is scrolled. Position of product
 * is tracked if list has this delay after scrolling or first show-up
 * @param itemCallback - callback to provide information about product
 */

public void registerView(@NonNull RecyclerView view, @IntRange(from=0) final long timeoutMilliseconds, @NonNull final ProductListItemCallback itemCallback){

    final RecyclerView.LayoutManager layoutManager = view.getLayoutManager();
    //we not support others layout managers then LinearLayoutManager
    if (!(layoutManager instanceof LinearLayoutManager)) {
        WebtrekkLogging.log("Error: not LinearLayouManager isn't supported");
        return;
    }

    mDelayHandler = new Handler();
    mScrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {

            if (newState == RecyclerView.SCROLL_STATE_IDLE){
                initPendingList(recyclerView, timeoutMilliseconds, itemCallback);
            }else{
                clearPendingEvents();
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            //it equals zero on the first list start in that case start pending
            if (dy == 0){
                initPendingList(recyclerView, timeoutMilliseconds, itemCallback);
            }
        }
    };

    view.addOnScrollListener(mScrollListener);

    mOnTouсhEventListener = new RecyclerItemClickListener(view.getContext(), view);
    view.addOnItemTouchListener(mOnTouсhEventListener);
    initPendingList(view, timeoutMilliseconds, itemCallback);
}
 
開發者ID:Webtrekk,項目名稱:webtrekk-android-sdk,代碼行數:47,代碼來源:ProductListTracker.java

示例13: setStatusBarColor

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * 設置狀態欄顏色
 *
 * @param fakeStatusBar 偽造狀態欄
 * @param color         狀態欄顏色值
 * @param alpha         狀態欄透明度,此透明度並非顏色中的透明度
 */
public static void setStatusBarColor(@NonNull final View fakeStatusBar,
                                     @ColorInt final int color,
                                     @IntRange(from = 0, to = 255) final int alpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
    fakeStatusBar.setVisibility(View.VISIBLE);
    transparentStatusBar((Activity) fakeStatusBar.getContext());
    ViewGroup.LayoutParams layoutParams = fakeStatusBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    layoutParams.height = BarUtils.getStatusBarHeight();
    fakeStatusBar.setBackgroundColor(getStatusBarColor(color, alpha));
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:19,代碼來源:BarUtils.java

示例14: clearInterval

import android.support.annotation.IntRange; //導入依賴的package包/類
@JSMethod(uiThread = false)
public void clearInterval(@IntRange(from = 1) int funcId) {
  if (funcId <= 0) {
    return;
  }
  removeOrHoldMessage(MODULE_INTERVAL, funcId);
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:8,代碼來源:WXTimerModule.java

示例15: compressByQuality

import android.support.annotation.IntRange; //導入依賴的package包/類
/**
 * 按質量壓縮
 *
 * @param src     源圖片
 * @param quality 質量
 * @param recycle 是否回收
 * @return 質量壓縮後的圖片
 */
public static Bitmap compressByQuality(final Bitmap src, @IntRange(from = 0, to = 100) final int quality, final boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    src.compress(Bitmap.CompressFormat.JPEG, quality, baos);
    byte[] bytes = baos.toByteArray();
    if (recycle && !src.isRecycled()) src.recycle();
    return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:ImageUtils.java


注:本文中的android.support.annotation.IntRange類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。