diff --git a/res/layout/library_row.xml b/res/layout/library_row.xml deleted file mode 100644 index b89f85d2..00000000 --- a/res/layout/library_row.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - diff --git a/res/layout/library_row_expandable.xml b/res/layout/library_row_expandable.xml index e8849e33..14909173 100644 --- a/res/layout/library_row_expandable.xml +++ b/res/layout/library_row_expandable.xml @@ -47,5 +47,6 @@ THE SOFTWARE. android:src="@drawable/arrow" android:layout_width="44dip" android:layout_height="44dip" + android:visibility="gone" android:contentDescription="@string/expand" /> diff --git a/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java b/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java index 8b031c61..3de7da58 100644 --- a/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java +++ b/src/ch/blinkenlights/android/vanilla/FileSystemAdapter.java @@ -188,13 +188,6 @@ public class FileSystemAdapter return pos; } - private static class ViewHolder { - public int id; - public TextView text; - public View divider; - public ImageView arrow; - } - @Override public View getView(int pos, View convertView, ViewGroup parent) { @@ -205,7 +198,6 @@ public class FileSystemAdapter view = mInflater.inflate(R.layout.library_row_expandable, null); holder = new ViewHolder(); holder.text = (TextView)view.findViewById(R.id.text); - holder.divider = view.findViewById(R.id.divider); holder.arrow = (ImageView)view.findViewById(R.id.arrow); holder.text.setOnClickListener(this); holder.arrow.setOnClickListener(this); @@ -219,7 +211,6 @@ public class FileSystemAdapter boolean isDirectory = file.isDirectory(); holder.id = pos; holder.text.setText(file.getName()); - holder.divider.setVisibility(isDirectory ? View.VISIBLE : View.GONE); holder.arrow.setVisibility(isDirectory ? View.VISIBLE : View.GONE); holder.text.setCompoundDrawablesWithIntrinsicBounds(isDirectory ? mFolderIcon : null, null, null, null); return view; @@ -295,11 +286,11 @@ public class FileSystemAdapter public Intent createData(View view) { ViewHolder holder = (ViewHolder)view.getTag(); - File file = mFiles[holder.id]; + File file = mFiles[(int)holder.id]; Intent intent = new Intent(); intent.putExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_FILE); - intent.putExtra(LibraryAdapter.DATA_ID, (long)holder.id); + intent.putExtra(LibraryAdapter.DATA_ID, holder.id); intent.putExtra(LibraryAdapter.DATA_TITLE, holder.text.getText().toString()); intent.putExtra(LibraryAdapter.DATA_EXPANDABLE, file.isDirectory()); diff --git a/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java b/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java index 0fdbcd26..cf2e2af7 100644 --- a/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java +++ b/src/ch/blinkenlights/android/vanilla/LibraryPagerAdapter.java @@ -314,18 +314,18 @@ public class LibraryPagerAdapter case MediaUtils.TYPE_ARTIST: adapter = mArtistAdapter = new MediaAdapter(activity, MediaUtils.TYPE_ARTIST, null); mArtistAdapter.setExpandable(mSongsPosition != -1 || mAlbumsPosition != -1); - mArtistHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row, null); + mArtistHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row_expandable, null); break; case MediaUtils.TYPE_ALBUM: adapter = mAlbumAdapter = new MediaAdapter(activity, MediaUtils.TYPE_ALBUM, mPendingAlbumLimiter); mAlbumAdapter.setExpandable(mSongsPosition != -1); mPendingAlbumLimiter = null; - mAlbumHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row, null); + mAlbumHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row_expandable, null); break; case MediaUtils.TYPE_SONG: adapter = mSongAdapter = new MediaAdapter(activity, MediaUtils.TYPE_SONG, mPendingSongLimiter); mPendingSongLimiter = null; - mSongHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row, null); + mSongHeader = header = (LinearLayout)inflater.inflate(R.layout.library_row_expandable, null); break; case MediaUtils.TYPE_PLAYLIST: adapter = mPlaylistAdapter = new MediaAdapter(activity, MediaUtils.TYPE_PLAYLIST, null); diff --git a/src/ch/blinkenlights/android/vanilla/MediaAdapter.java b/src/ch/blinkenlights/android/vanilla/MediaAdapter.java index c3d846cb..cb18a301 100644 --- a/src/ch/blinkenlights/android/vanilla/MediaAdapter.java +++ b/src/ch/blinkenlights/android/vanilla/MediaAdapter.java @@ -433,33 +433,25 @@ public class MediaAdapter } } - private static class ViewHolder { - public long id; - public String title; - public TextView text; - public ImageView arrow; - } - @Override public View getView(int position, View view, ViewGroup parent) { ViewHolder holder; - if (view == null || mExpandable != view instanceof LinearLayout) { + if (view == null) { // We must create a new view if we're not given a recycle view or // if the recycle view has the wrong layout. - int layout = mExpandable ? R.layout.library_row_expandable : R.layout.library_row; - view = mInflater.inflate(layout, null); + view = mInflater.inflate(R.layout.library_row_expandable, null); holder = new ViewHolder(); view.setTag(holder); holder.text = (TextView)view.findViewById(R.id.text); - if (mExpandable) { - holder.arrow = (ImageView)view.findViewById(R.id.arrow); - holder.arrow.setOnClickListener(this); - } + holder.arrow = (ImageView)view.findViewById(R.id.arrow); + holder.arrow.setOnClickListener(this); holder.text.setOnClickListener(this); + + holder.arrow.setVisibility(mExpandable ? View.VISIBLE : View.GONE); } else { holder = (ViewHolder)view.getTag(); } diff --git a/src/ch/blinkenlights/android/vanilla/ViewHolder.java b/src/ch/blinkenlights/android/vanilla/ViewHolder.java new file mode 100644 index 00000000..954d47c3 --- /dev/null +++ b/src/ch/blinkenlights/android/vanilla/ViewHolder.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2015 Adrian Ulrich + * + * 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 3 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, see . + */ + +package ch.blinkenlights.android.vanilla; + +import android.widget.TextView; +import android.widget.ImageView; + + +public class ViewHolder { + public long id; + public String title; + public TextView text; + public ImageView arrow; +}