This file contains 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
private ObservableManager obsManager = new ObservableManager(EventBus.getDefault()); | |
@Override | |
public Subscription getStores() { | |
// Get the observable if exists and is not too old | |
Observable<StoresList> observable = obsManager.get(ObservableManager.Types.STORES); | |
if (observable == null) { | |
// If is null create it and us cache to keep it in memeroy | |
observable = api.getStoresList() | |
.compose(applySchedulers(api.getStoresList())) |
This file contains 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 com.eatfirst.android.ui.custom; | |
/** | |
* Copyright 2015 Bartosz Lipinski | |
* | |
* 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 |
This file contains 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
/* | |
* Copyright (c) 2015 Express Quality Food Global Service GmbH. All rights reserved. | |
* | |
* 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 |
This file contains 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 com.eatfirst.android.utils; | |
import android.support.design.widget.TextInputLayout; | |
import java.util.concurrent.TimeUnit; | |
import rx.Observable; | |
import rx.android.schedulers.AndroidSchedulers; | |
import rx.android.widget.OnTextChangeEvent; | |
import rx.android.widget.WidgetObservable; | |
import rx.functions.Func1; |
This file contains 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
dependencies { | |
// Kotlin | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |
// Views | |
implementation 'com.android.support:appcompat-v7:27.1.1' | |
implementation 'com.android.support.constraint:constraint-layout:1.1.0' | |
// Network | |
implementation 'com.squareup.retrofit2:retrofit:2.4.0' |
This file contains 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 com.here.example.weather | |
import retrofit2.Call | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface WeatherApi { | |
@GET("/weather/1.0/report.json?app_id={YOUR_APP_ID}&app_code={YOUR_APP_CODE}") | |
fun getObservations(@Query("product") product: String, |
This file contains 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
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build() | |
val retrofit = Retrofit.Builder() | |
.baseUrl("https://weather.api.here.com") | |
.addConverterFactory(MoshiConverterFactory.create(moshi)) | |
.build() | |
weatherApi = retrofit.create(WeatherApi::class.java) |
This file contains 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
sealed class ApiResponse<out T, out S> { | |
data class Success<out T>(val result: T) : ApiResponse<T, Any>() | |
data class Failure<out T, out S>(val code: Int, val errorBody: S? = null) : ApiResponse<T, S>() | |
data class Exception<out T, out S>(val throwable: Throwable) : ApiResponse<T, S>() | |
} |
This file contains 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"> | |
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script> | |
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style> | |
<body> | |
<div style="max-width:900px; -webkit-transform:rotate(0deg)"> | |
<scene id="scene1"> | |
<label t="translate(0,346)"> |
This file contains 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 NetworkFactory(moshi: Moshi, authInterceptor: AuthenticationInterceptor, authenticator: Authenticator) { | |
private val okHttpClient: OkHttpClient | |
private val retrofitBuilder: Retrofit.Builder | |
init { | |
val level = if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE | |
val loggingInterceptor = HttpLoggingInterceptor().setLevel(level) | |
okHttpClient = OkHttpClient.Builder() |
OlderNewer