Skip to content

Commit

Permalink
refactor: replace if/else condition with a null block by let in modul…
Browse files Browse the repository at this point in the history
…e `owncloudApp`
  • Loading branch information
joragua committed Dec 11, 2024
1 parent a8c8d78 commit d30be87
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,7 @@ class FileListAdapter(
val fileIcon = holder.itemView.findViewById<ImageView>(R.id.thumbnail).apply {
tag = file.id
}
val thumbnail: Bitmap? = if (file.remoteId != null) {
ThumbnailsCacheManager.getBitmapFromDiskCache(file.remoteId)
} else {
null
}
val thumbnail: Bitmap? = file.remoteId?.let { ThumbnailsCacheManager.getBitmapFromDiskCache(file.remoteId) }

holder.itemView.findViewById<LinearLayout>(R.id.ListItemLayout)?.apply {
contentDescription = "LinearLayout-$name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,14 +862,8 @@ class FileDisplayActivity : FileActivity(),
syncInProgress = true

} else {
var currentFile: OCFile? = if (file == null)
null
else
storageManager.getFileByPath(file.remotePath, file.spaceId)
val currentDir = if (currentDir == null)
null
else
storageManager.getFileByPath(currentDir!!.remotePath, currentDir.spaceId)
var currentFile: OCFile? = file?.let { storageManager.getFileByPath(file.remotePath, file.spaceId) }
val currentDir = currentDir?.let { storageManager.getFileByPath(currentDir!!.remotePath, currentDir.spaceId) }

if (currentDir == null) {
// current folder was removed from the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PublicLinkPasswordUtilsTest {

@Test
fun `generatePassword creates password fulfilling all policies`() {
repeat (1000) {
repeat(1000) {
val password = generatePassword(
minChars = minCharacters,
maxChars = maxCharacters,
Expand Down

0 comments on commit d30be87

Please sign in to comment.