Example usage for android.view.animation RotateAnimation setFillAfter

List of usage examples for android.view.animation RotateAnimation setFillAfter

Introduction

In this page you can find the example usage for android.view.animation RotateAnimation setFillAfter.

Prototype

public void setFillAfter(boolean fillAfter) 

Source Link

Document

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

Usage

From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    final MainActivity mainActivity = ((MainActivity) this.getActivity());
    super.onViewCreated(view, savedInstanceState);
    if (this.isHidden())
        return;//  w w  w.  ja  v a2s .com

    DrawerAdapter drawerAdapter = ((DrawerAdapter) ((ListView) mainActivity.findViewById(R.id.drawer_list))
            .getAdapter());
    if (drawerAdapter.getSelectedItem() != 1) {
        drawerAdapter.setSelectedItem(1);
        drawerAdapter.notifyDataSetChanged();
    }

    if (!megaListView.hasOnGroupClickListener())
        megaListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator);
                RotateAnimation anim;
                if (megaListView.isGroupExpanded(groupPosition)) {
                    megaListView.collapseGroupWithAnimation(groupPosition);
                    if (indicator != null) {
                        anim = new RotateAnimation(180f, 360f, indicator.getWidth() / 2,
                                indicator.getHeight() / 2);
                        anim.setInterpolator(new DecelerateInterpolator(3));
                        anim.setDuration(500);
                        anim.setFillAfter(true);
                        indicator.startAnimation(anim);
                    }
                } else {
                    megaListView.expandGroupWithAnimation(groupPosition);
                    if (indicator != null) {
                        anim = new RotateAnimation(0f, 180f, indicator.getWidth() / 2,
                                indicator.getHeight() / 2);
                        anim.setInterpolator(new DecelerateInterpolator(2));
                        anim.setDuration(500);
                        anim.setFillAfter(true);
                        indicator.startAnimation(anim);
                    }
                }
                return true;
            }
        });

    if (!megaListView.hasOnChildClickListener())
        megaListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                    long id) {
                if (mSwiping) {
                    mSwiping = false;
                    return false;
                }
                final MainActivity mainActivity = (MainActivity) getActivity();
                megaListView.setOnChildClickListener(null); // prevents bug on double tap
                mainActivity.updateLyricsFragment(R.animator.slide_out_start, R.animator.slide_in_start, true,
                        ((LocalAdapter) megaListView.getExpandableListAdapter()).getChild(groupPosition,
                                childPosition));
                return true;
            }
        });

    this.isActiveFragment = true;
    new DBContentLister(this).execute();
}

From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java

@Override
public void onSensorChanged(SensorEvent event) {
    // get the angle around the z-axis rotated
    float degree = Math.round(event.values[0]);
    //tvHeading.setText("Heading: " + Float.toString(degree) + " degrees");
    // create a rotation animation (reverse turn degree degrees)
    RotateAnimation ra = new RotateAnimation(currentDegree, degree, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    // how long the animation will take place
    ra.setDuration(210);//  w  w  w  . ja  v  a  2 s . c  om
    // set the animation after the end of the reservation status
    ra.setFillAfter(true);
    // Start the animation
    image.startAnimation(ra);
    currentDegree = degree;

    editTextAngle.setText("AngleM : " + currentDegree + " DistM : " + distance + " GPSDir " + gpsDirection
            + " Dif " + diference + " Ponto " + index);

}