Last active
August 29, 2015 14:16
-
-
Save frogermcs/bb9d12d720a5b3b2b8f2 to your computer and use it in GitHub Desktop.
InstaMaterial source files (Photo publishing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MainActivity.java | |
@Override | |
protected void onNewIntent(Intent intent) { | |
super.onNewIntent(intent); | |
if (ACTION_SHOW_LOADING_ITEM.equals(intent.getAction())) { | |
showFeedLoadingItemDelayed(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PublishActivity.java | |
private void bringMainActivityToTop() { | |
Intent intent = new Intent(this, MainActivity.class); | |
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); | |
intent.setAction(MainActivity.ACTION_SHOW_LOADING_ITEM); | |
startActivity(intent); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setupProgressPaint() { | |
progressPaint = new Paint(); | |
progressPaint.setAntiAlias(true); | |
progressPaint.setStyle(Paint.Style.STROKE); | |
progressPaint.setColor(0xffffffff); | |
progressPaint.setStrokeWidth(PROGRESS_STROKE_SIZE); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void drawArcForCurrentProgress() { | |
tempCanvas.drawArc(progressBounds, -90f, 360 * currentProgress / 100, false, progressPaint); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onDraw(Canvas canvas) { | |
if (state == STATE_PROGRESS_STARTED) { | |
drawArcForCurrentProgress(); | |
} | |
//.. | |
canvas.drawBitmap(tempBitmap, 0, 0, null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setupSimulateProgressAnimator() { | |
simulateProgressAnimator = ObjectAnimator.ofFloat(this, "currentProgress", 0, 100).setDuration(2000); | |
simulateProgressAnimator.setInterpolator(new AccelerateInterpolator()); | |
simulateProgressAnimator.addListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
changeState(STATE_DONE_STARTED); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setCurrentProgress(0); | |
simulateProgressAnimator.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setupDonePaints() { | |
doneBgPaint = new Paint(); | |
doneBgPaint.setAntiAlias(true); | |
doneBgPaint.setStyle(Paint.Style.FILL); | |
doneBgPaint.setColor(0xff39cb72); | |
checkmarkPaint = new Paint(); | |
maskPaint = new Paint(); | |
maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setupDoneMaskBitmap() { | |
innerCircleMaskBitmap = Bitmap.createBitmap(getWidth(), getWidth(), Bitmap.Config.ARGB_8888); | |
Canvas srcCanvas = new Canvas(innerCircleMaskBitmap); | |
srcCanvas.drawCircle(getWidth() / 2, getWidth() / 2, getWidth() / 2 - INNER_CIRCLE_PADDING, new Paint()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onDraw(Canvas canvas) { | |
//... | |
} else if (state == STATE_DONE_STARTED) { | |
drawFrameForDoneAnimation(); | |
postInvalidate(); | |
} else if (state == STATE_FINISHED) { | |
drawFinishedState(); | |
} | |
//... | |
canvas.drawBitmap(tempBitmap, 0, 0, null); | |
} | |
private void drawFrameForDoneAnimation() { | |
tempCanvas.drawCircle(getWidth() / 2, getWidth() / 2 + currentDoneBgOffset, getWidth() / 2 - INNER_CIRCLE_PADDING, doneBgPaint); | |
tempCanvas.drawBitmap(checkmarkBitmap, checkmarkXPosition, checkmarkYPosition + currentCheckmarkOffset, checkmarkPaint); | |
tempCanvas.drawBitmap(innerCircleMaskBitmap, 0, 0, maskPaint); | |
tempCanvas.drawArc(progressBounds, 0, 360f, false, progressPaint); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setupDoneAnimators() { | |
doneBgAnimator = ObjectAnimator.ofFloat(this, "currentDoneBgOffset", MAX_DONE_BG_OFFSET, 0).setDuration(300); | |
doneBgAnimator.setInterpolator(new DecelerateInterpolator()); | |
checkmarkAnimator = ObjectAnimator.ofFloat(this, "currentCheckmarkOffset", MAX_DONE_IMG_OFFSET, 0).setDuration(300); | |
checkmarkAnimator.setInterpolator(new OvershootInterpolator()); | |
checkmarkAnimator.addListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
changeState(STATE_FINISHED); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment