From 216eecc96a916568b3db5c5bb9a9083789cd262b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 28 May 2013 12:55:21 +0400 Subject: [PATCH] add fancy animations for headlines list --- res/anim/headline_item.xml | 14 ++++++ res/anim/layout_headline.xml | 5 ++ res/layout/headlines_fragment.xml | 46 ++++++++++++++----- src/org/fox/ttrss/HeadlinesFragment.java | 25 ++++++++++ .../offline/OfflineHeadlinesFragment.java | 24 ++++++++++ 5 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 res/anim/headline_item.xml create mode 100644 res/anim/layout_headline.xml diff --git a/res/anim/headline_item.xml b/res/anim/headline_item.xml new file mode 100644 index 00000000..dbb60d23 --- /dev/null +++ b/res/anim/headline_item.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/res/anim/layout_headline.xml b/res/anim/layout_headline.xml new file mode 100644 index 00000000..07b84d11 --- /dev/null +++ b/res/anim/layout_headline.xml @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/res/layout/headlines_fragment.xml b/res/layout/headlines_fragment.xml index 787a8c8d..58fa6694 100644 --- a/res/layout/headlines_fragment.xml +++ b/res/layout/headlines_fragment.xml @@ -1,17 +1,39 @@ - - + - - - - + + + + + + + + - - - + + + + + \ No newline at end of file diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 7befaf9a..6ad805cc 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -34,6 +34,11 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.LayoutAnimationController; +import android.view.animation.TranslateAnimation; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.AdapterView; @@ -267,6 +272,26 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, ListView list = (ListView)view.findViewById(R.id.headlines); m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, (ArrayList
)m_articles); + + /* if (!m_activity.isCompatMode()) { + AnimationSet set = new AnimationSet(true); + + Animation animation = new AlphaAnimation(0.0f, 1.0f); + animation.setDuration(500); + set.addAnimation(animation); + + animation = new TranslateAnimation( + Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f, + Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f + ); + animation.setDuration(1000); + set.addAnimation(animation); + + LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); + + list.setLayoutAnimation(controller); + } */ + list.setAdapter(m_adapter); list.setOnItemClickListener(this); list.setOnScrollListener(this); diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index e89d01f4..242d7a16 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -33,6 +33,11 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.LayoutAnimationController; +import android.view.animation.TranslateAnimation; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; @@ -279,6 +284,25 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor, new String[] { "title" }, new int[] { R.id.title }, 0); + /* if (!m_activity.isCompatMode()) { + AnimationSet set = new AnimationSet(true); + + Animation animation = new AlphaAnimation(0.0f, 1.0f); + animation.setDuration(500); + set.addAnimation(animation); + + animation = new TranslateAnimation( + Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f, + Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f + ); + animation.setDuration(1000); + set.addAnimation(animation); + + LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); + + list.setLayoutAnimation(controller); + } */ + list.setAdapter(m_adapter); list.setOnItemClickListener(this); list.setEmptyView(view.findViewById(R.id.no_headlines));