Ejemplo n.º 1
0
  // display lisview
  public void displayLisview() {
    // set adapter
    task = new Task(context);
    arrTask = new ArrayList<Task>();
    arrTask =
        task.getData(
            context,
            context.getString(R.string.api_get_task),
            new Task.OnLoadListener() {

              @Override
              public void onStart() {
                loading.setVisibility(View.VISIBLE);
                connectError.setVisibility(View.GONE);
              }

              @Override
              public void onSuccess() {
                loading.setVisibility(View.GONE);
                adapter.notifyDataSetChanged();
                if (adapter.getCount() <= 0) {
                  listTask.setEmptyView(emptyView);
                }
              }

              @Override
              public void onFalse() {
                loading.setVisibility(View.GONE);
                connectError.setVisibility(View.VISIBLE);
              }
            });
    adapter = new TaskAdapter(context, arrTask, 3);
    listTask.setAdapter(adapter);
  }
Ejemplo n.º 2
0
  @Override
  public void onClick(View v) {
    int id = v.getId();
    switch (id) {
      case R.id.back:
        finish();
        break;
      case R.id.search:
        showSearchView();
        break;
      case R.id.close:
        closeSearchView();
        break;
      case R.id.empty:
        editSearch.setText("");
        break;
      case R.id.btnAssignNew:
        Intent intent = new Intent(OtherTaskActivity.this, AssignTaskActivity.class);
        startActivity(intent);
        break;
      case R.id.retry:
        adapter.setData(
            task.getData(
                OtherTaskActivity.this,
                getResources().getString(R.string.api_get_task),
                new Task.OnLoadListener() {

                  @Override
                  public void onStart() {
                    loading.setVisibility(View.VISIBLE);
                    connectError.setVisibility(View.GONE);
                  }

                  @Override
                  public void onSuccess() {
                    loading.setVisibility(View.GONE);
                    adapter.notifyDataSetChanged();
                    if (adapter.getCount() <= 0) {
                      listTask.setEmptyView(emptyView);
                    }
                  }

                  @Override
                  public void onFalse() {
                    loading.setVisibility(View.GONE);
                    connectError.setVisibility(View.VISIBLE);
                  }
                }));
        break;
    }
  }