Skip to content

Commit 660d48a

Browse files
main stream action buttons
1 parent 75aebe5 commit 660d48a

File tree

13 files changed

+324
-94
lines changed

13 files changed

+324
-94
lines changed

app/src/main/java/com/skuares/studio/quest/MainActivity.java

-3
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ public boolean onNavigationItemSelected(MenuItem item) {
318318
startActivity(intentMap);
319319

320320
}
321-
if (item.getItemId() == R.id.thirdItem) {
322-
323-
}
324321

325322

326323
if (item.getItemId() == R.id.logout) {

app/src/main/java/com/skuares/studio/quest/QOwnStreamFragment.java

+42-26
Original file line numberDiff line numberDiff line change
@@ -418,33 +418,49 @@ public void onCancelled(FirebaseError firebaseError) {
418418
@Override
419419
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
420420

421-
/*
422-
// update the data of the quest
423-
424-
// HOW TO DO IT
425-
// convert to quest card
426-
QuestCard updatedQuestCard = dataSnapshot.getValue(QuestCard.class);
427-
// get the keyy and index it into the map
428-
String key = updatedQuestCard.getQuestKey();
429-
//Log.e("indexes", "" + key);
430-
QuestCard oldQuest = map.get(key);
431-
//Log.e("indexes",""+oldQuest.getQuestKey());
432-
if(oldQuest == null){
433-
// not of interest to this user
434-
}else{
435-
// get the index of the oldQuest
436-
int index = questCards.indexOf(oldQuest);
437-
// use this index to update the quest
438-
//Log.e("indexes",""+index);
439-
//Log.e("indexes", "" + questCards.size());
440-
if(index >= 0){// because of the firebase issue of calling ondatachanged many times
441-
questCards.set(index,updatedQuestCard);
442-
// notify the adapter
443-
adapter.notifyDataSetChanged();
444-
}
445421

446-
}
447-
*/
422+
QuestCard updatedQuestCard = dataSnapshot.getValue(QuestCard.class);
423+
424+
425+
// loop through the questCard
426+
// find the quest that matches the key of this quest
427+
// get it's position and notify
428+
429+
430+
431+
for(int i = 0; i < questCards.size(); i++){
432+
433+
QuestCard qc = questCards.get(i);
434+
435+
if(qc.getQuestKey().equals(updatedQuestCard.getQuestKey())){
436+
437+
438+
439+
QuestCard newConst = new QuestCard(updatedQuestCard.getQuestImage(),
440+
updatedQuestCard.getQuestTitle(),
441+
updatedQuestCard.getAuthorId(),
442+
qc.getQuestUsername(),
443+
qc.getQuestUserImage(),
444+
updatedQuestCard.getQuestDescription(),
445+
updatedQuestCard.getQuestCost(),
446+
updatedQuestCard.getTodos(),
447+
updatedQuestCard.getQuestKey(),
448+
updatedQuestCard.getUsersWhoLiked(),
449+
updatedQuestCard.getTakers(),
450+
updatedQuestCard.getNumberOfLikes(),
451+
updatedQuestCard.getNumberOfTakers(),
452+
updatedQuestCard.getNumberOfFollowers(),
453+
updatedQuestCard.getJoiners()
454+
);
455+
456+
// TAKE out the old quest and insert this one instead
457+
questCards.set(i,newConst);
458+
459+
}
460+
}
461+
462+
463+
448464

449465
}
450466

0 commit comments

Comments
 (0)