Skip to content

Instantly share code, notes, and snippets.

View sevar83's full-sized avatar

Svetlozar Kostadinov sevar83

View GitHub Profile
@JvmName
JvmName / Android CI
Created October 28, 2014 23:57
Android CI
#Android and CI and Gradle (A How-To)
There are tech stacks in this world that make it dead simple to integrate a <abbr title="Continuous Integration">CI</abbr> build system. <br>
The Android platform is not one of them.
Although Gradle is getting better, it's still a bit non-deterministic, and some of the fixes you'll need will start to feel more like black magic than any sort of programming.
But fear not! It can be done!
Before we embark on our journey, you'll need a few things to run locally:
class FooActivity extends MviActivity<...> {
@Inject FooPresenter
public void onCreate(Bundle bundle){
super.onCreate(bundle);
FooComponent component = DaggerFooComponent.builder()
.fooModule(new FooModule(bundle))
.build();
component.inject(this);
@internetmosquito
internetmosquito / gist:b1c1f00ac99d9aa1f79cfdc21be36b5b
Last active June 11, 2018 10:32
How to encode images for Google Cloud Vision
images_names = list()
for iterator, image_file in enumerate(images):
image_path = os.path.join(folder_name, image_file)
images_names.append(self.path_leaf(image_path))
self.images_names.append(self.path_leaf(image_path))
with open(image_path, 'rb') as image:
image_content = base64.b64encode(image.read())
image_payload = {}
image_payload['image'] = {}
image_payload['image']['content'] = image_content.decode('UTF-8')
  • 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
@wispborne
wispborne / ViewOnceData.kt
Last active October 3, 2018 08:14
A class that encapsulates data, adding ability to know when the data has already been viewed. Useful for putting one-shot events, like "display dialog", into a State object that can be reapplied to a view.
import java.util.concurrent.atomic.AtomicBoolean
/**
* Wraps some data that should track when it has been viewed and allow future viewers to avoid a second showing.
* Useful for showing messages in the app that auto-hide because this class can exist in the app's state.
*/
data class ViewOnceData<T>(private val data: T) {
val wasViewed = AtomicBoolean(false)
/**
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AutoCompleteTextView;
/**
* Created by PasiMatalamaki on 7.9.2015.
@dustin-graham
dustin-graham / ApiService.java
Created February 15, 2015 06:17
Infinite Scrolling Android RecyclerView with RxJava
public static Observable<List<String>> paginatedThings(final Observable<Void> onNextObservable) {
return Observable.create(new Observable.OnSubscribe<List<String>>() {
@Override
public void call(final Subscriber<? super List<String>> subscriber) {
onNextObservable.subscribe(new Observer<Void>() {
int latestPage = -1;
@Override
public void onCompleted() {
subscriber.onCompleted();
@vestrel00
vestrel00 / Dagger2SimpleExample.java
Last active October 7, 2021 19:59
A: Dagger.android 2.11 simple example with support for Singleton, PerActivity, PerFragment, and PerChildFragment scopes
// 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.
@meoyawn
meoyawn / EmptyRecyclerView.java
Created November 1, 2014 11:20
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;
@yanngx
yanngx / FragmentArgumentDelegate.kt
Last active January 19, 2023 09:26
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created