fully get rid of library_row_expandable
This commit is contained in:
parent
4611a6c533
commit
f78485ed38
@ -1,62 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
-->
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
<ch.blinkenlights.android.vanilla.LazyCoverView
|
|
||||||
android:id="@+id/cover"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:layout_width="@dimen/cover_size"
|
|
||||||
android:layout_height="@dimen/cover_size"
|
|
||||||
android:layout_marginLeft="@dimen/cover_padding"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:visibility="gone" />
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:gravity="left|center_vertical"
|
|
||||||
android:layout_width="0px"
|
|
||||||
android:layout_height="@dimen/row_normal_height"
|
|
||||||
android:layout_marginLeft="@dimen/text_padding"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/divider"
|
|
||||||
android:layout_width="@dimen/divider_size"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:background="?android:attr/dividerHorizontal" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/arrow"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
|
||||||
android:src="@drawable/arrow"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:layout_width="@dimen/row_normal_height"
|
|
||||||
android:layout_height="@dimen/row_normal_height"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:contentDescription="@string/expand" />
|
|
||||||
</LinearLayout>
|
|
@ -24,6 +24,5 @@ THE SOFTWARE.
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:divider="@drawable/inset_divider"
|
android:divider="@null"
|
||||||
android:dividerHeight="1dip"
|
|
||||||
android:fastScrollEnabled="true"/>
|
android:fastScrollEnabled="true"/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
* Copyright (C) 2014-2016 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,6 +19,7 @@ package ch.blinkenlights.android.vanilla;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -45,6 +46,7 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
|||||||
/**
|
/**
|
||||||
* Layout types for use with setupLayout
|
* Layout types for use with setupLayout
|
||||||
*/
|
*/
|
||||||
|
public static final int LAYOUT_TEXTONLY = 0;
|
||||||
public static final int LAYOUT_CHECKBOXES = 1;
|
public static final int LAYOUT_CHECKBOXES = 1;
|
||||||
public static final int LAYOUT_DRAGGABLE = 2;
|
public static final int LAYOUT_DRAGGABLE = 2;
|
||||||
public static final int LAYOUT_LISTVIEW = 3;
|
public static final int LAYOUT_LISTVIEW = 3;
|
||||||
@ -85,6 +87,7 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
|||||||
mCoverView.setVisibility(View.VISIBLE);
|
mCoverView.setVisibility(View.VISIBLE);
|
||||||
mDragger.setImageResource(R.drawable.arrow);
|
mDragger.setImageResource(R.drawable.arrow);
|
||||||
break;
|
break;
|
||||||
|
case LAYOUT_TEXTONLY:
|
||||||
default:
|
default:
|
||||||
break; // do not care
|
break; // do not care
|
||||||
}
|
}
|
||||||
@ -139,6 +142,14 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
|||||||
mDragger.setVisibility( state ? View.VISIBLE : View.INVISIBLE );
|
mDragger.setVisibility( state ? View.VISIBLE : View.INVISIBLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDraggerOnClickListener(View.OnClickListener listener) {
|
||||||
|
TypedValue v = new TypedValue();
|
||||||
|
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, v, true);
|
||||||
|
|
||||||
|
mDragger.setBackgroundResource(v.resourceId);
|
||||||
|
mDragger.setOnClickListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an instance of our textview
|
* Returns an instance of our textview
|
||||||
*/
|
*/
|
||||||
|
@ -165,9 +165,9 @@ public class LibraryPagerAdapter
|
|||||||
* song limiters.
|
* song limiters.
|
||||||
*/
|
*/
|
||||||
private String mHeaderText;
|
private String mHeaderText;
|
||||||
private LinearLayout mArtistHeader;
|
private DraggableRow mArtistHeader;
|
||||||
private LinearLayout mAlbumHeader;
|
private DraggableRow mAlbumHeader;
|
||||||
private LinearLayout mSongHeader;
|
private DraggableRow mSongHeader;
|
||||||
/**
|
/**
|
||||||
* The current filter text, or null if none.
|
* The current filter text, or null if none.
|
||||||
*/
|
*/
|
||||||
@ -311,24 +311,24 @@ public class LibraryPagerAdapter
|
|||||||
LibraryActivity activity = mActivity;
|
LibraryActivity activity = mActivity;
|
||||||
LayoutInflater inflater = activity.getLayoutInflater();
|
LayoutInflater inflater = activity.getLayoutInflater();
|
||||||
LibraryAdapter adapter;
|
LibraryAdapter adapter;
|
||||||
LinearLayout header = null;
|
DraggableRow header = null;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MediaUtils.TYPE_ARTIST:
|
case MediaUtils.TYPE_ARTIST:
|
||||||
adapter = mArtistAdapter = new MediaAdapter(activity, MediaUtils.TYPE_ARTIST, mPendingArtistLimiter, activity);
|
adapter = mArtistAdapter = new MediaAdapter(activity, MediaUtils.TYPE_ARTIST, mPendingArtistLimiter, activity);
|
||||||
mArtistAdapter.setExpandable(mSongsPosition != -1 || mAlbumsPosition != -1);
|
mArtistAdapter.setExpandable(mSongsPosition != -1 || mAlbumsPosition != -1);
|
||||||
mArtistHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row_expandable, null);
|
mArtistHeader = header = (DraggableRow)inflater.inflate(R.layout.draggable_row, null);
|
||||||
break;
|
break;
|
||||||
case MediaUtils.TYPE_ALBUM:
|
case MediaUtils.TYPE_ALBUM:
|
||||||
adapter = mAlbumAdapter = new MediaAdapter(activity, MediaUtils.TYPE_ALBUM, mPendingAlbumLimiter, activity);
|
adapter = mAlbumAdapter = new MediaAdapter(activity, MediaUtils.TYPE_ALBUM, mPendingAlbumLimiter, activity);
|
||||||
mAlbumAdapter.setExpandable(mSongsPosition != -1);
|
mAlbumAdapter.setExpandable(mSongsPosition != -1);
|
||||||
mPendingAlbumLimiter = null;
|
mPendingAlbumLimiter = null;
|
||||||
mAlbumHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row_expandable, null);
|
mAlbumHeader = header = (DraggableRow)inflater.inflate(R.layout.draggable_row, null);
|
||||||
break;
|
break;
|
||||||
case MediaUtils.TYPE_SONG:
|
case MediaUtils.TYPE_SONG:
|
||||||
adapter = mSongAdapter = new MediaAdapter(activity, MediaUtils.TYPE_SONG, mPendingSongLimiter, activity);
|
adapter = mSongAdapter = new MediaAdapter(activity, MediaUtils.TYPE_SONG, mPendingSongLimiter, activity);
|
||||||
mPendingSongLimiter = null;
|
mPendingSongLimiter = null;
|
||||||
mSongHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row_expandable, null);
|
mSongHeader = header = (DraggableRow)inflater.inflate(R.layout.draggable_row, null);
|
||||||
break;
|
break;
|
||||||
case MediaUtils.TYPE_PLAYLIST:
|
case MediaUtils.TYPE_PLAYLIST:
|
||||||
adapter = mPlaylistAdapter = new MediaAdapter(activity, MediaUtils.TYPE_PLAYLIST, null, activity);
|
adapter = mPlaylistAdapter = new MediaAdapter(activity, MediaUtils.TYPE_PLAYLIST, null, activity);
|
||||||
@ -351,8 +351,7 @@ public class LibraryPagerAdapter
|
|||||||
|
|
||||||
view.setTag(type);
|
view.setTag(type);
|
||||||
if (header != null) {
|
if (header != null) {
|
||||||
TextView headerText = (TextView)header.findViewById(R.id.text);
|
header.getTextView().setText(mHeaderText);
|
||||||
headerText.setText(mHeaderText);
|
|
||||||
header.setTag(new ViewHolder()); // behave like a normal library row
|
header.setTag(new ViewHolder()); // behave like a normal library row
|
||||||
view.addHeaderView(header);
|
view.addHeaderView(header);
|
||||||
}
|
}
|
||||||
@ -455,11 +454,11 @@ public class LibraryPagerAdapter
|
|||||||
public void setHeaderText(String text)
|
public void setHeaderText(String text)
|
||||||
{
|
{
|
||||||
if (mArtistHeader != null)
|
if (mArtistHeader != null)
|
||||||
((TextView)mArtistHeader.findViewById(R.id.text)).setText(text);
|
mArtistHeader.getTextView().setText(text);
|
||||||
if (mAlbumHeader != null)
|
if (mAlbumHeader != null)
|
||||||
((TextView)mAlbumHeader.findViewById(R.id.text)).setText(text);
|
mAlbumHeader.getTextView().setText(text);
|
||||||
if (mSongHeader != null)
|
if (mSongHeader != null)
|
||||||
((TextView)mSongHeader.findViewById(R.id.text)).setText(text);
|
mSongHeader.getTextView().setText(text);
|
||||||
mHeaderText = text;
|
mHeaderText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,29 +508,25 @@ public class MediaAdapter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View view, ViewGroup parent)
|
public View getView(int position, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
|
DraggableRow row;
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
|
|
||||||
if (view == null) {
|
if (convertView == null) {
|
||||||
// We must create a new view if we're not given a recycle view or
|
// We must create a new view if we're not given a recycle view or
|
||||||
// if the recycle view has the wrong layout.
|
// if the recycle view has the wrong layout.
|
||||||
|
row = (DraggableRow)mInflater.inflate(R.layout.draggable_row, null);
|
||||||
|
row.setupLayout(DraggableRow.LAYOUT_LISTVIEW);
|
||||||
|
|
||||||
view = mInflater.inflate(R.layout.library_row_expandable, null);
|
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
view.setTag(holder);
|
row.setTag(holder);
|
||||||
|
|
||||||
holder.text = (TextView)view.findViewById(R.id.text);
|
row.setDraggerOnClickListener(this);
|
||||||
holder.divider = (View)view.findViewById(R.id.divider);
|
row.showDragger(mExpandable);
|
||||||
holder.arrow = (ImageView)view.findViewById(R.id.arrow);
|
|
||||||
holder.cover = (LazyCoverView)view.findViewById(R.id.cover);
|
|
||||||
holder.arrow.setOnClickListener(this);
|
|
||||||
|
|
||||||
holder.divider.setVisibility(mExpandable ? View.VISIBLE : View.GONE);
|
|
||||||
holder.arrow.setVisibility(mExpandable ? View.VISIBLE : View.GONE);
|
|
||||||
holder.cover.setVisibility(mCoverCacheType != MediaUtils.TYPE_INVALID ? View.VISIBLE : View.GONE);
|
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder)view.getTag();
|
row = (DraggableRow)convertView;
|
||||||
|
holder = (ViewHolder)row.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = mCursor;
|
Cursor cursor = mCursor;
|
||||||
@ -547,18 +543,18 @@ public class MediaAdapter
|
|||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
sb.append(line2);
|
sb.append(line2);
|
||||||
sb.setSpan(new ForegroundColorSpan(Color.GRAY), line1.length() + 1, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
sb.setSpan(new ForegroundColorSpan(Color.GRAY), line1.length() + 1, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
holder.text.setText(sb);
|
row.getTextView().setText(sb);
|
||||||
holder.title = line1;
|
holder.title = line1;
|
||||||
} else {
|
} else {
|
||||||
String title = cursor.getString(2);
|
String title = cursor.getString(2);
|
||||||
if(title == null) { title = DB_NULLSTRING_FALLBACK; }
|
if(title == null) { title = DB_NULLSTRING_FALLBACK; }
|
||||||
holder.text.setText(title);
|
row.getTextView().setText(title);
|
||||||
holder.title = title;
|
holder.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.cover.setCover(mCoverCacheType, cacheId, holder.title);
|
row.getCoverView().setCover(mCoverCacheType, cacheId, holder.title);
|
||||||
|
|
||||||
return view;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -640,7 +636,7 @@ public class MediaAdapter
|
|||||||
public void onClick(View view)
|
public void onClick(View view)
|
||||||
{
|
{
|
||||||
int id = view.getId();
|
int id = view.getId();
|
||||||
view = (View)view.getParent(); // get view of linear layout, not the click consumer
|
view = (View)view.getParent().getParent(); // get view of linear layout, not the click consumer
|
||||||
Intent intent = createData(view);
|
Intent intent = createData(view);
|
||||||
mActivity.onItemExpanded(intent);
|
mActivity.onItemExpanded(intent);
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,4 @@ import android.widget.ImageView;
|
|||||||
public class ViewHolder {
|
public class ViewHolder {
|
||||||
public long id;
|
public long id;
|
||||||
public String title;
|
public String title;
|
||||||
public TextView text;
|
|
||||||
public View divider;
|
|
||||||
public ImageView arrow;
|
|
||||||
public LazyCoverView cover;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user