Skip to content

Commit

Permalink
Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-budiyev committed May 3, 2022
1 parent 1537b9e commit 50ed236
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {

dependencies {

classpath 'com.android.tools.build:gradle:7.1.1'
classpath 'com.android.tools.build:gradle:7.1.3'
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
27 changes: 18 additions & 9 deletions src/main/java/com/budiyev/android/imageloader/ImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,25 @@ public final class ImageLoader {
@NonNull
@SuppressWarnings("unchecked")
public <T> ImageRequest<T> from(@NonNull final T data) {
final String dataClassName = data.getClass().getName();
final DataDescriptorFactory<T> descriptorFactory =
(DataDescriptorFactory<T>) mDescriptorFactories.get(dataClassName);
final BitmapLoader<T> bitmapLoader = (BitmapLoader<T>) mBitmapLoaders.get(dataClassName);
if (descriptorFactory == null || bitmapLoader == null) {
throw new IllegalArgumentException("Unsupported data type: " + dataClassName);
Class<?> dataClass = data.getClass();
for (; ; ) {
final String dataClassName = dataClass.getName();
final DataDescriptorFactory<T> descriptorFactory =
(DataDescriptorFactory<T>) mDescriptorFactories.get(dataClassName);
final BitmapLoader<T> bitmapLoader =
(BitmapLoader<T>) mBitmapLoaders.get(dataClassName);
if (descriptorFactory == null || bitmapLoader == null) {
dataClass = dataClass.getSuperclass();
if (dataClass == null) {
throw new IllegalArgumentException(
"Unsupported data type: " + data.getClass().getName());
}
continue;
}
return new ImageRequest<>(mContext.getResources(), mLoadExecutor, mCacheExecutor,
mPauseLock, mMainThreadHandler, mMemoryCache, mStorageCache, bitmapLoader,
descriptorFactory.newDescriptor(data));
}
return new ImageRequest<>(mContext.getResources(), mLoadExecutor, mCacheExecutor,
mPauseLock, mMainThreadHandler, mMemoryCache, mStorageCache, bitmapLoader,
descriptorFactory.newDescriptor(data));
}

/**
Expand Down

0 comments on commit 50ed236

Please sign in to comment.