Android Open Source - HorizontalImageScroller-Modified Image Url Request






From Project

Back to project page HorizontalImageScroller-Modified.

License

The source code is released under:

Apache License

If you think the Android project HorizontalImageScroller-Modified listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
Copyright 2012 Two Toasters, LLC//w  w w .j  ava  2  s.c om

   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.twotoasters.android.horizontalimagescroller.io;

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;

import com.twotoasters.android.horizontalimagescroller.image.ImageToLoadUrl;

public class ImageUrlRequest {
  final private ImageToLoadUrl _imageToLoadUrl;
  final private int _reqWidth;
  final private int _reqHeight;
  private ImageUrlRequestCacheKey _cacheKey;
  private String _cacheFileName;
  private int _imageFailedToLoadResourceId;
  
  public ImageUrlRequest(ImageToLoadUrl imageToLoadUrl, int reqWidth, int reqHeight) {
    _imageToLoadUrl = imageToLoadUrl;
    _reqWidth = reqWidth;
    _reqHeight = reqHeight;
  }
  
  public ImageToLoadUrl getImageToLoadUrl() {
    return _imageToLoadUrl;
  }
  
  public int getReqWidth() {
    return _reqWidth;
  }
  
  public int getReqHeight() {
    return _reqHeight;
  }
  
  public ImageUrlRequestCacheKey getCacheKey() {
    if (_cacheKey == null) {
      _cacheKey = new ImageUrlRequestCacheKey(_imageToLoadUrl.getUrl(), _imageToLoadUrl.getUsername(), _imageToLoadUrl.getPassword(), _reqWidth, _reqHeight);
    }
    return _cacheKey;
  }
  
  public String getCacheFileName() {
    if (_cacheFileName == null) {
      String url = _imageToLoadUrl.getUrl();
      String username = _imageToLoadUrl.getUsername();
      String password = _imageToLoadUrl.getPassword();
      String toHash = String.format("url_%1$s_creds_%2$s%3$s_size_%4$dx%5$d", url, username, password, _reqWidth, _reqHeight);
      _cacheFileName = new String(Hex.encodeHex(DigestUtils.sha256(toHash)));
    }
    return _cacheFileName;
  }

  public int getImageFailedToLoadResourceId() {
    return _imageFailedToLoadResourceId;
  }

  public void setImageFailedToLoadResourceId(int imageFailedToLoadResourceId) {
    _imageFailedToLoadResourceId = imageFailedToLoadResourceId;
  }
}




Java Source Code List

com.twotoasters.android.horizontalimagescroller.image.BitmapHelper.java
com.twotoasters.android.horizontalimagescroller.image.ImageToLoadDrawableResource.java
com.twotoasters.android.horizontalimagescroller.image.ImageToLoadSD.java
com.twotoasters.android.horizontalimagescroller.image.ImageToLoadUrl.java
com.twotoasters.android.horizontalimagescroller.image.ImageToLoad.java
com.twotoasters.android.horizontalimagescroller.image.OnImageLoadedListener.java
com.twotoasters.android.horizontalimagescroller.io.ExternalStorageHelper.java
com.twotoasters.android.horizontalimagescroller.io.FlushedInputStream.java
com.twotoasters.android.horizontalimagescroller.io.ImageCacheManager.java
com.twotoasters.android.horizontalimagescroller.io.ImageUrlRequestCacheKey.java
com.twotoasters.android.horizontalimagescroller.io.ImageUrlRequest.java
com.twotoasters.android.horizontalimagescroller.io.MemoryCache.java
com.twotoasters.android.horizontalimagescroller.sample.MainActivity.java
com.twotoasters.android.horizontalimagescroller.widget.HorizontalImageScrollerAdapter.java
com.twotoasters.android.horizontalimagescroller.widget.HorizontalImageScroller.java
com.twotoasters.android.horizontalimagescroller.widget.HorizontalListView.java
com.twotoasters.android.horizontalimagescroller.widget.SelectionToggleOnItemClickListener.java
com.twotoasters.android.horizontalimagescroller.widget.VerticalScrollView.java