whether a setOnLoadCompleteListener can be called several times
-
I've got three fragments, and every fragment has different sounds that appear on the buttons, and I'm calling.
setOnLoadCompleteListener
in every fragment, but in two fragments, the sound will come.I can't understand why.
mSoundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { loaded = true;
} });
and when I'm checking.
true
♪false
And the button doesn't work.
If I clean up the test, then the button works and the sound comes out.if (loaded) {
Sound.playSound(mBisonSound);
Toast.makeText(view.getContext(), R.string.Bison, Toast.LENGTH_SHORT).show();
Snackbar.make(view, R.string.Bison, Snackbar.LENGTH_SHORT).show();
}
-
Comments
Problem is, you're rewriting.
onLoadComplete
Three times, each of which changesloaded
current class. In other words, you need to reschedule the variable.loaded
into your classsound Pager
and change it there https://ru.stackoverflow.com/users/192419/daniel-shatz 25 Dec. '15 at 17:25