Exemplo n.º 1
0
 private void refreshList() {
   this.sounds = database.getSounds();
   ArrayList<Sound> lstSounds = new ArrayList<Sound>(Arrays.asList(this.sounds));
   this.adapter.clear();
   this.adapter.addAll(lstSounds);
   this.adapter.notifyDataSetChanged();
 }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    this.lst_main = (ListView) findViewById(R.id.lst_main);
    this.database = SoundDatabase.getInstance(this);
    this.sounds = this.database.getSounds();

    Resources res = getResources();

    //		initList();
    ArrayList<Sound> lstsounds = new ArrayList<Sound>(Arrays.asList(this.sounds));
    this.adapter = new MainListAdapter(this, R.layout.row_mainlist, lstsounds, database.getAtzen());
    this.lst_main.setAdapter(adapter);
    this.lst_main.setOnItemClickListener(this);
    this.lst_main.setOnItemLongClickListener(this);
  }
Exemplo n.º 3
0
  private void deleteSound(int position) {
    String filePath = sounds[position].getPath();
    database.deleteSound(sounds[position]);
    File file = new File(filePath);

    if (file.delete()) {
      Toast.makeText(this, filePath + " " + R.string.info_deleted, Toast.LENGTH_SHORT).show();
      refreshList();
    } else {
      Toast.makeText(this, R.string.info_shit_happened, Toast.LENGTH_SHORT).show();
    }
  }