com.bumptech.glide.request.target.CustomTarget Java Examples
The following examples show how to use
com.bumptech.glide.request.target.CustomTarget.
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: MediaNotificationManager.java From klingar with Apache License 2.0 | 6 votes |
private void loadImage(final String url, final NotificationCompat.Builder builder) { Glide.with(service) .asBitmap() .load(url) .apply(RequestOptions.overrideOf(iconWidth, iconHeight)) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady( @NonNull Bitmap resource, Transition<? super Bitmap> transition ) { if (TextUtils.equals(currentTrack.thumb(), url)) { builder.setLargeIcon(resource); notificationManager.notify(NOTIFICATION_ID, builder.build()); } } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); }
Example #2
Source File: EditEntryActivity.java From Aegis with GNU General Public License v3.0 | 6 votes |
private void startEditingIcon(Uri data) { Glide.with(this) .asBitmap() .load(data) .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(false) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { _kropView.setBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); _iconView.setVisibility(View.GONE); _kropView.setVisibility(View.VISIBLE); _saveImageButton.setOnClickListener(v -> { stopEditingIcon(true); }); _isEditingIcon = true; }
Example #3
Source File: MainActivity.java From lbry-android with MIT License | 6 votes |
@Nullable @Override public Bitmap getCurrentLargeIcon(Player player, PlayerNotificationManager.BitmapCallback callback) { if (nowPlayingClaimBitmap == null && nowPlayingClaim != null && !Helper.isNullOrEmpty(nowPlayingClaim.getThumbnailUrl())) { Glide.with(getApplicationContext()).asBitmap().load(nowPlayingClaim.getThumbnailUrl()).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { nowPlayingClaimBitmap = resource; callback.onBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); } return nowPlayingClaimBitmap; }
Example #4
Source File: WallpaperSetter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
public static void set(String url, int setTo, Context context, SetWallpaperListener setWallpaperListener) { Toast.makeText(context, R.string.save_image_first, Toast.LENGTH_SHORT).show(); WallpaperManager wallpaperManager = WallpaperManager.getInstance(context); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Glide.with(context).asBitmap().load(url).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { new SetAsWallpaperAsyncTask(resource, setTo, wallpaperManager, windowManager, setWallpaperListener).execute(); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); }
Example #5
Source File: ImportShowAdapter.java From YTPlayer with GNU General Public License v3.0 | 6 votes |
@Override public void onBindViewHolder(@NonNull ImportShowHolder holder, int i) { final ImportShowModel model = models.get(i); holder.title.setText(model.getTitle()); holder.author.setText(model.getAuthor()); Glide.with(context.getApplicationContext()).asBitmap().load(model.getImageUrl()).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { holder.image.setImageBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); }
Example #6
Source File: ZoomFragment.java From NClientV2 with Apache License 2.0 | 5 votes |
private void createTarget() { target=new CustomTarget<Drawable>() { void applyDrawable(ImageView toShow,ImageView toHide,Drawable drawable){ toShow.setVisibility(View.VISIBLE); toHide.setVisibility(View.GONE); toShow.setImageDrawable(drawable); if(toShow instanceof PhotoView) scalePhoto(drawable); } @Override public void onLoadStarted(@Nullable Drawable placeholder) { super.onLoadStarted(placeholder); applyDrawable(photoView,retryButton,placeholder); } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); applyDrawable(retryButton,photoView,errorDrawable); } @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { applyDrawable(photoView,retryButton,resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { applyDrawable(photoView,retryButton,placeholder); } }; }
Example #7
Source File: ViewImageOrGifActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
private void shareImage() { glide.asBitmap().load(mImageUrl).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { if (getExternalCacheDir() != null) { Toast.makeText(ViewImageOrGifActivity.this, R.string.save_image_first, Toast.LENGTH_SHORT).show(); new SaveImageToFileAsyncTask(resource, getExternalCacheDir().getPath(), mImageFileName, new SaveImageToFileAsyncTask.SaveImageToFileAsyncTaskListener() { @Override public void saveSuccess(File imageFile) { Uri uri = FileProvider.getUriForFile(ViewImageOrGifActivity.this, BuildConfig.APPLICATION_ID + ".provider", imageFile); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, getString(R.string.share))); } @Override public void saveFailed() { Toast.makeText(ViewImageOrGifActivity.this, R.string.cannot_save_image, Toast.LENGTH_SHORT).show(); } }).execute(); } else { Toast.makeText(ViewImageOrGifActivity.this, R.string.cannot_get_storage, Toast.LENGTH_SHORT).show(); } } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); }
Example #8
Source File: AddGroupDetailsFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (requestCode == REQUEST_CODE_AVATAR && resultCode == Activity.RESULT_OK && data != null) { if (data.getBooleanExtra("delete", false)) { viewModel.setAvatar(null); return; } final Media result = data.getParcelableExtra(AvatarSelectionActivity.EXTRA_MEDIA); final DecryptableStreamUriLoader.DecryptableUri decryptableUri = new DecryptableStreamUriLoader.DecryptableUri(result.getUri()); GlideApp.with(this) .asBitmap() .load(decryptableUri) .skipMemoryCache(true) .diskCacheStrategy(DiskCacheStrategy.NONE) .centerCrop() .override(AvatarHelper.AVATAR_DIMENSIONS, AvatarHelper.AVATAR_DIMENSIONS) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { viewModel.setAvatar(Objects.requireNonNull(BitmapUtil.toByteArray(resource))); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); } else { super.onActivityResult(requestCode, resultCode, data); } }
Example #9
Source File: ChannelActivity.java From Twire with GNU General Public License v3.0 | 5 votes |
private Target<Bitmap> getNightThemeTarget() { return new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) { streamerImage.setImageBitmap(bitmap); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }; }
Example #10
Source File: SearchAdapter.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(final MyViewHolder holder, final int listPosition) { final SearchModel searchModel = dataSet.get(listPosition); holder.titleText.setText(searchModel.getTitle()); Glide.with(con.getApplicationContext()) .asBitmap() .load(searchModel.getImageUrl()) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { holder.imageView.setImageBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); if (isLibraryFrag) { holder.mainCard.setOnClickListener(v -> { if (YTutils.isInternetAvailable()) { ArrayList<String> urls = new ArrayList<>(yturls); Collections.reverse(urls); MainActivity.PlayVideo(YTutils.ConvertToStringArray(urls), listPosition); }else Toast.makeText(con, "No active internet connection!", Toast.LENGTH_SHORT).show(); }); }else { holder.mainCard.setOnClickListener(v -> { if (YTutils.isInternetAvailable()) MainActivity.PlayVideo(YTutils.ConvertToStringArray(yturls),9-listPosition); else Toast.makeText(con, "No active internet connection!", Toast.LENGTH_SHORT).show(); }); } }
Example #11
Source File: DAdapter.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
@SuppressLint("SetTextI18n") @Override public void onBindViewHolder(@NonNull DHolder holder, int i) { final DModel dModel = models.get(i); holder.checkBox.setOnCheckedChangeListener(null); if (dModel.isChecked()) { holder.checkBox.setChecked(true); }else holder.checkBox.setChecked(false); holder.title.setText(dModel.getTitle()); if (dModel.getSeconds()>0) { holder.subtitle.setText(YTutils.milliSecondsToTimer(dModel.getSeconds()*1000)+" "+ Html.fromHtml("•")+" "+dModel.getSubtitle()); }else holder.subtitle.setText(dModel.getSubtitle()); Glide.with(context.getApplicationContext()).asBitmap().load(dModel.getImageUrl()).into(new CustomTarget<Bitmap>(){ @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { holder.imageView.setImageBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); holder.checkBox.setOnCheckedChangeListener((compoundButton, b) -> { listener.onClick(dModel,i); }); holder.layout.setOnClickListener(view -> listener.onClick(dModel,i)); }
Example #12
Source File: PlayerActivity2.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
@Override protected void onPostExecute(Void aVoid) { String imageUri = YTutils.getImageUrl(MusicService.yturls.get(MusicService.ytIndex)); if (MusicService.videoID.contains("soundcloud.com")) imageUri = soundCloud.getModel().getImageUrl(); Glide.with(activity.getApplicationContext()) .asBitmap() .load(imageUri) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { Palette.generateAsync(resource, palette -> { MusicService.bitmapIcon = resource; MusicService.nColor = palette.getVibrantColor(activity.getResources().getColor(R.color.light_white)); Log.e(TAG, "loadData: Changing nColor: "+MusicService.nColor + ", ImageUri: "+MusicService.imgUrl ); loadAgain(); MusicService.rebuildNotification(); }); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); super.onPostExecute(aVoid); }
Example #13
Source File: NPlaylistActivity.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
@Override protected void onPostExecute(Void aVoid) { if (MusicService.localPlayBack) { } if (meta.getVideMeta()!=null && !MusicService.localPlayBack) { cTitle.setText(YTutils.getVideoTitle(meta.getVideMeta().getTitle())); cAuthor.setText(YTutils.getChannelTitle(meta.getVideMeta().getTitle(),meta.getVideMeta().getAuthor())); Glide.with(NPlaylistActivity.this.getApplicationContext()) .asBitmap() .load(meta.getVideMeta().getImgUrl()) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { Palette.generateAsync(resource, palette -> { cImageView.setImageBitmap(resource); MusicService.bitmapIcon = resource; MusicService.nColor = palette.getVibrantColor(NPlaylistActivity.this .getResources().getColor(R.color.light_white)); Log.e(TAG, "setCurrentData: Changing nColor: "+MusicService.nColor + ", ImageUri: "+MusicService.imgUrl ); MusicService.rebuildNotification(); }); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); } super.onPostExecute(aVoid); }
Example #14
Source File: ChannelActivity.java From Twire with GNU General Public License v3.0 | 4 votes |
private Target<Bitmap> getLightThemeTarget() { return new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) { streamerImage.setImageBitmap(bitmap); Palette palette = Palette.from(bitmap).generate(); int defaultColor = Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, getBaseContext()); int defaultDarkColor = Service.getColorAttribute(R.attr.colorPrimaryDark, R.color.primaryDark, getBaseContext()); int vibrant = palette.getVibrantColor(defaultColor); int vibrantDark = palette.getDarkVibrantColor(defaultColor); int vibrantLight = palette.getLightVibrantColor(defaultColor); int muted = palette.getMutedColor(defaultColor); int mutedDark = palette.getDarkMutedColor(defaultColor); Palette.Swatch swatch; if (vibrant != defaultColor) { swatch = palette.getVibrantSwatch(); } else if (vibrantDark != defaultColor) { swatch = palette.getDarkVibrantSwatch(); } else if (vibrantLight != defaultColor) { swatch = palette.getLightVibrantSwatch(); } else if (muted != defaultColor) { swatch = palette.getMutedSwatch(); } else if (mutedDark != defaultColor) { swatch = palette.getDarkMutedSwatch(); } else { swatch = palette.getLightMutedSwatch(); } if (swatch != null) { float[] swatchValues = swatch.getHsl(); float[] newSwatch = {swatchValues[0], (float) 0.85, (float) 0.85}; float[] newSwatchComposite = {(swatchValues[0] + 180) % 360, newSwatch[1], newSwatch[2]}; float[] newSwatchDark = {newSwatch[0], newSwatch[1], (float) 0.6}; int newColorDark = Color.HSVToColor(newSwatchDark); int newColor = Color.HSVToColor(newSwatch); int compositeNewColor = Color.HSVToColor(newSwatchComposite); int primaryColor = Service.getBackgroundColorFromView(toolbar, defaultColor); int primaryColorDark = Service.getBackgroundColorFromView(mTabs, defaultDarkColor); Service.animateBackgroundColorChange(toolbar, newColor, primaryColor, COLOR_FADE_DURATION); Service.animateBackgroundColorChange(additionalToolbar, newColor, primaryColor, COLOR_FADE_DURATION); Service.animateBackgroundColorChange(mTabs, newColorDark, primaryColorDark, COLOR_FADE_DURATION); mFab.setBackgroundTintList(ColorStateList.valueOf(compositeNewColor)); mTabs.setSelectedTabIndicatorColor(compositeNewColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(newColorDark); } } } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }; }
Example #15
Source File: SubmitPostService.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
private void submitImagePost() { Glide.with(this) .asBitmap() .load(mediaUri) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { SubmitPost.submitImagePost(mOauthRetrofit, mUploadMediaRetrofit, mAccessToken, getResources().getConfiguration().locale, subredditName, title, resource, flair, isSpoiler, isNSFW, new SubmitPost.SubmitPostListener() { @Override public void submitSuccessful(Post post) { EventBus.getDefault().post(new SubmitImagePostEvent(true, null)); Toast.makeText(SubmitPostService.this, R.string.image_is_processing, Toast.LENGTH_SHORT).show(); stopService(); } @Override public void submitFailed(@Nullable String errorMessage) { EventBus.getDefault().post(new SubmitImagePostEvent(false, errorMessage)); stopService(); } }); } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { EventBus.getDefault().post(new SubmitImagePostEvent(false, getString(R.string.error_processing_image))); stopService(); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); }
Example #16
Source File: SubmitPostService.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
private void submitVideoPost() { try (ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(mediaUri, "r")) { if (pfd != null) { FileInputStream in = new FileInputStream(pfd.getFileDescriptor()); byte[] buffer; buffer = new byte[in.available()]; while (in.read(buffer) != -1) ; Glide.with(this) .asBitmap() .load(mediaUri) .into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { String type = getContentResolver().getType(mediaUri); if (type != null) { SubmitPost.submitVideoPost(mOauthRetrofit, mUploadMediaRetrofit, mUploadVideoRetrofit, mAccessToken, getResources().getConfiguration().locale, subredditName, title, buffer, type, resource, flair, isSpoiler, isNSFW, new SubmitPost.SubmitPostListener() { @Override public void submitSuccessful(Post post) { EventBus.getDefault().post(new SubmitVideoPostEvent(true, false, null)); Toast.makeText(SubmitPostService.this, R.string.video_is_processing, Toast.LENGTH_SHORT).show(); stopService(); } @Override public void submitFailed(@Nullable String errorMessage) { EventBus.getDefault().post(new SubmitVideoPostEvent(false, false, errorMessage)); stopService(); } }); } else { EventBus.getDefault().post(new SubmitVideoPostEvent(false, true, null)); } } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { EventBus.getDefault().post(new SubmitVideoPostEvent(false, true, null)); stopService(); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); } else { EventBus.getDefault().post(new SubmitVideoPostEvent(false, true, null)); } } catch (IOException e) { e.printStackTrace(); EventBus.getDefault().post(new SubmitVideoPostEvent(false, true, null)); stopService(); } }
Example #17
Source File: ViewImgurImageFragment.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_download_view_imgur_image_fragments: if (isDownloading) { return false; } isDownloading = true; if (Build.VERSION.SDK_INT >= 23) { if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Permission is not granted // No explanation needed; request the permission ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE); } else { // Permission has already been granted mediaDownloader.download(imgurMedia.getLink(), imgurMedia.getFileName(), getContext()); } } else { mediaDownloader.download(imgurMedia.getLink(), imgurMedia.getFileName(), getContext()); } return true; case R.id.action_share_view_imgur_image_fragments: glide.asBitmap().load(imgurMedia.getLink()).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { if (activity.getExternalCacheDir() != null) { Toast.makeText(activity, R.string.save_image_first, Toast.LENGTH_SHORT).show(); new SaveImageToFileAsyncTask(resource, activity.getExternalCacheDir().getPath(), imgurMedia.getFileName(), new SaveImageToFileAsyncTask.SaveImageToFileAsyncTaskListener() { @Override public void saveSuccess(File imageFile) { Uri uri = FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".provider", imageFile); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, getString(R.string.share))); } @Override public void saveFailed() { Toast.makeText(activity, R.string.cannot_save_image, Toast.LENGTH_SHORT).show(); } }).execute(); } else { Toast.makeText(activity, R.string.cannot_get_storage, Toast.LENGTH_SHORT).show(); } } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); return true; case R.id.action_set_wallpaper_view_imgur_image_fragments: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment(); Bundle bundle = new Bundle(); bundle.putInt(SetAsWallpaperBottomSheetFragment.EXTRA_VIEW_PAGER_POSITION, activity.getCurrentPagePosition()); setAsWallpaperBottomSheetFragment.setArguments(bundle); setAsWallpaperBottomSheetFragment.show(activity.getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag()); } else { ((SetAsWallpaperCallback) activity).setToBoth(activity.getCurrentPagePosition()); } return true; } return false; }
Example #18
Source File: DiscoverAdapter.java From YTPlayer with GNU General Public License v3.0 | 4 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof MyViewHolder) { final DiscoverModel model = discoverModels.get(position); final MyViewHolder viewHolder = ((MyViewHolder) holder); if (position==discoverModels.size()-1 && position!=totalItems-1) { viewHolder.progressBar.setVisibility(VISIBLE); }else viewHolder.progressBar.setVisibility(GONE); viewHolder.authorText.setText(model.getAuthor()+""); viewHolder.titleText.setText(model.getTitle()); viewHolder.rate_percent.setText("#"+(position+1)); Glide.with(con.getApplicationContext()).asBitmap().load(model.getImgUrl()).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { viewHolder.imageView.setImageBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); /*Glide.with(con).load(model.getImgUrl()).addListener(new RequestListener<Drawable>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { viewHolder.imageView.setImageDrawable(resource); return true; } }).into(viewHolder.imageView);*/ viewHolder.addPlaylist.setOnClickListener(v -> { Activity activity = (Activity) con; new getData(activity,model).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }); Object[] objects = new Object[5]; objects[0]=position; objects[1]=model.getTitle();objects[2]=model.getYtUrl();objects[3]=model.getAuthor(); objects[4]=model.getImgUrl(); viewHolder.mainCard.setTag(objects); viewHolder.mainCard.setOnLongClickListener(longClickListener); viewHolder.mainCard.setOnClickListener(v -> { // A quick smart hack... to set Playlist models directly during loading... MusicService.nPlayModels.clear(); String[] yturls = new String[discoverModels.size()]; for (int i=0;i<yturls.length;i++) { MetaModel metaModel = new MetaModel( YTutils.getVideoID(discoverModels.get(i).getYtUrl()), discoverModels.get(i).getTitle(), discoverModels.get(i).getAuthor(), discoverModels.get(i).getImgUrl() ); NPlayModel nPlayModel = new NPlayModel( discoverModels.get(i).getYtUrl(), new YTMeta(metaModel),false); MusicService.nPlayModels.add(nPlayModel); yturls[i] = discoverModels.get(i).getYtUrl(); } MainActivity.PlayVideo(yturls,position); }); if (position%5==0 && position!=0 && position%10!=0 && AppSettings.showAds) { // Load ads on 5,15,25... Log.e("ShowingAds","pos: "+position); viewHolder.adLayout.setVisibility(VISIBLE); AdRequest adRequest = new AdRequest.Builder().addTestDevice("07153BA64BB64F7C3F726B71C4AE30B9").build(); viewHolder.adView.loadAd(adRequest); }else { viewHolder.adLayout.setVisibility(GONE); } } else { ((ProgressViewHolder) holder).progressBar.setIndeterminate(true); } }