add fancy animations for headlines list

This commit is contained in:
Andrew Dolgov 2013-05-28 12:55:21 +04:00
parent ab4480c6f5
commit 216eecc96a
5 changed files with 102 additions and 12 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:duration="250"
/>
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="250"
/>
</set>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="20%"
android:animation="@anim/headline_item"
/>

View File

@ -1,17 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_fragment" android:id="@+id/headlines_fragment"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:paddingLeft="5dp" > android:paddingLeft="5dp" >
<ListView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/headlines"></ListView> <ListView
<LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent"> android:id="@+id/headlines"
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView> android:layout_width="match_parent"
android:layoutAnimation="@anim/layout_headline"
android:layout_height="match_parent" >
</ListView>
<LinearLayout
android:id="@+id/loading_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<TextView
android:id="@+id/loading_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>
</LinearLayout> </LinearLayout>
<TextView android:id="@+id/no_headlines"
android:visibility="invisible" <TextView
android:layout_gravity="center" android:id="@+id/no_headlines"
android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_headlines"></TextView> android:layout_width="wrap_content"
android:layout_height="wrap_content"
</FrameLayout> android:layout_gravity="center"
android:text="@string/no_headlines"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="invisible" >
</TextView>
</FrameLayout>

View File

@ -34,6 +34,11 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; 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;
import android.widget.AbsListView.OnScrollListener; import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -267,6 +272,26 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
ListView list = (ListView)view.findViewById(R.id.headlines); ListView list = (ListView)view.findViewById(R.id.headlines);
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, (ArrayList<Article>)m_articles); m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, (ArrayList<Article>)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.setAdapter(m_adapter);
list.setOnItemClickListener(this); list.setOnItemClickListener(this);
list.setOnScrollListener(this); list.setOnScrollListener(this);

View File

@ -33,6 +33,11 @@ import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; 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.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; 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, m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor,
new String[] { "title" }, new int[] { R.id.title }, 0); 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.setAdapter(m_adapter);
list.setOnItemClickListener(this); list.setOnItemClickListener(this);
list.setEmptyView(view.findViewById(R.id.no_headlines)); list.setEmptyView(view.findViewById(R.id.no_headlines));