A
A
afna2015-08-13 09:57:25
Java
afna, 2015-08-13 09:57:25

How to get the amount of new data?

Hello!
If who faced a problem of calculation of the new data, prompt please.
In different messengers, when new data arrives, the amount of this new data is displayed in the side menu, and when we go to this item, this circle disappears.
So what is the correct way to implement versioning of this data?
The catch is that when you go to a specific menu item, a form with a list opens and each element of the list can contain its own circle with the amount of new data.
Tell me, please, who faced such a problem. How do you implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Олег Гамега, 2015-08-13
@gadfi

все зависит от вашей архитектуры, единого рецепта нет.
Например сообщению добавить булевое поле прочитано и с помощью CursorLoader показывать в этом кружочке количество непрочитанных сообщений.
если нужна синхронизация между разными устройствами например клиент установлен на планшет и телефон, то это удобно сделать с помощью gcm
это первое что приходит в голову, возможно для вашей архитектуры оптимально другое решение

A
afna, 2015-08-19
@sulik93

Implemented in the following way:
From the server I get json like:
{
"data_array_1": [
{
"id": 4,
"count": 2
},
{
"id": 5,
"count": 5
},
{
"id": 6 ,
"count":3
}
],
"data_array_1":[
{
"id":54,
count:3
},
{
"id":55,
"count":5
},
{
"id":56,
"count":3
}
],
Write this data to SQLite.
After recording, I get the data to display by calling getSupportLoaderManager().getLoader(0).forceLoad()
. I update the data every 2 hours and provided that the response code 200 comes.
Further, I go to a specific list. For example data_array_1.
Each element of this list contains an id, by which I find the amount from the database, and display the amount in the list element if the amount != 0. At the same time, I also update the amount of new data in the side menu.
If anyone needs it, I'll explain in more detail.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question