Skip to content

Commit

Permalink
更新微博提醒Toast的实现方式
Browse files Browse the repository at this point in the history
  • Loading branch information
wenmingvs committed Sep 12, 2016
1 parent 91141d8 commit 6c59558
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wenming.weiswift.R;
Expand Down Expand Up @@ -87,6 +88,7 @@ public class HomeFragment extends Fragment implements HomeFragmentView {
private boolean mControlsVisible = true;

private TextView mToastTv;
private RelativeLayout mToastBg;

private onButtonBarListener mOnBottonBarListener;

Expand All @@ -105,6 +107,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mErrorMessage = (TextView) mView.findViewById(R.id.errorMessage);
mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_refresh_widget);
mToastTv = (TextView) mView.findViewById(R.id.toast_msg);
mToastBg = (RelativeLayout) mView.findViewById(R.id.toast_bg);
initRecyclerView();
initRefreshLayout();
initGroupWindows();
Expand Down Expand Up @@ -269,16 +272,15 @@ public void popWindowsDestory() {
}

@Override
public void showOrangeToast(int num) {
mToastTv.setVisibility(View.VISIBLE);
mToastTv.setText(num + "条新微博");
Animation animation = new AlphaAnimation(0.0f, 1.0f);
public void showOrangeToast(final int num) {
Animation animation = new AlphaAnimation(0.5f, 1.0f);
animation.setDuration(2000);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

mToastTv.setVisibility(View.VISIBLE);
mToastTv.setText(num + "条新微博");
}

@Override
Expand All @@ -291,7 +293,7 @@ public void onAnimationRepeat(Animation animation) {

}
});
mToastTv.startAnimation(animation);
mToastBg.startAnimation(animation);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions weiSwift/src/main/res/layout/loaded_toast.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_toast">
Expand Down

0 comments on commit 6c59558

Please sign in to comment.