Android Open Source - photo-share-android Api Request Service






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;
//ww  w  . ja  v  a  2  s.c  om
import android.content.Context;
import android.net.Uri;
import com.android.volley.Response;
import com.project.photoshare.utils.Constants;
import com.project.photoshare.utils.volley.VolleyHelper;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by TakuyaKodama on 14/06/08.
 */
public class ApiRequestService {
    private static final String TAG = ApiRequestService.class.getSimpleName();

    private Context mContext;

    public ApiRequestService(Context context) {
        mContext = context;
    }

    public void postImages(String password, List<Uri> uriList, boolean isAdd,
                           Response.Listener listener, Response.ErrorListener errorListener) {
        String url = Constants.BASE_API_URL + "image/upload";
        Map<String, String> stringParams = new HashMap<String, String>();
        Map<String, InputStream> binaryParams = new HashMap<String, InputStream>();

        stringParams.put("password", password);
        for (int i = 0; i < uriList.size(); i++) {
            Uri uri = uriList.get(i);
            try {
                InputStream inputStream = mContext.getContentResolver().openInputStream(uri);
                binaryParams.put(uri.toString(), inputStream);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        MultipartJsonRequest multipartJsonRequest
                = new MultipartJsonRequest(url, stringParams, binaryParams, listener, errorListener);

        VolleyHelper.getRequestQueue(mContext).add(multipartJsonRequest);
    }

    /*
    public void postImages(String password, Map<Uri, Bitmap> bitmapMap, boolean isAdd,
                           Response.Listener listener, Response.ErrorListener errorListener) {
        String url = Constants.BASE_API_URL + "image/upload";
        Map<String, String> stringParams = new HashMap<String, String>();
        Map<String, Byte[]> binaryParams = new HashMap<String, Byte[]>();

        stringParams.put("password", password);
        for (Map.Entry<Uri, Bitmap> entry : bitmapMap.entrySet()) {
            mMultipartEntityBuilder.addTextBody(entry.getKey(), entry.getValue());
        }

        for (int i = 0; i < bitmapMap.size(); i++) {
            Uri uri = bytes.get(i);
            try {
                InputStream inputStream = mContext.getContentResolver().openInputStream(uri);
                binaryParams.put(uri.toString(), inputStream);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        MultipartJsonRequest multipartJsonRequest
                = new MultipartJsonRequest(url, stringParams, binaryParams, listener, errorListener);

        VolleyHelper.getRequestQueue(mContext).add(multipartJsonRequest);
    }
    */

}




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