mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-03 07:53:37 +00:00
Implemented recursive scanning to get scan status
This commit is contained in:
@@ -68,12 +68,13 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||||||
settingViewModel.launchScan(new ScanCallback() {
|
settingViewModel.launchScan(new ScanCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception exception) {
|
public void onError(Exception exception) {
|
||||||
Toast.makeText(requireContext(), exception.getMessage(), Toast.LENGTH_SHORT).show();
|
findPreference("scan_library").setSummary(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(boolean isScanning, long count) {
|
public void onSuccess(boolean isScanning, long count) {
|
||||||
Toast.makeText(requireContext(), "Scanning: counting " + count + " elements", Toast.LENGTH_SHORT).show();
|
if(isScanning) getScanStatus();
|
||||||
|
else findPreference("scan_library").setSummary("Scanning: counting " + count + " tracks");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -94,4 +95,19 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getScanStatus() {
|
||||||
|
settingViewModel.getScanStatus(new ScanCallback() {
|
||||||
|
@Override
|
||||||
|
public void onError(Exception exception) {
|
||||||
|
findPreference("scan_library").setSummary(exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(boolean isScanning, long count) {
|
||||||
|
findPreference("scan_library").setSummary("Scanning: counting " + count + " tracks");
|
||||||
|
if(isScanning) getScanStatus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user