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
import android.os.Build | |
import android.os.Bundle | |
import android.os.StrictMode | |
import androidx.appcompat.app.AppCompatActivity | |
import io.ktor.network.selector.ActorSelectorManager | |
import io.ktor.network.sockets.aSocket | |
import io.ktor.network.sockets.openReadChannel | |
import io.ktor.network.sockets.openWriteChannel | |
import io.ktor.util.cio.write | |
import io.ktor.utils.io.readUTF8Line |
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 MemberActivity : AppCompatActivity() { | |
private var memberAdapter: MemberAdapter? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_member) | |
val compositeDisposable = CompositeDisposable() | |
compositeDisposable.add( |
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
data class Member( | |
@SerializedName("age") | |
val age: Int, | |
@SerializedName("email") | |
val email: String, | |
@SerializedName("_id") | |
val id: String, | |
@SerializedName("name") | |
val name: Name, | |
@SerializedName("phone") |
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
[ | |
{ | |
"_id":"5c5bb5ce54a9c166bf1c5b82", | |
"company":"GYNKO", | |
"website":"www.gynko.co.uk", | |
"logo":"http://placehold.it/32x32", | |
"about":"Veniam sit ex ex esse pariatur proident non aute sunt. Aute id eiusmod aute incididunt sint est ullamco eiusmod adipisicing aliqua est. Velit aliqua occaecat enim pariatur laboris deserunt aliqua dolore fugiat dolor consequat sit occaecat pariatur. Ullamco velit laborum cillum reprehenderit Lorem magna exercitation laboris qui et aute nulla veniam. Reprehenderit nulla culpa elit ad ex ex sunt nisi eiusmod. Non officia ea est exercitation ut Lorem aute nulla.", | |
"members":[ | |
{ | |
"_id":"5c5bb5ce9ea1ae34c3d4f0c7", |
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
[{"_id":"5c5bb5ce54a9c166bf1c5b82","company":"GYNKO","website":"www.gynko.co.uk","logo":"http://placehold.it/32x32","about":"Veniam sit ex ex esse pariatur proident non aute sunt. Aute id eiusmod aute incididunt sint est ullamco eiusmod adipisicing aliqua est. Velit aliqua occaecat enim pariatur laboris deserunt aliqua dolore fugiat dolor consequat sit occaecat pariatur. Ullamco velit laborum cillum reprehenderit Lorem magna exercitation laboris qui et aute nulla veniam. Reprehenderit nulla culpa elit ad ex ex sunt nisi eiusmod. Non officia ea est exercitation ut Lorem aute nulla.","members":[{"_id":"5c5bb5ce9ea1ae34c3d4f0c7","age":26,"name":{"first":"Heather","last":"Russell"},"email":"heather.russell@undefined.info","phone":"+1 (827) 549-3643"},{"_id":"5c5bb5ce591915de62e56bb2","age":30,"name":{"first":"Velma","last":"Hayden"},"email":"velma.hayden@undefined.me","phone":"+1 (989) 537-3158"},{"_id":"5c5bb5cee24406f77af3c0d1","age":30,"name":{"first":"Solomon","last":"Griffith"},"email":"solomon.griffith@unde |
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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:attrs="http://schemas.android.com/apk/res-auto" | |
> | |
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 BBCSportAdapter : | |
RecyclerView.Adapter<BBCSportAdapter.MyViewHolder>() { | |
companion object { | |
const val urlKey = "urlKey" | |
} | |
lateinit var articleList: List<Article> |
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 SportNewsApplication : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
// Adding Koin modules to our application | |
startKoin { | |
androidContext(this@SportNewsApplication) | |
listOf(appModules, bbcModules) |
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
@Suppress("UNCHECKED_CAST") | |
class MainViewModel(val newsRepository: NewsRepository) : ViewModel(), CoroutineScope { | |
// Coroutine's background job | |
val job = Job() | |
// Define default thread for Coroutine as Main and add job | |
override val coroutineContext: CoroutineContext = Dispatchers.Main + job | |
val showLoading = MutableLiveData<Boolean>() | |
val sportList = MutableLiveData <List<Article>>() | |
val showError = SingleLiveEvent<String>() |
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
@Entity(tableName = "news_table") | |
data class Article(@ColumnInfo(name = "author")val author: String, | |
val content: String, | |
val description: String, | |
val publishedAt: String, | |
val source: Source, | |
val title: String, | |
val url: String, | |
val urlToImage: String | |
) |