Exemple #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();
  }
Exemple #2
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setVisibility(View.VISIBLE);

    if (id == R.id.nav_my_collection) {
      databaseTable = "records";
      customAdapter.isOnLendoutScreen = false;
      reloadListView();
      getSupportActionBar().setTitle("My Collection");
      changeActionBarColor("#1c2f2f");

    } else if (id == R.id.nav_wishlist) {
      databaseTable = "wishlist";
      customAdapter.isOnLendoutScreen = false;
      reloadListView();
      getSupportActionBar().setTitle("Wishlist");
      changeActionBarColor("#2f1c2f");

    } else if (id == R.id.nav_backup) {
      Intent open_BackupMenu = new Intent(MainActivity.this, BackupRestore.class);
      startActivity(open_BackupMenu);
    } else if (id == R.id.nav_lentout) {
      databaseTable = "lentout";
      reloadListView();
      fab.setVisibility(View.GONE);
      getSupportActionBar().setTitle("Lentout");
      changeActionBarColor("#2f2f1c");
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Exemple #3
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();
  }