Skip to content

Instantly share code, notes, and snippets.

View jdsingh's full-sized avatar
🎯
Focusing

Jagdeep Singh jdsingh

🎯
Focusing
View GitHub Profile
@jdsingh
jdsingh / RxFirebase.java
Created May 3, 2017 08:58 — forked from TinasheMzondiwa/RxFirebase.java
RxFirebase implementation. Fork from https://gist.github.com/gsoltis/86210e3259dcc6998801 with my improvements.
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import rx.Observable;
import rx.Subscriber;
@jdsingh
jdsingh / ItemClickSupport.java
Created May 19, 2017 19:01 — forked from nesquena/ItemClickSupport.java
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});
@jdsingh
jdsingh / PhonecallReceiver.java
Created May 30, 2017 17:37 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@jdsingh
jdsingh / RealmBackupRestore.java
Created July 3, 2017 12:57 — forked from paolorotolo/RealmBackupRestore.java
Class to easily backup/restore data from Realm.
package org.glucosio.android.tools;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.widget.Toast;
@jdsingh
jdsingh / default.xml
Created July 12, 2017 12:29 — forked from Judas/default.xml
Repo configuration file
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="origin" fetch="https://github.com/yourorg" />
<default remote="origin" revision="develop" />
<project remote="origin" name="mobile-android-authentication-ui" path="modules/authentication-ui" />
<project remote="origin" name="mobile-android-conversation-ui" path="modules/conversation-ui" />
<project remote="origin" name="mobile-android-livefeed-ui" path="modules/livefeed-ui" />
<project remote="origin" name="mobile-android-stats-ui" path="modules/stats-ui" />
<project remote="origin" name="mobile-android-user-profile-ui" path="modules/user-profile-ui" />
0476a229ff21e49aef5e85739b00af6461ef067fbc2adb4b0a2f96b963a1560533ce8ad9d2602873384cf57729bdd94dd67473b55615d134de44e9b30dd8d44eed mirzap
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
val papertrailTree = PapertrailTree(
"MyLogger", "MyApp", PAPERTRAIL_HOST, PAPERTRAIL_PORT
)
Timber.plant(papertrailTree)
}
fun outerFunction(nice: String) {
val hello = "Hello, world"
fun innerFunction(awesome: String) {
println(awesome)
// we can access arguments of outer function
println(nice)
// and we can also access variables declared in outer functions
infix fun String.shouldBeSame(other: String) = this == other
// calling the function using the infix notation
"bello" shouldBeSame "bello"
// is the same as
"hello".shouldBeSame("hello")
"substring" should include("str")
user.email should beLowerCase()
a + b shouldBe result