Automatic updating of the newsfeed.

Issue #49 resolved
Raymond Wells created an issue

This will be a bit more of a complicated issue, but not terribly difficult to implement since android has a very good framework for this sort of thing built in to the api.

Essentially it will require these components:

  • A bound service which instantiates an alarm, and when triggered by the alarm, periodically checks for new advertisements.

  • A broadcast receiver (probably on the bound service, itself) which listens for the Intent with the ADVERTISEMENT_ALERT action, and triggers the service to update the ad data.

Each activity/fragment/whatever wishing to receive updates shall implement a broadcast receiver to receive the intent with the ADVERTISEMENT_UPDATE action. On new advertisements/misc other events the service shall send new data to the activity. It will be the responsibility of the activity/fragment/whatever to do what is appropriate with the data.

The service is only responsible for updating advertisements when triggered by anything, then broadcasting the intent that signals the activities about new data being available.

The receiver of an ADVERTISEMENT_UPDATE intent should never broadcast an ADVERTISEMENT_ALERT intent otherwise it will trigger an infinite loop.

Comments (4)

  1. Raymond Wells reporter

    Another thing to note is sending the ADVERTISEMENT_ALERT action is no guarantee new data will be received. If there is no new data available, there is an error, or another request is in progress.. it will not be received.

  2. Raymond Wells reporter

    Possible to extend the advertisementsservice to have the AdevrtisementUpdate service functionality.

    Still we need the advertisement alert intent broadcast though.

    Also, the AdvertisementsService object should be a singleton, as this makes things much cleaner.

  3. Raymond Wells reporter

    Done with pull to refresh. Also distinguishes between two request types: REPLACE or UPDATE.

    In addition, I've optimized the linear search through all ads when liking an ad using a hashmap.

  4. Log in to comment