Java Code Examples for android.view.animation.Animation#cancel()

The following examples show how to use android.view.animation.Animation#cancel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImptActivity.java    From ClassSchedule with Apache License 2.0 6 votes vote down vote up
@Override
public void captchaIsLoading(boolean isLoading) {
    if (getCaptchaIV() == null) {
        return;
    }

    if (isLoading) {
        getCaptchaIV().setImageResource(R.drawable.ic_svg_refresh);
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360f,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);

        rotateAnimation.setDuration(1000);
        rotateAnimation.setInterpolator(new LinearInterpolator());
        rotateAnimation.setRepeatCount(-1);
        getCaptchaIV().startAnimation(rotateAnimation);
    } else {
        Animation animation = getCaptchaIV().getAnimation();
        if (animation != null) {
            animation.cancel();
        }
    }
}
 
Example 2
Source File: ITagsFragment.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
private void updateITagImageAnimation(@NonNull ViewGroup rootView, ITagInterface itag, BLEConnectionInterface connection) {
    Activity activity = getActivity();
    if (activity == null) return; //
    if (mITagAnimation == null) {
        return;
    }

    Animation animShake = null;

    if (BuildConfig.DEBUG) {
        Log.d(LT, "updateITagImageAnimation isFindMe:" + connection.isFindMe() +
                " isAlerting:" + connection.isAlerting() +
                " isAlertDisconnected:" + itag.isAlertDisconnected() +
                " not conencted:" + !connection.isConnected()
        );
    }
    if (connection.isAlerting() ||
            connection.isFindMe() ||
            itag.isAlertDisconnected() && !connection.isConnected()) {
        animShake = mITagAnimation;//AnimationUtils.loadAnimation(getActivity(), R.anim.shake_itag);
    }
    final ImageView imageITag = rootView.findViewById(R.id.image_itag);
    if (animShake == null) {
        if (BuildConfig.DEBUG) {
            Log.d(LT, "updateITagImageAnimation: No animations appointed");
        }
        animShake = imageITag.getAnimation();
        if (animShake != null) {
            if (BuildConfig.DEBUG) {
                Log.d(LT, "updateITagImageAnimation: Stop previous animation");
            }
            animShake.cancel();
        }
    } else {
        if (BuildConfig.DEBUG) {
            Log.d(LT, "updateITagImageAnimation: Start animation");
        }
        imageITag.startAnimation(animShake);
    }
}
 
Example 3
Source File: PointViewAnimObject.java    From DragPointView with Apache License 2.0 5 votes vote down vote up
private void start(Animation object, final OnPointDragListener removeListener) {
    long duration = object.getDuration();
    object.cancel();
    view.startAnimation(object);
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            view.clearAnimation();
            end(removeListener);
        }
    }, duration);
}
 
Example 4
Source File: QuickStartFragment.java    From UMS-Interface with GNU General Public License v3.0 4 votes vote down vote up
/**
 * update status for UI
 * @param detect whether to research the status.
 * */
private void updateUIStatus(boolean detect)
{
    logInfo("quick_start updateUIStatus detect="+detect);
    Animation _anim = AnimationUtils.loadAnimation(mActivity,R.anim.circle_rotate);
    mRefreshIcon.startAnimation(_anim);
    if(detect)
        getStatus();
    if(mStatusFile!=null) {
        mUsbBtn.setVisibility(View.VISIBLE);
        mMountBtn.setVisibility(View.VISIBLE);
        String[] _strs =mStatusFile.split("/");
        mUseText.setText(getString(R.string.using) + " " + _strs[_strs.length-1]);
        mUseFileText.setText(mStatusFile);
        if(mStatusUsb) {
            mUsbText.setText(R.string.usb_connection);
            mUsbBtn.setText(R.string.close);
        }
        else {
            mUsbText.setText(R.string.quick_no_usb);
            mUsbBtn.setText(R.string.launch);
        }
        if(mStatusMount==null||!mStatusMount)
        {
            mMountText.setText(R.string.quick_no_mount);
            mMountBtn.setText(R.string.mount);
        }else {
            mMountText.setText(getString(R.string.local_mount) + " " + mStatusMountpoint);
            mMountBtn.setText(R.string.umount);
        }
    }else
    {
        mUseText.setText(getString(R.string.no_using));
        mUseFileText.setText(mStatusFile);
        mUsbBtn.setVisibility(View.INVISIBLE);
        mMountBtn.setVisibility(View.INVISIBLE);
        mUsbText.setText(R.string.quick_no_usb);
        mMountText.setText(R.string.quick_no_mount);
    }
    if(mStatusSD!=null)
    {
        if(mExtendGroup.getChildCount()==0)
            mExtendGroup.addView(mExtendView);
        mExtendText.setText(mStatusSD);
    }else {
        if(mExtendGroup.getChildCount()>0)
            mExtendGroup.removeAllViews();
    }
    _anim.cancel();

}
 
Example 5
Source File: ViewUtils.java    From px-android with MIT License 4 votes vote down vote up
public static void cancelAnimation(@NonNull final View targetView) {
    final Animation animation = targetView.getAnimation();
    if (animation != null) {
        animation.cancel();
    }
}
 
Example 6
Source File: LoaderTask.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
private void stopExistingAnimation() {
    Animation old = imageView.getAnimation();
    if (old != null && !old.hasEnded()) {
        old.cancel();
    }
}
 
Example 7
Source File: ImageWrapper.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
private void stopExistingAnimation() {
    Animation old = imageView.getAnimation();
    if (old != null && !old.hasEnded()) {
        old.cancel();
    }
}
 
Example 8
Source File: QuickStartFragment.java    From UMS-Interface with GNU General Public License v3.0 4 votes vote down vote up
/**
 * update status for UI
 * @param detect whether to research the status.
 * */
private void updateUIStatus(boolean detect)
{
    logInfo("quick_start updateUIStatus detect="+detect);
    Animation _anim = AnimationUtils.loadAnimation(mActivity,R.anim.circle_rotate);
    mRefreshIcon.startAnimation(_anim);
    if(detect)
        getStatus();
    if(mStatusFile!=null) {
        mUsbBtn.setVisibility(View.VISIBLE);
        mMountBtn.setVisibility(View.VISIBLE);
        String[] _strs =mStatusFile.split("/");
        mUseText.setText(getString(R.string.using) + " " + _strs[_strs.length-1]);
        mUseFileText.setText(mStatusFile);
        if(mStatusUsb) {
            mUsbText.setText(R.string.usb_connection);
            mUsbBtn.setText(R.string.close);
        }
        else {
            mUsbText.setText(R.string.quick_no_usb);
            mUsbBtn.setText(R.string.launch);
        }
        if(mStatusMount==null||!mStatusMount)
        {
            mMountText.setText(R.string.quick_no_mount);
            mMountBtn.setText(R.string.mount);
        }else {
            mMountText.setText(getString(R.string.local_mount) + " " + mStatusMountpoint);
            mMountBtn.setText(R.string.umount);
        }
    }else
    {
        mUseText.setText(getString(R.string.no_using));
        mUseFileText.setText(mStatusFile);
        mUsbBtn.setVisibility(View.INVISIBLE);
        mMountBtn.setVisibility(View.INVISIBLE);
        mUsbText.setText(R.string.quick_no_usb);
        mMountText.setText(R.string.quick_no_mount);
    }
    if(mStatusSD!=null)
    {
        if(mExtendGroup.getChildCount()==0)
            mExtendGroup.addView(mExtendView);
        mExtendText.setText(mStatusSD);
    }else {
        if(mExtendGroup.getChildCount()>0)
            mExtendGroup.removeAllViews();
    }
    _anim.cancel();

}
 
Example 9
Source File: BluetoothHidEmuActivity.java    From BluetoothHidEmu with Apache License 2.0 4 votes vote down vote up
/**
 * Updates UI
 * @param state
 */
private void setStatusIconState(StatusIconStates state) {

    if (state == mStatusState) {
        return;
    }
    
       Animation animation = null;
    switch (state) {
    case ON:
        if ((animation = mStatusTextView.getAnimation()) != null) {
            animation.cancel();
            mStatusTextView.setAnimation(null);
        }
        mStatusTextView.setTextColor(Color.GREEN);
        mStatusTextView.setShadowLayer(6, 0f, 0f, Color.BLACK);
        mStatusTextView.setText(getResources().getString(R.string.msg_status_connected));
        
        if (mUiControls != null) mUiControls.animate(View.VISIBLE);
        
        break;
    case OFF:
           if ((animation = mStatusTextView.getAnimation()) != null) {
               animation.cancel();
               mStatusTextView.setAnimation(null);
           }
           mStatusTextView.setTextColor(Color.RED);
           mStatusTextView.setShadowLayer(6, 0f, 0f, Color.BLACK);
           mStatusTextView.setText(getResources().getString(R.string.msg_status_disconnected));
           
           if (mUiControls != null) mUiControls.animate(View.INVISIBLE);

        break;
    case INTERMEDIATE:
        
        mStatusTextView.setTextColor(0xffffff00);
        mStatusTextView.setShadowLayer(6, 0f, 0f, Color.BLACK);
           mStatusTextView.setText(getResources().getString(R.string.msg_status_connecting));
        
           AlphaAnimation alphaAnim = new AlphaAnimation(1, 0.2f);
           alphaAnim.setDuration(250);
           alphaAnim.setInterpolator(new DecelerateInterpolator(10f));
           alphaAnim.setRepeatCount(Animation.INFINITE);
           alphaAnim.setRepeatMode(Animation.REVERSE);
           
           mStatusTextView.startAnimation(alphaAnim);
           
           if (mUiControls != null) mUiControls.animate(View.INVISIBLE);
        break;
    }
    mStatusState = state;

}