package com.refresh.pos.ui;

import com.refresh.pos.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class SaleActivity extends Activity  {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sale);
		
		final TextView totalPrice = (TextView) findViewById(R.id.total);
		totalPrice.setEnabled(false);
		
		final Button addButton = (Button) findViewById(R.id.addSaleItem);
		addButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				showAddDialog();
				
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
		
	}
	public void showAddDialog(){
		final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
		final LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);

		final View Viewlayout = inflater.inflate(R.layout.dialog_additemsale,
		(ViewGroup) findViewById(R.id.dialog_addItem));
		
//		popDialog.setIcon(android.R.drawable.btn_star_big_on);
		popDialog.setTitle("Add Item");
		popDialog.setView(Viewlayout);
		
		
		popDialog.create();
		popDialog.show();
	}

}

@@ -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
@@ -230,16 +230,74 @@
 Dialog;%0A
+import android.app.Dialog;%0Aimport android.content.Intent;%0A
 import a
@@ -314,16 +314,41 @@
 Bundle;%0A
+import android.util.Log;%0A
 import a
@@ -551,16 +551,45 @@
 extView;
+%0Aimport android.widget.Toast;
 %0A%0Apublic
@@ -629,16 +629,717 @@
 ity  %7B%0A%0A
+%09private EditText itemBarcode;%0A%09public void onActivityResult(int requestCode, int resultCode, Intent intent) %7B%0A%09%09Log.d(%22BARCODE%22, %22BARCODE 'onActivityResult' Successfully.%22);%0A%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%09// String scanFormat = scanningResult.getFormatName();%0A%09%09%09// Toast.makeText(AddActivity.this,%22got %3E%3E %22 + scanContent ,%0A%09%09%09// Toast.LENGTH_SHORT).show();%0A%09%09%09itemBarcode.setText(scanContent);%0A%09%09%7D else %7B%0A%09%09%09Toast.makeText(SaleActivity.this,%0A%09%09%09%09%09%22Failed to retrieve barcode.%22 + resultCode,%0A%09%09%09%09%09Toast.LENGTH_SHORT).show();%0A%09%09%7D%0A%09%7D%0A
 %09@Overri
@@ -1964,24 +1964,27 @@
 alog()%7B%0A
+%09%09%0A
 %09%09final 
 AlertDia
@@ -1979,32 +1979,16 @@
 nal 
-Alert
 Dialog
-.Builder popD
+ d
 ialo
@@ -1999,27 +1999,14 @@
 new 
-Alert
 Dialog
-.Builder
 (thi
@@ -2015,391 +2015,484 @@
 ;%0A%09%09
-final LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE
+dialog.setContentView(R.layout.dialog_additemsale
 );%0A
+%09%09
 %0A%09%09
-final View Viewlayout = inflater.inflate(R.layout.dialog_additemsale,%0A%09%09(ViewGroup) findViewById(R.id.dialog_addItem));%0A%09%09%0A//%09%09popDialog.setIcon(android.R.drawable.btn_star_big_on);%0A%09%09popDialog.setTitle(%22Add Item%22);%0A%09%09popDialog.setView(Viewlayout);
+dialog.setTitle(%22Add Item%22);%0A%0A%09%09%0A%09%09itemBarcode = (EditText) dialog.findViewById(R.id.barcodeTxt);%0A%09%09final Button scanButton = (Button) dialog.findViewById(R.id.scanButton);%0A%09%09scanButton.setOnClickListener(new View.OnClickListener() %7B%0A%0A%09%09%09@Override%0A%09%09%09public void onClick(View v) %7B%0A%09%09%09%09IntentIntegrator scanIntegrator = new IntentIntegrator(
 %0A%09%09
-%0A
 %09%09
-%0A
 %09%09
-popDialog.create();%0A%09%09popD
+SaleActivity.this);%0A%09%09%09%09scanIntegrator.initiateScan();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09d
 ialo

fix Sale