예제 #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 rescheduleAlarm(List<ItemGridModel> agenda) {

    for (ItemGridModel item : agenda) {
      Utils.removeAlarm(getActivity(), item);
      Utils.setAlarm(getActivity(), item);

      try {
        List<ItemGridModel> items = mDatabaseHelper.getItemGridByProposta(item.getPid());
        for (ItemGridModel itemGridModel : items) {
          itemGridModel.setAssistir(Boolean.TRUE);
          mDatabaseHelper.getItemGridDao().update(itemGridModel);
        }
      } catch (Exception e) {

      }
    }
  }
예제 #3
0
  private void fillGrid() {

    if (Utils.verifyInternetConnection(getActivity())) {
      new GridTask(getActivity()).execute();
    }
  }