Android Open Source - photo-share-android Input Stream Request






From Project

Back to project page photo-share-android.

License

The source code is released under:

Apache License

If you think the Android project photo-share-android 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

package com.project.photoshare.api;
//from   w  w  w. j a v a  2s.  co  m
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 *
 * @author <a href="mailto:">TakuyaKodama</a> (kodama-t)
 * @version 1.00 13/12/09 kodama-t
 */
public class InputStreamRequest extends Request<InputStream> {

    private final Response.Listener<InputStream> mListener;

    /**
     *
     * @param method
     * @param url
     * @param listener
     * @param errorListener
     */
    public InputStreamRequest(int method, String url, Response.Listener<InputStream> listener, Response.ErrorListener errorListener) {
        super(method, url, errorListener);
        this.mListener = listener;
    }

    /**
     *
     * @param url
     * @param listener
     * @param errorListener
     */
    public InputStreamRequest(String url, Response.Listener<InputStream> listener, Response.ErrorListener errorListener) {
        this(Method.GET, url, listener, errorListener);
    }

    /**
     *
     * @param response Response from the network
     *
     * @return The parsed response, or null in the case of an error
     */
    @Override
    protected Response<InputStream> parseNetworkResponse(NetworkResponse response) {
        InputStream inputStream = new ByteArrayInputStream(response.data);
        return Response.success(inputStream, HttpHeaderParser.parseCacheHeaders(response));
    }

    /**
     * Subclasses must implement this to perform delivery of the parsed
     * response to their listeners.  The given response is guaranteed to
     * be non-null; responses that fail to parse are not delivered.
     *
     * @param response The parsed response returned by
     *                 {@link #parseNetworkResponse(com.android.volley.NetworkResponse)}
     */
    @Override
    protected void deliverResponse(InputStream response) {
        mListener.onResponse(response);
    }
}




Java Source Code List

com.project.photoshare.DefaultActivity.java
com.project.photoshare.DownloadPageFragment.java
com.project.photoshare.HistoryPageFragment.java
com.project.photoshare.InputPassword.java
com.project.photoshare.MainActivity.java
com.project.photoshare.MyPageFragment.java
com.project.photoshare.PasswordConfirmation.java
com.project.photoshare.SelectIsAddLater.java
com.project.photoshare.SplashActivity.java
com.project.photoshare.UploadCompleted.java
com.project.photoshare.UploadPageFragment.java
com.project.photoshare.api.ApiRequestService.java
com.project.photoshare.api.InputStreamRequest.java
com.project.photoshare.api.MultipartHurlStack.java
com.project.photoshare.api.MultipartJsonRequest.java
com.project.photoshare.listener.PostImageErrorListener.java
com.project.photoshare.listener.PostImageSuccessListener.java
com.project.photoshare.utils.BitmapDecodeLoader.java
com.project.photoshare.utils.ImageUtils.java
com.project.photoshare.utils.LogHelper.java
com.project.photoshare.utils.Utils.java
com.project.photoshare.utils.volley.LruImageCache.java
com.project.photoshare.utils.volley.VolleyHelper.java
com.project.photoshare.widget.CustomEditText.java