Skip to content

Instantly share code, notes, and snippets.

View kyodgorbek's full-sized avatar

Yodgorbek Komilov kyodgorbek

View GitHub Profile
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
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(
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")
[
{
"_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",
[{"_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
<?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"
>
class BBCSportAdapter :
RecyclerView.Adapter<BBCSportAdapter.MyViewHolder>() {
companion object {
const val urlKey = "urlKey"
}
lateinit var articleList: List<Article>
@kyodgorbek
kyodgorbek / SportNewsApplication.kt
Last active March 20, 2020 11:20
Koin dependcy
class SportNewsApplication : Application() {
override fun onCreate() {
super.onCreate()
// Adding Koin modules to our application
startKoin {
androidContext(this@SportNewsApplication)
listOf(appModules, bbcModules)
@kyodgorbek
kyodgorbek / MainViewModel.kt
Last active December 6, 2019 21:49
crash log
@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>()
@kyodgorbek
kyodgorbek / Article.kt
Created December 2, 2019 10:10
news repository
@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
)