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
class RedditAdapter(mainActivity: Context, mList: MutableList<Child>) : Adapter<RedditAdapter.ViewHolder>() { | |
var mContext = mainActivity | |
var mList = mList | |
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { | |
return ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.reddit_item_view, parent, false)) | |
} | |
override fun getItemCount(): Int { |
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) |
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
fun getJsonFromAssets(): String? { | |
var json: String? = null | |
var inputStream: InputStream | |
inputStream = this.assets.open("reddit.json") | |
val size = inputStream.available() | |
val buffer = ByteArray(size) | |
inputStream.read(buffer) | |
inputStream.close() | |
json = String(buffer) | |
return json |
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
public final class FabTabBackgroundView extends View { | |
Paint paint; | |
Path path; | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
public FabTabBackgroundView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
super(context, attrs, defStyleAttr, defStyleRes); | |
init(); | |
} |