├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── dictionaries │ └── hamed.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── 20181203_182931.gif ├── README.md ├── Scaling-RecyclerView.zip ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── hamedrahimvand │ │ └── scalingrecyclerview │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── hamedrahimvand │ │ │ └── scalingrecyclerview │ │ │ ├── ScalingLayoutManager.kt │ │ │ ├── ScalingRecyclerView.kt │ │ │ ├── adapter │ │ │ └── ScalingRecyclerAdapter.kt │ │ │ ├── model │ │ │ └── ScalingRecyclerModel.kt │ │ │ └── utils │ │ │ └── ConverterUtils.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── background_award_header.xml │ │ ├── card_bg.xml │ │ ├── card_bg_light.xml │ │ ├── ic_launcher_background.xml │ │ └── transparent.xml │ │ ├── layout │ │ ├── item_scaling_recyclerview.xml │ │ └── scailing_recyclerview.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── hamedrahimvand │ └── scalingrecyclerview │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 177 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/dictionaries/hamed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hamed 5 | rahimvand 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /20181203_182931.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/20181203_182931.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scaling Recyclerview 2 | 3 | 4 | __Demo__ 5 | 6 | 7 | ![](20181203_182931.gif) 8 | 9 | 10 | __scaling-recyclerview developed with Kotlin and AndroidX.__ 11 | 12 | __Note:__ for use it you most migrate your project to [AndroidX](https://developer.android.com/jetpack/androidx/migrate). 13 | 14 | __you can add snap feature to your S.R.V. with setSnap(true)__ 15 | 16 | 17 | --- 18 | 19 | ## How to add? 20 | 21 | First of all change ```build.gradle(project)```, add below maven 22 | ``` 23 | allprojects { 24 | repositories { 25 | ... 26 | maven { url 'https://jitpack.io' } 27 | } 28 | } 29 | ``` 30 | And on ```build.gradle(app)```, add below line 31 | ``` 32 | implementation 'com.github.rvhamed:scaling-recyclerview:v1.0.0-beta.1' 33 | ``` 34 | __FINISH ;)__ 35 | 36 | --- 37 | 38 | ## How to use? 39 | 40 | Add ```ScalinRecyclerView``` to your ```xml``` file 41 | ``` 42 | 46 | 47 | ``` 48 | 49 | After that on your ```java/kotlin class``` 50 | 51 | __Note:__ this sample is with [kotlin](http://kotlinlang.org/). 52 | ======= 53 | 54 | 55 | ``` 56 | //find and initialize 57 | val srcMain = findViewById(R.id.src_main) 58 | 59 | ``` 60 | ___How to set adapter? How to create ScalingRecyclerModel?___ 61 | 62 | With below code you can create an object of your item with ```ScalingRecyclerModel```. Notice these fields are optional. 63 | ``` 64 | ScalingRecyclerModel.Builder() 65 | .firstTitle("Hamed" /*item primary text*/) 66 | .secondTitle("120 Score" /*item secondry text*/) 67 | .imageUrl("http://myImageUrl.com/.../hamed.jpg" /*item image url*/) 68 | .visibility(View.VISIBLE) 69 | .build() 70 | 71 | ``` 72 | Create ```ArrayList``` of ```ScalingRecyclerModel``` and setAdapter 73 | 74 | ``` 75 | srcMain.setAdapter(srmList) 76 | 77 | ``` 78 | At least you can add snap feature with 79 | ``` 80 | srcMain.setSnap(true) 81 | ``` 82 | 83 | __Note:__ Remember for use Glide to load images you need to set Internet Permission in manifest 84 | ``` 85 | 86 | 87 | ``` 88 | 89 | cool It was all that ;) 90 | 91 | __You can Fork it and Development it :)__ 92 | 93 | --- 94 | 95 | ## Methods 96 | 97 | - ```srcMain.setAdapter(srmList)``` 98 | - ```srcMain.setSnap(boolean)``` 99 | - ```srcMain.setLayoutOrientation(RecyclerView.VERTICAL/HORIZONTAL)``` 100 | - ```srcMain.addItem(srm)``` 101 | - ```srcMain.addItem(srmList)``` 102 | - ```srcMain.setFirstTitleTextAppearance(styleResId)``` 103 | - ```srcMain.setSecondTitleTextAppearance(styleResId)``` 104 | - ```srcMain.setFirstLayoutBackground(resId)``` 105 | - ```srcMain.setSecondLayoutBackground(resId)``` 106 | - ```srcMain.setThirdLayoutBackground(resId)``` 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /Scaling-RecyclerView.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/Scaling-RecyclerView.zip -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | defaultConfig { 10 | minSdkVersion 14 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 27 | implementation 'androidx.appcompat:appcompat:1.0.2' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'androidx.test:runner:1.1.1-alpha01' 30 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1-alpha01' 31 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' 32 | implementation 'androidx.core:core-ktx:1.0.1' 33 | implementation 'androidx.cardview:cardview:1.0.0' 34 | implementation 'androidx.recyclerview:recyclerview:1.0.0' 35 | implementation 'com.google.android.material:material:1.0.0' 36 | 37 | //noinspection GradleDependency 38 | implementation 'com.github.bumptech.glide:glide:3.8.0' 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/hamedrahimvand/scalingrecyclerview/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview 2 | 3 | import androidx.test.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @Suppress("DEPRECATION") 17 | @RunWith(AndroidJUnit4::class) 18 | class ExampleInstrumentedTest { 19 | @Test 20 | fun useAppContext() { 21 | // Context of the app under test. 22 | val appContext = InstrumentationRegistry.getTargetContext() 23 | assertEquals("com.hamed.scalingrecyclerview", appContext.packageName) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/java/com/hamedrahimvand/scalingrecyclerview/ScalingLayoutManager.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview 2 | 3 | import android.content.Context 4 | import android.widget.FrameLayout 5 | import androidx.recyclerview.widget.RecyclerView 6 | import androidx.recyclerview.widget.LinearLayoutManager 7 | 8 | /** 9 | * Created By Hamed Rahimvand on 3 December 2018 10 | */ 11 | 12 | class ScalingLayoutManager(context: Context, orientation: Int, reverseLayout: Boolean) : 13 | LinearLayoutManager(context, orientation, reverseLayout) { 14 | constructor (context: Context, orientation: Int) : this(context, orientation, false) 15 | constructor(context: Context) : this(context, RecyclerView.VERTICAL, false) 16 | 17 | private val mShrinkAmount = 0.3f 18 | private val mShrinkDistance = 0.9f 19 | 20 | override fun scrollVerticallyBy( 21 | dy: Int, 22 | recycler: RecyclerView.Recycler?, 23 | state: RecyclerView.State? 24 | ): Int { 25 | 26 | return scale(orientation, dy, recycler, state) 27 | } 28 | 29 | override fun scrollHorizontallyBy( 30 | dx: Int, 31 | recycler: RecyclerView.Recycler?, 32 | state: RecyclerView.State? 33 | ): Int { 34 | return scale(orientation, dx, recycler, state) 35 | } 36 | 37 | fun scale( 38 | orientation: Int, dxORdy: Int, 39 | recycler: RecyclerView.Recycler?, 40 | state: RecyclerView.State? 41 | ): Int { 42 | when (orientation) { 43 | HORIZONTAL -> { 44 | val scrolled = super.scrollHorizontallyBy(dxORdy, recycler, state) 45 | 46 | val midpoint = width / 2f 47 | val d0 = 0f 48 | val d1 = mShrinkDistance * midpoint 49 | val s0 = 1f 50 | val s1 = 1f - mShrinkAmount 51 | for (i in 0 until childCount) { 52 | val child = getChildAt(i) 53 | val childMidpoint = (getDecoratedRight(child!!) + getDecoratedLeft(child)) / 2f 54 | val d = Math.min(d1, Math.abs(midpoint - childMidpoint)) 55 | val scale = s0 + (s1 - s0) * (d - d0) / (d1 - d0) 56 | child.scaleX = scale 57 | child.scaleY = scale 58 | 59 | val frlSecondLayout = child.findViewById(R.id.frl_secondLayout) 60 | val frlThirdLayout = child.findViewById(R.id.frl_thirdLayout) 61 | 62 | frlSecondLayout.scaleX = scale + 0.2f 63 | frlSecondLayout.scaleY = scale + 0.2f 64 | frlThirdLayout.scaleX = scale + 0.45f 65 | frlThirdLayout.scaleY = scale + 0.45f 66 | } 67 | return scrolled 68 | } 69 | VERTICAL -> { 70 | val scrolled = super.scrollVerticallyBy(dxORdy, recycler, state) 71 | val midpoint = height / 2f 72 | val d0 = 0f 73 | val d1 = mShrinkDistance * midpoint 74 | val s0 = 1f 75 | val s1 = 1f - mShrinkAmount 76 | for (i in 0 until childCount) { 77 | val child = getChildAt(i) 78 | val childMidpoint = (getDecoratedBottom(child!!) + getDecoratedTop(child)) / 2f 79 | val d = Math.min(d1, Math.abs(midpoint - childMidpoint)) 80 | val scale = s0 + (s1 - s0) * (d - d0) / (d1 - d0) 81 | child.scaleX = scale 82 | child.scaleY = scale 83 | 84 | val frlSecondLayout = child.findViewById(R.id.frl_secondLayout) 85 | val frlThirdLayout = child.findViewById(R.id.frl_thirdLayout) 86 | 87 | frlSecondLayout.scaleX = scale + 0.2f 88 | frlSecondLayout.scaleY = scale + 0.2f 89 | frlThirdLayout.scaleX = scale + 0.45f 90 | frlThirdLayout.scaleY = scale + 0.45f 91 | 92 | } 93 | return scrolled 94 | } 95 | else -> return 0 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hamedrahimvand/scalingrecyclerview/ScalingRecyclerView.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview 2 | 3 | import android.content.Context 4 | import android.graphics.drawable.Drawable 5 | import android.util.AttributeSet 6 | import android.view.View 7 | import androidx.annotation.DrawableRes 8 | import androidx.annotation.StyleRes 9 | import androidx.constraintlayout.widget.ConstraintLayout 10 | import androidx.recyclerview.widget.LinearSnapHelper 11 | import androidx.recyclerview.widget.RecyclerView 12 | import com.hamedrahimvand.scalingrecyclerview.adapter.ScalingRecyclerAdapter 13 | import com.hamedrahimvand.scalingrecyclerview.model.ScalingRecyclerModel 14 | 15 | /** 16 | * Created By Hamed Rahimvand on 3 December 2018 17 | */ 18 | 19 | class ScalingRecyclerView(context: Context, attributeSet: AttributeSet?, defStyle: Int) : 20 | ConstraintLayout(context, attributeSet, defStyle) { 21 | constructor(context: Context, attributeSet: AttributeSet?) : this(context, attributeSet, 0) 22 | constructor(context: Context) : this(context, null, 0) 23 | 24 | lateinit var scalingRecyclerAdapter: ScalingRecyclerAdapter 25 | lateinit var scalingRecyclerModelScoreList: ArrayList 26 | lateinit var recyclerView: RecyclerView 27 | /** 28 | * @see snapHelper 29 | */ 30 | fun setSnap(isSnap: Boolean){ 31 | snapHelper(isSnap) 32 | } 33 | 34 | 35 | 36 | init { 37 | inflate(context, R.layout.scailing_recyclerview, this) 38 | initRecyclerView() 39 | } 40 | 41 | /** 42 | * Base initialize of recyclerView 43 | */ 44 | private fun initRecyclerView() { 45 | recyclerView = findViewById(R.id.rcv_scaling) 46 | recyclerView.setHasFixedSize(true) 47 | 48 | setLayoutOrientation(RecyclerView.HORIZONTAL) 49 | } 50 | 51 | /** 52 | * Add snap feature to recyclerView with SnapHelper 53 | * @see isSnap by default is "false", developer can enable snap feature by set it true 54 | */ 55 | private fun snapHelper(isSnap: Boolean) { 56 | if (isSnap) { 57 | val topSnapHelper = LinearSnapHelper() 58 | topSnapHelper.attachToRecyclerView(recyclerView) 59 | } 60 | } 61 | 62 | /** 63 | * set custom ScalingLayoutManager that extended of LinearLayoutManager to recyclerView 64 | * @see ScalingLayoutManager 65 | * @param orientation Is ScalingRecyclerViw orientation, default value is RecyclerView#HORIZONTAL 66 | */ 67 | fun setLayoutOrientation(@RecyclerView.Orientation orientation : Int) { 68 | recyclerView.layoutManager = ScalingLayoutManager(context, orientation, false) 69 | } 70 | 71 | 72 | /** 73 | * Generate recyclerView Adapter, Notice that if you didn't set recyclerView adapter 74 | * you get NullPointerExceptions 75 | */ 76 | fun setAdapter(scalingRecyclerList: ArrayList) { 77 | //just for fix snap for first and last item 78 | scalingRecyclerList.add( 79 | 0, 80 | ScalingRecyclerModel.Builder().visibility(View.INVISIBLE).build() 81 | ) 82 | scalingRecyclerList.add( 83 | scalingRecyclerList.size, 84 | ScalingRecyclerModel.Builder().visibility(View.INVISIBLE).build() 85 | ) 86 | 87 | //initialize list and adapter 88 | scalingRecyclerModelScoreList = scalingRecyclerList 89 | scalingRecyclerAdapter = ScalingRecyclerAdapter(context, scalingRecyclerList) 90 | recyclerView.adapter = scalingRecyclerAdapter 91 | 92 | } 93 | 94 | fun addItem(item: ScalingRecyclerModel) { 95 | if (this::scalingRecyclerAdapter.isInitialized && this::scalingRecyclerModelScoreList.isInitialized) { 96 | scalingRecyclerModelScoreList.add(scalingRecyclerModelScoreList.size-1,item) 97 | scalingRecyclerAdapter.notifyItemInserted(scalingRecyclerModelScoreList.size) 98 | } else { 99 | throw NullPointerException("ScalingAdapter can not be null, at first call setAdapter") 100 | } 101 | } 102 | 103 | fun addItem(items: ArrayList) { 104 | if (this::scalingRecyclerAdapter.isInitialized && this::scalingRecyclerModelScoreList.isInitialized) { 105 | scalingRecyclerModelScoreList.addAll(scalingRecyclerModelScoreList.size-1,items) 106 | scalingRecyclerAdapter.notifyItemInserted(scalingRecyclerModelScoreList.size) 107 | } else { 108 | throw NullPointerException("ScalingAdapter can not be null, at first call setAdapter") 109 | } 110 | } 111 | 112 | /** 113 | * @param placeholderDrawable The placeholderDrawable is used for imageView before load image from URL 114 | */ 115 | fun setPlaceHolder(placeholderDrawable: Drawable?) { 116 | scalingRecyclerAdapter.placeHolderDrawable = placeholderDrawable 117 | } 118 | 119 | /** 120 | * @param onErrorDrawable The onErrorDrawable is used for imageView when load image from URL is failed 121 | */ 122 | fun setOnErrorDrawable(onErrorDrawable: Drawable?) { 123 | scalingRecyclerAdapter.onErrorDrawable = onErrorDrawable 124 | } 125 | 126 | /** 127 | * @param resourceId TextAppearance resource id 128 | */ 129 | fun setFirstTitleTextAppearance(@StyleRes resourceId: Int) { 130 | scalingRecyclerAdapter.firstTitleTextAppearance = resourceId 131 | } 132 | 133 | /** 134 | * @param resourceId TextAppearance resource id 135 | */ 136 | fun setSecondTitleTextAppearance(@StyleRes resourceId: Int) { 137 | scalingRecyclerAdapter.secondTitleTextAppearance = resourceId 138 | } 139 | 140 | fun setFirstLayoutBackground(@DrawableRes resId:Int){ 141 | scalingRecyclerAdapter.firstLayoutBackgroundDrawable = resId 142 | } 143 | fun setSecondLayoutBackground(@DrawableRes resId:Int){ 144 | scalingRecyclerAdapter.secondLayoutBackgroundDrawable = resId 145 | } 146 | fun setThirdLayoutBackground(@DrawableRes resId:Int){ 147 | scalingRecyclerAdapter.thirdLayoutBackgroundDrawable = resId 148 | } 149 | 150 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hamedrahimvand/scalingrecyclerview/adapter/ScalingRecyclerAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview.adapter 2 | 3 | import android.content.Context 4 | import android.graphics.Bitmap 5 | import android.graphics.drawable.Drawable 6 | import android.os.Build 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import android.widget.FrameLayout 11 | import androidx.annotation.DrawableRes 12 | import androidx.appcompat.widget.AppCompatImageView 13 | import androidx.appcompat.widget.AppCompatTextView 14 | import androidx.constraintlayout.widget.ConstraintLayout 15 | import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory 16 | import androidx.recyclerview.widget.RecyclerView 17 | import com.bumptech.glide.Glide 18 | import com.bumptech.glide.load.engine.DiskCacheStrategy 19 | import com.bumptech.glide.request.target.BitmapImageViewTarget 20 | import com.hamedrahimvand.scalingrecyclerview.utils.ConverterUtils 21 | import com.hamedrahimvand.scalingrecyclerview.R 22 | import com.hamedrahimvand.scalingrecyclerview.model.ScalingRecyclerModel 23 | import kotlinx.android.synthetic.main.item_scaling_recyclerview.view.* 24 | 25 | /** 26 | * Created By Hamed Rahimvand on 3 December 2018 27 | */ 28 | 29 | class ScalingRecyclerAdapter(val context: Context, val dataList: ArrayList) : 30 | RecyclerView.Adapter() { 31 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ScalingRecyclerViewHolder { 32 | val view = 33 | LayoutInflater.from(context).inflate(R.layout.item_scaling_recyclerview, parent, false) 34 | return ScalingRecyclerViewHolder(view) 35 | } 36 | 37 | 38 | var imgWidth = 56 39 | var imgHeight = 56 40 | var firstTime = true 41 | var placeHolderDrawable: Drawable? = null 42 | var onErrorDrawable: Drawable? = null 43 | var firstTitleTextAppearance: Int? = null 44 | var secondTitleTextAppearance: Int? = null 45 | @DrawableRes var firstLayoutBackgroundDrawable: Int? = null 46 | @DrawableRes var secondLayoutBackgroundDrawable: Int? = null 47 | @DrawableRes var thirdLayoutBackgroundDrawable: Int? = null 48 | 49 | override fun getItemCount(): Int { 50 | return dataList.size 51 | } 52 | 53 | override fun onBindViewHolder(holder: ScalingRecyclerViewHolder, position: Int) { 54 | val itemData = dataList[holder.adapterPosition] 55 | 56 | if (itemData.visibility != null) holder.colParent.visibility = itemData.visibility 57 | holder.txvFirstTitle.text = itemData.firstTitle 58 | holder.txvSecondTitle.text = itemData.secondTitle 59 | setAppearance(holder) 60 | setDrawable(holder) 61 | //load images with glide 62 | if (itemData.imageUrl != null) { 63 | loadGlide( 64 | itemData.imageUrl, 65 | holder.imv, 66 | placeHolderDrawable, 67 | onErrorDrawable, 68 | imgWidth, 69 | imgHeight 70 | ) 71 | } 72 | 73 | //cut first and last item just for fix, the first and last item 74 | //dynamically imported to list 75 | if (position == 0 || position == dataList.size - 1) { 76 | holder.colParent.layoutParams.width = ConverterUtils.dpToPx(60f).toInt() 77 | holder.colParent.layoutParams.height = ConverterUtils.dpToPx(60f).toInt() 78 | } else { 79 | holder.colParent.layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT 80 | holder.colParent.layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT 81 | } 82 | 83 | //scale item for first time 84 | firstTime(position, holder) 85 | } 86 | 87 | private fun setDrawable(holder: ScalingRecyclerViewHolder) { 88 | if (firstLayoutBackgroundDrawable != null) { 89 | holder.frlFirstLayout.setBackgroundResource(firstLayoutBackgroundDrawable!!) 90 | } 91 | if (secondLayoutBackgroundDrawable != null) { 92 | holder.frlSecondLayout.setBackgroundResource(secondLayoutBackgroundDrawable!!) 93 | } 94 | if (thirdLayoutBackgroundDrawable != null) { 95 | holder.frlThirdLayout.setBackgroundResource(thirdLayoutBackgroundDrawable!!) 96 | } 97 | } 98 | 99 | @Suppress("DEPRECATION") 100 | private fun setAppearance(holder: ScalingRecyclerViewHolder) { 101 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 102 | if (secondTitleTextAppearance != null) { 103 | holder.txvSecondTitle.setTextAppearance(secondTitleTextAppearance!!) 104 | } 105 | if (firstTitleTextAppearance != null) { 106 | holder.txvFirstTitle.setTextAppearance(firstTitleTextAppearance!!) 107 | } 108 | } else { 109 | if (secondTitleTextAppearance != null) { 110 | holder.txvSecondTitle.setTextAppearance(context, secondTitleTextAppearance!!) 111 | } 112 | if (firstTitleTextAppearance != null) { 113 | holder.txvFirstTitle.setTextAppearance(context, firstTitleTextAppearance!!) 114 | } 115 | } 116 | } 117 | 118 | private fun firstTime(position: Int, holder: ScalingRecyclerViewHolder) { 119 | if (firstTime) { 120 | if (position == 1) { 121 | holder.frlSecondLayout.scaleX = 1.2f 122 | holder.frlSecondLayout.scaleY = 1.2f 123 | holder.frlThirdLayout.scaleX = 1.45f 124 | holder.frlThirdLayout.scaleY = 1.45f 125 | } 126 | if (position == 2) { 127 | firstTime = false 128 | holder.itemView.scaleX = 0.8f 129 | holder.itemView.scaleY = 0.8f 130 | holder.frlSecondLayout.scaleX = 1.0f 131 | holder.frlSecondLayout.scaleY = 1.0f 132 | holder.frlThirdLayout.scaleX = 1.0f 133 | holder.frlThirdLayout.scaleY = 1.0f 134 | } 135 | } 136 | } 137 | 138 | /** 139 | * Load image from url, after load,images will override size. 140 | * @param width The width in dp to use to load the resource. 141 | * @param height The height in dp to use to load the resource. 142 | */ 143 | private fun loadGlide( 144 | photoUrl: String, 145 | imv: AppCompatImageView, 146 | placeHolder: Drawable?, 147 | errorDrawable: Drawable?, 148 | width: Int, 149 | height: Int 150 | ) { 151 | //use ConverterUtils#dpToPx to convert input dp to px 152 | this.imgWidth = ConverterUtils.dpToPx(width.toFloat()).toInt() 153 | this.imgHeight = ConverterUtils.dpToPx(height.toFloat()).toInt() 154 | 155 | Glide.with(imv.context).load(photoUrl) 156 | .asBitmap() 157 | .diskCacheStrategy(DiskCacheStrategy.ALL) 158 | .placeholder(placeHolder) 159 | .error(errorDrawable) 160 | .override(this.imgWidth, this.imgHeight) 161 | .into(object : BitmapImageViewTarget(imv) { 162 | override fun setResource(resource: Bitmap?) { 163 | val circularBitmapDrawable = 164 | RoundedBitmapDrawableFactory.create(context.resources, resource) 165 | circularBitmapDrawable.isCircular = true 166 | imv.setImageDrawable(circularBitmapDrawable) 167 | } 168 | }) 169 | } 170 | 171 | 172 | class ScalingRecyclerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 173 | val colParent = 174 | itemView.findViewById(R.id.col_parent)!! 175 | val imv = itemView.findViewById(R.id.imv_cardImage)!! 176 | val txvFirstTitle = itemView.findViewById(R.id.txv_cardFirstTitle)!! 177 | val txvSecondTitle = itemView.findViewById(R.id.txv_cardSecondTitle)!! 178 | val frlFirstLayout = itemView.findViewById(R.id.frl_firstLayout)!! 179 | val frlSecondLayout = itemView.findViewById(R.id.frl_secondLayout)!! 180 | val frlThirdLayout = itemView.findViewById(R.id.frl_thirdLayout)!! 181 | } 182 | 183 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hamedrahimvand/scalingrecyclerview/model/ScalingRecyclerModel.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview.model 2 | 3 | import android.view.View 4 | /** 5 | * Created By Hamed Rahimvand on 3 December 2018 6 | */ 7 | 8 | class ScalingRecyclerModel private constructor( 9 | val firstTitle: String?, 10 | val imageUrl: String?, 11 | val secondTitle: String?, 12 | val visibility: Int? 13 | ) { 14 | 15 | data class Builder( 16 | var firstTitle: String? = null, 17 | var imageUrl: String? = null, 18 | var secondTitle: String? = null, 19 | var visibility: Int? = View.VISIBLE 20 | ) { 21 | 22 | fun firstTitle(firstTitle: String?) = apply { this.firstTitle = firstTitle } 23 | fun imageUrl(imageUrl: String?) = apply { this.imageUrl = imageUrl } 24 | fun secondTitle(secondTitle: String?) = apply { this.secondTitle = secondTitle } 25 | fun visibility(visibility: Int) = apply { this.visibility = visibility } 26 | fun build() = ScalingRecyclerModel(firstTitle, imageUrl, secondTitle, visibility) 27 | } 28 | 29 | 30 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hamedrahimvand/scalingrecyclerview/utils/ConverterUtils.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview.utils 2 | 3 | import android.content.res.Resources 4 | /** 5 | * Created By Hamed Rahimvand on 3 December 2018 6 | */ 7 | 8 | class ConverterUtils { 9 | 10 | companion object { 11 | fun dpToPx(dp: Float): Float { 12 | return (dp * Resources.getSystem().displayMetrics.density) 13 | } 14 | 15 | fun pxToDp(px: Float): Float { 16 | return (px / Resources.getSystem().displayMetrics.density) 17 | } 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_award_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_bg_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/transparent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_scaling_recyclerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 23 | 24 | 25 | 26 | 39 | 40 | 41 | 42 | 55 | 56 | 59 | 60 | 70 | 71 | 84 | 85 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /app/src/main/res/layout/scailing_recyclerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | 8 | #c5f5f5f5 9 | #bdafafaf 10 | #f9f9f9 11 | 12 | #222 13 | #444444 14 | #f9f9f9f9 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Scaling RecyclerView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/hamedrahimvand/scalingrecyclerview/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.hamedrahimvand.scalingrecyclerview 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.2.71' 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.2.1' 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # Kotlin code style for this project: "official" or "obsolete": 15 | kotlin.code.style=official 16 | android.useAndroidX=true 17 | android.enableJetifier=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamed-rv/scaling-recyclerview/5def4d27b49b91341c835cf7f4b31ba738d699bc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------