This column focuses on sharing the knowledge of large-scale Bat interview, and it will be updated continuously in the future. If you like it, please click a follow
Interviewer: What is audio and video, and why does video need to be compressed
Psychological analysis: many people’s concept of audio and video stays in the small film of Cang teacher, and can only understand him as a video file. The interviewer will ask if they have any concept of the format of the video file, the composition of the video file and the development of audio and video
** Job seeker :** You need to start with video file composition and work your way down to video coding
Data processing and view loading are separated
As we know, the data pulled from the remote end must be placed in the asynchronous, after we pull down the data may be hastily thrown to VH processing, in fact, we should also put the data processing logic in the asynchronous processing, so that the Adapter after notify change, The ViewHolder can simply do the data-view binding logic without pressure, for example:
mTextView.setText(Html.fromHtml(data).toString());
The html.fromhtml (data) method may be time-consuming, especially if there are multiple TextViews, resulting in frame drops and stalling. If this step is combined with the network asynchronous thread, the network refresh will take a little longer at most from the user’s perspective.
Data optimization
Pull remote data in pages to cache the pulled remote data to improve the secondary loading speed. For new or deleted data, DiffUtil refreshes data locally rather than globally.
Layout optimization
Reduced transition drawing
RecyclerView is not recommended for use with ConstraintLayout. Many developers have reported that using it is worse than using it in RecyclerView. Is ConstraintLayout that slow? , constraintLayout 1.1.1 not work well in listview.
Reduce the time of the XML file inflate
The XML file here includes not only layout XML but also drawable XML. The XML file inflate out of the ItemView through time-consuming IO operations, especially when Item reuse is low. As Type increases, The loss caused by this inflate is quite large, and you can generate the layout in code, new View() style, by knowing the API for the attributes of each node in the XML.
Reduce the creation of View objects
A slightly complex Item can contain a lot of views, and creating a lot of views can take a lot of time, so try to simplify ItemView as much as possible. When designing ItemType, the parts that can be shared by multiple viewTypes should be designed as custom views to reduce View construction and nesting.
other
The others don’t mean unimportant, but I can’t categorize them, and some of them might make a big change to your RecyclerView.
- Upgrade RecycleView version to 25.1.0 and above to use Prefetch function, refer to RecyclerView data Prefetch.
- If the Item is fixed, you can use RecyclerView. SetHasFixedSize (true); To prevent requestLayout from wasting resources;
- Set RecyclerView. AddOnScrollListener (the listener); To stop the loading operation during sliding.
- If does not require the animation, can pass ((SimpleItemAnimator) the rv. GetItemAnimator ()). SetSupportsChangeAnimations (false); Turn off the default animation for efficiency.
- Use String.toUpperCase for TextView instead of Android :textAllCaps=”true”.
- Replace TextView with a custom View StaticLayout or DynamicLayout.
- Through rewriting RecyclerView. OnViewRecycled (holder) to recycling of resources.
- Through RecycleView. SetItemViewCacheSize (size); To increase the RecyclerView cache, with space for time to improve the fluidity of scrolling.
- If multiple RecycledView Adapter is the same, such as nested RecyclerView exist in the same Adapter, you can set RecyclerView. SetRecycledViewPool (pool); To share a RecycledViewPool.
- Set up a listener for ItemView. Instead of calling addXxListener for each Item, you should use a common XxListener to perform different operations based on the ID. This optimizes resource consumption caused by frequent object creation.
- Use getExtraLayoutSpace to add extra space for RecyclerView.
Finally, in order to help you deeply understand the principle of Android related knowledge points and interview related knowledge, here are 24 sets of interview questions from Tencent, Bytedance, Alibaba and Baidu that I have collected and sorted out. I have sorted out the technical points into videos and PDF (actually much more effort than expected). Package knowledge context + many details.
There are advanced architecture technology advanced brain map, Android development interview materials to help you learn to improve the progress, but also save you on the Internet to search for information time to learn, can also share with friends around to learn together.
Click:
Android Architecture Video +BAT Interview topics PDF+ Study Notes is available for free
There is a lot of information about Learning Android online, but if the knowledge learned is not systematic, and problems are only tasted, no further research, then it is difficult to achieve real technology improvement. I hope this systematic technical system has a direction reference for everyone.