Пример #1
0
  public int updateWeeklytask(WeeklyTD weeklyTD) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(NAME, weeklyTD.getName());
    values.put(TIME, weeklyTD.getTime());

    return db.update(
        TABLE_NAME_WEEKLY_TASKS,
        values,
        ID + " = ?",
        new String[] {String.valueOf(weeklyTD.getID())});
  }
Пример #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container2, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    // return inflater.inflate(R.layout.fragment_weekly_tasks, container2, false);
    View v = inflater.inflate(R.layout.fragment_weekly_tasks, container2, false);

    FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.fabWeekly);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            getActivity().finish();
            Intent intent =
                new Intent(getActivity().getApplicationContext(), CreateWeeklyActivity.class);
            startActivity(intent);
            Snackbar.make(view, "New Task", Snackbar.LENGTH_LONG).setAction("Action", null).show();
          }
        });
    mDate = new Database(getActivity());
    // ListView listView = (ListView) v.findViewById(R.id.list);
    // String List;
    TextView textView = (TextView) v.findViewById(R.id.textView4);
    // mCatList = new ArrayList<String>(List);
    // HashMap<String, Object> hm;
    String a = "";

    List<WeeklyTD> weeklyTDList = mDate.getAllWeeklyTasks();
    for (WeeklyTD cn : weeklyTDList) {
      a = a + cn.getName() + cn.getDescription();
    }
    textView.setText(a);
    // for(WeeklyTD cn : weeklyTDList){
    // hm = new HashMap<>();
    // List = cn.getName();
    // hm.put(ICON, R.drawable.a); // Картинка
    // hm.put(TITLE, cn.getName() ); // Название
    // hm.put(DESCRIPTION, cn.getDescription());
    // mCatList.add(hm);
    // }

    // SimpleAdapter adapter = new SimpleAdapter(getActivity(), mCatList,
    //      R.layout.list_item, new String[]{TITLE, DESCRIPTION},
    //    new int[]{R.id.text1, R.id.text2});

    // listView.setAdapter(adapter);

    // listView.setOnItemClickListener(itemClickListener);
    return v;
  }
Пример #3
0
  public List<WeeklyTD> getAllWeeklyTasks() {
    List<WeeklyTD> weeklyTasksList = new ArrayList<WeeklyTD>();
    String selectQuery = "SELECT  * FROM " + TABLE_NAME_WEEKLY_TASKS;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    if (cursor.moveToFirst()) {
      do {
        WeeklyTD weeklyTasks = new WeeklyTD();
        // weeklyTasks.setID(Integer.parseInt(cursor.getString(0)));
        weeklyTasks.setName(cursor.getString(1));
        weeklyTasks.setDescription(cursor.getString(14));
        weeklyTasksList.add(weeklyTasks);
      } while (cursor.moveToNext());
    }

    return weeklyTasksList;
  }
Пример #4
0
 public void deleteWeeklyTask(WeeklyTD contact) {
   SQLiteDatabase db = this.getWritableDatabase();
   db.delete(TABLE_NAME_WEEKLY_TASKS, ID + " = ?", new String[] {String.valueOf(contact.getID())});
   db.close();
 }
Пример #5
0
  public void addWeeklyTD(WeeklyTD weeklyTD) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(NAME, weeklyTD.getName());
    values.put(TIME, weeklyTD.getTime());
    values.put(MONDAY, weeklyTD.getMonday());
    values.put(TUESDAY, weeklyTD.getTuesday());
    values.put(WEDNESDAY, weeklyTD.getWednesday());
    values.put(THURSDAY, weeklyTD.getThursday());
    values.put(FRIDAY, weeklyTD.getFriday());
    values.put(SATURDAY, weeklyTD.getSaturday());
    values.put(SUNDAY, weeklyTD.getSunday());
    values.put(CLOCK_IMAGE, weeklyTD.getVibration());
    values.put(SOUND, weeklyTD.getSound());
    values.put(ORIGINAL_SOUND, weeklyTD.getOriginalSound());
    values.put(DESCRIPTION, weeklyTD.getDescription());
    values.put(ICON, weeklyTD.getIconD());
    values.put(VOLUME, weeklyTD.getVolume());
    values.put(COLOUR, weeklyTD.getColour());
    values.put(WHISTLING, weeklyTD.getWhistling());

    db.insert(TABLE_NAME_WEEKLY_TASKS, null, values);
    db.close();
  }