Skip to content

Commit

Permalink
Changed image buttons to normal buttons with text.
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorch committed Nov 27, 2014
1 parent 4dc43f6 commit 940f1c9
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 35 additions & 23 deletions app/src/main/java/de/storch/fluchomat/FluchomatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import android.os.Bundle;
import android.widget.GridView;

import java.util.ArrayList;
import java.util.List;

public class FluchomatActivity extends Activity {

private SoundManager mSoundManager;
private SoundManager soundManager;
private List<Sound> sounds = new ArrayList<Sound>();

/** Called when the activity is first created. */
@Override
Expand All @@ -16,32 +20,40 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main);

GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setAdapter(new ListAdapter(this));

sounds.add(new Sound(R.raw.scheisse, "Scheiße"));
sounds.add(new Sound(R.raw.scheisse_hier_mit_der_scheisse_hier, "Scheiße mit der Scheiße"));
sounds.add(new Sound(R.raw.ja_ich_werd_noch_mal_bloede, "Werd noch mal blöde"));
sounds.add(new Sound(R.raw.ich_seh_aber_nuescht, "Ich seh aber nüscht"));
sounds.add(new Sound(R.raw.wie_gehtn_das, "Wie geht'n das?"));
sounds.add(new Sound(R.raw.das_man_ma_was_sieht, "Daß ma mal was sieht"));
sounds.add(new Sound(R.raw.wo_ist_hier_vorne_und_hinten, "Vorne und Hinten"));
sounds.add(new Sound(R.raw.zweihundert_puls_hab_ich_bald, "200 Puls"));
sounds.add(new Sound(R.raw.ich_schmeiss_die_scheisse_aus_dem_fenster_raus, "Aus dem Fenster raus"));
sounds.add(new Sound(R.raw.en_schwarzen_bildschirm_hab_ich, "Schwarzen Bildschirm"));
sounds.add(new Sound(R.raw.ich_hau_ihn_weg, "Hau ihn weg"));
sounds.add(new Sound(R.raw.hier_steht_on_off_soll_ich_da_druff_druecken, "On, Off"));
sounds.add(new Sound(R.raw.ohhhh, "Ohhh"));
sounds.add(new Sound(R.raw.gibts_doch_gar_net, "Gibts doch gar net"));
sounds.add(new Sound(R.raw.jetzt_geht_er, "Jetzt geht er"));
sounds.add(new Sound(R.raw.ich_hab_hier_aufn_knopf_gedrueckt_und_er_geht, "Knopf gedrückt"));

soundManager = new SoundManager();
soundManager.initSounds(getBaseContext());
for (Sound sound : sounds) {
soundManager.addSound(sounds.indexOf(sound), sound.getId());
}

mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1, R.raw.scheisse);
mSoundManager.addSound(2, R.raw.scheisse_hier_mit_der_scheisse_hier);
mSoundManager.addSound(3, R.raw.ja_ich_werd_noch_mal_bloede);
mSoundManager.addSound(4, R.raw.ich_seh_aber_nuescht);
mSoundManager.addSound(5, R.raw.wie_gehtn_das);
mSoundManager.addSound(6, R.raw.das_man_ma_was_sieht);
mSoundManager.addSound(7, R.raw.wo_ist_hier_vorne_und_hinten);
mSoundManager.addSound(8, R.raw.zweihundert_puls_hab_ich_bald);
mSoundManager.addSound(9, R.raw.ich_schmeiss_die_scheisse_aus_dem_fenster_raus);
mSoundManager.addSound(10, R.raw.en_schwarzen_bildschirm_hab_ich);
mSoundManager.addSound(11, R.raw.ich_hau_ihn_weg);
mSoundManager.addSound(12, R.raw.hier_steht_on_off_soll_ich_da_druff_druecken);
mSoundManager.addSound(13, R.raw.ohhhh);
mSoundManager.addSound(14, R.raw.gibts_doch_gar_net);
mSoundManager.addSound(15, R.raw.jetzt_geht_er);
mSoundManager.addSound(16, R.raw.ich_hab_hier_aufn_knopf_gedrueckt_und_er_geht);

setVolumeControlStream(AudioManager.STREAM_MUSIC);
}

public void playSound(int soundId) {
mSoundManager.playSound(soundId);
public void playSound(int id) {
soundManager.playSound(id);
}

public String getSoundText(int soundId) {
return sounds.get(soundId).getText();
}

}
55 changes: 0 additions & 55 deletions app/src/main/java/de/storch/fluchomat/ImageAdapter.java

This file was deleted.

49 changes: 49 additions & 0 deletions app/src/main/java/de/storch/fluchomat/ListAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package de.storch.fluchomat;

import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

public class ListAdapter extends BaseAdapter {

private FluchomatActivity mContext;

public ListAdapter(FluchomatActivity c) {
mContext = c;
}

public int getCount() {
return 16;
}

public Object getItem(int position) {
return null;
}

public long getItemId(int position) {
return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(final int position, View convertView, ViewGroup parent) {
Button listItem;
if (convertView == null) { // if it's not recycled, initialize some attributes
listItem = new Button(mContext);
listItem.setText(mContext.getSoundText(position));
listItem.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
mContext.playSound(position);
}
});
} else {
listItem = (Button) convertView;
}

return listItem;
}

}
23 changes: 23 additions & 0 deletions app/src/main/java/de/storch/fluchomat/Sound.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.storch.fluchomat;

/**
* One Sound with id and text
*/
public class Sound {

private int id;
private String text;

public Sound(int id, String text) {
this.id = id;
this.text = text;
}

public int getId() {
return id;
}

public String getText() {
return text;
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/de/storch/fluchomat/SoundManager.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.storch.fluchomat;

import java.util.HashMap;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;

import java.util.HashMap;

public class SoundManager {
private SoundPool mSoundPool;
private HashMap<Integer, Integer> mSoundPoolMap;
Expand Down
Binary file removed app/src/main/res/drawable/button_normal.png
Binary file not shown.
Binary file removed app/src/main/res/drawable/button_pressed.png
Binary file not shown.
6 changes: 0 additions & 6 deletions app/src/main/res/layout/pushbutton.xml

This file was deleted.

0 comments on commit 940f1c9

Please sign in to comment.