Skip to content

Instantly share code, notes, and snippets.

@yongjhih
Created June 12, 2015 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongjhih/c1f497aff86e12777dfb to your computer and use it in GitHub Desktop.
Save yongjhih/c1f497aff86e12777dfb to your computer and use it in GitHub Desktop.
yongjhih / PhotographicPrintAnimator.java https://gist.github.com/yongjhih/4c9076f81ba9cacd93cf
/*******************************************************************************
* 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();
}
}
}
@yongjhih
Copy link
Author

commit a8cf63d358057ccc873a32b531e9b3df2713f016
Author: Andrew Chen <yongjhih@gmail.com>
Date:   Sat Dec 20 07:36:23 2014 +0800

    Reduce brightness and apply photo print animator as ImageLoader displayer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment