2021-07-24 02:37:17 +00:00
package c.b.a.d ;
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 ;
import c.b.a.e.c ;
2021-10-15 06:18:26 +00:00
import c0.z.d.m ;
import c0.z.d.o ;
2021-07-24 02:37: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 java.util.Iterator ;
import java.util.List ;
import java.util.Objects ;
import kotlin.Unit ;
import kotlin.jvm.functions.Function1 ;
/* compiled from: MediaCursorAdapter.kt */
public final class i extends RecyclerView . Adapter < a > {
public final SelectionCoordinator < ? , Media > a ;
public Cursor b ;
/* renamed from: c reason: collision with root package name */
2021-10-20 06:51:20 +00:00
public int f257c ;
2021-07-24 02:37: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 j implements View . OnClickListener {
public Media o ;
public final AnimatorSet p ;
public final AnimatorSet q ;
2021-10-15 06:18:26 +00:00
/* renamed from: r reason: collision with root package name */
2021-10-20 06:51:20 +00:00
public final c f258r ;
2021-10-15 06:18:26 +00:00
public final /* synthetic */ i s ;
2021-07-24 02:37:17 +00:00
/* compiled from: MediaCursorAdapter.kt */
/* renamed from: c.b.a.d.i$a$a reason: collision with other inner class name */
2021-10-20 06:51:20 +00:00
public static final class C0053a extends o implements Function1 < AnimatorSet , Unit > {
2021-07-24 02:37:17 +00:00
public final /* synthetic */ boolean $isAnimationRequested ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
2021-10-20 06:51:20 +00:00
public C0053a ( boolean z2 ) {
2021-07-24 02:37: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 ( i iVar , c cVar ) {
super ( r4 ) ;
m . checkNotNullParameter ( cVar , " binding " ) ;
2021-10-15 06:18:26 +00:00
this . s = iVar ;
2021-07-24 02:37:17 +00:00
FrameLayout frameLayout = cVar . a ;
m . checkNotNullExpressionValue ( frameLayout , " binding.root " ) ;
2021-10-20 06:51:20 +00:00
this . f258r = cVar ;
2021-07-24 02:37: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 ;
this . p = animatorSet ;
animatorSet . setTarget ( cVar . b ) ;
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 ;
this . q = animatorSet2 ;
animatorSet2 . setTarget ( cVar . b ) ;
}
@Override // c.b.a.d.j
public SimpleDraweeView a ( ) {
2021-10-20 06:51:20 +00:00
SimpleDraweeView simpleDraweeView = this . f258r . f261c ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.contentIv " ) ;
return simpleDraweeView ;
}
public final void d ( boolean z2 , boolean z3 ) {
2021-10-20 06:51:20 +00:00
FrameLayout frameLayout = this . f258r . a ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( frameLayout , " binding.root " ) ;
frameLayout . setSelected ( z2 ) ;
2021-10-20 06:51:20 +00:00
C0053a aVar = new C0053a ( z3 ) ;
2021-07-24 02:37:17 +00:00
if ( z2 ) {
2021-10-20 06:51:20 +00:00
SimpleDraweeView simpleDraweeView = this . f258r . d ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.itemCheckIndicator " ) ;
simpleDraweeView . setVisibility ( 0 ) ;
2021-10-20 06:51:20 +00:00
FrameLayout frameLayout2 = this . f258r . b ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( frameLayout2 , " binding.contentContainer " ) ;
if ( frameLayout2 . getScaleX ( ) = = 1 . 0f ) {
aVar . a ( this . p ) ;
return ;
}
return ;
}
2021-10-20 06:51:20 +00:00
SimpleDraweeView simpleDraweeView2 = this . f258r . d ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView2 , " binding.itemCheckIndicator " ) ;
simpleDraweeView2 . setVisibility ( 8 ) ;
2021-10-20 06:51:20 +00:00
FrameLayout frameLayout3 = this . f258r . b ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( frameLayout3 , " binding.contentContainer " ) ;
if ( frameLayout3 . getScaleX ( ) ! = 1 . 0f ) {
aVar . a ( this . q ) ;
}
}
@Override // android.view.View.OnClickListener
public void onClick ( View view ) {
m . checkNotNullParameter ( view , " v " ) ;
2021-10-15 06:18:26 +00:00
SelectionCoordinator < ? , Media > selectionCoordinator = this . s . a ;
2021-07-24 02:37:17 +00:00
Media media = this . o ;
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 */ i a ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public b ( i iVar , ContentResolver contentResolver ) {
super ( contentResolver ) ;
this . a = iVar ;
}
@Override // android.content.AsyncQueryHandler
public void onQueryComplete ( int i , Object obj , Cursor cursor ) {
m . checkNotNullParameter ( obj , " cookie " ) ;
if ( cursor ! = null ) {
i iVar = this . a ;
2021-10-20 06:51:20 +00:00
iVar . f257c = cursor . getColumnIndex ( " _id " ) ;
2021-07-24 02:37:17 +00:00
iVar . d = cursor . getColumnIndex ( " _data " ) ;
iVar . e = cursor . getColumnIndex ( " _display_name " ) ;
iVar . f = cursor . getColumnIndex ( " media_type " ) ;
if ( Build . VERSION . SDK_INT > = 29 ) {
iVar . g = Integer . valueOf ( cursor . getColumnIndex ( " duration " ) ) ;
}
iVar . b = cursor ;
this . a . notifyDataSetChanged ( ) ;
}
}
}
public i ( 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 ;
Cursor cursor = this . b ;
Media media = null ;
r1 = null ;
Long l = null ;
if ( cursor ! = null ) {
cursor . moveToPosition ( i ) ;
2021-10-20 06:51:20 +00:00
long j = cursor . getLong ( this . f257c ) ;
2021-07-24 02:37: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 ( ) {
Cursor cursor = this . b ;
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 ) ;
aVar2 . o = a2 ;
2021-10-20 06:51:20 +00:00
FrameLayout frameLayout = aVar2 . f258r . a ;
2021-07-27 00:35:07 +00:00
m . checkNotNullExpressionValue ( frameLayout , " binding.root " ) ;
Context context = frameLayout . getContext ( ) ;
2021-07-24 02:37:17 +00:00
int i2 = 0 ;
if ( a2 ! = null ) {
2021-10-15 06:18:26 +00:00
aVar2 . d ( aVar2 . s . a . a ( a2 , aVar2 . getAdapterPosition ( ) ) , false ) ;
2021-07-24 02:37:17 +00:00
}
2021-10-15 06:18:26 +00:00
aVar2 . c ( a2 , Integer . valueOf ( aVar2 . s . h ) , Integer . valueOf ( aVar2 . s . i ) ) ;
2021-07-24 02:37:17 +00:00
boolean z2 = true ;
if ( a2 = = null | | ! a2 . i ) {
z2 = false ;
}
2021-10-20 06:51:20 +00:00
TextView textView = aVar2 . f258r . e ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( textView , " binding.itemVideoIndicator " ) ;
if ( ! z2 ) {
i2 = 8 ;
}
textView . setVisibility ( i2 ) ;
if ( z2 ) {
2021-10-20 06:51:20 +00:00
TextView textView2 = aVar2 . f258r . e ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( textView2 , " binding.itemVideoIndicator " ) ;
Drawable background = textView2 . getBackground ( ) ;
m . checkNotNullExpressionValue ( background , " binding.itemVideoIndicator.background " ) ;
background . setAlpha ( 127 ) ;
long longValue = ( a2 = = null | | ( l = a2 . j ) = = null ) ? 0 : l . longValue ( ) ;
2021-10-20 06:51:20 +00:00
TextView textView3 = aVar2 . f258r . e ;
2021-07-24 02:37:17 +00:00
m . checkNotNullExpressionValue ( textView3 , " binding.itemVideoIndicator " ) ;
2021-07-27 00:35:07 +00:00
textView3 . setText ( longValue > 0 ? TimeUtils . toFriendlyStringSimple$default ( TimeUtils . INSTANCE , longValue , null , null , 6 , null ) : context . getString ( R . g . video ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-10-20 06:51:20 +00:00
SimpleDraweeView simpleDraweeView = aVar2 . f258r . f261c ;
2021-07-27 00:35:07 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.contentIv " ) ;
simpleDraweeView . setContentDescription ( context . getString ( z2 ? R . g . video : R . g . image ) ) ;
2021-07-24 02:37:17 +00:00
}
/* 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 ) {
aVar3 . d ( aVar4 . b , true ) ;
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 . f . view_grid_image , viewGroup , false ) ;
int i2 = R . e . content_container ;
FrameLayout frameLayout = ( FrameLayout ) inflate . findViewById ( i2 ) ;
if ( frameLayout ! = null ) {
i2 = R . e . content_iv ;
SimpleDraweeView simpleDraweeView = ( SimpleDraweeView ) inflate . findViewById ( i2 ) ;
if ( simpleDraweeView ! = null ) {
i2 = R . e . item_check_indicator ;
SimpleDraweeView simpleDraweeView2 = ( SimpleDraweeView ) inflate . findViewById ( i2 ) ;
if ( simpleDraweeView2 ! = null ) {
i2 = R . e . 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 " ) ;
Cursor cursor = this . b ;
if ( cursor ! = null ) {
cursor . close ( ) ;
}
super . onDetachedFromRecyclerView ( recyclerView ) ;
}
/* 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 ( ) ;
}
}