Skip to content
Snippets Groups Projects
Commit 45b78b2c authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Network: Create isConnected() util

parent d875f976
No related branches found
No related tags found
No related merge requests found
......@@ -167,6 +167,11 @@ public class ExternalMonitor extends BroadcastReceiver implements LifecycleObser
return mobile;
}
public static boolean isConnected() {
final Boolean co = connected.getValue();
return co != null && co.booleanValue();
}
public static boolean isLan() {
final Boolean status = connected.getValue();
return status != null && status && !mobile;
......
......@@ -128,7 +128,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment implements Simpl
@Override
public void refresh() {
refresh(ExternalMonitor.connected.getValue());
refresh(ExternalMonitor.isConnected());
}
public void refresh(boolean connected) {
......@@ -212,8 +212,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment implements Simpl
*/
protected void updateEmptyView() {
if (getBinding() == null) return;
final Boolean connected = ExternalMonitor.connected.getValue();
if (connected != null && connected.booleanValue()) {
if (ExternalMonitor.isConnected()) {
if (Util.isListEmpty(getViewModel().getDataset().getValue())) {
if (mSwipeRefreshLayout == null || mSwipeRefreshLayout.isRefreshing()) {
getBinding().empty.setText(R.string.loading);
......
......@@ -36,7 +36,7 @@ class NetworkProvider(dataset: LiveDataset<MediaLibraryItem>, url: String? = nul
}
suspend fun updateFavorites() : MutableList<MediaLibraryItem> {
if (ExternalMonitor.connected?.value != true) return mutableListOf()
if (!ExternalMonitor.isConnected()) return mutableListOf()
val favs: MutableList<MediaLibraryItem> = withContext(CommonPool) { MediaDatabase.getInstance().allNetworkFav }.toMutableList()
if (!ExternalMonitor.allowLan()) {
val schemes = Arrays.asList("ftp", "sftp", "ftps", "http", "https")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment