use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.
the class MusicBottomBarFragment method updateTrack.
protected void updateTrack() {
HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
Track track = application.getPlaylistAdapter().getCurrentItem();
if (track != null) {
trackTitle.setText(track.getTrackTitle());
artistName.setText(track.getArtistName());
imageLoader.displayImage(track.getThumbnailUrl(), imageView, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
rootView.setVisibility(View.VISIBLE);
} else {
rootView.setVisibility(View.GONE);
}
if (MusicPlayerService.isLoading()) {
isLoading.setVisibility(View.VISIBLE);
isPlaying.setVisibility(View.GONE);
} else {
if (MusicPlayerService.isPlaying()) {
isPlaying.setImageDrawable(pauseIcon);
} else {
isPlaying.setImageDrawable(playIcon);
}
isLoading.setVisibility(View.GONE);
isPlaying.setVisibility(View.VISIBLE);
}
}
use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.
the class MusicBottomBarFragment method onDestroy.
@Override
public void onDestroy() {
HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
playlistAdapter.unregisterDataSetObserver(playlistObserver);
super.onDestroy();
}
use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.
the class MusicBottomBarFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_music_bottom_bar, container, false);
rootView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), MusicPlaylistActivity.class);
Bundle bundle = new Bundle();
intent.putExtras(bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
});
imageView = (ImageView) rootView.findViewById(R.id.image);
trackTitle = (TextView) rootView.findViewById(R.id.trackTitle);
artistName = (TextView) rootView.findViewById(R.id.artistName);
isLoading = (ProgressBar) rootView.findViewById(R.id.isLoading);
isPlaying = (ImageView) rootView.findViewById(R.id.isPlaying);
isPlaying.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
playlistAdapter.playPauseToggle();
}
});
playlistObserver = new DataSetObserver() {
@Override
public void onChanged() {
updateTrack();
}
@Override
public void onInvalidated() {
updateTrack();
}
};
HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
playlistAdapter.registerDataSetObserver(playlistObserver);
return rootView;
}
use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.
the class TrackListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View trackListItemView;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
trackListItemView = inflater.inflate(R.layout.track_list_item, parent, false);
} else {
trackListItemView = convertView;
}
final ProgressBar progressBar = (ProgressBar) trackListItemView.findViewById(R.id.load);
final ImageView imageView = (ImageView) trackListItemView.findViewById(R.id.image);
final TextView trackTitle = (TextView) trackListItemView.findViewById(R.id.trackTitle);
final TextView artistName = (TextView) trackListItemView.findViewById(R.id.artistName);
final Track track = trackList.get(position);
trackTitle.setText(track.getTrackTitle());
artistName.setText(track.getArtistName());
String imageUrl = track.getThumbnailUrl();
imageLoader.displayImage(imageUrl, imageView, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
progressBar.setVisibility(View.VISIBLE);
imageView.setVisibility(View.INVISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
imageView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
progressBar.setVisibility(View.GONE);
}
});
final Button listenTrackButton = (Button) trackListItemView.findViewById(R.id.listenTrackButton);
final Button addTrackButton = (Button) trackListItemView.findViewById(R.id.addTrackButton);
// when click a 'listen' button.
listenTrackButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HowaboutApplication application = (HowaboutApplication) activity.getApplication();
application.getPlaylistAdapter().play(track);
}
});
// when click an 'add' button.
addTrackButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HowaboutApplication application = (HowaboutApplication) activity.getApplication();
application.getPlaylistAdapter().add(track);
}
});
return trackListItemView;
}
Aggregations