Ejemplo n.º 1
0
  /**
   * 根据页码获取缓存数据
   *
   * @param page
   * @return
   */
  @Override
  public ArrayList<Picture> getCacheByPage(int page) {

    QueryBuilder<PictureCache> query =
        mPictureCacheDao.queryBuilder().where(PictureCacheDao.Properties.Page.eq("" + page));

    if (query.list().size() > 0) {
      return (ArrayList<Picture>)
          JSONParser.toObject(
              query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() {}.getType());
    } else {
      return new ArrayList<Picture>();
    }
  }
Ejemplo n.º 2
0
    protected void onPostExecute(String values) {
      // dialogo.hide();
      if (values != null) {
        try {
          JSONObject json = new JSONObject(values);
          if (json.getString("status").equals("OK")) {

            JSONArray result = json.getJSONArray("result");
            JSONObject datos = new JSONObject(result.getString(0));
            JSONObject fields_ = datos.getJSONObject("fields");

            Clientes cliente = new Clientes();
            cliente.setNombres(fields_.getString("nombres"));
            cliente.setApellidos(fields_.getString("apellidos"));
            cliente.setDirección("No disponible");
            cliente.setDocumento("1105683985");
            cliente.setEmail(fields_.getString("email"));
            cliente.setReferencia(datos.getInt("pk"));
            cliente.setTelefono("6700572");

            QueryBuilder qb = DaoAPP.daoSession.getClientesDao().queryBuilder();
            qb.where(ClientesDao.Properties.Referencia.eq(datos.getInt("pk")));
            List<Clientes> clientes = qb.list();
            if (clientes.size() == 0) {
              DaoAPP.daoSession.getClientesDao().insert(cliente);
            }
          }
        } catch (JSONException e) {
          e.printStackTrace();
        }
      }
    }
Ejemplo n.º 3
0
    protected void onPostExecute(String values) {
      // dialogo.hide();
      if (values != null) {
        katana kata = new katana();
        try {
          long fer = kata.crearFincaEnInicio(new JSONObject(values));
          if (fer != 0) {
            QueryBuilder qb = DaoAPP.daoSession.getClientesDao().queryBuilder();
            qb.where(ClientesDao.Properties.Referencia.eq(fer));

            List<Clientes> clientes = qb.list();
            if (clientes.size() == 0) {
              new descargarCliente().execute(String.valueOf(fer));
            }
          }
        } catch (JSONException e) {
          e.printStackTrace();
        }

      } else {
        Toast.makeText(
                MainActivity.this,
                "No hemos podido iniciar sesión, asegurate de estar conectado a internet.",
                Toast.LENGTH_SHORT)
            .show();
      }
    }
Ejemplo n.º 4
0
 public static List<AskTag> getUnselectedTags() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   QueryBuilder<AskTag> builder =
       tagDao
           .queryBuilder()
           .where(AskTagDao.Properties.Selected.eq(false))
           .orderAsc(AskTagDao.Properties.Order);
   return builder.list();
 }
 private void getPlayerData(String playerID) {
   QueryBuilder<Player> playerQB =
       CustomApplcation.getDaoSession(mContext).getPlayerDao().queryBuilder();
   playerQB.where(com.kinth.football.dao.PlayerDao.Properties.Uuid.eq(playerID));
   List<Player> list = playerQB.list();
   for (int i = 0; i < list.size(); i++) {
     playerList.add(list.get(i));
   }
 }
 /**
  * Executes the query and returns the result as a list containing all entities loaded into memory.
  *
  * @param dao
  * @param isAsc
  * @param orderProperty
  * @return
  */
 public static List getList(AbstractDao dao, boolean isAsc, Property... orderProperty) {
   setIfLog();
   QueryBuilder queryBuilder = dao.queryBuilder();
   if (isAsc) {
     queryBuilder = queryBuilder.orderAsc(orderProperty);
   } else {
     queryBuilder = queryBuilder.orderDesc(orderProperty);
   }
   List indexFavList = queryBuilder.list();
   return indexFavList;
 }
Ejemplo n.º 7
0
  public void InitialiserListe(Context context) {
    // On récupère la base de données
    DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "trivia-db", null);
    db = helper.getWritableDatabase();
    daoMaster = new DaoMaster(db);
    daoSession = daoMaster.newSession();

    // On récupère toutes les questions
    questionDao = daoSession.getQuestionDao();
    QueryBuilder qb = questionDao.queryBuilder();
    listAllQuestion = qb.list();
  }
 public void testOrderWithSpecialNames() {
   QueryBuilder<SpecialNamesEntity> queryBuilder = dao.queryBuilder();
   queryBuilder.orderAsc(Properties.Avg);
   queryBuilder.orderAsc(Properties.Count);
   queryBuilder.orderAsc(Properties.Distinct);
   queryBuilder.orderAsc(Properties.Index);
   queryBuilder.orderAsc(Properties.Join);
   queryBuilder.orderAsc(Properties.On);
   queryBuilder.orderAsc(Properties.Select);
   queryBuilder.orderAsc(Properties.Sum);
   queryBuilder.orderAsc(Properties.Order);
   queryBuilder.list();
 }
    @Override
    protected List<Player> doInBackground(Void... params) {
      QueryBuilder<TeamPlayer> tpQB =
          CustomApplcation.getDaoSession(mContext).getTeamPlayerDao().queryBuilder();
      tpQB.where(com.kinth.football.dao.TeamPlayerDao.Properties.Team_id.eq(onlyTeam.getUuid()));
      List<TeamPlayer> teamId_playerId_List = tpQB.list();

      if (teamId_playerId_List.size() != 0) {
        for (TeamPlayer teamplayer : teamId_playerId_List) {
          getPlayerData(teamplayer.getPlayer_id());
        }
      }
      return playerList;
    }
Ejemplo n.º 10
0
 public void testWhereWithSpecialNamesWithValues() {
   QueryBuilder<SpecialNamesEntity> queryBuilder = dao.queryBuilder();
   queryBuilder.where(Properties.Avg.eq("test"));
   queryBuilder.where(Properties.Count.notIn("test", "test2"));
   queryBuilder.where(Properties.Distinct.ge("test"));
   queryBuilder.where(Properties.Index.le("test"));
   queryBuilder.where(Properties.Join.like("test"));
   queryBuilder.where(Properties.On.notEq("test"));
   queryBuilder.where(Properties.Select.in("test", "test2"));
   queryBuilder.where(Properties.Sum.lt(1));
   queryBuilder.where(Properties.Order.gt(1));
   queryBuilder.list();
   queryBuilder.buildCount().count();
   queryBuilder.buildDelete().executeDeleteWithoutDetachingEntities();
 }
Ejemplo n.º 11
0
 public void testWhereWithSpecialNames() {
   QueryBuilder<SpecialNamesEntity> queryBuilder = dao.queryBuilder();
   queryBuilder.where(Properties.Avg.isNotNull());
   queryBuilder.where(Properties.Count.isNotNull());
   queryBuilder.where(Properties.Distinct.isNotNull());
   queryBuilder.where(Properties.Index.isNotNull());
   queryBuilder.where(Properties.Join.isNotNull());
   queryBuilder.where(Properties.On.isNotNull());
   queryBuilder.where(Properties.Select.isNotNull());
   queryBuilder.where(Properties.Sum.isNotNull());
   queryBuilder.where(Properties.Order.isNotNull());
   queryBuilder.list();
   queryBuilder.buildCount().count();
   queryBuilder.buildDelete().executeDeleteWithoutDetachingEntities();
 }
Ejemplo n.º 12
0
 public static List<SubItem> getSelectedQuestionSubItems() {
   AskTagDao tagDao = AppApplication.getDaoSession().getAskTagDao();
   QueryBuilder<AskTag> builder =
       tagDao
           .queryBuilder()
           .where(AskTagDao.Properties.Selected.eq(true))
           .orderAsc(AskTagDao.Properties.Order);
   List<AskTag> askTags = builder.list();
   ArrayList<SubItem> subItems = new ArrayList<>();
   for (int i = 0; i < askTags.size(); i++) {
     AskTag tag = askTags.get(i);
     SubItem subItem = new SubItem(tag.getSection(), tag.getType(), tag.getName(), tag.getValue());
     subItems.add(subItem);
   }
   return subItems;
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    ButterKnife.inject(this, view);

    DatabaseHelper helper = DatabaseHelper.getInstance(getActivity());
    SQLiteDatabase db = helper.getWritableDatabase();
    DaoMaster daoMaster = new DaoMaster(db);
    DaoSession daoSession = daoMaster.newSession();
    GalleryDao galleryDao = daoSession.getGalleryDao();

    QueryBuilder<Gallery> qb = galleryDao.queryBuilder();
    qb.where(GalleryDao.Properties.Starred.eq(true));
    qb.orderDesc(GalleryDao.Properties.Lastread);
    getList().addAll(qb.list());
    notifyDataSetChanged();

    if (getCount() == 0) {
      errorView.setText(R.string.error_no_starred);
    }

    return view;
  }
 public List<DeviceBean> loadAllDeviceBean(String UUIDString) {
   QueryBuilder<DeviceBean> mqBuilder = deviceBeanDao.queryBuilder();
   mqBuilder.where(com.itraing.greendao.DeviceBeanDao.Properties.UUIDString.eq(UUIDString));
   return mqBuilder.list();
 }