Click here to Skip to main content
15,029,128 members
Home / Discussions / Android
   

Android

 
QuestionAndroid media player won't start Pin
Pavlex413-May-17 2:08
MemberPavlex413-May-17 2:08 
AnswerRe: Android media player won't start Pin
Pavlex413-May-17 5:13
MemberPavlex413-May-17 5:13 
QuestionAndroid read file from url Pin
Pavlex412-May-17 6:39
MemberPavlex412-May-17 6:39 
QuestionRe: Android read file from url Pin
David Crow12-May-17 10:06
MemberDavid Crow12-May-17 10:06 
QuestionAndroid Shopping Cart Pin
Member 1319622012-May-17 2:52
MemberMember 1319622012-May-17 2:52 
AnswerRe: Android Shopping Cart Pin
Richard MacCutchan12-May-17 3:13
mveRichard MacCutchan12-May-17 3:13 
QuestionRe: Android Shopping Cart Pin
David Crow12-May-17 9:48
MemberDavid Crow12-May-17 9:48 
QuestionCorrect MVVM implementation to manually login to website, go to certain link in the website, read information from html element and display it in another View. Pin
JoJo8210-May-17 6:15
MemberJoJo8210-May-17 6:15 
Hi Sifu..

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.
Idea 1:
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.


Idea 2:
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.
Thanks.

modified 10-May-17 18:00pm.

AnswerRe: Correct MVVM implementation to manually login to website, go to certain link in the website, read information from html element and display it in another View. Pin
Richard MacCutchan10-May-17 6:41
mveRichard MacCutchan10-May-17 6:41 
GeneralRe: Correct MVVM implementation to manually login to website, go to certain link in the website, read information from html element and display it in another View. Pin
JoJo8210-May-17 12:07
MemberJoJo8210-May-17 12:07 
QuestionPrevious fragment visible under the new fragment issue Pin
Pavlex46-May-17 7:59
MemberPavlex46-May-17 7:59 
SuggestionRe: Previous fragment visible under the new fragment issue Pin
David Crow8-May-17 6:53
MemberDavid Crow8-May-17 6:53 
QuestionHelp Pin
Member 1302311825-Apr-17 14:06
MemberMember 1302311825-Apr-17 14:06 
QuestionRe: Help Pin
Richard MacCutchan25-Apr-17 21:28
mveRichard MacCutchan25-Apr-17 21:28 
AnswerRe: Help Pin
Member 1302311826-Apr-17 0:22
MemberMember 1302311826-Apr-17 0:22 
QuestionRe: Help Pin
David Crow26-Apr-17 3:00
MemberDavid Crow26-Apr-17 3:00 
AnswerRe: Help Pin
Member 1302311826-Apr-17 3:27
MemberMember 1302311826-Apr-17 3:27 
SuggestionRe: Help Pin
David Crow26-Apr-17 3:36
MemberDavid Crow26-Apr-17 3:36 
GeneralRe: Help Pin
Member 1302311826-Apr-17 3:38
MemberMember 1302311826-Apr-17 3:38 
GeneralRe: Help Pin
Richard MacCutchan26-Apr-17 21:07
mveRichard MacCutchan26-Apr-17 21:07 
Questionhow can i open a rar file with password Pin
Member 1298133419-Apr-17 3:05
MemberMember 1298133419-Apr-17 3:05 
AnswerRe: how can i open a rar file with password Pin
Nick_314159265419-Apr-17 4:08
MemberNick_314159265419-Apr-17 4:08 
AnswerRe: how can i open a rar file with password Pin
CHill6019-Apr-17 4:10
mveCHill6019-Apr-17 4:10 
SuggestionRe: how can i open a rar file with password Pin
David Crow24-Apr-17 9:55
MemberDavid Crow24-Apr-17 9:55 
AnswerMessage Closed Pin
17-May-17 10:55
MemberMember 1320708517-May-17 10:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.