Search in sources :

Example 1 with AirPlayService

use of com.connectsdk.service.AirPlayService in project butter-android by butterproject.

the class BeamDeviceAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.casting_dialog_listitem, parent, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    ConnectableDevice device = getItem(position);
    int imgResource = R.drawable.ic_dlna;
    Collection<DeviceService> services = device.getServices();
    ArrayList<String> textServices = new ArrayList<>(services.size());
    for (DeviceService service : services) {
        if (service instanceof CastService) {
            imgResource = R.drawable.ic_googlecast;
            textServices.add("Google Cast");
        } else if (service instanceof DLNAService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("DLNA");
        } else if (service instanceof AirPlayService) {
            imgResource = R.drawable.ic_airplay;
            textServices.add("AirPlay");
        } else if (service instanceof RokuService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("Roku");
        } else if (service instanceof WebOSTVService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("webOS TV");
        } else if (service instanceof NetcastTVService) {
            imgResource = R.drawable.ic_dlna;
            textServices.add("Netcast");
        }
    }
    String serviceText;
    if (textServices.size() == 0) {
        serviceText = "Beaming Device";
    } else {
        serviceText = TextUtils.join(",", textServices);
    }
    holder.icon.setImageResource(imgResource);
    holder.text1.setText(device.getFriendlyName());
    holder.text2.setText(serviceText);
    return convertView;
}
Also used : NetcastTVService(com.connectsdk.service.NetcastTVService) ConnectableDevice(com.connectsdk.device.ConnectableDevice) AirPlayService(com.connectsdk.service.AirPlayService) CastService(com.connectsdk.service.CastService) DeviceService(com.connectsdk.service.DeviceService) ArrayList(java.util.ArrayList) WebOSTVService(com.connectsdk.service.WebOSTVService) DLNAService(com.connectsdk.service.DLNAService) RokuService(com.connectsdk.service.RokuService)

Aggregations

ConnectableDevice (com.connectsdk.device.ConnectableDevice)1 AirPlayService (com.connectsdk.service.AirPlayService)1 CastService (com.connectsdk.service.CastService)1 DLNAService (com.connectsdk.service.DLNAService)1 DeviceService (com.connectsdk.service.DeviceService)1 NetcastTVService (com.connectsdk.service.NetcastTVService)1 RokuService (com.connectsdk.service.RokuService)1 WebOSTVService (com.connectsdk.service.WebOSTVService)1 ArrayList (java.util.ArrayList)1