android.support.annotation.NonNull Java Examples
The following examples show how to use
android.support.annotation.NonNull.
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: IntentDownloadService.java From YTPlayer with GNU General Public License v3.0 | 6 votes |
@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; } }
Example #2
Source File: FeedManageActivity.java From Focus with GNU General Public License v3.0 | 6 votes |
@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(); } }
Example #3
Source File: NotificationAdapter.java From tysq-android with GNU General Public License v3.0 | 6 votes |
/** * 设置富文本内容,并设置昵称的点击事件 * * @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()); }
Example #4
Source File: BaseItemAdapter.java From SimpleAdapterDemo with Apache License 2.0 | 6 votes |
@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; }
Example #5
Source File: FriendAdapter.java From star-zone-android with Apache License 2.0 | 6 votes |
@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); } }); }
Example #6
Source File: StoryView.java From zom-android-matrix with Apache License 2.0 | 6 votes |
@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); }
Example #7
Source File: MainActivity.java From landlord_client with Apache License 2.0 | 6 votes |
@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; } }
Example #8
Source File: ImageSource.java From pdfview-android with Apache License 2.0 | 5 votes |
/** * 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; }
Example #9
Source File: MultiParamStepProvider.java From SoloPi with Apache License 2.0 | 5 votes |
public MultiParamStepProvider(@NonNull RecordCaseInfo recordCase) { this.recordCase = recordCase; currentIdx = 0; operationService = LauncherApplication.service(OperationService.class); parseParams(); resultBeans = new ArrayList<>(repeatParams.size() + 1); }
Example #10
Source File: CustomActivityOnCrash.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 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; } }
Example #11
Source File: SceneTests.java From scene with Apache License 2.0 | 5 votes |
@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(); }
Example #12
Source File: DisplayUtils.java From WanAndroid with MIT License | 5 votes |
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; }
Example #13
Source File: GoodsInfoDelegate.java From FastWaiMai with MIT License | 5 votes |
@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)); }
Example #14
Source File: MyToolBar.java From MarketAndroidApp with Apache License 2.0 | 5 votes |
@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; }
Example #15
Source File: BenchmarkTest.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
@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; }
Example #16
Source File: DownloadPresenter.java From v9porn with MIT License | 5 votes |
/** * 连同文件一起删除 * * @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); } }); } }
Example #17
Source File: CommonAdapter.java From videocreator with Apache License 2.0 | 5 votes |
@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); } } }
Example #18
Source File: CustomActivityOnCrash.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 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; }
Example #19
Source File: SubmitDelegate.java From FastWaiMai with MIT License | 5 votes |
@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); }
Example #20
Source File: Fido2DemoActivity.java From security-samples with Apache License 2.0 | 5 votes |
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(); } }); }
Example #21
Source File: TransactionDetailViewModelFactory.java From Upchain-wallet with GNU Affero General Public License v3.0 | 5 votes |
@NonNull @Override public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { return (T) new TransactionDetailViewModel( EthereumNetworkRepository, findDefaultWalletInteract ); }
Example #22
Source File: WindowUtils.java From SimpleAdapterDemo with Apache License 2.0 | 5 votes |
/** * 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; }
Example #23
Source File: MediaCodecVideoRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onFrameRendered(@NonNull MediaCodec codec, long presentationTimeUs, long nanoTime) { if (this != tunnelingOnFrameRenderedListener) { // Stale event. return; } maybeNotifyRenderedFirstFrame(); }
Example #24
Source File: AsyncInflateSceneDemo.java From scene with Apache License 2.0 | 5 votes |
@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; }
Example #25
Source File: ActivityUtils.java From Android-utils with Apache License 2.0 | 5 votes |
/** * 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; }
Example #26
Source File: NavigationSceneCompatUtility.java From scene with Apache License 2.0 | 5 votes |
/** * 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); }
Example #27
Source File: BaseUrlManager.java From BaseUrlManager with MIT License | 5 votes |
@Override public void remove(@NonNull UrlInfo urlInfo) { if(urlInfos!=null){ urlInfos.remove(urlInfo); BaseUrlUtil.remove(context,urlInfo.getBaseUrl()); } }
Example #28
Source File: InjectParam.java From SoloPi with Apache License 2.0 | 5 votes |
private InjectParam(@NonNull String name, @NonNull Class type) { this.name = name; if (type.isPrimitive()) { this.type = Const.getPackedType(type); } else { this.type = type; } }
Example #29
Source File: AbstractWeexActivity.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
@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); } }
Example #30
Source File: WebDelegateImpl.java From FastWaiMai with MIT License | 5 votes |
@Override public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) { //跳转URL if(getUrl() != null){ //原生的webView 方法进行加载 Router.getInstance().loadPage(this,getUrl()); } }