コード例 #1
0
 private void displayCount() {
   CategoriesDataSourceSelector categoriesData =
       new CategoriesDataSourceSelector(getApplicationContext());
   ItemsDataSourceSelector itemsData = new ItemsDataSourceSelector(getApplicationContext());
   txvwCount.setText(categoriesData.getCount() + " - " + itemsData.getCount());
 }
コード例 #2
0
    @Override
    protected String doInBackground(Void... params) {
      Log.i(LOG_TAG, "AST_fillWithPokemons | String doInBackground(Void... params)");

      CategoriesDataSourceSelector categoriesData;
      categoriesData = new CategoriesDataSourceSelector(getApplicationContext());

      int[] categs = categoriesData.getAllIds();

      ItemsDataSourceSelector itemsData;
      itemsData = new ItemsDataSourceSelector(getApplicationContext());

      Random rand = new Random();

      Item item;

      String[] liste = getResources().getStringArray(R.array.prenoms_array);
      int liste_length = liste.length;

      int max = 20000;
      // int max = Pokemons.LIST.length;

      for (int j = 0; j < 1; j += 1) {

        int i = 0;
        int cat;
        String mm, dd;

        while (i < max) {

          mm = "" + (rand.nextInt(12) + 1);
          if (mm.length() < 2) mm = "0" + mm;
          dd = "" + (rand.nextInt(28) + 1);
          if (dd.length() < 2) dd = "0" + dd;

          cat = categs[rand.nextInt(categs.length)];

          item = new Item();
          // item.setName(Pokemons.LIST[i]);
          item.setName(liste[rand.nextInt(liste_length)] + " " + liste[rand.nextInt(liste_length)]);
          item.setDate((rand.nextInt(2100 - 1900) + 1900) + "-" + mm + "-" + dd);
          item.setRating((rand.nextInt(10) + 1) / Float.parseFloat("2.0"));
          item.setBool(rand.nextInt(2));
          item.setCategoryId(cat);
          // String resid = "" + (i+1);
          String resid = "" + (rand.nextInt(649 * 2) + 1);
          if (resid.length() == 1) resid = "00" + resid;
          if (resid.length() == 2) resid = "0" + resid;
          int res = getResources().getIdentifier("p" + resid, "drawable", "be.arno.crud");
          Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), res);
          item.setImage(mBitmap);

          itemsData.create(item);
          publishProgress(max, i);

          i += 1;
        }
      }

      return null;
    }