Search in sources :

Example 1 with ImageUploadResponse

use of app.insti.api.response.ImageUploadResponse in project IITB-App by wncc.

the class FileComplaintFragment method sendImage.

private void sendImage() {
    progressDialog.setMessage("Uploading Image");
    ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    retrofitInterface.uploadImage("sessionid=" + getArguments().getString(Constants.SESSION_ID), imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() {

        @Override
        public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) {
            if (response.isSuccessful()) {
                ImageUploadResponse imageUploadResponse = response.body();
                uploadedImagesUrl.add(imageUploadResponse.getPictureURL());
                showImage(uploadedImagesUrl);
                Log.i(TAG, "ImageURL: " + uploadedImagesUrl.toString());
            } else {
                progressDialog.dismiss();
                Toast.makeText(getContext(), getString(R.string.error_message), Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onFailure(Call<ImageUploadResponse> call, Throwable t) {
            Log.i(TAG, "failure in sendImage: " + t.toString());
            progressDialog.dismiss();
            Toast.makeText(getContext(), getString(R.string.error_message), Toast.LENGTH_LONG).show();
        }
    });
}
Also used : ImageUploadRequest(app.insti.api.request.ImageUploadRequest) ImageUploadResponse(app.insti.api.response.ImageUploadResponse) RetrofitInterface(app.insti.api.RetrofitInterface)

Aggregations

RetrofitInterface (app.insti.api.RetrofitInterface)1 ImageUploadRequest (app.insti.api.request.ImageUploadRequest)1 ImageUploadResponse (app.insti.api.response.ImageUploadResponse)1