I need some advice to properly implement MVVM with what I'm trying to do.
1) I have a WebView control in a View because I need user to manually login to a website.
2) Once login, it will set a flag to indicate that user has logged in. It will then go to another link in the website and periodically read a html element value.
3) The values read will then be displayed in a table in another View.
4) In the scenario when the user is logged off from the website, it will show the website login page again. And then it will continue to Step 2 and Step 3.
5) The View that has the WebView control only need to be shown for the user to log in to the website. After logging in, the View can be hidden, and only showing the table which contains the values read, which are periodically updated.
I have few ideas on how to implement it but I am not sure if my idea is correct or not.
Have 2 View/ViewModel pair. 1 View/ViewModel (VM1) to display out the readings read. Another View/ViewModel (VM2) which contains WebView control for the user to login. VM1 will periodically trigger VM2 (by using mediator pattern) to read from the website. As VW2 tries to read from the website, if the user is not logged in to the website, it will go to the log in page. Once the user has logged in, it will go to the webpage that contains the html element and read the value. It will stay in that webpage so that the next time VW1 triggers VM2 to read the value, it can readily do so without user intervention.
Eventhough user may close the VM2's View, the View is not really closed. It is just hidden and the program is still able to read from the webpage in the background.
Have View/ViewModel (VM1) to display out the value in the table. VM1 calls a service that does the reading of webpage. The service has a WebView control. If the user is not logged in, the service will instantiate a View/ViewModel (VM2) and passing in the WebView control which the user can use to log in. Once the user has logged in, the WebView control is passed back to the service so that the service can continue to read the html element. The service then triggers the ViewModel (VM2) to close the View.
Please advice on what is the correct MVVM way to do what I'm trying to do.
Hi Richard.. forgive me for the misunderstanding..
Sifus is referring to Teacher/Master in Chinese because I'm still learning and there are a lot of very experienced people in this forum.
Actually, it is Sifu.. I just use Sifus to make it plural..
I have created android application with navigation drawer and when I click item from navigation drawer old fragment is not replaced,I can still see the old fragment under the new fragment.How to fix this issue?
privatevoid displaySelectedScreen(int id)
Fragment fragment = null;
fragment = new Main();
Intent intent = new Intent(this, Settings.class);
Intent intent1 = new Intent(this, About.class);
Intent i = new Intent(Intent.ACTION_SEND);
String sAux = "\nLet me recommend you this application\n\n";
sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n";
startActivity(Intent.createChooser(i, "choose one"));
fragment = new Feedback();
if (fragment != null)
FragmentManager fragmentManager = getSupportFragmentManager();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
@Overridepublicboolean onNavigationItemSelected(MenuItem item)
// Handle navigation view item clicks here.int id = item.getItemId();
Hello everyone i need to hashed my password when i put it in my login application android and then i need to compare it with my password in my table fos_user of symfony and the password in fos_user is encoders:bcrypt
This is my code:
// Check whether username or password is set from android if(isset($_POST['username']) && isset($_POST['password']))
// Innitialize Variable
$username = $_POST['username'];
$password = $_POST['password'];
$hash = password_hash($password, PASSWORD_BCRYPT);
// Query database for row exist or not
$sql = "SELECT password FROM fos_user WHERE username = '$username' AND password = '$hash'";
$test = mysql_query($sql) or die( mysql_error() );
$row = mysql_fetch_assoc($test);
if ($hash == $row['password'])
// send result back to android
i have a file named test.rar which have password that i set on it ,cuz i have a database file in it ,
i want to open this file and read data from my database file and use it for my app in android studio .
how can i do it ?
Store the .rar file in your project's assets folder. During runtime, you can access and save that file to the phone's internal storage or the SD card. As I understand it, RAR is a propriatary format so you can't unarchive it using Java's SDK. Use a third party library like junrar to do the unarchiving.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
I am working with googlemap. I have implemented custom marker window, this window contains photo of the marker. I am taking the url of the photo as string and setting it into imageview with thread. However, the code is not syncronized with user. When I have clicked the marker, it shows the photo of the previeus marker that I have clicked. When I did debug, I can see that true url values are coming from background but the setting image into imageview operation is becoming late. How can I solve this problem? I have tried picasso and glide but still same problem.