blonsky95 / DigiCoachAndroid

0 stars 0 forks source link

Making initial layout fragments #91

Closed blonsky95 closed 4 years ago

blonsky95 commented 4 years ago
  1. home, exercise viewer, month viewer, store and profile will be fragments

  2. share to friends will be fragment, and when receiving something it will also display a fragment with info of what it is and from who

  3. figure out the architechture to make all of that work well together

blonsky95 commented 4 years ago

make code analagous to exerciseviewer fragment

blonsky95 commented 4 years ago

in ProfileFragment think how to do the whole friends thing I need a fragment to display friends, and send requests, and a fragment to display incoming friend request packages like the others so, one button for incoming requests, and one button to see current friends

blonsky95 commented 4 years ago

Ok so for communication - interfaces can help out with a couple things such as parameters, but everything is more organised if in viewmodel and if using observers

So there will be one mutablelivedata Int, which specifies fragment type, home activity will observe this as well as the packages, and when the type changes it can load the fragment with the parameters it needs (the packages) with the newInstance method, like in sharetofriends, and then implement the interface analogously for onRequestAccepted depending on the type

blonsky95 commented 4 years ago

Fragment is all ready, now in homeactivity need to implement the itnerface so it can add everything thats accepted, and update the package online too, bit of view model copying pasting

blonsky95 commented 4 years ago

Ok so things to do:

  1. Get allExes, alldays and all friends asynchronously from their daos - this is fine because these are not being called immediately after homeactivity is open - but when the social button is tapped in each fragment - actually this is a problem because when they are updated - say i receive a new exe 2 times, it would insert 2 times because the allexes var doesnt get updated, because its not livedata, so might have to use observers for all of them hehe and just pass to viewmodel!

  2. use allExes to check if already existing exercise

  3. do the dialog, could make it livedata, and when triggered it passes a dialog with the interface to call the methods of the mainviewmodel already implemented

blonsky95 commented 4 years ago

OK so: In exercises and motnhviewer, the social button is updated by the observer. When clicked it triggers a fragment display PackageReceiver which based on the argument will display a list of received days, exercises or friends.

In here all you do is accept, which will update the state of the firebase object + insert the item and do its corresponding checks.

However in Friends, we also need to be able to add friends, accepting is easy. There will be another icon for friends which when pressed opens friends displayer fragment - this displays the friends - and has a button to make friend request - lets make it an edit text and a plus button.

Things to do this considered:

  1. When accepting a friend - do the corresponding firebase updates - so the methods when accepting - this should be in MAINVIEWMODEL
  2. FriendDisplayer will have its own viewmodel to refresh and display an observed value of the friends list, as well has to handle the add friend operations.

When sending you need:

  1. inform receiving user firebase (friend displayer view model)
  2. inform sending user firebase (friend displayer view model)

When accepting/rejecting (receiving) you need:

  1. insert (mainviewmodel logic - already in interface)
  2. updateRequestStateofReceiverandSender (mainviewmodel logic - already in interface)
blonsky95 commented 4 years ago

So current issue is that when you get the transfer packages from gson it needs to know the type

blonsky95 commented 4 years ago

Ok so navigation is more or less sorted:

Horizontal fragment navigation doesnt add to backstack, so back button ignores any fragment navigation (ideally ill change this so back is home)

Vertical fragment display - when a vertical is displayed, if you change tab, it dissapears through popbackstack

  1. friends working - need to clear received packages after accepting or rejecting - exercise packages not removing - debug and check
  2. social button number working - in exercises yes but as packages dont dissapear social number either
  3. test exercises and days
blonsky95 commented 4 years ago

ok much better - need to reinitialise variables for packages at some point - recheck what causes packages to not be reset correctly

blonsky95 commented 4 years ago

Also make sure there is no navigation back to not fragments from activities like exe creator and stuff

blonsky95 commented 4 years ago

get rid of unused activities/viewmodels