Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView;

public class MainActivity extends Activity {
Expand All @@ -14,6 +16,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
animatedCircleLoadingView = (AnimatedCircleLoadingView) findViewById(R.id.circle_loading_view);
animatedCircleLoadingView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
resetLoading();
startLoading();
startPercentMockThread();
}
});
startLoading();
startPercentMockThread();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.github.jlmd.animatedcircleloadingview.animator.ViewAnimator;
import com.github.jlmd.animatedcircleloadingview.component.InitialCenterCircleView;
Expand Down Expand Up @@ -80,7 +81,7 @@ private void startAnimation() {
startAnimationIndeterminate = false;
}
if (startAnimationDeterminate) {
addView(percentIndicatorView);
percentIndicatorView.showView();
viewAnimator.startAnimator();
startAnimationDeterminate = false;
}
Expand Down Expand Up @@ -126,6 +127,7 @@ private void addComponentsViews() {
addView(mainCircleView);
addView(finishedOkView);
addView(finishedFailureView);
addView(percentIndicatorView);
}

private void initAnimatorHelper() {
Expand Down Expand Up @@ -172,6 +174,5 @@ public void stopFailure() {

public void resetLoading() {
viewAnimator.resetAnimator();
setPercent(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.jlmd.animatedcircleloadingview.animator;

import android.view.View;

import com.github.jlmd.animatedcircleloadingview.component.ComponentViewAnimation;
import com.github.jlmd.animatedcircleloadingview.component.InitialCenterCircleView;
import com.github.jlmd.animatedcircleloadingview.component.MainCircleView;
Expand Down Expand Up @@ -69,6 +71,7 @@ public void resetAnimator() {
mainCircleView.hideView();
finishedOkView.hideView();
finishedFailureView.hideView();
percentIndicatorView.reset();
resetAnimator = true;
startAnimator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.widget.TextView;

Expand All @@ -20,6 +21,7 @@ public PercentIndicatorView(Context context, int parentWidth) {
}

private void init() {
hideView();
int textSize = (35 * parentWidth) / 700;
setTextSize(textSize);
setTextColor(Color.WHITE);
Expand All @@ -32,9 +34,24 @@ public void setPercent(int percent) {
}

public void startAlphaAnimation() {
AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
AlphaAnimation alphaAnimation = new AlphaAnimation(0.8f, 0);
alphaAnimation.setDuration(700);
alphaAnimation.setFillAfter(true);
startAnimation(alphaAnimation);
}

public void reset() {
hideView();
setText("");
clearAnimation();
setAlpha(0.8f);
}

public void hideView() {
setVisibility(View.INVISIBLE);
}

public void showView() {
setVisibility(View.VISIBLE);
}
}