Android Open Source - controldlna Route Adapter






From Project

Back to project page controldlna.

License

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.support.v7.media.MediaRouter.RouteInfo;
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>() {
    @Override
    public int compare(RouteInfo lhs, RouteInfo rhs) {
      return lhs.getName().compareTo(rhs.getName());
    }
  };

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

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

    TextView title = (TextView) convertView.findViewById(R.id.title);
    title.setText(getItem(position).getName());

    TextView subtitle = (TextView) convertView.findViewById(R.id.subtitle);
    subtitle.setText(getItem(position).getDescription());

    return convertView;
  }

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

}




Java Source Code List

com.github.nutomic.controldlna.gui.MainActivity.java
com.github.nutomic.controldlna.gui.PreferencesActivity.java
com.github.nutomic.controldlna.gui.RouteFragment.java
com.github.nutomic.controldlna.gui.ServerFragment.java
com.github.nutomic.controldlna.localroute.Controller.java
com.github.nutomic.controldlna.localroute.ProviderService.java
com.github.nutomic.controldlna.localroute.Provider.java
com.github.nutomic.controldlna.mediarouter.MediaRouterPlayServiceBinder.java
com.github.nutomic.controldlna.mediarouter.MediaRouterPlayService.java
com.github.nutomic.controldlna.upnp.ProviderService.java
com.github.nutomic.controldlna.upnp.Provider.java
com.github.nutomic.controldlna.upnp.RemotePlayServiceBinder.java
com.github.nutomic.controldlna.upnp.RemotePlayService.java
com.github.nutomic.controldlna.utility.DeviceArrayAdapter.java
com.github.nutomic.controldlna.utility.FileArrayAdapter.java
com.github.nutomic.controldlna.utility.LoadImageTask.java
com.github.nutomic.controldlna.utility.RemoteImageView.java
com.github.nutomic.controldlna.utility.RouteAdapter.java