@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Intent scheduleIntent = new Intent(this, Schedule.class); Channel channel = (Channel) l.getItemAtPosition(position); ((GuiaTvApp) getApplication()).setChoice(channel); startActivity(scheduleIntent); Log.d(TAG, channel.toString()); }
public static void main(String[] args) { ChannelCollection listeChannel = new ChannelCollectionImpl(); listeChannel.addChannel(new Channel("M6 Kids", ChannelTypeEnum.KIDS)); listeChannel.addChannel(new Channel("M6 Music", ChannelTypeEnum.MUSIC)); listeChannel.addChannel(new Channel("M6 Pipo", ChannelTypeEnum.NEWS)); listeChannel.addChannel(new Channel("M6", ChannelTypeEnum.GENERAL)); ChannelIterator it = listeChannel.iterator(ChannelTypeEnum.GENERAL); while (it.hasNext()) { Channel c = it.next(); System.out.println(c.toString()); } System.out.println("****"); it = listeChannel.iterator(ChannelTypeEnum.KIDS); while (it.hasNext()) { Channel c = it.next(); System.out.println(c.toString()); } }
/** * @param persoLevel - Mettre 0 si on ne veut pas prendre en compte les limitations de range de * niveau. * @param state - L'état du channel de combat (Preparing, Active, Looting) * @return */ public StringBuilder getChannelsList(int persoLevel, byte state) { StringBuilder sb = new StringBuilder(channels.size() * 10); // jai mit 10 completement au hasard, à refaire. for (Channel c : channels.values()) { if (c.getState() == state) { if (persoLevel == 0 || c.getLevelMin() <= persoLevel && c.getLevelMax() >= persoLevel) { if (sb.length() != 0) { sb.append("|"); } sb.append(c.toString()); } } } return sb; }
@Override protected boolean internalReceiveChanneledCommand( String itemName, Command command, Channel sChannel, String commandAsString) { ProtocolBindingProvider provider = findFirstMatchingBindingProvider(itemName); if (command != null) { String transformedMessage = transformResponse(provider.getProtocolCommand(itemName, command), commandAsString); String UDPCommandName = preAmble + transformedMessage + postAmble; ByteBuffer outputBuffer = ByteBuffer.allocate(UDPCommandName.getBytes().length); try { outputBuffer.put(UDPCommandName.getBytes("ASCII")); } catch (UnsupportedEncodingException e) { logger.warn("Exception while attempting an unsupported encoding scheme"); } // send the buffer in an asynchronous way ByteBuffer result = null; try { result = writeBuffer(outputBuffer, sChannel, blocking, timeOut); } catch (Exception e) { logger.error( "An exception occurred while writing a buffer to a channel: {}", e.getMessage()); } if (result != null && blocking) { logger.info( "Received {} from the remote end {}", new String(result.array()), sChannel.toString()); String transformedResponse = transformResponse( provider.getProtocolCommand(itemName, command), new String(result.array())); // if the remote-end does not send a reply in response to the string we just sent, then the // abstract superclass will update // the openhab status of the item for us. If it does reply, then an additional update is // done via parseBuffer. // since this TCP binding does not know about the specific protocol, there might be two // state updates (the command, and if // the case, the reply from the remote-end) if (updateWithResponse) { List<Class<? extends State>> stateTypeList = provider.getAcceptedDataTypes(itemName, command); State newState = createStateFromString(stateTypeList, transformedResponse); if (newState != null) { eventPublisher.postUpdate(itemName, newState); } else { logger.warn( "Can not parse transformed input " + transformedResponse + " to match command {} on item {} ", command, itemName); } return false; } else { return true; } } else { return true; } } return false; }
public void connected(Channel channel) { System.out.println("Connexion sur le channel : " + channel.toString()); }