1 |
6a06a912
|
Leszek Koltunski
|
package org.distorted.library;
|
2 |
|
|
|
3 |
|
|
import java.util.HashMap;
|
4 |
|
|
/**
|
5 |
|
|
* List of all DistortedObjects currently created by the application.
|
6 |
|
|
* We need to be able to quickly retrieve an Object by its ID, thus a HashMap.
|
7 |
|
|
*/
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
final class DistortedObjectList
|
11 |
|
|
{
|
12 |
|
|
private static long id =0;
|
13 |
9361b337
|
Leszek Koltunski
|
private static HashMap<Long,DistortedObject> mBitmaps = new HashMap<>();
|
14 |
6a06a912
|
Leszek Koltunski
|
|
15 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
16 |
|
|
|
17 |
|
|
static synchronized long add(DistortedObject dBmp)
|
18 |
|
|
{
|
19 |
|
|
long ret = id++;
|
20 |
|
|
mBitmaps.put(ret,dBmp);
|
21 |
|
|
return ret;
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
|
26 |
|
|
static synchronized void remove(DistortedObject dBmp)
|
27 |
|
|
{
|
28 |
|
|
mBitmaps.remove(dBmp);
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
|
|
33 |
|
|
static DistortedObject get(long id)
|
34 |
|
|
{
|
35 |
|
|
return mBitmaps.get(id);
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
|
40 |
|
|
static synchronized void reset()
|
41 |
|
|
{
|
42 |
|
|
for(long id: mBitmaps.keySet())
|
43 |
|
|
{
|
44 |
|
|
get(id).resetTexture();
|
45 |
|
|
}
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49 |
|
|
|
50 |
|
|
static synchronized void release()
|
51 |
|
|
{
|
52 |
|
|
for(long id: mBitmaps.keySet())
|
53 |
|
|
{
|
54 |
|
|
get(id).releasePriv();
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
mBitmaps.clear();
|
58 |
|
|
id = 0;
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
}
|