use of com.github.amlcurran.showcaseview.targets.ViewTarget in project MusicDNA by harjot-oberai.
the class PlayerFragment method onViewCreated.
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
imgLoader = new ImageLoader(getContext());
smallPlayer = (RelativeLayout) view.findViewById(R.id.smallPlayer);
snappyRecyclerView = (SnappyRecyclerView) view.findViewById(R.id.visualizer_recycler);
bufferingIndicator = (AVLoadingIndicatorView) view.findViewById(R.id.bufferingIndicator);
currTime = (TextView) view.findViewById(R.id.currTime);
totalTime = (TextView) view.findViewById(R.id.totalTime);
repeatController = (ImageView) view.findViewById(R.id.repeat_controller);
shuffleController = (ImageView) view.findViewById(R.id.shuffle_controller);
spToolbar = (RelativeLayout) view.findViewById(R.id.smallPlayer_AB);
overflowMenuAB = (ImageView) view.findViewById(R.id.menuIcon);
lyricsContainer = (RelativeLayout) view.findViewById(R.id.lyrics_container);
lyricsIcon = (ImageView) view.findViewById(R.id.lyrics_icon);
lyricsContent = (TextView) view.findViewById(R.id.lyrics_content);
lyricsLoadingIndicator = (AVLoadingIndicatorView) view.findViewById(R.id.lyrics_loading_indicator);
lyricsStatus = (TextView) view.findViewById(R.id.lyrics_status_text);
lyricsIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isLyricsVisisble) {
lyricsIcon.setAlpha(1.0f);
mVisualizerView.setVisibility(View.GONE);
lyricsContainer.setVisibility(View.VISIBLE);
lyricsLoadingIndicator.setVisibility(View.VISIBLE);
lyricsStatus.setText("Searching Lyrics");
lyricsStatus.setVisibility(View.VISIBLE);
if (currentLyrics == null) {
downloadThread = new DownloadThread(PlayerFragment.this, false, selected_track_artist.getText().toString(), selected_track_title.getText().toString());
downloadThread.start();
} else {
onLyricsDownloaded(currentLyrics);
}
} else {
lyricsIcon.setAlpha(0.5f);
lyricsContent.setText("");
lyricsContainer.setVisibility(View.GONE);
mVisualizerView.setVisibility(View.VISIBLE);
}
isLyricsVisisble = !isLyricsVisisble;
}
});
spImgAB = (ImageView) view.findViewById(R.id.selected_track_image_sp_AB);
spImgAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!homeActivity.isPlayerTransitioning && smallPlayer != null) {
homeActivity.hidePlayer();
homeActivity.isPlayerVisible = false;
}
}
});
spTitleAB = (TextView) view.findViewById(R.id.selected_track_title_sp_AB);
spTitleAB.setSelected(true);
spArtistAB = (TextView) view.findViewById(R.id.selected_track_artist_sp_AB);
if (homeActivity.shuffleEnabled) {
shuffleController.setImageResource(R.drawable.ic_shuffle_filled);
} else {
shuffleController.setImageResource(R.drawable.ic_shuffle_alpha);
}
if (homeActivity.repeatEnabled) {
repeatController.setImageResource(R.drawable.ic_repeat_filled);
} else if (homeActivity.repeatOnceEnabled) {
repeatController.setImageResource(R.drawable.ic_repeat_once);
} else {
repeatController.setImageResource(R.drawable.ic_repeat_alpha);
}
repeatController.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (homeActivity.repeatOnceEnabled) {
homeActivity.repeatOnceEnabled = false;
repeatController.setImageResource(R.drawable.ic_repeat_alpha);
} else if (homeActivity.repeatEnabled) {
homeActivity.repeatEnabled = false;
homeActivity.repeatOnceEnabled = true;
repeatController.setImageResource(R.drawable.ic_repeat_once);
} else {
homeActivity.repeatEnabled = true;
repeatController.setImageResource(R.drawable.ic_repeat_filled);
}
}
});
shuffleController.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (homeActivity.shuffleEnabled) {
homeActivity.shuffleEnabled = false;
shuffleController.setImageResource(R.drawable.ic_shuffle_alpha);
mCallback.onShuffleDisabled();
} else {
homeActivity.shuffleEnabled = true;
shuffleController.setImageResource(R.drawable.ic_shuffle_filled);
mCallback.onShuffleEnabled();
}
snappyRecyclerView.scrollToPosition(HomeActivity.queueCurrentIndex);
snappyRecyclerView.setCurrentPosition(HomeActivity.queueCurrentIndex);
customAdapter.notifyDataSetChanged();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
snappyRecyclerView.setTransparency();
}
}, 400);
}
});
equalizerIcon = (ImageView) view.findViewById(R.id.equalizer_icon);
equalizerIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onEqualizerClicked();
}
});
equalizerIcon.setVisibility(View.INVISIBLE);
saveDNAToggle = (ImageView) view.findViewById(R.id.toggleSaveDNA);
if (homeActivity.isSaveDNAEnabled) {
saveDNAToggle.setImageResource(R.drawable.ic_save_filled);
} else {
saveDNAToggle.setImageResource(R.drawable.ic_save_alpha);
}
saveDNAToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (homeActivity.isSaveDNAEnabled) {
homeActivity.isSaveDNAEnabled = false;
saveDNAToggle.setImageResource(R.drawable.ic_save_alpha);
} else {
homeActivity.isSaveDNAEnabled = true;
saveDNAToggle.setImageResource(R.drawable.ic_save_filled);
}
}
});
mainTrackController = (ImageView) view.findViewById(R.id.controller);
nextTrackController = (ImageView) view.findViewById(R.id.next);
previousTrackController = (ImageView) view.findViewById(R.id.previous);
isFav = false;
favouriteIcon = (ImageView) view.findViewById(R.id.fav_icon);
favControllerSp = (ImageView) view.findViewById(R.id.fav_controller_sp);
if (homeActivity.isFavourite) {
favouriteIcon.setImageResource(R.drawable.ic_heart_filled_1);
favControllerSp.setImageResource(R.drawable.ic_heart_filled_1);
isFav = true;
} else {
favouriteIcon.setImageResource(R.drawable.ic_heart_alpha);
favControllerSp.setImageResource(R.drawable.ic_heart_alpha);
isFav = false;
}
favouriteIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isFav) {
favouriteIcon.setImageResource(R.drawable.ic_heart_alpha);
favControllerSp.setImageResource(R.drawable.ic_heart_alpha);
isFav = false;
removeFromFavourite();
} else {
favouriteIcon.setImageResource(R.drawable.ic_heart_filled_1);
favControllerSp.setImageResource(R.drawable.ic_heart_filled_1);
isFav = true;
addToFavourite();
}
new HomeActivity.SaveFavourites().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
favControllerSp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isFav) {
favouriteIcon.setImageResource(R.drawable.ic_heart_alpha);
favControllerSp.setImageResource(R.drawable.ic_heart_alpha);
isFav = false;
removeFromFavourite();
} else {
favouriteIcon.setImageResource(R.drawable.ic_heart_filled_1);
favControllerSp.setImageResource(R.drawable.ic_heart_filled_1);
isFav = true;
addToFavourite();
}
new HomeActivity.SaveFavourites().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
queueIcon = (ImageView) view.findViewById(R.id.queue_icon);
queueIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onQueueClicked();
}
});
selected_track_image = (ImageView) view.findViewById(R.id.selected_track_image_sp);
selected_track_title = (TextView) view.findViewById(R.id.selected_track_title_sp);
selected_track_artist = (TextView) view.findViewById(R.id.selected_track_artist_sp);
player_controller = (ImageView) view.findViewById(R.id.player_control_sp);
nextControllerSp = (ImageView) view.findViewById(R.id.next_controller_sp);
nextControllerSp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mMediaPlayer.pause();
homeActivity.nextControllerClicked = true;
mCallback.onComplete();
}
});
bottomContainer = (RelativeLayout) view.findViewById(R.id.mainControllerContainer);
seekBarContainer = (RelativeLayout) view.findViewById(R.id.seekBarContainer);
toggleContainer = (RelativeLayout) view.findViewById(R.id.toggleContainer);
mVisualizerView = (VisualizerView) view.findViewById(R.id.myvisualizerview);
VisualizerView.w = HomeActivity.screen_width;
VisualizerView.h = HomeActivity.screen_height;
VisualizerView.conf = Bitmap.Config.ARGB_8888;
VisualizerView.bmp = Bitmap.createBitmap(VisualizerView.w, VisualizerView.h, VisualizerView.conf);
HomeActivity.cacheCanvas = new Canvas(VisualizerView.bmp);
if (HomeActivity.queue != null) {
customAdapter = new CustomAdapter(getContext(), snappyRecyclerView, HomeActivity.queue.getQueue());
} else {
customAdapter = new CustomAdapter(getContext(), snappyRecyclerView, new ArrayList<UnifiedTrack>());
}
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
snappyRecyclerView.setLayoutManager(linearLayoutManager);
snappyRecyclerView.setItemAnimator(new DefaultItemAnimator());
snappyRecyclerView.setAdapter(customAdapter);
snappyRecyclerView.setActivity(homeActivity);
snappyRecyclerView.addOnItemTouchListener(new ClickItemTouchListener(snappyRecyclerView) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
return false;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, int position, long id) {
if (homeActivity.isFullScreenEnabled) {
homeActivity.isFullScreenEnabled = false;
bottomContainer.setVisibility(View.VISIBLE);
seekBarContainer.setVisibility(View.VISIBLE);
toggleContainer.setVisibility(View.VISIBLE);
spToolbar.setVisibility(View.VISIBLE);
mCallback.onFullScreen();
} else {
homeActivity.isFullScreenEnabled = true;
bottomContainer.setVisibility(View.GONE);
seekBarContainer.setVisibility(View.GONE);
toggleContainer.setVisibility(View.GONE);
spToolbar.setVisibility(View.INVISIBLE);
mCallback.onFullScreen();
}
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
cpb = (CustomProgressBar) view.findViewById(R.id.customProgress);
smallPlayer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onSmallPlayerTouched();
}
});
track = homeActivity.selectedTrack;
localTrack = homeActivity.localSelectedTrack;
if (homeActivity.streamSelected) {
try {
durationInMilliSec = track.getDuration();
} catch (Exception e) {
}
if (track.getArtworkURL() != null) {
Picasso.with(getActivity()).load(track.getArtworkURL()).resize(100, 100).into(selected_track_image);
} else {
selected_track_image.setImageResource(R.drawable.ic_default);
}
try {
spTitleAB.setText(track.getTitle());
selected_track_title.setText(track.getTitle());
selected_track_artist.setText("");
spArtistAB.setText("");
} catch (Exception e) {
}
} else {
try {
durationInMilliSec = (int) localTrack.getDuration();
} catch (Exception e) {
}
try {
imgLoader.DisplayImage(localTrack.getPath(), selected_track_image);
} catch (Exception e) {
}
try {
spTitleAB.setText(localTrack.getTitle());
selected_track_title.setText(localTrack.getTitle());
selected_track_artist.setText(localTrack.getArtist());
spArtistAB.setText(localTrack.getArtist());
} catch (Exception e) {
}
}
temp = getTime(durationInMilliSec);
totalTime.setText(temp.first + ":" + temp.second);
homeActivity.mWifi = homeActivity.connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
try {
if (homeActivity.streamSelected) {
if ((homeActivity.settings.isStreamOnlyOnWifiEnabled() && homeActivity.mWifi.isConnected()) || !homeActivity.settings.isStreamOnlyOnWifiEnabled()) {
isPrepared = false;
mMediaPlayer.reset();
mMediaPlayer.setDataSource(track.getStreamURL() + "?client_id=" + Config.CLIENT_ID);
mMediaPlayer.prepareAsync();
} else {
mMediaPlayer.pause();
homeActivity.nextControllerClicked = true;
mCallback.onComplete();
}
} else {
isPrepared = false;
mMediaPlayer.reset();
File f = new File(localTrack.getPath());
if (f.exists()) {
mMediaPlayer.setDataSource(localTrack.getPath());
mMediaPlayer.prepareAsync();
} else {
Toast.makeText(getContext(), "Error playing " + localTrack.getTitle() + ". Skipping to next track", Toast.LENGTH_SHORT).show();
mMediaPlayer.pause();
homeActivity.nextControllerClicked = true;
mCallback.onComplete();
}
}
bufferingIndicator.setVisibility(View.VISIBLE);
mainTrackController.setVisibility(View.GONE);
} catch (Exception e) {
e.printStackTrace();
}
overflowMenuAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popMenu = new PopupMenu(getContext(), overflowMenuAB);
popMenu.getMenuInflater().inflate(R.menu.player_overflow_menu, popMenu.getMenu());
popMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getTitle().equals("Full Screen")) {
if (homeActivity.isFullScreenEnabled) {
homeActivity.isFullScreenEnabled = false;
bottomContainer.setVisibility(View.VISIBLE);
seekBarContainer.setVisibility(View.VISIBLE);
toggleContainer.setVisibility(View.VISIBLE);
spToolbar.setVisibility(View.VISIBLE);
mCallback.onFullScreen();
} else {
homeActivity.isFullScreenEnabled = true;
bottomContainer.setVisibility(View.GONE);
seekBarContainer.setVisibility(View.GONE);
toggleContainer.setVisibility(View.GONE);
spToolbar.setVisibility(View.INVISIBLE);
mCallback.onFullScreen();
}
} else if (item.getTitle().equals("Settings")) {
mCallback.onSettingsClicked();
} else if (item.getTitle().equals("Add to playlist")) {
UnifiedTrack ut = HomeActivity.queue.getQueue().get(HomeActivity.queueCurrentIndex);
mCallback.addCurrentSongtoPlaylist(ut);
}
return true;
}
});
popMenu.show();
}
});
player_controller.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isReplayIconVisible) {
homeActivity.hasQueueEnded = true;
mCallback.onComplete();
} else {
if (!pauseClicked) {
pauseClicked = true;
}
togglePlayPause();
}
}
});
mainTrackController.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isReplayIconVisible) {
homeActivity.hasQueueEnded = true;
mCallback.onComplete();
} else {
if (!pauseClicked) {
pauseClicked = true;
}
togglePlayPause();
}
}
});
nextTrackController.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mMediaPlayer.pause();
homeActivity.nextControllerClicked = true;
mCallback.onComplete();
}
});
previousTrackController.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (homeActivity.queueCurrentIndex != 0) {
mMediaPlayer.pause();
mCallback.onPreviousTrack();
}
}
});
progressBar = (SeekBar) view.findViewById(R.id.progressBar);
progressBar.setMax(durationInMilliSec);
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
if (isPrepared && !isTracking && getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
float[] hsv = new float[3];
hsv[0] = homeActivity.seekBarColor;
hsv[1] = (float) 0.8;
hsv[2] = (float) 0.5;
progressBar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(Color.HSVToColor(hsv), PorterDuff.Mode.SRC_IN));
cpb.update();
}
});
try {
temp = getTime(mMediaPlayer.getCurrentPosition());
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
currTime.setText(temp.first + ":" + temp.second);
}
});
progressBar.setProgress(mMediaPlayer.getCurrentPosition());
} catch (Exception e) {
Log.e("MEDIA", e.getMessage() + ":");
}
}
}
}, 0, 50);
progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
temp = getTime(progress);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
currTime.setText(temp.first + ":" + temp.second);
}
});
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
isTracking = true;
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
mMediaPlayer.seekTo(seekBar.getProgress());
if (mMediaPlayer.isPlaying())
mMediaPlayer.start();
isTracking = false;
}
});
final Button mEndButton = new Button(getContext());
mEndButton.setBackgroundColor(homeActivity.themeColor);
mEndButton.setTextColor(Color.WHITE);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(2).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(homeActivity.tp).setTarget(new ViewTarget(mVisualizerView.getId(), getActivity())).setContentTitle("The DNA").setContentText("The DNA of the currently playing song.").build();
showCase.setButtonText("Next");
showCase.setButtonPosition(homeActivity.lps);
showCase.overrideButtonClick(new View.OnClickListener() {
int count1 = -1;
@Override
public void onClick(View v) {
count1++;
switch(count1) {
case 0:
showCase.setTarget(new ViewTarget(mVisualizerView.getId(), getActivity()));
showCase.setContentTitle("The DNA");
showCase.setContentText("Swipe Left or Right to change Song." + "Long Press for fullscreen");
showCase.setButtonPosition(homeActivity.lps);
showCase.setButtonText("Next");
break;
case 1:
showCase.setTarget(new ViewTarget(R.id.toggleContainer, getActivity()));
showCase.setContentTitle("The Controls");
showCase.setContentText("Equalizer \n" + "Save DNA toggle\n" + "Add to Favourites \n" + "Queue");
showCase.setButtonPosition(homeActivity.lps);
showCase.setButtonText("Done");
break;
case 2:
showCase.setTarget(new ViewTarget(R.id.lyrics_icon, getActivity()));
showCase.setContentTitle("Lyrics");
showCase.setContentText("Get lyrics by tapping this icon");
showCase.setButtonPosition(homeActivity.lps);
showCase.setButtonText("Done");
break;
case 3:
showCase.hide();
break;
}
}
});
}
}, 500);
}
use of com.github.amlcurran.showcaseview.targets.ViewTarget in project MusicDNA by harjot-oberai.
the class QueueFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
backBtn = (ImageView) view.findViewById(R.id.queue_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
fragTitle = (TextView) view.findViewById(R.id.queue_fragment_title);
if (SplashActivity.tf4 != null)
fragTitle.setTypeface(SplashActivity.tf4);
clearText = (TextView) view.findViewById(R.id.queue_clear_text);
clearText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onQueueClear();
}
});
queueRecycler = (RecyclerView) view.findViewById(R.id.queueRecycler);
qAdapter = new QueueRecyclerAdapter(HomeActivity.queue.getQueue(), getContext(), this);
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
queueRecycler.setLayoutManager(mLayoutManager2);
queueRecycler.setItemAnimator(new DefaultItemAnimator());
queueRecycler.setAdapter(qAdapter);
queueRecycler.addOnItemTouchListener(new ClickItemTouchListener(queueRecycler) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
mCallback.onQueueItemClicked(position);
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, int position, long id) {
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
saveQueue = (FloatingActionButton) view.findViewById(R.id.save_queue);
saveQueue.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
saveQueue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onQueueSave();
}
});
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(qAdapter);
mItemTouchHelper = new ItemTouchHelper(callback);
mItemTouchHelper.attachToRecyclerView(queueRecycler);
Button mEndButton = new Button(getContext());
mEndButton.setBackgroundColor(HomeActivity.themeColor);
mEndButton.setTextColor(Color.WHITE);
showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(3).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(HomeActivity.tp).setTarget(new ViewTarget(R.id.queue_alt_showcase, getActivity())).setContentTitle("Queue").setContentText("Here all songs that are currently in queue are listed." + " Use handle to reorder the Queue and swipe the song to remove from queue").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.setButtonPosition(lps);
showCase.setTarget(new ViewTarget(saveQueue.getId(), getActivity()));
showCase.setContentTitle("Save Queue");
showCase.setContentText("Save the queue as a playlist");
showCase.setButtonText("Done");
break;
case 2:
showCase.hide();
break;
}
}
});
}
use of com.github.amlcurran.showcaseview.targets.ViewTarget in project MusicDNA by harjot-oberai.
the class HomeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
screen_width = display.getWidth();
screen_height = display.getHeight();
ratio = (float) screen_height / (float) 1920;
ratio2 = (float) screen_width / (float) 1080;
ratio = Math.min(ratio, ratio2);
setContentView(R.layout.activity_home);
headSetReceiver = new HeadSetReceiver();
IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
registerReceiver(headSetReceiver, filter);
PackageInfo pInfo;
try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionName = pInfo.versionName;
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
mEndButton = new Button(this);
mEndButton.setBackgroundColor(themeColor);
mEndButton.setTextColor(Color.WHITE);
tp = new TextPaint();
tp.setColor(themeColor);
tp.setTextSize(65 * ratio);
tp.setFakeBoldText(true);
recentsViewAll = (TextView) findViewById(R.id.recents_view_all);
recentsViewAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("recent");
}
});
playlistsViewAll = (TextView) findViewById(R.id.playlists_view_all);
playlistsViewAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("allPlaylists");
}
});
copyrightText = (TextView) findViewById(R.id.copyright_text);
copyrightText.setText("Music DNA v" + versionName);
if (SplashActivity.tf4 != null) {
try {
copyrightText.setTypeface(SplashActivity.tf4);
} catch (Exception e) {
e.printStackTrace();
}
}
imgLoader = new ImageLoader(this);
ctx = this;
initializeHeaderImages();
hasSoftNavbar = CommonUtils.hasNavBar(this);
statusBarHeightinDp = CommonUtils.getStatusBarHeight(this);
navBarHeightSizeinDp = hasSoftNavbar ? CommonUtils.getNavBarHeight(this) : 0;
serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
// cast the IBinder and get MyService instance
MediaPlayerService.LocalBinder binder = (MediaPlayerService.LocalBinder) service;
myService = binder.getService();
bound = true;
// register
myService.setCallbacks(HomeActivity.this);
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
bound = false;
}
};
minuteList = new ArrayList<>();
for (int i = 1; i < 25; i++) {
minuteList.add(String.valueOf(i * 5));
}
sleepHandler = new Handler();
lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
lps.setMargins(margin, margin, margin, navBarHeightSizeinDp + ((Number) (getResources().getDisplayMetrics().density * 5)).intValue());
fragMan = getSupportFragmentManager();
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
if (SplashActivity.tf4 != null) {
collapsingToolbar.setCollapsedTitleTypeface(SplashActivity.tf4);
collapsingToolbar.setExpandedTitleTypeface(SplashActivity.tf4);
}
customLinearGradient = (CustomLinearGradient) findViewById(R.id.custom_linear_gradient);
customLinearGradient.setAlpha(170);
customLinearGradient.invalidate();
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
navigationView = (NavigationView) findViewById(R.id.nav_view);
if (navigationView != null) {
navigationView.setNavigationItemSelectedListener(this);
}
navigationView.setCheckedItem(R.id.nav_home);
View header = navigationView.getHeaderView(0);
navImageView = (ImageView) header.findViewById(R.id.nav_image_view);
if (navImageView != null) {
navImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PlayerFragment pFrag = getPlayerFragment();
if (pFrag != null) {
if (pFrag.mMediaPlayer != null && pFrag.mMediaPlayer.isPlaying()) {
onBackPressed();
isPlayerVisible = true;
// hideTabs();
showPlayer();
}
}
}
});
}
connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
PlayerFragment pFrag = playerFragment;
if (playerFragment != null) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
//Incoming call: Pause music
if (pFrag.mMediaPlayer != null && pFrag.mMediaPlayer.isPlaying()) {
wasMediaPlayerPlaying = true;
pFrag.togglePlayPause();
} else {
wasMediaPlayerPlaying = false;
}
} else if (state == TelephonyManager.CALL_STATE_IDLE) {
//Not in call: Play music
if (pFrag.mMediaPlayer != null && !pFrag.mMediaPlayer.isPlaying() && wasMediaPlayerPlaying) {
pFrag.togglePlayPause();
}
} else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
//A call is dialing, active or on hold
if (playerFragment.mMediaPlayer != null && pFrag.mMediaPlayer.isPlaying()) {
wasMediaPlayerPlaying = true;
pFrag.togglePlayPause();
} else {
wasMediaPlayerPlaying = false;
}
}
}
super.onCallStateChanged(state, incomingNumber);
}
};
TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if (mgr != null) {
mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
mPrefs = getPreferences(MODE_PRIVATE);
prefsEditor = mPrefs.edit();
gson = new Gson();
main = this;
localBanner = (RelativeLayout) findViewById(R.id.localBanner);
favBanner = (ImageView) findViewById(R.id.favBanner);
recentBanner = (ImageView) findViewById(R.id.recentBanner);
folderBanner = (ImageView) findViewById(R.id.folderBanner);
savedDNABanner = (ImageView) findViewById(R.id.savedDNABanner);
localBannerPlayAll = (ImageView) findViewById(R.id.local_banner_play_all);
localBanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("local");
}
});
favBanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("favourite");
}
});
recentBanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("recent");
}
});
folderBanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("allFolders");
}
});
savedDNABanner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("allSavedDNAs");
}
});
localBannerPlayAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
queue.getQueue().clear();
for (int i = 0; i < localTrackList.size(); i++) {
UnifiedTrack ut = new UnifiedTrack(true, localTrackList.get(i), null);
queue.getQueue().add(ut);
}
if (queue.getQueue().size() > 0) {
Random r = new Random();
int tmp = r.nextInt(queue.getQueue().size());
queueCurrentIndex = tmp;
LocalTrack track = localTrackList.get(tmp);
localSelectedTrack = track;
streamSelected = false;
localSelected = true;
queueCall = false;
isReloaded = false;
onLocalTrackSelected(-1);
}
}
});
bottomToolbar = (FrameLayout) findViewById(R.id.bottomMargin);
spHome = (Toolbar) findViewById(R.id.smallPlayer_home);
playerControllerHome = (ImageView) findViewById(R.id.player_control_sp_home);
spImgHome = (CircleImageView) findViewById(R.id.selected_track_image_sp_home);
spTitleHome = (TextView) findViewById(R.id.selected_track_title_sp_home);
playerControllerHome.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (queue != null && queue.getQueue().size() > 0) {
onQueueItemClicked(queueCurrentIndex);
bottomToolbar.setVisibility(View.INVISIBLE);
}
}
});
playerControllerHome.setImageResource(R.drawable.ic_play_arrow_white_48dp);
spHome.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (queue != null && queue.getQueue().size() > 0) {
onQueueItemClicked(queueCurrentIndex);
bottomToolbar.setVisibility(View.INVISIBLE);
}
}
});
localRecyclerContainer = (RelativeLayout) findViewById(R.id.localRecyclerContainer);
recentsRecyclerContainer = (RelativeLayout) findViewById(R.id.recentsRecyclerContainer);
streamRecyclerContainer = (RelativeLayout) findViewById(R.id.streamRecyclerContainer);
playlistRecyclerContainer = (RelativeLayout) findViewById(R.id.playlistRecyclerContainer);
if (SplashActivity.tf4 != null) {
try {
((TextView) findViewById(R.id.playListRecyclerLabel)).setTypeface(SplashActivity.tf4);
((TextView) findViewById(R.id.recentsRecyclerLabel)).setTypeface(SplashActivity.tf4);
} catch (Exception e) {
e.printStackTrace();
}
}
localNothingText = (TextView) findViewById(R.id.localNothingText);
streamNothingText = (TextView) findViewById(R.id.streamNothingText);
recentsNothingText = (TextView) findViewById(R.id.recentsNothingText);
playlistNothingText = (TextView) findViewById(R.id.playlistNothingText);
localViewAll = (TextView) findViewById(R.id.localViewAll);
localViewAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("local");
}
});
streamViewAll = (TextView) findViewById(R.id.streamViewAll);
streamViewAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFragment("stream");
}
});
progress = new Dialog(ctx);
progress.setCancelable(false);
progress.requestWindowFeature(Window.FEATURE_NO_TITLE);
progress.setContentView(R.layout.custom_progress_dialog);
progress.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
progress.show();
showCase = new ShowcaseView.Builder(this).blockAllTouches().singleShot(0).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(tp).setTarget(new ViewTarget(R.id.recentsRecyclerLabel, this)).setContentTitle("Recents and Playlists").setContentText("Here all you recent songs and playlists will be listed." + "Long press the cards or playlists for more options \n" + "\n" + "(Press Next to continue / Press back to Hide)").build();
showCase.setButtonText("Next");
showCase.setButtonPosition(lps);
showCase.overrideButtonClick(new View.OnClickListener() {
int count1 = 0;
@Override
public void onClick(View v) {
count1++;
switch(count1) {
case 1:
showCase.setTarget(new ViewTarget(R.id.local_banner_alt_showcase, (Activity) ctx));
showCase.setContentTitle("Local Songs");
showCase.setContentText("See all songs available locally, classified on basis of Artist and Album");
showCase.setButtonPosition(lps);
showCase.setButtonText("Next");
break;
case 2:
showCase.setTarget(new ViewTarget(searchView.getId(), (Activity) ctx));
showCase.setContentTitle("Search");
showCase.setContentText("Search for songs from local library and SoundCloud™");
showCase.setButtonPosition(lps);
showCase.setButtonText("Done");
break;
case 3:
showCase.hide();
break;
}
}
});
new loadSavedData().execute();
}
use of com.github.amlcurran.showcaseview.targets.ViewTarget in project MusicDNA by harjot-oberai.
the class ViewSavedDNA method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
backBtn = (ImageView) view.findViewById(R.id.view_saved_dna_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
fragmentTitle = (TextView) view.findViewById(R.id.view_saved_dna_fragment_title);
if (SplashActivity.tf4 != null)
fragmentTitle.setTypeface(SplashActivity.tf4);
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
mVisualizerView2 = (VisualizerView2) view.findViewById(R.id.saved_dna_visualizer);
viewDnaRecycler = (RecyclerView) view.findViewById(R.id.saved_dna_recycler);
noSavedContent = (LinearLayout) view.findViewById(R.id.no_saved_dnas);
if (SplashActivity.tf4 != null)
((TextView) view.findViewById(R.id.no_saved_content_text)).setTypeface(SplashActivity.tf4);
if (HomeActivity.savedDNAs == null || HomeActivity.savedDNAs.getSavedDNAs().size() == 0) {
noSavedContent.setVisibility(View.VISIBLE);
mVisualizerView2.setVisibility(View.INVISIBLE);
viewDnaRecycler.setVisibility(View.INVISIBLE);
} else {
noSavedContent.setVisibility(View.GONE);
mVisualizerView2.setVisibility(View.VISIBLE);
viewDnaRecycler.setVisibility(View.VISIBLE);
}
if (HomeActivity.savedDNAs != null)
vdAdapter = new ViewSavedDnaRecyclerAdapter(HomeActivity.savedDNAs.getSavedDNAs(), getContext(), this);
else
vdAdapter = new ViewSavedDnaRecyclerAdapter(new ArrayList<SavedDNA>(), getContext(), this);
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
viewDnaRecycler.setLayoutManager(mLayoutManager2);
viewDnaRecycler.setItemAnimator(new DefaultItemAnimator());
viewDnaRecycler.setAdapter(vdAdapter);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (HomeActivity.savedDNAs.getSavedDNAs().size() > 0) {
SavedDNA dna = HomeActivity.savedDNAs.getSavedDNAs().get(selectedDNA);
selectedDNA = 0;
HomeActivity.tempSavedDNA = dna;
Bitmap bmp = bitmapFromBase64String(dna.getBase64encodedBitmap());
mVisualizerView2.setBmp(bmp);
mVisualizerView2.update();
}
}
}, 350);
viewDnaRecycler.addOnItemTouchListener(new ClickItemTouchListener(viewDnaRecycler) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
vdAdapter.notifyItemChanged(selectedDNA);
selectedDNA = position;
vdAdapter.notifyItemChanged(selectedDNA);
SavedDNA dna = HomeActivity.savedDNAs.getSavedDNAs().get(position);
selectedDNA = position;
HomeActivity.tempSavedDNA = dna;
Bitmap bmp = bitmapFromBase64String(dna.getBase64encodedBitmap());
mVisualizerView2.setBmp(bmp);
mVisualizerView2.update();
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
PopupMenu popup = new PopupMenu(getContext(), view);
popup.getMenuInflater().inflate(R.menu.save_dna_popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getTitle().equals("View")) {
vdAdapter.notifyItemChanged(selectedDNA);
selectedDNA = position;
vdAdapter.notifyItemChanged(selectedDNA);
SavedDNA dna = HomeActivity.savedDNAs.getSavedDNAs().get(position);
selectedDNA = position;
HomeActivity.tempSavedDNA = dna;
Bitmap bmp = bitmapFromBase64String(dna.getBase64encodedBitmap());
mVisualizerView2.setBmp(bmp);
mVisualizerView2.update();
} else if (item.getTitle().equals("Delete")) {
HomeActivity.savedDNAs.getSavedDNAs().remove(position);
vdAdapter.notifyItemRemoved(position);
if (position == selectedDNA) {
if (position > 0) {
selectedDNA = position - 1;
} else if (position == 0) {
if (HomeActivity.savedDNAs.getSavedDNAs().size() == 0) {
noSavedContent.setVisibility(View.VISIBLE);
new HomeActivity.SaveTheDNAs().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return true;
} else {
selectedDNA = 0;
}
}
SavedDNA dna = HomeActivity.savedDNAs.getSavedDNAs().get(selectedDNA);
HomeActivity.tempSavedDNA = dna;
Bitmap bmp = bitmapFromBase64String(dna.getBase64encodedBitmap());
mVisualizerView2.setBmp(bmp);
mVisualizerView2.update();
}
new HomeActivity.SaveTheDNAs().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
return true;
}
});
popup.show();
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
shareIcon = (ImageView) view.findViewById(R.id.share_icon);
saveToStorageIcon = (ImageView) view.findViewById(R.id.save_to_storage_icon);
shareIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (HomeActivity.tempSavedDNA != null) {
showDialog(1);
}
}
});
saveToStorageIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (HomeActivity.tempSavedDNA != null) {
showDialog(0);
}
}
});
Button mEndButton = new Button(getContext());
mEndButton.setBackgroundColor(HomeActivity.themeColor);
mEndButton.setTextColor(Color.WHITE);
if (HomeActivity.savedDNAs.getSavedDNAs().size() > 0) {
showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(5).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(HomeActivity.tp).setTarget(new ViewTarget(R.id.visualizer_alt_showcase, getActivity())).setContentTitle("Saved DNAs").setContentText("View all your saved DNAs here").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:
showCase.setTarget(new ViewTarget(shareIcon.getId(), getActivity()));
showCase.setContentTitle("Share DNA");
showCase.setContentText("Share the DNA as an image with your friends");
showCase.setButtonPosition(HomeActivity.lps);
showCase.setButtonText("Next");
break;
case 2:
showCase.setTarget(new ViewTarget(saveToStorageIcon.getId(), getActivity()));
showCase.setContentTitle("Save DNA");
showCase.setContentText("Save the DNA as an image to your internal storage");
showCase.setButtonPosition(HomeActivity.lps);
showCase.setButtonText("Done");
break;
case 3:
showCase.hide();
break;
}
}
});
}
}
use of com.github.amlcurran.showcaseview.targets.ViewTarget 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;
}
}
});
}
Aggregations