Skip to content

Instantly share code, notes, and snippets.

View olealgoritme's full-sized avatar
🐧
vim >

Ole Algoritme olealgoritme

🐧
vim >
View GitHub Profile
@olealgoritme
olealgoritme / LoginActivity.java
Created September 29, 2017 13:44 — forked from cutiko/LoginActivity.java
How to customize firebase-ui-auth for Android
public class LoginActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 343;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@olealgoritme
olealgoritme / MainActivity.java
Created September 6, 2017 11:33 — forked from riggaroo/MainActivity.java
Online Presence with Firebase and Android based off article https://firebase.googleblog.com/2013/06/how-to-build-presence-system.html . Read the article as it explains the whole .onDisconnect().removeValue() nicely.
private void initialiseOnlinePresence() {
final DatabaseReference onlineRef = databaseReference.child(".info/connected");
final DatabaseReference currentUserRef = databaseReference.child("/presence/" + userId);
onlineRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Log.d(TAG, "DataSnapshot:" + dataSnapshot);
if (dataSnapshot.getValue(Boolean.class)){
currentUserRef.onDisconnect().removeValue();
currentUserRef.setValue(true);