使用 TextSwitcher 替代 ProgressiveTextView

This commit is contained in:
seven332 committed 2014-05-12 02:17:19 +08:00
1 parent f8b2b46172
commit 5417918382
6 files changed
+76 -9

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="1000"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />
</set>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="1000"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="1000" />
</set>
+2 -1
View File
@@ -92,7 +92,8 @@
android:layout_width="fill_parent"
android:layout_height="2.0dp"
android:background="@android:color/holo_blue_light" />
<!-- TODO maybe viewstub and is better -->
<include
android:id="@+id/manga_detail_normal"
layout="@layout/detail_normal"
+5
View File
@@ -0,0 +1,5 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/DetailSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
+5 -3
View File
@@ -23,14 +23,16 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true" />
<com.hippo.ehviewer.widget.ProgressiveTextView
<TextSwitcher
android:id="@+id/detail_average_people"
style="@style/DetailSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/detail_rate"
android:layout_marginLeft="6.0dp" />
android:layout_marginLeft="6.0dp"
android:inAnimation="@anim/push_up_in"
android:outAnimation="@anim/push_up_out" >
</TextSwitcher>
</RelativeLayout>
@@ -53,6 +53,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
@@ -60,8 +61,11 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.ScrollView;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import android.widget.ViewSwitcher.ViewFactory;
public class DetailSectionFragment extends Fragment
implements View.OnClickListener {
@@ -485,8 +489,15 @@ public class DetailSectionFragment extends Fragment
RatingBar rate = (RatingBar)mRootView.findViewById(R.id.detail_rate);
rate.setRating(mGalleryDetail.rating);
TextView averagePeople = (TextView)mRootView.findViewById(R.id.detail_average_people);
averagePeople.setText(String.format("%.2f (%d)",
TextSwitcher averagePeople = (TextSwitcher)mRootView.findViewById(R.id.detail_average_people);
averagePeople.setFactory(new ViewFactory() {
@Override
public View makeView() {
LayoutInflater inflater = LayoutInflater.from(mActivity);
return inflater.inflate(R.layout.detail_avg_text, null);
}
});
averagePeople.setCurrentText(String.format("%.2f (%d)",
mGalleryDetail.rating, mGalleryDetail.people));
TextView posted = (TextView)mRootView.findViewById(R.id.detail_posted);
@@ -664,9 +675,9 @@ public class DetailSectionFragment extends Fragment
RatingBar rate = (RatingBar)mRootView.findViewById(R.id.detail_rate);
rate.setRating(mGalleryDetail.rating);
ProgressiveTextView averagePeople = (ProgressiveTextView)mRootView.findViewById(
R.id.detail_average_people);
averagePeople.setNewText(String.format("%.2f (%d)",
TextSwitcher averagePeople = (TextSwitcher)
mRootView.findViewById(R.id.detail_average_people);
averagePeople.setText(String.format("%.2f (%d)",
mGalleryDetail.rating, mGalleryDetail.people));
}
Toast.makeText(mActivity,
@@ -827,4 +838,12 @@ public class DetailSectionFragment extends Fragment
"投票失败\n" + eMsg, Toast.LENGTH_SHORT).show(); // TODO
}
}
private ViewFactory mFactory = new ViewFactory() {
@Override
public View makeView() {
LayoutInflater inflater = LayoutInflater.from(mActivity);
return inflater.inflate(R.layout.detail_avg_text, null);
}
};
}