F
F
fedormoore2017-05-22 18:26:16
Android
fedormoore, 2017-05-22 18:26:16

Asynchronously loading images in a ListView using a Socket connection?

Please help me solve my problem. I am using code to load asynchronous images from this site www.technotalkative.com/android-asynchronous-image... With HTTP it works as it should, but if I change a piece when with

URL imageUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
conn.setConnectTimeout(30000);
conn.setReadTimeout(30000);
conn.setInstanceFollowRedirects(true);
InputStream is=conn.getInputStream();

On the
Socket socket1 = new Socket();
socket1.connect(new InetSocketAddress(mSettings.getString(APP_PREFERENCES_IPSERVER, ""), 30100), 5000);
ObjectOutputStream outp1 = new ObjectOutputStream(socket1.getOutputStream());
ObjectInputStream inp1 = new ObjectInputStream(socket1.getInputStream());
outp1.writeObject("ASprUserEdir,-,fileget,-," + url);
outp1.flush();
String messageReceived = (String) inp1.readObject();
int file_size = Integer.valueOf(messageReceived.split(",-,")[1]);
InputStream is=socket1.getInputStream();

Then, if the connection is slow, if you scroll through the sheet, the image does not appear in its place. How can this be fixed? Perhaps this requires a different code. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-05-22
@zagayevskiy

Take a normal Glide or Picasso and you will be happy. Loading images into a list is not the most trivial thing to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question