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 32 of file HomeViewModel.java.

Constructor & Destructor Documentation

◆ HomeViewModel()

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

Definition at line 42 of file HomeViewModel.java.

43 {
44 super(application);
45 manualBookmarkGateway =
46 new ManualBookmarkGateway(AppDatabase.getInstance(application).bookmarkDao());
47 quickConnectHistoryGateway =
48 new QuickConnectHistoryGateway(HistoryDatabase.getInstance(application).historyDao());
49 }

Member Function Documentation

◆ deleteBookmark()

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

Definition at line 85 of file HomeViewModel.java.

86 {
87 executor.execute(() -> {
88 manualBookmarkGateway.delete(id);
89 loadBookmarks(currentQuery);
90 });
91 }

◆ getBookmarks()

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

Definition at line 51 of file HomeViewModel.java.

52 {
53 return bookmarks;
54 }

◆ getCurrentQuery()

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

Definition at line 56 of file HomeViewModel.java.

57 {
58 return currentQuery;
59 }

◆ loadBookmarks()

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

Definition at line 61 of file HomeViewModel.java.

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

◆ onCleared()

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

Definition at line 93 of file HomeViewModel.java.

94 {
95 super.onCleared();
96 executor.shutdown();
97 }

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