code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
private void setTestDeviceIds() {
// [START set_test_device_ids]
List<String> testDeviceIds = Arrays.asList("33BE2250B43518CCDA7DE426D04EE231");
RequestConfiguration configuration =
new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
MobileAds.setRequestConfiguration(conf... | Java code snippets for the developer guide. | setTestDeviceIds | java | googleads/googleads-mobile-android-examples | java/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/RequestConfigurationSnippets.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/RequestConfigurationSnippets.java | Apache-2.0 |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Set your test devices.
MobileAds.setRequestConfiguration(
new RequestConfiguration.Builder()
.setTestDeviceIds(Arrays.asList(TEST_DEVICE_HA... | A simple activity showing the use of {@link AdView} ads in a {@link RecyclerView} widget.
<p>The {@link RecyclerView} widget is a more advanced and flexible version of ListView. This
widget helps simplify the display and handling of large data sets by allowing the layout manager
to determine when to reuse (recycle) it... | onCreate | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
@Override
protected void onResume() {
for (Object item : recyclerViewItems) {
if (item instanceof AdView) {
AdView adView = (AdView) item;
adView.resume();
}
}
super.onResume();
} | A simple activity showing the use of {@link AdView} ads in a {@link RecyclerView} widget.
<p>The {@link RecyclerView} widget is a more advanced and flexible version of ListView. This
widget helps simplify the display and handling of large data sets by allowing the layout manager
to determine when to reuse (recycle) it... | onResume | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
@Override
protected void onPause() {
for (Object item : recyclerViewItems) {
if (item instanceof AdView) {
AdView adView = (AdView) item;
adView.pause();
}
}
super.onPause();
} | A simple activity showing the use of {@link AdView} ads in a {@link RecyclerView} widget.
<p>The {@link RecyclerView} widget is a more advanced and flexible version of ListView. This
widget helps simplify the display and handling of large data sets by allowing the layout manager
to determine when to reuse (recycle) it... | onPause | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
@Override
protected void onDestroy() {
for (Object item : recyclerViewItems) {
if (item instanceof AdView) {
AdView adView = (AdView) item;
adView.destroy();
}
}
super.onDestroy();
} | A simple activity showing the use of {@link AdView} ads in a {@link RecyclerView} widget.
<p>The {@link RecyclerView} widget is a more advanced and flexible version of ListView. This
widget helps simplify the display and handling of large data sets by allowing the layout manager
to determine when to reuse (recycle) it... | onDestroy | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
public int getAdWidth() {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int adWidthPixels = displayMetrics.widthPixels;
if (VERSION.SDK_INT >= VERSION_CODES.R) {
WindowMetrics windowMetrics = this.getWindowManager().getCurrentWindowMetrics();
adWidthPixels = windowMetrics.... | A simple activity showing the use of {@link AdView} ads in a {@link RecyclerView} widget.
<p>The {@link RecyclerView} widget is a more advanced and flexible version of ListView. This
widget helps simplify the display and handling of large data sets by allowing the layout manager
to determine when to reuse (recycle) it... | getAdWidth | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
private void addBannerAds() {
// Loop through the items array and place a new banner ad in every ith position in
// the items List.
for (int i = 0; i <= recyclerViewItems.size(); i += ITEMS_PER_AD) {
final AdView adView = new AdView(MainActivity.this);
adView.setAdSize(AdSize.getCurrentOrientati... | Adds banner ads to the items list. | addBannerAds | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
private void loadBannerAds() {
// Load the first banner ad in the items list (subsequent ads will be loaded automatically
// in sequence).
loadBannerAd(0);
} | Sets up and loads the banner ads. | loadBannerAds | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
private void loadBannerAd(final int index) {
if (index >= recyclerViewItems.size()) {
return;
}
Object item = recyclerViewItems.get(index);
if (!(item instanceof AdView)) {
throw new ClassCastException(
"Expected item at index " + index + " to be a banner ad" + " ad.");
}
... | Loads the banner ads in the items list. | loadBannerAd | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
@Override
public void onAdLoaded() {
super.onAdLoaded();
// The previous banner ad loaded successfully, call this method again to
// load the next ad in the items list.
loadBannerAd(index + ITEMS_PER_AD);
} | Loads the banner ads in the items list. | onAdLoaded | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
// The previous banner ad failed to load. Call this method again to load
// the next ad in the items list.
String error =
String.format(
Locale.US,
... | Loads the banner ads in the items list. | onAdFailedToLoad | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
private void addMenuItemsFromJson() {
try {
String jsonDataString = readJsonDataFromFile();
JSONArray menuItemsJsonArray = new JSONArray(jsonDataString);
for (int i = 0; i < menuItemsJsonArray.length(); ++i) {
JSONObject menuItemObject = menuItemsJsonArray.getJSONObject(i);
Stri... | Adds {@link MenuItem}'s from a JSON file. | addMenuItemsFromJson | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
private String readJsonDataFromFile() throws IOException {
InputStream inputStream = null;
StringBuilder builder = new StringBuilder();
try {
String jsonDataString = null;
inputStream = getResources().openRawResource(R.raw.menu_items_json);
BufferedReader bufferedReader =
new B... | Reads the JSON file and converts the JSON data to a {@link String}.
@return A {@link String} representation of the JSON data.
@throws IOException if unable to read the JSON file. | readJsonDataFromFile | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java | Apache-2.0 |
public String getName() {
return name;
} | The {@link MenuItem} class.
<p>Defines the attributes for a restaurant menu item.</p> | getName | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | Apache-2.0 |
public String getDescription() {
return description;
} | The {@link MenuItem} class.
<p>Defines the attributes for a restaurant menu item.</p> | getDescription | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | Apache-2.0 |
public String getPrice() {
return price;
} | The {@link MenuItem} class.
<p>Defines the attributes for a restaurant menu item.</p> | getPrice | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | Apache-2.0 |
public String getCategory() {
return category;
} | The {@link MenuItem} class.
<p>Defines the attributes for a restaurant menu item.</p> | getCategory | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | Apache-2.0 |
public String getImageName() {
return imageName;
} | The {@link MenuItem} class.
<p>Defines the attributes for a restaurant menu item.</p> | getImageName | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MenuItem.java | Apache-2.0 |
@Override
public int getItemViewType(int position) {
return (position % MainActivity.ITEMS_PER_AD == 0) ? BANNER_AD_VIEW_TYPE
: MENU_ITEM_VIEW_TYPE;
} | Determines the view type for the given position. | getItemViewType | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/RecyclerViewAdapter.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/RecyclerViewAdapter.java | Apache-2.0 |
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
switch (viewType) {
case MENU_ITEM_VIEW_TYPE:
View menuItemLayoutView = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.menu_it... | Creates a new view for a menu item view or a banner ad view based on the viewType. This method
is invoked by the layout manager. | onCreateViewHolder | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/RecyclerViewAdapter.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/RecyclerViewAdapter.java | Apache-2.0 |
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
int viewType = getItemViewType(position);
switch (viewType) {
case MENU_ITEM_VIEW_TYPE:
MenuItemViewHolder menuItemHolder = (MenuItemViewHolder) holder;
MenuItem ... | Replaces the content in the views that make up the menu item view and the banner ad view. This
method is invoked by the layout manager. | onBindViewHolder | java | googleads/googleads-mobile-android-examples | java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/RecyclerViewAdapter.java | https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/RecyclerViewAdapter.java | Apache-2.0 |
public static int getImageType(File file) {
int type = TYPE_STILL_IMAGE;
try {
FileInputStream inputStream = new FileInputStream(file);
byte[] header = new byte[20];
int read = inputStream.read(header);
if (read >= 3 && isGifHeader(header)) {
... | For GIF, we only need 3 bytes, 'GIF',
For WebP, we need 12 bytes, 'RIFF' + size + 'WEBP',
to determine still/animated WebP, we need 5 extra bytes, 4 bytes chunk header to check
for extended WebP format, 1 byte to check for animated bit.
reference: https://developers.google.com/speed/webp/docs/riff_container | getImageType | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | Apache-2.0 |
public static String typeName(int type) {
switch (type) {
case TYPE_GIF:
return "GIF";
case TYPE_STILL_WEBP:
return "STILL_WEBP";
case TYPE_ANIMATED_WEBP:
return "ANIMATED_WEBP";
case TYPE_STILL_IMAGE:
de... | For GIF, we only need 3 bytes, 'GIF',
For WebP, we need 12 bytes, 'RIFF' + size + 'WEBP',
to determine still/animated WebP, we need 5 extra bytes, 4 bytes chunk header to check
for extended WebP format, 1 byte to check for animated bit.
reference: https://developers.google.com/speed/webp/docs/riff_container | typeName | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | Apache-2.0 |
private static boolean isGifHeader(byte[] header) {
return header[0] == 'G' && header[1] == 'I' && header[2] == 'F';
} | For GIF, we only need 3 bytes, 'GIF',
For WebP, we need 12 bytes, 'RIFF' + size + 'WEBP',
to determine still/animated WebP, we need 5 extra bytes, 4 bytes chunk header to check
for extended WebP format, 1 byte to check for animated bit.
reference: https://developers.google.com/speed/webp/docs/riff_container | isGifHeader | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | Apache-2.0 |
private static boolean isWebpHeader(byte[] header) {
return header[0] == 'R' && header[1] == 'I' && header[2] == 'F' && header[3] == 'F'
&& header[8] == 'W' && header[9] == 'E' && header[10] == 'B' && header[11] == 'P';
} | For GIF, we only need 3 bytes, 'GIF',
For WebP, we need 12 bytes, 'RIFF' + size + 'WEBP',
to determine still/animated WebP, we need 5 extra bytes, 4 bytes chunk header to check
for extended WebP format, 1 byte to check for animated bit.
reference: https://developers.google.com/speed/webp/docs/riff_container | isWebpHeader | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | Apache-2.0 |
private static boolean isExtendedWebp(byte[] header) {
return header[12] == 'V' && header[13] == 'P' && header[14] == '8' && header[15] == 'X';
} | For GIF, we only need 3 bytes, 'GIF',
For WebP, we need 12 bytes, 'RIFF' + size + 'WEBP',
to determine still/animated WebP, we need 5 extra bytes, 4 bytes chunk header to check
for extended WebP format, 1 byte to check for animated bit.
reference: https://developers.google.com/speed/webp/docs/riff_container | isExtendedWebp | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/loader/ImageInfoExtractor.java | Apache-2.0 |
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (wm == null) return -1;
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
wm.getDefaultDispl... | Return the width of screen, in pixel.
@return the width of screen, in pixel | getScreenWidth | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | Apache-2.0 |
public static int getScreenHeight(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (wm == null) return -1;
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
wm.getDefaultDisp... | Return the height of screen, in pixel.
@return the height of screen, in pixel | getScreenHeight | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | Apache-2.0 |
public static int getAppScreenHeight(Context context) {
return getScreenHeight(context) - getNavigationBarHeight(context);
} | Return the height of screen, in pixel.
@return the height of screen, in pixel | getAppScreenHeight | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | Apache-2.0 |
public static boolean isLandscape(Context context) {
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
} | Return whether screen is landscape.
@return {@code true}: yes<br>{@code false}: no | isLandscape | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | Apache-2.0 |
public static boolean isPortrait(Context context) {
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
} | Return whether screen is portrait.
@return {@code true}: yes<br>{@code false}: no | isPortrait | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | Apache-2.0 |
public static int getScreenRotation(@NonNull final Activity activity) {
switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
case Surface.ROTATION_0:
return 0;
case Surface.ROTATION_90:
return 90;
case Surface.ROTATION_180:
... | Return the rotation of screen.
@param activity The activity.
@return the rotation of screen | getScreenRotation | java | mikaelzero/mojito | mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | https://github.com/mikaelzero/mojito/blob/master/mojito/src/main/java/net/mikaelzero/mojito/tools/ScreenUtils.java | Apache-2.0 |
private static int getMaxSize(@Nullable ActivityManager activityManager) {
final int memoryClassBytes = activityManager != null ? activityManager.getMemoryClass() * 1024 * 1024 : 100;
final boolean isLowMemoryDevice = isLowMemoryDevice(activityManager);
return Math.round(memoryClassBytes
... | A calculator that tries to intelligently determine cache sizes for a given device based on some constants and the
devices screen density, width, and height. | getMaxSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | Apache-2.0 |
private static String toMb(@NonNull Context context, int bytes) {
return Formatter.formatFileSize(context, bytes);
} | A calculator that tries to intelligently determine cache sizes for a given device based on some constants and the
devices screen density, width, and height. | toMb | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | Apache-2.0 |
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean isLowMemoryDevice(@Nullable ActivityManager activityManager) {
final int sdkInt = Build.VERSION.SDK_INT;
return activityManager == null || sdkInt >= Build.VERSION_CODES.KITKAT && activityManager.isLowRamDevice();
} | A calculator that tries to intelligently determine cache sizes for a given device based on some constants and the
devices screen density, width, and height. | isLowMemoryDevice | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | Apache-2.0 |
public int getMemoryCacheSize() {
return memoryCacheSize;
} | Returns the recommended memory cache size for the device it is run on in bytes. | getMemoryCacheSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | Apache-2.0 |
public int getBitmapPoolSize() {
return bitmapPoolSize;
} | Returns the recommended bitmap pool size for the device it is run on in bytes. | getBitmapPoolSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/MemorySizeCalculator.java | Apache-2.0 |
private static String getBitmapString(Bitmap bitmap) {
return getBitmapString(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | getBitmapString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
private static String getBitmapString(int width, int height, Bitmap.Config config) {
return "[" + width + "x" + height + "], " + config;
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | getBitmapString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
public void put(Bitmap bitmap) {
final Key key = keyPool.get(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
groupedMap.put(key, bitmap);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | put | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public Bitmap get(int width, int height, Bitmap.Config config) {
final Key key = keyPool.get(width, height, config);
return groupedMap.get(key);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | get | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public Bitmap removeLast() {
return groupedMap.removeLast();
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | removeLast | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public String logBitmap(Bitmap bitmap) {
return getBitmapString(bitmap);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | logBitmap | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
return getBitmapString(width, height, config);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | logBitmap | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public int getSize(Bitmap bitmap) {
return SketchUtils.getByteCount(bitmap);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | getSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Nullable
@Override
public String getKey() {
return "AttributeStrategy";
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | getKey | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
public Key get(int width, int height, Bitmap.Config config) {
Key result = get();
result.init(width, height, config);
return result;
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | get | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
protected Key create() {
return new Key(this);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | create | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
public void init(int width, int height, Bitmap.Config config) {
this.width = width;
this.height = height;
this.config = config;
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | init | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public boolean equals(Object o) {
if (o instanceof Key) {
Key other = (Key) o;
return width == other.width
&& height == other.height
&& config == other.config;
}
return false;
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | equals | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public int hashCode() {
int result = width;
result = 31 * result + height;
result = 31 * result + (config != null ? config.hashCode() : 0);
return result;
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | hashCode | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public String toString() {
return getBitmapString(width, height, config);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | toString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
@Override
public void offer() {
pool.offer(this);
} | A strategy for reusing bitmaps that requires any returned bitmap's dimensions to exactly match those request. | offer | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/AttributeStrategy.java | Apache-2.0 |
public V get(K key) {
LinkedEntry<K, V> entry = keyToEntry.get(key);
if (entry == null) {
entry = new LinkedEntry<K, V>(key);
keyToEntry.put(key, entry);
} else {
key.offer();
}
makeHead(entry);
return entry.removeLast();
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | get | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
public V removeLast() {
LinkedEntry<K, V> last = head.prev;
while (!last.equals(head)) {
V removed = last.removeLast();
if (removed != null) {
return removed;
} else {
// We will clean up empty lru entries since they are likely to have... | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | removeLast | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
@Override
public String toString() {
StringBuilder sb = new StringBuilder("GroupedLinkedMap( ");
LinkedEntry<K, V> current = head.next;
boolean hadAtLeastOneItem = false;
while (!current.equals(head)) {
hadAtLeastOneItem = true;
sb.append('{').append(current.k... | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | toString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
private void makeHead(LinkedEntry<K, V> entry) {
removeEntry(entry);
entry.prev = head;
entry.next = head.next;
updateEntry(entry);
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | makeHead | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
private void makeTail(LinkedEntry<K, V> entry) {
removeEntry(entry);
entry.prev = head.prev;
entry.next = head;
updateEntry(entry);
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | makeTail | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
private static <K, V> void updateEntry(LinkedEntry<K, V> entry) {
entry.next.prev = entry;
entry.prev.next = entry;
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | updateEntry | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
private static <K, V> void removeEntry(LinkedEntry<K, V> entry) {
entry.prev.next = entry.next;
entry.next.prev = entry.prev;
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | removeEntry | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
public V removeLast() {
final int valueSize = size();
return valueSize > 0 ? values.remove(valueSize - 1) : null;
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | removeLast | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
public int size() {
return values != null ? values.size() : 0;
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | size | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
public boolean contains(V value) {
return values != null && values.contains(value);
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | contains | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
public void add(V value) {
if (values == null) {
values = new ArrayList<V>();
}
values.add(value);
} | Similar to {@link java.util.LinkedHashMap} when access ordered except that it is access ordered on groups
of bitmaps rather than individual objects. The idea is to be able to find the LRU bitmap size, rather than the
LRU bitmap object. We can then remove bitmaps from the least recently used size of bitmap when we need ... | add | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/GroupedLinkedMap.java | Apache-2.0 |
@Override
public void put(Bitmap bitmap) {
int size = SketchUtils.getByteCount(bitmap);
Key key = keyPool.get(size, bitmap.getConfig());
groupedMap.put(key, bitmap);
NavigableMap<Integer, Integer> sizes = getSizesForConfig(bitmap.getConfig());
Integer current = sizes.get(ke... | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | put | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public Bitmap get(int width, int height, Bitmap.Config config) {
int size = SketchUtils.computeByteCount(width, height, config);
Key targetKey = keyPool.get(size, config);
Key bestKey = findBestKey(targetKey, size, config);
Bitmap result = groupedMap.get(bestKey);
... | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | get | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
private Key findBestKey(Key key, int size, Bitmap.Config config) {
Key result = key;
for (Bitmap.Config possibleConfig : getInConfigs(config)) {
NavigableMap<Integer, Integer> sizesForPossibleConfig = getSizesForConfig(possibleConfig);
Integer possibleSize = sizesForPossibleConfi... | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | findBestKey | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public Bitmap removeLast() {
Bitmap removed = groupedMap.removeLast();
if (removed != null) {
int removedSize = SketchUtils.getByteCount(removed);
decrementBitmapOfSize(removedSize, removed.getConfig());
}
return removed;
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | removeLast | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
private void decrementBitmapOfSize(Integer size, Bitmap.Config config) {
NavigableMap<Integer, Integer> sizes = getSizesForConfig(config);
Integer current = sizes.get(size);
if (current == 1) {
sizes.remove(size);
} else {
sizes.put(size, current - 1);
}
... | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | decrementBitmapOfSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
private NavigableMap<Integer, Integer> getSizesForConfig(Bitmap.Config config) {
NavigableMap<Integer, Integer> sizes = sortedSizes.get(config);
if (sizes == null) {
sizes = new TreeMap<Integer, Integer>();
sortedSizes.put(config, sizes);
}
return sizes;
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | getSizesForConfig | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public String logBitmap(Bitmap bitmap) {
int size = SketchUtils.getByteCount(bitmap);
return getBitmapString(size, bitmap.getConfig());
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | logBitmap | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
int size = SketchUtils.computeByteCount(width, height, config);
return getBitmapString(size, config);
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | logBitmap | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public int getSize(Bitmap bitmap) {
return SketchUtils.getByteCount(bitmap);
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | getSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public String toString() {
StringBuilder sb = new StringBuilder()
.append("SizeConfigStrategy{groupedMap=")
.append(groupedMap)
.append(", sortedSizes=(");
for (Map.Entry<Bitmap.Config, NavigableMap<Integer, Integer>> entry : sortedSizes.entr... | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | toString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Nullable
@Override
public String getKey() {
return "SizeConfigStrategy";
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | getKey | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
public Key get(int size, Bitmap.Config config) {
Key result = get();
result.init(size, config);
return result;
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | get | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
protected Key create() {
return new Key(this);
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | create | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
public void init(int size, Bitmap.Config config) {
this.size = size;
this.config = config;
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | init | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public void offer() {
pool.offer(this);
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | offer | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public String toString() {
return getBitmapString(size, config);
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | toString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public boolean equals(Object o) {
if (o instanceof Key) {
Key other = (Key) o;
return size == other.size && (config == null ? other.config == null : config.equals(other.config));
}
return false;
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | equals | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
@Override
public int hashCode() {
int result = size;
result = 31 * result + (config != null ? config.hashCode() : 0);
return result;
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | hashCode | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
private static String getBitmapString(int size, Bitmap.Config config) {
return "[" + size + "](" + config + ")";
} | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | getBitmapString | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
private static Bitmap.Config[] getInConfigs(Bitmap.Config requested) {
switch (requested) {
case ARGB_8888:
return ARGB_8888_IN_CONFIGS;
case RGB_565:
return RGB_565_IN_CONFIGS;
case ARGB_4444:
return ARGB_4444_IN_CONFIGS;
... | Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.
<p>
<p>
Using both the config and the byte size allows us to safely re-use a greater variety of
{@link Bitmap Bitmaps}, which increases the hit rate of the pool and ther... | getInConfigs | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/cache/recycle/SizeConfigStrategy.java | Apache-2.0 |
public static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
... | Returns the remainder of 'reader' as a string, closing it when done. | readFully | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public static String readAsciiLine(InputStream in) throws IOException {
StringBuilder result = new StringBuilder(80);
while (true) {
int c = in.read();
if (c == -1) {
throw new EOFException();
} else if (c == '\n') {
break;
... | Returns the ASCII characters up to but not including the next "\r\n", or
"\n".
@throws EOFException if the stream is exhausted before the next newline
character. | readAsciiLine | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public static void closeQuietly(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Exception ignored) {
}
}
} | Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null. | closeQuietly | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public static void deleteContents(File dir) throws IOException {
File[] files = dir.listFiles();
if (files == null) {
// throw new IllegalArgumentException("not a directory: " + dir);
return;
}
for (File file : files) {
if (file.isDirectory()) {
... | Recursively delete everything in {@code dir}. | deleteContents | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
@Override
public Void call() throws Exception {
synchronized (DiskLruCache.this) {
if (journalWriter == null) {
return null; // closed
}
trimToSize();
if (journalRebuildRequired()) {
rebuildJourna... | This cache uses a single background thread to evict entries. | call | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize)
throws IOException {
if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
if (valueCount <= 0) {
throw new IllegalArgumentException("valueCount <... | Opens the cache in {@code directory}, creating a cache if none exists
there.
@param directory a writable directory
@param appVersion
@param valueCount the number of values per cache entry. Must be positive.
@param maxSize the maximum number of bytes this cache should use to store
@throws IOException if reading or ... | open | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
private void readJournal() throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(journalFile), IO_BUFFER_SIZE);
try {
String magic = readAsciiLine(in);
String version = readAsciiLine(in);
String appVersionString = readAsciiLine(in);
... | Opens the cache in {@code directory}, creating a cache if none exists
there.
@param directory a writable directory
@param appVersion
@param valueCount the number of values per cache entry. Must be positive.
@param maxSize the maximum number of bytes this cache should use to store
@throws IOException if reading or ... | readJournal | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
private void readJournalLine(String line) throws IOException {
String[] parts = line.split(" ");
if (parts.length < 2) {
throw new IOException("unexpected journal line: " + line);
}
String key = parts[1];
if (parts[0].equals(REMOVE) && parts.length == 2) {
... | Opens the cache in {@code directory}, creating a cache if none exists
there.
@param directory a writable directory
@param appVersion
@param valueCount the number of values per cache entry. Must be positive.
@param maxSize the maximum number of bytes this cache should use to store
@throws IOException if reading or ... | readJournalLine | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
private void processJournal() throws IOException {
deleteIfExists(journalFileTmp);
for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext(); ) {
Entry entry = i.next();
if (entry.currentEditor == null) {
for (int t = 0; t < valueCount; t++) {
... | Computes the initial size and collects garbage as a part of opening the
cache. Dirty entries are assumed to be inconsistent and will be deleted. | processJournal | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public synchronized Snapshot get(String key) throws IOException, ClosedException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (entry == null) {
return null;
}
if (!entry.readable) {
return null;
}
/*... | Returns a snapshot of the entry named {@code key}, or null if it doesn't
exist is not currently readable. If a value is returned, it is moved to
the head of the LRU queue. | get | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public synchronized SimpleSnapshot getSimpleSnapshot(String key) throws IOException, ClosedException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (entry == null) {
return null;
}
if (!entry.readable) {
return null;
... | Returns a snapshot of the entry named {@code key}, or null if it doesn't
exist is not currently readable. If a value is returned, it is moved to
the head of the LRU queue. | getSimpleSnapshot | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public synchronized boolean exist(String key) throws ClosedException, IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
redundantOpCount++;
journalWriter.append(READ + ' ' + key + '\n');
if (journalRebuildRequired()) {
execu... | Returns exisr of the entry named {@code key} | exist | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public Editor edit(String key) throws IOException, ClosedException {
return edit(key, ANY_SEQUENCE_NUMBER);
} | Returns an editor for the entry named {@code key}, or null if another
edit is in progress. | edit | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException, ClosedException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER
&& (entry == null || entry.sequenceNumb... | Returns an editor for the entry named {@code key}, or null if another
edit is in progress. | edit | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public File getDirectory() {
return directory;
} | Returns the directory where this cache stores its data. | getDirectory | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
public long maxSize() {
return maxSize;
} | Returns the maximum number of bytes that this cache should use to store
its data. | maxSize | java | mikaelzero/mojito | SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | https://github.com/mikaelzero/mojito/blob/master/SketchImageViewLoader/src/main/java/net/mikaelzero/mojito/view/sketch/core/util/DiskLruCache.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.