2021-08-09 22:50:52 +00:00
package com.discord.utilities.images ;
import android.graphics.Bitmap ;
import android.net.Uri ;
import androidx.core.app.NotificationCompat ;
import c.f.j.e.h ;
import c.f.j.e.l ;
import com.airbnb.lottie.parser.AnimatableValueParser ;
import com.facebook.imagepipeline.request.ImageRequest ;
import com.facebook.imagepipeline.request.ImageRequestBuilder ;
import d0.g0.t ;
import d0.z.d.g0.a ;
import d0.z.d.m ;
import j0.l.a.q ;
import java.io.Closeable ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.Map ;
import java.util.Set ;
import java.util.function.BiFunction ;
import java.util.function.Function ;
import rx.Observable ;
/* compiled from: MGImagesBitmap.kt */
public final class MGImagesBitmap {
public static final MGImagesBitmap INSTANCE = new MGImagesBitmap ( ) ;
/* compiled from: MGImagesBitmap.kt */
public static final class CloseableBitmaps implements Map < String , Bitmap > , Closeable , a {
private final Map < String , Bitmap > underlyingMap ;
public CloseableBitmaps ( Map < String , Bitmap > map ) {
m . checkNotNullParameter ( map , " underlyingMap " ) ;
this . underlyingMap = map ;
}
@Override // java.util.Map
public void clear ( ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close ( ) {
for ( Map . Entry < String , Bitmap > entry : this . underlyingMap . entrySet ( ) ) {
entry . getValue ( ) . recycle ( ) ;
}
}
public Bitmap compute ( String str , BiFunction < ? super String , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.util.function.BiFunction] */
@Override // java.util.Map
public /* synthetic */ Bitmap compute ( String str , BiFunction < ? super String , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
public Bitmap computeIfAbsent ( String str , Function < ? super String , ? extends Bitmap > function ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.util.function.Function] */
@Override // java.util.Map
public /* synthetic */ Bitmap computeIfAbsent ( String str , Function < ? super String , ? extends Bitmap > function ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
public Bitmap computeIfPresent ( String str , BiFunction < ? super String , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.util.function.BiFunction] */
@Override // java.util.Map
public /* synthetic */ Bitmap computeIfPresent ( String str , BiFunction < ? super String , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
@Override // java.util.Map
public final /* bridge */ boolean containsKey ( Object obj ) {
if ( obj instanceof String ) {
return containsKey ( ( String ) obj ) ;
}
return false ;
}
public boolean containsKey ( String str ) {
m . checkNotNullParameter ( str , " key " ) ;
return this . underlyingMap . containsKey ( str ) ;
}
public boolean containsValue ( Bitmap bitmap ) {
m . checkNotNullParameter ( bitmap , " value " ) ;
return this . underlyingMap . containsValue ( bitmap ) ;
}
@Override // java.util.Map
public final /* bridge */ boolean containsValue ( Object obj ) {
if ( obj instanceof Bitmap ) {
return containsValue ( ( Bitmap ) obj ) ;
}
return false ;
}
@Override // java.util.Map
public final /* bridge */ Set < Map . Entry < String , Bitmap > > entrySet ( ) {
return getEntries ( ) ;
}
public Bitmap get ( String str ) {
m . checkNotNullParameter ( str , " key " ) ;
return this . underlyingMap . get ( str ) ;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // java.util.Map
public final /* bridge */ Bitmap get ( Object obj ) {
if ( obj instanceof String ) {
return get ( ( String ) obj ) ;
}
return null ;
}
public Set < Map . Entry < String , Bitmap > > getEntries ( ) {
return this . underlyingMap . entrySet ( ) ;
}
public Set < String > getKeys ( ) {
return this . underlyingMap . keySet ( ) ;
}
public int getSize ( ) {
return this . underlyingMap . size ( ) ;
}
public Collection < Bitmap > getValues ( ) {
return this . underlyingMap . values ( ) ;
}
@Override // java.util.Map
public boolean isEmpty ( ) {
return this . underlyingMap . isEmpty ( ) ;
}
@Override // java.util.Map
public final /* bridge */ Set < String > keySet ( ) {
return getKeys ( ) ;
}
public Bitmap merge ( String str , Bitmap bitmap , BiFunction < ? super Bitmap , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.lang.Object, java.util.function.BiFunction] */
@Override // java.util.Map
public /* synthetic */ Bitmap merge ( String str , Bitmap bitmap , BiFunction < ? super Bitmap , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
public Bitmap put ( String str , Bitmap bitmap ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.lang.Object] */
@Override // java.util.Map
public /* synthetic */ Bitmap put ( String str , Bitmap bitmap ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
@Override // java.util.Map
public void putAll ( Map < ? extends String , ? extends Bitmap > map ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
public Bitmap putIfAbsent ( String str , Bitmap bitmap ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.lang.Object] */
@Override // java.util.Map
public /* synthetic */ Bitmap putIfAbsent ( String str , Bitmap bitmap ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // java.util.Map
public Bitmap remove ( Object obj ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
@Override // java.util.Map
public boolean remove ( Object obj , Object obj2 ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
public Bitmap replace ( String str , Bitmap bitmap ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* 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, java.lang.Object] */
@Override // java.util.Map
public /* synthetic */ Bitmap replace ( String str , Bitmap bitmap ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object, java.lang.Object] */
@Override // java.util.Map
public /* synthetic */ boolean replace ( String str , Bitmap bitmap , Bitmap bitmap2 ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
public boolean replace ( String str , Bitmap bitmap , Bitmap bitmap2 ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
@Override // java.util.Map
public void replaceAll ( BiFunction < ? super String , ? super Bitmap , ? extends Bitmap > biFunction ) {
throw new UnsupportedOperationException ( " Operation is not supported for read-only collection " ) ;
}
@Override // java.util.Map
public final /* bridge */ int size ( ) {
return getSize ( ) ;
}
@Override // java.util.Map
public final /* bridge */ Collection < Bitmap > values ( ) {
return getValues ( ) ;
}
}
/* compiled from: MGImagesBitmap.kt */
public static final class DecodeException extends Exception {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public DecodeException ( String str ) {
super ( " Unable to decode image: " + str + '.' ) ;
m . checkNotNullParameter ( str , " imageUri " ) ;
}
}
/* compiled from: MGImagesBitmap.kt */
public static final class ImageNotFoundException extends Exception {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ImageNotFoundException ( String str ) {
super ( " 404 image not found: " + str ) ;
m . checkNotNullParameter ( str , " imageUri " ) ;
}
}
/* compiled from: MGImagesBitmap.kt */
public static final class ImageRequest {
private final String imageUri ;
private final boolean roundAsCircle ;
public ImageRequest ( String str , boolean z2 ) {
m . checkNotNullParameter ( str , " imageUri " ) ;
this . imageUri = str ;
this . roundAsCircle = z2 ;
}
public static /* synthetic */ ImageRequest copy$default ( ImageRequest imageRequest , String str , boolean z2 , int i , Object obj ) {
if ( ( i & 1 ) ! = 0 ) {
str = imageRequest . imageUri ;
}
if ( ( i & 2 ) ! = 0 ) {
z2 = imageRequest . roundAsCircle ;
}
return imageRequest . copy ( str , z2 ) ;
}
public final String component1 ( ) {
return this . imageUri ;
}
public final boolean component2 ( ) {
return this . roundAsCircle ;
}
public final ImageRequest copy ( String str , boolean z2 ) {
m . checkNotNullParameter ( str , " imageUri " ) ;
return new ImageRequest ( str , z2 ) ;
}
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof ImageRequest ) ) {
return false ;
}
ImageRequest imageRequest = ( ImageRequest ) obj ;
return m . areEqual ( this . imageUri , imageRequest . imageUri ) & & this . roundAsCircle = = imageRequest . roundAsCircle ;
}
public final String getImageUri ( ) {
return this . imageUri ;
}
public final boolean getRoundAsCircle ( ) {
return this . roundAsCircle ;
}
public int hashCode ( ) {
String str = this . imageUri ;
int hashCode = ( str ! = null ? str . hashCode ( ) : 0 ) * 31 ;
boolean z2 = this . roundAsCircle ;
if ( z2 ) {
z2 = true ;
}
int i = z2 ? 1 : 0 ;
int i2 = z2 ? 1 : 0 ;
int i3 = z2 ? 1 : 0 ;
return hashCode + i ;
}
public String toString ( ) {
2021-08-18 07:29:27 +00:00
StringBuilder L = c . d . b . a . a . L ( " ImageRequest(imageUri= " ) ;
L . append ( this . imageUri ) ;
L . append ( " , roundAsCircle= " ) ;
return c . d . b . a . a . G ( L , this . roundAsCircle , " ) " ) ;
2021-08-09 22:50:52 +00:00
}
}
/* compiled from: MGImagesBitmap.kt */
public static final class MissingBitmapException extends Exception {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public MissingBitmapException ( String str ) {
super ( " Unable to decode image as bitmap: " + str ) ;
m . checkNotNullParameter ( str , " imageUri " ) ;
}
}
private MGImagesBitmap ( ) {
}
public static final Observable < CloseableBitmaps > getBitmaps ( Set < ImageRequest > set ) {
m . checkNotNullParameter ( set , " imageRequests " ) ;
ArrayList arrayList = new ArrayList ( ) ;
for ( Object obj : set ) {
if ( ! t . isBlank ( ( ( ImageRequest ) obj ) . getImageUri ( ) ) ) {
arrayList . add ( obj ) ;
}
}
Observable < CloseableBitmaps > X = Observable . h0 ( new q ( arrayList ) ) . z ( MGImagesBitmap$getBitmaps$1 . INSTANCE ) . g0 ( MGImagesBitmap$getBitmaps$2 . INSTANCE , MGImagesBitmap$getBitmaps$3 . INSTANCE ) . F ( MGImagesBitmap$getBitmaps$4 . INSTANCE ) . X ( j0 . p . a . a ( ) ) ;
m . checkNotNullExpressionValue ( X , " Observable \ n .from…Schedulers.computation()) " ) ;
return X ;
}
private final boolean isValidUri ( String str ) {
Uri parse = Uri . parse ( str ) ;
m . checkNotNullExpressionValue ( parse , NotificationCompat . MessagingStyle . Message . KEY_DATA_URI ) ;
String scheme = parse . getScheme ( ) ;
if ( scheme = = null | | t . isBlank ( scheme ) ) {
return false ;
}
String host = parse . getHost ( ) ;
if ( host = = null | | t . isBlank ( host ) ) {
return false ;
}
String path = parse . getPath ( ) ;
return ! ( path = = null | | t . isBlank ( path ) ) ;
}
public final Observable < Bitmap > getBitmap ( String str , boolean z2 ) {
m . checkNotNullParameter ( str , " imageUri " ) ;
if ( ! isValidUri ( str ) ) {
Observable < Bitmap > w = Observable . w ( new IllegalArgumentException ( " invalid uri " ) ) ;
m . checkNotNullExpressionValue ( w , " Observable.error(Illegal…Exception( \" invalid uri \" )) " ) ;
return w ;
}
l lVar = l . a ;
AnimatableValueParser . y ( lVar , " ImagePipelineFactory was not initialized! " ) ;
if ( lVar . l = = null ) {
lVar . l = lVar . a ( ) ;
}
h hVar = lVar . l ;
ImageRequestBuilder imageRequest = MGImages . getImageRequest ( str , 0 , 0 , false ) ;
if ( z2 ) {
imageRequest . j = new RoundAsCirclePostprocessor ( str ) ;
}
Observable < Bitmap > h02 = Observable . h0 ( new MGImagesBitmap$getBitmap$1 ( hVar . a ( imageRequest . a ( ) , null , ImageRequest . c . FULL_FETCH , null , null ) , str ) ) ;
m . checkNotNullExpressionValue ( h02 , " Observable.unsafeCreate …y emits the bitmap. \ n } " ) ;
return h02 ;
}
}