Skip to content

Commit a28fbd0

Browse files
committed
style: changed functions with just return to expression body
1 parent f62fb05 commit a28fbd0

File tree

7 files changed

+18
-25
lines changed

7 files changed

+18
-25
lines changed

owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/FileListAdapter.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ class FileListAdapter(
386386
}
387387
}
388388

389-
private fun generateFooterText(filesCount: Int, foldersCount: Int): String {
390-
return when {
389+
private fun generateFooterText(filesCount: Int, foldersCount: Int): String =
390+
when {
391391
filesCount <= 0 -> {
392392
when {
393393
foldersCount <= 0 -> {
@@ -438,7 +438,6 @@ class FileListAdapter(
438438
}
439439
}
440440
}
441-
}
442441

443442
interface FileListAdapterListener {
444443
fun onItemClick(ocFileWithSyncInfo: OCFileWithSyncInfo, position: Int)

owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,8 +1303,8 @@ class MainFileListFragment : Fragment(),
13031303
}
13041304
}
13051305

1306-
private fun onCheckedFilesActionChosen(menuId: Int?, checkedFiles: ArrayList<OCFile>): Boolean {
1307-
return when (menuId) {
1306+
private fun onCheckedFilesActionChosen(menuId: Int?, checkedFiles: ArrayList<OCFile>): Boolean =
1307+
when (menuId) {
13081308
R.id.file_action_select_all -> {
13091309
fileListAdapter.selectAll()
13101310
updateActionModeAfterTogglingSelected()
@@ -1380,7 +1380,6 @@ class MainFileListFragment : Fragment(),
13801380
false
13811381
}
13821382
}
1383-
}
13841383

13851384
/**
13861385
* Update or remove the actionMode after applying any change to the selected items.

owncloudApp/src/main/java/com/owncloud/android/presentation/security/passcode/PassCodeActivity.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
415415
finish()
416416
}
417417

418-
private fun getPasscodeAction(action: String?): PasscodeAction {
419-
return when (action) {
418+
private fun getPasscodeAction(action: String?): PasscodeAction =
419+
when (action) {
420420
ACTION_REMOVE -> {
421421
PasscodeAction.REMOVE
422422
}
@@ -429,7 +429,6 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
429429
PasscodeAction.CHECK
430430
}
431431
}
432-
}
433432

434433
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean =
435434
when (keyCode) {

owncloudApp/src/main/java/com/owncloud/android/providers/FileContentProvider.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ class FileContentProvider(val executors: Executors = Executors()) : ContentProvi
193193
return newUri
194194
}
195195

196-
private fun insert(db: SQLiteDatabase, uri: Uri, values: ContentValues?): Uri {
197-
return when (uriMatcher.match(uri)) {
196+
private fun insert(db: SQLiteDatabase, uri: Uri, values: ContentValues?): Uri =
197+
when (uriMatcher.match(uri)) {
198198
ROOT_DIRECTORY, SINGLE_FILE -> {
199199
val remotePath = values?.getAsString(ProviderTableMeta.FILE_PATH)
200200
val accountName = values?.getAsString(ProviderTableMeta.FILE_ACCOUNT_OWNER)
@@ -270,8 +270,6 @@ class FileContentProvider(val executors: Executors = Executors()) : ContentProvi
270270
else -> throw IllegalArgumentException("Unknown uri id: $uri")
271271
}
272272

273-
}
274-
275273
override fun onCreate(): Boolean {
276274
dbHelper = DataBaseHelper(context)
277275
// This sentence is for opening the database, which is necessary to perform the migration correctly to DB version 38

owncloudApp/src/main/java/com/owncloud/android/usecases/transfers/downloads/DownloadFileUseCase.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ class DownloadFileUseCase(
5050
val ocFile = params.file
5151
val accountName = params.accountName
5252

53-
return if (ocFile.id == null) {
54-
null
55-
} else if (isDownloadAlreadyEnqueued(accountName, ocFile)) {
56-
null
57-
} else {
58-
enqueueNewDownload(ocFile, accountName)
53+
return ocFile.id?.let {
54+
if (isDownloadAlreadyEnqueued(accountName, ocFile)) {
55+
null
56+
} else {
57+
enqueueNewDownload(ocFile, accountName)
58+
}
5959
}
6060
}
6161

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ open class MoveRemoteFileOperation(
6363
*
6464
* @param client Client object to communicate with the remote ownCloud server.
6565
*/
66-
override fun run(client: OwnCloudClient): RemoteOperationResult<Unit> {
67-
return if (targetRemotePath == sourceRemotePath) {
66+
override fun run(client: OwnCloudClient): RemoteOperationResult<Unit> =
67+
if (targetRemotePath == sourceRemotePath) {
6868
// nothing to do!
6969
RemoteOperationResult(ResultCode.OK)
7070
} else if (targetRemotePath.startsWith(sourceRemotePath)) {
@@ -115,7 +115,6 @@ open class MoveRemoteFileOperation(
115115
}
116116
result
117117
}
118-
}
119118

120119
/**
121120
* For standard moves, we will use [OwnCloudClient.getUserFilesWebDavUri].

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/StatusRequester.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,18 @@ internal class StatusRequester {
4949
(baseUrl.startsWith(HTTPS_SCHEME) &&
5050
!redirectedUrl.startsWith(HTTPS_SCHEME))
5151

52-
fun updateLocationWithRedirectPath(oldLocation: String, redirectedLocation: String): String {
52+
fun updateLocationWithRedirectPath(oldLocation: String, redirectedLocation: String): String =
5353
/** Redirection with different endpoint.
5454
* When asking for server.com/status.php and redirected to different.one/, we need to ask different.one/status.php
5555
*/
56-
return if (redirectedLocation.endsWith('/')) {
56+
if (redirectedLocation.endsWith('/')) {
5757
redirectedLocation.trimEnd('/') + OwnCloudClient.STATUS_PATH
5858
} else if (!redirectedLocation.startsWith("/")) {
5959
redirectedLocation
6060
} else {
6161
val oldLocationURL = URL(oldLocation)
6262
URL(oldLocationURL.protocol, oldLocationURL.host, oldLocationURL.port, redirectedLocation).toString()
6363
}
64-
}
6564

6665
private fun getGetMethod(url: String): GetMethod =
6766
GetMethod(URL(url)).apply {

0 commit comments

Comments
 (0)