Skip to content

Instantly share code, notes, and snippets.

View lawloretienne's full-sized avatar
💭
Check out the surf report app I'm working on https://pitted.app

Etienne Lawlor lawloretienne

💭
Check out the surf report app I'm working on https://pitted.app
View GitHub Profile
@lawloretienne
lawloretienne / EmailSubscription.java
Last active February 29, 2020 16:54
EmailChangeObservable
Subscription emailSubscription =
emailChangeObservable
.doOnNext(new Action1<CharSequence>() {
@Override
public void call(CharSequence charSequence) {
hideEmailError();
}
})
.debounce(400, TimeUnit.MILLISECONDS)
.filter(new Func1<CharSequence, Boolean>() {
object EmailUtils {
fun getEmailIntent(context: Context): Intent {
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"))
val bodyText = getEmailBody(context)
val emailAddy = EMAIL_SUPPORT
val subject = context.resources.getString(R.string.email_subject)
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(emailAddy))
intent.putExtra(Intent.EXTRA_SUBJECT, subject)
intent.putExtra(Intent.EXTRA_TEXT, bodyText)
return intent
package com.getsomeheadspace.android.foundation.utils
// https://proandroiddev.com/briefly-about-rxjava-logging-20308b013e6d
import io.reactivex.*
import timber.log.Timber
inline fun <reified T> printEvent(tag: String, success: T?, error: Throwable?) =
when {
success == null && error == null -> Timber.d("$tag Complete") /* Only with Maybe */
public class RxImageView extends ImageView {
// region Member Variables
private PublishSubject<Boolean> publishSubject = PublishSubject.create();
// endregion
// region Constructors
public RxImageView(Context context) {
super(context);
}
public class RoundedBitmapDrawableUtility {
public static RoundedBitmapDrawable getRoundedSquareBitmapDrawable(Context context, Bitmap originalBitmap, int cornerRadius){
return getRoundedSquareBitmapDrawable(context, originalBitmap, cornerRadius, -1, -1);
}
public static RoundedBitmapDrawable getRoundedSquareBitmapDrawable(Context context, Bitmap originalBitmap, int cornerRadius, int borderWidth, int borderColor){
int originalBitmapWidth = originalBitmap.getWidth();
int originalBitmapHeight = originalBitmap.getHeight();
  • Functional Programming is a model of programming that transform and compose stream of immutable sequences by applying map, filter and reduce. Events are immutable because you can't change history.
  • Reactive Programming is a model of programming focuses on data flow and change propagation.
  • ReactiveX is an API that focuses on asynchronous composition and manipulation of observable streams of data or events by using a combination of the Observer pattern, Iterator pattern, and features of Functional Programming.
  • RxJava is the open-source implementation of ReactiveX in Java.
  • RxJava is a Java VM implementation of ReactiveX (Reactive Extensions): a library for composing asynchronous and event-based programs by using observable sequences.
  • RxAndroid is a lightweight extension to RxJava that providers a Scheduler for Android’s Main Thread, as well as the ability to create a Scheduler that runs on any given Android Handler class.
  • The two main classes are Observable and Subscriber.
  • `O
while true; do
    ./adb shell input swipe 100 400 4000 400 400;
done
  • A dependency is a coupling between two classes usually because one of them uses the other to do something.
  • Dependency injection consists of passing dependencies (inject them) via constructor in order to extract the task of creating modules out from other modules. Objects are instantiated somewhere else and passed as constructor attributes when creating the current object.
  • A dependency injector is another module in our app that is in charge of providing instances of the rest of modules and inject their dependencies. It's responsibility is the creation of modules is localized in a single point in our app, and we have full control over it.
  • Dagger is a dependency injector designed for low-end devices. Most dependency injectors rely on reflection to create and inject dependencies. Reflection is very time consuming on low-end devices, and specially on old android versions. Dagger, however, uses a pre-compiler that creates all the classes it needs to work. That way, no reflection is needed. Dagger is
public class CustomTextView extends AppCompatTextView {
public CustomTextView(Context context) {
super(context);
init(context,null);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}