Code rearanged
This commit is contained in:
parent
00e3724ab4
commit
6aaf926ff7
27 changed files with 107 additions and 158 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package com.kabouzeid.gramophone;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.res.Configuration;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.android.volley.Request;
|
||||
|
|
@ -12,7 +11,6 @@ import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
|||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.ThreadEnforcer;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class PlaylistSongAdapter extends RecyclerView.Adapter<PlaylistSongAdapte
|
|||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MusicPlayerRemote.openQueue((List<Song>) (List)dataSet, getAdapterPosition(), true);
|
||||
MusicPlayerRemote.openQueue((List<Song>) (List) dataSet, getAdapterPosition(), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class AddToPlaylistDialogHelper {
|
|||
CharSequence[] playlistNames = new CharSequence[playlists.size() + 1];
|
||||
playlistNames[0] = context.getResources().getString(R.string.action_new_playlist);
|
||||
for (int i = 1; i < playlistNames.length; i++) {
|
||||
playlistNames[i] = playlists.get(i-1).name;
|
||||
playlistNames[i] = playlists.get(i - 1).name;
|
||||
}
|
||||
return new MaterialDialog.Builder(context)
|
||||
.items(playlistNames)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ public class CreatePlaylistDialogHelper {
|
|||
public static MaterialDialog getDialog(final Context context, final List<Song> songs) {
|
||||
final EditText editText = new EditText(context);
|
||||
ViewGroup layout = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.dialog_empty_frame, null);
|
||||
if (editText.getParent() != null) {((ViewGroup) editText.getParent()).removeView(editText);}
|
||||
if (editText.getParent() != null) {
|
||||
((ViewGroup) editText.getParent()).removeView(editText);
|
||||
}
|
||||
layout.addView(editText, new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
return new MaterialDialog.Builder(context)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
|||
* Created by karim on 19.03.15.
|
||||
*/
|
||||
public class DeletePlaylistDialogHelper {
|
||||
public static MaterialDialog getDialog(final Context context, final int playlistId){
|
||||
public static MaterialDialog getDialog(final Context context, final int playlistId) {
|
||||
return new MaterialDialog.Builder(context)
|
||||
.title(context.getResources().getString(R.string.delete_playlist) + PlaylistsUtil.getNameForPlaylist(context, playlistId))
|
||||
.positiveText(context.getResources().getString(R.string.ok))
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ public class MusicPlayerRemote {
|
|||
}
|
||||
|
||||
public static void moveSong(int from, int to) {
|
||||
if(musicService != null){
|
||||
if (musicService != null) {
|
||||
musicService.moveSong(from, to);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ import android.app.TaskStackBuilder;
|
|||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
|
|
@ -21,9 +19,7 @@ import com.kabouzeid.gramophone.model.Song;
|
|||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
import com.kabouzeid.gramophone.ui.activities.MusicControllerActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.squareup.picasso.MemoryPolicy;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Target;
|
||||
|
||||
public class PlayingNotificationHelper {
|
||||
public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
|
||||
|
|
@ -165,7 +161,9 @@ public class PlayingNotificationHelper {
|
|||
notificationLayout.setImageViewResource(R.id.album_art, R.drawable.default_album_art);
|
||||
notificationLayoutExpanded.setImageViewResource(R.id.album_art, R.drawable.default_album_art);
|
||||
notificationManager.notify(NOTIFICATION_ID, notification);
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public void killNotification() {
|
||||
service.stopForeground(true);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import com.afollestad.materialdialogs.MaterialDialog;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.PlayingQueueAdapter;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
import com.mobeta.android.dslv.DragSortListView;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class LastFMAlbumInfoUtil {
|
|||
public static void downloadAlbumInfoJSON(final Context context, final String album, final String artist, final Response.Listener<JSONObject> callbackSuccess, final Response.ErrorListener callbackError) {
|
||||
App app = (App) context.getApplicationContext();
|
||||
String albumUrl = LastFMAlbumInfoUtil.getAlbumUrl(album, artist);
|
||||
JsonObjectRequest albumInfoJSONRequest = new JsonObjectRequest(0, albumUrl, (JSONObject)null, new Response.Listener<JSONObject>() {
|
||||
JsonObjectRequest albumInfoJSONRequest = new JsonObjectRequest(0, albumUrl, (JSONObject) null, new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
LastFMAlbumInfoUtil.saveAlbumJSONDataToCacheAndDisk(context, album, artist, response);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class LastFMArtistBiographyLoader {
|
|||
private static void downloadArtistBio(final Context context, final String artist, final ArtistBioLoaderCallback callback) {
|
||||
App app = (App) context.getApplicationContext();
|
||||
String artistUrl = LastFMArtistInfoUtil.getArtistUrl(artist);
|
||||
JsonObjectRequest artistInfoJSONRequest = new JsonObjectRequest(0, artistUrl, (JSONObject)null, new Response.Listener<JSONObject>() {
|
||||
JsonObjectRequest artistInfoJSONRequest = new JsonObjectRequest(0, artistUrl, (JSONObject) null, new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
LastFMArtistInfoUtil.saveArtistJSONDataToCacheAndDisk(context, artist, response);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class LastFMArtistInfoUtil {
|
|||
public static void downloadArtistJSON(final Context context, final String artist, final Response.Listener<JSONObject> callback) {
|
||||
App app = (App) context.getApplicationContext();
|
||||
String artistUrl = LastFMArtistInfoUtil.getArtistUrl(artist);
|
||||
JsonObjectRequest artistInfoJSONRequest = new JsonObjectRequest(0, artistUrl, (JSONObject)null, new Response.Listener<JSONObject>() {
|
||||
JsonObjectRequest artistInfoJSONRequest = new JsonObjectRequest(0, artistUrl, (JSONObject) null, new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
LastFMArtistInfoUtil.saveArtistJSONDataToCacheAndDisk(context, artist, response);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package com.kabouzeid.gramophone.lastfm.artist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.kabouzeid.gramophone.provider.ArtistJSONStore;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Target;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class AlbumLoader {
|
|||
}
|
||||
|
||||
public static List<Album> getAlbums(Context context, String query) {
|
||||
Cursor cursor = makeAlbumCursor(context, MediaStore.Audio.AlbumColumns.ALBUM + " LIKE ?", new String[]{"%"+query+"%"});
|
||||
Cursor cursor = makeAlbumCursor(context, MediaStore.Audio.AlbumColumns.ALBUM + " LIKE ?", new String[]{"%" + query + "%"});
|
||||
List<Album> albums = new ArrayList<>();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ArtistLoader {
|
|||
}
|
||||
|
||||
public static List<Artist> getArtists(Context context, String query) {
|
||||
Cursor cursor = makeArtistCursor(context, MediaStore.Audio.ArtistColumns.ARTIST + " LIKE ?", new String[]{"%"+query+"%"});
|
||||
Cursor cursor = makeArtistCursor(context, MediaStore.Audio.ArtistColumns.ARTIST + " LIKE ?", new String[]{"%" + query + "%"});
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ public class PlaylistLoader {
|
|||
Cursor cursor = makePlaylistCursor(context, BaseColumns._ID + "=?", new String[]{String.valueOf(playlistId)});
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int id = cursor.getInt(0);
|
||||
final String name = cursor.getString(1);
|
||||
playlist = new Playlist(id, name);
|
||||
final int id = cursor.getInt(0);
|
||||
final String name = cursor.getString(1);
|
||||
playlist = new Playlist(id, name);
|
||||
}
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import android.database.Cursor;
|
|||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Audio.AudioColumns;
|
||||
|
||||
import com.kabouzeid.gramophone.model.Playlist;
|
||||
import com.kabouzeid.gramophone.model.PlaylistSong;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ public class SongFilePathLoader {
|
|||
return songFiles;
|
||||
}
|
||||
|
||||
public static String getSongFilePath(Context context, int queryId){
|
||||
public static String getSongFilePath(Context context, int queryId) {
|
||||
try {
|
||||
return getSongFilePaths(context, new int[]{queryId}).get(0);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class SongLoader {
|
|||
}
|
||||
|
||||
public static List<Song> getSongs(final Context context, final String query) {
|
||||
Cursor cursor = makeSongCursor(context, MediaStore.Audio.AudioColumns.TITLE + " LIKE ?", new String[]{"%"+query+"%"});
|
||||
Cursor cursor = makeSongCursor(context, MediaStore.Audio.AudioColumns.TITLE + " LIKE ?", new String[]{"%" + query + "%"});
|
||||
List<Song> songs = new ArrayList<>();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -26,13 +26,11 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
|
||||
public class DragSortRecycler extends RecyclerView.ItemDecoration implements RecyclerView.OnItemTouchListener {
|
||||
|
|
@ -52,15 +50,15 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
private int fingerOffsetInViewY;
|
||||
|
||||
private float autoScrollWindow = 0.1f;
|
||||
private float autoScrollSpeed = 0.5f;
|
||||
private float autoScrollSpeed = 0.5f;
|
||||
|
||||
private BitmapDrawable floatingItem;
|
||||
private Rect floatingItemStatingBounds;
|
||||
private Rect floatingItemBounds;
|
||||
private Rect floatingItemStatingBounds;
|
||||
private Rect floatingItemBounds;
|
||||
|
||||
|
||||
private float floatingItemAlpha = 0.5f;
|
||||
private int floatingItemBgColor = 0;
|
||||
private int floatingItemBgColor = 0;
|
||||
|
||||
private int viewHandleId = -1;
|
||||
|
||||
|
|
@ -72,69 +70,60 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
OnDragStateChangedListener dragStateChangedListener;
|
||||
|
||||
|
||||
|
||||
public interface OnItemMovedListener
|
||||
{
|
||||
public interface OnItemMovedListener {
|
||||
public void onItemMoved(int from, int to);
|
||||
}
|
||||
|
||||
public interface OnDragStateChangedListener {
|
||||
public void onDragStart();
|
||||
|
||||
public void onDragStop();
|
||||
}
|
||||
|
||||
private void debugLog(String log)
|
||||
{
|
||||
private void debugLog(String log) {
|
||||
if (DEBUG)
|
||||
Log.d(TAG, log);
|
||||
}
|
||||
|
||||
public RecyclerView.OnScrollListener getScrollListener()
|
||||
{
|
||||
public RecyclerView.OnScrollListener getScrollListener() {
|
||||
return scrollListener;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the item move interface
|
||||
*/
|
||||
public void setOnItemMovedListener(OnItemMovedListener swif)
|
||||
{
|
||||
public void setOnItemMovedListener(OnItemMovedListener swif) {
|
||||
moveInterface = swif;
|
||||
}
|
||||
|
||||
public void setViewHandleId(int id)
|
||||
{
|
||||
public void setViewHandleId(int id) {
|
||||
viewHandleId = id;
|
||||
}
|
||||
|
||||
public void setLeftDragArea(int w)
|
||||
{
|
||||
public void setLeftDragArea(int w) {
|
||||
dragHandleWidth = w;
|
||||
}
|
||||
|
||||
public void setFloatingAlpha(float a)
|
||||
{
|
||||
public void setFloatingAlpha(float a) {
|
||||
floatingItemAlpha = a;
|
||||
}
|
||||
|
||||
public void setFloatingBgColor(int c)
|
||||
{
|
||||
public void setFloatingBgColor(int c) {
|
||||
floatingItemBgColor = c;
|
||||
}
|
||||
|
||||
/*
|
||||
Set the window at top and bottom of list, must be between 0 and 0.5
|
||||
For example 0.1 uses the top and bottom 10% of the lists for scrolling
|
||||
*/
|
||||
public void setAutoScrollWindow(float w)
|
||||
{
|
||||
public void setAutoScrollWindow(float w) {
|
||||
autoScrollWindow = w;
|
||||
}
|
||||
|
||||
/*
|
||||
Set the autoscroll speed, default is 0.5
|
||||
*/
|
||||
public void setAutoScrollSpeed(float speed)
|
||||
{
|
||||
public void setAutoScrollSpeed(float speed) {
|
||||
autoScrollSpeed = speed;
|
||||
}
|
||||
|
||||
|
|
@ -145,63 +134,55 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
debugLog("getItemOffsets");
|
||||
|
||||
debugLog("View top = " + view.getTop());
|
||||
if (selectedDragItemPos != -1)
|
||||
{
|
||||
int itemPos = rv.getChildPosition(view);
|
||||
if (selectedDragItemPos != -1) {
|
||||
int itemPos = rv.getChildPosition(view);
|
||||
debugLog("itemPos =" + itemPos);
|
||||
|
||||
if(!canDragOver(itemPos)) {
|
||||
|
||||
if (!canDragOver(itemPos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Movement of finger
|
||||
float totalMovement = fingerY-fingerAnchorY;
|
||||
float totalMovement = fingerY - fingerAnchorY;
|
||||
|
||||
if (itemPos == selectedDragItemPos)
|
||||
{
|
||||
if (itemPos == selectedDragItemPos) {
|
||||
view.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//Make view visible incase invisible
|
||||
view.setVisibility(View.VISIBLE);
|
||||
|
||||
//Find middle of the floatingItem
|
||||
float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height()/2;
|
||||
float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2;
|
||||
|
||||
//Moving down the list
|
||||
//These will auto-animate if the device continually sends touch motion events
|
||||
// if (totalMovment>0)
|
||||
// if (totalMovment>0)
|
||||
{
|
||||
if ((itemPos > selectedDragItemPos) && (view.getTop() < floatMiddleY))
|
||||
{
|
||||
float amountUp = (floatMiddleY - view.getTop()) / (float)view.getHeight();
|
||||
// amountUp *= 0.5f;
|
||||
if ((itemPos > selectedDragItemPos) && (view.getTop() < floatMiddleY)) {
|
||||
float amountUp = (floatMiddleY - view.getTop()) / (float) view.getHeight();
|
||||
// amountUp *= 0.5f;
|
||||
if (amountUp > 1)
|
||||
amountUp = 1;
|
||||
|
||||
outRect.top = -(int)(floatingItemBounds.height()*amountUp);
|
||||
outRect.bottom = (int)(floatingItemBounds.height()*amountUp);
|
||||
outRect.top = -(int) (floatingItemBounds.height() * amountUp);
|
||||
outRect.bottom = (int) (floatingItemBounds.height() * amountUp);
|
||||
}
|
||||
|
||||
}//Moving up the list
|
||||
// else if (totalMovment < 0)
|
||||
// else if (totalMovment < 0)
|
||||
{
|
||||
if((itemPos < selectedDragItemPos) && (view.getBottom() > floatMiddleY))
|
||||
{
|
||||
float amountDown = ((float)view.getBottom() - floatMiddleY) / (float)view.getHeight();
|
||||
// amountDown *= 0.5f;
|
||||
if ((itemPos < selectedDragItemPos) && (view.getBottom() > floatMiddleY)) {
|
||||
float amountDown = ((float) view.getBottom() - floatMiddleY) / (float) view.getHeight();
|
||||
// amountDown *= 0.5f;
|
||||
if (amountDown > 1)
|
||||
amountDown = 1;
|
||||
|
||||
outRect.top = (int)(floatingItemBounds.height()*amountDown);
|
||||
outRect.bottom = -(int)(floatingItemBounds.height()*amountDown);
|
||||
outRect.top = (int) (floatingItemBounds.height() * amountDown);
|
||||
outRect.bottom = -(int) (floatingItemBounds.height() * amountDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
outRect.top = 0;
|
||||
outRect.bottom = 0;
|
||||
//Make view visible incase invisible
|
||||
|
|
@ -215,15 +196,14 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
* This *seems* to work, another method would be to use
|
||||
* getItemOffsets, but I think that could miss items?..
|
||||
*/
|
||||
private int getNewPostion(RecyclerView rv)
|
||||
{
|
||||
private int getNewPostion(RecyclerView rv) {
|
||||
int itemsOnScreen = rv.getLayoutManager().getChildCount();
|
||||
|
||||
float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height()/2;
|
||||
float floatMiddleY = floatingItemBounds.top + floatingItemBounds.height() / 2;
|
||||
|
||||
int above=0;
|
||||
int above = 0;
|
||||
int below = Integer.MAX_VALUE;
|
||||
for (int n=0;n < itemsOnScreen;n++) //Scan though items on screen, however they may not
|
||||
for (int n = 0; n < itemsOnScreen; n++) //Scan though items on screen, however they may not
|
||||
{ // be in order!
|
||||
|
||||
View view = rv.getLayoutManager().getChildAt(n);
|
||||
|
|
@ -236,13 +216,12 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
if (itemPos == selectedDragItemPos) //Don't check against itself!
|
||||
continue;
|
||||
|
||||
float viewMiddleY = view.getTop() + view.getHeight()/2;
|
||||
float viewMiddleY = view.getTop() + view.getHeight() / 2;
|
||||
if (floatMiddleY > viewMiddleY) //Is above this item
|
||||
{
|
||||
if (itemPos > above)
|
||||
above = itemPos;
|
||||
}
|
||||
else if (floatMiddleY <= viewMiddleY) //Is below this item
|
||||
} else if (floatMiddleY <= viewMiddleY) //Is below this item
|
||||
{
|
||||
if (itemPos < below)
|
||||
below = itemPos;
|
||||
|
|
@ -254,9 +233,7 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
if (below < selectedDragItemPos) //Need to count itself
|
||||
below++;
|
||||
return below - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (above < selectedDragItemPos)
|
||||
above++;
|
||||
|
||||
|
|
@ -267,34 +244,30 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
debugLog("onInterceptTouchEvent");
|
||||
debugLog("onInterceptTouchEvent");
|
||||
|
||||
//if (e.getAction() == MotionEvent.ACTION_DOWN)
|
||||
{
|
||||
View itemView = rv.findChildViewUnder(e.getX(), e.getY());
|
||||
|
||||
if (itemView==null)
|
||||
if (itemView == null)
|
||||
return false;
|
||||
|
||||
boolean dragging = false;
|
||||
|
||||
if ((dragHandleWidth > 0 ) && (e.getX() < dragHandleWidth))
|
||||
{
|
||||
if ((dragHandleWidth > 0) && (e.getX() < dragHandleWidth)) {
|
||||
dragging = true;
|
||||
}
|
||||
else if (viewHandleId != -1)
|
||||
{
|
||||
} else if (viewHandleId != -1) {
|
||||
//Find the handle in the list item
|
||||
View handleView = itemView.findViewById(viewHandleId);
|
||||
|
||||
if (handleView == null)
|
||||
{
|
||||
if (handleView == null) {
|
||||
Log.e(TAG, "The view ID " + viewHandleId + " was not found in the RecycleView item");
|
||||
return false;
|
||||
}
|
||||
|
||||
//View should be visible to drag
|
||||
if(handleView.getVisibility()!=View.VISIBLE) {
|
||||
if (handleView.getVisibility() != View.VISIBLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -311,10 +284,10 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
|
||||
Rect touchBounds = new Rect(itemView.getLeft() + xRel, itemView.getTop() + yRel,
|
||||
itemView.getLeft() + xRel + handleView.getWidth(),
|
||||
itemView.getTop() + yRel + handleView.getHeight()
|
||||
itemView.getTop() + yRel + handleView.getHeight()
|
||||
);
|
||||
|
||||
if (touchBounds.contains((int)e.getX(), (int)e.getY()))
|
||||
if (touchBounds.contains((int) e.getX(), (int) e.getY()))
|
||||
dragging = true;
|
||||
|
||||
debugLog("parentItemPos = " + parentItemPos[0] + " " + parentItemPos[1]);
|
||||
|
|
@ -322,15 +295,14 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
}
|
||||
|
||||
|
||||
if (dragging)
|
||||
{
|
||||
if (dragging) {
|
||||
debugLog("Started Drag");
|
||||
|
||||
setIsDragging(true);
|
||||
|
||||
floatingItem = createFloatingBitmap(itemView);
|
||||
|
||||
fingerAnchorY = (int)e.getY();
|
||||
fingerAnchorY = (int) e.getY();
|
||||
fingerOffsetInViewY = fingerAnchorY - itemView.getTop();
|
||||
fingerY = fingerAnchorY;
|
||||
|
||||
|
|
@ -348,10 +320,8 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
debugLog("onTouchEvent");
|
||||
|
||||
if ((e.getAction() == MotionEvent.ACTION_UP) ||
|
||||
(e.getAction() == MotionEvent.ACTION_CANCEL))
|
||||
{
|
||||
if ((e.getAction() == MotionEvent.ACTION_UP) && selectedDragItemPos != -1)
|
||||
{
|
||||
(e.getAction() == MotionEvent.ACTION_CANCEL)) {
|
||||
if ((e.getAction() == MotionEvent.ACTION_UP) && selectedDragItemPos != -1) {
|
||||
int newPos = getNewPostion(rv);
|
||||
if (moveInterface != null)
|
||||
moveInterface.onItemMoved(selectedDragItemPos, newPos);
|
||||
|
|
@ -365,14 +335,13 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
}
|
||||
|
||||
|
||||
fingerY = (int)e.getY();
|
||||
fingerY = (int) e.getY();
|
||||
|
||||
if (floatingItem!=null)
|
||||
{
|
||||
if (floatingItem != null) {
|
||||
floatingItemBounds.top = fingerY - fingerOffsetInViewY;
|
||||
|
||||
if (floatingItemBounds.top < -floatingItemStatingBounds.height()/2) //Allow half the view out the top
|
||||
floatingItemBounds.top = -floatingItemStatingBounds.height()/2;
|
||||
if (floatingItemBounds.top < -floatingItemStatingBounds.height() / 2) //Allow half the view out the top
|
||||
floatingItemBounds.top = -floatingItemStatingBounds.height() / 2;
|
||||
|
||||
floatingItemBounds.bottom = floatingItemBounds.top + floatingItemStatingBounds.height();
|
||||
|
||||
|
|
@ -380,27 +349,24 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
}
|
||||
|
||||
//Do auto scrolling at end of list
|
||||
float scrollAmount=0;
|
||||
if (fingerY > (rv.getHeight() * (1-autoScrollWindow)))
|
||||
{
|
||||
scrollAmount = (fingerY - (rv.getHeight() * (1-autoScrollWindow)));
|
||||
}
|
||||
else if (fingerY < (rv.getHeight() * autoScrollWindow))
|
||||
{
|
||||
float scrollAmount = 0;
|
||||
if (fingerY > (rv.getHeight() * (1 - autoScrollWindow))) {
|
||||
scrollAmount = (fingerY - (rv.getHeight() * (1 - autoScrollWindow)));
|
||||
} else if (fingerY < (rv.getHeight() * autoScrollWindow)) {
|
||||
scrollAmount = (fingerY - (rv.getHeight() * autoScrollWindow));
|
||||
}
|
||||
debugLog("Scroll: " + scrollAmount);
|
||||
|
||||
scrollAmount *= autoScrollSpeed;
|
||||
rv.scrollBy(0, (int)scrollAmount);
|
||||
rv.scrollBy(0, (int) scrollAmount);
|
||||
|
||||
rv.invalidateItemDecorations();// Redraw
|
||||
}
|
||||
|
||||
private void setIsDragging(final boolean dragging) {
|
||||
if(dragging != isDragging) {
|
||||
if (dragging != isDragging) {
|
||||
isDragging = dragging;
|
||||
if(dragStateChangedListener != null) {
|
||||
if (dragStateChangedListener != null) {
|
||||
if (isDragging) {
|
||||
dragStateChangedListener.onDragStart();
|
||||
} else {
|
||||
|
|
@ -416,12 +382,13 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
|
||||
|
||||
Paint bgColor = new Paint();
|
||||
|
||||
@Override
|
||||
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
if (floatingItem != null) {
|
||||
floatingItem.setAlpha((int)(255 * floatingItemAlpha));
|
||||
floatingItem.setAlpha((int) (255 * floatingItemAlpha));
|
||||
bgColor.setColor(floatingItemBgColor);
|
||||
c.drawRect(floatingItemBounds,bgColor);
|
||||
c.drawRect(floatingItemBounds, bgColor);
|
||||
floatingItem.draw(c);
|
||||
}
|
||||
}
|
||||
|
|
@ -439,10 +406,8 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
fingerAnchorY -= dy;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param position
|
||||
* @return True if we can drag the item over this position, False if not.
|
||||
*/
|
||||
|
|
@ -451,9 +416,8 @@ public class DragSortRecycler extends RecyclerView.ItemDecoration implements Rec
|
|||
}
|
||||
|
||||
|
||||
private BitmapDrawable createFloatingBitmap(View v)
|
||||
{
|
||||
floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(),v.getRight(), v.getBottom());
|
||||
private BitmapDrawable createFloatingBitmap(View v) {
|
||||
floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
|
||||
floatingItemBounds = new Rect(floatingItemStatingBounds);
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(floatingItemStatingBounds.width(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.kabouzeid.gramophone.model;
|
||||
|
||||
public class PlaylistSong extends Song{
|
||||
public class PlaylistSong extends Song {
|
||||
public int playlistId;
|
||||
public int idInPlayList;
|
||||
|
||||
public PlaylistSong(final int id, final int albumId, final int artistId, final String title, final String artistName,
|
||||
final String albumName, final long duration, final int trackNumber, final int playlistId, final int idInPlayList) {
|
||||
final String albumName, final long duration, final int trackNumber, final int playlistId, final int idInPlayList) {
|
||||
super(id, albumId, artistId, title, artistName, albumName, duration, trackNumber);
|
||||
this.playlistId = playlistId;
|
||||
this.idInPlayList = idInPlayList;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.kabouzeid.gramophone.service;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
public class MediaButtonIntentReceiver extends BroadcastReceiver {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.kabouzeid.gramophone.App;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.AlbumSongAdapter;
|
||||
import com.kabouzeid.gramophone.comparator.SongTrackNumberComparator;
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
import com.kabouzeid.gramophone.loader.AlbumSongLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
|
|
@ -277,7 +276,7 @@ public class AlbumDetailActivity extends AbsFabActivity {
|
|||
return true;
|
||||
case R.id.action_go_to_artist:
|
||||
Pair[] artistPairs = null;
|
||||
artistPairs = getSharedViewsWithFab(artistPairs);
|
||||
artistPairs = getSharedViewsWithFab(artistPairs);
|
||||
NavigationUtil.goToArtist(this, album.artistId, artistPairs);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private MaterialDialog getBiographyDialog(){
|
||||
private MaterialDialog getBiographyDialog() {
|
||||
return new MaterialDialog.Builder(ArtistDetailActivity.this)
|
||||
.title(artist.name)
|
||||
.content(biography)
|
||||
|
|
@ -316,7 +316,7 @@ public class ArtistDetailActivity extends AbsFabActivity {
|
|||
NavigationUtil.openPlayingQueueDialog(this);
|
||||
return true;
|
||||
case R.id.action_biography:
|
||||
if(biography != null){
|
||||
if (biography != null) {
|
||||
getBiographyDialog().show();
|
||||
} else {
|
||||
Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.biography_unavailable), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -14,29 +14,24 @@ import android.support.v7.app.ActionBar;
|
|||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.google.samples.apps.iosched.ui.widget.SlidingTabLayout;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.AboutDeveloperDialogHelper;
|
||||
import com.kabouzeid.gramophone.helper.CreatePlaylistDialogHelper;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.PlayingQueueDialogHelper;
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.ui.fragments.NavigationDrawerFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AbsMainActivityFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AlbumViewFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.ArtistViewFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.AbsMainActivityFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.PlaylistViewFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.mainactivityfragments.SongViewFragment;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
|
|
@ -216,7 +211,7 @@ public class MainActivity extends AbsFabActivity
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
switch (currentPage){
|
||||
switch (currentPage) {
|
||||
case 3:
|
||||
getMenuInflater().inflate(R.menu.menu_playlists, menu);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ public class PlaylistsUtil {
|
|||
context.getContentResolver().update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
|
||||
contentValues,
|
||||
MediaStore.Audio.Playlists._ID + "=?",
|
||||
new String[]{ String.valueOf(id) });
|
||||
new String[]{String.valueOf(id)});
|
||||
App.bus.post(new DataBaseChangedEvent(DataBaseChangedEvent.PLAYLISTS_CHANGED));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@ import android.provider.MediaStore;
|
|||
|
||||
/**
|
||||
* Holds all of the sort orders for each list type.
|
||||
*
|
||||
*
|
||||
* @author Andrew Neal (andrewdneal@gmail.com)
|
||||
*/
|
||||
public final class SortOrder {
|
||||
|
||||
/** This class is never instantiated */
|
||||
/**
|
||||
* This class is never instantiated
|
||||
*/
|
||||
public SortOrder() {
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue