-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: parneet-guraya <[email protected]>
- Loading branch information
1 parent
a5c8863
commit ff002a3
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...n/src/main/java/com/owncloud/android/domain/files/usecases/GetIfFileFolderLocalUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* ownCloud Android client application | ||
* | ||
* @author Parneet Singh | ||
* Copyright (C) 2024 ownCloud GmbH. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.owncloud.android.domain.files.usecases | ||
|
||
import com.owncloud.android.domain.BaseUseCaseWithResult | ||
import com.owncloud.android.domain.files.FileRepository | ||
import com.owncloud.android.domain.files.model.OCFile | ||
|
||
class GetIfFileFolderLocalUseCase(private val fileRepository: FileRepository) : BaseUseCaseWithResult<Boolean, GetIfFileFolderLocalUseCase.Params>() { | ||
|
||
override fun run(params: Params): Boolean = getIfFileFolderLocal(params.listOfFiles) | ||
|
||
private fun getIfFileFolderLocal(listOfFiles: List<OCFile>): Boolean { | ||
listOfFiles.forEach { file -> | ||
if (file.isFolder) { | ||
if (getIfFileFolderLocal(fileRepository.getFolderContent(file.id!!))) return true | ||
} else { | ||
if (file.isAvailableLocally) return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
data class Params(val listOfFiles: List<OCFile>) | ||
|
||
} |