From d9776e3dd4f6c0e8be98b7398c66a816b2325abf Mon Sep 17 00:00:00 2001 From: ssiori Date: Thu, 18 Jan 2024 10:37:50 +0800 Subject: [PATCH] optimize imports --- .../github/yueeng/moebooru/CropActivity.kt | 2 +- .../java/com/github/yueeng/moebooru/Db.kt | 18 ++++++++- .../github/yueeng/moebooru/MainApplication.kt | 13 ++++++- .../github/yueeng/moebooru/PopularActivity.kt | 11 +++++- .../github/yueeng/moebooru/PreviewActivity.kt | 24 ++++++++++-- .../github/yueeng/moebooru/SavedActivity.kt | 18 +++++++-- .../yueeng/moebooru/SettingsActivity.kt | 15 ++++++- .../github/yueeng/moebooru/SimilarActivity.kt | 17 +++++++- .../github/yueeng/moebooru/UserActivity.kt | 39 ++++++++++++++++--- 9 files changed, 134 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/github/yueeng/moebooru/CropActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/CropActivity.kt index 6263cf34..af5453de 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/CropActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/CropActivity.kt @@ -25,7 +25,7 @@ import com.bumptech.glide.request.transition.Transition import com.yalantis.ucrop.UCrop import com.yalantis.ucrop.UCropActivity import java.io.File -import java.util.* +import java.util.UUID class CropActivity : AppCompatActivity() { companion object { diff --git a/app/src/main/java/com/github/yueeng/moebooru/Db.kt b/app/src/main/java/com/github/yueeng/moebooru/Db.kt index 3ae9efb0..f0db9734 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/Db.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/Db.kt @@ -2,9 +2,23 @@ package com.github.yueeng.moebooru import android.content.Context import androidx.paging.PagingSource -import androidx.room.* +import androidx.room.ColumnInfo +import androidx.room.Dao +import androidx.room.Database +import androidx.room.Delete +import androidx.room.Entity +import androidx.room.Index +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.PrimaryKey +import androidx.room.Query +import androidx.room.Room +import androidx.room.RoomDatabase +import androidx.room.TypeConverter +import androidx.room.TypeConverters +import androidx.room.Update import kotlinx.coroutines.flow.Flow -import java.util.* +import java.util.Date @Entity( tableName = "tags", diff --git a/app/src/main/java/com/github/yueeng/moebooru/MainApplication.kt b/app/src/main/java/com/github/yueeng/moebooru/MainApplication.kt index 636adc3b..da3c828b 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/MainApplication.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/MainApplication.kt @@ -19,7 +19,11 @@ import android.transition.Explode import android.transition.Fade import android.transition.Slide import android.transition.TransitionSet -import android.view.* +import android.view.Gravity +import android.view.Menu +import android.view.MenuItem +import android.view.View +import android.view.Window import android.widget.TextView import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity @@ -38,7 +42,12 @@ import androidx.lifecycle.asFlow import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import com.google.android.material.snackbar.Snackbar -import com.google.android.material.transition.platform.* +import com.google.android.material.transition.platform.MaterialArcMotion +import com.google.android.material.transition.platform.MaterialContainerTransform +import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback +import com.google.android.material.transition.platform.MaterialElevationScale +import com.google.android.material.transition.platform.MaterialFadeThrough +import com.google.android.material.transition.platform.MaterialSharedAxis import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.drop import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/github/yueeng/moebooru/PopularActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/PopularActivity.kt index 2a86fe05..beccf085 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/PopularActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/PopularActivity.kt @@ -1,7 +1,12 @@ package com.github.yueeng.moebooru import android.os.Bundle -import android.view.* +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.core.os.bundleOf import androidx.core.view.MenuProvider @@ -21,7 +26,9 @@ import com.github.yueeng.moebooru.databinding.PopularTabItemBinding import com.google.android.material.datepicker.CalendarConstraints import com.google.android.material.datepicker.MaterialDatePicker import java.text.SimpleDateFormat -import java.util.* +import java.util.Calendar +import java.util.Date +import java.util.Locale class PopularActivity : MoeActivity(R.layout.activity_container) { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/github/yueeng/moebooru/PreviewActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/PreviewActivity.kt index 01d04a2e..431a09a9 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/PreviewActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/PreviewActivity.kt @@ -26,7 +26,14 @@ import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels -import androidx.lifecycle.* +import androidx.lifecycle.AbstractSavedStateViewModelFactory +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import androidx.lifecycle.asFlow +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import androidx.paging.LoadState import androidx.paging.PagingDataAdapter import androidx.palette.graphics.Palette @@ -50,9 +57,18 @@ import com.google.android.flexbox.FlexDirection import com.google.android.flexbox.FlexboxLayoutManager import com.google.android.material.bottomsheet.BottomSheetBehavior import jp.wasabeef.glide.transformations.BlurTransformation -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.* -import java.util.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.distinctUntilChangedBy +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.mapNotNull +import kotlinx.coroutines.flow.onCompletion +import kotlinx.coroutines.flow.sample +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import java.util.Locale import kotlin.math.max diff --git a/app/src/main/java/com/github/yueeng/moebooru/SavedActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/SavedActivity.kt index 8ad38d9a..c2d5a64c 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/SavedActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/SavedActivity.kt @@ -8,8 +8,20 @@ import android.view.View import android.view.ViewGroup import androidx.core.view.isVisible import androidx.fragment.app.Fragment -import androidx.lifecycle.* -import androidx.paging.* +import androidx.lifecycle.AbstractSavedStateViewModelFactory +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import androidx.lifecycle.asFlow +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import androidx.lifecycle.viewModelScope +import androidx.paging.LoadState +import androidx.paging.Pager +import androidx.paging.PagingConfig +import androidx.paging.PagingDataAdapter +import androidx.paging.cachedIn +import androidx.paging.insertHeaderItem import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.RecyclerView @@ -23,7 +35,7 @@ import com.google.android.flexbox.FlexboxLayoutManager import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch -import java.util.* +import java.util.Date import kotlin.math.min diff --git a/app/src/main/java/com/github/yueeng/moebooru/SettingsActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/SettingsActivity.kt index 2ee4f539..7e79848c 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/SettingsActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/SettingsActivity.kt @@ -9,8 +9,19 @@ import android.view.Menu import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.core.content.edit -import androidx.lifecycle.* -import androidx.preference.* +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LiveData +import androidx.lifecycle.MediatorLiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ProcessLifecycleOwner +import androidx.lifecycle.asFlow +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import androidx.preference.EditTextPreference +import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat +import androidx.preference.PreferenceManager +import androidx.preference.SeekBarPreference import com.google.android.material.textfield.TextInputLayout import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/app/src/main/java/com/github/yueeng/moebooru/SimilarActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/SimilarActivity.kt index c75ccf4c..1a19dbd0 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/SimilarActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/SimilarActivity.kt @@ -14,8 +14,21 @@ import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels -import androidx.lifecycle.* -import androidx.paging.* +import androidx.lifecycle.AbstractSavedStateViewModelFactory +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import androidx.lifecycle.asFlow +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import androidx.lifecycle.viewModelScope +import androidx.paging.LoadState +import androidx.paging.Pager +import androidx.paging.PagingConfig +import androidx.paging.PagingDataAdapter +import androidx.paging.PagingSource +import androidx.paging.PagingState +import androidx.paging.cachedIn import androidx.recyclerview.widget.RecyclerView import androidx.savedstate.SavedStateRegistryOwner import com.bumptech.glide.Glide diff --git a/app/src/main/java/com/github/yueeng/moebooru/UserActivity.kt b/app/src/main/java/com/github/yueeng/moebooru/UserActivity.kt index 6d3edff8..27d33459 100644 --- a/app/src/main/java/com/github/yueeng/moebooru/UserActivity.kt +++ b/app/src/main/java/com/github/yueeng/moebooru/UserActivity.kt @@ -4,24 +4,53 @@ import android.app.ActivityOptions import android.content.Intent import android.os.Bundle import android.os.Parcelable -import android.view.* +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels -import androidx.lifecycle.* +import androidx.lifecycle.AbstractSavedStateViewModelFactory +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import androidx.lifecycle.asFlow +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import androidx.savedstate.SavedStateRegistryOwner import com.bumptech.glide.Glide import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions -import com.github.yueeng.moebooru.databinding.* +import com.github.yueeng.moebooru.databinding.FragmentStarBinding +import com.github.yueeng.moebooru.databinding.FragmentUserBinding +import com.github.yueeng.moebooru.databinding.UserImageItemBinding +import com.github.yueeng.moebooru.databinding.UserTagItemBinding +import com.github.yueeng.moebooru.databinding.UserTitleItemBinding +import com.github.yueeng.moebooru.databinding.VoteTitleItemBinding +import com.github.yueeng.moebooru.databinding.VoteUserItemBinding import com.google.android.flexbox.FlexDirection import com.google.android.flexbox.FlexboxLayoutManager -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.drop +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.flattenMerge +import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.flow.mapNotNull +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import kotlinx.parcelize.Parcelize import okhttp3.Request import org.jsoup.Jsoup