• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.providers.media.photopicker.ui;
18 
19 import android.content.Context;
20 import android.view.ViewGroup;
21 import android.widget.ImageView;
22 
23 import androidx.viewpager2.widget.ViewPager2;
24 import androidx.annotation.NonNull;
25 
26 import com.android.providers.media.R;
27 import com.android.providers.media.photopicker.data.model.Item;
28 
29 /**
30  * ViewHolder of an image item within the {@link ViewPager2}
31  */
32 public class PreviewImageHolder extends BaseViewHolder {
33     private final ImageLoader mImageLoader;
34     private final ImageView mImageView;
35 
PreviewImageHolder(@onNull Context context, @NonNull ViewGroup parent, @NonNull ImageLoader imageLoader)36     public PreviewImageHolder(@NonNull Context context, @NonNull ViewGroup parent,
37             @NonNull ImageLoader imageLoader) {
38         super(context, parent, R.layout.item_image_preview);
39 
40         mImageView = itemView.findViewById(R.id.preview_imageView);
41         mImageLoader = imageLoader;
42     }
43 
44     @Override
bind()45     public void bind() {
46         final Item item = (Item) itemView.getTag();
47         mImageLoader.loadImagePreview(item, mImageView);
48     }
49 }
50