@@ -377,6 +377,11 @@ public static List<Exit> getExitsForDelete() {
377
377
return new Exit ().getItems (params );
378
378
}
379
379
380
+ @ Override
381
+ public boolean delete () {
382
+ return this .delete (true );
383
+ }
384
+
380
385
public boolean delete (boolean updateJumps ) {
381
386
382
387
//We need to update jumps before deleting
@@ -390,54 +395,6 @@ public boolean delete(boolean updateJumps) {
390
395
return super .delete ();
391
396
}
392
397
393
- @ Override
394
- protected void populateContentValues (ContentValues contentValues ) {
395
-
396
- if (this ._id > 0 ) {
397
- contentValues .put (_ID , this ._id );
398
- }
399
-
400
- moveExistingExit ();
401
- super .populateContentValues (contentValues );
402
- }
403
-
404
- /**
405
- * This method is only used when a remote_id attribute is set.
406
- * We need to check if we already have an exit in this position and shuffle it out to a new unused ID
407
- */
408
- private void moveExistingExit () {
409
- if (this .remote_id != null ) {
410
- //Check if we need to move an existing item out of the way.
411
- Exit existingExit = (Exit ) new Exit ().getOneById (this .remote_id );
412
-
413
- if (existingExit != null ) {
414
- //get the newId BEFORE deleting existing exit to prevent overlapping
415
- int newId = new Exit ().getNextAutoIncrement ();
416
-
417
- existingExit .setDeleted (DELETED_TRUE );
418
- existingExit .delete (false );
419
-
420
- if (existingExit .getDetails () != null ) {
421
- existingExit .getDetails ().setExitId (newId );
422
- existingExit .getDetails ().save ();
423
- }
424
-
425
- existingExit ._id = newId ;
426
- existingExit .markSynced ();
427
- }
428
-
429
- //Check if we have a global exit with the same incoming name, if we do, remove it
430
- Exit globalExit = (Exit ) new Exit ().getItem (new Pair <String , String >(COLUMN_NAME_NAME , this .getName ()));
431
- if (globalExit != null && globalExit .isGlobal ()) {
432
- if (globalExit .getDetails () != null ) {
433
- globalExit .getDetails ().delete ();
434
- }
435
- globalExit .setDeleted (DELETED_TRUE );
436
- globalExit .delete ();
437
- }
438
- }
439
- }
440
-
441
398
/**
442
399
* Get the top jumped exits
443
400
*
@@ -451,7 +408,13 @@ public static LinkedHashMap<Exit, Integer> getTop3Exits() {
451
408
452
409
if (cursor .moveToFirst ()) {
453
410
while (cursor .isAfterLast () == false ) {
454
- results .put ((Exit ) new Exit ().getOneById (cursor .getInt (0 )), cursor .getInt (1 ));
411
+ int exitId = cursor .getInt (0 );
412
+ int jumpsFromExit = cursor .getInt (1 );
413
+ Exit exit = (Exit ) new Exit ().getOneById (exitId );
414
+
415
+ if (exitId != 0 && exit != null ) {
416
+ results .put (exit , jumpsFromExit );
417
+ }
455
418
cursor .moveToNext ();
456
419
}
457
420
}
0 commit comments