🤵♂️
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
| suspend fun <T> retryIO( | |
| times: Int = Int.MAX_VALUE, | |
| initialDelay: Long = 100, // 0.1 second | |
| maxDelay: Long = 1000, // 1 second | |
| factor: Double = 2.0, | |
| block: suspend () -> T): T | |
| { | |
| var currentDelay = initialDelay | |
| repeat(times - 1) { | |
| try { |
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
| // edit /home/.bashrc and add the following lines | |
| JAVA_HOME='/home/raghu/jdk1.8.0_241' | |
| export JAVA_HOME | |
| export PATH=$PATH:$JAVA_HOME/bin | |
| FLUTTER_HOME='/home/raghu/flutter' | |
| export FLUTTER_HOME | |
| export PATH=$PATH:$FLUTTER_HOME/bin | |
| ANDROID_SDK_ROOT='/home/raghu/Android/Sdk' |
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 me.raghu.mvpassignment.util | |
| import androidx.recyclerview.widget.DiffUtil | |
| import androidx.recyclerview.widget.ListUpdateCallback | |
| import androidx.recyclerview.widget.RecyclerView | |
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.channels.Channel.Factory.CONFLATED | |
| import kotlinx.coroutines.channels.actor | |
| import java.util.* |
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
| import android.animation.Animator | |
| import android.animation.ObjectAnimator | |
| import android.animation.ValueAnimator.AnimatorUpdateListener | |
| import android.content.Context | |
| import android.content.res.Resources | |
| import androidx.core.widget.NestedScrollView | |
| import android.util.AttributeSet | |
| import android.util.Log | |
| import android.view.MotionEvent | |
| import android.view.View |
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
| import android.text.TextUtils; | |
| import org.jetbrains.annotations.NotNull; | |
| import java.io.IOException; | |
| import java.util.concurrent.TimeUnit; | |
| import okhttp3.Interceptor; | |
| import okhttp3.OkHttpClient; |
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
| final OkHttpClient client = new OkHttpClient.Builder() | |
| . authenticator(new Authenticator() { | |
| @Override public Request authenticate(Route route, Response response) throws IOException { | |
| if (response.request().header("Authorization") != null) { | |
| return null; // Give up, we've already attempted to authenticate. | |
| } | |
| String credential = Credentials.basic("jesse", "password1"); | |
| return response.request().newBuilder() | |
| .header("Authorization", credential) | |
| .build(); |
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
| @Override | |
| public void onBackPressed() { | |
| if(mDrawerLayout.isDrawerOpen(GravityCompat.START)) { | |
| mDrawerLayout.closeDrawers(); | |
| } | |
| else if (getSupportFragmentManager().getBackStackEntryCount() > 0) { | |
| String fragmentTag = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1).getName(); | |
| if (fragmentTag.equals("dashboard")) { | |
| //Toast.makeText(this.getApplicationContext(),""+fragmentTag,Toast.LENGTH_SHORT).show(); | |
| finish(); |
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
| class class RetrofitDependency : RetrofitInterface { | |
| override fun provideRetrofit(): Retrofit { | |
| val logging = HttpLoggingInterceptor() | |
| logging.level = HttpLoggingInterceptor.Level.BASIC | |
| val okHttpClient = OkHttpClient.Builder() | |
| .addInterceptor(logging) | |
| .connectTimeout(10, TimeUnit.SECONDS) | |
| .writeTimeout(10, TimeUnit.SECONDS) | |
| .readTimeout(30, TimeUnit.SECONDS) |
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
| interface RetrofitInterface { | |
| fun provideRetrofit(): Retrofit | |
| } |
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
| class ListRepositoryImpl(private val retrofitDependency: RetrofitDependency): ListRepository { | |
| var data = MutableLiveData<List<Users>>() | |
| override fun getUsers(): MutableLiveData<List<Users>>{ | |
| val service = retrofitDependency.provideRetrofit().create(Api::class.java) | |
| service.users.enqueue(object : Callback<List<Users>> { | |
| override fun onResponse(call: Call<List<Users>>, response: Response<List<Users>>) { | |
| if (response.isSuccessful) { |