Skip to content

Instantly share code, notes, and snippets.

View rallat's full-sized avatar
🏠
Working from home

Israel Ferrer Camacho rallat

🏠
Working from home
View GitHub Profile
@chrisbanes
chrisbanes / ScopedViewModel.kt
Last active October 2, 2024 04:13
ScopedViewModel
open class ScopedViewModel : ViewModel() {
private val job = Job()
protected val scope: CoroutineScope = job + Dispatchers.Main
override fun onCleared() {
super.onCleared()
job.cancel()
}
}
@FedericoPonzi
FedericoPonzi / big-o-java-collections.md
Last active November 15, 2024 11:57
Big O notation for java's collections

The book Java Generics and Collections has this information (pages: 188, 211, 222, 240).

List implementations:

                      get  add  contains next remove(0) iterator.remove
ArrayList             O(1) O(1) O(n)     O(1) O(n)      O(n)
LinkedList O(n) O(1) O(n) O(1) O(1) O(1)
@saxophone
saxophone / ResultTestActivity.java
Last active October 13, 2020 14:43
Use Android Espresso to test that your Activity finishes with the expected result.
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static org.hamcrest.MatcherAssert.assertThat;
@artem-zinnatullin
artem-zinnatullin / build.gradle
Last active November 9, 2019 23:19
Android Unit tests logging configuration
android {
// ...
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
import java.lang.ref.WeakReference;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
public abstract class WeakCallback<T, C> implements Callback<T> {
private final WeakReference<C> context;
@efrohnhoefer
efrohnhoefer / VerifyCredentialsController.scala
Last active July 11, 2016 13:21
Code demonstrating call to verify_credentials API using OAuth Echo. Written in Scala on the Play Framework.
package controllers
import play.api.libs.ws.WS
import play.api.mvc.{Action, Controller}
import scala.concurrent.Future
class VerifyCredentialsController extends Controller {
implicit val context = scala.concurrent.ExecutionContext.Implicits.global
@JakeWharton
JakeWharton / 19.1.0_to_20.0.0.diff
Last active August 29, 2015 14:03
Public API changes between support-v4 19.1.0 to 20.0.0. Created with https://github.com/JakeWharton/jardiff
diff -U 0 -N support-v4-19.1.0/android.support.v4.BuildConfig support-v4-20.0.0/android.support.v4.BuildConfig
--- support-v4-19.1.0/android.support.v4.BuildConfig 1969-12-31 16:00:00.000000000 -0800
+++ support-v4-20.0.0/android.support.v4.BuildConfig 2014-06-26 19:59:59.000000000 -0700
@@ -0,0 +1,9 @@
+public final class android.support.v4.BuildConfig {
+ public static final boolean DEBUG;
+ public static final java.lang.String PACKAGE_NAME;
+ public static final java.lang.String BUILD_TYPE;
+ public static final java.lang.String FLAVOR;
+ public static final int VERSION_CODE;
@dmarcato
dmarcato / strip_play_services.gradle
Last active December 21, 2022 10:10
Gradle task to strip unused packages on Google Play Services library
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@grantland
grantland / post.md
Last active February 9, 2023 05:09
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder