Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,15 @@ import android.transition.Fade
import android.transition.TransitionManager
import android.transition.TransitionSet
import android.util.FloatProperty
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.VelocityTracker
import android.view.View
import android.view.*
import android.view.View.GONE
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.widget.ImageView
import android.widget.LinearLayout.HORIZONTAL
import android.widget.LinearLayout.VERTICAL
import android.widget.SeekBar
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

private val grid by lazy(LazyThreadSafetyMode.NONE) {
findViewById<RecyclerView>(R.id.grid)
}
private val damping by lazy(LazyThreadSafetyMode.NONE) {
findViewById<SeekBar>(R.id.damping)
}
private val stiffness by lazy(LazyThreadSafetyMode.NONE) {
findViewById<SeekBar>(R.id.stiffness)
}
private val velocityTracker = VelocityTracker.obtain()
private val corners: FloatArray by lazy(LazyThreadSafetyMode.NONE) {
val density = resources.displayMetrics.density
Expand Down Expand Up @@ -163,7 +149,7 @@ class MainActivity : AppCompatActivity() {

val fastOutSlowIn = AnimationUtils.loadInterpolator(
this, android.R.interpolator.fast_out_slow_in)
findViewById<View>(R.id.mask).setOnClickListener {
mask.setOnClickListener {
corner = ++corner % corners.size
with(ObjectAnimator.ofFloat(
this@MainActivity,
Expand Down Expand Up @@ -194,7 +180,7 @@ class MainActivity : AppCompatActivity() {
(grid.layoutManager as GridLayoutManager).orientation = orientation
}

with(findViewById<ImageView>(R.id.background)) {
with(background) {
setOnClickListener {
decor = decor.next()
grid.setBackgroundResource(decor.background)
Expand All @@ -210,16 +196,16 @@ class MainActivity : AppCompatActivity() {
}
}

findViewById<SeekBar>(R.id.foreground_parallax)
foreground_parallax
.onSeek { progress -> foregroundTranslateFactor = progress / 100f }
findViewById<SeekBar>(R.id.background_parallax)
background_parallax
.onSeek { progress -> backgroundTranslateFactor = progress / 100f }
findViewById<SeekBar>(R.id.foreground_scale)
foreground_scale
.onSeek { progress -> foregroundScaleFactor = progress / 100f }
findViewById<SeekBar>(R.id.background_scale)
background_scale
.onSeek { progress -> backgroundScaleFactor = progress / 100f }

BottomSheetBehavior.from(findViewById<View>(R.id.settings_sheet)).setBottomSheetCallback(
BottomSheetBehavior.from(settings_sheet).setBottomSheetCallback(
object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {}

Expand All @@ -238,7 +224,7 @@ class MainActivity : AppCompatActivity() {

override fun onLoadFinished(loader: Loader<List<AdaptiveIconDrawable>>,
data: List<AdaptiveIconDrawable>) {
findViewById<View>(R.id.loading).visibility = GONE
loading.visibility = GONE
adapter = IconAdapter(data, corners[0])
grid.adapter = adapter
grid.setOnTouchListener(gridTouch)
Expand Down Expand Up @@ -402,6 +388,7 @@ class MainActivity : AppCompatActivity() {
setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) =
progressChanged(progress)

override fun onStartTrackingTouch(seekBar: SeekBar) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar) = Unit
})
Expand Down