FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.presentation.HomeViewModel Class Reference
Inheritance diagram for com.freerdp.freerdpcore.presentation.HomeViewModel:
Collaboration diagram for com.freerdp.freerdpcore.presentation.HomeViewModel:

Public Member Functions

 HomeViewModel (@NonNull Application application)
 
LiveData< List< BookmarkBase > > getBookmarks ()
 
String getCurrentQuery ()
 
void loadBookmarks (String query)
 
void deleteBookmark (long id)
 

Protected Member Functions

void onCleared ()
 

Detailed Description

Definition at line 28 of file HomeViewModel.java.

Constructor & Destructor Documentation

◆ HomeViewModel()

com.freerdp.freerdpcore.presentation.HomeViewModel.HomeViewModel ( @NonNull Application  application)
inline

Definition at line 38 of file HomeViewModel.java.

39 {
40 super(application);
41 manualBookmarkGateway =
42 new ManualBookmarkGateway(AppDatabase.getInstance(application).bookmarkDao());
43 quickConnectHistoryGateway =
44 new QuickConnectHistoryGateway(HistoryDatabase.getInstance(application).historyDao());
45 }

Member Function Documentation

◆ deleteBookmark()

void com.freerdp.freerdpcore.presentation.HomeViewModel.deleteBookmark ( long  id)
inline

Definition at line 81 of file HomeViewModel.java.

82 {
83 executor.execute(() -> {
84 manualBookmarkGateway.delete(id);
85 loadBookmarks(currentQuery);
86 });
87 }

◆ getBookmarks()

LiveData< List< BookmarkBase > > com.freerdp.freerdpcore.presentation.HomeViewModel.getBookmarks ( )
inline

Definition at line 47 of file HomeViewModel.java.

48 {
49 return bookmarks;
50 }

◆ getCurrentQuery()

String com.freerdp.freerdpcore.presentation.HomeViewModel.getCurrentQuery ( )
inline

Definition at line 52 of file HomeViewModel.java.

53 {
54 return currentQuery;
55 }

◆ loadBookmarks()

void com.freerdp.freerdpcore.presentation.HomeViewModel.loadBookmarks ( String  query)
inline

Definition at line 57 of file HomeViewModel.java.

58 {
59 currentQuery = query != null ? query : "";
60 executor.execute(() -> {
61 List<BookmarkBase> result = new ArrayList<>();
62 if (!currentQuery.isEmpty())
63 {
64 BookmarkBase qcBm = new BookmarkBase();
65 qcBm.setType(BookmarkBase.TYPE_QUICKCONNECT);
66 qcBm.setLabel(currentQuery);
67 qcBm.setHostname(currentQuery);
68 qcBm.setDirectConnect(true);
69 result.add(qcBm);
70 result.addAll(quickConnectHistoryGateway.findHistory(currentQuery));
71 result.addAll(manualBookmarkGateway.findByLabelOrHostnameLike(currentQuery));
72 }
73 else
74 {
75 result.addAll(manualBookmarkGateway.findAll());
76 }
77 bookmarks.postValue(result);
78 });
79 }

◆ onCleared()

void com.freerdp.freerdpcore.presentation.HomeViewModel.onCleared ( )
inlineprotected

Definition at line 89 of file HomeViewModel.java.

90 {
91 super.onCleared();
92 executor.shutdown();
93 }

The documentation for this class was generated from the following file: