<commit_before>package liulx.data_center.ui;

import java.io.UnsupportedEncodingException;

import liulx.data_center.R;
import liulx.data_center.R.id;
import liulx.data_center.R.layout;
import liulx.data_center.R.menu;
import liulx.data_center.config.Config;
import liulx.data_center.net.RestClient;
import liulx.util.UIHelper;

import org.apache.http.Header;
import org.apache.http.entity.StringEntity;
import org.json.JSONException;
import org.json.JSONObject;

import com.loopj.android.http.JsonHttpResponseHandler;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class DataCenterActivity extends Activity implements OnClickListener {
	private final static int SCANNIN_ITEM_CODE = 1;
	private final static int SCANNIN_INV_CODE = 2;

	private Button btnScanItem, btnScanInv, btnSend;
	private EditText edtItemCode, edtInvCode;
	private String inv_type_url;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_data_center);
		
		switch(getIntent().getIntExtra(Config.INV_TYPE, 0)){
		case 0:
			inv_type_url = Config.INV_IN;
			break;
		case 1:
			inv_type_url = Config.INV_OUT;
			break;
		}
		
		btnScanItem = (Button) findViewById(R.id.btnScanItem);
		btnScanInv = (Button) findViewById(R.id.btnScanInv);
		btnSend = (Button) findViewById(R.id.btnSend);
		
		edtItemCode = (EditText) findViewById(R.id.edtItemCode);
		edtInvCode = (EditText) findViewById(R.id.edtInvCode);
		
		
		btnScanItem.setOnClickListener(this);
		btnScanInv.setOnClickListener(this);
		btnSend.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.btnScanInv:
			btnScanInv_onClick();
			break;
		case R.id.btnScanItem:
			btnScanItem_onClick();
			break;
		case R.id.btnSend:
			btnSend_onClick();
			break;
		default:
				break;
		}
	}
	
	//ɨλ
	private void btnScanInv_onClick(){
		Intent intent = new Intent();
		intent.setClass(this, MipcaActivityCapture.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivityForResult(intent, SCANNIN_INV_CODE);
	}
	
	//ɨ
	private void btnScanItem_onClick(){
		Intent intent = new Intent();
		intent.setClass(this, MipcaActivityCapture.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivityForResult(intent, SCANNIN_ITEM_CODE);
	}
	
	//
	private void btnSend_onClick(){
		System.out.println("Ͱť");
		JSONObject jsonParams = new JSONObject();
		try {
			jsonParams.put("item_code", edtItemCode.getText().toString());
			jsonParams.put("inventory_code", edtInvCode.getText().toString());
			System.out.println(jsonParams.toString());
			StringEntity entity = new StringEntity(jsonParams.toString());
			RestClient.postJson(this, inv_type_url, entity, new JsonHttpResponseHandler(){
				@Override
				public void onSuccess(int statusCode, Header[] headers,<commit_msg>货位物料为空时不能出入库<commit_after>package liulx.data_center.ui;

import java.io.UnsupportedEncodingException;

import liulx.data_center.R;
import liulx.data_center.R.id;
import liulx.data_center.R.layout;
import liulx.data_center.R.menu;
import liulx.data_center.config.Config;
import liulx.data_center.net.RestClient;
import liulx.util.UIHelper;

import org.apache.http.Header;
import org.apache.http.entity.StringEntity;
import org.json.JSONException;
import org.json.JSONObject;

import com.loopj.android.http.JsonHttpResponseHandler;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class DataCenterActivity extends Activity implements OnClickListener {
	private final static int SCANNIN_ITEM_CODE = 1;
	private final static int SCANNIN_INV_CODE = 2;

	private Button btnScanItem, btnScanInv, btnSend;
	private EditText edtItemCode, edtInvCode;
	private String inv_type_url;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_data_center);
		
		switch(getIntent().getIntExtra(Config.INV_TYPE, 0)){
		case 0:
			inv_type_url = Config.INV_IN;
			break;
		case 1:
			inv_type_url = Config.INV_OUT;
			break;
		}
		
		btnScanItem = (Button) findViewById(R.id.btnScanItem);
		btnScanInv = (Button) findViewById(R.id.btnScanInv);
		btnSend = (Button) findViewById(R.id.btnSend);
		
		edtItemCode = (EditText) findViewById(R.id.edtItemCode);
		edtInvCode = (EditText) findViewById(R.id.edtInvCode);
		
		
		btnScanItem.setOnClickListener(this);
		btnScanInv.setOnClickListener(this);
		btnSend.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.btnScanInv:
			btnScanInv_onClick();
			break;
		case R.id.btnScanItem:
			btnScanItem_onClick();
			break;
		case R.id.btnSend:
			btnSend_onClick();
			break;
		default:
				break;
		}
	}
	
	//ɨλ
	private void btnScanInv_onClick(){
		Intent intent = new Intent();
		intent.setClass(this, MipcaActivityCapture.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivityForResult(intent, SCANNIN_INV_CODE);
	}
	
	//ɨ
	private void btnScanItem_onClick(){
		Intent intent = new Intent();
		intent.setClass(this, MipcaActivityCapture.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivityForResult(intent, SCANNIN_ITEM_CODE);
	}
	
	//
	private void btnSend_onClick(){
		System.out.println("Ͱť");
		if(TextUtils.isEmpty(edtItemCode.getText()) || TextUtils.isEmpty(edtInvCode.getText())){
			UIHelper.ToastMessage(this, "ͻλ벻Ϊ");
			return;
		}
		JSONObject jsonParams = new JSONObject();
		try {
			jsonParams.put("item_code", edtItemCode.getText().toString());
			jsonParams.put("inventory_code", edtInvCode.getText().toString());
			System.out.println(jsonParams.toString());
			StringEntity entity = new StringEntity(jsonParams.toString());
			RestClient.postJson(this, inv_type_url, entity, new JsonHttpResponseHandler(){
				@Override
				public void onSuccess(int statusCode, Header[] headers,
{'fraction_non_alphanumeric': 0.10752829692024217, 'fraction_numerical': 0.0013161358252171624, 'mean_word_length': 4.969363707776905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '818866', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2479, 'n_words': 520}