Log.v(“ThreeTips”, “#8”)
1- Spinner Datepicker is not working on Android 7.0
I faced with a weird problem with date picker on android 7.0. After some research, I came across this issue on Android Issue Tracker. Yes it is fixed on 7.1 update but my nougat users still see weird picker. I found a workaround fixes this problem.
Previously (Does not show spinner datepicker on Nougat)
DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), AlertDialog.THEME_HOLO_LIGHT, this, year, month - 1, day);
Then add gist class to my project and changed my initialization (Works on Nougat)
Context themedContext = new ContextThemeWrapper(this.getContext(), android.R.style.Theme_Holo_Light_Dialog);DatePickerDialog datePickerDialog = new FixedHoloDatePickerDialog(themedContext, this, year, month - 1, day);
2- Multiple Serialized Value! No more custom TypeAdapter needed!
I ran into a strange problem the other day. We had to add another endpoint to our project for another implementation. But some of my models were common for both services. Than I saw this SO answer.
Gson version 2.4 added the ability to use alternate/multiple names for
@SerializedName
when deserializing.
So this is the scenario that you need to use alternate
1- You have Person class which is used in both services.
2- Different person name key (“name” for one service, “username” for otherone)
Here is the annotation that you can use to cover both service.
@SerializedName(value="name", alternate={"username"})
String userName;
You can also add more alternate values like ;
@SerializedName(value="name", alternate={"username", "user_name})
String userName;
But in my opinion, all of you services should have same naming convention. You can ask you backend developer if it is possible.
3- Reducing the size of App Updates by 65%
I know this is not a tip for you but I wanted you to know that google play update. They just published on android blogspot. When user wants to update app, of course there is an algorithm behind that process that calculate differences between update and installed app. Google Play were using bsdiff algorithm to update installed app. Actually bsdiff algorithm was pretty good. Update reduces size of apk by %47. But now, they switch to File by File Patching. Actually I am suprised when I saw percentage. Update reduces size of apk by %65. This is perfect for saving user data. And this is what they said;
The savings, compared to our previous approach, add up to 6 petabytes of user data saved per day!
Here is more detail about algorithms and blogpost.
Click recommend button if you follow my series.