-
-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB: migrate to unique IDs for groups #1333
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,36 +5,21 @@ | |
import androidx.annotation.Nullable; | ||
|
||
public class Group { | ||
public final String _id; | ||
public final int _id; | ||
public final String name; | ||
public final int order; | ||
|
||
public Group(final String _id, final int order) { | ||
public Group(final int _id, final String name, final int order) { | ||
this._id = _id; | ||
this.name = name; | ||
this.order = order; | ||
} | ||
|
||
public static Group toGroup(Cursor cursor) { | ||
String _id = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbGroups.ID)); | ||
int _id = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbGroups.ID)); | ||
String name = cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbGroups.NAME)); | ||
int order = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbGroups.ORDER)); | ||
|
||
return new Group(_id, order); | ||
} | ||
|
||
@Override | ||
public boolean equals(@Nullable Object obj) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure we lo longer need |
||
if (obj == null) { | ||
return false; | ||
} | ||
if (!(obj instanceof Group)) { | ||
return false; | ||
} | ||
Group anotherGroup = (Group) obj; | ||
return _id.equals(anotherGroup._id) && order == anotherGroup.order; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
String combined = _id + "_" + order; | ||
return combined.hashCode(); | ||
return new Group(_id, name, order); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Altonss why did you remove
COLLATE NOCASE
?