use coordclicklistener in all places

This commit is contained in:
Adrian Ulrich 2018-11-22 21:15:08 +01:00
parent 715b80044f
commit 82d8b7cccd
3 changed files with 14 additions and 13 deletions

View File

@ -25,6 +25,7 @@ package ch.blinkenlights.android.vanilla;
import ch.blinkenlights.android.vanilla.ui.FancyMenu;
import ch.blinkenlights.android.vanilla.ui.FancyMenuItem;
import ch.blinkenlights.android.vanilla.ext.CoordClickListener;
import android.app.Activity;
import android.app.AlertDialog;
@ -50,7 +51,7 @@ import com.mobeta.android.dslv.DragSortListView;
public class PlaylistActivity extends Activity
implements View.OnClickListener
, AbsListView.OnItemClickListener
, AbsListView.OnItemLongClickListener
, CoordClickListener.Callback
, DialogInterface.OnClickListener
, DragSortListView.DropListener
, DragSortListView.RemoveListener
@ -109,9 +110,10 @@ public class PlaylistActivity extends Activity
setContentView(R.layout.playlist_activity);
CoordClickListener ccl = new CoordClickListener(this);
DragSortListView view = (DragSortListView)findViewById(R.id.list);
ccl.registerForOnItemLongClickListener(view);
view.setOnItemClickListener(this);
view.setOnItemLongClickListener(this);
view.setDropListener(this);
view.setRemoveListener(this);
mListView = view;
@ -199,7 +201,7 @@ public class PlaylistActivity extends Activity
private static final int MENU_SHOW_DETAILS = -2;
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
public boolean onItemLongClickWithCoords(AdapterView<?> parent, View view, int pos, long id, float x, float y) {
ViewHolder holder = (ViewHolder)view.findViewById(R.id.text).getTag();
Intent intent = new Intent();
intent.putExtra("id", id);
@ -220,7 +222,7 @@ public class PlaylistActivity extends Activity
fm.addSpacer(0);
fm.add(MENU_SHOW_DETAILS, 0, R.drawable.menu_details, R.string.details).setIntent(intent);
fm.add(MENU_REMOVE, 0, R.drawable.menu_remove, R.string.remove).setIntent(intent);
fm.show(view);
fm.show(view, x, y);
return true;
}

View File

@ -19,6 +19,7 @@ package ch.blinkenlights.android.vanilla;
import ch.blinkenlights.android.vanilla.ui.FancyMenu;
import ch.blinkenlights.android.vanilla.ui.FancyMenuItem;
import ch.blinkenlights.android.vanilla.ext.CoordClickListener;
import android.annotation.SuppressLint;
import android.app.Fragment;
@ -38,7 +39,7 @@ import com.mobeta.android.dslv.DragSortListView;
public class ShowQueueFragment extends Fragment
implements TimelineCallback,
AdapterView.OnItemClickListener,
AdapterView.OnItemLongClickListener,
CoordClickListener.Callback,
DragSortListView.DropListener,
DragSortListView.RemoveListener,
FancyMenu.Callback
@ -55,13 +56,15 @@ public class ShowQueueFragment extends Fragment
View view = inflater.inflate(R.layout.showqueue_listview, container, false);
Context context = getActivity();
mListView = (DragSortListView) view.findViewById(R.id.list);
mListAdapter = new ShowQueueAdapter(context, R.layout.draggable_row);
mListView = (DragSortListView) view.findViewById(R.id.list);
mListView.setAdapter(mListAdapter);
mListView.setDropListener(this);
mListView.setRemoveListener(this);
mListView.setOnItemClickListener(this);
mListView.setOnItemLongClickListener(this);
CoordClickListener ccl = new CoordClickListener(this);
ccl.registerForOnItemLongClickListener(mListView);
PlaybackService.addTimelineCallback(this);
return view;
@ -99,7 +102,7 @@ public class ShowQueueFragment extends Fragment
* Called on long-click on a adapeter row
*/
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
public boolean onItemLongClickWithCoords(AdapterView<?> parent, View view, int pos, long id, float x, float y) {
Song song = playbackService().getSongByQueuePosition(pos);
Intent intent = new Intent();
@ -121,7 +124,7 @@ public class ShowQueueFragment extends Fragment
fm.addSpacer(0);
fm.add(CTX_MENU_SHOW_DETAILS, 0, R.drawable.menu_details, R.string.details).setIntent(intent);
fm.add(CTX_MENU_REMOVE, 90, R.drawable.menu_remove, R.string.remove).setIntent(intent);
fm.show(view);
fm.show(view, x, y);
return true;
}

View File

@ -196,10 +196,6 @@ public class FancyMenu {
return (suggested > maxHeight ? maxHeight : ListPopupWindow.WRAP_CONTENT);
}
public void show(View parent) {
show(parent, Float.NaN, Float.NaN);
}
/**
* Show the assembled fancy menu
*