use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class FavouritesFragment method updateFavFragment.
@Override
public void updateFavFragment() {
if (HomeActivity.favouriteTracks.getFavourite().size() > 0) {
UnifiedTrack ut = HomeActivity.favouriteTracks.getFavourite().get(0);
if (ut.getType()) {
LocalTrack lt = ut.getLocalTrack();
imgLoader.DisplayImage(lt.getPath(), backdrop);
} else {
Track t = ut.getStreamTrack();
Picasso.with(getContext()).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(backdrop);
}
}
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class LocalMusicFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
shuffleFab = (FloatingActionButton) view.findViewById(R.id.play_all_fab_local);
if (HomeActivity.localTrackList.size() == 0) {
shuffleFab.setVisibility(View.INVISIBLE);
}
shuffleFab.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
shuffleFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HomeActivity.queue.getQueue().clear();
for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.localTrackList.get(i), null);
HomeActivity.queue.getQueue().add(ut);
}
if (HomeActivity.queue.getQueue().size() > 0) {
Random r = new Random();
int tmp = r.nextInt(HomeActivity.queue.getQueue().size());
HomeActivity.queueCurrentIndex = tmp;
LocalTrack track = HomeActivity.localTrackList.get(tmp);
HomeActivity.localSelectedTrack = track;
HomeActivity.streamSelected = false;
HomeActivity.localSelected = true;
HomeActivity.queueCall = false;
HomeActivity.isReloaded = false;
mCallback.onLocalTrackSelected(-1);
}
}
});
lv = (RecyclerView) view.findViewById(R.id.localMusicList);
adapter = new LocalTrackRecyclerAdapter(HomeActivity.finalLocalSearchResultList, getContext());
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
lv.setLayoutManager(mLayoutManager2);
lv.setItemAnimator(new DefaultItemAnimator());
lv.setAdapter(adapter);
lv.addOnItemTouchListener(new ClickItemTouchListener(lv) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
if (position >= 0) {
HomeActivity.queue.getQueue().clear();
for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.localTrackList.get(i), null);
HomeActivity.queue.getQueue().add(ut);
}
HomeActivity.queueCurrentIndex = getPosition(HomeActivity.finalLocalSearchResultList.get(position));
LocalTrack track = HomeActivity.finalLocalSearchResultList.get(position);
HomeActivity.localSelectedTrack = track;
HomeActivity.streamSelected = false;
HomeActivity.localSelected = true;
HomeActivity.queueCall = false;
HomeActivity.isReloaded = false;
mCallback.onLocalTrackSelected(-1);
}
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
if (position >= 0) {
CustomLocalBottomSheetDialog localBottomSheetDialog = new CustomLocalBottomSheetDialog();
localBottomSheetDialog.setPosition(position);
localBottomSheetDialog.setLocalTrack(activity.finalLocalSearchResultList.get(position));
localBottomSheetDialog.show(activity.getSupportFragmentManager(), "local_song_bottom_sheet");
}
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
Button mEndButton = new Button(getContext());
mEndButton.setBackgroundColor(HomeActivity.themeColor);
mEndButton.setTextColor(Color.WHITE);
showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(1).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(HomeActivity.tp).setTarget(new ViewTarget(R.id.songs_tab_alt_showcase, getActivity())).setContentTitle("All Songs").setContentText("All local Songs listed here.Click to Play.Long click for more options").build();
showCase.setButtonText("Next");
showCase.setButtonPosition(HomeActivity.lps);
showCase.overrideButtonClick(new View.OnClickListener() {
int count1 = 0;
@Override
public void onClick(View v) {
count1++;
switch(count1) {
case 1:
RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
lps.setMargins(margin, margin, margin, 5 + HomeActivity.navBarHeightSizeinDp);
showCase.setTarget(new ViewTarget(shuffleFab.getId(), getActivity()));
showCase.setContentTitle("Shuffle");
showCase.setContentText("Play all songs, shuffled randomly");
showCase.setButtonText("Done");
showCase.setButtonPosition(lps);
break;
case 2:
showCase.hide();
break;
}
}
});
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class PlayerFragment method removeFromFavourite.
public void removeFromFavourite() {
UnifiedTrack ut;
if (homeActivity.localSelected)
ut = new UnifiedTrack(true, localTrack, null);
else
ut = new UnifiedTrack(false, null, track);
for (int i = 0; i < homeActivity.favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut1 = homeActivity.favouriteTracks.getFavourite().get(i);
if (ut.getType() && ut1.getType()) {
if (ut.getLocalTrack().getTitle().equals(ut1.getLocalTrack().getTitle())) {
homeActivity.favouriteTracks.getFavourite().remove(i);
break;
}
} else if (!ut.getType() && !ut1.getType()) {
if (ut.getStreamTrack().getTitle().equals(ut1.getStreamTrack().getTitle())) {
homeActivity.favouriteTracks.getFavourite().remove(i);
break;
}
}
}
mCallback.onAddedtoFavfromPlayer();
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class FavouriteTrackAdapter method onItemMove.
@Override
public void onItemMove(int fromPosition, int toPosition) {
UnifiedTrack prev = favouriteList.remove(fromPosition);
favouriteList.add(toPosition, prev);
notifyItemMoved(fromPosition, toPosition);
mCallback2.updateFavFragment();
new HomeActivity.SaveFavourites().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class FavouriteTrackAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
UnifiedTrack ut = favouriteList.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;
}
});
}
Aggregations