Skip to content

Commit

Permalink
入荷
Browse files Browse the repository at this point in the history
apiエラーは出ないもののきちんと動作しているかは未検証
  • Loading branch information
R-Y committed Sep 4, 2012
1 parent 1747ebf commit 0d8d866
Show file tree
Hide file tree
Showing 15 changed files with 349 additions and 131 deletions.
38 changes: 23 additions & 15 deletions res/layout/stocking.xml
Expand Up @@ -6,15 +6,15 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.82"
android:orientation="vertical" >
Expand Down Expand Up @@ -74,16 +74,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Spinner
android:id="@+id/target_container_spinner"
android:layout_width="227dp"
<TextView
android:id="@+id/target_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.96" />
android:layout_weight="1" />

<Button
android:id="@+id/button1"
android:id="@+id/select_container_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="@string/select" />
</LinearLayout>

Expand All @@ -98,14 +99,21 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<Spinner
android:id="@+id/spinner1"
android:layout_width="226dp"
<ImageView
android:id="@+id/target_image"
android:layout_width="48dp"
android:layout_height="48dp"
android:contentDescription="" />

<TextView
android:id="@+id/target_product"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.55" />
android:layout_weight="1"
android:layout_marginLeft="10dp" />

<Button
android:id="@+id/button2"
android:id="@+id/select_product_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select" />
Expand All @@ -123,21 +131,21 @@
android:layout_height="wrap_content" >

<EditText
android:id="@+id/editText1"
android:id="@+id/stock_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />

<Button
android:id="@+id/button3"
android:id="@+id/stock_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/stock_in" />
</LinearLayout>

</LinearLayout>

</ScrollView>
2 changes: 2 additions & 0 deletions res/values-ja/strings.xml
Expand Up @@ -142,6 +142,8 @@
<string name="stock_number">いくつ入荷しますか?</string>
<string name="name">名前</string>
<string name="register_this_container">このコンテナに登録しますか?</string>
<string name="stock_this_product">この商品を入荷しますか?</string>
<string name="stock_done">入荷しました</string>

<string name="new_product_add">商品追加</string>
<string name="add">追加</string>
Expand Down
2 changes: 2 additions & 0 deletions res/values/strings.xml
Expand Up @@ -149,6 +149,8 @@
<string name="stock_number">Number of stock?</string>
<string name="name">Name</string>
<string name="register_this_container">Register this container?</string>
<string name="stock_this_product">Stocking this product?</string>
<string name="stock_done">Stock in</string>

<string name="new_product_add">Add Product</string>
<string name="add">Add</string>
Expand Down
36 changes: 29 additions & 7 deletions src/org/genshin/spree/SpreeImageData.java
Expand Up @@ -3,25 +3,47 @@
import android.graphics.drawable.Drawable;

public class SpreeImageData {
public String name;
public Integer id;
public Drawable data;
private String name;
private Integer id;
private Drawable data;

public SpreeImageData() {
this.name = "";
this.id = -1;
this.data = null;
}

public SpreeImageData(String name, Integer id) {
this.name = name;
this.id = id;
this.data = null;
}

public SpreeImageData(String name, Integer id, Drawable data) {
this.name = name;
this.id = id;
this.data = data;
}
}

// 各種ゲッター、セッター
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}

public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}

public Drawable getData() {
return this.data;
}
public void setData(Drawable data) {
this.data = data;
}
}
24 changes: 5 additions & 19 deletions src/org/genshin/warehouse/Warehouse.java
Expand Up @@ -38,9 +38,7 @@ public static enum ResultCodes { NORMAL, SCAN, SETTINGS, PRODUCT_SELECT,

// 入荷の時に使用
private static Product selectProduct = new Product();
private static String selectContainerName = "";
private static String selectContainerId = "";
private static String selectContainerPermalink = "";
private static ContainerTaxon selectContainer = new ContainerTaxon();

public Warehouse(Context homeContext) {
Warehouse.ctx = homeContext;
Expand Down Expand Up @@ -112,22 +110,10 @@ public static void setSelectProduct(Product product) {
Warehouse.selectProduct =product;
}

public static String getSelectContainerName() {
return Warehouse.selectContainerName;
public static ContainerTaxon getSelectContainer() {
return Warehouse.selectContainer;
}
public static void setSelectContainerName(String name) {
Warehouse.selectContainerName = name;
}
public static String getSelectContainerId() {
return Warehouse.selectContainerId;
}
public static void setSelectContainerId(String id) {
Warehouse.selectContainerId = id;
}
public static String getSelectContainerPermalink() {
return Warehouse.selectContainerPermalink;
}
public static void setSelectContainerPermalink(String permalink) {
Warehouse.selectContainerName = permalink;
public static void setSelectContainer(ContainerTaxon container) {
Warehouse.selectContainer = container;
}
}
31 changes: 17 additions & 14 deletions src/org/genshin/warehouse/products/Product.java
Expand Up @@ -45,6 +45,7 @@ public Product() {
this.description = "";
this.permalink = "";
this.visualCode = "";
this.variants = new ArrayList<Variant>();
}

// コンストラクタ
Expand All @@ -59,11 +60,13 @@ public Product(int id, String name, String sku, double price,
this.countOnHand = countOnHand;
this.description = description;
this.permalink = permalink;
this.variants = new ArrayList<Variant>();
}

// コンストラクタ JSONObjectを格納
public Product(JSONObject productJSON) {
init();
this.variants = new ArrayList<Variant>();

parseProductJSON(productJSON);

Expand Down Expand Up @@ -109,7 +112,7 @@ public Variant variant(int idx) {
public void addVariant(int id, String name, int countOnHand, // basics
String visualCode, String sku, double price, // extended identifying information
double weight, double height, double width, double depth, //physical specifications
Boolean isMaster, double costPrice, String permalink) { // extended data information
Boolean isMaster, double costPrice, String permalink) { // extended data informationß
variants.add(new Variant(id, name, countOnHand, visualCode, sku,
price, weight, height, width, depth, isMaster, costPrice, permalink));

Expand All @@ -124,7 +127,7 @@ public void addVariant(int id, String name, int countOnHand, // basics
private void obtainThumbnail() {
if (images.size() > 0) {
this.thumbnail = images.get(0);
this.thumbnail.name = this.thumbnail.name;
this.thumbnail.setName(this.thumbnail.getName());
this.thumbnail = getThumbnailData(this.thumbnail);
} else
this.thumbnail = null;
Expand All @@ -146,25 +149,25 @@ private void obtainImagesInfo(JSONObject productJSON) {

// サムネイル格納
private SpreeImageData getThumbnailData(SpreeImageData image) {
String path = "spree/products/" + image.id + "/small/" + image.name;
String path = "spree/products/" + image.getId() + "/small/" + image.getName();

InputStream is = Warehouse.Spree().connector.getStream(path);
if (is != null) {
Drawable imageData = Drawable.createFromStream(is, image.name);
image.data = imageData;
Drawable imageData = Drawable.createFromStream(is, image.getName());
image.setData(imageData);
}

return image;
}

// イメージ画像パス格納
private SpreeImageData getImageData(SpreeImageData image) {
String path = "spree/products/" + image.id + "/product/" + image.name;
String path = "spree/products/" + image.getId() + "/product/" + image.getName();

InputStream is = Warehouse.Spree().connector.getStream(path);
if (is != null) {
Drawable imageData = Drawable.createFromStream(is, image.name);
image.data = imageData;
Drawable imageData = Drawable.createFromStream(is, image.getName());
image.setData (imageData);
}

return image;
Expand Down Expand Up @@ -238,28 +241,28 @@ private void processVariantJSON(JSONObject v) {
try {
weight = v.getDouble("weight");
} catch (JSONException e) {
weight = this.variant().getWeight();
//weight = this.variant().getWeight();
}

double height = 0.0;
try {
height = v.getDouble("height");
} catch (JSONException e) {
height = this.variant().getHeight();
//height = this.variant().getHeight();
}

double width = 0.0;
try {
width = v.getDouble("width");
} catch (JSONException e) {
width = this.variant().getWidth();
//width = this.variant().getWidth();
}

double depth = 0.0;
try {
depth = v.getDouble("depth");
} catch (JSONException e) {
depth = this.variant().getDepth();
//depth = this.variant().getDepth();
}

double costPrice = 0.0;
Expand All @@ -275,6 +278,7 @@ private void processVariantJSON(JSONObject v) {
} catch (JSONException e) {

}

addVariant(id, name, countOnHand,
visualCode, sku, price,
weight, height, width, depth,
Expand All @@ -292,7 +296,6 @@ private void obtainVariants(JSONObject productJSON) {
e.printStackTrace();
}


//Log.d("VARIANTS", "Length: " + variantArray.length());

// get master first
Expand All @@ -308,11 +311,11 @@ private void obtainVariants(JSONObject productJSON) {

boolean isMaster = false;
try {
v = v.getJSONObject("variant");
isMaster = v.getBoolean("is_master");
} catch (JSONException e) {
isMaster = false;
}

if (isMaster) {
processVariantJSON(v);
break;
Expand Down

0 comments on commit 0d8d866

Please sign in to comment.