Android Open Source - controldlna Route Adapter

From Project

Back to project page controldlna.


The source code is released under:

Copyright (c) 2013, Felix Ableitner All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:...

If you think the Android project controldlna listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.nutomic.controldlna.utility;
/*  www.ja v a 2 s.c o m*/
import java.util.Comparator;
import java.util.List;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.github.nutomic.controldlna.R;

public class RouteAdapter extends ArrayAdapter<RouteInfo> {

   * Sorts routes by name. Call {@code sort(COMPARATOR)} whenever an item is inserted.
  public static final Comparator COMPARATOR = new Comparator<RouteInfo>() {
    public int compare(RouteInfo lhs, RouteInfo rhs) {
      return lhs.getName().compareTo(rhs.getName());

  public RouteAdapter(Context context) {
    super(context, R.layout.list_item);

  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater inflater = (LayoutInflater) getContext()
      convertView = inflater.inflate(R.layout.list_item, parent, false);

    TextView title = (TextView) convertView.findViewById(;

    TextView subtitle = (TextView) convertView.findViewById(;

    return convertView;

   * Replacement for addAll, which is not implemented on lower API levels.
  public void add(List<RouteInfo> routes) {
    for (RouteInfo r : routes) {


Java Source Code List