Skip to content

Commit

Permalink
Adds Save Queue option
Browse files Browse the repository at this point in the history
  • Loading branch information
harjot-oberai committed May 21, 2016
1 parent 310c2d4 commit 11633f2
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 3 deletions.
41 changes: 39 additions & 2 deletions app/src/main/java/com/sdsmdg/harjot/MusicDNA/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public class HomeActivity extends AppCompatActivity
ViewPlaylistFragment.onPLaylistItemClickedListener,
FavouritesFragment.onFavouriteItemClickedListener,
ViewPlaylistFragment.onPlaylistPlayAllListener,
FavouritesFragment.onFavouritePlayAllListener{
FavouritesFragment.onFavouritePlayAllListener,
QueueFragment.onQueueSaveListener {

public static List<LocalTrack> localTrackList = new ArrayList<>();
public static List<LocalTrack> finalLocalSearchResultList = new ArrayList<>();
Expand Down Expand Up @@ -1850,6 +1851,11 @@ public void onFavouritePlayAll() {
showFragment("queue");
}

@Override
public void onQueueSave() {
showSaveQueueDialog();
}

public static class MyAsyncTask extends AsyncTask<Void, Void, Void> {

@Override
Expand Down Expand Up @@ -1969,6 +1975,37 @@ public void onClick(View v) {
dialog.show();
}

public void showSaveQueueDialog() {
final Dialog dialog = new Dialog(ctx);
dialog.setContentView(R.layout.add_to_playlist_dialog);
dialog.setTitle("Save Queue");

ListView lv = (ListView) dialog.findViewById(R.id.playlist_list);
lv.setVisibility(View.GONE);

// set the custom dialog components - text, image and button
final EditText text = (EditText) dialog.findViewById(R.id.new_playlist_name);
ImageView image = (ImageView) dialog.findViewById(R.id.confirm_button);
// if button is clicked, close the custom dialog
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (text.getText().toString().trim().equals("")) {
text.setError("Enter Playlist Name!");
} else {
Playlist pl = new Playlist(text.getText().toString());
pl.setSongList(queue.getQueue());
allPlaylists.addPlaylist(pl);
playlistsRecycler.setVisibility(View.VISIBLE);
playlistNothingText.setVisibility(View.INVISIBLE);
pAdapter.notifyDataSetChanged();
dialog.dismiss();
}
}
});
dialog.show();
}

public void logQueue() {
Log.d("QUEUE", "ENTERED");
for (int i = 0; i < queue.getQueue().size(); i++) {
Expand Down Expand Up @@ -2015,6 +2052,7 @@ public void showFragment(String type) {
android.app.FragmentManager fm = getFragmentManager();
QueueFragment newFragment = new QueueFragment();
QueueFragment.mCallback = this;
QueueFragment.mCallback2 = this;
fm.beginTransaction()
.setCustomAnimations(R.animator.slide_up,
R.animator.slide_down,
Expand Down Expand Up @@ -2060,7 +2098,6 @@ public void showFragment(String type) {
isEqualizerVisible = true;
android.app.FragmentManager fm = getFragmentManager();
EqualizerFragment newFragment = new EqualizerFragment();
// QueueFragment.mCallback = this;
fm.beginTransaction()
.setCustomAnimations(R.animator.slide_up,
R.animator.slide_down,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public class Playlist {
private List<UnifiedTrack> songList;
private String playlistName;

public Playlist(String name){
playlistName = name;
}

public Playlist(List<UnifiedTrack> songList, String playlistName) {
this.songList = songList;
this.playlistName = playlistName;
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/sdsmdg/harjot/MusicDNA/QueueFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand All @@ -30,12 +31,19 @@ public class QueueFragment extends Fragment implements QueueRecyclerAdapter.OnDr

static ItemTouchHelper mItemTouchHelper;

FloatingActionButton saveQueue;

static onQueueItemClickedListener mCallback;
static onQueueSaveListener mCallback2;

public interface onQueueItemClickedListener {
public void onQueueItemClicked(int position);
}

public interface onQueueSaveListener{
public void onQueueSave();
}

public QueueFragment() {
// Required empty public constructor
}
Expand Down Expand Up @@ -87,6 +95,14 @@ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});

saveQueue = (FloatingActionButton) view.findViewById(R.id.save_queue);
saveQueue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback2.onQueueSave();
}
});

ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(qAdapter);
mItemTouchHelper = new ItemTouchHelper(callback);
mItemTouchHelper.attachToRecyclerView(queueRecycler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface onPLaylistItemClickedListener {
public void onPLaylistItemClicked(int position);
}

public interface onPlaylistPlayAllListener{
public interface onPlaylistPlayAllListener {
public void onPlaylistPLayAll();
}

Expand Down Expand Up @@ -111,4 +111,5 @@ public void onClick(View v) {
mItemTouchHelper.attachToRecyclerView(playlistRecyler);

}

}
Binary file added app/src/main/res/drawable/ic_save_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions app/src/main/res/layout/fragment_queue.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEE"
Expand All @@ -12,6 +13,21 @@
android:layout_height="match_parent"
android:layout_above="@+id/bottomLinear"></android.support.v7.widget.RecyclerView>

<android.support.design.widget.FloatingActionButton
android:id="@+id/save_queue"
android:layout_above="@+id/bottomLinear"
android:clickable="true"
app:backgroundTint="#111111"
app:borderWidth="0dp"
app:elevation="6dp"
app:pressedTranslationZ="9dp"
app:rippleColor="#888888"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/ic_save_white"/>

<LinearLayout
android:id="@+id/bottomLinear"
android:layout_width="match_parent"
Expand Down

0 comments on commit 11633f2

Please sign in to comment.