예제 #1
0
  private void populateList(ArrayList<Records> recordList, boolean artistMode) {
    final MyDBHandler dbHandler = new MyDBHandler(getApplicationContext(), null, null, 1);
    recordDisplayList = (ListView) findViewById(R.id.listViewMainDisplay);

    if (!databaseTable.equals("lentout")) {
      customAdapter = new ListViewAdapterMain(this, recordList, null);
      customAdapter.artistView = artistMode;
      customAdapter.callingTable = databaseTable;
    } else {
      ArrayList<LentOut> lentOutList =
          dbHandler.getLentOut("SELECT * FROM lentout ORDER BY album_id");
      customAdapter = new ListViewAdapterMain(this, recordList, lentOutList);
      customAdapter.setIsOnLendOutScreen(true);
      customAdapter.callingTable = databaseTable;
    }

    recordDisplayList.setAdapter(customAdapter);
    recordDisplayList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Records selectedRecord = customAdapter.getItem(position);
            String selectedBandName = selectedRecord.get_bandname();
            populateArrayList(
                "SELECT * FROM " + databaseTable + " WHERE bandname='" + selectedBandName + "';",
                false);
          }
        });
    customAdapter.notifyDataSetChanged();
    dbHandler.close();
  }
예제 #2
0
  private void populateGenreList(ArrayList<Records> recordList) {
    recordDisplayList = (ListView) findViewById(R.id.listViewMainDisplay);

    customAdapter = new ListViewAdapterMain(this, recordList, null);
    customAdapter.artistView = true;
    recordDisplayList.setAdapter(customAdapter);
    recordDisplayList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Records selectedRecord = customAdapter.getItem(position);
            String selectedBandName = selectedRecord.get_bandname();
            populateArrayList(
                "SELECT * FROM records INNER JOIN recordsgenres ON records._id=recordsgenres.album_id WHERE recordsgenres.genre='"
                    + selectedBandName
                    + "' ORDER BY records._id;",
                false);
          }
        });

    customAdapter.notifyDataSetChanged();
  }