An open API service indexing awesome lists of open source software.

https://github.com/frostyshadows/android-cheatsheet

Helpful visual guides for Android development
https://github.com/frostyshadows/android-cheatsheet

Last synced: 3 months ago
JSON representation

Helpful visual guides for Android development

Awesome Lists containing this project

README

        

# Android Cheatsheet

This is a collection of visual guides that I find myself coming back to repeatedly while doing Android development. Open to contributions!

## Table of contents

[Activities and Fragments](#activities-and-fragments)

[User interface](#user-interface)

[Kotlin](#kotlin)

[Jetpack Compose](#jetpack-compose)

[Architecture](#architecture)

[Build process](#build-process)

[General software engineering](#general-software-engineering)

## Activities and Fragments

### Lifecycle flowchart

### Callback methods

| Callback | When | What |Is Activity visible|
| --------------|---------------------------------|-----------------------------------------------------|:-----------------:|
|onCreate() | Activity is first created | All the necessary UI elements should be initialized | no |
| onStart() | Activity becomes visible to user| Code that maintains the UI, start async tasks (get data from API or database), register listeners | yes |
| onResume() | Activity becomes interactable to user| Starts animations | yes |
| onPause() | User is leaving the activity | Stops animations |partially visible |
| onStop() | Activity is no longer visible to user| Unregisters listeners and resources allocated in onStart()|no |
| onRestart() | Activity in the stopped state is about to start again (on back click) | Cursor objects should be re-queried | no |
| onDestroy() | Activity is destroyed from memory| | no |

### Launch modes
| Mode | Default | Instantiation | New Task on Launch | Allow other activities within Task |
| ---------------| --------------|--------------------| -------------------| -----------------------------------|
| standard | Yes | Everytime an intent is created, a new instance is created. Also instances can be member of multiple tasks and more than one instance in a Task. | No. Open in the same Task that originated the intent | Yes |
| singleTop | No | Exactly like standard but if the activity is at the top of the Task stack then it uses the existing instance. | No. Open in the same Task that originated the intent | Yes |
| singleTask | No | Single instance | Yes. Always a Root Task. | Yes |
| singleInstance | No | Single instance | Yes. Always a Root Task. | Never. Always the only activity in the task |

[Source](https://guides.codepath.com/android/Navigation-and-Task-Stacks)

## User interface
### RecyclerView pieces

| Piece | What it does |
|-----------------|------------------------------------------------------------------------------------------------------------------------------|
| `RecyclerView` | The `ViewGroup` that contains the views corresponding to your data. |
| item | One data item of the list to display. Can be of any type; often a data class you define. |
| `Adapter` | Takes data and prepares it for `RecyclerView` to display. |
| `ViewHolder`s | A pool of views for `RecyclerView` to use and reuse to display items. Each individual `ViewHolder` is a wrapper around a `View`. |
| `View` | A layout that can display one data item. |
| `LayoutManager` | Measures and positions individual item views within a `RecyclerView` and determines the policy for when to recycle item views that are no longer visible. The ones provided in the `RecyclerView` library are `LinearLayoutManager`, `GridLayoutManager`, and `StaggeredGridLayoutManager` |

[Source](https://developer.android.com/codelabs/basic-android-kotlin-training-recyclerview-scrollable-list)

### ImageView ScaleTypes

[Source](https://thoughtbot.com/blog/android-imageview-scaletype-a-visual-guide)

### [PorterDuff modes](https://developer.android.com/reference/android/graphics/PorterDuff.Mode) for tinting

[Source](https://chiuki.github.io/android-shaders-filters/#/)

## Kotlin

### Kotlin Standard Library functions

### Type system

[Source](http://natpryce.com/articles/000818.html)

### Kotlin Flow Cheatsheet

[Source](https://medium.com/@galou.minisini/advanced-kotlin-flow-cheat-sheet-for-android-engineer-cb8157d4f848)

## Jetpack Compose

### Three phases of a frame

[Source](https://developer.android.com/jetpack/compose/phases)

### Centering items in Composables

### Choosing an API to implement an animation

[Source](https://developer.android.com/develop/ui/compose/animation/choose-api)

## Architecture

### Uncle Bob's clean architecture

[Source](https://android.jlelse.eu/thoughts-on-clean-architecture-b8449d9d02df)

## Build process

[Source](https://stuff.mit.edu/afs/sipb/project/android/docs/tools/building/index.html)

## General software engineering

### Code review checklist

[Source](https://www.michaelagreiler.com/code-review-checklist-2/)

### Gang of Four design patterns

[Source](http://www.blackwasp.co.uk/GangOfFour.aspx)