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
@file:Suppress("NOTHING_TO_INLINE") | |
package net.aquadc.commonandroid.views | |
import android.content.Context | |
import android.view.View | |
import android.widget.RelativeLayout | |
import android.widget.RelativeLayout.TRUE | |
import androidx.annotation.IdRes | |
import splitties.views.dsl.core.wrapContent | |
import kotlin.contracts.ExperimentalContracts |
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 net.aquadc.commonandroid.views | |
import android.annotation.SuppressLint | |
import android.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.drawable.BitmapDrawable | |
import android.graphics.drawable.ColorDrawable | |
import android.graphics.drawable.Drawable | |
import android.graphics.drawable.TransitionDrawable | |
import android.view.View |
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 net.aquadc.commonandroid.lists; | |
import android.graphics.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
public class FirstLastItemSpacesDecoration extends RecyclerView.ItemDecoration { | |
private final int directSpace; | |
private final int reverseSpace; |
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) 2008 The Android Open Source Project | |
* | |
* 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 net.aquadc.util; | |
import java.util.Comparator; | |
import java.util.Objects; | |
import java.util.Optional; | |
import java.util.stream.Collector; | |
/** | |
* Stats of a stream of objects, including {@linkplain #size()}, {@linkplain #min()}, and {@linkplain #max()}. | |
* <p>This is intended to be used with {@link java.util.stream.Stream#collect}, for example</p> |
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 java.util.Collection; | |
import java.util.Comparator; | |
import java.util.Deque; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.ListIterator; | |
import java.util.NavigableSet; | |
import java.util.Queue; | |
import java.util.Set; | |
import java.util.SortedSet; |
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
// Java(?) way | |
interface Fraction<E extends Exception> { | |
int numerator() throws E; | |
int denominator() throws E; | |
} | |
class FracStatic implements Fraction<RuntimeException> // don't force catching | |
class FracSum<E1, E2> implements Fraction<EitherException<E1, E2>> // impossible due to type erasure | |
// Kotlin, Scala, Rust way |
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 net.aquadc.util; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.List; | |
/** | |
* For lists with O(n) random-deletion time (array-based lists, like {@link ArrayList}), | |
* it's faster to mark items as removed and them sweep them all together. |
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 net.aquadc.util; | |
import java.io.IOException; | |
import java.io.UncheckedIOException; | |
import java.util.Iterator; | |
import java.util.function.Consumer; | |
import java.util.stream.Stream; | |
public final class Iterators { | |
private Iterators() {} |
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.Handler; | |
import android.os.Looper; | |
import androidx.annotation.WorkerThread; | |
import java.io.File; | |
import java.util.Collections; | |
import java.util.HashSet; | |
import java.util.Set; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.Executor; |