Skip to content

Commit

Permalink
fix: Members aren't showing
Browse files Browse the repository at this point in the history
  • Loading branch information
iyxan23 committed Feb 12, 2021
1 parent b7f4223 commit 1535a2a
Showing 1 changed file with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -39,6 +40,8 @@

public class ViewOnlineProjectActivity extends AppCompatActivity {

private static final String TAG = "ViewOnlineProjectActivi";

private ActivityViewOnlineProjectBinding binding;

private String description_;
Expand Down Expand Up @@ -134,6 +137,8 @@ protected void onCreate(Bundle savedInstanceState) {
})
*/
.addOnSuccessListener(result -> {
Log.d(TAG, "onCreate: Fetch success");

DocumentSnapshot project_data = tmp[0];
DocumentSnapshot uploader_userdata = tmp[1];
DocumentSnapshot latest_commit = result.getDocuments().get(0);
Expand Down Expand Up @@ -168,15 +173,15 @@ protected void onCreate(Bundle savedInstanceState) {
commit_start_id.setText(first_commit_id);
description_textview.setText(description);

Log.d(TAG, "onCreate: Fetching members");
fetchMembers(members_);

// Hide the progressbar
findViewById(R.id.progress_project).setVisibility(View.GONE);
})
.addOnFailureListener(e -> Toast.makeText(this, "Error while fetching: " + e.getMessage(), Toast.LENGTH_LONG).show());
}

private void fetchMembers(List<String> members_) {
Log.d(TAG, "fetchMembers: members_: " + members_);

// Check if members_ is null bruh
if (members_ == null) {
// kekw we're outta here
Expand All @@ -191,6 +196,8 @@ private void fetchMembers(List<String> members_) {
if (cached_names.containsKey(uid)) {
username = cached_names.get(uid);

Log.d(TAG, "fetchMembers: Username already cached: " + uid + "; value: " + username);

} else {
// Fetch it's username
Task<DocumentSnapshot> userdata_fetch = userdata.document(uid).get();
Expand All @@ -208,6 +215,8 @@ private void fetchMembers(List<String> members_) {

username = user.getString("name");

Log.d(TAG, "fetchMembers: Username fetched, uid: " + uid + ", name: " + username);

cached_names.put(uid, username);

} catch (ExecutionException | InterruptedException e) {
Expand All @@ -218,8 +227,26 @@ private void fetchMembers(List<String> members_) {
}
}

Log.d(TAG, "fetchMembers: Add member: " + username + " (" + uid + ")");
members.add(new Userdata(username, uid));
}

// Update the textview
runOnUiThread(() -> {
TextView members_list = findViewById(R.id.members_list);
members_list.setText("");

boolean is_start = false;

for (Userdata member_userdata: members) {
members_list.append((is_start ? ", " : "") + member_userdata.getName());

is_start = true;
}

// Hide the progressbar
findViewById(R.id.progress_project).setVisibility(View.GONE);
});
}).start();
}

Expand Down

0 comments on commit 1535a2a

Please sign in to comment.