Skip to content

Latest commit

 

History

History
51 lines (43 loc) · 1.34 KB

Android.md

File metadata and controls

51 lines (43 loc) · 1.34 KB

Get Start(中文)


Usage

1. Install MediaLibManager in ur Application

// YourApplication.kt
  override fun onCreate() {
    super.onCreate()
    ...
    MediaLibManager.install(this, reactNativeHost.reactInstanceManager)
  }

2. Optional: Get results in native way.

U can observe a signal in ur 'MediaLib' container(maybe a activity or a fragment) to get selector result list.
U must choose one between Point.2 and Point.3

  ...
  // (1) get GalleryViewModel
  val model = ViewModelProviders.of(this).get(GalleryViewModel::class.java)
  // (2) observe nextStep
  model.nextStep.observe(this) {
      if (it != true) return@observe
      // (3) obtain all selected item
      val allSelected = model.getAllSelected()
      allSelected ?: return@observe
      // (4) for example: open a new native page
      openANewNativePage(allSelected)
    }
  
  private fun openANewNativePage(temp: List<LocalMedia>) {
    val intent = Intent(this, NativeNextActivity::class.java)
    val data: ArrayList<LocalMedia> = arrayListOf()
    data.addAll(temp)
    intent.putExtra("data", data)
    startActivity(intent)
  }
  ...

3. Optional: Get results in react-native way:

for more detail:README Usage Point.3

End