Skip to content

Instantly share code, notes, and snippets.

View odaridavid's full-sized avatar

David Odari odaridavid

View GitHub Profile
@odaridavid
odaridavid / MainActivity.kt
Created May 31, 2021 13:57
expand_collapse_demo
package com.github.odaridavid.readmore
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.annotation.IdRes
class MainActivity : AppCompatActivity() {
@odaridavid
odaridavid / activity_main.xml
Created May 31, 2021 13:56
expand_collapse
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/descriptionCollapsed"
package com.github.odaridavid.spinner;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
package com.moose.foodies.util
import com.moose.foodies.network.Authenticator
import io.reactivex.schedulers.Schedulers
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
@odaridavid
odaridavid / Authenticator.kt
Created June 30, 2020 14:10
okhhtp header
package com.moose.foodies.network
import com.moose.foodies.FoodiesApplication
import com.moose.foodies.util.PreferenceHelper
import okhttp3.Headers
import okhttp3.Interceptor
import okhttp3.Response
object Authenticator : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
@odaridavid
odaridavid / Useful commands
Last active June 8, 2020 14:39
🔨 Collection of Android CLI commands [To Be Updated]
#Get keystore information including Certificates for release builds
keytool -list -v -keystore ${locationToKeystore/app.jks} -alias ${keystore_alias}
@odaridavid
odaridavid / StarWarsApi.kt
Last active May 27, 2020 04:52
Blog Dynamic Url
interface StarWarsApiService {
@GET("people")
suspend fun searchCharacters(@Query("search") params: String): SearchResponse
@GET
suspend fun getSpeciesDetails(@Url speciesUrl: String): SpecieDetailsResponse
@GET
suspend fun getFilmDetails(@Url filmsUrl: String): FilmDetailsResponse
@odaridavid
odaridavid / Utils.kt
Created May 9, 2020 17:28
Blog Dynamic Url
val String.id: Int
get() =
if (this.isNotBlank() && this.contains("-?\\d+(\\.\\d+)?".toRegex()))
this.replace("[^0-9]".toRegex(), "").toInt()
else -1
@odaridavid
odaridavid / starwarsapi.kt
Last active May 27, 2020 04:54
Blog Dynamic Url
interface StarWarsApiService {
@GET("people")
suspend fun searchCharacters(@Query("search") params: String): SearchResponse
@GET("species/{id}/")
suspend fun getSpeciesDetails(@Path("id") speciesId: Int): SpeciesDetailResponse
@GET("films/{id}/")
suspend fun getFilmDetails(@Path("id") filmsId: Int): FilmDetailResponse