Reputation: 4281
Suppose I developed an android library XYZ which has methods
animateWithTransition() which has code related with Transition api(i.e. minsdk=21)
animateSimply() which has simple animation.
When Client uses XYZ library, he should be able to see animateWithTransition() as a suggestion(ctrl+space) if his minsdk < 21. and should be able to see only animateSimply() : |
How to go about this?
Upvotes: 3
Views: 78
Reputation: 1314
You should try structuring your code in the following manner -
public void performAnimation() {
if(Build.VERSION.SDK_INT < 21 )
{
// write code for animateSimply function here
}
else
{
// write code for animateWithTransition function here
}
}
That ways, you'll have a single function (which means less code, clean code), and easier testing. Plus your client has to call only 1 function, which makes it easier for him/her to use your library.
Upvotes: 2