コード例 #1
0
  private void addProductsToList(int i, int cid) {
    dba.open();
    Cursor mcursor = dba.retriveproductsbycategory(cid);

    //	Log.d("bis"," cat addProductsToList count= "+mcursor.getCount());

    if (mcursor.moveToFirst()) {
      do {

        // Log.d("bis","mcursor.getString(4)=="+mcursor.getString(4));

        // po.setPid(mcursor.getInt(0));
        // po.setCid(mcursor.getInt(1));
        // po.setPinfo(mcursor.getString(3));
        // po.setPname(mcursor.getString(2));
        // po.setPurl(mcursor.getString(4));
        // po.setPcost(mcursor.getString(6));

        // productList.add(po);
        lists_pnames.get(i).add(mcursor.getString(2));
        lists_pids.get(i).add(mcursor.getInt(0));

      } while (mcursor.moveToNext());
    }

    if (mcursor != null && !mcursor.isClosed()) {
      mcursor.close();
    }

    dba.close();
  }
コード例 #2
0
  private void get_list_for_actionbar(String query) {

    apoList = new ArrayList<ActionbarProductObject>();

    dba.open();
    Cursor mcursor = dba.retriveallproductsByMatch(query);
    if (mcursor.moveToFirst()) {
      do {
        Log.d("bis", " mcursor is not empty at PL Sv " + mcursor.getCount());
        ActionbarProductObject apo = new ActionbarProductObject();
        apo.setPid(mcursor.getInt(0));
        apo.setCid(mcursor.getInt(1));
        apo.setPinfo(mcursor.getString(3));
        apo.setPname(mcursor.getString(2));
        apo.setPurl(mcursor.getString(4));
        apo.setPcost(mcursor.getString(6));
        apoList.add(apo);

      } while (mcursor.moveToNext());
    } else {
      Log.d("bis", " mcursor is empty at PL Sv");
    }

    dba.close();
  }
コード例 #3
0
  private void getListOfCategories() {
    // TODO Auto-generated method stub
    dba.open();
    Cursor mCursor = dba.retriveallcategories();
    dba.close();
    // Log.d("bis", "mCursor==" + mCursor.getCount());

    // Log.d("bis"," cat count= "+mCursor.getCount());

    for (int i = 0; i < mCursor.getCount(); i++) {

      // cateObject.setCurl(mCursor.getString(2));
      // cateObject.setCname(mCursor.getString(1));
      // cateObject.setCid(mCursor.getInt(0));
      listDataHeader_catnames.add(mCursor.getString(1));
      listDataHeader_cat_ids.add(mCursor.getInt(0));

      mCursor.moveToNext();
    }
  }
コード例 #4
0
  private void get_list_of_products() {
    dba.open();
    Cursor mcursor = dba.retriveproductsbycategory(cid);

    if (mcursor.moveToFirst()) {
      do {

        // Log.d("bis","mcursor.getString(4)=="+mcursor.getString(4));
        productObject po = new productObject();
        po.setPid(mcursor.getInt(0));
        po.setCid(mcursor.getInt(1));
        po.setPinfo(mcursor.getString(3));
        po.setPname(mcursor.getString(2));
        po.setPurl(mcursor.getString(4));
        po.setPcost(mcursor.getString(6));

        productList.add(po);
      } while (mcursor.moveToNext());
    }

    if (mcursor != null && !mcursor.isClosed()) {
      mcursor.close();
    }

    dba.close();

    pgva = new ProductGridViewAdapter(this, productList);

    // ====================================================

    recList.setHasFixedSize(true);
    GridLayoutManager llm = new GridLayoutManager(this, 4);
    // llm.setOrientation(GridLayoutManager.);
    recList.setLayoutManager(llm);

    recList.setAdapter(pgva);
    recList.setItemAnimator(new DefaultItemAnimator());

    // item click listner
    recList.addOnItemTouchListener(
        new RecyclerItemClickListener(
            getApplicationContext(),
            new RecyclerItemClickListener.OnItemClickListener() {
              @Override
              public void onItemClick(View view, int pos) {

                Constants.pid = productList.get(pos).getPid();
                Constants.pname = productList.get(pos).getPname();
                Constants.pcost = productList.get(pos).getPcost();

                if (InfoTracker.usersessionid > 0) {

                  InfoTracker.resetValuesAtProductLevel();

                  InfoTracker.pid = productList.get(pos).getPid();
                  InfoTracker.pname = productList.get(pos).getPname();
                  InfoTracker.time = System.currentTimeMillis();
                }

                Intent intent = new Intent(context, ProductOverView.class);

                context.startActivity(intent);
              }
            }));
  }