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
import 'dart:async'; | |
import 'package:dio/dio.dart'; | |
import 'package:flutter/cupertino.dart'; | |
/// [LoggingInterceptor] is used to print logs during network requests. | |
/// It's better to add [LoggingInterceptor] to the tail of the interceptor queue, | |
/// otherwise the changes made in the interceptor behind A will not be printed out. | |
/// This is because the execution of interceptors is in the order of addition. | |
class LoggingInterceptor extends Interceptor { |
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
import "package:flutter/material.dart"; | |
import 'package:flutter/services.dart'; | |
import 'dart:math'; | |
const CURVE_HEIGHT = 160.0; | |
const AVATAR_RADIUS = CURVE_HEIGHT * 0.28; | |
const AVATAR_DIAMETER = AVATAR_RADIUS * 2; | |
void main() => runApp(new MyApp()); |
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
<?xml version="1.0" encoding="utf-8"?><!-- | |
~ Use Extended FAB on Android even if Material Components doesn't support it yet | |
~ See https://github.com/material-components/material-components-android/issues/79 | |
~ | |
~ Created by Simone Sestito | |
--> | |
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> |
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
/** | |
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | |
* already been handled. | |
* | |
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | |
*/ | |
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | |
override fun onChanged(event: Event<T>?) { | |
event?.getContentIfNotHandled()?.let { value -> | |
onEventUnhandledContent(value) |
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
/** | |
* Used as a wrapper for data that is exposed via a LiveData that represents an event. | |
*/ | |
open class Event<out T>(private val content: T) { | |
var hasBeenHandled = false | |
private set // Allow external read but not write | |
/** | |
* Returns the content and prevents its use again. |
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
import android.os.Bundle | |
import android.util.Log | |
import android.view.ViewGroup | |
import android.widget.TextView | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.databinding.DataBindingUtil | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleObserver | |
import androidx.lifecycle.OnLifecycleEvent | |
import app.keima.android.recyclerviewsandbox.databinding.ActivityMainBinding |
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
// This is a super simplified example of how to use the new dagger.android framework | |
// introduced in Dagger 2.10. For a more complete, in-depth guide to dagger.android | |
// read https://proandroiddev.com/how-to-android-dagger-2-10-2-11-butterknife-mvp-part-1-eb0f6b970fd | |
// For a complete codebase using dagger.android 2.11-2.17, butterknife 8.7-8.8, and MVP, | |
// see https://github.com/vestrel00/android-dagger-butterknife-mvp | |
// This example works with Dagger 2.11-2.17. Starting with Dagger 2.11, | |
// @ContributesAndroidInjector was introduced removing the need to define @Subcomponent classes. |