Skip to content

Commit

Permalink
Code cleanup. Udpate licenses notices
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed Sep 23, 2017
1 parent 0dfb894 commit d25e412
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 54 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ Just join our community and make a post. We'll help you as soon as possible. [![
- [Kevin Aguilar](http://kevaguilar.com/)
- [Eduardo Pratti](https://plus.google.com/+EduardoPratti/posts)
- [Anthony Nguyen](https://plus.google.com/+AHNguyen)
- [Translators](http://jahirfiquitiva.oneskyapp.com/admin/collaborators)

---

Expand Down
2 changes: 0 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ dependencies {
// Material Dialogs
compile 'com.afollestad.material-dialogs:core:' + project.ext.materialDialogs
compile 'com.afollestad.material-dialogs:commons:' + project.ext.materialDialogs
// Snap Helper
compile 'com.github.rubensousa:gravitysnaphelper:' + project.ext.snapHelper
// OkHttp
compile 'com.squareup.okhttp3:okhttp:' + project.ext.okhttp
// Glide Image Loading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package jahirfiquitiva.libs.frames.helpers.extensions

import android.animation.ArgbEvaluator
import android.animation.TypeEvaluator
import android.animation.ValueAnimator
import android.app.ActivityManager
import android.content.Context
import android.content.Intent
Expand All @@ -27,7 +24,6 @@ import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.support.annotation.ColorInt
import ca.allanwang.kau.utils.dimenPixelSize
import com.afollestad.materialdialogs.MaterialDialog
import com.bumptech.glide.Priority
Expand Down Expand Up @@ -186,26 +182,4 @@ val Context.thumbnailOptions:RequestOptions
get() = urlOptions.priority(Priority.IMMEDIATE)

val Context.wallpaperOptions:RequestOptions
get() = urlOptions.priority(Priority.HIGH)

@Suppress("UNCHECKED_CAST")
fun <T> createAnimator(evaluator:TypeEvaluator<*>, vararg values:T,
onConfig:ValueAnimator.() -> Unit = {},
onUpdate:(T) -> Unit):ValueAnimator =
ValueAnimator.ofObject(evaluator, values).apply {
addUpdateListener { onUpdate(it.animatedValue as T) }
onConfig(this)
}


fun animateSmoothly(@ColorInt startColor:Int, @ColorInt endColor:Int,
doUpdate:(Int) -> Unit):ValueAnimator =
createAnimator(ArgbEvaluator(),
startColor, endColor,
onConfig = {
duration = 1000
repeatMode = ValueAnimator.REVERSE
repeatCount = ValueAnimator.INFINITE
start()
},
onUpdate = doUpdate)
get() = urlOptions.priority(Priority.HIGH)
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ package jahirfiquitiva.libs.frames.helpers.extensions

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ArgbEvaluator
import android.animation.ObjectAnimator
import android.animation.TypeEvaluator
import android.animation.ValueAnimator
import android.app.Activity
import android.graphics.ColorMatrixColorFilter
import android.os.Build
import android.support.annotation.ColorInt
import android.support.annotation.StringRes
import android.support.design.widget.FloatingActionButton
import android.support.design.widget.Snackbar
Expand Down Expand Up @@ -131,4 +135,26 @@ private fun getAllChildren(v:View):ArrayList<View> {
result.addAll(viewArrayList)
}
return result
}
}

@Suppress("UNCHECKED_CAST")
fun <T> createAnimator(evaluator:TypeEvaluator<*>, vararg values:T,
onConfig:ValueAnimator.() -> Unit = {},
onUpdate:(T) -> Unit):ValueAnimator =
ValueAnimator.ofObject(evaluator, *values).apply {
addUpdateListener { onUpdate(it.animatedValue as T) }
onConfig(this)
}


fun animateSmoothly(@ColorInt startColor:Int, @ColorInt endColor:Int,
doUpdate:(Int) -> Unit):ValueAnimator =
createAnimator(ArgbEvaluator(),
startColor, endColor,
onConfig = {
duration = 1000
repeatMode = ValueAnimator.REVERSE
repeatCount = ValueAnimator.INFINITE
start()
},
onUpdate = doUpdate)
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package jahirfiquitiva.libs.frames.helpers.utils

import jahirfiquitiva.libs.frames.ui.activities.CreditsActivity
import jahirfiquitiva.libs.frames.ui.adapters.viewholders.Credit

const val DATABASE_NAME = "FAVORITES"

const val PREFERENCES_NAME = "frames_preferences"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ abstract class FramesWallpaperHolder(itemView:View):GlideViewHolder(itemView) {
abstract internal val img:ImageView
abstract internal fun getListener():GlideRequestCallback<Bitmap>

internal fun animateLoad(view:View) {
with(view) {
whenFaded(ifHasNotFaded = {
if (context.framesKonfigs.animationsEnabled) {
animateSmoothly(context.dividerColor, context.thumbnailColor,
{ setBackgroundColor(it) })
} else {
setBackgroundColor(context.dividerColor)
}
})
}
}

internal fun loadImage(manager:RequestManager, url:String, thumbUrl:String) {
val hasFaded = wallpaper?.hasFaded ?: true
img.loadWallpaper(manager, url, thumbUrl, hasFaded, getListener())
Expand Down Expand Up @@ -88,15 +101,7 @@ class CollectionHolder(itemView:View):FramesWallpaperHolder(itemView) {
collection:Collection, listener:(Collection) -> Unit) {
if (this.wallpaper != collection.bestCover) this.wallpaper = collection.bestCover
with(itemView) {
whenFaded(ifHasNotFaded = {
if (context.framesKonfigs.animationsEnabled) {
animateSmoothly(context.dividerColor, context.thumbnailColor,
{ setBackgroundColor(it) })
} else {
setBackgroundColor(context.dividerColor)
}
})

animateLoad(this)
detailsBg.setBackgroundColor(context.dividerColor)
val rightCover = collection.bestCover ?: collection.wallpapers.first()
val url = rightCover.url
Expand Down Expand Up @@ -172,14 +177,7 @@ class WallpaperHolder(itemView:View, private val showFavIcon:Boolean):
ViewCompat.setTransitionName(author, "author_transition_$adapterPosition")
ViewCompat.setTransitionName(heartIcon, "fav_transition_$adapterPosition")

whenFaded(ifHasNotFaded = {
if (context.framesKonfigs.animationsEnabled) {
animateSmoothly(context.dividerColor, context.thumbnailColor,
{ setBackgroundColor(it) })
} else {
setBackgroundColor(context.dividerColor)
}
})
animateLoad(this)

val url = wallpaper.url
val thumb = wallpaper.thumbUrl
Expand Down
12 changes: 9 additions & 3 deletions library/src/main/res/raw/notices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<copyright>Copyright (c) 2017 Jahir Fiquitiva</copyright>
<license>CreativeCommons Attribution-ShareAlike 4.0 International License</license>
</notice>
<notice>
<name>Material Chips Input</name>
<url>https://github.com/jahirfiquitiva/MaterialChipsInput</url>
<copyright>Copyright (c) 2017 pchmn</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
<name>KAU</name>
<url>https://github.com/AllanWang/KAU</url>
Expand All @@ -39,9 +45,9 @@
<license>MIT License</license>
</notice>
<notice>
<name>Volley</name>
<url>https://github.com/google/volley</url>
<copyright>Copyright (c) 2017 Google Inc.</copyright>
<name>OkHttp</name>
<url>http://square.github.io/okhttp/</url>
<copyright>Copyright (c) 2016 Square, Inc.</copyright>
<license>Apache Software License 2.0</license>
</notice>
<notice>
Expand Down

0 comments on commit d25e412

Please sign in to comment.