Skip to content

lvhkhanh/Android

Repository files navigation

Google Developer Profile

Android

Official

Downloads

Prerequisites

where java add JAVA_HOME to PATH

Ebooks

Paths

Assessments

Labs

Courses

Tools

gradlew lint

Best Practices

Links

IDE

Android Studio

Import Samples

Instance run/ apply changes/ hot reloading

Darcula, Dark, Black theme | Light, White theme

Settings

Add Unambiguous Imports on the fly
Optimized Imports on the fly

Pluggin

Markdown

IntelliJ

Android SDK

Pluggin Android

Tips

File/Invalidate and restart

Cat log, setting android version

build.gradle

dependencies

dependencies {
  // Face features
  implementation 'com.google.mlkit:face-detection:16.0.0'

  // Text features
  implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.0.0'
}

repositories

{
  jcenter()
  google()
}

Notes

Compose UI default stack overlay
App foreground -> toast, background -> notification
RxJava, RxKotlin, RxAndroid
addOnSuccessListener + addOnFailureListener => addOnCompletedListener check Task.Result 
build.gradle
  dependencies
    implementation 'androidx.support:appcompact:1.0'
class MainActivity : AppCompactActivity(){
  val otherHelper = OtherHelper(this, lifecycle)
  onCreate(saveInstanceState: Bundle?)
    // called on rotate
    // prefer bundle then intent data
    if isNewlyCreated && savedInstanceState != null
      viewModel.restoreState(savedInstanceState)
    viewModel.isNewlyCreated = false
    // adapter = ...
    // set action on item click
    startActivity(Intent(this, OtherActivity::class.java))
  onSaveInstanceState(outState: Bundle?)
    // call when rotate
    // save some state
    outState.putData("DATA_KEY", "DATA_CURRENT_VALUE")
  onPause
    saveData()
  onResume()
    adapter.notifyDataSetChanged()
}
class OtherActivity: Activity(){
  private val viewModel by lazy { ViewModelProviders.of(this)[OtherActivityViewModel::class.java] }
  fun onCreate(){
    val vm = ViewModel
  }
}
class OtherActivityViewModel : ViewModel(){
  isNewlyCreated = true
  fun saveState(outState: Bundle){
    outState.putInt(intName, intValue)
  }
  fun restoreState(savedInstanceState: Bundle){
    intValue = savedInstanceState.getInt(intName)
  }
}

class OtherHelper(val context: Context, val lifecycle: Lifecycle): LiecycleObsever{
  init {
    lifecycle.addObserver(this)
  }

  val tag = this::class.simpleName
  val currentLat = 0.0
  val currentLon = 0.0
  
  val locManager = PLocManager(context){lat,lon ->
    currentLat = lat
    currentLon = on
    Log.d(tag, "$lat $lon")
  }
  
  @OnLifecycleEvent(Lifecycle.Event.ON_START)
  fun startHandler(){
    locManager.start()
  }
}

Test

JUnit

Espresso

Steps

Wireframing

Split screens, flows to each screen

Theme colors

UI/UX

device-independant pixel dp, scalable pixel sp

primary
primary dark
accent

Mapping

Compose HTML
Text("text") <span>text</span>
Column Column
Row Row
Modifiers <tag modifier="modifier">
image = imageResource(R.id.image); Image(image) <img src="src">
Spacer() <div data-hold="maximum as posible"/>

Keywords

annotation, binding, observable
shrink
clean code, best practices, coding conventions, checklist
attachToParent when custom view include in fragment?

Build Process

kotlin/java -> *.class -> Dalvik Executable (DEX) -> Dalvik virtual machine used by Android -> Android Package (APK)

Data Binding

View Binding

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published