Android Question Updating from old Table Class to Flex Table Class [SOLVED]

Tim Chapman

Active Member
Licensed User
Longtime User
I am trying to update my project to Flex Table class because I need functions it offers.
I have added a layout file in the Files folder and added it in the files manager.
When I open it in the designer and tell it to generate members, it seems to do nothing.
So I created a new project with nothing in it. Added the main.bal layout file and tried to generate members again. Same results.
As a result of this not working correctly, I am getting an error because
There is code regarding initializing the table in Activity_Create and at line 454.

Presently I am getting an error in the Table module but I am certain it is because I have not set it up correctly in the Main module.
I have also tried to follow what was done here (https://www.b4x.com/android/forum/threads/how-to-remove-a-row-on-a-table.112439/) in RedDogRework with no luck.
Project is attached.
What am I doing wrong here?
Thank you again for the help in advance!
 

Attachments

  • TimTodo.zip
    215.3 KB · Views: 41
Last edited:
Solution
Where ever you use a TempTodo = Starter.TodoList.Get() in a For / Next loop you must declare the TempTodo object.
I am not sure if the TempTodo.Initialize is always necessary.
I leave it up to you to make these modifications.
I think that this should solve your problem.
B4X:
    For j = 0 To Starter.TodoList.Size-1
        'Log("...")
        'Log("*TodoList counter = "&j)
        Private TempTodo As Todo
        TempTodo.Initialize
        TempTodo = Starter.TodoList.Get(j)

klaus

Expert
Licensed User
Longtime User
I had a deeper look into your project.
I found why you lost the content of the Starter.TodoList list.
In the AllTodos you code you declare a TempTodo object only at the beginning of the routine.
But you must declare a new one for each iteration in the For / Next loop.
I moved the runtime permission calls to the Activity_Create routine.
I have not found why the progress bar is not displayed.
For me it is not necessary, when you run the project in release mode it is fast eough.

Attached the modified project.
 

Attachments

  • TimTodo2024_01_16.zip
    253.8 KB · Views: 32
Upvote 0

Tim Chapman

Active Member
Licensed User
Longtime User
Please note that the software is running well enough as it is. If you won't want to dig more it is OK.

When the tracker service starts, the data is lost. That is the only thing I can find so far.

It has to be fully functional to see the problem.
This means that a good location must be entered in the contexts spreadsheet for Home. Put your current latitude and longitude there before continuing.
It may then be used from DirAssets or Download folder.

The instructions below are to get the table to reload (and thus go through the TodoList list many times. As the software is now, it runs the LoadArrays sub each time the table loads. The objective is to get the LoadArrays sub to run once at the beginning of the code and not lose the contents of TodoList list when the table is reloaded.

When the code runs, it will beep and a notification will show us saying Contexts Nearby. Tap to Proceed.
Tap and then select Home in the menu that follows. 5 todo items will show.
Tap the back arrow to go back to the AllTodos list.
Then on the menu, select Leave Here. Select Semi from the list (scroll down on the list to see Semi). 3 Todo items will show.
Click the back arrow to see the AllTodos list.
On the menu, click See Last 'Trip'. The same 3 Todo items should show again.

If you can get that to work with LoadArrays running only once at the beginning of the program, the problem is solved.
If you watch the log, you will see it loses the TodoList when the Tracker Service is started during the code.
Note that I have no Sleep(0) statements in the code. I don't see this as a problem but I may be incorrect. I have had a lot of trouble with resumable subs and usually make them so they wait to finish using the method shown here: https://www.b4x.com/android/forum/threads/b4x-resumable-subs-sleep-wait-for.78601/post-499130
 

Attachments

  • TimTodo Klaus8a.zip
    244 KB · Views: 30
Upvote 0

klaus

Expert
Licensed User
Longtime User
Where ever you use a TempTodo = Starter.TodoList.Get() in a For / Next loop you must declare the TempTodo object.
I am not sure if the TempTodo.Initialize is always necessary.
I leave it up to you to make these modifications.
I think that this should solve your problem.
B4X:
    For j = 0 To Starter.TodoList.Size-1
        'Log("...")
        'Log("*TodoList counter = "&j)
        Private TempTodo As Todo
        TempTodo.Initialize
        TempTodo = Starter.TodoList.Get(j)
 
Upvote 0
Solution

Tim Chapman

Active Member
Licensed User
Longtime User
Thank you again Klaus! That fixed it. I implemented that fix before when you said to, but not in every location TempTodo was used. My mistake.
 
Upvote 0
Top