Example #1
0
  private void showTruckDetails(String s) throws ParseException {
    final Truck selectedTruck = DBOps.getTruckByRegNo(this, s);
    String details =
        "Truck Code : "
            + selectedTruck.getCode()
            + "\n"
            + "Tare Weight : "
            + selectedTruck.getTare_wt()
            + "\n"
            + "Group : "
            + selectedTruck.getGroup_code()
            + "\n"
            + "Capacity : "
            + selectedTruck.getCapacity()
            + "\n"
            + "Registration Date : "
            + Util.getFormatedDate(selectedTruck.getReg_date());
    detailsTextView.setText(details);
    detailsTextView.setVisibility(View.VISIBLE);
    writeTagButton.setVisibility(View.VISIBLE);
    writeTagButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            try {
              startWriteProcedure(selectedTruck);
            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }
Example #2
0
 public void getRegistrationNumbers() {
   allRegistrationNumbers = DBOps.getAllTruckRegNo(this);
 }
Example #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_issue_truck_tag);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //
    libInstance = NxpNfcLibLite.getInstance();
    // intent filter directly picked from manifest
    libInstance.registerActivity(this);
    //        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    //            // Registering the activity for the NFC tag detection mode.
    //
    //            final Handler mLibhandler = new Handler(mLibhandlercb);
    //
    //            try {
    //                libInstance.setNfcControllerMode(1000, new NfcAdapter.ReaderCallback() {
    //
    //                    @Override
    //                    public void onTagDiscovered(final Tag tagObject) {
    //                        NxpLogUtils.d(TAG,
    //                                "TAG is Discovered from ReaderCallBack...");
    //
    //                        tag = tagObject;
    //                        mLibhandler.sendEmptyMessage(0);
    //
    //                    }
    //                }, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_V |
    // NfcAdapter.FLAG_READER_NFC_B | NfcAdapter.FLAG_READER_NFC_F );
    //            } catch (SmartCardException e) {
    //
    //            }
    //        }
    //
    if (DBOps.getAllTruckRegNo(this).size() == 0) {
      DBOps.insertNewTruck(
          this,
          new Truck(
              "TC1",
              "GA04J4008",
              "TCC1",
              "DC1",
              "GC1",
              "CARDID1000",
              "CAT1",
              new Date(),
              7000,
              3000));
      DBOps.insertNewTruck(
          this,
          new Truck(
              "TC2",
              "GA09J4567",
              "TCC2",
              "DC2",
              "GC2",
              "CARDID2001",
              "CAT2",
              new Date(),
              7000,
              4000));
      DBOps.insertNewTruck(
          this,
          new Truck(
              "TC3",
              "GA04J4444",
              "TCC3",
              "DC3",
              "GC3",
              "CARDID3002",
              "CAT3",
              new Date(),
              7000,
              5000));
    }
    initializeViews();
    getRegistrationNumbers();
    bindDataToAutoCompleteTextView();
  }