Created
June 12, 2015 05:10
-
-
Save yongjhih/c1f497aff86e12777dfb to your computer and use it in GitHub Desktop.
yongjhih / PhotographicPrintAnimator.java https://gist.github.com/yongjhih/4c9076f81ba9cacd93cf
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
/******************************************************************************* | |
* Copyright 2014 8tory, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*******************************************************************************/ | |
package com.nostra13.universalimageloader.core.display; | |
import android.graphics.Bitmap; | |
import android.view.View; | |
import android.widget.ImageView; | |
import com.nostra13.universalimageloader.core.assist.LoadedFrom; | |
import com.nostra13.universalimageloader.core.imageaware.ImageAware; | |
import com.github.pgloaguen.PhotographicPrintAnimator; | |
public class PhotographicPrintDisplayer implements BitmapDisplayer { | |
private int duration; | |
private int saturationDuration = -1; | |
private int brightnessDuration = -1; | |
private int alphaDuration = -1; | |
public PhotographicPrintDisplayer setDuration(int duration) { | |
this.duration = duration; | |
return this; | |
} | |
public PhotographicPrintDisplayer setSaturationDuration(int duration) { | |
this.saturationDuration = duration; | |
return this; | |
} | |
public PhotographicPrintDisplayer setBrightnessDuration(int duration) { | |
this.brightnessDuration = duration; | |
return this; | |
} | |
public PhotographicPrintDisplayer setAlphaDuration(int duration) { | |
this.alphaDuration = duration; | |
return this; | |
} | |
public PhotographicPrintDisplayer(int duration) { | |
setDuration(duration); | |
} | |
public PhotographicPrintDisplayer(PhotographicPrintAnimator animator) { | |
setAnimator(animator); | |
} | |
public PhotographicPrintDisplayer setAnimator(PhotographicPrintAnimator animator) { | |
saturationDuration = animator.getSaturationDuration(); | |
brightnessDuration = animator.getBrightnessDuration(); | |
alphaDuration = animator.getAlphaDuration(); | |
return this; | |
} | |
@Override | |
public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { | |
imageAware.setImageBitmap(bitmap); | |
if (loadedFrom == LoadedFrom.MEMORY_CACHE) return; | |
if (loadedFrom == LoadedFrom.DISC_CACHE) return; | |
ImageView imageView = (ImageView) imageAware.getWrappedView(); | |
if (imageView != null) { | |
new PhotographicPrintAnimator() | |
.setView(imageView) | |
.setDuration(duration) | |
.setSaturationDuration(saturationDuration) | |
.setBrightnessDuration(brightnessDuration) | |
.setAlphaDuration(alphaDuration) | |
.start(); | |
} | |
} | |
} |
Author
yongjhih
commented
Jun 12, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment