Created
August 25, 2017 10:03
-
-
Save AkshatAgrawal05/8e531fca2be769f926bcafe6e93ae5e1 to your computer and use it in GitHub Desktop.
Async Task to read json file
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
private inner class JsonExecuter : AsyncTask<Void, Void, String>() { | |
override fun doInBackground(vararg p0: Void?): String { | |
return getJsonFromAssets()!! | |
} | |
override fun onPostExecute(result: String?) { | |
super.onPostExecute(result) | |
val moshi = Moshi.Builder().build() | |
val jsonAdapter = moshi.adapter(Reddit::class.java) | |
var red: Reddit? = jsonAdapter.fromJson(result) | |
mList = red?.data?.children!! | |
rvReddit?.adapter = RedditAdapter(mContext, mList) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment