The first issue: 2018/11/5-2018/11/11

  • Android leak pattern: subscriptions in views

Summary: Anonymous inner classes hold leaked cases referenced by external instances. The onFinishInflate is always invoked, but the onAttachedToWindow is invoked as soon as the parent view addView has a window, and no window is invoked when the parent attaches to a window. And view.onattachedTowindow () is called on the first View traversal, sometime after activity.onstart ()

  • A small leak will sink a great ship

Summary: The Dalvik VM (pre-Android 5.0) does not discard the message if the current message is consumed and no new message is queued. The onClickListener of the AlertDialog is queued and held by the message. Message is sent with a copy. The original message is never sent, so it is never recycled. If the Listener holds a reference to an external activity, it will leak memory. ClearOnDetach /send an Empty message

  • Advocating Against Android Fragments

Summary: Square Tech Leader PY after heavy use of Fragments. 1. Most of our difficult crashes were related to the fragment lifecycle. 2. We only need views to build a responsive UI, a backstack, and screen transitions.

  • Alipay client architecture analysis: Android client startup speed optimization “garbage Collection”

Summary: The general idea of Alipay to improve startup speed by inhibiting GC: cancel softLimit detection, cancel the wake up of GC thread, cancel GC routine function, OOM stop GC suppression.

  • LiveData Overview

Summary: Using Android’s official live-Data component gives Data the ability to sense the UI lifecycle. OnActive (),onInactive(), and setValue() are important methods that occur in viewModels.

  • Android Security Journey – Just a few lines of code to make Android applications more secure

Summary: 1. Confusion. 2. The hook. 3. Anti-packet capture. 4. Anti-debugging. 5. Verify signatures. 6. The carton.

The second issue: 2018/11/12-2018/11/18

  • Get started debugging JavaScript in Chrome DevTools
  • Start with a strange piece of code

Summary: Three softreferences

encapsulated in Fresco are the same. The reason is that Dalvik will treat the SoftReference in even bit as WeakReference during GC (if its reference is not reachable by GC Roots). If there is still not enough memory allocation after GC for alloc, All softreferences are cleared. This means that as long as an object has one SoftReference alive, all of its softreferences are alive, so two softreferences in a row are guaranteed not to be GC. Three softreferences are used here just to be safe. Ensure that the OOMSoftReference is reclaimed only before an OOM is discarded.

  • Forget RxJava: Kotlin Coroutines are all you need. Part 1/2

Summary: RxJava vs Kotlin Coroutines

RxJava kotlin coroutines
The Performance overhead operator generates a large number of objects Fewer objects
Unreadable stacktrace Unreadable stacktrace
The learning complexity & Readability higher Readability

Kotlin coroutines are written like JS async await, very close to synchronous writing.

  • The Android Lifecycle Cheat Sheet — Part II: Multiple Activities

  • The Android Lifecycle cheat sheet — part III : Fragments

  • R8, the new code shrinker from Google, is available in Android studio 3.3 beta

Summary: R8 does all of shrinking, desugaring and dexing in one step. When comparing to the current code shrinking solution, Proguard, R8 shrinks the code faster while improving the output size.

The third issue: 2018/11/19-2018/11/25

  • Charles went from beginner to master
  • Do not always trust @JvmOverloads

@jvmoverloads loads of bugs in Android development…

  • 5 common mistakes when using Architecture Components

The fourth issue: 2018/11/26-2018/12/2

  • Invokedynamic: Java’s secret weapon

The instructions for Java bytecode calls are:

  • Invokevirtual — Standard dispatch of instance methods, invoking methods based on instance classes

  • Invokestatic — Used to dispatch static methods

  • Invokeinterface — Dispatch for method calls through the interface, such as List

  • Invokespecial — Invoke constructor or private method, a method of the current instance’s parent class

  • Invokedynamic — The interpreter invokes BSM when it encounters this directive, returning an object of type CallSite that contains a MethodHandle. When the class containing InvokeDynamic is loaded, the call point is in “Laced” state, and after BSM returns, The resulting CallSite and method handle will make the call point in the Laced state.

  • Translation of Lambda Expressions

  • Install Bao Li minus 1M– wechat Android resource confusion packaging tool

  • Android Reverse Tour – parse the compiled Resource. Arsc file format

Original text: AndroidWeekly