Last active
October 10, 2017 14:52
-
-
Save adamsp/43c15744f6e8bba6202308c51bc10ecf to your computer and use it in GitHub Desktop.
Paging Lib Blog MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var screenshotLoader: ScreenshotLoader? = null | |
var adapter: ScreenshotPickerAdapter? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
screenshotLoader = SAFScreenshotLoader(contentResolver, diskExecutor) | |
adapter = ScreenshotPickerAdapter(this) | |
val recycler = findViewById(R.id.main_recycler) as RecyclerView? | |
recycler?.layoutManager = GridLayoutManager(this, 2) | |
recycler?.adapter = adapter | |
loadScreenshots() | |
} | |
private fun loadScreenshots() { | |
screenshotLoader?.allScreenshots({ | |
if (!isDestroyed()) { | |
runOnUiThread { | |
if (!isDestroyed()) { | |
adapter?.setList(it) | |
} | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment