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


Java NonNull類代碼示例

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


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

示例1: createView

import android.support.annotation.NonNull; //導入依賴的package包/類
public View createView(View parent, final String name, @NonNull Context context,
                       @NonNull AttributeSet attrs) {
    final boolean isPre21 = Build.VERSION.SDK_INT < 21;

    if (mSkinCompatViewInflater == null) {
        mSkinCompatViewInflater = new SkinCompatViewInflater();
    }

    // We only want the View to inherit its context if we're running pre-v21
    final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent);

    return mSkinCompatViewInflater.createView(parent, name, context, attrs, inheritContext,
            isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */
            true, /* Read read app:theme as a fallback at all times for legacy reasons */
            VectorEnabledTintResources.shouldBeUsed() /* Only tint wrap the context if enabled */
    );
}
 
開發者ID:wutongke,項目名稱:AndroidSkinAnimator,代碼行數:18,代碼來源:SkinCompatDelegate.java

示例2: navigateBack

import android.support.annotation.NonNull; //導入依賴的package包/類
private void navigateBack(@NonNull String message) {
    Snacky.builder()
            .setActivty(CoinEditActivity.this)
            .setText(message)
            .setDuration(Snacky.LENGTH_INDEFINITE)
            .success()
            .show();

    new Handler().postDelayed(() -> {
        NavigationService.NavigationResult navigationResult = NavigationService.getInstance().GoBack(CoinEditActivity.this);
        if (navigationResult != NavigationService.NavigationResult.SUCCESS) {
            Logger.getInstance().Error(TAG, String.format(Locale.getDefault(), "Navigation failed! navigationResult is %s!", navigationResult));
            displayFailSnacky("Failed to navigate back! Please contact LucaHome support!");
        }
    }, 1500);
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:17,代碼來源:CoinEditActivity.java

示例3: invalidateDrawable

import android.support.annotation.NonNull; //導入依賴的package包/類
@Override
public void invalidateDrawable(@NonNull Drawable drawable) {
    if (hasSameDrawable(drawable)) {
        invalidate();
    } else {
        super.invalidateDrawable(drawable);
    }
}
 
開發者ID:YiiGuxing,項目名稱:CompositionAvatar,代碼行數:9,代碼來源:CompositionAvatarView.java

示例4: calculateDistanceToFinalSnap

import android.support.annotation.NonNull; //導入依賴的package包/類
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager,
                                          @NonNull View targetView) {
    int[] out = new int[2];

    if (layoutManager.canScrollHorizontally()) {
        if (gravity == Gravity.START) {
            out[0] = distanceToStart(targetView, getHorizontalHelper(layoutManager), false);
        } else { // END
            out[0] = distanceToEnd(targetView, getHorizontalHelper(layoutManager), false);
        }
    } else {
        out[0] = 0;
    }

    if (layoutManager.canScrollVertically()) {
        if (gravity == Gravity.TOP) {
            out[1] = distanceToStart(targetView, getVerticalHelper(layoutManager), false);
        } else { // BOTTOM
            out[1] = distanceToEnd(targetView, getVerticalHelper(layoutManager), false);
        }
    } else {
        out[1] = 0;
    }

    return out;
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:27,代碼來源:GravityDelegate.java

示例5: createToolbarIcon

import android.support.annotation.NonNull; //導入依賴的package包/類
/**
 * Creates a Material Design compliant {@link android.support.v7.widget.Toolbar} icon
 * from a given full sized icon.
 *
 * @param resources Resources for the current {@link android.content.Context}.
 * @param icon The bitmap to convert.
 * @return A scaled Bitmap of the appropriate size and in-built padding.
 */
public static Bitmap createToolbarIcon(@NonNull Resources resources,
                                       @NonNull final Bitmap icon) {
    final int padding = resources.getDimensionPixelSize(R.dimen.margin_small);
    final int iconSize = resources.getDimensionPixelSize(R.dimen.toolbar_icon_size);
    final int sizeWithPadding = iconSize + (2 * padding);

    // Create a Bitmap backed Canvas to be the toolbar icon.
    final Bitmap toolbarIcon =
            Bitmap.createBitmap(sizeWithPadding, sizeWithPadding, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(toolbarIcon);
    canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

    // Resize the app icon to Material Design size.
    final Bitmap scaledIcon = Bitmap.createScaledBitmap(icon, iconSize, iconSize, false);
    canvas.drawBitmap(scaledIcon, padding, padding, null);

    return toolbarIcon;
}
 
開發者ID:googlesamples,項目名稱:android-media-controller,代碼行數:27,代碼來源:BitmapUtils.java

示例6: setupContentViewAndStatusBarView

import android.support.annotation.NonNull; //導入依賴的package包/類
@NonNull
private View setupContentViewAndStatusBarView(@NonNull Activity activity) throws IllegalStateException {
    ViewGroup contentViewGroup = (ViewGroup) activity.findViewById(android.R.id.content);
    View userView = contentViewGroup.getChildAt(0);
    if (userView == null) {
        throw new IllegalStateException("Plz invode setContentView() method first!");
    }

    userView.setFitsSystemWindows(false);

    mInsetsRect.top = ImmerseGlobalConfig.getInstance().getStatusBarHeight();

    View statusBarView = new View(activity);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mInsetsRect.top);
    contentViewGroup.addView(statusBarView, params);

    return statusBarView;
}
 
開發者ID:ls1110924,項目名稱:ImmerseMode,代碼行數:19,代碼來源:TpSbTlNbwFCImmerseMode.java

示例7: convert

import android.support.annotation.NonNull; //導入依賴的package包/類
@Nullable private static Intent convert(@NonNull Context context, Uri data, boolean showRepoBtn) {
    if (data == null) return null;
    if (InputHelper.isEmpty(data.getHost()) || InputHelper.isEmpty(data.getScheme())) {
        String host = data.getHost();
        if (InputHelper.isEmpty(host)) host = HOST_DEFAULT;
        String scheme = data.getScheme();
        if (InputHelper.isEmpty(scheme)) scheme = PROTOCOL_HTTPS;
        String prefix = scheme + "://" + host;
        String path = data.getPath();
        if (!InputHelper.isEmpty(path)) {
            if (path.charAt(0) == '/') {
                data = Uri.parse(prefix + path);
            } else {
                data = Uri.parse(prefix + '/' + path);
            }
        } else {
            data = Uri.parse(prefix);
        }
    }
    if (data.getPathSegments() != null && !data.getPathSegments().isEmpty()) {
        if (IGNORED_LIST.contains(data.getPathSegments().get(0))) return null;
        return getIntentForURI(context, data, showRepoBtn);
    }
    return null;
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:26,代碼來源:SchemeParser.java

示例8: onConnectionFailed

import android.support.annotation.NonNull; //導入依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.i(TAG, "onConnectionFailed:" + connectionResult.getErrorMessage());

    // Viene chiamata nel caso la connect fallisca ad esempio
    // non è ancora stata data autorizzaiozne alla applicazione corrente
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
            // Unable to resolve, message user appropriately
        }
    } else {
        GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show();
    }
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:17,代碼來源:BaseMainDbActivity.java

示例9: onBindViewHolder

import android.support.annotation.NonNull; //導入依賴的package包/類
@Override
protected void onBindViewHolder(@NonNull ViewHold holder, @NonNull final CollectionItem item) {
    Glide.with(mActivity).load(item.data.cover.feedCover).into(holder.image);

    holder.title.setText(item.data.title);
    holder.title.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.DB1FontPath)));

    holder.info.setText("#" + item.data.category + " / " + TranslateDuration.translateSeconds(item.data.duration) + " / 開眼精選");
    holder.info.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.LFontPath)));

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mActivity, MovieDetailActivity.class);
            Bundle bundle = new Bundle();
            bundle.putParcelable("DATA", item.data);
            intent.putExtras(bundle);

            mActivity.startActivity(intent);
        }
    });
}
 
開發者ID:KnowledgeBegger,項目名稱:MyEyepetizer,代碼行數:23,代碼來源:HomeCollectionItemBinder.java

示例10: BookmarksAdapter

import android.support.annotation.NonNull; //導入依賴的package包/類
public BookmarksAdapter(@NonNull Context context,
                        ArrayList<ZhihuDailyNews.Question> zhihuList,
                        ArrayList<GuokrHandpickNews.result> guokrList,
                        ArrayList<DoubanMomentNews.posts> doubanList,
                        ArrayList<Integer> types) {
    this.context = context;
    this.inflater = LayoutInflater.from(context);

    this.zhihuList = zhihuList;
    this.guokrList = guokrList;
    this.doubanList = doubanList;

    // types.size = zhihuList.size + guokrList.size + doubanList.size
    this.types = types;

}
 
開發者ID:makezhao,項目名稱:LianXiZhihu,代碼行數:17,代碼來源:BookmarksAdapter.java

示例11: writeToParcel

import android.support.annotation.NonNull; //導入依賴的package包/類
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
    super.writeToParcel(out, flags);
    out.writeInt(color);
    out.writeInt(dateTextAppearance);
    out.writeInt(weekDayTextAppearance);
    out.writeInt(showOtherDates);
    out.writeByte((byte) (allowClickDaysOutsideCurrentMonth ? 1 : 0));
    out.writeParcelable(minDate, 0);
    out.writeParcelable(maxDate, 0);
    out.writeTypedList(selectedDates);
    out.writeInt(firstDayOfWeek);
    out.writeInt(orientation);
    out.writeInt(tileWidthPx);
    out.writeInt(tileHeightPx);
    out.writeInt(topbarVisible ? 1 : 0);
    out.writeInt(selectionMode);
    out.writeInt(dynamicHeightEnabled ? 1 : 0);
    out.writeInt(calendarMode == CalendarMode.WEEKS ? 1 : 0);
    out.writeParcelable(currentMonth, 0);
    out.writeByte((byte) (cacheCurrentPosition ? 1 : 0));
}
 
開發者ID:ptrstovka,項目名稱:calendarview2,代碼行數:23,代碼來源:CalendarView2.java

示例12: getRetrofit

import android.support.annotation.NonNull; //導入依賴的package包/類
public static Retrofit getRetrofit(@NonNull String blogUrl, @NonNull OkHttpClient httpClient) {
    String baseUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, "ghost/api/v0.1/");
    Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new DateDeserializer())
            .registerTypeAdapter(ConfigurationList.class, new ConfigurationListDeserializer())
            .registerTypeAdapterFactory(new PostTypeAdapterFactory())
            .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
            .setExclusionStrategies(new RealmExclusionStrategy(), new AnnotationExclusionStrategy())
            .create();
    return new Retrofit.Builder()
            .baseUrl(baseUrl)
            .client(httpClient)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            // for HTML output (e.g., to get the client secret)
            .addConverterFactory(StringConverterFactory.create())
            // for raw JSONObject output (e.g., for the /configuration/about call)
            .addConverterFactory(JSONObjectConverterFactory.create())
            // for domain objects
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:22,代碼來源:GhostApiUtils.java

示例13: subscribe

import android.support.annotation.NonNull; //導入依賴的package包/類
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {

    final OnCompleteListener<T> listener = new OnCompleteListener<T>() {
        @Override
        public void onComplete(@NonNull Task<T> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    database.runTransaction(transaction).addOnCompleteListener(listener);
}
 
開發者ID:btrautmann,項目名稱:RxFirestore,代碼行數:21,代碼來源:RunTransactionOnSubscribe.java

示例14: handlePermissionResult

import android.support.annotation.NonNull; //導入依賴的package包/類
public void handlePermissionResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){
    PermissionRequest request = mCurrentRequest.poll();
    PermissionCallBack callBack = request.getCallBack();
    if(requestCode != PERMISSION_CODE || callBack == null){
        return;
    }
    for(int i=0;i<grantResults.length;i++){
        if(grantResults[i] == PackageManager.PERMISSION_DENIED){
            callBack.onDenied();
            return;
        }
    }
     callBack.onAllPermissionGranted();
}
 
開發者ID:stdnull,項目名稱:RunMap,代碼行數:15,代碼來源:PermissionManager.java

示例15: GetList

import android.support.annotation.NonNull; //導入依賴的package包/類
@Override
public SerializableList<Movie> GetList(@NonNull String[] stringArray) {
    if (StringHelper.StringsAreEqual(stringArray)) {
        return parseStringToList(stringArray[0]);
    } else {
        String usedEntry = StringHelper.SelectString(stringArray, SEARCH_PARAMETER);
        return parseStringToList(usedEntry);
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:10,代碼來源:JsonDataToMovieConverter.java


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