WorkerStateLiveData.kt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Alper Ozturk
  5. * Copyright (C) 2023 Alper Ozturk
  6. * Copyright (C) 2023 Nextcloud GmbH
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. package com.nextcloud.model
  22. import androidx.lifecycle.LiveData
  23. class WorkerStateLiveData private constructor() : LiveData<WorkerState>() {
  24. fun setWorkState(state: WorkerState) {
  25. postValue(state)
  26. }
  27. companion object {
  28. private var instance: WorkerStateLiveData? = null
  29. fun instance(): WorkerStateLiveData {
  30. return instance ?: synchronized(this) {
  31. instance ?: WorkerStateLiveData().also { instance = it }
  32. }
  33. }
  34. }
  35. }