use of android.support.annotation.Nullable in project GalleryFinal by pengjianbo.
the class CropUtil method getFromMediaUriPfd.
@Nullable
private static File getFromMediaUriPfd(Context context, ContentResolver resolver, Uri uri) {
if (uri == null)
return null;
FileInputStream input = null;
FileOutputStream output = null;
try {
ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r");
FileDescriptor fd = pfd.getFileDescriptor();
input = new FileInputStream(fd);
String tempFilename = getTempFilename(context);
output = new FileOutputStream(tempFilename);
int read;
byte[] bytes = new byte[4096];
while ((read = input.read(bytes)) != -1) {
output.write(bytes, 0, read);
}
return new File(tempFilename);
} catch (IOException ignored) {
// Nothing we can do
} finally {
closeSilently(input);
closeSilently(output);
}
return null;
}
use of android.support.annotation.Nullable in project storio by pushtorefresh.
the class DefaultStorIOContentResolverTest method getTypeMappingFinder.
@Nullable
private static TypeMappingFinder getTypeMappingFinder(@NonNull DefaultStorIOContentResolver storIOContentResolver) throws NoSuchFieldException, IllegalAccessException {
Field field = DefaultStorIOContentResolver.LowLevelImpl.class.getDeclaredField("typeMappingFinder");
field.setAccessible(true);
return (TypeMappingFinder) field.get(storIOContentResolver.lowLevel());
}
use of android.support.annotation.Nullable in project storio by pushtorefresh.
the class PreparedGetObject method executeAsBlocking.
/**
* Executes Prepared Operation immediately in current thread.
* <p>
* Notice: This is blocking I/O operation that should not be executed on the Main Thread,
* it can cause ANR (Activity Not Responding dialog), block the UI and drop animations frames.
* So please, call this method on some background thread. See {@link WorkerThread}.
*
* @return single instance of mapped result. Can be {@code null}, if no items are found.
*/
@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
@WorkerThread
@Nullable
@Override
public T executeAsBlocking() {
try {
final GetResolver<T> getResolver;
if (explicitGetResolver != null) {
getResolver = explicitGetResolver;
} else {
final ContentResolverTypeMapping<T> typeMapping = storIOContentResolver.lowLevel().typeMapping(type);
if (typeMapping == null) {
throw new IllegalStateException("This type does not have type mapping: " + "type = " + type + "," + "ContentProvider was not touched by this operation, please add type mapping for this type");
}
getResolver = typeMapping.getResolver();
}
final Cursor cursor = getResolver.performGet(storIOContentResolver, query);
try {
final int count = cursor.getCount();
if (count == 0) {
return null;
}
cursor.moveToFirst();
return getResolver.mapFromCursor(cursor);
} finally {
cursor.close();
}
} catch (Exception exception) {
throw new StorIOException("Error has occurred during Get operation. query = " + query, exception);
}
}
use of android.support.annotation.Nullable in project storio by pushtorefresh.
the class PreparedGetObject method executeAsBlocking.
/**
* Executes Get Operation immediately in current thread.
* <p>
* Notice: This is blocking I/O operation that should not be executed on the Main Thread,
* it can cause ANR (Activity Not Responding dialog), block the UI and drop animations frames.
* So please, call this method on some background thread. See {@link WorkerThread}.
*
* @return single instance of mapped result. Can be {@code null}, if no items are found.
*/
@Nullable
@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
@WorkerThread
public T executeAsBlocking() {
try {
final GetResolver<T> getResolver;
if (explicitGetResolver != null) {
getResolver = explicitGetResolver;
} else {
final SQLiteTypeMapping<T> typeMapping = storIOSQLite.lowLevel().typeMapping(type);
if (typeMapping == null) {
throw new IllegalStateException("This type does not have type mapping: " + "type = " + type + "," + "db was not touched by this operation, please add type mapping for this type");
}
getResolver = typeMapping.getResolver();
}
final Cursor cursor;
if (query != null) {
cursor = getResolver.performGet(storIOSQLite, query);
} else if (rawQuery != null) {
cursor = getResolver.performGet(storIOSQLite, rawQuery);
} else {
throw new IllegalStateException("Please specify query");
}
try {
final int count = cursor.getCount();
if (count == 0) {
return null;
}
cursor.moveToNext();
return getResolver.mapFromCursor(cursor);
} finally {
cursor.close();
}
} catch (Exception exception) {
throw new StorIOException("Error has occurred during Get operation. query = " + (query != null ? query : rawQuery), exception);
}
}
use of android.support.annotation.Nullable in project RxJavaSamples by rengwuxian.
the class ElementaryFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_elementary, container, false);
ButterKnife.bind(this, view);
gridRv.setLayoutManager(new GridLayoutManager(getActivity(), 2));
gridRv.setAdapter(adapter);
swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);
swipeRefreshLayout.setEnabled(false);
return view;
}
Aggregations