Пример #1
0
 protected void setMessages(List<MosaicMessage> msgs) {
   if (msgs != null) {
     ArrayList<Long> newIds = new ArrayList<Long>();
     for (MosaicMessage msg : msgs) {
       if (iMain != null) {
         try {
           if (messages.containsKey(msg.getId())
               && (messages.get(msg.getId()).getRadius() == msg.getRadius()))
             iMain.addMessage(
                 msg.getId(),
                 fromE6(msg.getLatitudeE6()),
                 fromE6(msg.getLongitudeE6()),
                 Mosaic.RADIUS_UNCHANGED,
                 msg.getTitle(),
                 msg.getBody(),
                 msg.getUser().getNickname());
           else
             iMain.addMessage(
                 msg.getId(),
                 fromE6(msg.getLatitudeE6()),
                 fromE6(msg.getLongitudeE6()),
                 msg.getRadius(),
                 msg.getTitle(),
                 msg.getBody(),
                 msg.getUser().getNickname());
         } catch (RemoteException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
         }
       }
       messages.put(msg.getId(), msg);
       newIds.add(msg.getId());
     }
     ArrayList<Long> removalIds = new ArrayList<Long>();
     for (Long id : messages.keySet()) {
       if (!newIds.contains(id)) removalIds.add(id);
     }
     for (Long id : removalIds) {
       messages.remove(id);
       if (iMain != null) {
         try {
           iMain.removeMarker(id);
         } catch (RemoteException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
         }
       }
     }
   } else {
     messages.clear();
     if (iMain != null) {
       try {
         iMain.clearMessages();
       } catch (RemoteException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
 }
Пример #2
0
 protected void updateMessage(MosaicMessage message) {
   messages.put(message.getId(), message);
   if (iMain != null) {
     try {
       iMain.addMessage(
           message.getId(),
           fromE6(message.getLatitudeE6()),
           fromE6(message.getLongitudeE6()),
           message.getRadius(),
           message.getTitle(),
           message.getBody(),
           message.getUser().getNickname());
     } catch (RemoteException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
Пример #3
0
 @Override
 public void getMessage(long id) throws RemoteException {
   if (messages.containsKey((Long) id)) {
     MosaicMessage message = messages.get((Long) id);
     new ViewMessageTask(MosaicService.this, id).execute();
     if (message.getUserId().equals(mosaicUser.getId()))
       iMain.editMessage(
           message.getId(),
           message.getTitle(),
           message.getBody(),
           message.getRadius(),
           message.getExpiry());
     else
       iMain.viewMessage(
           message.getId(),
           message.getTitle(),
           message.getBody(),
           message.getUser().getNickname());
   } else {
     // TODO error
   }
 }