Skip to content

Commit

Permalink
Create database model
Browse files Browse the repository at this point in the history
Prekė `Item`:

* barcode - Barkodas
* name - Prekės pavadinimas
* price - Kaina
* weight - Svoris
* image_url - Nuotrauka

Nuskenuota prekė `ScannedItem`:

* id - nuskenavimo id
* barcode - prekės barkodas
* time - Laikas
* place - Vieta
* volunteer - Savanoris
  • Loading branch information
ViliusKraujutis committed Feb 8, 2014
1 parent c6e9e5c commit a3d19b7
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Skenavimą pasinaudojant Intent'ais.
* OnStop
* OnDestroy

[Pakeitimai](8a58e205d20fd3556cad6e6f3032397069718879)
[Pakeitimai](https://github.com/gdgvilnius/MaistoBankas/commit/8a58e205d20fd3556cad6e6f3032397069718879)

## Fragmentų gyvavimo ciklo loginimas
Analogiškai kaip ir su Activity gyvavimo ciklo loginimu,
Expand All @@ -77,5 +77,30 @@ kurioje sudėsime loginimo metodus:
* onAttach
...

[Pasikeitimai]()
[Pasikeitimai](https://github.com/gdgvilnius/MaistoBankas/commit/c6e9e5c208491567eb4879c13d7af52035a81498)

## Integruoti duomenų bazę Barkodų saugojimui
Tam pasinaudosime [ORM lite](http://ormlite.com/sqlite_java_android_orm.shtml).

### Susikurti duomenų modelį

Saugotina informacija

Prekė `Item`:

* barcode - Barkodas
* name - Prekės pavadinimas
* price - Kaina
* weight - Svoris
* image_url - Nuotrauka

Nuskenuota prekė `ScannedItem`:

* id - nuskenavimo id
* barcode - prekės barkodas
* time - Laikas
* place - Vieta
* volunteer - Savanoris

[Pakeitimai]()

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ android {

dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.j256.ormlite:ormlite-android:4.+'
compile 'com.android.support:support-v4:13.0.+'
}
69 changes: 69 additions & 0 deletions app/src/main/java/lt/andro/maistobankas/db/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package lt.andro.maistobankas.db;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
* @author Vilius Kraujutis viliusk@gmail.com
* @since 2014-02-08 14:30
*/
@DatabaseTable(tableName = "items")
public class Item {
@DatabaseField(id = true)
private String barcode;
private String name;
private double price;
private double weight;
private String imageUrl;

public String getBarcode() {
return barcode;
}

public void setBarcode(String barcode) {
this.barcode = barcode;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}

public double getWeight() {
return weight;
}

public void setWeight(double weight) {
this.weight = weight;
}

public String getImageUrl() {
return imageUrl;
}

public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}

@Override
public String toString() {
return "Item{" +
"barcode='" + barcode + '\'' +
", name='" + name + '\'' +
", price=" + price +
", weight=" + weight +
", imageUrl='" + imageUrl + '\'' +
'}';
}
}
73 changes: 73 additions & 0 deletions app/src/main/java/lt/andro/maistobankas/db/ScannedItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package lt.andro.maistobankas.db;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
* @author Vilius Kraujutis viliusk@gmail.com
* @since 2014-02-08 14:50
*/
@DatabaseTable(tableName = "scanned_item")
public class ScannedItem {

@DatabaseField(id = true)
private long id;

@DatabaseField(canBeNull = false)
private String barcode;
@DatabaseField(canBeNull = false)
private long timestamp;
private String place;
private String volunteer;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getBarcode() {
return barcode;
}

public void setBarcode(String barcode) {
this.barcode = barcode;
}

public long getTimestamp() {
return timestamp;
}

public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}

public String getPlace() {
return place;
}

public void setPlace(String place) {
this.place = place;
}

public String getVolunteer() {
return volunteer;
}

public void setVolunteer(String volunteer) {
this.volunteer = volunteer;
}

@Override
public String toString() {
return "ScannedItem{" +
"id=" + id +
", barcode='" + barcode + '\'' +
", timestamp=" + timestamp +
", place='" + place + '\'' +
", volunteer='" + volunteer + '\'' +
'}';
}
}

0 comments on commit a3d19b7

Please sign in to comment.