예제 #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    cd = new ConnectionDetector(getApplicationContext());

    Intent intent;
    switch (item.getItemId()) {
      case R.id.homelbl:
        if (!cd.isConnectingToInternet()) {

          alert.showAlertDialog(
              ListClinic.this,
              "Internet Connection Error",
              "Please connect to working Internet connection",
              false);

          return true;
        }

        finish();
        break;

      case R.id.mio_logout:
        intent = new Intent(this, LoginActivity.class);
        this.finish();
        Intent exit0 = new Intent(Intent.ACTION_MAIN);
        exit0.addCategory(Intent.CATEGORY_HOME);
        exit0.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        exit0.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        break;

      default:
        break;
    }

    return true;
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.clinic_activity);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle("Clinic List");

    cd = new ConnectionDetector(getApplicationContext());

    if (!cd.isConnectingToInternet()) {

      alert.showAlertDialog(
          ListClinic.this,
          "Internet Connection Error",
          "Please connect to working Internet connection",
          false);

      return;
    }

    Intent in = getIntent();
    MIO_ID = in.getLongExtra("MIO_ID", 0);

    clinictList = new ArrayList<Map<String, String>>();

    task = (LoadClinic) getLastNonConfigurationInstance();
    if (task == null) {
      task = new LoadClinic(this);
      task.execute();

    } else {
      task.attach(this);
      CreateList(task.getJSON());
    }
    // get listview
    ListView lv = getListView();

    lv.setOnItemClickListener(
        new android.widget.AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View view, int arg2, long arg3) {

            TextView clinic_id = ((TextView) view.findViewById(R.id.clinicid));

            TextView clinic_name = ((TextView) view.findViewById(R.id.clinicname));
            TextView clinic_address = ((TextView) view.findViewById(R.id.clinicaddress));
            TextView clinic_target = ((TextView) view.findViewById(R.id.clinic_target_value));
            TextView clinic_market = ((TextView) view.findViewById(R.id.clinicmarket));

            TextView clinic_contact = ((TextView) view.findViewById(R.id.cliniccntnumlbl));

            String vDetails = "Id \t\t\t\t\t: " + clinic_id.getText().toString() + "\n";
            vDetails += "Name \t\t\t: " + clinic_name.getText().toString() + "\n";
            vDetails += "Address \t:  " + clinic_address.getText().toString() + "\n";
            vDetails += "Target \t\t:  " + clinic_target.getText().toString() + "\n";
            vDetails += "Market \t\t: " + clinic_market.getText().toString() + "\n";

            vDetails += "Contact \t:  " + clinic_contact.getText().toString() + "\n";

            alert.showAlertDialog(ListClinic.this, "Clinic Profile", vDetails, true);
          }
        });
  }