Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Vamsi Tallapudi vamsitallapudi

🎯
Focusing
View GitHub Profile
View SimpleRxAndroidActivity.java
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 Jan 16, 2018
Read a file in Java Using Buffered Reader
View ReadFile.java
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 Jan 16, 2018
Read a file in Kotlin
View ReadFile.kt
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 Jan 16, 2018
Read a file in Kotlin using Extension Function
View ReadFileWithExtFunction.kt
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())
}
View build.gradle
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"
...
}
View activity_main.xml
...
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
...
View news_item.xml
<?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"
View NewsRecyclerAdapter.kt
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.*
/**
View MainActivity.kt
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
You can’t perform that action at this time.