Merge pull request #4 from biconou/forPullRequests

Ability to see entire song and album title
This commit is contained in:
Óscar García Amor 2016-02-23 18:34:17 +01:00
commit e6192f80e1
3 changed files with 89 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
@ -46,7 +47,9 @@ import org.moire.ultrasonic.util.EntryByDiscAndTrackComparator;
import org.moire.ultrasonic.util.Pair; import org.moire.ultrasonic.util.Pair;
import org.moire.ultrasonic.util.TabActivityBackgroundTask; import org.moire.ultrasonic.util.TabActivityBackgroundTask;
import org.moire.ultrasonic.util.Util; import org.moire.ultrasonic.util.Util;
import org.moire.ultrasonic.view.AlbumView;
import org.moire.ultrasonic.view.EntryAdapter; import org.moire.ultrasonic.view.EntryAdapter;
import org.moire.ultrasonic.view.SongView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -105,6 +108,31 @@ public class SelectAlbumActivity extends SubsonicTabActivity
} }
}); });
refreshAlbumListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
for (int i=0;i<albumListView.getChildCount();i++) {
Object child = albumListView.getChildAt(i);
if (child instanceof AlbumView) {
AlbumView albumView = (AlbumView) child;
if (albumView.isMaximized()) {
albumView.maximizeOrMinimize();
}
}
if (child instanceof SongView) {
SongView songView = (SongView) child;
if (songView.isMaximized()) {
songView.maximizeOrMinimize();
}
}
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
header = LayoutInflater.from(this).inflate(R.layout.select_album_header, albumListView, false); header = LayoutInflater.from(this).inflate(R.layout.select_album_header, albumListView, false);
albumListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); albumListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
@ -137,6 +165,29 @@ public class SelectAlbumActivity extends SubsonicTabActivity
} }
}); });
albumListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof AlbumView) {
AlbumView albumView = (AlbumView) view;
if (!albumView.isMaximized()) {
albumView.maximizeOrMinimize();
return true;
} else {
return false;
}
}
if (view instanceof SongView) {
SongView songView = (SongView) view;
songView.maximizeOrMinimize();
return true;
}
return false;
}
});
selectButton = (ImageView) findViewById(R.id.select_album_select); selectButton = (ImageView) findViewById(R.id.select_album_select);
playNowButton = (ImageView) findViewById(R.id.select_album_play_now); playNowButton = (ImageView) findViewById(R.id.select_album_play_now);
playNextButton = (ImageView) findViewById(R.id.select_album_play_next); playNextButton = (ImageView) findViewById(R.id.select_album_play_next);

View File

@ -49,6 +49,7 @@ public class AlbumView extends UpdateView
private MusicDirectory.Entry entry; private MusicDirectory.Entry entry;
private EntryAdapter.AlbumViewHolder viewHolder; private EntryAdapter.AlbumViewHolder viewHolder;
private ImageLoader imageLoader; private ImageLoader imageLoader;
private boolean maximized = false;
public AlbumView(Context context, ImageLoader imageLoader) public AlbumView(Context context, ImageLoader imageLoader)
{ {
@ -94,6 +95,24 @@ public class AlbumView extends UpdateView
return this.entry; return this.entry;
} }
public boolean isMaximized() {
return maximized;
}
public void maximizeOrMinimize() {
if (maximized) {
maximized = false;
} else {
maximized = true;
}
if (this.viewHolder.title != null) {
this.viewHolder.title.setSingleLine(!maximized);
}
if (this.viewHolder.artist != null) {
this.viewHolder.artist.setSingleLine(!maximized);
}
}
public void setAlbum(final MusicDirectory.Entry album) public void setAlbum(final MusicDirectory.Entry album)
{ {
viewHolder.cover_art.setTag(album); viewHolder.cover_art.setTag(album);

View File

@ -71,6 +71,7 @@ public class SongView extends UpdateView implements Checkable
private DownloadFile downloadFile; private DownloadFile downloadFile;
private boolean playing; private boolean playing;
private EntryAdapter.SongViewHolder viewHolder; private EntryAdapter.SongViewHolder viewHolder;
private boolean maximized = false;
public SongView(Context context) public SongView(Context context)
{ {
@ -427,6 +428,24 @@ public class SongView extends UpdateView implements Checkable
viewHolder.check.toggle(); viewHolder.check.toggle();
} }
public boolean isMaximized() {
return maximized;
}
public void maximizeOrMinimize() {
if (maximized) {
maximized = false;
} else {
maximized = true;
}
if (this.viewHolder.title != null) {
this.viewHolder.title.setSingleLine(!maximized);
}
if (this.viewHolder.artist != null) {
this.viewHolder.artist.setSingleLine(!maximized);
}
}
public enum ImageType public enum ImageType
{ {
none, none,