Revision eb985085
Added by Leszek Koltunski almost 4 years ago
| src/main/java/org/distorted/config/ConfigScreen.java | ||
|---|---|---|
| 99 | 99 |
RubikObject rObject = RubikObjectList.getObject(ordinal); |
| 100 | 100 |
int row = object/NUM_COLUMNS; |
| 101 | 101 |
ImageButton button = new ImageButton(act); |
| 102 |
if( rObject!=null ) rObject.setIconTo(button); |
|
| 102 |
if( rObject!=null ) rObject.setIconTo(act,button);
|
|
| 103 | 103 |
|
| 104 | 104 |
button.setOnClickListener( new View.OnClickListener() |
| 105 | 105 |
{
|
| src/main/java/org/distorted/dialogs/RubikDialogPattern.java | ||
|---|---|---|
| 104 | 104 |
int ordinal = RubikPatternList.getObject(i); |
| 105 | 105 |
RubikObject object = RubikObjectList.getObject(ordinal); |
| 106 | 106 |
ImageView imageView = new ImageView(act); |
| 107 |
if( object!=null ) object.setIconTo(imageView); |
|
| 107 |
if( object!=null ) object.setIconTo(act,imageView);
|
|
| 108 | 108 |
imageView.setLayoutParams(paramsView); |
| 109 | 109 |
TabLayout.Tab tab = tabLayout.getTabAt(i); |
| 110 | 110 |
if(tab!=null) tab.setCustomView(imageView); |
| src/main/java/org/distorted/dialogs/RubikDialogScores.java | ||
|---|---|---|
| 116 | 116 |
{
|
| 117 | 117 |
RubikObject robject = RubikObjectList.getObject(object); |
| 118 | 118 |
ImageView imageView = new ImageView(act); |
| 119 |
if( robject!=null ) robject.setIconTo(imageView); |
|
| 119 |
if( robject!=null ) robject.setIconTo(act,imageView);
|
|
| 120 | 120 |
imageView.setLayoutParams(paramsView); |
| 121 | 121 |
TabLayout.Tab tab = tabLayout.getTabAt(object); |
| 122 | 122 |
if(tab!=null) tab.setCustomView(imageView); |
| src/main/java/org/distorted/dialogs/RubikDialogTutorial.java | ||
|---|---|---|
| 103 | 103 |
RubikObject object = RubikObjectList.getObject(i); |
| 104 | 104 |
ImageView imageView = new ImageView(act); |
| 105 | 105 |
imageView.setLayoutParams(paramsView); |
| 106 |
if( object!=null ) object.setIconTo(imageView); |
|
| 106 |
if( object!=null ) object.setIconTo(act,imageView);
|
|
| 107 | 107 |
TabLayout.Tab tab = tabLayout.getTabAt(i); |
| 108 | 108 |
if(tab!=null) tab.setCustomView(imageView); |
| 109 | 109 |
} |
| src/main/java/org/distorted/external/RubikFiles.java | ||
|---|---|---|
| 20 | 20 |
package org.distorted.external; |
| 21 | 21 |
|
| 22 | 22 |
import java.io.File; |
| 23 |
import java.io.FileInputStream; |
|
| 24 |
import java.io.FileNotFoundException; |
|
| 23 | 25 |
import java.io.FileOutputStream; |
| 24 | 26 |
import java.io.IOException; |
| 25 | 27 |
import java.io.InputStream; |
| ... | ... | |
| 54 | 56 |
|
| 55 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | 58 |
|
| 57 |
public Bitmap getIcon(Context context, String name)
|
|
| 59 |
public InputStream openFile(Context context, String name)
|
|
| 58 | 60 |
{
|
| 59 | 61 |
File file = new File(context.getFilesDir(), name); |
| 60 | 62 |
|
| 63 |
try |
|
| 64 |
{
|
|
| 65 |
return new FileInputStream(file); |
|
| 66 |
} |
|
| 67 |
catch(FileNotFoundException ex) |
|
| 68 |
{
|
|
| 69 |
// ignore |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
return null; |
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 76 |
|
|
| 77 |
public Bitmap getIcon(Context context, String name) |
|
| 78 |
{
|
|
| 79 |
File dir = context.getFilesDir(); |
|
| 80 |
File file = new File(dir, name); |
|
| 81 |
|
|
| 61 | 82 |
if( file.exists() ) |
| 62 | 83 |
{
|
| 63 |
String fname = context.getFilesDir().getAbsolutePath()+"/"+name;
|
|
| 84 |
String fname = dir.getAbsolutePath()+"/"+name;
|
|
| 64 | 85 |
return BitmapFactory.decodeFile(fname); |
| 65 | 86 |
} |
| 66 | 87 |
|
| src/main/java/org/distorted/objects/RubikObject.java | ||
|---|---|---|
| 23 | 23 |
|
| 24 | 24 |
import android.app.Activity; |
| 25 | 25 |
import android.content.res.Resources; |
| 26 |
import android.graphics.drawable.Drawable; |
|
| 26 | 27 |
import android.widget.ImageButton; |
| 27 | 28 |
import android.widget.ImageView; |
| 28 | 29 |
|
| ... | ... | |
| 47 | 48 |
|
| 48 | 49 |
private int mMeshState; |
| 49 | 50 |
private int mExtrasOrdinal; |
| 51 |
private Drawable mIconD; |
|
| 50 | 52 |
|
| 51 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 52 | 54 |
|
| ... | ... | |
| 70 | 72 |
|
| 71 | 73 |
mObjectMinor = JsonWriter.VERSION_OBJECT_MINOR; |
| 72 | 74 |
mExtrasMinor = JsonWriter.VERSION_EXTRAS_MINOR; |
| 75 |
|
|
| 76 |
mIconD = null; |
|
| 73 | 77 |
} |
| 74 | 78 |
/* |
| 75 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 99 | 103 |
|
| 100 | 104 |
} |
| 101 | 105 |
*/ |
| 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 107 |
|
|
| 108 |
private void createIconDrawable(Activity act) |
|
| 109 |
{
|
|
| 110 |
mIconD = act.getDrawable(mIconID); |
|
| 111 |
} |
|
| 112 |
|
|
| 102 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 103 | 114 |
|
| 104 | 115 |
public void setExtrasOrdinal(int ordinal) |
| ... | ... | |
| 144 | 155 |
|
| 145 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 146 | 157 |
|
| 147 |
public void setIconTo(ImageButton button) |
|
| 158 |
public int getObjectMinor() |
|
| 159 |
{
|
|
| 160 |
return mObjectMinor; |
|
| 161 |
} |
|
| 162 |
|
|
| 163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 164 |
|
|
| 165 |
public int getExtrasMinor() |
|
| 166 |
{
|
|
| 167 |
return mExtrasMinor; |
|
| 168 |
} |
|
| 169 |
|
|
| 170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 171 |
|
|
| 172 |
public void setIconTo(Activity act,ImageButton button) |
|
| 148 | 173 |
{
|
| 149 |
button.setBackgroundResource(mIconID); |
|
| 174 |
if( mIconD==null ) createIconDrawable(act); |
|
| 175 |
button.setBackground(mIconD); |
|
| 150 | 176 |
} |
| 151 | 177 |
|
| 152 | 178 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 153 | 179 |
|
| 154 |
public void setIconTo(ImageView view) |
|
| 180 |
public void setIconTo(Activity act,ImageView view)
|
|
| 155 | 181 |
{
|
| 156 |
view.setImageResource(mIconID); |
|
| 182 |
if( mIconD==null ) createIconDrawable(act); |
|
| 183 |
view.setImageDrawable(mIconD); |
|
| 157 | 184 |
} |
| 158 | 185 |
|
| 159 | 186 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 205 | 232 |
{
|
| 206 | 233 |
return mPatterns; |
| 207 | 234 |
} |
| 208 |
|
|
| 209 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 210 |
|
|
| 211 |
public int getObjectMinor() |
|
| 212 |
{
|
|
| 213 |
return mObjectMinor; |
|
| 214 |
} |
|
| 215 |
|
|
| 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 217 |
|
|
| 218 |
public int getExtrasMinor() |
|
| 219 |
{
|
|
| 220 |
return mExtrasMinor; |
|
| 221 |
} |
|
| 222 | 235 |
} |
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 277 | 277 |
final RubikObject rObject = RubikObjectList.getObject(object); |
| 278 | 278 |
int row = object/NUM_COLUMNS; |
| 279 | 279 |
ImageButton button = new ImageButton(act); |
| 280 |
if( rObject!=null ) rObject.setIconTo(button); |
|
| 280 |
if( rObject!=null ) rObject.setIconTo(act,button);
|
|
| 281 | 281 |
|
| 282 | 282 |
button.setOnClickListener( new View.OnClickListener() |
| 283 | 283 |
{
|
Also available in: Unified diff
Refactor RubikObject in preparation for creating RubikObjects from DownloadedObjects.