Created
August 10, 2020 06:20
-
-
Save bengongon97/25734255d2be4e8a407383381e600762 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onCreate(Bundle savedInstanceState) { | |
//... your other codes | |
final Drawable shuffleDrawable = getDrawable(R.drawable.menu_shuffle_normal); | |
final Drawable orderDrawable = getDrawable(R.drawable.menu_order_normal); | |
final Drawable loopItself = getDrawable(R.drawable.menu_loop_one_normal); | |
final Drawable loopPlaylist = getDrawable(R.drawable.menu_loop_normal); | |
binding.shuffleButtonImageView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if(mHwAudioPlayerManager != null){ | |
if(binding.shuffleButtonImageView.getDrawable().getConstantState().equals(shuffleDrawable.getConstantState())){ | |
mHwAudioPlayerManager.setPlayMode(0); | |
binding.shuffleButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_order_normal)); | |
Toast.makeText(MainActivity.this,"Normal order",Toast.LENGTH_SHORT).show(); | |
} | |
else if(binding.shuffleButtonImageView.getDrawable().getConstantState().equals(orderDrawable.getConstantState())){ | |
mHwAudioPlayerManager.setPlayMode(1); | |
binding.shuffleButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_shuffle_normal)); | |
Toast.makeText(MainActivity.this,"Shuffle songs",Toast.LENGTH_SHORT).show(); | |
} | |
} | |
} | |
}); | |
binding.loopButtonImageView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if(mHwAudioPlayerManager != null){ | |
if(binding.loopButtonImageView.getDrawable().getConstantState().equals(loopItself.getConstantState())){ | |
mHwAudioPlayerManager.setPlayMode(2); | |
binding.loopButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_loop_normal)); | |
Toast.makeText(MainActivity.this,"Loop playlist",Toast.LENGTH_SHORT).show(); | |
} | |
else if(binding.loopButtonImageView.getDrawable().getConstantState().equals(loopPlaylist.getConstantState())){ | |
mHwAudioPlayerManager.setPlayMode(3); | |
binding.loopButtonImageView.setImageDrawable(getDrawable(R.drawable.menu_loop_one_normal)); | |
Toast.makeText(MainActivity.this,"Loop the song",Toast.LENGTH_SHORT).show(); | |
} | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment