2021-12-17 21:59:34 +00:00
package b.b.a.d ;
2021-07-24 02:37:17 +00:00
2021-11-02 06:38:17 +00:00
import android.animation.Animator ;
import android.animation.AnimatorInflater ;
import android.animation.AnimatorSet ;
import android.content.AsyncQueryHandler ;
import android.content.ContentResolver ;
import android.content.Context ;
import android.database.Cursor ;
import android.graphics.drawable.Drawable ;
import android.net.Uri ;
import android.os.Build ;
import android.provider.MediaStore ;
import android.view.LayoutInflater ;
import android.view.View ;
import android.view.ViewGroup ;
import android.widget.FrameLayout ;
import android.widget.TextView ;
import androidx.recyclerview.widget.RecyclerView ;
2021-12-17 21:59:34 +00:00
import b.b.a.e.c ;
2021-11-02 06:38:17 +00:00
import com.discord.utilities.time.TimeUtils ;
import com.facebook.drawee.view.SimpleDraweeView ;
import com.lytefast.flexinput.R ;
import com.lytefast.flexinput.model.Media ;
import com.lytefast.flexinput.utils.SelectionCoordinator ;
import d0.z.d.m ;
import d0.z.d.o ;
import java.util.Iterator ;
import java.util.List ;
import java.util.Objects ;
import kotlin.Unit ;
2021-07-24 02:37:17 +00:00
import kotlin.jvm.functions.Function1 ;
2021-11-02 06:38:17 +00:00
/* compiled from: MediaCursorAdapter.kt */
public final class h extends RecyclerView . Adapter < a > {
public final SelectionCoordinator < ? , Media > a ;
2021-07-24 02:37:17 +00:00
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-01-27 07:52:47 +00:00
public Cursor f316b ;
2021-12-17 21:59:34 +00:00
public int c ;
2021-11-02 06:38:17 +00:00
public int d ;
public int e ;
public int f ;
public Integer g ;
public final int h ;
public final int i ;
/* compiled from: MediaCursorAdapter.kt */
public final class a extends i implements View . OnClickListener {
2021-12-02 18:53:44 +00:00
public Media p ;
2021-11-02 06:38:17 +00:00
public final AnimatorSet q ;
2021-12-02 18:53:44 +00:00
public final AnimatorSet r ;
2021-11-02 06:38:17 +00:00
/* renamed from: s reason: collision with root package name */
2022-01-27 07:52:47 +00:00
public final c f317s ;
2021-12-02 18:53:44 +00:00
public final /* synthetic */ h t ;
2021-11-02 06:38:17 +00:00
/* compiled from: MediaCursorAdapter.kt */
2021-12-17 21:59:34 +00:00
/* renamed from: b.b.a.d.h$a$a reason: collision with other inner class name */
2022-02-02 08:50:56 +00:00
public static final class C0051a extends o implements Function1 < AnimatorSet , Unit > {
2021-11-02 06:38:17 +00:00
public final /* synthetic */ boolean $isAnimationRequested ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
2022-02-02 08:50:56 +00:00
public C0051a ( boolean z2 ) {
2021-11-02 06:38:17 +00:00
super ( 1 ) ;
this . $isAnimationRequested = z2 ;
}
public final void a ( AnimatorSet animatorSet ) {
m . checkNotNullParameter ( animatorSet , " animation " ) ;
animatorSet . start ( ) ;
if ( ! this . $isAnimationRequested ) {
animatorSet . end ( ) ;
}
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke ( AnimatorSet animatorSet ) {
a ( animatorSet ) ;
return Unit . a ;
}
}
/* JADX WARNING: Illegal instructions before constructor call */
public a ( h hVar , c cVar ) {
super ( r4 ) ;
m . checkNotNullParameter ( cVar , " binding " ) ;
2021-12-02 18:53:44 +00:00
this . t = hVar ;
2021-11-02 06:38:17 +00:00
FrameLayout frameLayout = cVar . a ;
m . checkNotNullExpressionValue ( frameLayout , " binding.root " ) ;
2022-01-27 07:52:47 +00:00
this . f317s = cVar ;
2021-11-02 06:38:17 +00:00
cVar . a . setOnClickListener ( this ) ;
FrameLayout frameLayout2 = cVar . a ;
m . checkNotNullExpressionValue ( frameLayout2 , " binding.root " ) ;
Animator loadAnimator = AnimatorInflater . loadAnimator ( frameLayout2 . getContext ( ) , R . a . selection_shrink ) ;
Objects . requireNonNull ( loadAnimator , " null cannot be cast to non-null type android.animation.AnimatorSet " ) ;
AnimatorSet animatorSet = ( AnimatorSet ) loadAnimator ;
2021-12-02 18:53:44 +00:00
this . q = animatorSet ;
2022-01-27 07:52:47 +00:00
animatorSet . setTarget ( cVar . f321b ) ;
2021-11-02 06:38:17 +00:00
FrameLayout frameLayout3 = cVar . a ;
m . checkNotNullExpressionValue ( frameLayout3 , " binding.root " ) ;
Animator loadAnimator2 = AnimatorInflater . loadAnimator ( frameLayout3 . getContext ( ) , R . a . selection_grow ) ;
Objects . requireNonNull ( loadAnimator2 , " null cannot be cast to non-null type android.animation.AnimatorSet " ) ;
AnimatorSet animatorSet2 = ( AnimatorSet ) loadAnimator2 ;
2021-12-02 18:53:44 +00:00
this . r = animatorSet2 ;
2022-01-27 07:52:47 +00:00
animatorSet2 . setTarget ( cVar . f321b ) ;
2021-11-02 06:38:17 +00:00
}
2021-12-17 21:59:34 +00:00
@Override // b.b.a.d.i
2021-11-02 06:38:17 +00:00
public SimpleDraweeView a ( ) {
2022-01-27 07:52:47 +00:00
SimpleDraweeView simpleDraweeView = this . f317s . c ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.contentIv " ) ;
return simpleDraweeView ;
}
public final void d ( boolean z2 , boolean z3 ) {
2022-01-27 07:52:47 +00:00
FrameLayout frameLayout = this . f317s . a ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( frameLayout , " binding.root " ) ;
frameLayout . setSelected ( z2 ) ;
2022-02-02 08:50:56 +00:00
C0051a aVar = new C0051a ( z3 ) ;
2021-11-02 06:38:17 +00:00
if ( z2 ) {
2022-01-27 07:52:47 +00:00
SimpleDraweeView simpleDraweeView = this . f317s . d ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.itemCheckIndicator " ) ;
simpleDraweeView . setVisibility ( 0 ) ;
2022-01-27 07:52:47 +00:00
FrameLayout frameLayout2 = this . f317s . f321b ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( frameLayout2 , " binding.contentContainer " ) ;
if ( frameLayout2 . getScaleX ( ) = = 1 . 0f ) {
2021-12-02 18:53:44 +00:00
aVar . a ( this . q ) ;
2021-11-02 06:38:17 +00:00
return ;
}
return ;
}
2022-01-27 07:52:47 +00:00
SimpleDraweeView simpleDraweeView2 = this . f317s . d ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView2 , " binding.itemCheckIndicator " ) ;
simpleDraweeView2 . setVisibility ( 8 ) ;
2022-01-27 07:52:47 +00:00
FrameLayout frameLayout3 = this . f317s . f321b ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( frameLayout3 , " binding.contentContainer " ) ;
if ( frameLayout3 . getScaleX ( ) ! = 1 . 0f ) {
2021-12-02 18:53:44 +00:00
aVar . a ( this . r ) ;
2021-11-02 06:38:17 +00:00
}
}
@Override // android.view.View.OnClickListener
public void onClick ( View view ) {
m . checkNotNullParameter ( view , " v " ) ;
2021-12-02 18:53:44 +00:00
SelectionCoordinator < ? , Media > selectionCoordinator = this . t . a ;
Media media = this . p ;
2021-11-02 06:38:17 +00:00
int adapterPosition = getAdapterPosition ( ) ;
Objects . requireNonNull ( selectionCoordinator ) ;
if ( media ! = null & & ! selectionCoordinator . d ( media ) ) {
selectionCoordinator . c ( media , adapterPosition ) ;
}
}
}
/* compiled from: MediaCursorAdapter.kt */
public static final class b extends AsyncQueryHandler {
public final /* synthetic */ h a ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public b ( h hVar , ContentResolver contentResolver ) {
super ( contentResolver ) ;
this . a = hVar ;
}
@Override // android.content.AsyncQueryHandler
public void onQueryComplete ( int i , Object obj , Cursor cursor ) {
m . checkNotNullParameter ( obj , " cookie " ) ;
if ( cursor ! = null ) {
h hVar = this . a ;
2021-12-17 21:59:34 +00:00
hVar . c = cursor . getColumnIndex ( " _id " ) ;
2021-11-02 06:38:17 +00:00
hVar . d = cursor . getColumnIndex ( " _data " ) ;
hVar . e = cursor . getColumnIndex ( " _display_name " ) ;
hVar . f = cursor . getColumnIndex ( " media_type " ) ;
if ( Build . VERSION . SDK_INT > = 29 ) {
hVar . g = Integer . valueOf ( cursor . getColumnIndex ( " duration " ) ) ;
}
2022-01-27 07:52:47 +00:00
hVar . f316b = cursor ;
2021-11-02 06:38:17 +00:00
this . a . notifyDataSetChanged ( ) ;
}
}
}
public h ( SelectionCoordinator < ? , Media > selectionCoordinator , int i , int i2 ) {
m . checkNotNullParameter ( selectionCoordinator , " selectionCoordinator " ) ;
this . h = i ;
this . i = i2 ;
Objects . requireNonNull ( selectionCoordinator ) ;
m . checkNotNullParameter ( this , " adapter " ) ;
selectionCoordinator . a = this ;
this . a = selectionCoordinator ;
setHasStableIds ( true ) ;
}
public final Media a ( int i ) {
String str ;
2022-01-27 07:52:47 +00:00
Cursor cursor = this . f316b ;
2021-11-02 06:38:17 +00:00
Media media = null ;
r1 = null ;
Long l = null ;
if ( cursor ! = null ) {
cursor . moveToPosition ( i ) ;
2021-12-17 21:59:34 +00:00
long j = cursor . getLong ( this . c ) ;
2021-11-02 06:38:17 +00:00
boolean z2 = cursor . getInt ( this . f ) = = 3 ;
Uri withAppendedPath = z2 ? Uri . withAppendedPath ( MediaStore . Video . Media . EXTERNAL_CONTENT_URI , String . valueOf ( j ) ) : Uri . withAppendedPath ( MediaStore . Images . Media . EXTERNAL_CONTENT_URI , String . valueOf ( j ) ) ;
String str2 = z2 ? " vid " : " img " ;
Integer num = this . g ;
if ( z2 & & num ! = null ) {
l = Long . valueOf ( cursor . getLong ( num . intValue ( ) ) ) ;
}
m . checkNotNullExpressionValue ( withAppendedPath , " fileUri " ) ;
String string = cursor . getString ( this . e ) ;
if ( string ! = null ) {
str = string ;
} else {
str = str2 + '-' + j ;
}
media = new Media ( j , withAppendedPath , str , cursor . getString ( this . d ) , z2 , l ) ;
}
return media ;
}
public final void b ( ContentResolver contentResolver ) {
m . checkNotNullParameter ( contentResolver , " contentResolver " ) ;
int i = Build . VERSION . SDK_INT ;
new b ( this , contentResolver ) . startQuery ( 1 , this , MediaStore . Files . getContentUri ( " external " ) , i > = 29 ? new String [ ] { " _id " , " _data " , " _display_name " , " media_type " , " duration " } : new String [ ] { " _id " , " _data " , " _display_name " , " media_type " } , i > = 29 ? " media_type = 1 OR media_type = 3 " : " media_type = 1 " , null , " date_added DESC " ) ;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount ( ) {
2022-01-27 07:52:47 +00:00
Cursor cursor = this . f316b ;
2021-11-02 06:38:17 +00:00
if ( cursor ! = null ) {
return cursor . getCount ( ) ;
}
return 0 ;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public long getItemId ( int i ) {
Media a2 = a ( i ) ;
if ( a2 ! = null ) {
return a2 . getId ( ) ;
}
return - 1 ;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onAttachedToRecyclerView ( RecyclerView recyclerView ) {
m . checkNotNullParameter ( recyclerView , " recyclerView " ) ;
super . onAttachedToRecyclerView ( recyclerView ) ;
Context context = recyclerView . getContext ( ) ;
m . checkNotNullExpressionValue ( context , " recyclerView.context " ) ;
ContentResolver contentResolver = context . getContentResolver ( ) ;
m . checkNotNullExpressionValue ( contentResolver , " recyclerView.context.contentResolver " ) ;
b ( contentResolver ) ;
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$ViewHolder, int] */
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onBindViewHolder ( a aVar , int i ) {
Long l ;
a aVar2 = aVar ;
m . checkNotNullParameter ( aVar2 , " holder " ) ;
Media a2 = a ( i ) ;
2021-12-02 18:53:44 +00:00
aVar2 . p = a2 ;
2022-01-27 07:52:47 +00:00
FrameLayout frameLayout = aVar2 . f317s . a ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( frameLayout , " binding.root " ) ;
Context context = frameLayout . getContext ( ) ;
int i2 = 0 ;
if ( a2 ! = null ) {
2021-12-02 18:53:44 +00:00
aVar2 . d ( aVar2 . t . a . a ( a2 , aVar2 . getAdapterPosition ( ) ) , false ) ;
2021-11-02 06:38:17 +00:00
}
2021-12-02 18:53:44 +00:00
aVar2 . c ( a2 , Integer . valueOf ( aVar2 . t . h ) , Integer . valueOf ( aVar2 . t . i ) ) ;
2021-11-02 06:38:17 +00:00
boolean z2 = true ;
2021-12-02 18:53:44 +00:00
if ( a2 = = null | | ! a2 . j ) {
2021-11-02 06:38:17 +00:00
z2 = false ;
}
2022-01-27 07:52:47 +00:00
TextView textView = aVar2 . f317s . e ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( textView , " binding.itemVideoIndicator " ) ;
if ( ! z2 ) {
i2 = 8 ;
}
textView . setVisibility ( i2 ) ;
if ( z2 ) {
2022-01-27 07:52:47 +00:00
TextView textView2 = aVar2 . f317s . e ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( textView2 , " binding.itemVideoIndicator " ) ;
Drawable background = textView2 . getBackground ( ) ;
m . checkNotNullExpressionValue ( background , " binding.itemVideoIndicator.background " ) ;
background . setAlpha ( 127 ) ;
2021-12-02 18:53:44 +00:00
long longValue = ( a2 = = null | | ( l = a2 . k ) = = null ) ? 0 : l . longValue ( ) ;
2022-01-27 07:52:47 +00:00
TextView textView3 = aVar2 . f317s . e ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( textView3 , " binding.itemVideoIndicator " ) ;
textView3 . setText ( longValue > 0 ? TimeUtils . toFriendlyStringSimple$default ( TimeUtils . INSTANCE , longValue , null , null , 6 , null ) : context . getString ( R . h . video ) ) ;
}
2022-01-27 07:52:47 +00:00
SimpleDraweeView simpleDraweeView = aVar2 . f317s . c ;
2021-11-02 06:38:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.contentIv " ) ;
simpleDraweeView . setContentDescription ( context . getString ( z2 ? R . h . video : R . h . image ) ) ;
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$ViewHolder, int, java.util.List] */
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onBindViewHolder ( a aVar , int i , List list ) {
SelectionCoordinator . a aVar2 ;
Object obj ;
a aVar3 = aVar ;
m . checkNotNullParameter ( aVar3 , " holder " ) ;
m . checkNotNullParameter ( list , " payloads " ) ;
Iterator it = list . iterator ( ) ;
while ( true ) {
aVar2 = null ;
if ( ! it . hasNext ( ) ) {
obj = null ;
break ;
}
obj = it . next ( ) ;
if ( obj instanceof SelectionCoordinator . a ) {
break ;
}
}
if ( obj ! = null ) {
if ( obj instanceof SelectionCoordinator . a ) {
aVar2 = obj ;
}
SelectionCoordinator . a aVar4 = aVar2 ;
if ( aVar4 ! = null ) {
2022-02-01 08:01:17 +00:00
aVar3 . d ( aVar4 . f3144b , true ) ;
2021-11-02 06:38:17 +00:00
return ;
}
}
super . onBindViewHolder ( aVar3 , i , list ) ;
}
/* Return type fixed from 'androidx.recyclerview.widget.RecyclerView$ViewHolder' to match base method */
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public a onCreateViewHolder ( ViewGroup viewGroup , int i ) {
m . checkNotNullParameter ( viewGroup , " parent " ) ;
View inflate = LayoutInflater . from ( viewGroup . getContext ( ) ) . inflate ( R . g . view_grid_image , viewGroup , false ) ;
int i2 = R . f . content_container ;
FrameLayout frameLayout = ( FrameLayout ) inflate . findViewById ( i2 ) ;
if ( frameLayout ! = null ) {
i2 = R . f . content_iv ;
SimpleDraweeView simpleDraweeView = ( SimpleDraweeView ) inflate . findViewById ( i2 ) ;
if ( simpleDraweeView ! = null ) {
i2 = R . f . item_check_indicator ;
SimpleDraweeView simpleDraweeView2 = ( SimpleDraweeView ) inflate . findViewById ( i2 ) ;
if ( simpleDraweeView2 ! = null ) {
i2 = R . f . item_video_indicator ;
TextView textView = ( TextView ) inflate . findViewById ( i2 ) ;
if ( textView ! = null ) {
c cVar = new c ( ( FrameLayout ) inflate , frameLayout , simpleDraweeView , simpleDraweeView2 , textView ) ;
m . checkNotNullExpressionValue ( cVar , " ViewGridImageBinding.inf….context), parent, false) " ) ;
return new a ( this , cVar ) ;
}
}
}
}
throw new NullPointerException ( " Missing required view with ID: " . concat ( inflate . getResources ( ) . getResourceName ( i2 ) ) ) ;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onDetachedFromRecyclerView ( RecyclerView recyclerView ) {
m . checkNotNullParameter ( recyclerView , " recyclerView " ) ;
2022-01-27 07:52:47 +00:00
Cursor cursor = this . f316b ;
2021-11-02 06:38:17 +00:00
if ( cursor ! = null ) {
cursor . close ( ) ;
}
super . onDetachedFromRecyclerView ( recyclerView ) ;
2021-07-24 02:37:17 +00:00
}
2021-11-02 06:38:17 +00:00
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$ViewHolder] */
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onViewRecycled ( a aVar ) {
a aVar2 = aVar ;
m . checkNotNullParameter ( aVar2 , " holder " ) ;
super . onViewRecycled ( aVar2 ) ;
aVar2 . b ( ) ;
2021-07-24 02:37:17 +00:00
}
}