Revision ac1900c3
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
---|---|---|
37 | 37 |
import org.distorted.external.RubikNetwork; |
38 | 38 |
import org.distorted.external.RubikUpdates; |
39 | 39 |
import org.distorted.objectlib.json.JsonReader; |
40 |
import org.distorted.objects.MainEntry; |
|
41 |
import org.distorted.objects.MainEntryList; |
|
42 |
import org.distorted.objects.RubikObject; |
|
40 | 43 |
import org.distorted.objects.RubikObjectList; |
41 | 44 |
import org.distorted.screens.RubikScreenPlay; |
42 | 45 |
import org.distorted.screens.ScreenList; |
... | ... | |
221 | 224 |
|
222 | 225 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1"); |
223 | 226 |
|
224 |
RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion, |
|
225 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess); |
|
227 |
boolean success = RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion, |
|
228 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess); |
|
229 |
if( success ) |
|
230 |
{ |
|
231 |
int numObjects = RubikObjectList.getNumObjects(); |
|
232 |
int ordinal = numObjects-1; |
|
233 |
RubikObject rubikObject = RubikObjectList.getObject(ordinal); |
|
234 |
MainEntry entry = new MainEntry(rubikObject,ordinal); |
|
235 |
MainEntryList list = MainEntryList.getInstance(); |
|
236 |
list.addEntry(entry); |
|
237 |
} |
|
226 | 238 |
|
227 | 239 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2"); |
228 | 240 |
|
src/main/java/org/distorted/objects/MainEntry.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 43 |
|
44 |
MainEntry(RubikObject object, int ordinal) |
|
44 |
public MainEntry(RubikObject object, int ordinal)
|
|
45 | 45 |
{ |
46 | 46 |
mType = TYPE_OBJECT; |
47 | 47 |
mIconID = 0; |
... | ... | |
53 | 53 |
|
54 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 55 |
|
56 |
MainEntry(int type, int iconID) |
|
56 |
public MainEntry(int type, int iconID)
|
|
57 | 57 |
{ |
58 | 58 |
mType = type; |
59 | 59 |
mIconID = iconID; |
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
138 | 138 |
mObjects.add(obj); |
139 | 139 |
mNumObjects++; |
140 | 140 |
|
141 |
MainEntry entry = new MainEntry(obj,mNumObjects-1); |
|
142 |
MainEntryList list = MainEntryList.getInstance(); |
|
143 |
list.addEntry(entry); |
|
144 |
|
|
145 | 141 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "creating downloaded object "+obj.getUpperName() ); |
146 | 142 |
|
147 | 143 |
if( obj.hasExtras() ) |
... | ... | |
203 | 199 |
|
204 | 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
205 | 201 |
|
206 |
public static void addDownloadedObject(Context context, String shortName, int numScrambles, int objectMinor,
|
|
202 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, int objectMinor,
|
|
207 | 203 |
int extrasMinor, boolean icon, boolean object, boolean extras) |
208 | 204 |
{ |
209 | 205 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras); |
... | ... | |
234 | 230 |
android.util.Log.e("D", "exception trying to reload object: "+ex.getMessage() ); |
235 | 231 |
} |
236 | 232 |
|
237 |
return; |
|
233 |
return false;
|
|
238 | 234 |
} |
239 | 235 |
} |
240 | 236 |
|
... | ... | |
246 | 242 |
{ |
247 | 243 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras); |
248 | 244 |
mDownloadedObjects.add(obj); |
245 |
return true; |
|
249 | 246 |
} |
250 | 247 |
else |
251 | 248 |
{ |
252 | 249 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" is already built-in, deleting"); |
253 |
|
|
254 |
mDownloadedObjects.remove(obj); |
|
255 | 250 |
RubikFiles files = RubikFiles.getInstance(); |
256 | 251 |
files.deleteIcon(context,shortName); |
257 | 252 |
files.deleteJsonObject(context,shortName); |
258 | 253 |
files.deleteJsonExtras(context,shortName); |
254 |
return false; |
|
259 | 255 |
} |
260 | 256 |
} |
261 | 257 |
|
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
99 | 99 |
mMenuButtonHeight = (int)(mScreenWidth*RubikActivity.MENU_BUTTON_HEIGHT); |
100 | 100 |
mMenuTextSize = (int)(mScreenWidth*RubikActivity.MENU_MAIN_TEXT_SIZE); |
101 | 101 |
|
102 |
recreatePopup();
|
|
102 |
mObjectPopup = null;
|
|
103 | 103 |
|
104 | 104 |
// TOP //////////////////////////// |
105 | 105 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
... | ... | |
183 | 183 |
|
184 | 184 |
private void setupObjectWindow(final RubikActivity act, final float width, final float height) |
185 | 185 |
{ |
186 |
MainEntryList list = MainEntryList.getInstance(); |
|
187 |
int numEntries = list.getNumOfEntries(); |
|
188 |
mRowCount = (numEntries + NUM_COLUMNS-1) / NUM_COLUMNS; |
|
189 |
mColCount = NUM_COLUMNS; |
|
190 |
|
|
186 | 191 |
int cubeSize = (int)(width/9); |
187 | 192 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN); |
188 | 193 |
mObjectSize = (int)(cubeSize + 2*margin + 0.5f); |
... | ... | |
216 | 221 |
colSpecs[col] = GridLayout.spec(col); |
217 | 222 |
} |
218 | 223 |
|
219 |
MainEntryList list = MainEntryList.getInstance(); |
|
220 |
int numEntries = list.getNumOfEntries(); |
|
221 |
|
|
222 | 224 |
for(int entry=0; entry<numEntries; entry++) |
223 | 225 |
{ |
224 | 226 |
final MainEntry mainEntry = list.getEntry(entry); |
... | ... | |
618 | 620 |
public void recreatePopup() |
619 | 621 |
{ |
620 | 622 |
mObjectPopup = null; |
621 |
|
|
622 |
MainEntryList list = MainEntryList.getInstance(); |
|
623 |
int numObjects = list.getNumOfEntries(); |
|
624 |
mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS; |
|
625 |
mColCount = NUM_COLUMNS; |
|
626 | 623 |
} |
627 | 624 |
|
628 | 625 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
correct the way we add new downloadeed objects.