================================================
FILE: .idea/vcs.xml
================================================
================================================
FILE: README.md
================================================
# ElasticView

[](https://android-arsenal.com/api?level=21)
[](https://android-arsenal.com/details/1/7274)
Elastic view is a regular **CardView**, which can **flex** from user touches💪
**Kotlin** ❤️

Let's see it in action 💻📲


### Download sample [apk](https://github.com/armcha/ElasticView/raw/master/screens/sample.apk) :arrow_down:
The current minSDK version is API level 21.
### Download
Gradle:
```groovy
implementation 'com.github.armcha:ElasticView:0.2.0'
```
## Setup and usage
You can use it as a regualar CardView.
```xml
```
## Customization
For now, you can only change flexibility for the view
from code
```kotlin
elasticView.flexibility = 8f
```
or from xml
```xml
```
**Note the flexibility must be between [1f..10f] ❗️**
That's all :ok_hand:
### Contact :book:
:arrow_forward: **Email**: chatikyana@gmail.com
:arrow_forward: **Medium**: https://medium.com/@chatikyan
:arrow_forward: **Twitter**: https://twitter.com/ArmanChatikyan
:arrow_forward: **Google+**: https://plus.google.com/+ArmanChatikyan
:arrow_forward: **Website**: https://armcha.github.io/
License
--------
ElasticView
Copyright (c) 2018 Arman Chatikyan (https://github.com/armcha/ElasticView).
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle
================================================
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "io.armcha.sampleapp"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation project(':elastic_view')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: app/src/androidTest/java/io/armcha/sampleapp/ExampleInstrumentedTest.kt
================================================
package io.armcha.sampleapp
import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("io.armcha.sampleapp", appContext.packageName)
}
}
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
================================================
FILE: app/src/main/java/io/armcha/sampleapp/MainActivity.kt
================================================
package io.armcha.sampleapp
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//imageElasticView.flexibility = 8f
imageElasticView.isDebugPathEnabled = true
buttonElasticView.setOnClickListener {
startActivity(Intent(this, RecyclerViewActivity::class.java))
}
seekBar.setOnSeekBarChangeListener(object : SeekBarChangeListener() {
override fun onProgress(progress: Int) {
imageElasticView.flexibility = progress / 10f + 1f
seekBarText.text = "Flexibility is ${imageElasticView.flexibility}f"
}
})
seekBar.progress = 40
}
}
================================================
FILE: app/src/main/java/io/armcha/sampleapp/RecyclerViewActivity.kt
================================================
package io.armcha.sampleapp
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_recycler_view.*
class RecyclerViewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_recycler_view)
recyclerView setUpWith SimpleAdapter()
}
}
================================================
FILE: app/src/main/java/io/armcha/sampleapp/SeekBarChangeListener.kt
================================================
package io.armcha.sampleapp
import android.widget.SeekBar
/**
*
* Created by Arman Chatikyan on 29 Oct 2018
*
*/
abstract class SeekBarChangeListener : SeekBar.OnSeekBarChangeListener {
abstract fun onProgress(progress: Int)
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
onProgress(progress)
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
}
================================================
FILE: app/src/main/java/io/armcha/sampleapp/SimpleAdapter.kt
================================================
package io.armcha.sampleapp
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.squareup.picasso.Picasso
import io.armcha.sampleapp.data.DataSource
import kotlinx.android.synthetic.main.item_view.view.*
class SimpleAdapter : RecyclerView.Adapter() {
private val items = DataSource.items
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_view, parent, false))
}
override fun getItemCount(): Int {
return items.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = items[position]
holder.bind(item)
}
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bind(imageUrl: String) {
Picasso.get()
.load(imageUrl)
.into(itemView.imageView)
itemView.nameText.text = "Item for position $adapterPosition"
}
}
}
infix fun RecyclerView.setUpWith(simpleAdapter: SimpleAdapter) {
adapter = simpleAdapter
layoutManager = LinearLayoutManager(context)
}
================================================
FILE: app/src/main/java/io/armcha/sampleapp/data/DataSource.kt
================================================
package io.armcha.sampleapp.data
object DataSource {
val items by lazy {
mutableListOf().apply {
repeat(5) {
add("https://cdn.pixabay.com/photo/2016/05/16/17/59/strawberries-1396330_640.jpg")
add("https://cdn.pixabay.com/photo/2018/02/08/22/27/flower-3140492_640.jpg")
add("https://cdn.pixabay.com/photo/2018/02/07/17/53/poppy-3137588_640.jpg")
add("https://cdn.pixabay.com/photo/2018/02/06/14/07/dance-3134828_640.jpg")
add("https://cdn.pixabay.com/photo/2012/04/26/22/31/substances-43354_640.jpg")
add("https://cdn.pixabay.com/photo/2017/06/06/22/46/mediterranean-cuisine-2378758_640.jpg")
add("https://cdn.pixabay.com/photo/2018/02/01/19/21/easter-3123834_640.jpg")
add("https://cdn.pixabay.com/photo/2017/11/29/09/15/paint-2985569_640.jpg")
add("https://cdn.pixabay.com/photo/2017/11/18/17/09/strawberry-2960533_640.jpg")
add("https://cdn.pixabay.com/photo/2017/11/05/00/46/flower-2919284_640.jpg")
add("https://cdn.pixabay.com/photo/2017/09/25/20/44/peppers-2786684_640.jpg")
add("https://cdn.pixabay.com/photo/2017/09/01/21/53/blue-2705642_640.jpg")
add("https://cdn.pixabay.com/photo/2017/05/31/18/38/sea-2361247_640.jpg")
add("https://cdn.pixabay.com/photo/2018/02/02/22/28/nature-3126513_640.jpg")
add("https://cdn.pixabay.com/photo/2018/01/28/21/14/lens-3114729_640.jpg")
add("https://cdn.pixabay.com/photo/2018/01/27/05/49/woman-3110483_640.jpg")
add("https://cdn.pixabay.com/photo/2018/01/31/16/27/sea-3121435_640.jpg")
add("https://cdn.pixabay.com/photo/2018/01/31/12/16/architecture-3121009_640.jpg")
add("https://cdn.pixabay.com/photo/2018/01/28/14/41/bird-3113835_640.jpg")
add("https://cdn.pixabay.com/photo/2018/01/28/17/48/gallery-3114279_640.jpg")
add("https://cdn.pixabay.com/photo/2017/11/26/19/50/jeans-2979818_640.jpg")
add("https://cdn.pixabay.com/photo/2017/12/15/13/51/polynesia-3021072_640.jpg")
add("https://cdn.pixabay.com/photo/2016/11/13/00/40/girl-1820122_640.jpg")
}
}
}
}
================================================
FILE: app/src/main/res/drawable/ic_launcher_background.xml
================================================
================================================
FILE: app/src/main/res/drawable-v24/ic_launcher_foreground.xml
================================================
================================================
FILE: app/src/main/res/layout/activity_main.xml
================================================
================================================
FILE: app/src/main/res/layout/activity_recycler_view.xml
================================================
================================================
FILE: app/src/main/res/layout/item_view.xml
================================================
================================================
FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
================================================
================================================
FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
================================================
================================================
FILE: app/src/main/res/values/attrs_my_view.xml
================================================
================================================
FILE: app/src/main/res/values/colors.xml
================================================
#008577#00574B#D81B60#D1D1D1
================================================
FILE: app/src/main/res/values/strings.xml
================================================
SampleApp
================================================
FILE: app/src/main/res/values/styles.xml
================================================
================================================
FILE: app/src/test/java/io/armcha/sampleapp/ExampleUnitTest.kt
================================================
package io.armcha.sampleapp
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
fun `this is test case for`(){
}
}
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-beta04'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "guru.stefma.bintrayrelease:bintrayrelease:1.1.1"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: elastic_view/.gitignore
================================================
/build
================================================
FILE: elastic_view/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'guru.stefma.bintrayrelease'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
tasks.withType(Javadoc).all { enabled = false }
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' }
mavenCentral()
}
version = "0.2.0"
group = "com.github.armcha"
publish {
userOrg = 'armcha'
artifactId = 'ElasticView'
desc = 'ElasticView'
website = 'https://github.com/armcha/ElasticView'
}
================================================
FILE: elastic_view/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: elastic_view/src/main/AndroidManifest.xml
================================================
================================================
FILE: elastic_view/src/main/kotlin/io/armcha/elasticview/CentrePointProvider.kt
================================================
package io.armcha.elasticview
import android.view.MotionEvent
import android.view.View
internal abstract class CentrePointProvider(protected val parentView: View) {
private val screenOffDistance = -300f
protected var cx = screenOffDistance
protected var cy = screenOffDistance
init {
parentView.setOnTouchListener { v, event ->
attach(event)
v.onTouchEvent(event)
}
}
private fun attach(event: MotionEvent) {
val (x, y) = if (event.action == MotionEvent.ACTION_MOVE) {
event.x to event.y
} else {
screenOffDistance to screenOffDistance
}
cx = x
cy = y
parentView.invalidate()
}
}
================================================
FILE: elastic_view/src/main/kotlin/io/armcha/elasticview/DebugPath.kt
================================================
package io.armcha.elasticview
import android.graphics.*
import android.view.View
internal class DebugPath(parentView: View) : CentrePointProvider(parentView) {
private val _pathPaint by lazy {
Paint().apply {
style = Paint.Style.STROKE
color = Color.WHITE
strokeWidth = 2f
pathEffect = DashPathEffect(floatArrayOf(20f, 10f), 0f)
}
}
private val _circlePaint by lazy {
Paint().apply {
style = Paint.Style.FILL
color = Color.WHITE
}
}
private val _horizontalPath = Path()
private val _verticalPath = Path()
fun onDispatchDraw(canvas: Canvas?) {
_verticalPath.reset()
_horizontalPath.reset()
_horizontalPath.moveTo(cx, 0f)
_horizontalPath.lineTo(cx, parentView.height.toFloat())
_verticalPath.moveTo(0f, cy)
_verticalPath.lineTo(parentView.width.toFloat(), cy)
canvas?.run {
drawPath(_horizontalPath, _pathPaint)
drawPath(_verticalPath, _pathPaint)
drawCircle(cx, cy, 15f, _circlePaint)
}
}
}
================================================
FILE: elastic_view/src/main/kotlin/io/armcha/elasticview/ElasticView.kt
================================================
package io.armcha.elasticview
import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.ViewPropertyAnimator
import com.google.android.material.card.MaterialCardView
class ElasticView(context: Context, attrs: AttributeSet? = null) : MaterialCardView(context, attrs) {
private val ANIMATION_DURATION = 200L
private val ANIMATION_DURATION_SHORT = 100L
private var _isAnimating = false
private var _isActionUpPerformed = false
private val _debugPath by lazy {
DebugPath(this)
}
private val _shineProvider by lazy {
ShineProvider(this)
}
//Will be available in next versions
private var isShineEnabled = false
var flexibility = 5f
set(value) {
if (value !in 1f..10f) {
throw IllegalArgumentException("Flexibility must be between [1f..10f].")
}
field = value
}
var isDebugPathEnabled = false
init {
isClickable = true
init(attrs)
}
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
processTouchEvent(event)
return super.dispatchTouchEvent(event)
}
override fun dispatchDraw(canvas: Canvas?) {
super.dispatchDraw(canvas)
if (isDebugPathEnabled)
_debugPath.onDispatchDraw(canvas)
if (isShineEnabled)
_shineProvider.onDispatchDraw(canvas)
}
private fun processTouchEvent(event: MotionEvent) {
val verticalRotation = calculateRotation((event.x * flexibility * 2) / width)
val horizontalRotation = -calculateRotation((event.y * flexibility * 2) / height)
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
animator {
rotationY(verticalRotation)
rotationX(horizontalRotation)
duration = ANIMATION_DURATION_SHORT
withStartAction {
_isActionUpPerformed = false
_isAnimating = true
}
withEndAction {
if (_isActionUpPerformed) {
animateToOriginalPosition()
} else {
_isAnimating = false
}
}
}
}
MotionEvent.ACTION_MOVE -> {
rotationY = verticalRotation
rotationX = horizontalRotation
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_OUTSIDE -> {
_isActionUpPerformed = true
if (!_isAnimating) {
animateToOriginalPosition()
}
}
}
}
private fun init(attrs: AttributeSet?) {
context.obtainStyledAttributes(attrs, R.styleable.ElasticView).apply {
if (hasValue(R.styleable.ElasticView_flexibility)) {
flexibility = getFloat(R.styleable.ElasticView_flexibility, flexibility)
}
recycle()
}
}
private fun animator(body: ViewPropertyAnimator.() -> Unit) {
animate().apply {
interpolator = FastOutSlowInInterpolator()
body()
start()
}
}
private fun animateToOriginalPosition() {
animator {
rotationX(0f)
rotationY(0f)
duration = ANIMATION_DURATION
}
}
private fun calculateRotation(value: Float): Float {
var tempValue = when {
value < 0 -> 1f
value > flexibility * 2 -> flexibility * 2
else -> value
}
tempValue -= flexibility
return tempValue
}
}
================================================
FILE: elastic_view/src/main/kotlin/io/armcha/elasticview/FastOutSlowInInterpolator.kt
================================================
package io.armcha.elasticview
import android.view.animation.Interpolator
internal class FastOutSlowInInterpolator : Interpolator {
private val _values = floatArrayOf(0.0f, 1.0E-4f, 2.0E-4f, 5.0E-4f, 9.0E-4f, 0.0014f,
0.002f, 0.0027f, 0.0036f, 0.0046f, 0.0058f, 0.0071f, 0.0085f, 0.0101f, 0.0118f, 0.0137f,
0.0158f, 0.018f, 0.0205f, 0.0231f, 0.0259f, 0.0289f, 0.0321f, 0.0355f, 0.0391f, 0.043f,
0.0471f, 0.0514f, 0.056f, 0.0608f, 0.066f, 0.0714f, 0.0771f, 0.083f, 0.0893f, 0.0959f,
0.1029f, 0.1101f, 0.1177f, 0.1257f, 0.1339f, 0.1426f, 0.1516f, 0.161f, 0.1707f, 0.1808f,
0.1913f, 0.2021f, 0.2133f, 0.2248f, 0.2366f, 0.2487f, 0.2611f, 0.2738f, 0.2867f, 0.2998f,
0.3131f, 0.3265f, 0.34f, 0.3536f, 0.3673f, 0.381f, 0.3946f, 0.4082f, 0.4217f, 0.4352f,
0.4485f, 0.4616f, 0.4746f, 0.4874f, 0.5f, 0.5124f, 0.5246f, 0.5365f, 0.5482f, 0.5597f,
0.571f, 0.582f, 0.5928f, 0.6033f, 0.6136f, 0.6237f, 0.6335f, 0.6431f, 0.6525f, 0.6616f,
0.6706f, 0.6793f, 0.6878f, 0.6961f, 0.7043f, 0.7122f, 0.7199f, 0.7275f, 0.7349f, 0.7421f,
0.7491f, 0.7559f, 0.7626f, 0.7692f, 0.7756f, 0.7818f, 0.7879f, 0.7938f, 0.7996f, 0.8053f,
0.8108f, 0.8162f, 0.8215f, 0.8266f, 0.8317f, 0.8366f, 0.8414f, 0.8461f, 0.8507f, 0.8551f,
0.8595f, 0.8638f, 0.8679f, 0.872f, 0.876f, 0.8798f, 0.8836f, 0.8873f, 0.8909f, 0.8945f,
0.8979f, 0.9013f, 0.9046f, 0.9078f, 0.9109f, 0.9139f, 0.9169f, 0.9198f, 0.9227f, 0.9254f,
0.9281f, 0.9307f, 0.9333f, 0.9358f, 0.9382f, 0.9406f, 0.9429f, 0.9452f, 0.9474f, 0.9495f,
0.9516f, 0.9536f, 0.9556f, 0.9575f, 0.9594f, 0.9612f, 0.9629f, 0.9646f, 0.9663f, 0.9679f,
0.9695f, 0.971f, 0.9725f, 0.9739f, 0.9753f, 0.9766f, 0.9779f, 0.9791f, 0.9803f, 0.9815f,
0.9826f, 0.9837f, 0.9848f, 0.9858f, 0.9867f, 0.9877f, 0.9885f, 0.9894f, 0.9902f, 0.991f,
0.9917f, 0.9924f, 0.9931f, 0.9937f, 0.9944f, 0.9949f, 0.9955f, 0.996f, 0.9964f, 0.9969f,
0.9973f, 0.9977f, 0.998f, 0.9984f, 0.9986f, 0.9989f, 0.9991f, 0.9993f, 0.9995f, 0.9997f,
0.9998f, 0.9999f, 0.9999f, 1.0f, 1.0f)
private val _stepSize by lazy {
1 / (_values.size - 1f)
}
override fun getInterpolation(input: Float): Float {
return when {
input >= 1.0f -> 1.0f
input <= 0.0f -> 0.0f
else -> {
val position = Math.min((input * (_values.size - 1)).toInt(), _values.size - 2)
val quantized = position * _stepSize
val diff = input - quantized
val weight = diff / _stepSize
_values[position] + weight * (_values[position + 1] - _values[position])
}
}
}
}
================================================
FILE: elastic_view/src/main/kotlin/io/armcha/elasticview/ShineProvider.kt
================================================
package io.armcha.elasticview
import android.graphics.*
import androidx.core.content.ContextCompat
import android.view.View
internal class ShineProvider(parentView: View) : CentrePointProvider(parentView) {
private val _paint by lazy {
Paint().apply {
color = Color.BLACK
style = Paint.Style.FILL
}
}
private val _centreColor by lazy {
ContextCompat.getColor(parentView.context, R.color.startColor)
}
private val _shineRadius by lazy {
parentView.height / 2.5f
}
fun onDispatchDraw(canvas: Canvas?) {
_paint.shader = RadialGradient(cx, cy, _shineRadius, _centreColor,
Color.TRANSPARENT, Shader.TileMode.CLAMP)
canvas?.drawCircle(cx, cy, _shineRadius, _paint)
}
}
================================================
FILE: elastic_view/src/main/res/drawable/shine.xml
================================================
================================================
FILE: elastic_view/src/main/res/values/attrs_elastic_view.xml
================================================
================================================
FILE: elastic_view/src/main/res/values/colors.xml
================================================
#59FFFFFF#23FFFFFF
================================================
FILE: elastic_view/src/main/res/values/strings.xml
================================================
elastic_view
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Tue Oct 23 11:24:05 AMT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
include ':app', ':elastic_view'