android.support.annotation.NonNull源码实例Demo

类android.support.annotation.NonNull源码实例Demo

下面列出了android.support.annotation.NonNull 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: zom-android-matrix   文件: StoryView.java
@Override
public void onViewRecycled(@NonNull MessageViewHolder holder) {
    if (holder.itemView instanceof PDFView) {
        final PDFView pdfView = (PDFView)holder.itemView;
        pdfView.post(new Runnable() {
            @Override
            public void run() {
                pdfView.recycle();
            }
        });
    } else if (holder.itemView instanceof SimpleExoPlayerView) {
        ((SimpleExoPlayerView)holder.itemView).getPlayer().stop(true);
        ((SimpleExoPlayerView)holder.itemView).getPlayer().release();
        ((SimpleExoPlayerView)holder.itemView).setPlayer(null);
    }
    super.onViewRecycled(holder);
}
 
源代码2 项目: Focus   文件: FeedManageActivity.java
@Override
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
    //3.1 申请成功
    if (requestCode == OPMLReadHelper.RQUEST_STORAGE_READ){
        if (opmlReadHelper==null){
            opmlReadHelper = new OPMLReadHelper(FeedManageActivity.this);
        }
        opmlReadHelper.run();
    }else if (requestCode == OPMLCreateHelper.REQUEST_STORAGE_WRITE){
        if (opmlCreateHelper==null){
            opmlCreateHelper = new OPMLCreateHelper(FeedManageActivity.this);
        }
        opmlCreateHelper.run();
    }

}
 
源代码3 项目: YTPlayer   文件: IntentDownloadService.java
@Override
protected void onHandleIntent(@NonNull Intent intent) {
    isDownloaded=false;

    currentModel = (YTConfig) intent.getSerializableExtra("addJob");

    if (pendingJobs.size() > 0)
        pendingJobs.remove(0);
    switch (currentModel.getTaskExtra()) {

        case "autoTask":
            autoTask();
            break;
        case "mp3Task":
            mp3Task();
            break;
        case "mergeTask":
            mergeTask();
            break;
    }
}
 
源代码4 项目: landlord_client   文件: MainActivity.java
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case 200:
            if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                avatarPopupWindow.dismiss();
                AvatarChangeUtil.selectPicture(this);
            } else {
                avatarPopupWindow.dismiss();
            }
            break;
        case 300:
            if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED
                    && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
                avatarPopupWindow.dismiss();
                AvatarChangeUtil.takePicture(this);
            } else {
                avatarPopupWindow.dismiss();
            }
            break;
    }
}
 
源代码5 项目: tysq-android   文件: NotificationAdapter.java
/**
 * 设置富文本内容,并设置昵称的点击事件
 *
 * @param content  内容
 * @param name     昵称
 * @param userId   用户id
 * @param textView
 */
private void setContentAndNameClick(String content, String name, int userId, TextView textView) {
    SpannableStringBuilder builder = new SpannableStringBuilder(content);
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(@NonNull View view) {
            PersonalHomePageActivity.startActivity(mContext.get(), userId);
        }

        @Override
        public void updateDrawState(@NonNull TextPaint ds) {
            ds.setColor(mContext.get().getResources().getColor(R.color.main_text_color));
        }
    };

    builder.setSpan(
            clickableSpan,
            0,
            name.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    textView.setText(builder);
    textView.setMovementMethod(MyLinkedMovementMethod.getInstance());
}
 
源代码6 项目: star-zone-android   文件: FriendAdapter.java
@Override
public void onBindViewHolder(@NonNull final FriendAdapter.ViewHolder holder, final int position) {
    final UserProfile user = dataList.get(position);
    String headImgValue = user.getHeadImg();
    if (!TextUtils.isEmpty(headImgValue)) {
        ImageLoadMnanger.INSTANCE.loadImage(holder.headView,
                NetConstant.RESOURCES_BASE + headImgValue);
    }
    holder.nameView.setText(user.getNickname());

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onItemClick(holder.itemView, position, user);
        }
    });
}
 
源代码7 项目: SimpleAdapterDemo   文件: BaseItemAdapter.java
@NonNull
@Override
public BaseItemViewHolder<T> onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
    View itemView = onCreateViewHolderListener == null ? null : onCreateViewHolderListener.onCreateItemView(viewGroup);
    if (itemView == null) {
        if (getItemLayoutId() == -1)
            throw new IllegalArgumentException("Please set item layout first.");
        itemView = LayoutInflater.from(viewGroup.getContext()).inflate(getItemLayoutId(), viewGroup, false);
    }
    BaseItemViewHolder<T> holder = new BaseItemViewHolder<>(itemView);
    holder.bindItemClickListener(onItemClickListener);
    holder.bindItemLongClickListener(onItemLongClickListener);
    holder.bindItemChildClickListener(onItemChildClickListener);
    holder.bindItemChildLongClickListener(onItemChildLongClickListener);
    if (onCreateViewHolderListener != null)
        onCreateViewHolderListener.afterCreateViewHolder(holder);
    return holder;
}
 
源代码8 项目: security-samples   文件: Fido2DemoActivity.java
public void removeTokenByIndexInList(int whichToken) {
/* assume this operation can only happen within short time after
  updateAndDisplayRegisteredKeys, which has already checked permission
*/
    Task<String> removeSecurityKeyTask = asyncRemoveSecurityKey(whichToken);
    removeSecurityKeyTask.addOnCompleteListener(
            new OnCompleteListener<String>() {
                @Override
                public void onComplete(@NonNull Task<String> task) {
                    updateAndDisplayRegisteredKeys();
                }
            });
}
 
源代码9 项目: pdfview-android   文件: ImageSource.java
/**
 * Use a region of the source image. Region must be set independently for the full size image and the preview if
 * you are using one.
 * @param sRegion the region of the source image to be displayed.
 * @return this instance for chaining.
 */
@NonNull
public ImageSource region(Rect sRegion) {
    this.sRegion = sRegion;
    setInvariants();
    return this;
}
 
源代码10 项目: FastWaiMai   文件: GoodsInfoDelegate.java
@Override
public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) {
    final String name = mData.getString("name");
    final String desc = mData.getString("description");
    final double price = mData.getDoubleValue("price");
    mTvGoodsTitle.setText(name);
    mTvGoodsDesc.setText(desc);
    mTvGoodsPrice.setText(String.valueOf(price));
}
 
源代码11 项目: v9porn   文件: DownloadPresenter.java
/**
 * 连同文件一起删除
 *
 * @param v9PornItem v
 */
private void deleteWithFile(V9PornItem v9PornItem) {
    File file = new File(v9PornItem.getDownLoadPath(getCustomDownloadVideoDirPath()));
    if (file.delete()) {
        v9PornItem.setDownloadId(0);
        dataManager.updateV9PornItem(v9PornItem);
    } else {
        ifViewAttached(new ViewAction<DownloadView>() {
            @Override
            public void run(@NonNull DownloadView view) {
                view.showMessage("删除文件失败", TastyToast.ERROR);
            }
        });
    }
}
 
源代码12 项目: scene   文件: SceneTests.java
@Test(expected = IllegalStateException.class)
public void testRequireArgumentsException() {
    Scene scene = new Scene() {
        @NonNull
        @Override
        public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable Bundle savedInstanceState) {
            return new View(requireSceneContext());
        }
    };
    scene.requireArguments();
}
 
源代码13 项目: videocreator   文件: CommonAdapter.java
@Override
public void onViewAttachedToWindow(@NonNull CommonHolder holder) {
    if (mSupport == null) {
        return;
    }
    int position = holder.getLayoutPosition();
    // 如果设置合并单元格
    if (mSupport.isSpan(data.get(position))) {
        ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
        if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
            StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
            p.setFullSpan(true);
        }
    }
}
 
源代码14 项目: AndroidWallet   文件: CustomActivityOnCrash.java
/**
 * Given an Intent, returns several error details including the stack trace extra from the intent.
 *
 * @param context A valid context. Must not be null.
 * @param intent  The Intent. Must not be null.
 * @return The full error details.
 */
@NonNull
public static String getAllErrorDetailsFromIntent(@NonNull Context context, @NonNull Intent intent) {
    //I don't think that this needs localization because it's a development string...

    Date currentDate = new Date();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);

    //Get build date
    String buildDateAsString = getBuildDateAsString(context, dateFormat);

    //Get app version
    String versionName = getVersionName(context);

    String errorDetails = "";

    errorDetails += "Build version: " + versionName + " \n";
    if (buildDateAsString != null) {
        errorDetails += "Build date: " + buildDateAsString + " \n";
    }
    errorDetails += "Current date: " + dateFormat.format(currentDate) + " \n";
    //Added a space between line feeds to fix #18.
    //Ideally, we should not use this method at all... It is only formatted this way because of coupling with the default error activity.
    //We should move it to a method that returns a bean, and let anyone format it as they wish.
    errorDetails += "Device: " + getDeviceModelName() + " \n \n";
    errorDetails += "Stack trace:  \n";
    errorDetails += getStackTraceFromIntent(intent);

    String activityLog = getActivityLogFromIntent(intent);

    if (activityLog != null) {
        errorDetails += "\nUser actions: \n";
        errorDetails += activityLog;
    }
    return errorDetails;
}
 
源代码15 项目: SoloPi   文件: MultiParamStepProvider.java
public MultiParamStepProvider(@NonNull RecordCaseInfo recordCase) {
    this.recordCase = recordCase;
    currentIdx = 0;
    operationService = LauncherApplication.service(OperationService.class);

    parseParams();
    resultBeans = new ArrayList<>(repeatParams.size() + 1);
}
 
源代码16 项目: SimpleAdapterDemo   文件: WindowUtils.java
/**
 * Get status bar height.
 *
 * @param context context
 * @return the height of status bar
 */
public static int getStatusBarHeight(@NonNull Context context) {
    int statusBarHeight = 0;
    int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = CompatResourceUtils.getDimensionPixelSize(context, resourceId);
    }
    return statusBarHeight;
}
 
源代码17 项目: scene   文件: AsyncInflateSceneDemo.java
@NonNull
@Override
public ViewGroup onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    id = View.generateViewId();

    FrameLayout frameLayout = new FrameLayout(requireActivity());
    frameLayout.setId(id);
    return frameLayout;
}
 
源代码18 项目: scene   文件: NavigationSceneCompatUtility.java
/**
 * use {@link #setupWithFragment(Fragment, Class, int)} instead
 */
@Deprecated
@NonNull
public static SceneDelegate setupWithFragment(@NonNull final Fragment fragment,
                                              @IdRes int containerId,
                                              @Nullable Bundle savedInstanceState,
                                              @NonNull Class<? extends Scene> rootScene,
                                              @Nullable Bundle bundle,
                                              boolean supportRestore) {
    return setupWithFragment(fragment, containerId, savedInstanceState,
            new NavigationSceneOptions(rootScene, bundle),
            null,
            supportRestore);
}
 
源代码19 项目: BaseUrlManager   文件: BaseUrlManager.java
@Override
public void remove(@NonNull UrlInfo urlInfo) {
    if(urlInfos!=null){
        urlInfos.remove(urlInfo);
        BaseUrlUtil.remove(context,urlInfo.getBaseUrl());
    }
}
 
源代码20 项目: SoloPi   文件: InjectParam.java
private InjectParam(@NonNull String name, @NonNull Class type) {
    this.name = name;
    if (type.isPrimitive()) {
        this.type = Const.getPackedType(type);
    } else {
        this.type = type;
    }
}
 
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  if (mInstance != null) {
    mInstance.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }
}
 
源代码22 项目: FastWaiMai   文件: WebDelegateImpl.java
@Override
public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) {
	//跳转URL
	if(getUrl() != null){
		//原生的webView 方法进行加载
		Router.getInstance().loadPage(this,getUrl());
	}
}
 
源代码23 项目: Android-utils   文件: ActivityUtils.java
/**
 * Judge is given activity exists.
 *
 * @param pkg the package name
 * @param cls the class name
 * @return true if exists
 */
public static boolean isActivityExists(@NonNull final String pkg, @NonNull final String cls) {
    Intent intent = new Intent();
    intent.setClassName(pkg, cls);
    PackageManager pm = UtilsApp.getApp().getPackageManager();
    return pm.resolveActivity(intent, 0) != null
            && intent.resolveActivity(pm) != null
            && pm.queryIntentActivities(intent, 0).size() != 0;
}
 
源代码24 项目: TelePlus-Android   文件: MediaCodecVideoRenderer.java
@Override
public void onFrameRendered(@NonNull MediaCodec codec, long presentationTimeUs, long nanoTime) {
  if (this != tunnelingOnFrameRenderedListener) {
    // Stale event.
    return;
  }
  maybeNotifyRenderedFirstFrame();
}
 
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
    return (T) new TransactionDetailViewModel(
            EthereumNetworkRepository,
            findDefaultWalletInteract
            );
}
 
源代码26 项目: WanAndroid   文件: DisplayUtils.java
public static void setCustomDensity(@NonNull Activity activity, @NonNull final Application application) {
    DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics();
    if (sNoncompatDensity == 0) {
        sNoncompatDensity = appDisplayMetrics.density;
        sNoncompatScaledDensity = appDisplayMetrics.scaledDensity;
        // 防止系统切换后不起作用
        application.registerComponentCallbacks(new ComponentCallbacks() {
            @Override
            public void onConfigurationChanged(Configuration newConfig) {
                if (newConfig != null && newConfig.fontScale > 0) {
                    sNoncompatScaledDensity = application.getResources().getDisplayMetrics().scaledDensity;
                }
            }

            @Override
            public void onLowMemory() {

            }
        });
    }
    float targetDensity = appDisplayMetrics.widthPixels / 360;
    // 防止字体变小
    float targetScaleDensity = targetDensity * (sNoncompatScaledDensity / sNoncompatDensity);
    int targetDensityDpi = (int) (160 * targetDensity);

    appDisplayMetrics.density = targetDensity;
    appDisplayMetrics.scaledDensity = targetScaleDensity;
    appDisplayMetrics.densityDpi = targetDensityDpi;

    final DisplayMetrics activityDisplayMetrics = activity.getResources().getDisplayMetrics();
    activityDisplayMetrics.density = targetDensity;
    activityDisplayMetrics.scaledDensity = targetScaleDensity;
    activityDisplayMetrics.densityDpi = targetDensityDpi;
}
 
源代码27 项目: FastWaiMai   文件: SubmitDelegate.java
@Override
public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) {
	//支付方式
	initPayCheckBox();

	//订单支付剩余时间15min开始倒计时
	initPayLeftTime();

	//支付金额
	final SpannableString paymoney = new SpannableString("¥24.8");
	paymoney.setSpan(new AbsoluteSizeSpan(20, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
	mTvPayMoney.setText(paymoney);
}
 
源代码28 项目: AndroidWallet   文件: CustomActivityOnCrash.java
/**
 * INTERNAL method that returns the device model name with correct capitalization.
 * Taken from: http://stackoverflow.com/a/12707479/1254846
 *
 * @return The device model name (i.e., "LGE Nexus 5")
 */
@NonNull
private static String getDeviceModelName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return capitalize(model);
    } else {
        return capitalize(manufacturer) + " " + model;
    }
}
 
源代码29 项目: MarketAndroidApp   文件: MyToolBar.java
@NonNull
private TextView findTitle() {
    TextView title = (TextView) this.findViewById(R.id.cat_title);
    if (title == null) {
        throw new IllegalStateException("TextView with id ta_title not found");
    }
    return title;
}
 
源代码30 项目: incubator-weex-playground   文件: BenchmarkTest.java
@NonNull
private BenchmarkActivity loadWeexPage() {
  final BenchmarkActivity benchmarkActivity = mActivityRule.getActivity();
  benchmarkActivity.loadWeexPage();
  await().atMost(WAIT_TIMEOUT, TimeUnit.MILLISECONDS).until(new Callable<Boolean>() {
    @Override
    public Boolean call() throws Exception {
      return benchmarkActivity.isRenderFinish();
    }
  });
  return benchmarkActivity;
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类方法
 同包方法