forked from bumptech/glide
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes bumptech#335. Allows us to re-use Bitmaps with configs other than ARGB_8888. Differs from AttributeStrategy in that it sorts Bitmaps by config only, and allows Bitmaps with a given config to be reconfigured to change their dimensions. In addition, we allow switching configs between the hidden GIF config and ARGB_8888 which appears not to trigger bumptech#301.
- Loading branch information
Showing
13 changed files
with
326 additions
and
50 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...ndroidTest/java/com/bumptech/glide/load/engine/bitmap_recycle/SizeConfigStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.bumptech.glide.load.engine.bitmap_recycle; | ||
|
||
import com.google.common.testing.EqualsTester; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
public class SizeConfigStrategyTest { | ||
|
||
@Mock SizeConfigStrategy.KeyPool pool; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
} | ||
|
||
@Test | ||
public void testKeyEquals() { | ||
new EqualsTester() | ||
.addEqualityGroup( | ||
new SizeConfigStrategy.Key(pool, 100, Bitmap.Config.ARGB_8888), | ||
new SizeConfigStrategy.Key(pool, 100, Bitmap.Config.ARGB_8888) | ||
) | ||
.addEqualityGroup( | ||
new SizeConfigStrategy.Key(pool, 101, Bitmap.Config.ARGB_8888) | ||
) | ||
.addEqualityGroup( | ||
new SizeConfigStrategy.Key(pool, 100, Bitmap.Config.RGB_565) | ||
) | ||
.addEqualityGroup( | ||
new SizeConfigStrategy.Key(pool, 100, null /*config*/) | ||
) | ||
.testEquals(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/PrettyPrintTreeMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bumptech.glide.load.engine.bitmap_recycle; | ||
|
||
import java.util.TreeMap; | ||
|
||
class PrettyPrintTreeMap<K, V> extends TreeMap<K, V> { | ||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("( "); | ||
for (Entry<K, V> entry : entrySet()) { | ||
sb.append('{').append(entry.getKey()).append(':').append(entry.getValue()).append("}, "); | ||
} | ||
if (!isEmpty()) { | ||
sb.replace(sb.length() - 2, sb.length(), ""); | ||
} | ||
return sb.append(" )").toString(); | ||
} | ||
} |
Oops, something went wrong.