Fix code analytics

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-12-29 14:26:32 +01:00 committed by Alper Öztürk
parent c135e24c4b
commit 5c31d91149
6 changed files with 13 additions and 16 deletions

View file

@ -45,10 +45,8 @@ class FileDownloadHelper {
private var instance: FileDownloadHelper? = null
fun instance(): FileDownloadHelper {
return if (instance == null) {
FileDownloadHelper()
} else {
instance!!
return instance ?: synchronized(this) {
instance ?: FileDownloadHelper().also { instance = it }
}
}
}

View file

@ -179,11 +179,11 @@ class FileDownloadWorker(
}
private fun setWorkerState(user: User?, file: DownloadFileOperation?) {
WorkerStateLiveData.instance?.setWorkState(WorkerState.Download(user, file))
WorkerStateLiveData.instance().setWorkState(WorkerState.Download(user, file))
}
private fun setIdleWorkerState() {
WorkerStateLiveData.instance?.setWorkState(WorkerState.Idle)
WorkerStateLiveData.instance().setWorkState(WorkerState.Idle)
}
private fun addAccountUpdateListener() {

View file

@ -30,13 +30,12 @@ class WorkerStateLiveData private constructor() : LiveData<WorkerState>() {
}
companion object {
var instance: WorkerStateLiveData? = null
get() {
if (field == null) {
field = WorkerStateLiveData()
}
return field
private var instance: WorkerStateLiveData? = null
fun instance(): WorkerStateLiveData {
return instance ?: synchronized(this) {
instance ?: WorkerStateLiveData().also { instance = it }
}
private set
}
}
}

View file

@ -1563,7 +1563,7 @@ public class FileDisplayActivity extends FileActivity
}
private void observeWorkerState() {
WorkerStateLiveData.Companion.getInstance().observe(this, state -> {
WorkerStateLiveData.Companion.instance().observe(this, state -> {
if (state instanceof WorkerState.Download) {
Log_OC.d(TAG, "Download worker started");
handleDownloadWorkerState();

View file

@ -518,7 +518,7 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
}
private void observeWorkerState() {
WorkerStateLiveData.Companion.getInstance().observe(this, state -> {
WorkerStateLiveData.Companion.instance().observe(this, state -> {
if (state instanceof WorkerState.Download) {
Log_OC.d(TAG, "Download worker started");
workerAccountName = ((WorkerState.Download) state).getUser().getAccountName();

View file

@ -307,7 +307,7 @@ public class PreviewImageActivity extends FileActivity implements
}
private void observeWorkerState() {
WorkerStateLiveData.Companion.getInstance().observe(this, state -> {
WorkerStateLiveData.Companion.instance().observe(this, state -> {
if (state instanceof WorkerState.Download) {
Log_OC.d(TAG, "Download worker started");
isDownloadWorkStarted = true;