Skip to content

Instantly share code, notes, and snippets.

View jerryOkafor's full-sized avatar

Jerry Hanks Okafor jerryOkafor

View GitHub Profile
@jerryOkafor
jerryOkafor / FileChooser.java
Created April 23, 2016 09:04
This gist is to enable you select, or choose a file, stringfy it and uplaod to server
package com.dipoletech.unnmobile;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Color;
@jerryOkafor
jerryOkafor / MessagingEndpoint.java
Created June 18, 2016 00:49
This will show u how to send the messages
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Backend with Google Cloud Messaging" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/GcmEndpoints
*/
package com.dotdex.squattn;
import com.dotdex.squattn.models.RegistrationRecord;
import com.dotdex.squattn.util.Utility;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
{
"Key2" : "Value2",
"key1" : 12,
"key3" : 12.09,
"key4" : 198376475886432
}
public class FirebaseQuery {
//Build a key value Pair
public Map<String, Object> getKeyValuePair(){
Object obj = new Object();
Map<String, Object> keyValuePair = new HashMap<>();
keyValuePair.put("key1","This is a string value"); //a string value
keyValuePair.put("key2",12); //an integer value
{
"members" : {
"kZDqscQARJVmdYMad9ndJ7X5kmo2" : 100,
"kZDqscQARJVmdYMad9ndJ7X5kmo3" : 200,
"kZDqscQARJVmdYMad9ndJ7X5kmo4" : 200,
"kZDqscQARJVmdYMad9ndJ7X5kmo4" : 100
},
"schoolId" : "-KWJUc2ylvhO02VfVImh",
"schoolName" : "University of Nigeria Nsukka ",
"setAdmin" : "kZDqscQARJVmdYMad9ndJ7X5kmo2",
public static class QuerySetByMembers{
public void querySet(String memberId)
{
Query queryByMember = FirebaseDatabase.getInstance().getReference().child("sets").orderByChild("members/"+memberId);
queryByMember.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Not that we are returning a list as our query is on sets
//so iterate through the datasnapshot and get the values
for (DataSnapshot data : dataSnapshot.getChildren())
public void querySet(String memberId)
{
Query queryByMember = FirebaseDatabase.getInstance().getReference().child("sets").orderByChild("members/"+memberId).endAt(200);
queryByMember.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Not that we are returning a list as our query is on sets
//so iterate through the datasnapshot and get the values
for (DataSnapshot data : dataSnapshot.getChildren())
{
public void querySet(String memberId)
{
Query queryByMember = FirebaseDatabase.getInstance().getReference().child("sets").orderByChild("members/"+memberId).startAt(300);
queryByMember.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Not that we are returning a list as our query is on sets
//so iterate through the datasnapshot and get the values
for (DataSnapshot data : dataSnapshot.getChildren())
{
@jerryOkafor
jerryOkafor / sets.json
Created December 3, 2016 06:57
This is a sample .json data for my blog post.
{
"-KXAlZM_-wGb6VtDWaXi" : {
"members" : {
"93O9tc5SebdZEOtei8tiTN8JQRt2" : 100,
"KUwDuuo9zqR0EfAQD5DdGMI3MnS2" : 200,
"L9qJXkjvsfRLip5Awg0yhJLcmJb2" : 500
},
"schId" : "-KXAlZMY1cwVaekwtqm2",
"schName" : "University of Nigeria Nsukka",
"setAdmin" : "KUwDuuo9zqR0EfAQD5DdGMI3MnS2",