Skip to content

Instantly share code, notes, and snippets.

View Dadoufi's full-sized avatar

Konstantinos Tsantoulas Dadoufi

View GitHub Profile
@Dadoufi
Dadoufi / CustomSemantics.kt
Created September 6, 2024 11:29 — forked from gnumilanix/CustomSemantics.kt
Compose custom semantics with multiple matchers
import androidx.compose.ui.semantics.SemanticsPropertyKey
import androidx.compose.ui.semantics.SemanticsPropertyReceiver
val DrawableId = SemanticsPropertyKey<List<Int>>(
name = "DrawableResId",
mergePolicy = mergeSemantics()
)
var SemanticsPropertyReceiver.drawableId: Int
get() = throwSemanticsGetNotSupported()
@Dadoufi
Dadoufi / SmoothListAdapter.kt
Created December 6, 2020 07:23 — forked from polson/SmoothListAdapter.kt
A ListAdapter that pre-caches its views on creation
class SmoothListAdapter(val context: Context) : ListAdapter<ListItem, ListItemViewHolder>(MyDiffCallback()) {
data class ListItem(val id: String, val text: String)
class ListItemViewHolder(view: View) : ViewHolder(view) {
fun populateFrom(listItem: ListItem) {
//TODO: populate your view
}
}
@Dadoufi
Dadoufi / KotlinRxJava2CallAdapterFactory.kt
Created January 28, 2019 22:15 — forked from naturalwarren/KotlinRxJava2CallAdapterFactory.kt
A CallAdapterFactory capable of creating NetworkResponse instances.
/**
* A [CallAdapter.Factory] which allows [NetworkResponse] objects to be
* returned from RxJava streams created by Retrofit.
*
* Adding this class to [Retrofit] allows you to write service methods like:
*
* fun getTokens(): Single<NetworkResponse<AccessToken,Error>>
*/
class KotlinRxJava2CallAdapterFactory : CallAdapter.Factory() {
@Dadoufi
Dadoufi / build.gradle
Created December 27, 2018 11:50 — forked from gabrielemariotti/build.gradle
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
package com.degordian.common.data.retrofit
import android.util.Log
import io.reactivex.*
import retrofit2.Call
import retrofit2.CallAdapter
import retrofit2.HttpException
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import java.io.IOException
@Dadoufi
Dadoufi / CookieJarManager.kt
Created December 27, 2018 07:17 — forked from oligazar/CookieJarManager.kt
1. RetrofitException 2. RxErrorHandlingCallAdapterFactory 3. YourRetrofitBuilder 4. RetrofitBuilder 5. RetrofitManager 6. CookieManager 7. SingletonHolder 8. Injector 9. RetrofitHelpers
/**
* Handles cookies for retrofit requests
*
* https://github.com/franmontiel/PersistentCookieJar
* http://codezlab.com/add-cookies-interceptor-using-retrofit-android/
* https://gist.github.com/nikhiljha/52d45ca69a8415c6990d2a63f61184ff
* https://gist.github.com/tsuharesu/cbfd8f02d46498b01f1b
*/
class CookieJarManager {
companion object: SingletonHolder<Context, PersistentCookieJar>(
@Dadoufi
Dadoufi / ObservableLceFilterDelay.kt
Created November 9, 2018 21:10 — forked from dimsuz/ObservableLceFilterDelay.kt
RxJava2 operator which adjusts items of an LCE (loading-content-error) stream so that L (loading) and C/E (content/error) items are not emitted close to each other. This is a reactive state alternative to Android's ContentLoadingProgressBar: https://developer.android.com/reference/android/support/v4/widget/ContentLoadingProgressBar.html
package com.dimsuz.lcefilterdelay
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.Observer
import io.reactivex.Scheduler
import io.reactivex.disposables.Disposable
import io.reactivex.exceptions.Exceptions
import io.reactivex.internal.disposables.DisposableHelper
import io.reactivex.internal.fuseable.SimpleQueue
class BottomNavigationBehavior<V : View>(context: Context, attrs: AttributeSet) :
CoordinatorLayout.Behavior<V>(context, attrs) {
override fun layoutDependsOn(parent: CoordinatorLayout?, child: V, dependency: View?): Boolean {
if (dependency is Snackbar.SnackbarLayout) {
updateSnackbar(child, dependency)
}
return super.layoutDependsOn(parent, child, dependency)
}
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Single;
import io.reactivex.SingleSource;
import io.reactivex.annotations.NonNull;
@Dadoufi
Dadoufi / Preferences.kt
Created May 17, 2017 05:53 — forked from wispborne/Preferences.kt
Android SharedPreferences helper class for Kotlin. Easy-to-use delegated properties, automatic database creation, and listening for property changes.
import android.content.Context
import android.content.SharedPreferences
import kotlin.reflect.KProperty
/**
* Represents a single [SharedPreferences] file.
*
* Usage:
*