Skip to content

Instantly share code, notes, and snippets.

View miroslavign's full-sized avatar

Miroslav Ignjatovic miroslavign

View GitHub Profile
@miroslavign
miroslavign / EndlessRecyclerOnScrollListener.java
Created January 16, 2016 18:01 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@miroslavign
miroslavign / RoundedQuickContactBadge
Created January 20, 2016 09:55 — forked from kishu27/RoundedQuickContactBadge
Just a quick and dirty method to get a rounded QuickContactBadge
/**
* A rounded version of {@link QuickContactBadge]
* @author kishu27 (http://linkd.in/1laN852)
*
*/
public class RoundedQuickContactBadge extends QuickContactBadge {
/**
* This path is used to mask out the outer edges of a circle on this View
*/
@miroslavign
miroslavign / NotificationExamplesMainActivity
Created January 27, 2016 00:44 — forked from waynepiekarski/NotificationExamplesMainActivity
Example of using stack and page notifications with the Android Wear SDK
package testing.blog.waynepie.blogtesting;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import com.squareup.picasso.Transformation;
public class CircleTransform implements Transformation {
private final int BORDER_COLOR = Color.WHITE;
@miroslavign
miroslavign / AndroidManifest.xml
Created December 27, 2016 13:23 — forked from vikrum/AndroidManifest.xml
Firebase+Android sample app with background Service + local notifications.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bgfirebaseapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="17" />
private void setUpSearchQuerySubscription2(){
Subscription searchQuerySubscription = searchQueryChangeObservable
.doOnNext(new Action1<CharSequence>() {
@Override
public void call(CharSequence charSequence) {
searchProgressBar.setVisibility(View.INVISIBLE);
}
})
.debounce(400, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
PublishRelay<Integer> publishRelay = PublishRelay.create();
Observable<Integer> relayObservable = publishRelay
.doOnSubscribe(() -> {
Log.i("RxExperiments", "ReplayingShare->doOnSubscribe");
// Register to event here...
}).doOnUnsubscribe(() -> {
Log.i("RxExperiments", "ReplayingShare->doOnUnsubscribe");
// Un-register from event here...
})
.compose(ReplayingShare.instance());
@miroslavign
miroslavign / Observables
Created March 13, 2017 18:27
All RX android related
from
http://blog.danlew.net/2015/06/22/loading-data-from-multiple-sources-with-rxjava/
https://github.com/dlew/rxjava-multiple-sources-sample/tree/master/src/main/java/net/danlew/sample
// Our sources (left as an exercise for the reader)
Observable<Data> memory = ...;
Observable<Data> disk = ...;
Observable<Data> network = ...;
// Retrieve the first source with data
/*
* Copyright (C) 2014 [email protected]
*
* 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