我正在撰写社交平台应用。我正在使用PHPMyAdmin。我的问题是:当我打开我的个人资料(活动)时,我下载的图片下载速度太慢或者没有。我打开我的活动布局,看到白皮书.1-2分钟后,他们装了一半。我怎么能解决它?
这是我的活动代码AsyncTask:
public class DownloadImageKullanici extends AsyncTask<String, Void, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
String ID_res;
@Override
protected Bitmap doInBackground(String... URL) {
Bitmap bitmap = null;
if (!DownStop) {
FTPClient ftpClient = new FTPClient();
File file = null;
try {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "MH_JPEG_" + timeStamp + ".jpg";
ftpClient.connect(AConnect.Connect_image, 21);
ftpClient.login(AConnect.FTPKul, AConnect.FTPSifre);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
String remoteFile1 = "/" + URL[0];
Log.e("name", remoteFile1);
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), imageFileName);
OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(file));
ID_res = URL[1];
boolean success = ftpClient.retrieveFile(remoteFile1, outputStream1);
//Dosya indi log u.
Log.e("Dosya indi", String.valueOf(success));
outputStream1.close();
bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
File file_del = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), imageFileName);
file_del.delete();
} catch (SocketException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
return bitmap;
}
@Override
protected void onPostExecute(Bitmap result) {
// Set the bitmap into ImageView
// image.setImageBitmap(result);
/* ByteArrayOutputStream stream = new ByteArrayOutputStream();
result.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
*/
galeri_yedek.addAll(galeri);
{
// galeri.clear();
}
ActKullanici.adaptorRes.addListItemToAdapter(new DgknRes(ID_res,result));
// Close progressdialog
}
}
我的logcat:
04-17 18:47:21.072 2488-7160/com.jmteknoloji.mypdym E/Dosya indi: false
04-17 18:47:21.646 2488-7160/com.jmteknoloji.mypdym E/name: /M_JPEG_20180417_131223.jpg
04-17 18:47:22.088 2488-7160/com.jmteknoloji.mypdym E/Dosya indi: true
04-17 18:47:22.508 2488-7160/com.jmteknoloji.mypdym E/name: /M_JPEG_20180417_131156.jpg