@Override public void onStateChange(int state) { ((MainActivity) getActivity()).showStateHint(state); }
@Override public void reset() { fillableLoader.reset(); //We wait a little bit to start the animation, to not contaminate the drawing effect //by the activity creation animation. fillableLoader.postDelayed(new Runnable() { @Override public void run() { fillableLoader.start(); } }, 250); } }
private void init() { drawingState = State.NOT_STARTED; initDashPaint(); initFillPaint(); animInterpolator = new DecelerateInterpolator(); setLayerType(LAYER_TYPE_SOFTWARE, null); }
@Override public void run() { ((ResettableView) adapter.getItem(0)).reset(); clippingModeText.setText(adapter.getPageTitle(0)); } });
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); setupPagination(); setupDisableTraceButton(); }
private void buildPathData() { SvgPathParser parser = getPathParser(); pathData = new PathData(); try { pathData.path = parser.parsePath(svgPath); } catch (ParseException e) { pathData.path = new Path(); } PathMeasure pm = new PathMeasure(pathData.path, true); while (true) { pathData.length = Math.max(pathData.length, pm.getLength()); if (!pm.nextContour()) { break; } } }
private void checkRequirements() { checkOriginalDimensions(); checkPath(); }
public static FillableLoaderPage newInstance(int pageNum) { FillableLoaderPage page = new FillableLoaderPage(); Bundle bundle = new Bundle(); bundle.putInt("pageNum", pageNum); page.setArguments(bundle); return page; }
public void start() { checkRequirements(); initialTime = System.currentTimeMillis(); changeState(State.STROKE_STARTED); ViewCompat.postInvalidateOnAnimation(this); }
public FillableLoader(Context context) { super(context); init(); }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); viewWidth = w; viewHeight = h; buildPathData(); }
public void setToFinishedFrame() { initialTime = 1; changeState(State.FINISHED); ViewCompat.postInvalidateOnAnimation(this); }
public FillablePagesAdapter(FragmentManager fm) { super(fm); firstPage = FillableLoaderPage.newInstance(0); secondPage = FillableLoaderPage.newInstance(1); thirdPage = FillableLoaderPage.newInstance(2); fourthPage = FillableLoaderPage.newInstance(3); fifthPage = FillableLoaderPage.newInstance(4); sixthPage = FillableLoaderPage.newInstance(5); seventhPage = FillableLoaderPage.newInstance(6); eighthPage = FillableLoaderPage.newInstance(7); }
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentage = progress; fillableLoader.setPercentage(progress); }
@Override public void run() { fillableLoader.start(); } }, 250);
/** * Constructor for the {@link FillableLoaderBuilder} class. */ FillableLoader(ViewGroup parent, ViewGroup.LayoutParams params, int strokeColor, int fillColor, int strokeWidth, int originalWidth, int originalHeight, int strokeDrawingDuration, int fillDuration, ClippingTransform transform, String svgPath, boolean percentageEnabled, float fillPercentage) { super(parent.getContext()); this.strokeColor = strokeColor; this.fillColor = fillColor; this.strokeWidth = strokeWidth; this.strokeDrawingDuration = strokeDrawingDuration; this.fillDuration = fillDuration; this.clippingTransform = transform; this.originalWidth = originalWidth; this.originalHeight = originalHeight; this.svgPath = svgPath; this.percentageEnabled = percentageEnabled; this.percentage = fillPercentage; init(); parent.addView(this, params); }
public void setSvgPath(String svgPath) { if (svgPath == null || svgPath.length() == 0) { throw new IllegalArgumentException( "You must provide a not empty path in order to draw the view properly."); } this.svgPath = svgPath; buildPathData(); }
/** * Resets the fillable loader. Means that the whole loader stroke + fill disappears. */ public void reset() { initialTime = 0; previousFramePercentage = 0; changeState(State.NOT_STARTED); ViewCompat.postInvalidateOnAnimation(this); }