Skip to content

Instantly share code, notes, and snippets.

View vamsitallapudi's full-sized avatar
🚩
Be better than yesterday

Vamsi Tallapudi vamsitallapudi

🚩
Be better than yesterday
View GitHub Profile
@vamsitallapudi
vamsitallapudi / SimpleRxAndroidActivity.java
Created November 4, 2017 11:39
Simple Rx Activity created for blog www.coderefer.com
package com.coderefer.rxandroidexamples.intro;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.coderefer.rxandroidexamples.R;
@vamsitallapudi
vamsitallapudi / ReadFile.java
Last active January 16, 2018 07:02
Read a file in Java Using Buffered Reader
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(getAssets().open("news_data_file.json"), "UTF-8"));
// do reading, usually loop until end of file reading
String mLine;
while ((mLine = reader.readLine()) != null) {
//process line
...
@vamsitallapudi
vamsitallapudi / ReadFile.kt
Created January 16, 2018 07:40
Read a file in Kotlin
try {
val inputStream:InputStream = assets.open("news_data_file.json")
val inputStreamReader = InputStreamReader(inputStream)
val sb = StringBuilder()
var line: String?
val br = BufferedReader(inputStreamReader)
line = br.readLine()
while (br.readLine() != null) {
sb.append(line)
line = br.readLine()
@vamsitallapudi
vamsitallapudi / ReadFileWithExtFunction.kt
Created January 16, 2018 07:46
Read a file in Kotlin using Extension Function
try {
val inputStream:InputStream = assets.open("news_data_file.json")
val inputString = inputStream.bufferedReader().use{it.readText()}
Log.d(TAG,inputString)
} catch (e:Exception){
Log.d(TAG, e.toString())
}
dataBinding {
enabled = false
}
dependencies {
...
//adding a recyclerview
compile "com.android.support:recyclerview-v7:26.1.0"
//adding a cardview
compile "com.android.support:cardview-v7:26.1.0"
...
}
...
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
...
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.coderefer.newsboard.MainActivity"
>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
package com.coderefer.newsboard
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.View
import android.view.ViewGroup
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.news_item.view.*
/**
package com.coderefer.newsboard
import android.databinding.DataBindingUtil
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.util.Log
import com.coderefer.newsboard.databinding.ActivityMainBinding
import kotlinx.android.synthetic.main.activity_main.*
import org.json.JSONArray