-
Notifications
You must be signed in to change notification settings - Fork 60
Download module #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download module #114
Conversation
imageViewRef = new WeakReference<>(imageView); | ||
} | ||
|
||
synchronized void setUrl(String url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather avoid a synchronized method calling a synchronized method. Even though it works, it's a bit confusing and not as readable.
Add a private not-synchronizedd doStart()
methods that directly starts the download - then both public methods (start
and setUrl()
) can call it if the conditions are right. Makes sense?
ImageRequest imageRequest = imageRequestBuilder.build(); | ||
GenericDraweeHierarchy genericDraweeHierarchy = genericDraweeHierarchyBuilder.build(); | ||
|
||
DraweeView draweeView = (DraweeView) imageView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of failing on a cast here, please throw an IllegalArgumentException
(at the beginning of the method) if the image view is not a DraweeView
progressBar.setVisibility(View.GONE); | ||
} | ||
}); | ||
currentUrl = url.generate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a TODO here to put back the progress bar visibility code once we implement callbacks in the strategy.
download/build.gradle
Outdated
compileOnly 'com.squareup.picasso:picasso:2.71828' | ||
compileOnly 'com.facebook.fresco:fresco:2.2.0' | ||
compileOnly 'com.github.bumptech.glide:glide:4.11.0' | ||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed here? The glide integration is a separate module and I didn't spot a usage of extensions in this PR.
public static void setup() { | ||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
MediaManager.init(context); | ||
MediaManager.get().getCloudinary().config.cloudName = TEST_CLOUD_NAME; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cloud info should be injected from the environment instead of hard coded constants.
You can see the full workflow in the core tests. The test manifest has a template place holder and the build process replaces it with with the env variable.
https://github.com/cloudinary/cloudinary_android/blob/master/core/src/androidTest/AndroidManifest.xml and
https://github.com/cloudinary/cloudinary_android/blob/master/core/build.gradle (the manifestPlaceholders
line).
Let me know if you need assistance with that.
} | ||
} else if (source instanceof Integer) { | ||
downloadRequestBuilderStrategy.load((Integer) source); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please separate into two exceptions - illegal argument exception in case the source is not a string/int either, and an illegal state exception if it's explicitly null.
It's true that currently, your check is 100% accurate (since we only allow to send in a string or an int), but this may change in a future commit and we can easily miss this check and cause unexpected error messages.
No description provided.