@@ -0,0 +1,1799 @@
+package com.example.habitrack;%0A%0Aimport android.graphics.Bitmap;%0Aimport android.graphics.BitmapFactory;%0Aimport android.os.AsyncTask;%0Aimport android.util.Base64;%0Aimport android.util.Log;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0A%0Aimport io.searchbox.core.DocumentResult;%0Aimport io.searchbox.core.Index;%0A%0A/**%0A * Created by sshussai on 11/17/17.%0A */%0A%0Apublic class ImageHandler %7B%0A%0A    public static class Compressor extends AsyncTask%3CBitmap, Void, String%3E %7B%0A        private final int COMPRESSION_QUALITY = 100;%0A        private String encodedImage;%0A        ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();%0A%0A        // Code taken from: http://mobile.cs.fsu.edu/converting-images-to-json-objects/%0A        @Override%0A        protected String doInBackground(Bitmap... bitmaps) %7B%0A            for(Bitmap bitmap : bitmaps)%7B%0A                bitmap.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY,%0A                        byteArrayBitmapStream);%0A                byte%5B%5D b = byteArrayBitmapStream.toByteArray();%0A                encodedImage = Base64.encodeToString(b, Base64.DEFAULT);%0A            %7D%0A            return encodedImage;%0A        %7D%0A    %7D%0A%0A    public static class Decompressor extends AsyncTask%3CString, Void, Bitmap%3E%7B%0A%0A        private Bitmap decodedByte;%0A%0A        // Code taken from: http://mobile.cs.fsu.edu/converting-images-to-json-objects/%0A        @Override%0A        protected Bitmap doInBackground(String... strings) %7B%0A            for (String stringPicture : strings) %7B%0A                byte%5B%5D decodedString = Base64.decode(stringPicture, Base64.DEFAULT);%0A%0A                decodedByte = BitmapFactory.decodeByteArray(decodedString,%0A                        0, decodedString.length);%0A            %7D%0A            return decodedByte;%0A        %7D%0A    %7D%0A%7D%0A

add an async task to compress/decopress images outside of ui thread