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 Project: zom-android-matrix Author: zom File: StoryView.java License: 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 #2
Source Project: Focus Author: ihewro File: FeedManageActivity.java License: 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 Project: YTPlayer Author: KaustubhPatange File: IntentDownloadService.java License: 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 #4
Source Project: landlord_client Author: GramYang File: MainActivity.java License: 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 #5
Source Project: tysq-android Author: tysqapp File: NotificationAdapter.java License: 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 #6
Source Project: star-zone-android Author: bootsrc File: FriendAdapter.java License: 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 #7
Source Project: SimpleAdapterDemo Author: JustinRoom File: BaseItemAdapter.java License: 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 #8
Source Project: security-samples Author: android File: Fido2DemoActivity.java License: 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 #9
Source Project: pdfview-android Author: Dmitry-Borodin File: ImageSource.java License: 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 #10
Source Project: FastWaiMai Author: zion223 File: GoodsInfoDelegate.java License: 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 #11
Source Project: v9porn Author: ForLovelj File: DownloadPresenter.java License: 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 #12
Source Project: scene Author: bytedance File: SceneTests.java License: 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 #13
Source Project: videocreator Author: xiaoyifan6 File: CommonAdapter.java License: 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 #14
Source Project: AndroidWallet Author: Cocos-BCX File: CustomActivityOnCrash.java License: 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 #15
Source Project: SoloPi Author: alipay File: MultiParamStepProvider.java License: 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 #16
Source Project: SimpleAdapterDemo Author: JustinRoom File: WindowUtils.java License: 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 #17
Source Project: scene Author: bytedance File: AsyncInflateSceneDemo.java License: 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 #18
Source Project: scene Author: bytedance File: NavigationSceneCompatUtility.java License: 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 #19
Source Project: BaseUrlManager Author: jenly1314 File: BaseUrlManager.java License: MIT License | 5 votes |
@Override public void remove(@NonNull UrlInfo urlInfo) { if(urlInfos!=null){ urlInfos.remove(urlInfo); BaseUrlUtil.remove(context,urlInfo.getBaseUrl()); } }
Example #20
Source Project: SoloPi Author: alipay File: InjectParam.java License: 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 #21
Source Project: incubator-weex-playground Author: apache File: AbstractWeexActivity.java License: 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 #22
Source Project: FastWaiMai Author: zion223 File: WebDelegateImpl.java License: MIT License | 5 votes |
@Override public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) { //跳转URL if(getUrl() != null){ //原生的webView 方法进行加载 Router.getInstance().loadPage(this,getUrl()); } }
Example #23
Source Project: Android-utils Author: Shouheng88 File: ActivityUtils.java License: 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 #24
Source Project: TelePlus-Android Author: TelePlusDev File: MediaCodecVideoRenderer.java License: 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 #25
Source Project: Upchain-wallet Author: xilibi2003 File: TransactionDetailViewModelFactory.java License: 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 #26
Source Project: WanAndroid Author: chejdj File: DisplayUtils.java License: 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 #27
Source Project: FastWaiMai Author: zion223 File: SubmitDelegate.java License: 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 #28
Source Project: AndroidWallet Author: Cocos-BCX File: CustomActivityOnCrash.java License: 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 #29
Source Project: MarketAndroidApp Author: a1098832322 File: MyToolBar.java License: 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 #30
Source Project: incubator-weex-playground Author: apache File: BenchmarkTest.java License: 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; }