package com.refresh.pos.ui;

import com.refresh.pos.R;
import com.refresh.pos.core.ProductCatalogController;
import com.refresh.pos.database.ProductDao;
import com.refresh.pos.database.ProductDaoAndroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class StockAddActivity extends Activity{
	private EditText itemBarcode;
	private EditText itemName;
	private ProductCatalogController productCatalogController;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_stockadd);

		ProductDao productDao = new ProductDaoAndroid(this);
		productCatalogController = new ProductCatalogController(productDao);
	}
	
}

@@ -22,16 +22,136 @@
 os.ui;%0A%0A
+import com.google.zxing.integration.android.IntentIntegrator;%0Aimport com.google.zxing.integration.android.IntentResult;%0A
 import c
@@ -366,17 +366,129 @@
 oid.
-os.Bundle
+content.Intent;%0Aimport android.os.Bundle;%0Aimport android.util.Log;%0Aimport android.view.View;%0Aimport android.widget.Button
 ;%0Aim
@@ -516,16 +516,45 @@
 ditText;
+%0Aimport android.widget.Toast;
 %0A%0Apublic
@@ -719,280 +719,1698 @@
 r;%0A%09
-@Override%0A%09protected void onCreate(Bundle savedInstanceState) %7B%0A%09%09super.onCreate(savedInstanceState);%0A%09%09setContentView(R.layout.activity_stockadd);%0A%0A%09%09ProductDao productDao = new ProductDaoAndroid(this);%0A%09%09productCatalogController = new ProductCatalogController(productDao
+%0A%09public void onActivityResult(int requestCode, int resultCode, Intent intent) %7B%0A//%09%09Log.d(%22BARCODE%22, %22BARCODE 'onActivityResult' Successfully.%22);%0A%09%09%0A%09%09IntentResult scanningResult = IntentIntegrator.parseActivityResult(%0A%09%09%09%09requestCode, resultCode, intent);%0A//%0A%09%09if (scanningResult != null) %7B%0A%09%09%09String scanContent = scanningResult.getContents();%0A%09%09%09String scanFormat = scanningResult.getFormatName();%0A//%09%09%09Toast.makeText(AddActivity.this,%22got %3E%3E %22 + scanContent , Toast.LENGTH_SHORT).show();%0A%09%09%09itemBarcode.setText(scanContent);%0A%09%09%09%0A//%0A%09%09%7D else %7B%0A%09%09%09Toast.makeText(StockAddActivity.this,%0A%09%09%09%09%09%22Failed to retrieve barcode.%22 + resultCode, Toast.LENGTH_SHORT)%0A%09%09%09%09%09.show();%0A%09%09%7D%0A%09%7D%0A%09%0A%09@Override%0A%09protected void onCreate(Bundle savedInstanceState) %7B%0A%09%09super.onCreate(savedInstanceState);%0A%09%09setContentView(R.layout.activity_stockadd);%0A%0A%09%09ProductDao productDao = new ProductDaoAndroid(this);%0A%09%09productCatalogController = new ProductCatalogController(productDao);%0A%09%09%0A%0A%09%09itemName = (EditText) findViewById(R.id.nameTxt);%0A%09%09itemBarcode = (EditText) findViewById(R.id.barcodeTxt);%0A%09%09itemBarcode.setEnabled(false);%0A%09%09itemName.setEnabled(false);%0A%09%09%0A%09%09final Button scanButton = (Button) findViewById(R.id.scanButton);%0A%09%09scanButton.setOnClickListener(new View.OnClickListener() %7B%0A%09%09%09@Override%0A%09%09%09public void onClick(View v) %7B%0A//%09%09%09%09IntentIntegrator scanIntegrator = new IntentIntegrator(StockAddActivity.this);%0A//%09%09%09%09scanIntegrator.initiateScan();%0A%09%09%09%09Object get = productCatalogController.getProductNamebyBarcode(%228851959139707%22);%0A%09%09%09%09if(get == null)%7B%0A%09%09%09%09%09Log.v(%22%3E%3E%3E%22,%22null%22);%0A%09%09%09%09%7D%0A%09%09%09%09else%7B%0A%09%09%09%09%09String%5B%5D a = (String%5B%5D) get;%0A%09%09%09%09%09itemBarcode.setText(a%5B0%5D);%0A%09%09%09%09%09itemName.setText(a%5B1%5D);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D
 );%0A%09

Add function in AddStockActivity