create account

Triviums Mobile App (UPDATE: Show Users) by princessdharmy

View this thread on: hive.blogpeakd.comecency.com
· @princessdharmy ·
$10.72
Triviums Mobile App (UPDATE: Show Users)
### Repository
https://github.com/princessdharmy/triviums

### History
- [Triviums Mobile App](https://steemit.com/utopian-io/@princessdharmy/triviums-mobile-app)

## Fixes
One of the major problems Android Developers encounter is *App Crash* with some Exceptions. In order to tackle this problem, here is my implementation:
- Firstly, I added a NetworkBoundResource class `FirestoreResultResponse.java`to encapsulate both the data and state
```Java
public class FirestoreResultResponse {

    Map<String, Object> data;
    String error;

    public FirestoreResultResponse() {
    }

    public FirestoreResultResponse(Map<String, Object> data, String error) {
        this.data = data;
        this.error = error;
    }
}
```
- Secondly, I had some issues while fetching data from Firestore; once there is a bad internet connection, the app crashes. So, in order to avoid the *FirebaseFirestoreException*, I used a try-catch in the `StageRepository.java` class :
```Java
private void fetchProgress(String categoryName, ProgressCallback callback) {
        ...
        docRef.get().addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
            }
            try {
                callback.onCallback(new FirestoreResultResponse(task.getResult().getData(), null));
            } catch (Exception e) {
                if (e instanceof FirebaseFirestoreException) {
                    callback.onCallback(new FirestoreResultResponse(null, e.getLocalizedMessage()));
                }
                e.printStackTrace();
            }
        })
                .addOnFailureListener(error -> {
                    callback.onCallback(new FirestoreResultResponse(null, error.toString()));
                });

    }
```

## New Features
- Show Users
As stated in the roadmap of my previous post, it's somewhat interesting to know how many people are playing the game you are involved in. So, I decided to get and display all users that are using the app or playing the game.

<center>![](https://cdn.steemitimages.com/DQme93ndHemqVadUkezp7nUNE1uS3SZCzzDacwyTD4t1YCj/image.png)</center>

*Implementation*
- This code snippet fetches all the users in the database - Firestore in the `LeaderboardRepository.java`
```Java
private void fetchUsers(UserCallback callback){

        CollectionReference collection = firestore.collection("users");

        collection.get().addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                document = task.getResult().getDocuments();
            }
            try {
                callback.onCallback(document);
            } catch (Exception e) {
                if (e instanceof FirebaseFirestoreException) {

                }
                e.printStackTrace();
            }
        })
                .addOnFailureListener(error -> {

                });
    }
```

- The `LeaderboardFragment.java` class gets the user data and display
```Java
public void getUsers() {
        viewModel.getUsers().observe(getViewLifecycleOwner(), response -> {
            binding.loader.setVisibility(View.GONE);
            binding.peopleRecyclerview.setVisibility(View.VISIBLE);
            if (response != null) {
                adapter.updateData(response);
            }
        });

    }
```

## Important resources
- [Github Repo](https://github.com/princessdharmy/triviums)
- [Pull Request](https://github.com/princessdharmy/triviums/pull/16)
- [Apk file](https://github.com/princessdharmy/triviums/releases/tag/1.01)
- [Playstore](https://play.google.com/store/apps/details?id=com.app.horizon)

## Roadmap
- Leaderboard implementation:
~~Display all users~~
  Add users to compete
  Remove users from competition
- Display of users' quiz achievements
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 77 others
πŸ‘Ž  
properties (23)
authorprincessdharmy
permlinktriviums-mobile-app-update-show-users
categoryutopian-io
json_metadata{"tags":["utopian-io","development","open-source","android","quiz"],"image":["https://cdn.steemitimages.com/DQme93ndHemqVadUkezp7nUNE1uS3SZCzzDacwyTD4t1YCj/image.png"],"links":["https://github.com/princessdharmy/triviums","https://steemit.com/utopian-io/@princessdharmy/triviums-mobile-app","https://github.com/princessdharmy/triviums/pull/16","https://github.com/princessdharmy/triviums/releases/tag/1.01","https://play.google.com/store/apps/details?id=com.app.horizon"],"app":"steemit/0.1","format":"markdown"}
created2018-12-03 20:33:51
last_update2018-12-03 20:33:51
depth0
children8
last_payout2018-12-10 20:33:51
cashout_time1969-12-31 23:59:59
total_payout_value8.171 HBD
curator_payout_value2.547 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,736
author_reputation3,142,320,977,108
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,311,491
net_rshares17,677,777,155,021
author_curate_reward""
vote details (142)
@codingdefined ·
$9.71
Thank you for your contribution. A nice little update to the project and its good to see you are continually progressing with the app. Few thoughts : 

1. It's always better not to use path like https://github.com/princessdharmy/triviums/pull/16/files#diff-6889d0299409e1fd2600e5bd55d17c7eR49 but to use relative path.
2. You are showing category even if it is not connected, is that correct? https://github.com/princessdharmy/triviums/pull/16/files#diff-9e6f31efe8684a67503ce75a99bdeeb8R89

----



Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/2332223).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , ,
properties (23)
authorcodingdefined
permlinkre-princessdharmy-triviums-mobile-app-update-show-users-20181205t045011202z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://github.com/princessdharmy/triviums/pull/16/files#diff-6889d0299409e1fd2600e5bd55d17c7eR49","https://github.com/princessdharmy/triviums/pull/16/files#diff-9e6f31efe8684a67503ce75a99bdeeb8R89","https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2332223","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-12-05 04:50:12
last_update2018-12-05 04:50:12
depth1
children4
last_payout2018-12-12 04:50:12
cashout_time1969-12-31 23:59:59
total_payout_value7.343 HBD
curator_payout_value2.362 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length989
author_reputation532,490,077,298,033
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,380,437
net_rshares15,839,207,455,490
author_curate_reward""
vote details (11)
@princessdharmy ·
@codingdefined thank you for your review and comments. 
I would like to comment on your thoughts:
1. I don't understand what the path means, I mean the actual problem.
2. When a user launches the app after installation, it's ideal not to leave the main screen blank or to exit the app because there is no internet connection. So, this is the reason I persisted it in Firestore for offline query. No other action can be performed after this when there is no internet
properties (22)
authorprincessdharmy
permlinkre-codingdefined-re-princessdharmy-triviums-mobile-app-update-show-users-20181205t100641882z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["codingdefined"],"app":"steemit/0.1"}
created2018-12-05 10:06:48
last_update2018-12-05 10:06:48
depth2
children2
last_payout2018-12-12 10:06:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length465
author_reputation3,142,320,977,108
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,390,370
net_rshares0
@codingdefined ·
I am saying that since you are using the full path as C:\...\..., its better to not use like this and usr a relative path.
πŸ‘  
properties (23)
authorcodingdefined
permlinkre-princessdharmy-re-codingdefined-re-princessdharmy-triviums-mobile-app-update-show-users-20181206t085114724z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-12-06 08:51:15
last_update2018-12-06 08:51:15
depth3
children1
last_payout2018-12-13 08:51:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length122
author_reputation532,490,077,298,033
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,440,003
net_rshares511,324,080
author_curate_reward""
vote details (1)
@utopian-io ·
Thank you for your review, @codingdefined! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-princessdharmy-triviums-mobile-app-update-show-users-20181205t045011202z-20181207t052415z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-12-07 05:24:15
last_update2018-12-07 05:24:15
depth2
children0
last_payout2018-12-14 05:24:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length65
author_reputation152,955,367,999,756
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,482,720
net_rshares0
@steemitboard ·
Congratulations @princessdharmy! You received a personal award!

<table><tr><td>https://steemitimages.com/70x70/http://steemitboard.com/@princessdharmy/birthday1.png</td><td>1 Year on Steemit</td></tr></table>

<sub>_[Click here to view your Board](https://steemitboard.com/@princessdharmy)_</sub>


**Do not miss the last post from @steemitboard:**
<table><tr><td><a href="https://steemit.com/christmas/@steemitboard/christmas-challenge-send-a-gift-to-to-your-friends-the-party-continues"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/kf4SJb.png"></a></td><td><a href="https://steemit.com/christmas/@steemitboard/christmas-challenge-send-a-gift-to-to-your-friends-the-party-continues">Christmas Challenge - The party continues</a></td></tr><tr><td><a href="https://steemit.com/christmas/@steemitboard/christmas-challenge-send-a-gift-to-to-your-friends"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/kf4SJb.png"></a></td><td><a href="https://steemit.com/christmas/@steemitboard/christmas-challenge-send-a-gift-to-to-your-friends">Christmas Challenge - Send a gift to to your friends</a></td></tr></table>

> Support [SteemitBoard's project](https://steemit.com/@steemitboard)! **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-princessdharmy-20181228t212509000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-12-28 21:25:09
last_update2018-12-28 21:25:09
depth1
children0
last_payout2019-01-04 21:25:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,359
author_reputation38,975,615,169,260
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,511,135
net_rshares0
@steemitboard ·
Congratulations @princessdharmy! You received a personal award!

<table><tr><td>https://steemitimages.com/70x70/http://steemitboard.com/@princessdharmy/birthday2.png</td><td>Happy Birthday! - You are on the Steem blockchain for 2 years!</td></tr></table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@princessdharmy) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=princessdharmy)_</sub>


###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-princessdharmy-20191228t213633000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2019-12-28 21:36:33
last_update2019-12-28 21:36:33
depth1
children0
last_payout2020-01-04 21:36:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length644
author_reputation38,975,615,169,260
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id93,817,764
net_rshares0
@utopian-io ·
Hey, @princessdharmy!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-triviums-mobile-app-update-show-users-20181205t054559z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-12-05 05:46:00
last_update2018-12-05 05:46:00
depth1
children0
last_payout2018-12-12 05:46:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length596
author_reputation152,955,367,999,756
root_title"Triviums Mobile App (UPDATE: Show Users)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,382,278
net_rshares0