johncarl81 / transfuse

:syringe: Transfuse - A Dependency Injection and Integration framework for Google Android
http://androidtransfuse.org/
Apache License 2.0
220 stars 28 forks source link

add suppress for deprecation warnings #187

Closed dbachelder closed 9 years ago

johncarl81 commented 9 years ago

Is transfuse using depreciated methods on the Android api?

dbachelder commented 9 years ago

for injected drawable resources

http://developer.android.com/reference/android/content/res/Resources.html#getDrawable(int)

johncarl81 commented 9 years ago

Ah, maybe we should move to Context.getDrawable() instead.

dbachelder commented 9 years ago

that was added in api 21

johncarl81 commented 9 years ago

Shoot, you're correct. I wonder if we could annotate the invocation directly:

@SuppressWarnings("depreciated")
resources.getDrawable(1234);

That way if anything else is depreciated we would know about it. Supressing all depreciated warnings feels a little heavy handed to me.

dbachelder commented 9 years ago

unfortunately annotations aren't allowed in method bodies

johncarl81 commented 9 years ago

SuppressWarnings is, at least for local variables:

@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
public @interface SuppressWarnings {

LOCAL_VARIABLE

dbachelder commented 9 years ago

That is for the variable declaration. This would only be useful if we created a temporary variable to assign the resource to then assigned that to the property on the component delegate.

johncarl81 commented 9 years ago

Ah, you're right... hmm, with some of the newer rules I feel like we're supporting a specific version of Android anyways. Are you not compiling against version > 21?

dbachelder commented 9 years ago

We are compiling against 23. What do you think makes it specific? those new annotations I added are optional...

johncarl81 commented 9 years ago

I'm sorry, I think I was a little quick to answer and too short. Im thinking that we fix this issue instead of masking it with suppressing the depreciation warning. It would be fairly easy to migrate to use Context.getDrawable() instead. Would this work for you or is there some other issue I'm not seeing?

dbachelder commented 9 years ago

That won't work for people not targeting >= 21.. how about using ContextCompat?

http://developer.android.com/reference/android/support/v4/content/ContextCompat.html