use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class ViewAlbumFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
backBtn = (ImageView) view.findViewById(R.id.view_album_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
backDrop = (ImageView) view.findViewById(R.id.album_backdrop);
imgLoader.DisplayImage(HomeActivity.tempAlbum.getAlbumSongs().get(0).getPath(), backDrop);
fragTitle = (TextView) view.findViewById(R.id.album_fragment_title);
if (SplashActivity.tf4 != null)
fragTitle.setTypeface(SplashActivity.tf4);
albumTitle = (TextView) view.findViewById(R.id.album_title);
albumTitle.setText(HomeActivity.tempAlbum.getName());
albumTracksText = (TextView) view.findViewById(R.id.album_tracks_text);
addToQueueIcon = (ImageView) view.findViewById(R.id.add_album_to_queue_icon);
addToQueueIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.addAlbumToQueue();
}
});
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
int tmp = HomeActivity.tempAlbum.getAlbumSongs().size();
String details1;
if (tmp == 1) {
details1 = "1 Song ";
} else {
details1 = tmp + " Songs ";
}
albumTracksText.setText(details1);
fab = (FloatingActionButton) view.findViewById(R.id.play_all_from_album);
fab.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
rv = (RecyclerView) view.findViewById(R.id.album_songs_recycler);
aslAdapter = new LocalTrackRecyclerAdapter(HomeActivity.tempAlbum.getAlbumSongs(), getContext());
LinearLayoutManager mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
rv.setLayoutManager(mLayoutManager2);
rv.setItemAnimator(new DefaultItemAnimator());
rv.setAdapter(aslAdapter);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HomeActivity.queue.getQueue().clear();
for (int i = 0; i < HomeActivity.tempAlbum.getAlbumSongs().size(); i++) {
UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.tempAlbum.getAlbumSongs().get(i), null);
HomeActivity.queue.getQueue().add(ut);
}
mCallback.onAlbumPlayAll();
}
});
rv.addOnItemTouchListener(new ClickItemTouchListener(rv) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
LocalTrack track = HomeActivity.tempAlbum.getAlbumSongs().get(position);
if (HomeActivity.queue.getQueue().size() == 0) {
HomeActivity.queueCurrentIndex = 0;
HomeActivity.queue.getQueue().add(new UnifiedTrack(true, track, null));
} else if (HomeActivity.queueCurrentIndex == HomeActivity.queue.getQueue().size() - 1) {
HomeActivity.queueCurrentIndex++;
HomeActivity.queue.getQueue().add(new UnifiedTrack(true, track, null));
} else if (HomeActivity.isReloaded) {
HomeActivity.isReloaded = false;
HomeActivity.queueCurrentIndex = HomeActivity.queue.getQueue().size();
HomeActivity.queue.getQueue().add(new UnifiedTrack(true, track, null));
} else {
HomeActivity.queue.getQueue().add(++HomeActivity.queueCurrentIndex, new UnifiedTrack(true, track, null));
}
HomeActivity.localSelectedTrack = track;
HomeActivity.streamSelected = false;
HomeActivity.localSelected = true;
HomeActivity.queueCall = false;
HomeActivity.isReloaded = false;
mCallback.onAlbumSongClick();
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
CustomLocalBottomSheetDialog localBottomSheetDialog = new CustomLocalBottomSheetDialog();
localBottomSheetDialog.setPosition(position);
localBottomSheetDialog.setLocalTrack(activity.tempAlbum.getAlbumSongs().get(position));
localBottomSheetDialog.setFragment("Album");
localBottomSheetDialog.show(activity.getSupportFragmentManager(), "local_song_bottom_sheet");
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class PlaylistTrackAdapter method onItemMove.
@Override
public void onItemMove(int fromPosition, int toPosition) {
UnifiedTrack prev = songList.remove(fromPosition);
songList.add(toPosition, prev);
notifyItemMoved(fromPosition, toPosition);
if (homeActivity.pAdapter != null)
homeActivity.pAdapter.notifyDataSetChanged();
homeActivity.updateAllPlaylistFragment();
mCallback2.updateViewPlaylistFragment();
new HomeActivity.SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class PlaylistTrackAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final PlaylistTrackAdapter.MyViewHolder holder, int position) {
UnifiedTrack ut = songList.get(position);
if (ut.getType()) {
LocalTrack lt = ut.getLocalTrack();
imgLoader.DisplayImage(lt.getPath(), holder.art);
holder.title.setText(lt.getTitle());
holder.artist.setText(lt.getArtist());
} else {
Track t = ut.getStreamTrack();
Picasso.with(ctx).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(holder.art);
holder.title.setText(t.getTitle());
holder.artist.setText("");
}
holder.holderImg.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
mDragStartListener.onDragStarted(holder);
}
return false;
}
});
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class PlayListsHorizontalAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Playlist pl = playlists.get(position);
List<UnifiedTrack> list = pl.getSongList();
for (int i = 0; i < 4; i++) {
holder.img[i].setImageBitmap(null);
}
if (list.size() >= 4) {
for (int i = 0; i < 4; i++) {
if (list.get(i).getType()) {
imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
} else {
imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
}
}
} else {
int sz = list.size();
for (int i = 0; i < sz; i++) {
if (list.get(i).getType()) {
imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
} else {
imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
}
}
}
holder.playlistName.setText(pl.getPlaylistName());
if (pl.getSongList().size() > 1)
holder.playlistSize.setText(String.valueOf(pl.getSongList().size()) + " Songs");
else
holder.playlistSize.setText(String.valueOf(pl.getSongList().size()) + " Song");
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class ViewAllPlaylistsRecyclerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Playlist p = playlists.get(position);
List<UnifiedTrack> list = p.getSongList();
if (SplashActivity.tf3 != null)
holder.playListName.setTypeface(SplashActivity.tf3);
holder.playListName.setText(p.getPlaylistName());
if (list.size() >= 3) {
String[] names = new String[3];
for (int i = 0; i < 3; i++) {
if (list.get(i).getType()) {
names[i] = list.get(i).getLocalTrack().getTitle();
imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
} else {
names[i] = list.get(i).getStreamTrack().getTitle();
imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
}
holder.name[i].setText(names[i]);
}
holder.continuedSymbol.setVisibility(View.VISIBLE);
} else {
int sz = list.size();
String[] names = new String[3];
for (int i = 0; i < sz; i++) {
if (list.get(i).getType()) {
names[i] = list.get(i).getLocalTrack().getTitle();
imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
} else {
names[i] = list.get(i).getStreamTrack().getTitle();
imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
}
holder.name[i].setText(names[i]);
}
}
}
Aggregations