|
|
@@ -0,0 +1,79 @@
|
|
|
+package kr.co.zumo.app.lifeplus.view.custom.loading;
|
|
|
+
|
|
|
+import android.animation.Keyframe;
|
|
|
+import android.animation.ObjectAnimator;
|
|
|
+import android.animation.PropertyValuesHolder;
|
|
|
+import android.animation.ValueAnimator;
|
|
|
+import android.content.Context;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.constraint.ConstraintLayout;
|
|
|
+import android.util.AttributeSet;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.animation.LinearInterpolator;
|
|
|
+
|
|
|
+import kr.co.zumo.app.R;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ButtonLoadingView
|
|
|
+ * <pre>
|
|
|
+ * </pre>
|
|
|
+ *
|
|
|
+ * @author 하세미
|
|
|
+ * @version 1.0
|
|
|
+ * @history 하세미 [2019-01-11] [최초 작성]
|
|
|
+ * @since 2019-01-11
|
|
|
+ */
|
|
|
+public class LoadingCircleView extends ConstraintLayout {
|
|
|
+
|
|
|
+ private ObjectAnimator alphaAnimator;
|
|
|
+
|
|
|
+ public LoadingCircleView(Context context) {
|
|
|
+ super(context);
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ public LoadingCircleView(Context context, @Nullable AttributeSet attrs) {
|
|
|
+ super(context, attrs);
|
|
|
+ }
|
|
|
+
|
|
|
+ public LoadingCircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
|
+ super(context, attrs, defStyleAttr);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void init(Context context) {
|
|
|
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
+ inflater.inflate(R.layout.loading_circle_view, this);
|
|
|
+ View circle = findViewById(R.id.loading_circle);
|
|
|
+
|
|
|
+ Keyframe kf0 = Keyframe.ofFloat(0f, 1.0f);
|
|
|
+ Keyframe kf1 = Keyframe.ofFloat(.5f, 0f);
|
|
|
+ Keyframe kf2 = Keyframe.ofFloat(1f, 1.0f);
|
|
|
+
|
|
|
+ PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe(ALPHA, kf0, kf1, kf2);
|
|
|
+ alphaAnimator = ObjectAnimator.ofPropertyValuesHolder(circle, propertyValuesHolder);
|
|
|
+ alphaAnimator.setInterpolator(new LinearInterpolator());
|
|
|
+ alphaAnimator.setRepeatCount(ValueAnimator.INFINITE);
|
|
|
+ alphaAnimator.setDuration(1000);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setCurrentPlayTime(long currentPlayTime) {
|
|
|
+ if (null != alphaAnimator) {
|
|
|
+ alphaAnimator.setCurrentPlayTime(currentPlayTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void animationStart() {
|
|
|
+ if (null != alphaAnimator) {
|
|
|
+ alphaAnimator.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void animationCancel() {
|
|
|
+ if (null != alphaAnimator) {
|
|
|
+ alphaAnimator.cancel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|