private void initView() {
    mEtDeviceName = (MaterialEditText) findViewById(R.id.etDeviceName);
    mEtDeviceDesc = (MaterialEditText) findViewById(R.id.etDeviceDescription);
    mEtAndroidVersion = (MaterialEditText) findViewById(R.id.etAndroidVersion);
    mLinDeviceName = (LinearLayout) findViewById(R.id.linDeviceName);
    mLinDeviceDesc = (LinearLayout) findViewById(R.id.linDeviceDescription);
    mLinAndroidVersion = (LinearLayout) findViewById(R.id.linAndroidVersion);

    mEtAndroidVersion.setOnClickListener(this);

    mEtDeviceName.addTextChangedListener(new CustomInputValidator(mEtDeviceName));
    mEtDeviceName.setOnFocusChangeListener(AddDeviceActivity.this);

    mEtDeviceDesc.setFilters(new InputFilter[] {new InputFilter.LengthFilter(256)});
    mEtDeviceDesc.addTextChangedListener(new CustomInputValidator(mEtDeviceDesc));
    mEtDeviceDesc.setOnFocusChangeListener(AddDeviceActivity.this);

    mDbHelper = DBHelper.getInstance(ShowCaseApp.getAppContext());
  }
 private void setOnEventTypeClickListener() {
   MaterialEditText typeEditText = ((MaterialEditText) rootView.findViewById(R.id.event_type));
   typeEditText.setOnClickListener(showEventTypeDialog());
 }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addpolicy);
    db = new DBAdapter(NewPolicies.this);
    final Calendar c = Calendar.getInstance();
    year = c.get(Calendar.YEAR);
    month = c.get(Calendar.MONTH);
    day = c.get(Calendar.DAY_OF_MONTH);

    temppolID = getIntent().getIntExtra("polID", 1);
    tempclientName = getIntent().getStringExtra("clientName");
    tempagentName = getIntent().getStringExtra("agentName");
    tempcmpName = getIntent().getStringExtra("cmpName");
    temppolNo = getIntent().getStringExtra("polNo");

    temppolType = getIntent().getStringExtra("polType");
    temppolDetails = getIntent().getStringExtra("polDetails");
    tempefftDate = getIntent().getStringExtra("efftDate");
    tempexpDate = getIntent().getStringExtra("expDate");
    temptermLength = getIntent().getStringExtra("termLength");

    tempinsSummary = getIntent().getStringExtra("insSummary");
    temppremium = getIntent().getStringExtra("premium");
    tempdownPayment = getIntent().getStringExtra("downPayment");
    tempsalesCommision = getIntent().getStringExtra("salesCommision");
    tempdeductible = getIntent().getStringExtra("deductible");
    temppayMethod = getIntent().getStringExtra("payMethod");

    temppayFreq = getIntent().getStringExtra("payFreq");
    tempstatus = getIntent().getStringExtra("status");
    tempcharge = getIntent().getStringExtra("charge");
    tempcredit = getIntent().getStringExtra("credit");
    tempbalance = getIntent().getStringExtra("balance");

    init();

    policyType = new ArrayList<>();
    policyType.add("Vehicle (auto)");
    policyType.add("Property");
    policyType.add("Home");
    policyType.add("Health");
    policyType.add("Dental");
    policyType.add("Life");
    policyType.add("International (Travel)");
    policyType.add("Other");
    ArrayAdapter<String> clientAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, android.R.id.text1, policyType);
    spPType.setAdapter(clientAdapter);
    spPType.setSelection(getSimpleIndex(spPType, temppolType));

    paymentMethod = new ArrayList<>();
    paymentMethod.add("Cash/Check");
    paymentMethod.add("Debit Card/Credit Card");
    paymentMethod.add("Direct Debit/Standing Order");
    paymentMethod.add("In-House Payroll");
    paymentMethod.add("Other");
    ArrayAdapter<String> payMethodAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, android.R.id.text1, paymentMethod);
    spPayM.setAdapter(payMethodAdapter);
    spPayM.setSelection(getSimpleIndex(spPayM, temppayMethod));

    paymentFreq = new ArrayList<>();
    paymentFreq.add("01-Unique/Yearly");
    paymentFreq.add("12-Monthly");
    paymentFreq.add("06-Three-Monthly/Quarterly");
    paymentFreq.add("02-Semi-Annually/Bi-Annually");
    paymentFreq.add("24-Semi-Monthly");
    ArrayAdapter<String> payFreqAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, android.R.id.text1, paymentFreq);
    spPayFrq.setAdapter(payFreqAdapter);
    spPayFrq.setSelection(getSimpleIndex(spPayFrq, temppayFreq));

    status = new ArrayList<>();
    status.add("Active");
    status.add("Inactive");
    status.add("Canceled");
    ArrayAdapter<String> statusAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, android.R.id.text1, status);
    spStatus.setAdapter(statusAdapter);
    spStatus.setSelection(getSimpleIndex(spStatus, tempstatus));

    if (temppolNo == null || temppolNo.toString().trim().length() == 0) {
      spPType.setSelection(0);
    } else {
      edPolicyNumber.setText(temppolNo + " :: Edit");
      edProductD.setText(temppolDetails);
      edDate.setText(tempefftDate);
      expDate.setText(tempexpDate);
      edInsSumm.setText(tempinsSummary);
      edPrem.setText(temppremium);
      edDownP.setText(tempdownPayment);
      edSales.setText(tempsalesCommision);
      edTerm.setText(temptermLength);
      edDeduct.setText(tempdeductible);
      edCharge.setText(tempcharge);
      edCredit.setText(tempcredit);
      edBal.setText(tempbalance);
    }

    spPType.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i) {
              case 0:
                edProductD.setText(
                    "Vehicle Type:\nMake/Model:\nMarket Price:\nPrimary use:\nYear:\nMileage:\nTransmission:\nColor:");
                break;
              case 1:
                edProductD.setText(
                    "Construction Type:\nMarket Price:\nYear Built:\nLocation:\nConstruction Materials:\n# of Units:\n# of Stories:\nOccupancy:");
                break;
              case 2:
                edProductD.setText(
                    "Construction Type:\nMarket Price:\nYear Built:\nLocation:\nConstruction Materials:\n# of Units:\n# of Stories:\nOccupancy:");
                break;
              case 3:
                edProductD.setText(
                    "SSN:\nCoverage Desired:Single / Family\nMember coverage:\nBeneficiaries:\nPersonal Info:\nMedical Info:");
                break;
              case 4:
                edProductD.setText(
                    "SSN:\nCoverage Desired:Single / Family\nMember coverage:\nBeneficiaries:\nPersonal Info:\nMedical Info:");
                break;
              case 5:
                edProductD.setText(
                    "SSN:\nCoverage Desired:Single / Family\nMember coverage:\nBeneficiaries:\nPersonal Info:\nMedical Info:");
                break;
              case 6:
                edProductD.setText("");
                break;
              case 7:
                edProductD.setText("");
                break;
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });

    edDate.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            showDialog(DATE_PICKER_ID1);
          }
        });

    expDate.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            showDialog(DATE_PICKER_ID2);
          }
        });
    /* edDate.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int DRAWABLE_LEFT = 0;
            final int DRAWABLE_TOP = 1;
            final int DRAWABLE_RIGHT = 2;
            final int DRAWABLE_BOTTOM = 3;

            if (event.getAction() == MotionEvent.ACTION_UP) {
                if (event.getRawX() >= (edDate.getRight() - edDate.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                    showDialog(DATE_PICKER_ID1);
                    return true;
                }
            }
            return false;
        }
    });*/

    /*expDate.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int DRAWABLE_LEFT = 0;
            final int DRAWABLE_TOP = 1;
            final int DRAWABLE_RIGHT = 2;
            final int DRAWABLE_BOTTOM = 3;

            if (event.getAction() == MotionEvent.ACTION_UP) {
                if (event.getRawX() >= (expDate.getRight() - expDate.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                    showDialog(DATE_PICKER_ID2);
                    return true;
                }
            }
            return false;
        }
    });*/

    imgSave.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            checkValidation();
          }
        });
  }