Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

android - Firebase sort by points depending on date

I am trying to add a monthly scoreboard but it seems to be a little bit difficult to me. I don't know how to just take a specific value to some list or array. Like Date, only date with 09.01.2017 values. If I could do that then I think that I can sort them by value.

enter image description here

        FirebaseDatabase database = FirebaseDatabase.getInstance();
    final DatabaseReference highscoreRef = database.getReference();




    // Ordering with score and adding key values as string to nameList and scoreList
    highscoreRef.orderByChild("score").limitToLast(10).addChildEventListener(new ChildEventListener() {
        @Override
        public void onChildAdded(DataSnapshot snapshot, String previousChildKey) {
            try {

                nameList.push(snapshot.child("name").getValue().toString());
                scoreList.push(snapshot.child("score").getValue().toString());

            } catch (Exception e) {
                //Toast.makeText(getApplicationContext(), "Error fetching data.", Toast.LENGTH_SHORT).show();
            }
        }
        @Override
        public void onChildChanged(DataSnapshot dataSnapshot, String s) {

        }
        @Override
        public void onChildRemoved(DataSnapshot dataSnapshot) {

        }
        @Override
        public void onChildMoved(DataSnapshot dataSnapshot, String s) {

        }
        @Override
        public void onCancelled(DatabaseError databaseError) {
            Toast.makeText(getApplicationContext(), "Error sending data.", Toast.LENGTH_LONG).show();
        }

    });
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...