mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-03-13 10:00:23 +01:00
Fix adapter using toString() method for entry.
Replace it to use getName(). Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
4ab4351cb4
commit
12c68d9ebf
@ -19,8 +19,14 @@
|
|||||||
package org.moire.ultrasonic.view;
|
package org.moire.ultrasonic.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.moire.ultrasonic.R;
|
import org.moire.ultrasonic.R;
|
||||||
import org.moire.ultrasonic.domain.Artist;
|
import org.moire.ultrasonic.domain.Artist;
|
||||||
@ -35,6 +41,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexer
|
public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexer
|
||||||
{
|
{
|
||||||
|
private final LayoutInflater layoutInflater;
|
||||||
|
|
||||||
// Both arrays are indexed by section ID.
|
// Both arrays are indexed by section ID.
|
||||||
private final Object[] sections;
|
private final Object[] sections;
|
||||||
@ -44,6 +51,8 @@ public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexe
|
|||||||
{
|
{
|
||||||
super(context, R.layout.artist_list_item, artists);
|
super(context, R.layout.artist_list_item, artists);
|
||||||
|
|
||||||
|
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
Collection<String> sectionSet = new LinkedHashSet<String>(30);
|
Collection<String> sectionSet = new LinkedHashSet<String>(30);
|
||||||
List<Integer> positionList = new ArrayList<Integer>(30);
|
List<Integer> positionList = new ArrayList<Integer>(30);
|
||||||
|
|
||||||
@ -63,6 +72,23 @@ public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexe
|
|||||||
positions = positionList.toArray(new Integer[positionList.size()]);
|
positions = positionList.toArray(new Integer[positionList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public View getView(
|
||||||
|
int position,
|
||||||
|
@Nullable View convertView,
|
||||||
|
@NonNull ViewGroup parent
|
||||||
|
) {
|
||||||
|
View rowView = convertView;
|
||||||
|
if (rowView == null) {
|
||||||
|
rowView = layoutInflater.inflate(R.layout.artist_list_item, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
((TextView) rowView).setText(getItem(position).getName());
|
||||||
|
|
||||||
|
return rowView;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] getSections()
|
public Object[] getSections()
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,14 @@
|
|||||||
package org.moire.ultrasonic.view;
|
package org.moire.ultrasonic.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.moire.ultrasonic.R;
|
import org.moire.ultrasonic.R;
|
||||||
import org.moire.ultrasonic.domain.Genre;
|
import org.moire.ultrasonic.domain.Genre;
|
||||||
@ -35,7 +41,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
|
public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
|
||||||
{
|
{
|
||||||
|
private final LayoutInflater layoutInflater;
|
||||||
// Both arrays are indexed by section ID.
|
// Both arrays are indexed by section ID.
|
||||||
private final Object[] sections;
|
private final Object[] sections;
|
||||||
private final Integer[] positions;
|
private final Integer[] positions;
|
||||||
@ -44,6 +50,8 @@ public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
|
|||||||
{
|
{
|
||||||
super(context, R.layout.artist_list_item, genres);
|
super(context, R.layout.artist_list_item, genres);
|
||||||
|
|
||||||
|
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
Collection<String> sectionSet = new LinkedHashSet<String>(30);
|
Collection<String> sectionSet = new LinkedHashSet<String>(30);
|
||||||
List<Integer> positionList = new ArrayList<Integer>(30);
|
List<Integer> positionList = new ArrayList<Integer>(30);
|
||||||
|
|
||||||
@ -62,7 +70,20 @@ public class GenreAdapter extends ArrayAdapter<Genre> implements SectionIndexer
|
|||||||
positions = positionList.toArray(new Integer[positionList.size()]);
|
positions = positionList.toArray(new Integer[positionList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||||
|
View rowView = convertView;
|
||||||
|
if (rowView == null) {
|
||||||
|
rowView = layoutInflater.inflate(R.layout.artist_list_item, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
((TextView) rowView).setText(getItem(position).getName());
|
||||||
|
|
||||||
|
return rowView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object[] getSections()
|
public Object[] getSections()
|
||||||
{
|
{
|
||||||
return sections;
|
return sections;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user