Esempio n. 1
0
 public void filter(String charText) {
   charText = charText.toLowerCase(Locale.getDefault());
   arrData.clear();
   if (charText.length() == 0) {
     arrData.addAll(newArr);
     adapter.notifyDataSetChanged();
   } else {
     for (AnimalCategoryMasterDTO contacts : newArr) {
       if (contacts.getAnimalCategory().toLowerCase(Locale.getDefault()).contains(charText)) {
         arrData.add(contacts);
         adapter.notifyDataSetChanged();
       }
     }
   }
 }
Esempio n. 2
0
  @SuppressLint("SimpleDateFormat")
  @Override
  public void onClick(View v) {
    Intent intent;
    switch (v.getId()) {
      case R.id.img_view_push_messages:
        if (InternetUtils.getInstance().isConnectingToInternet(HomeActivity.this)) {
          intent = new Intent(HomeActivity.this, ViewMessageActivity.class);

          startActivity(intent);
        } else {
          Toast.makeText(HomeActivity.this, "no net work", Toast.LENGTH_LONG).show();
        }

        break;

      case R.id.img_new_push_message:
        intent = new Intent(HomeActivity.this, UpdateAnimalActivity.class);

        startActivity(intent);
        break;
      case R.id.contact_us:
        intent = new Intent(HomeActivity.this, ContactUsActivity.class);
        startActivity(intent);
        break;
      case R.id.update:
        TokenModel tokenModel = TokenModel.getInstance();
        TokenDTO tokenDTO = tokenModel.getToken(HomeActivity.this);
        String dateExpires = tokenDTO.getExpires();
        Date date2 = null;
        Date date1 = null;
        String pattern = "EEE, dd MMM yyyy HH:mm:ss Z";
        SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.ENGLISH);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDay = sdf.format(new Date());
        String currentDayExpires = format.format(new Date());
        try {
          date1 = format.parse(currentDayExpires);
          date2 = format.parse(dateExpires);
          if (date1.compareTo(date2) < 0) {
            if (InternetUtils.getInstance().isConnectingToInternet(this)) {
              this.runOnUiThread(
                  new Runnable() {

                    @Override
                    public void run() {
                      String path = Constants.URL_CATEGORY;
                      String[] strs = path.split("/");
                      File file =
                          new File(
                              Environment.getExternalStorageDirectory()
                                  + "/"
                                  + Constants.APP_NAME
                                  + "/"
                                  + strs[4]
                                  + "/");
                      // deleteDirectory(file);
                      DeleteRecursive(file);
                      adapter.notifyDataSetChanged();
                      grid.invalidateViews();
                    }
                  });
              new AsystaskUpdateAnimal(currentDay, tokenDTO, HomeActivity.this).execute();
              flag = true;
              // arrData = new ArrayList<Object>();
              // InitData();
              // adapter = new AnimalCategoryMasterAdapter(this,
              // R.layout.grid_row,
              // arrData);
              adapter.notifyDataSetChanged();
            } else {
              Toast.makeText(HomeActivity.this, "no network", Toast.LENGTH_LONG).show();
            }
          }
        } catch (Exception e) {
          // TODO: handle exception
        }

        break;
      default:
        break;
    }
  }