Exemplo n.º 1
0
  /**
   * Adding new task
   *
   * @param view
   */
  @SuppressLint("SimpleDateFormat")
  public void onClick(View view) {

    switch (view.getId()) {
      case R.id.button_add:
        Task task = new Task();
        EditText text = (EditText) findViewById(R.id.edit_text_task);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
        task.setText(text.getText().toString());
        task.setCreatedDate(sdf.format(new Date()));
        task.setUpdatedDate(sdf.format(new Date()));
        task.setArchived(false);
        task.setChecked(false);
        System.out.println(user.getName());
        task.setUsername(user.getName());

        long id = table.tasks.create(task);
        task.setId(id);

        this.tasks.add(task);
        text.setText("");
        text.clearFocus();
        InputMethodManager inputManager =
            (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(
            this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

        break;
    }
  }
Exemplo n.º 2
0
  private void logoutUser() {

    Table table = Table.getInstance(this);
    List<User> users = (List<User>) table.users.select("usr_logged_in='1'");
    if (!users.isEmpty()) {

      User user = users.get(0);
      user.setLoggedIn(0);

      table.users.update(user);

      Intent intent = new Intent(this, AccountManagement.class);
      startActivity(intent);
    }
  }
Exemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar ab = getActionBar();
    ab.setDisplayUseLogoEnabled(true);
    ab.setDisplayShowTitleEnabled(false);
    setContentView(R.layout.activity_main);

    table = Table.getInstance(this);
    List<User> users = (List<User>) table.users.select("usr_logged_in='1'");
    if (users.isEmpty()) {
      Intent intent = new Intent(this, AccountManagement.class);
      startActivity(intent);
    }

    user = users.get(0);

    tasks = table.tasks.select("task_username='******'");
    listView = (ListView) findViewById(R.id.list_view_tasks);

    taskArrayAdapter = new TaskArrayAdapter(this, R.layout.task, tasks);

    // listView.setClickable(true);
    // listView.setItemsCanFocus(true);
    // listView.setOnItemClickListener(clickOnTask);
    // listTasks.setOnItemLongClickListener(editOnTask);
    listView.setAdapter(taskArrayAdapter);

    taskArrayAdapter.notifyDataSetChanged();
  }