Пример #1
0
    @Override
    protected void onPostExecute(ItemGridModel[] result) {

      if (result != null && result.length > 0) {

        List<ItemGridModel> items = Arrays.asList(result);

        List<ItemGridModel> agenda = mDatabaseHelper.getAgenda();

        mDatabaseHelper.removeAllItemGrid();

        for (ItemGridModel item : items) {
          item.setAuthor(
              new AuthorModel(item.getAuthorId(), item.getAuthorName(), item.getCurriculum()));
          item.setInicio(Utils.getTime(item.getDate(), item.getTime(), true));
          item.setFim(Utils.getTime(item.getDate(), item.getTime(), false));
          mDatabaseHelper.createItemGrid(item);
        }

        rescheduleAlarm(agenda);
      } else {
        Toast.makeText(mContext, getString(R.string.server_down), Toast.LENGTH_LONG).show();
      }

      if (mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
      }

      createViewPager();
    }
Пример #2
0
  private void criarItemGradeFake(int dia, int minutos) {

    String titulo = "Evento de Teste do Lembrete - ";

    // Teste de AlarmManager
    Calendar inicio = Calendar.getInstance();
    // inicio.set(Calendar.HOUR_OF_DAY, 16);
    // inicio.set(Calendar.DAY_OF_MONTH, dia);
    inicio.add(Calendar.MINUTE, 2 + minutos);
    inicio.set(Calendar.SECOND, 0);

    Calendar fim = Calendar.getInstance();
    fim.setTimeInMillis(inicio.getTimeInMillis());
    fim.add(Calendar.HOUR_OF_DAY, 1);

    ItemGridModel itemGrade = new ItemGridModel();
    itemGrade.setInicio(new Date(inicio.getTimeInMillis()));
    itemGrade.setFim(new Date(fim.getTimeInMillis()));

    itemGrade.setAssistir(true);
    itemGrade.setPid(140);
    itemGrade.setTime(1);
    itemGrade.setDate(1);
    itemGrade.setPlace(1);
    itemGrade.setTitle(titulo + minutos);
    itemGrade.setType(1);

    AuthorModel author = new AuthorModel();
    author.setCurriculum("Biografia");
    author.setId(900);
    author.setName("Clovis Lemes Ferreira Junior");

    itemGrade.setAuthor(author);

    List<ItemGridModel> t = mDatabaseHelper.getItemGridDao().queryForEq("title", titulo + minutos);

    if (t == null || t.isEmpty()) {
      mDatabaseHelper.createItemGrid(itemGrade);
    }
  }