1
現在我正在使用下面的一段代碼檢索圖像,它工作的很好。但我想用universal-image-loader
實現緩存。我已經在我的其他項目中實現了它,其中我完全像url圖像一樣。 \ pic1.jpeg。另一方面,在使用Contacts api v3時,我必須處理輸入流,並且我沒有這樣完整的url.so,我不知道如何執行universal-image-loader
。是否有可能借助通用圖像加載程序檢索使用Contacts api v3的聯繫人圖像?
爲參考:Contact api v3
這裏是我使用的是現在的代碼:
Bitmap bm=BitmapFactory.decodeResource(HomeActivity.this.getResources(),
R.drawable.profile_pic);
CONSTANTS.buffer = new byte[4096];
// iterate the loop upto number of contacts
for(int i=0;i<CONSTANTS.contactArrayList.size();i++)
{
//if the contact has any profile pic then retrieve it otherwise set default profile pic from drawable folder
if(CONSTANTS.contactArrayList.get(i).getContactPhotoLink().getEtag()!=null)
{
try
{
GDataRequest request = CONSTANTS.mContactService.createLinkQueryRequest(CONSTANTS.contactArrayList.get(i).getContactPhotoLink());
request.execute();
InputStream in = request.getResponseStream();
CONSTANTS.buffer = ByteStreams.toByteArray(in);
bm = BitmapFactory.decodeByteArray(CONSTANTS.buffer, 0, CONSTANTS.buffer.length);
in.close();
request.end();
}
catch (Exception e) {
UTILS.Log_e("loadProfilePics error", e.toString());
}
}
else
{
bm = BitmapFactory.decodeResource(HomeActivity.this.getResources(),
R.drawable.profile_pic);
}
CONSTANTS.contactArrayList.get(i).setContactPhoto(bm);
}
如果ContactPhotoLink是一樣的東西'''https://www.google.com/m8/feeds/contacts/ {} USEREMAIL/... '''然後我建議用** contacts **替換** https **,將它傳遞給imageLoader:'''imageLoader.displayImage(「constacts://www.google.com/m8/feeds/contacts/ .. 。「),然後在CustomImageDownloader中檢查imageUri.getScheme()。equals(」contacts「)''',如果是這樣,用** https **替換** **的**接觸**並通過此方法檢索InputStream鏈接。 – NOSTRA