use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowBitmap method createBitmap.
@Implementation
public static Bitmap createBitmap(int[] colors, int width, int height, Bitmap.Config config) {
if (colors.length != width * height) {
throw new IllegalArgumentException("array length (" + colors.length + ") did not match width * height (" + (width * height) + ")");
}
Bitmap newBitmap = Bitmap.createBitmap(width, height, config);
ShadowBitmap shadowBitmap = shadowOf(newBitmap);
shadowBitmap.setMutable(false);
shadowBitmap.createdFromColors = colors;
shadowBitmap.colors = new int[colors.length];
System.arraycopy(colors, 0, shadowBitmap.colors, 0, colors.length);
return newBitmap;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowBitmapFactory method decodeFileDescriptor.
@Implementation
public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, BitmapFactory.Options opts) {
Bitmap bitmap = create("fd:" + fd, opts);
ShadowBitmap shadowBitmap = Shadows.shadowOf(bitmap);
shadowBitmap.createdFromFileDescriptor = fd;
return bitmap;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowBitmapFactory method decodeFile.
@Implementation
public static Bitmap decodeFile(String pathName, BitmapFactory.Options options) {
Bitmap bitmap = create("file:" + pathName, options);
ShadowBitmap shadowBitmap = Shadows.shadowOf(bitmap);
shadowBitmap.createdFromPath = pathName;
return bitmap;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowBitmapFactory method decodeResource.
@Implementation
public static Bitmap decodeResource(Resources res, int id, BitmapFactory.Options options) {
if (id == 0) {
return null;
}
Bitmap bitmap = create("resource:" + RuntimeEnvironment.application.getResources().getResourceName(id), options);
Shadows.shadowOf(bitmap).createdFromResId = id;
return bitmap;
}
use of org.robolectric.annotation.Implementation in project robolectric by robolectric.
the class ShadowLocalBroadcastManager method sendBroadcast.
@Implementation
public boolean sendBroadcast(Intent intent) {
boolean sent = false;
sentBroadcastIntents.add(intent);
List<Wrapper> copy = new ArrayList<>();
copy.addAll(registeredReceivers);
for (Wrapper wrapper : copy) {
if (wrapper.intentFilter.matchAction(intent.getAction())) {
final int match = wrapper.intentFilter.matchData(intent.getType(), intent.getScheme(), intent.getData());
if (match != IntentFilter.NO_MATCH_DATA && match != IntentFilter.NO_MATCH_TYPE) {
sent = true;
final BroadcastReceiver receiver = wrapper.broadcastReceiver;
final Intent broadcastIntent = intent;
Robolectric.getForegroundThreadScheduler().post(new Runnable() {
@Override
public void run() {
receiver.onReceive(RuntimeEnvironment.application, broadcastIntent);
}
});
}
}
}
return sent;
}
Aggregations