Update record

  • 2020-09-06: Read custom View, update Scroller

First, Android related

Handler

✅ do you really know Handler? Handler q&a

MSG. When can’t be assigned to System. CurrentTimeMills. MessageQueue when = SystemClock#uptimeMillis() and delayMillis; SystemClock#uptimeMillis() is a relative time of the current time, representing the number of milliseconds between 0 and the time the method was called

✅ Why is MessageQueue stored as a linked list?

The question is: What’s the difference between an array and a linked list? Handler is used in situations where you insert frequently, but only fetch the first message each time, so it’s natural to use linked lists rather than arrays for storage in this case

Refer to Message for team entry process analysis

Fragment

✅ Android Fragment from the perspective of source code

The difference between adding fragments to a container and adding them to a container, and how to display one fragment and hide the other – getFragments() Then call the hide method to hide, and finally call the show() method to show XXFragment);

  • Fragment reuse stuff

Answer questions about how to use findFragmentByTag() properly and why not use findViewByTag() with ViewPager.

  • Two steps to complete the Fragment return key

Solution: Manage all Fragment return keys based on FragmentManager

  • (ViewPager, ListView, WebView, FragmentTabhost can be nested)

Bitmap

✅ [introduction to BitmapFactory Options

The bitmapFactory.options parameter is explained, along with a solution for loading a large image -> inJustDecode + inSampleSize

✅ Android Bitmap changes and principles (4.x-8.x)

4. X-8.x Bitmap pixel data is saved in the Java heap and will occur OOM; 8.0x is saved in Native and is not prone to OOM. According to the author’s test, after 8.0, Bitmap memory consumption can grow indefinitely until the system memory is exhausted.

  • The Matrix method for image and video editing is good

2020.03.31 One brush, did not understand ~ wait for the second brush

Activity

  • The Android interviewer failed: the Activity launch mode

What are the problems with taskAffinity and the various startup flags

  • Todo: Summarize what each phase does

Is the Activity destroyed after calling onDestroy? In fact, if we look at the source code, we can see that the onDestory method of the Activity does not have any code to empty the Activity. OnDestroy only unties the ViewRootImpl and DecorView, and AMS ends up cleaning up the mess.

✅ Android Visible APP invisible task stack destruction analysis

One swipe: For single-stack (TaskRecord) applications, all interfaces are not recycled in the foreground, and only activities with invisible stacks are recycled in multi-stack cases. When to reclaim invisible tasks: when Java is using more than 3/4 of the memory;

ViewStub

Mmap principle analysis

  • The principle and application of MMAP in Android
  • The principle and application of MMAP in Android

1.11 LowMemoryKiller

  • How does an Android application re-run the splash screen logic after being killed by the background
  • The Android Backend Kill series 4: Binder Obituaries
  • Android background Kill: FragmentActivity and PhoneWindow background kill mechanism
  • Android Background Kill series 2: ActivityManagerService and App On-site recovery mechanism
  • LowMemoryKiller (4.3-6.0)

Android Window Management

✅ Android Graphical system (I) -window View loading process

Very good article, easy to retract. It not only introduces the process of Window addition, but also provides a flow chart for the process of WMS addition. In addition, my biggest gain is that I have a clearer understanding of the collaboration and function between the various classes in the process, which is great!

✅ Android Graphics System (2) -DecorView layout loading process

The DecorView load process consists of four main steps:

1. Initialize DecorView (installDecor, including theme and feature properties that resolve Windows, also in this step)

Parse the XML and add it to the decorView

3. Set the DecorView visible in the handleResumeActivity and bind it to ViewRootImpl using the view.assignparent (this) method

✅ Android window mechanism (5) the final chapter: WindowManager. LayoutParams and Token as well as other Dialog window, Toast

Clarify the different types of Windows: Toast is the system window; PopupWindow and Dialog are child Windows (attached to the activity)

✅ Basic principle of adding View to Window in Android

Helps clarify the Window removal logic

  • Android window management analysis (4) : Android View drawing memory allocation, transfer, use
  • Android window management analysis (3) : window grouping and Z-order determination
  • Android Window management analysis (2) : WindowManagerService Window management Window add process
  • Android Window management analysis (1) : How to draw the View on the screen subjective understanding
  • Android Graphics Display System (1)
  • Liu Wangshu’s Windows Manager series
  • Android parses Windows ManagerService (2) to add important WMS members and Windows
  • Overview of Android Graphics System
  • VSync for Android graphics
  • Android Graphics System part Gralloc

Input system

  • How are input events distributed to Windows?

Toast

✅[A first look at Android window management from Toast display principle

NotificationManager -> handler.post -> wims.addView ()

Binder

  • I heard that you are good at Binder mechanism, so let’s solve these problems. (3)
  • I heard that you are good at Binder mechanics, so LET’s solve these problems (2)
  • I heard that you are good at Binder mechanics, to solve these problems (I)
  • Basic principles of Android Binder (1) Essential knowledge before learning Binder

AMS

  • ActivityTask and Activity stack management

The custom view

  • > NestedScrolling
  • 【 lens series 】 Through > Touch event distribution >
  • Android implements the ArcSlidingHelper for the arc sliding effect
  • View Article: Play with custom ViewGroups

✅ Android Advanced Tour – self-defined View ✅ Do you really understand Android ViewGroup draw and onDraw call timing

If setWillNotDraw(true) is set to mPrivateFlag (mPrivateFlag, mPrivateFlag), setWillNotDraw(true), Call dispatchDraw() and subclass it. However, if setWillNotDraw(false) is set, the view.isopque () method will not draw itself if it returns true. DrawBackGround and onDraw() ‘methods will only be called if it returns false.

✅ view.post () exactly what it did

As for the view.post () method, before reading the article, I assumed that the Handler was used at the bottom, and that the Handler should come from a DecorView, but I couldn’t guess the exact time of the post. After reading the article, we know that handler is used at the bottom level. The time for post is in view otimpl’s performTraversal and in front of performMeasure(). The reason is that the message in the message queue will be executed only after the message is executed. So it doesn’t really matter if you send it before or after. Therefore, the view. post method is reliable in getting the width and height of the View because it has already been executed.

Extension: Several ways to get the width and height of a View:

  1. With the onWindowFocusChanged method
  2. Do this via view.post ()
  3. Callback via OnGlobalLayoutListener in ViewTreeObserver

Scroller

  • Scroller class usage fully analyzed with source code analysis

Second, third-party open source libraries

RxJava

✅ RxJava2 source code parsing (a)

The first part explains the flow of the Observable.create method, summarizes the flow of data source creation, and how to associate the source and end points through the subscribeActual method.

✅ RxJava2 source code parsing (two)

The second part introduces the source code of the map operator and the principle of thread switching. Map works by calling its own Apply method in the onNext method and then calling the downstream onNext method. The implementation principle of thread switching is as follows: scheduler. ScheduleDirect method is called in the subscribeActual method, and the method is placed in different threads to execute by creating thread scheduling classes such as IOWorker. When the onNext method is called, the MainThreadWorker is also created and the method is put back on the main thread to run.

OkHttp

✅[why response.body().string() can only be called once?

It can only be read once because OkHttp closes the data stream connection after it is read. The main reason for this design is that it is not possible to read data multiple times, so it is designed to be read once

✅ okHttp source code analysis series

The best series I’ve seen so far

✅[OkHttp 2 that you must Learn

The previous OkHttp series did not analyze the retry mechanism, so to fix it, I drew a flow chart based on my understanding

  • OKHttp3 – retry and redirect the interceptor RetryAndFollowUpInterceptor source code parsing [6]

✅[Into TLS of OKHttp

Retrofit

✅Android: Take you hand by hand through Retrofit 2.0 source code

✅[Retrofit analysis – beautiful decoupling routines

The above two articles are used to build the framework, the more beautiful source code in tracking the more likely to get lost, the first article will be very long, do not have to look at it once, first look at the framework focus: We can continue to clarify the roles and flow of Call, CallAdapter, Converter, and CallBackExecutor

✅Android: Take you hand by hand through Retrofit 2.0 source code

✅ Dismantle the Wheel Series: Dismantle Retrofit

Both articles have an analysis of the source code and the patterns involved in the source code. Both articles are long, but fortunately they are well formatted and not too boring to look at

EventBus

✅[EventBus source code parsing

Very detailed source code analysis, code comments are very much

✅[Android Framework Learning 3: Lessons learned from EventBus

Advantages: Eentbus is useful for transferring large data between activities or services. Disadvantages: Difficult to manage and debug

ARouter

  • Analysis of Android routing scheme ARouter

Java basics

HashMap

✅HashMap initial capacity is 2 to the NTH power and expansion is 2 times the form

The reason is that when an element is added to the set, the (n-1) &hash method is used to determine the position of the element in the set:

1, symbol & is the calculation of bitwise and, which is bit operation, the computer can directly calculate, especially efficient; 2, (n-1) of the binary form 1111111***111, so that the hash with the hash value of the added element can be fully hashed

SparseArray

  • Memory optimization: SparseArray is full of contradictions

Four, other

Mixed development

✅H5 and Native interaction principle

There are two ways to interact between native and front-end: url scheme and JavaScriptCore (addJavascriptInterface in Android)

- H5 call Android- Native register with addJavascriptInterface, then H5 call directlyCopy the code

Android calls H5- natively called from loadUrl, 4.4 and above can also be called from evaluateJavascript

Performance optimization

✅Systrace usage guide

This series covers Systrace in great detail and covers a lot of dry stuff, such as graphics systems and SurfaceFlinger

✅ Android overdraws

You can be inspired by setting your Activity’s theme to WindowBackground-null and canvas.drawXX to draw one more layer each time

  • Gradle Wrapper is an important Gradle Wrapper

pluggable

  • Principle of Android plug-in (A) Activity plug-in

Bytecode staking

  • Android AOP bytecode staking

ANR

✅Android application ANR analysis

This tutorial explains how to analyze the data files (ANR, CPU usage, JVM parameters, etc.). Lack of analysis of the underlying causes of ANR, such as: how does the system monitor ANR?

  • Input System ANR analysis

5. Excellent blog

  • Meituan technology blog
  • Tencent WeTest
  • Reading a little snail
  • Red orange Darren