I'm programming an Android app that shows data from MySQL database via ListView with some sorting:
1) Items that are closer to android phone by GPS are shown firstly
If there are 2 or more items with equal distance, second sorting parameter applies - time.
2) Items that are closer in time are showm firstly.
Here is a scheme of the process that I guess to implement:
My idea is to get all needed rows into Array, then make some PHP manipulations with it and then pull sorted Array to the phone.
(as shown on the image above)
So please advice me what will be the proper way?
Maybe there is easier method for this functionality?
Or maybe I should do all the sortings exactly in the Android app when programming ListView, getting only standard "SELECT *" array from the database? Then, is there an opportunity to create a ListView with sorting based on calculated values?
Related
My application must show data from a Csv File in RecyclerView.
I have everything set up and I set up also a function to read the Csv File, but I have a problem.
Since the Csv File is very large ( many thousand of rows ) when I try to show all the rows in the RecyclerView, app crashes.
How can avoid this?
Ah, I enter the data in a Room database.
This is my process :
ReadFile
Save it as List of List of String
Create my type objects for every row and create a List
Apply insertAll(input : List) to insert into Room Database
How can I manage this type of operation without slowing down or crashing the application?
Thanks everyone and good life :)
Best way to do that is by partitioning, load only 20 row each time or any number, when user scroll load another 20.
I have a simple form containing TstringGrid with 2 columns, a TStringColumn and TCheckColumn added. I have seen many examples of saving the contents to file if the cells contain text or numbers. I have not seen any examples of saving with a TCheckColumn. I am assuming that I must check each CheckColumn cell, determine its state and assign a value that can be saved to file. Or maybe there is a more elegant way to do this.
As for sorting - again many examples using strings or numbers but none with TCheckColumn. I have HeaderClick enabled. On the TStringColumn I would like to sort Alphabetically - On the TCheckColumn - I would like checked items at the top of the column.
I am using Delphi 10.2.1 and will compile for Android.
Without saying you shouldn't start from here - I will just answer the specific questioN;
To keep it simple, I would:
Save: iterate through the rows and take the state of the checkboxes and prefix the string item with BoolToStr(theCheckValue)+':'+theContents of the string.
Then save the stringList.
To Load:
load into the stringList and then iterate and break the string apart using pos on the ':' and StrToBool the left portion, setting the checked item based on this.
Not got an IDE up, so haven't tested, but that would be my approach as a bit of a hack.
Currently, I have three string-arrays in my String Resources that hold information I need for the application to start and function. These arrays need to be kept in order as string-array A position 5 corresponds to string-array B position 5 and so on.
This doesn't seem great as it can be error prone and not extensible if I want to add 100 new datapoints - so I have been looking into using a JSON file to store the data which seems to be better.
My problem: I have a Recycler View that is populated with data from my String Resources. Each item in the Recycler View is different, so the first view will take information from the first entry in string-array A, B and C and continue through each view in the Recycler View.
Is it better to create a JSON file that collects and groups the data so corresponding data is kept together? As well as reading this file into my SQLite database and create a cursor object that will populate my Recycler View and allow for some other database related activities later on in my application? From what I can tell it is.
Is this a viable solution to my problem?
Thanks
I'm trying to make a very simple list-based android app.
Is there a easy way to order objects and sort them by date?
My goal is to show the last added item on top of the list.
I've already tried with a client-side solution but it's not efficient.
At the moment i'm using this json data model:
{
id:"",
name:"",
body:"",
date:"date here"
}
Does anyone have and idea on how to solve this?
You must must use orderedByChild by the key of the date you'd like to order the children by. You can then observe the Value or ChildAdded event type of this query to retrieve the children in ascending order of date. To have the most recent first, you must reverse the objects manually client-side. Otherwise, you could prepend a - symbol to all the dates and handle it client side.
I have a scenario here.I am developing a housing app in which the Complex owners can post announcements and flat owners can see it.I am using webservice.The complex owner can add a new announcement(which I am saving in my server) and the flat owners can see those announcements(I am binding the announcements headers into a list view through json parsing and on-clicking a header a full message will be displayed).
Now the problem is in case of new announcements.I want to distinguish between the readed and unreaded messages(just like in our mail).So how can I determine which listview item is clicked or which item is not clicked??And also how can I give them different colors(i.e. to mark an item unreaded or not clicked ??)
Any help will be appreciated.
Save all announcements in a table locally in sqlite. Add a column to contain the read unread flag.
While populating the list read from the table and load considering the flag.