Android developer options have great support when it comes to understanding the animations in app.
Please take a look below video and set animation scale to 5x
Now lets come to the point and see how toolbar title animates.
As you must have seen in the above video , the toolbar title animates and its a subtle but pretty nice and easy on eyes , soothing animation.
Now lets see what are observations before we look at implementation to see how one would go about implementing this.
Observations:
Initially the title was not visibile - [ Alpha must be zero ]
Animation starts after some delay - [ There must be a start delay ]
See the letter spacing effect - [ At present not sure - how its achieved ]
It appears to scale horizontally but not from zero - [ There must be some initial value scaleX ]
Animation starts fast and slows as the time progresses - [ Must be some kind of Interpolator at play ]
Lets look at implementation from the Plaid App.
There is an aptly named animateToolbar() method in the HomeActivity.java.
privatevoidanimateToolbar(){// this is gross but toolbar doesn't expose it's children to animate them :(Viewt=toolbar.getChildAt(0);if(t!=null&&tinstanceofTextView){TextViewtitle=(TextView)t;// fade in and space out the title. Animating the letterSpacing performs horribly so// fake it by setting the desired letterSpacing then animating the scaleX ¯\_(ツ)_/¯title.setAlpha(0f);title.setScaleX(0.8f);title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900).setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this));}}
Again these are the kind of animations that make our apps a treat to use for consumers.
One last point before we end this post. This animation is called only when we are launching this activity a fresh for the first time. This is again an important detail so that we don't overdo the animation.
if(savedInstanceState==null){animateToolbar();}
Thats it for this post and there will be more post in this series. So please look forward to it and do let me know in the comments if you like the content.
These methods store the files in primary storage (internal SD card) which is protected
This cannot be seen on an unrooted device when USB is connected.
Files stored here are automatically removed when app is uninstalled.
App doesn't require any specific permissions to read / write from this location.
Context.getExternalFilesDir()
Context.getExternalCacheDir()
These methods store the files in primary storage (internal SD card) which is un-protected
This can be seen on an unrooted device when USB is connected.
Files stored here are automatically removed when app is uninstalled.
App doesn't require any specific permissions to read / write from this location.
The
main call to onSizeChanged() is done after the construction of your view but
before the drawing. At this time the system will calculate the size of your
view and notify you by calling onSizeChanged()
CalculateTextPosition
: finds out the x,y co-ordinates within view so that the text is centered.
createBitmap :
creates a canvas -> draws over it using the textPaint.
But while doing that
it just punches a hole on the canvas using the Portar Duff
// this is the magic
– Clear mode punches out the bitmap
ViewPager associates
each page with a key Object instead of working with Views directly. This key is
used to track and uniquely identify a given page independent of its position in
the adapter
A very simple
PagerAdapter may choose to use the page Views themselves as key objects,
returning them from instantiateItem(ViewGroup,
int) after creation and adding them to the parent ViewGroup. A matching destroyItem(ViewGroup,
int, Object) implementation would remove the View from the parent ViewGroup
and isViewFromObject(View,
Object) could be implemented as return view == object;.
You will also find a
LibraryAdapter which is just a simple recyclerview adapter for recyclerview on
the third page which shows popular android opensource libraries.
Since we are doing
the Architecture explanation here , we will not go into details of how the elastic
effect is achieved and how awesomely that InkPageIndicator is implemented.
That info is for the
Learnings from Plaid series which will definitely cover in that series :-) till
that time just appreciate the effect.
Today we are going to look at how Plaid app communicates with Dribble API and that its the same mechanism with which it communicates with Designer News and Producthunt APIs. but for the purpose of this blog we are going to look at only the Dribble APIs.
This is the tree that we will discuss today.
Data->api
Designernews
Dribble
Producthunt
If you open the
navigation drawer and click on
Dribble following
My Dribble Shots
My Dribble likes
You will be asked
for a login into Dribble.
Plaid app uses Retrofit to for the communication with
Dribble API , why ? Just because its
awesome , you will see how in this post. Retrofit is popular
library among all android developers for communicating with Rest APIs and its
from SQUARE.
for Dribblelogin
activity , in AndroidManifest.xml, we haveandroid:launchmode = "SingleTop" ,
Once we are
redirected back to the activity after authentication , we use the same activity
instance and redeliver the intent to same activity.
This time onNewIntent() is invoked and since we will receive the access token as part of this intent we fetch the accesstoken. Then we authenticate with Dribble auth endpoint using the client ID / SECRET and the access token that we received. Once the authentication is successful , the logged in user is displayed.