This file contains hidden or 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
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 |
This file contains hidden or 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 ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View { | |
return LayoutInflater.from(context).inflate(layoutRes,this,attachToRoot) | |
} |
This file contains hidden or 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
dependencies { | |
... | |
// Robolectric | |
testImplementation "org.robolectric:robolectric:3.7.1" | |
... | |
} |
This file contains hidden or 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
android { | |
... | |
testOptions { | |
unitTests { | |
includeAndroidResources = true | |
} | |
} | |
... | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
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" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.coderefer.androidtestingexamples.MainActivity"> | |
<Button |
This file contains hidden or 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
package com.coderefer.androidtestingexamples | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) |
This file contains hidden or 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
package com.coderefer.androidtestingexamples | |
import kotlinx.android.synthetic.main.activity_main.* | |
import org.junit.Test | |
import org.junit.Assert.* | |
import org.junit.runner.RunWith | |
import org.robolectric.Robolectric | |
import org.robolectric.RobolectricTestRunner | |
This file contains hidden or 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
// Room | |
implementation "android.arch.persistence.room:runtime:1.0.0" | |
kapt "android.arch.persistence.room:compiler:1.0.0" |
This file contains hidden or 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 testScope(){ | |
var name = "Hi Vamsi" | |
run{ | |
var name = "Hello there" | |
println(name) //Hello there | |
} | |
println(name) // Hi Vamsi | |
} |
This file contains hidden or 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
Button(this).run { | |
text = "Login" | |
background = ContextCompat.getDrawable(context,R.drawable.abc_btn_radio_material) | |
setOnClickListener { | |
openNextScreen() | |
} | |
} |