From fbcee2c7a030b812b3bbfc102ec83e1cfa992af4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 6 Dec 2017 16:10:21 +0100 Subject: [PATCH] couple code style updates --- .../simplemobiletools/gallery/activities/MainActivity.kt | 4 ++-- .../gallery/activities/MediaActivity.kt | 6 +++--- .../gallery/activities/SetWallpaperActivity.kt | 4 ++-- .../gallery/activities/ViewPagerActivity.kt | 4 ++-- .../gallery/adapters/DirectoryAdapter.kt | 5 ++--- .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 9 ++++----- app/src/main/res/layout/directory_item_list.xml | 2 +- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index af6e3b8ee..89f8e1fbf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -598,7 +598,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.postDelayed({ - Thread({ + Thread { val mediaId = getLatestMediaId() if (mLatestMediaId != mediaId) { mLatestMediaId = mediaId @@ -608,7 +608,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } else { checkLastMediaChanged() } - }).start() + }.start() }, LAST_MEDIA_CHECK_PERIOD) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 0ec644665..9da4e2278 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -75,7 +75,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mAllowPickingMultiple = getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) } - media_refresh_layout.setOnRefreshListener({ getMedia() }) + media_refresh_layout.setOnRefreshListener { getMedia() } mPath = intent.getStringExtra(DIRECTORY) storeStateVariables() if (mShowAll) @@ -218,7 +218,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.postDelayed({ - Thread({ + Thread { val mediaId = getLatestMediaId() if (mLatestMediaId != mediaId) { mLatestMediaId = mediaId @@ -228,7 +228,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } else { checkLastMediaChanged() } - }).start() + }.start() }, LAST_MEDIA_CHECK_PERIOD) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt index 559d06452..9f149647c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt @@ -114,7 +114,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete if (result.error == null) { toast(R.string.setting_wallpaper) - Thread({ + Thread { val bitmap = result.bitmap val wantedHeight = wallpaperManager.desiredMinimumHeight val ratio = wantedHeight / bitmap.height.toFloat() @@ -132,7 +132,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete setResult(Activity.RESULT_CANCELED) } finish() - }).start() + }.start() } else { toast("${getString(R.string.image_editing_failed)}: ${result.error.message}") } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 47b0f6e53..428c1125b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -499,9 +499,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View SaveAsDialog(this, currPath, false) { val selectedFile = File(it) handleSAFDialog(selectedFile) { - Thread({ + Thread { saveImageToFile(currPath, it) - }).start() + }.start() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index dbd4cd7de..25a95566a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.gallery.adapters -import android.graphics.PorterDuff import android.view.Menu import android.view.View import android.view.ViewGroup @@ -342,8 +341,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList, } private fun toggleFileVisibility(hide: Boolean) { - Thread({ + Thread { getSelectedMedia().forEach { val oldFile = File(it.path) activity.toggleFileVisibility(oldFile, hide) @@ -151,7 +150,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, listener?.refreshItems() finishActMode() } - }).start() + }.start() } private fun shareMedia() { @@ -264,7 +263,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, if (isListViewType) { photo_name.setTextColor(textColor) - play_outline.setColorFilter(textColor, PorterDuff.Mode.SRC_IN) + play_outline.applyColorFilter(textColor) } } } diff --git a/app/src/main/res/layout/directory_item_list.xml b/app/src/main/res/layout/directory_item_list.xml index fb7e8e7d8..c5dca4520 100644 --- a/app/src/main/res/layout/directory_item_list.xml +++ b/app/src/main/res/layout/directory_item_list.xml @@ -4,9 +4,9 @@ android:id="@+id/dir_holder" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="@dimen/small_margin" android:clickable="true" android:focusable="true" + android:paddingLeft="@dimen/small_margin" android:paddingTop="@dimen/small_margin">