2015-07-25 00:07:33 +00:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
|
|
|
import android.content.ContentResolver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Build.VERSION;
|
|
|
|
import android.os.Build.VERSION_CODES;
|
|
|
|
import android.provider.ContactsContract;
|
|
|
|
|
|
|
|
import com.bumptech.glide.load.data.StreamLocalUriFetcher;
|
|
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
2017-10-12 00:12:46 +00:00
|
|
|
class ContactPhotoLocalUriFetcher extends StreamLocalUriFetcher {
|
|
|
|
|
2015-07-25 00:07:33 +00:00
|
|
|
private static final String TAG = ContactPhotoLocalUriFetcher.class.getSimpleName();
|
|
|
|
|
2017-10-12 00:12:46 +00:00
|
|
|
ContactPhotoLocalUriFetcher(Context context, Uri uri) {
|
|
|
|
super(context.getContentResolver(), uri);
|
2015-07-25 00:07:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected InputStream loadResource(Uri uri, ContentResolver contentResolver)
|
|
|
|
throws FileNotFoundException
|
|
|
|
{
|
|
|
|
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
|
|
|
|
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
|
|
|
|
} else {
|
|
|
|
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|