Why in the fragment inside the bottomNavigation, the request is not sent to the server from the second time onwards

78
April 18, 2022, at 05:10 AM

I have a bottom navigation and when switch between its items In two cases, two different things happen : First : When the program is first run -> Everything works fine . that's mean: enter image description here

Exactly when I debug: First we enter onSuccess and livedata valued and finally we listen to it in the fragment And finally we see the list of products in the shopping cart.

enter image description here

So far, so good But : Second: When the program is run and After adding other products to the cart and refer to the shopping cart item for the second time : We do not see any new products added.

After debugging, I realized that when the program is run for the first time, the code snippet inside the init{} block is executed, and as a result, we receive the products of the shopping cart on the server side. But for the second time after, when we click on the shopping cart item, we only listen to the live data, and in fact, the code snippet inside Init is not executed so that we can receive the server-side products. Now my question is: My main problem is with the shopping cart item. What can I do to change items and return to the cart to receive recently added products? In fact, when I come to the shopping cart item for the second time, what should I do to execute the code snippet inside Init{} AND To be able to see the new products stored in the database?

Answer 1

This is because when the onCreateView method is executed, it causes the init block to be executed only once. The solution is to destroy the piece

Rent Charter Buses Company
READ ALSO
user = discord.utils.get(client.users, name="name", discriminator="0000") comes back with none

user = discord.utils.get(client.users, name="name", discriminator="0000") comes back with none

So i want to be able to mention a user when I input there name and discriminator but I cant get it to work as it keeps return none

104
What is the logic behind this fstring in python?

What is the logic behind this fstring in python?

From this question: Converting an integer to signed 2's complement binary string

121
How to switch to predict mode in Trax after training a model?

How to switch to predict mode in Trax after training a model?

I'm familiarizing myself with the Trax library for building deep learning models and one question that I can't find an answer to is how to switch from "train" mode to "eval" mode after model training is complete

104
Rotate point about another point in degrees python

Rotate point about another point in degrees python

If you had a point (in 2d), how could you rotate that point by degrees around the other point (the origin) in python?

195