Skip to content
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

fix: Display product by order ID product list view #456

Merged
merged 5 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 52): knows all DAOs.
* Master of DAO (schema version 53): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 52;
public static final int SCHEMA_VERSION = 53;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
Expand Down
12 changes: 11 additions & 1 deletion core/src/main/java/in/testpress/models/greendao/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class Product {
@SerializedName("courses")
@Convert(converter = in.testpress.util.IntegerListConverter.class, columnType = String.class)
private IntegerList courseIds;
private Long order;

// KEEP FIELDS - put your custom fields here
// KEEP FIELDS END
Expand All @@ -56,7 +57,7 @@ public Product(Long id) {
}

@Generated
public Product(Long id, String title, String slug, String descriptionHtml, String image, String startDate, String endDate, String buyNowText, String surl, String furl, String currentPrice, IntegerList prices, IntegerList courseIds) {
public Product(Long id, String title, String slug, String descriptionHtml, String image, String startDate, String endDate, String buyNowText, String surl, String furl, String currentPrice, IntegerList prices, IntegerList courseIds, Long order) {
this.id = id;
this.title = title;
this.slug = slug;
Expand All @@ -70,6 +71,7 @@ public Product(Long id, String title, String slug, String descriptionHtml, Strin
this.currentPrice = currentPrice;
this.prices = prices;
this.courseIds = courseIds;
this.order = order;
}

public Long getId() {
Expand Down Expand Up @@ -176,6 +178,14 @@ public void setCourseIds(IntegerList courseIds) {
this.courseIds = courseIds;
}

public Long getOrder() {
return order;
}

public void setOrder(Long order) {
this.order = order;
}

// KEEP METHODS - put your custom methods here

public static QueryBuilder<Product> getQueryBuilder(Context context) {
Expand Down
18 changes: 16 additions & 2 deletions core/src/main/java/in/testpress/models/greendao/ProductDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static class Properties {
public final static Property CurrentPrice = new Property(10, String.class, "currentPrice", false, "CURRENT_PRICE");
public final static Property Prices = new Property(11, String.class, "prices", false, "PRICES");
public final static Property CourseIds = new Property(12, String.class, "courseIds", false, "COURSE_IDS");
public final static Property Order = new Property(13, Long.class, "order", false, "ORDER");
}

private final IntegerListConverter pricesConverter = new IntegerListConverter();
Expand Down Expand Up @@ -67,7 +68,8 @@ public static void createTable(Database db, boolean ifNotExists) {
"\"FURL\" TEXT," + // 9: furl
"\"CURRENT_PRICE\" TEXT," + // 10: currentPrice
"\"PRICES\" TEXT," + // 11: prices
"\"COURSE_IDS\" TEXT);"); // 12: courseIds
"\"COURSE_IDS\" TEXT," + // 12: courseIds
"\"ORDER\" INTEGER);"); // 13: order
}

/** Drops the underlying database table. */
Expand Down Expand Up @@ -144,6 +146,11 @@ protected final void bindValues(DatabaseStatement stmt, Product entity) {
if (courseIds != null) {
stmt.bindString(13, courseIdsConverter.convertToDatabaseValue(courseIds));
}

Long order = entity.getOrder();
if (order != null) {
stmt.bindLong(14, order);
}
}

@Override
Expand Down Expand Up @@ -214,6 +221,11 @@ protected final void bindValues(SQLiteStatement stmt, Product entity) {
if (courseIds != null) {
stmt.bindString(13, courseIdsConverter.convertToDatabaseValue(courseIds));
}

Long order = entity.getOrder();
if (order != null) {
stmt.bindLong(14, order);
}
}

@Override
Expand All @@ -236,7 +248,8 @@ public Product readEntity(Cursor cursor, int offset) {
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // furl
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // currentPrice
cursor.isNull(offset + 11) ? null : pricesConverter.convertToEntityProperty(cursor.getString(offset + 11)), // prices
cursor.isNull(offset + 12) ? null : courseIdsConverter.convertToEntityProperty(cursor.getString(offset + 12)) // courseIds
cursor.isNull(offset + 12) ? null : courseIdsConverter.convertToEntityProperty(cursor.getString(offset + 12)), // courseIds
cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13) // order
);
return entity;
}
Expand All @@ -256,6 +269,7 @@ public void readEntity(Cursor cursor, Product entity, int offset) {
entity.setCurrentPrice(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setPrices(cursor.isNull(offset + 11) ? null : pricesConverter.convertToEntityProperty(cursor.getString(offset + 11)));
entity.setCourseIds(cursor.isNull(offset + 12) ? null : courseIdsConverter.convertToEntityProperty(cursor.getString(offset + 12)));
entity.setOrder(cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ public AvailableCourseListAdapter(Activity activity, final List<Product> items)
setItems(items);
}

@Override
public Product getItem(int position) {
return productDao.queryBuilder().listLazy().get(position);
}

@Override
public int getCount() {
return (int) productDao.queryBuilder().count();
}

@Override
public long getItemId(int position) {
return getItem(position).getId();
}

@Override
protected int[] getChildViewIds() {
return new int[] { R.id.title, R.id.total_chapters, R.id.total_contents, R.id.price,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class TestpressSDKDaoGenerator {
// Increase the version if any modification has been made in this file.
private static final int VERSION = 52;
private static final int VERSION = 53;

public static void main(String args[]) throws Exception {
Schema schema = new Schema(VERSION, "in.testpress.models.greendao");
Expand Down Expand Up @@ -141,6 +141,7 @@ private static Entity addProduct(Schema schema) {
"in.testpress.util.IntegerList",
"in.testpress.util.IntegerListConverter"
).codeBeforeField("@SerializedName(\"courses\")");
product.addLongProperty("order");
return product;
}

Expand Down