Skip to content

Commit

Permalink
Recyclerview item animation.
Browse files Browse the repository at this point in the history
  • Loading branch information
yueeng committed Nov 9, 2015
1 parent d13fcd0 commit 00605c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 14
targetSdkVersion 23
versionCode 14
versionName "1.0.8.2"
versionName "1.0.9"
multiDexEnabled true
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
}
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/scala/io/github/yueeng/hacg/MainActivity.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.yueeng.hacg

import android.animation.ObjectAnimator
import android.app.SearchManager
import android.content._
import android.graphics.Point
Expand All @@ -21,6 +22,7 @@ import android.text.style.{BackgroundColorSpan, ClickableSpan}
import android.text.{SpannableStringBuilder, Spanned, TextPaint}
import android.view.View.OnClickListener
import android.view._
import android.view.animation.DecelerateInterpolator
import android.widget.ImageView.ScaleType
import android.widget._
import com.squareup.picasso.Picasso
Expand Down Expand Up @@ -436,6 +438,24 @@ class ArticleFragment extends Fragment with ViewEx.ViewEx[Boolean, SwipeRefreshL
holder.text3.setVisibility(if (item.tags.nonEmpty) View.VISIBLE else View.GONE)

Picasso.`with`(holder.context).load(item.img).placeholder(R.drawable.loading).error(R.drawable.placeholder).into(holder.image1)

if (position > last) {
last = position
val anim = ObjectAnimator.ofFloat(holder.itemView, "translationY", from, 0)
.setDuration(1000)
anim.setInterpolator(interpolator)
anim.start()
}
}

var last = -1
val interpolator = new DecelerateInterpolator(3)
val from = getActivity.getWindowManager.getDefaultDisplay match {
case d: Display =>
val p = new Point()
d.getSize(p)
Math.max(p.x, p.y) / 4
case _ => 300;
}

override def onCreateViewHolder(parent: ViewGroup, viewType: Int): ArticleHolder =
Expand Down

0 comments on commit 00605c8

Please sign in to comment.