InputSream Java input code is different every time, even when the request is the same

I have a request that is not related to UniversalImageLoader , but because I am trying to use a content stream to load an image that is facing the following problem.

I use the stream stream "stream: //" to be able to use ImageLoader. Everything works fine, except that the hash code of the input stream for the same request is generated differently and, therefore, forces imageloader to download the image from the network again, and not from the disk.

What should I do to fix this.

PS: I tried to execute the answer here

Code for getting InputStream (UtilityMethod method marks async task only):

 public void displayContentImage(final String fileId, final ImageView imageView) {
    UtilityMethods.startMyTask(new AsyncTask<Object, Void, InputStream>() {

        @Override
        protected InputStream doInBackground(Object... params) {
            CMServiceGateway cmServiceGateway = new CMServiceGateway();
            final InputStream inputStream = cmServiceGateway.GetContentAsStream(fileId);
            if (inputStream != null) {
                //String imageId = "stream://" + inputStream.hashCode();
                //Log.d("ImageId :: 1 ::", "file id : " + fileId + "hashcode:  " + imageId);
                //String imageId2 = "stream://" + cmServiceGateway.GetContentAsStream(fileId).hashCode();
                //Log.d("ImageId :: 2 ::", "file id : " + fileId + "hashcode:  " + imageId2);
                return inputStream;
            }
            return null;
        }

        @Override
        protected void onPostExecute(InputStream inputStream) {
            if (inputStream != null) {
                displayImage(inputStream, imageView);
            }
        }
    });
}
+1
1

-, , , - - , inputStream .

 //String imageId = "stream://" + inputStream.hashCode();
            //Log.d("ImageId :: 1 ::", "file id : " + fileId + "hashcode:  " + imageId);
            //String imageId2 = "stream://" + cmServiceGateway.GetContentAsStream(fileId).hashCode();
            //Log.d("ImageId :: 2 ::", "file id : " + fileId + "hashcode:  " + imageId2);

, , - id. , , .

+1

Source: https://habr.com/ru/post/1526851/


All Articles