This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twansoftware.invoicemakerpro.adapter; | |
import android.content.Context; | |
import android.support.v7.util.SortedList; | |
import android.support.v7.widget.RecyclerView; | |
import android.support.v7.widget.util.SortedListAdapterCallback; | |
import android.util.Log; | |
import com.firebase.client.ChildEventListener; | |
import com.firebase.client.DataSnapshot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twansoftware.invoicemakerpro.adapter; | |
import android.content.Context; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import java.util.Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class CustomSortFirebaseRecyclerAdapter<T> extends RecyclerView.Adapter implements ChildEventListener { | |
protected Query mRef; | |
private Class<T> mModelClass; | |
private RecyclerQuestionAnswerer<T> mRecyclerQuestionAnswerer; | |
protected SortedList<T> mModels; | |
protected Map<String, T> mModelKeys; | |
private ChildEventListener mListener; | |
protected Context mContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.ViewGroup; | |
import com.firebase.client.ChildEventListener; | |
import com.firebase.client.DataSnapshot; | |
import com.firebase.client.FirebaseError; | |
import com.firebase.client.Query; | |
import java.util.ArrayList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> T loadSynchronous(final Firebase firebaseLocation, Class<T> clazz) { | |
final DataSnapshotWrapper snapshotWrapper = new DataSnapshotWrapper(); | |
final CountDownLatch latch = new CountDownLatch(1); | |
firebaseLocation.addListenerForSingleValueEvent(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
System.out.println("Location loaded"); | |
snapshotWrapper.snapshot = dataSnapshot; | |
latch.countDown(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirebaseDataSnapshotMapper { | |
public static void map(Object object, DataSnapshot dataSnapshot) { | |
try { | |
final Class<?> aClass = object.getClass(); | |
final Field[] fields = aClass.getDeclaredFields(); | |
for (final Field classField : fields) { | |
if (classField.isAnnotationPresent(Firemapped.class)) { | |
classField.setAccessible(true); | |
final Firemapped annotation = classField.getAnnotation(Firemapped.class); | |
final DataSnapshot child = dataSnapshot.child(annotation.firebasePath()); |