Skip to content

Instantly share code, notes, and snippets.

@ankitchauhan20
ankitchauhan20 / DataActivity.kt
Created August 12, 2022 08:32
room database with mvvm
package com.example.profilescreen.view.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.example.profilescreen.R
import com.example.profilescreen.databinding.ActivityDataBinding
class DataActivity : AppCompatActivity() {
lateinit var dataBinding:ActivityDataBinding
@ankitchauhan20
ankitchauhan20 / ApiService.kt
Created July 28, 2022 04:53
Dagger with MVVM
package com.example.dagger2.model.data
import com.example.dagger2.model.dataModel.PostItem
import retrofit2.Call
import retrofit2.http.GET
interface ApiService {
@GET("/posts")
fun getPost(): Call<List<PostItem>>
@ankitchauhan20
ankitchauhan20 / ApiService.kt
Created July 26, 2022 12:32
Dagger with Retrofit MVVM
package com.example.di
import com.example.dagger2.model.dataModel.PostItem
import retrofit2.Call
import retrofit2.http.GET
interface ApiService {
@GET("/posts")
fun getPost(): Call<List<PostItem>>
@ankitchauhan20
ankitchauhan20 / AndroidManifest.xml
Last active July 26, 2022 05:58
Save Data User Input Data in Room Database
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.profilescreen">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
@ankitchauhan20
ankitchauhan20 / ApiClient.kt
Last active July 26, 2022 06:02
Retrofit with MVVM
package com.example.application.network
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
object ApiClient {
val BASE_URL: String = "https://jsonplaceholder.typicode.com/"
var retrofit: Retrofit? = null
@ankitchauhan20
ankitchauhan20 / RxAPI.kt
Created July 19, 2022 04:20
Api with Obserable
package com.example.kotlintutorial.application.network
import com.example.kotlintutorial.dataModel.model.RxBannerResponse
import com.example.kotlintutorial.dataModel.model.RxCountryBanner
import io.reactivex.rxjava3.core.Observable
import retrofit2.http.GET
interface RxAPI {
package com.example.kotlintutorial.presentation.view.adapter
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.kotlintutorial.dataModel.model.CountryBanner
@ankitchauhan20
ankitchauhan20 / AdapterBinding
Created July 12, 2022 06:47
AdapterBinding
package com.example.kotlintutorial
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.kotlintutorial.databinding.DataItemBinding
class BannerAdapter(var list: ArrayList<CountryBanner>) : RecyclerView.Adapter<BannerAdapter.ViewHolder>() {
@ankitchauhan20
ankitchauhan20 / ApiClient.kt
Created June 29, 2022 10:21
Retrofit Get In Kotlin
package com.example.kotlintutorial
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class ApiClient {
package com.example.oopstutorial.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;