Skip to content

Instantly share code, notes, and snippets.

View jdsingh's full-sized avatar
🎯
Focusing

Jagdeep Singh jdsingh

🎯
Focusing
View GitHub Profile
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
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
val papertrailTree = PapertrailTree(
"MyLogger", "MyApp", PAPERTRAIL_HOST, PAPERTRAIL_PORT
)
Timber.plant(papertrailTree)
}
0476a229ff21e49aef5e85739b00af6461ef067fbc2adb4b0a2f96b963a1560533ce8ad9d2602873384cf57729bdd94dd67473b55615d134de44e9b30dd8d44eed mirzap
@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" />
@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 / 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 / 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 / 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 / DownloadManagerResolver.java
Created March 1, 2017 18:00 — forked from Folyd/DownloadManagerResolver.java
A helper class to detect whether DownloadManager is disabled in Android device,if true show AlertDialog to tell user to enable it.
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatTextView;
@jdsingh
jdsingh / RxFirebase.java
Created February 24, 2017 12:41 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
package com.firebase.client;
import com.firebase.client.core.Constants;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.subscriptions.Subscriptions;
public class RxFirebase {