Android mobile phone system development tutorial! Detailed explanation of the interview questions related to the hash (hash) table in the BTAJ interview.

Preface

As we all know, Android is an operating system based on Linux. But for the Linux kernel, Android is just an application running on the kernel, and there is no difference from other applications running on the kernel.

Therefore, Android also needs a running environment, and the Linux kernel needs to load the resources needed for the Android Framework to run after the startup is complete. Only after the Framework is initialized can the corresponding APK application be started.

Framework is so important, how do we learn?

Regarding how to learn Android Framework development knowledge, I was fortunate enough to pick up this Android framework advanced development note in the hands of the former Alibaba technical director. Some of the knowledge chapters were published on Zhihu and even 1000+ likes. I will share it with you today.

This note explains the main modules of the Framework, from the deployment of the environment to the application of the technology, and then to the actual project. Let us not only learn the use of the framework technology, but also learn how to use the architecture to solve practical problems, from the shallower to the deeper, in detail Analyze Framework, let you learn this knowledge simply and efficiently!

Separation of data processing and view loading

We know that pulling data from the remote must be asynchronous. After we pull the data, we may hurriedly throw the data to the VH for processing. In fact, we should also place the data processing logic in asynchronous processing, so After the Adapter notify the change, ViewHolder can do data and view binding logic simply and without pressure, such as:

mTextView.setText(Html.fromHtml(data).toString());

The Html.fromHtml(data) method here may be more time-consuming. If there are multiple TextViews, the time-consuming will be more serious, which will cause frame drops and freezes. If you put this step together with the network asynchronous thread From the user's point of view, the network refresh time is a little longer at most.

Data optimization

Pull remote data by paging, cache the pulled remote data, improve the speed of secondary loading; for newly added or deleted data, use DiffUtil to refresh the data locally instead of blindly refreshing the data globally.

Layout optimization

Reduce transition drawing

To reduce the layout level, you can consider using a custom View to reduce the level, or set the layout more reasonably to reduce the level. It is not recommended to use ConstraintLayout in RecyclerView. Many developers have already reported that using it is even worse. Related links are: Is ConstraintLayout that slow?, constraintlayout 1.1.1 not work well in listview.

Reduce xml file inflate time

The xml file here includes not only the xml of the layout, but also the xml of the drawable. The xml file inflate out the ItemView through time-consuming IO operations, especially when the probability of Item reuse is very low, as the Type increases, this The loss caused by inflate is quite large. At this time, we can use code to generate the layout, that is, the new View() method, as long as we figure out the API corresponding to the attributes of each node in the xml.

Reduce the creation of View objects

A slightly complex Item will contain a large number of Views, and the creation of a large number of Views will also consume a lot of time, so the ItemView should be simplified as much as possible; when designing the ItemType, design the part that can be shared by multiple ViewTypes as much as possible to design a custom View to reduce the View The construction and nesting.

other

Others do not mean that they are not important, but I can't classify them. Some operations may greatly optimize your RecyclerView.

  • Upgrade RecycleView version to 25.1.0 and above to use Prefetch function, please refer to RecyclerView data prefetching.
  • If the Item height is fixed, you can use RecyclerView.setHasFixedSize(true); to avoid requestLayout wasting resources;
  • Set RecyclerView.addOnScrollListener(listener); to stop the loading operation during the sliding process.
  • If animation is not required, you can pass ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false); turn off the default animation to improve efficiency.
  • Use String.toUpperCase for TextView instead of android:textAllCaps="true".
  • Use custom View of StaticLayout or DynamicLayout for TextView instead of it.
  • Recycle resources by overriding RecyclerView.onViewRecycled(holder).
  • Use RecycleView.setItemViewCacheSize(size); to increase the cache of RecyclerView, and use space for time to improve the smoothness of scrolling.
  • If the Adapter of multiple RecycledViews is the same, for example, the same Adapter exists in the nested RecyclerView, you can share a RecycledViewPool by setting RecyclerView.setRecycledViewPool(pool);.
  • Set up a listener for ItemView. Don't call addXxListener for each Item. You should share an XxListener and perform different operations based on the ID, which optimizes the resource consumption caused by frequent creation of objects.
  • Use getExtraLayoutSpace to increase the extra space reserved by RecyclerView (outside the display range, there should be extra cache space)

At last

In fact, there are so many knowledge points in Android development, and there are still a few things to ask in interviews. Therefore, there are no other tricks for the interview, just look at how well you prepare for these knowledge points. So, when you go out for an interview, it is good to see which stage you have reached in your review.

The high-frequency interview questions shared by Tencent, Toutiao, Ali, Meituan, ByteDance and other companies in 2019-2021 . The blogger also organized these technical points into videos and PDFs (in fact, it took a lot more than expected Energy), including knowledge + many details . Due to the limited space, the above is just a part of the picture to show you.

[ Android learning PDF + learning video + interview document + knowledge point notes ]

[Android mind map (skill tree)]

Knowledge is not system? Here is also a sorted out mind map of Android advanced learning, for everyone to refer to a direction.

[Android Advanced Architecture Video Learning Resources]

to.

[External link image is being transferred...(img-7a34UAUi-1614154687686)]

[Android Advanced Architecture Video Learning Resources]

**Android part of the video is even more powerful after receiving and learning! **Enter the BATJ factory and so on (preparation)! Nowadays, it’s said that the Internet is cold. In fact, you get in the wrong car and wear less (skills). If you get in the right car and your own technical ability is strong enough, the cost of the company’s replacement is high. How could you be laid off? It's only the elimination of the end business Curd! Nowadays, there is a flood of junior programmers in the market. This set of tutorials is aimed at Android development engineers who are 1-6 years old. They are in a bottleneck period. Those who want to break through their salary increases in the next year, advanced Android intermediate and senior, architects are even more important to you. Like a fish in water, get it quickly!

Guess you like

Origin blog.csdn.net/chayel123/article/details/114026418