Jetzt loslegen. Gratis!
oder registrieren mit Ihrer E-Mail-Adresse
Android (2) von Mind Map: Android (2)

1. Kotlin

1.1. Các feature mới của kotlin: null safety, extesion function, data class, coroutine....

1.2. data class: Override sẵn:getter/setter, equals, hashcode, tostring...

1.2.1. data class và class thường khác nhau như nào?

1.2.1.1. bình thường thì khi so sánh 2 object vs nhau thì so sánh địa chỉ ô nhớ

1.2.1.2. data class override lại equals -> so sánh thuộc tính

1.3. null safety: Mọi thứ trong kotlin là non-null

1.3.1. ?: nullable

1.3.2. ?. không null mới gọi

1.3.3. ?: nếu null lấy bên trái - null lấy bên phỉa (giống check if else null)

1.3.4. !!: chắc chắn ko lỗi - nếu null throw exception

1.4. extesion function

1.4.1. bình thường khi thêm 1 method vào 1 class thì phải extend -> dùng extension function ko cần extend

1.5. High-order function

1.5.1. 1 function đc truyền vào như 1 parameter của 1 function khác

1.5.1.1. vd như hồi truyền vào adapter cái onclicklistener(lambda)

1.6. Reference function: truyền luôn cái function vào

1.6.1. vd: getData("trung",::printUppercase)

1.7. Object class/ companion object

1.7.1. object class như static class trong java

1.7.2. companion object: tạo ra 1 static scope bên trong class

1.8. scope function:apply, let, run, with, also

1.8.1. let: check null

1.8.2. with: binding: từ 1 đối tượng gọi tiếp các con

1.8.3. apply:

1.9. default parameter/named paramêtrr

1.9.1. named parameter

1.9.1.1. khi truyền parameter thì specific ra tên của parameter, thứ tự ko cần tuân thủ)

1.9.2. default parameter

1.9.2.1. tương tự như overload trong java, nếu ko truyền thì lấy cái default

1.10. phân biêt lateinit/lazy

1.10.1. lateinit: ko thể set lateinit = null

1.10.2. lazy: khởi tạo lần đầu tiên được call

1.10.3. so sánh

1.10.3.1. lateinit chỉ dùng cho var, lazy chỉ cho val

1.10.3.1.1. lateinit có thể assign nhiều lần còn lazy chỉ assign 1 lần

1.10.3.2. lateinit ko thread safety, còn lazy có thể

1.10.3.3. lateinit ko thể null, lazy có thể

1.10.3.4. lateinit ko áp dụng cho kiểu dữ liệu nguyên thuỷ đc còn lazy thì có

1.11. Coroutine:

1.11.1. Builder: design pattern để khởi tạo coroutine

1.11.1.1. launch: return a Job: chỉ để check status, có thể cancel

1.11.1.2. async/await: return Deffer<T>

1.11.1.3. runBlocking: block current thread gọi nó đến khi khối trong runBlocking chạy xong

1.11.1.4. withContext: chuyển Dispatcher

1.11.2. Dispatcher

1.11.2.1. Main

1.11.2.1.1. UI

1.11.2.2. IO

1.11.2.2.1. ĐỌc ghi file, network, database

1.11.2.3. Default

1.11.2.3.1. tác vụ cần CPU như sort, search, parseData

1.11.3. Scope

1.11.3.1. GlobalScope: application

1.11.3.2. LifeCycleScope: activity

1.11.3.3. ViewModelScope: viewModel

1.11.3.4. ViewOnerScope: fragment view

1.11.3.5. suppervior scope - coroutine scope

1.11.3.5.1. supervisor: nếu 1 thread chết các thread khác ko sao

1.11.3.5.2. coroutine: 1 thread chết ảnh hưởng đến thread khác

1.11.4. Exception

1.11.4.1. try catch

1.11.4.2. exception handller

1.11.5. suspend function: phải được call bên trong 1 coroutine scope, 1 function có thể suspend

1.12. Flow/StateFlow/ShareFlow

1.12.1. Hot flow: StateFlow, ShareFlow (self demo recommend)

1.12.2. Cold flow: Flow

2. Android

2.1. Basic:

2.1.1. 4 components chính

2.1.1.1. Activity

2.1.1.1.1. OnCreate: khởi tạo view

2.1.1.1.2. start/resume

2.1.1.1.3. pause/stop

2.1.1.1.4. restart

2.1.1.1.5. onDestroy: xoá view

2.1.1.2. Service

2.1.1.2.1. 2 loại

2.1.1.2.2. onStartCommand (note: onCreate chỉ chạy 1 lần -> start service 2 lần thì onStart 2 lần

2.1.1.2.3. AIDL: Giao tiếp liên tiến trình

2.1.1.2.4. so sánh khái niệm

2.1.1.3. Content provider

2.1.1.3.1. là 1 triển khai của IPC chia sẻ dữ liệu

2.1.1.4. Broadcast: giúp giao tiếp ứng dụng -hệ thống, ud - ud, internal

2.1.1.4.1. Dùng permission, protection level: dangous, signature....

2.1.1.4.2. sendOrdered: gửi nhiều nơi dựa vào priority

2.1.2. Permission

2.1.2.1. Install permission

2.1.2.1.1. cài là có

2.1.2.2. normal permission

2.1.2.2.1. xin trong manifest là có quyền

2.1.2.3. runtime permission/dangerous

2.1.2.3.1. phải ddc cấp bởi người dùng

2.1.3. Intent

2.1.3.1. là component giúp các thành phần chính giao tiếp với nhau

2.1.3.2. 2 loại

2.1.3.2.1. Implicit

2.1.3.2.2. Explicit

2.1.3.3. intent filter: bộ lọc intent, những intent mình có thể xử lý được

2.1.3.3.1. vd nếu mình khai báo intent filter với action send ảnh thì khi người dùng cần share ảnh app mình sẽ hiện lên -> thông báo app này xử lý đc hành động đó

2.1.4. ViewGroup

2.1.4.1. Framelayour

2.1.4.1.1. code sau thì lên trước

2.1.4.2. Linear Layout

2.1.4.2.1. weight

2.1.4.3. ConstraintLayout

2.1.4.3.1. ratio: tỉ lệ (4:3, 16:9,...)

2.1.4.3.2. guideline

2.1.4.3.3. barrier

2.1.4.3.4. chain

2.1.4.3.5. group

2.1.4.3.6. constraint set

2.1.5. CustomView

2.1.5.1. tự tạo view ko có sẵn, override ít nhất 2 constructor

2.1.5.2. tạo style file attr xml

2.1.5.3. onMeasure

2.1.5.3.1. hình dung bố cục, tính toán kích thước trong view

2.1.5.4. onLayout

2.1.5.4.1. đặt các thành phần con

2.1.5.5. onDraw

2.1.5.5.1. vễ

2.1.6. Drawable

2.1.6.1. Vector Drawable

2.1.6.2. Bitmap Drawable

2.1.6.2.1. jpeg, png,

2.1.6.3. Shape Drawable

2.1.6.3.1. xml (shape, solid, corners, stroke..)

2.1.6.4. Animation-list drawable

2.1.6.5. Level list drawable

2.1.6.6. Layer list drawable

2.1.6.6.1. array of drawable

2.1.6.7. State-list Drawable

2.1.6.7.1. button pressed, normal, hover,...

2.1.7. Animation

2.1.7.1. ViewAnimation (chỉ thay đổi view, ko thay đổi thuộc tính, vd khi click)

2.1.7.1.1. alpha

2.1.7.1.2. scale

2.1.7.1.3. rotate

2.1.7.1.4. translate

2.1.7.2. PropertyAnimation

2.1.7.2.1. ValueAnimator

2.1.7.2.2. ObjectAnimator

2.1.8. Context

2.1.8.1. Application context

2.1.8.2. Activity context

2.2. Advance

2.2.1. architecture

2.2.1.1. Model View Controller (ko test dc)

2.2.1.2. Model View Presenter

2.2.1.2.1. giao tiếp với nhau qua interface

2.2.1.2.2. 1-1 relationship (1 view đi vs 1 presenter), presenter chứa logic

2.2.1.3. MVVM

2.2.1.3.1. Observer pattern

2.2.1.3.2. N-N relationship (1 view có thể nhiều viewmodel, 1 viewmodel nhiều view,...)

2.2.1.4. Clean architecture(phu hop project to)

2.2.1.4.1. domain

2.2.1.4.2. data

2.2.1.4.3. presenter

2.2.1.5. Model View Intent

2.2.1.5.1. custom lại của MVVM

2.2.2. Architecture Components Jetpack

2.2.2.1. ViewModel

2.2.2.1.1. 2 loại: ViewModel, AndroidViewModel

2.2.2.1.2. shared view model bằng activity context

2.2.2.2. Live data

2.2.2.2.1. single event (vd khi xoay màn hình)

2.2.2.2.2. MediatorLiveData

2.2.3. Room

2.2.3.1. Entity

2.2.3.1.1. map table-class

2.2.3.2. DAO- interface

2.2.3.3. Database: Khai báo DAO

2.2.3.4. relationship

2.2.3.4.1. one-many

2.2.3.4.2. many-many

2.2.3.4.3. one-one

2.2.4. Navigation

2.2.4.1. NavHost

2.2.4.2. Navigation graph

2.2.4.3. NavController

2.2.5. Data binding

2.2.5.1. One way

2.2.5.1.1. thay đổi trong code thì trong xml listen đc

2.2.5.2. 2 way

2.2.5.2.1. cả 2 phía, có thể update trong xml

2.2.6. Paging

2.2.7. Work Manager

2.2.7.1. là 1 component để quản lý và chạy các tác vụ bất đồng bộ

2.2.7.1.1. Request

2.2.7.1.2. Constraint

2.2.8. Hilt

2.2.8.1. AndroidApplication

2.2.8.2. AndroidEntryPoint

2.2.8.3. @Inject

2.2.8.4. Provider

2.2.8.4.1. dùng khi mình cần cung cấp instance của những library

2.2.8.5. Bind

2.2.8.5.1. dùng để cung cấp instance của interface, mapping interface vs implementation

2.2.8.6. SingletonComponent

2.2.8.7. ActivityComponent

2.2.8.8. Named: đặt tên cho instance

2.2.9. RxJava

2.2.9.1. imperative programming

2.2.9.1.1. tập trung các bước cần làm, vd filter thì vòng for

2.2.9.2. -> declarative programming

2.2.9.2.1. tập trung vào mình cần j hơn là phải làm j, vd chỉ cần dùng 1 hàm filter

2.2.10. Compose

2.2.10.1. các layer

2.2.10.1.1. Material

2.2.10.1.2. Foundation

2.2.10.1.3. UI

2.2.10.1.4. Runtime

2.2.10.2. Composable function

2.2.10.2.1. data + composable function -> UI

2.2.10.3. phases

2.2.10.3.1. composition

2.2.10.3.2. layout

2.2.10.3.3. drawing

2.2.10.4. component

2.2.10.4.1. Scaffold

2.2.10.5. state

2.2.10.5.1. bất kì value có thể thay đổi over time

2.2.10.5.2. compose nào có state thì stateful, ko thì stateless

2.2.10.6. side effect

2.2.10.6.1. code mình ảnh hưởng đến 1 vấn đề khác

2.2.10.6.2. fix: dùng launchEffect

2.2.10.6.3. hoặc trong coroutine scope

3. UML

3.1. High Level Design - HLD / SAD

3.1.1. Component Diagram

3.1.2. Use case Diagram

3.2. Low level design - LLD, SDD

3.2.1. Sequence Diagram

3.2.1.1. if/else

3.2.1.2. for/loop

3.2.1.3. synchonize/asynchonize

3.2.2. Class Diagram

4. Unit test

4.1. Test Lifecycle

4.1.1. @BeforeAll, BeforeEach, Test, AfterAll, AlterEach

4.2. Test double: Các cách cung cấp dependencies

4.2.1. Mock

4.2.2. fake

4.2.3. stub

4.2.4. dummy

4.2.5. spy

4.3. Test coverage

4.3.1. C0

4.3.1.1. line

4.3.2. C1

4.3.2.1. nhánh

4.3.3. C2

4.3.3.1. Path