67 lines
2.0 KiB
Java
67 lines
2.0 KiB
Java
|
|
package com.qxcm.moduleutil.widget;
|
||
|
|
|
||
|
|
import android.content.Context;
|
||
|
|
import android.util.AttributeSet;
|
||
|
|
import android.view.LayoutInflater;
|
||
|
|
import android.view.View;
|
||
|
|
import android.view.animation.Animation;
|
||
|
|
import android.view.animation.AnimationUtils;
|
||
|
|
import android.view.animation.LinearInterpolator;
|
||
|
|
|
||
|
|
import androidx.databinding.DataBindingUtil;
|
||
|
|
|
||
|
|
import com.qxcm.moduleutil.R;
|
||
|
|
import com.qxcm.moduleutil.databinding.RoomViewMusicRatationBinding;
|
||
|
|
import com.qxcm.moduleutil.widget.floatingView.FloatingMagnetView;
|
||
|
|
|
||
|
|
|
||
|
|
public class MusicRotationView extends FloatingMagnetView {
|
||
|
|
private RoomViewMusicRatationBinding mBinding;
|
||
|
|
|
||
|
|
public MusicRotationView(Context context) {
|
||
|
|
this(context, null, 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
public MusicRotationView(Context context, AttributeSet attrs) {
|
||
|
|
this(context, attrs, 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
public MusicRotationView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||
|
|
super(context, attrs, defStyleAttr);
|
||
|
|
mBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.room_view_music_ratation,this,true);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 开启图片旋转动画
|
||
|
|
*/
|
||
|
|
public void startRotateAnimation() {
|
||
|
|
Animation rotateAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.image_rotate);
|
||
|
|
LinearInterpolator lin = new LinearInterpolator();
|
||
|
|
rotateAnimation.setInterpolator(lin);
|
||
|
|
mBinding.rivAvatar.setAnimation(rotateAnimation);
|
||
|
|
mBinding.rivAvatar.setVisibility(View.VISIBLE);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void setVisibility(int visibility) {
|
||
|
|
super.setVisibility(visibility);
|
||
|
|
if (visibility == GONE) {
|
||
|
|
// RtcManager.getInstance().setAudioUrl(null);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 关闭图片旋转动画
|
||
|
|
*/
|
||
|
|
public void endRotateAnimation() {
|
||
|
|
mBinding.rivAvatar.clearAnimation();
|
||
|
|
mBinding.rivAvatar.setAnimation(null);
|
||
|
|
mBinding.rivAvatar.setVisibility(View.VISIBLE);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected boolean isNearestLeft() {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|