Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="com.example.batuhan.qrcodereader.ActivityUserProfile"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
- android:paddingTop="16dp"
- android:paddingBottom="16dp">
- </Relativelayout>
- public class ActivityUserProfile extends AppCompatActivity {
- private ZXingScannerView scannerView;
- public static final String LOGIN_URL = "http://www.HHH.com/QR_Users_Select.php";
- public static final String KEY_USERNAME = "username";
- public static final String KEY_PASSWORD = "password";
- private TextView txt_ViewUsername;
- public static EditText edt_Productname;
- public static EditText edt_Productcode;
- public static EditText edt_Productweight;
- public static EditText edt_Productprice;
- private Button btn_addToCart;
- private Button btn_Scan;
- private Button btn_seeProd;
- String resultCode;
- public String prodName;
- public String prodCode;
- public String prodWeight;
- public String prodPrice;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_user_profile);
- txt_ViewUsername = (TextView) findViewById(R.id.txt_ViewUsername);
- edt_Productname = (EditText) findViewById(R.id.edt_ProdName);
- edt_Productcode = (EditText) findViewById(R.id.edt_ProdCode);
- edt_Productweight= (EditText) findViewById(R.id.edt_ProdWeight);
- edt_Productprice = (EditText) findViewById(R.id.edt_ProdPrice);
- edt_Productcode.setEnabled(true);
- edt_Productname.setEnabled(true);
- edt_Productweight.setEnabled(true);
- edt_Productprice.setEnabled(true);
- Intent i = getIntent();
- txt_ViewUsername.setText("Sayın "+ i.getStringExtra(ActivityUserProfile.KEY_USERNAME) +" marketimize hoşgeldiniz.");
- btn_Scan = (Button) findViewById(R.id.btn_scan);
- btn_Scan.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- scanCode();
- }
- });
- btn_seeProd = (Button) findViewById(R.id.btn_seeProd);
- btn_seeProd.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplicationContext(),ProductView.class);
- startActivity(intent);
- }
- });
- btn_addToCart = (Button) findViewById(R.id.btn_addToCart);
- btn_addToCart.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- ...
- }
- });
- }
- public void scanCode()
- {
- scannerView = new ZXingScannerView(this);
- scannerView.setResultHandler(new ZXingScannerResultHandler());
- setContentView(scannerView);
- scannerView.startCamera();
- }
- @Override
- public void onPause(){
- super.onPause();
- if (scannerView != null) {
- scannerView.stopCamera();
- scannerView = null;
- }
- }
- public class ZXingScannerResultHandler implements ZXingScannerView.ResultHandler
- {
- @Override
- public void handleResult(Result result){
- try{
- resultCode = result.getText();
- Log.i("Bilgi","ResultCode -> "+resultCode );
- setContentView(R.layout.activity_user_profile);
- scannerView.removeAllViews();
- scannerView.stopCamera();
- String [] chars = resultCode.split(":");
- Log.i("counter",chars.length+"");
- Log.i("company",chars[1]);
- prodName = chars[1];
- prodCode = chars[3];
- prodWeight =chars[5];
- prodPrice = chars[7];
- EditText product_name_text = (EditText) findViewById(R.id.edt_ProdName);
- EditText product_code_text = (EditText) findViewById(R.id.edt_ProdCode);
- EditText product_weight_text= (EditText) findViewById(R.id.edt_ProdWeight);
- EditText product_price_text = (EditText) findViewById(R.id.edt_ProdPrice);
- product_name_text.setText(prodName);
- product_code_text.setText(prodCode);
- product_weight_text.setText(String.valueOf(prodWeight));
- product_price_text.setText(String.valueOf(prodPrice));
- } catch (NullPointerException nu) {
- Toast.makeText(ActivityUserProfile.this,"Gelen data düzenli değil!",Toast.LENGTH_LONG).show();
- } catch (Exception ex){
- Toast.makeText(ActivityUserProfile.this,"Okuyucuda problem oluştu!",Toast.LENGTH_LONG).show();
- Log.e("errors",ex.getMessage());
- }
- }
- }
Add Comment
Please, Sign In to add comment