Commit e00cfe05 authored by Geoffrey Métais's avatar Geoffrey Métais

Use interface for Audio click handler

parent 7cbcfe7e
......@@ -13,7 +13,7 @@
type="boolean"/>
<variable
name="handler"
type="org.videolan.vlc.gui.audio.AudioBrowserListAdapter.ClickHandler"/>
type="org.videolan.vlc.interfaces.IAudioClickHandler"/>
<variable
name="clickable"
type="boolean"/>
......@@ -81,7 +81,7 @@
android:background="@drawable/ic_more"
android:contentDescription="@string/more_actions"
android:visibility="@{clickable ? View.VISIBLE : View.GONE}"
android:onClick="@{handler.onClick}"
android:onClick="@{handler.onMoreClick}"
android:clickable="@{clickable}" />
</RelativeLayout>
......
......@@ -42,6 +42,7 @@ import android.widget.TextView;
import org.videolan.vlc.BR;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.interfaces.IAudioClickHandler;
import org.videolan.vlc.util.BitmapCache;
import org.videolan.vlc.util.Util;
......@@ -53,7 +54,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndexer {
public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndexer, IAudioClickHandler {
public final static String TAG = "VLC/AudioBrowserListAdapter";
public final static int TYPE_ARTISTS = 0;
......@@ -347,7 +348,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
holder.binding.setVariable(BR.footer, !isMediaItemAboveASeparator(position));
holder.binding.setVariable(BR.clickable, mContextPopupMenuListener != null);
holder.binding.setVariable(BR.handler, mClickHandler);
holder.binding.setVariable(BR.handler, this);
holder.binding.executePendingBindings();
return v;
......@@ -561,11 +562,9 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
}
};
public ClickHandler mClickHandler = new ClickHandler();
public class ClickHandler {
public void onClick(View v){
if (mContextPopupMenuListener != null)
mContextPopupMenuListener.onPopupMenu(v, ((ViewHolder) ((LinearLayout)v.getParent().getParent()).getTag()).position);
}
@Override
public void onMoreClick(View v) {
if (mContextPopupMenuListener != null)
mContextPopupMenuListener.onPopupMenu(v, ((ViewHolder) ((LinearLayout)v.getParent().getParent()).getTag()).position);
}
}
/*
* *************************************************************************
* IAudioClickHandler.java
* **************************************************************************
* Copyright © 2015 VLC authors and VideoLAN
* Author: Geoffrey Métais
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* ***************************************************************************
*/
package org.videolan.vlc.interfaces;
import android.view.View;
public interface IAudioClickHandler {
void onMoreClick(View v);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment