와의 setRequestProperty를 HttpURLConnection의를 사용할 수 있습니다어떻게, 글라이드
여기 내가 글라이드 라이브러리 대신 비동기 작업
를 사용하여 구현해야하는 코드의 조각이다 미리 감사드립니다.
public class ImageLoadingAsyncTask extends AsyncTask<Integer, Void, Void> {
Bitmap bmp;
@Override
protected void onPreExecute() {
super.onPreExecute();
pb_imageProgressBar.setVisibility(VISIBLE);
}
@Override
protected Void doInBackground(Integer... integers) {
String url = PrefManager.getInstanceUrl()
+ "clients/"
+ integers[0]
+ "/images?maxHeight=120&maxWidth=120";
Log.d("ashu",url);
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) (new URL(url))
.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty(MifosInterceptor.HEADER_TENANT,
"default");
httpURLConnection.setRequestProperty(MifosInterceptor.HEADER_AUTH,
PrefManager.getToken());
httpURLConnection.setRequestProperty("Accept", "application/octet-stream");
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
InputStream inputStream = httpURLConnection.getInputStream();
bmp = BitmapFactory.decodeStream(inputStream);
httpURLConnection.disconnect();
} catch (MalformedURLException e) {
} catch (IOException ioe) {
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
if (bmp != null) {
iv_clientImage.setImageBitmap(bmp);
} else {
iv_clientImage.setImageDrawable(
ContextCompat.getDrawable(getActivity(), R.drawable.ic_launcher));
pb_imageProgressBar.setVisibility(GONE);
}
}
}
글라이드를 사용하는 경우이 작업을 수행 할 필요가 없습니다. 내가 여기서 뭔가를 놓치고 있니? –
@AshwaniK url 충분치 않아요 [link] (https://demo.openmf.org/fineract-provider/api/v1/clients/11/images?maxHeight=120&maxWidth=120) 우리가 문자열에서 얻는 링크를 확인하십시오 url –