use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class StreamMusicFragment 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());
lv = (RecyclerView) view.findViewById(R.id.trackList);
adapter = new StreamTrackListAdapter(getContext(), HomeActivity.streamingTrackList);
LinearLayoutManager 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) {
Track track = HomeActivity.streamingTrackList.get(position);
if (HomeActivity.queue.getQueue().size() == 0) {
HomeActivity.queueCurrentIndex = 0;
HomeActivity.queue.getQueue().add(new UnifiedTrack(false, null, track));
} else if (HomeActivity.queueCurrentIndex == HomeActivity.queue.getQueue().size() - 1) {
HomeActivity.queueCurrentIndex++;
HomeActivity.queue.getQueue().add(new UnifiedTrack(false, null, track));
} else if (HomeActivity.isReloaded) {
HomeActivity.isReloaded = false;
HomeActivity.queueCurrentIndex = HomeActivity.queue.getQueue().size();
HomeActivity.queue.getQueue().add(new UnifiedTrack(false, null, track));
} else {
HomeActivity.queue.getQueue().add(++HomeActivity.queueCurrentIndex, new UnifiedTrack(false, null, track));
}
HomeActivity.selectedTrack = track;
HomeActivity.streamSelected = true;
HomeActivity.localSelected = false;
HomeActivity.queueCall = false;
HomeActivity.isReloaded = false;
mCallback.onTrackSelected(position);
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
CustomGeneralBottomSheetDialog generalBottomSheetDialog = new CustomGeneralBottomSheetDialog();
generalBottomSheetDialog.setPosition(position);
generalBottomSheetDialog.setTrack(new UnifiedTrack(false, null, HomeActivity.streamingTrackList.get(position)));
generalBottomSheetDialog.setFragment("Stream");
generalBottomSheetDialog.show(getActivity().getSupportFragmentManager(), "general_bottom_sheet_dialog");
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
}
Aggregations