experimental animation stuff

This commit is contained in:
Andrew Dolgov 2011-09-09 15:58:11 +04:00
parent c7a583a116
commit fb7054eb18
7 changed files with 129 additions and 14 deletions

8
res/anim/test.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="1"
android:toXScale="0.5"
android:duration="1000">
</scale>

View File

@ -0,0 +1,7 @@
<LinearLayout android:id="@+id/article_fragment" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:paddingRight="2dip" android:layout_height="match_parent" android:background="?feedlistDivider" android:layout_width="wrap_content" android:paddingLeft="2dip"></ImageView>
<LinearLayout android:gravity="center" android:layout_height="match_parent" android:id="@+id/linearLayout1" android:layout_width="match_parent">
<TextView android:text="--- Article ---" android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge"></TextView>
</LinearLayout>
</LinearLayout>

View File

@ -4,12 +4,8 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/headlines_fragment">
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<ListView android:layout_weight="1" android:background="?headlinesBackground"
<ListView android:layout_weight="1"
android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/headlines"></ListView>
</LinearLayout>
<TextView android:id="@+id/no_headlines"
android:visibility="invisible"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_headlines"></TextView>
</FrameLayout>

View File

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="match_parent">
<CheckBox android:paddingLeft="6dip" android:paddingRight="6dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/selected"></CheckBox>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="match_parent">
android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal">
<CheckBox android:focusable="false"
android:paddingLeft="6dip" android:paddingRight="6dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/selected"></CheckBox>
<LinearLayout android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="match_parent">
<TextView android:id="@+id/title" android:textSize="16sp" android:text="{Title...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
<TextView android:id="@+id/excerpt" android:textSize="13sp" android:textColor="#909090" android:text="{Content excerpt...}" android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
</LinearLayout>

View File

@ -18,14 +18,20 @@
android:paddingLeft="2dip" android:paddingRight="2dip"
android:layout_width="wrap_content" android:layout_height="match_parent"></ImageView>
</LinearLayout>
<LinearLayout android:layout_weight="0.5" android:layout_height="match_parent" android:id="@+id/headlines_container" android:layout_width="match_parent">
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/LinearLayout1" android:layout_weight="0.5">
<LinearLayout android:layout_width="match_parent" android:layout_weight="0" android:id="@+id/headlines_container" android:layout_height="match_parent"></LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_weight="1" android:background="#f0f0ff" android:id="@+id/article_container" android:layout_height="match_parent"></LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView android:layout_gravity="center" android:visibility="invisible"
android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/no_unread_feeds" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/no_unread_feeds"></TextView>
<TextView android:id="@+id/no_headlines"
android:visibility="invisible"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_headlines"></TextView>
</FrameLayout>

View File

@ -0,0 +1,49 @@
package org.fox.ttrss;
import java.util.Timer;
import org.fox.ttrss.FeedsFragment.FeedsListAdapter;
import android.app.Activity;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
public class ArticleFragment extends Fragment {
SharedPreferences m_prefs;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (savedInstanceState != null) {
//
}
View view = inflater.inflate(R.layout.article_fragment, container, false);
return view;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onSaveInstanceState (Bundle out) {
super.onSaveInstanceState(out);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
}
}

View File

@ -2,19 +2,25 @@ package org.fox.ttrss;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
public class HeadlinesFragment extends Fragment {
public class HeadlinesFragment extends Fragment implements OnItemClickListener {
private final String TAG = this.getClass().getSimpleName();
protected int m_feedId;
protected SharedPreferences m_prefs;
@ -39,9 +45,9 @@ public class HeadlinesFragment extends Fragment {
if (list != null) {
list.setAdapter(m_adapter);
//list.setOnItemClickListener(this);
list.setOnItemClickListener(this);
list.setEmptyView(view.findViewById(R.id.no_headlines));
//list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
}
return view;
@ -66,4 +72,44 @@ public class HeadlinesFragment extends Fragment {
m_feedId = feedId;
}
@Override
public void onItemClick(AdapterView<?> av, View view, int position, long id) {
ListView list = (ListView)getActivity().findViewById(R.id.headlines);
if (list != null) {
Cursor cursor = (Cursor) list.getItemAtPosition(position);
if (cursor != null) {
int articleId = (int) cursor.getLong(0);
Log.d(TAG, "clicked on article " + articleId);
viewArticle(articleId);
}
}
}
private void viewArticle(int articleId) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ArticleFragment frag = new ArticleFragment();
//frag.initialize(articleId);
Animation a = AnimationUtils.loadAnimation(getActivity(), R.anim.test);
a.reset();
View v = getView().findViewById(R.id.headlines_container);
v.clearAnimation();
v.startAnimation(a);
ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
ft.replace(R.id.article_container, frag);
ft.commit();
//m_adapter.notifyDataSetChanged();
}
}