Search in sources :

Example 1 with NotificationVO

use of com.chrishoekstra.trello.vo.NotificationVO in project Trello-Android by chrisHoekstra.

the class TrelloModel method setNotifications.

public void setNotifications(ArrayList<NotificationVO> notifications) {
    mNotifications = notifications;
    int count;
    for (NotificationVO notification : notifications) {
        if (notification.data.card != null) {
            count = 0;
            if (mCardNotifications.containsKey(notification.data.card.id)) {
                count = mCardNotifications.get(notification.data.card.id);
            }
            mCardNotifications.put(notification.data.card.id, count);
        }
    }
}
Also used : NotificationVO(com.chrishoekstra.trello.vo.NotificationVO)

Example 2 with NotificationVO

use of com.chrishoekstra.trello.vo.NotificationVO in project Trello-Android by chrisHoekstra.

the class TrelloService method getNotifications.

public ArrayList<NotificationVO> getNotifications() {
    ArrayList<NotificationVO> result = null;
    ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    params.add(new BasicNameValuePair("key", PUBLIC_KEY));
    params.add(new BasicNameValuePair("token", mToken));
    HttpGet httpGet = new HttpGet(TRELLO_API_URL + "members/" + "me/" + "notifications?" + URLEncodedUtils.format(params, "UTF-8"));
    HttpClient httpClient = getHttpClient();
    try {
        httpGet.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
        httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT_STRING);
        HttpResponse response = httpClient.execute(httpGet, mContext);
        if (response != null) {
            result = mObjectMapper.readValue(mJsonFactory.createJsonParser(new InputStreamReader(response.getEntity().getContent(), "UTF-8")), new TypeReference<ArrayList<NotificationVO>>() {
            });
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
Also used : InputStreamReader(java.io.InputStreamReader) NotificationVO(com.chrishoekstra.trello.vo.NotificationVO) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) HttpGet(org.apache.http.client.methods.HttpGet) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) ClientProtocolException(org.apache.http.client.ClientProtocolException)

Example 3 with NotificationVO

use of com.chrishoekstra.trello.vo.NotificationVO in project Trello-Android by chrisHoekstra.

the class NotificationsAdapter method getView.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.notification_row, null);
        holder = new ViewHolder();
        holder.notificationText = (TextView) convertView.findViewById(R.id.notification_text);
        holder.dateText = (TextView) convertView.findViewById(R.id.date);
        holder.gravatar = (GravatarView) convertView.findViewById(R.id.gravatar);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    NotificationVO notification = mNotifications.get(position);
    if (notification != null) {
        holder.notificationText.setText(Utils.getHtmlFormattedNotificationText(notification));
        holder.dateText.setText(Utils.getFormattedStringFromDate(notification.date));
        //MemberVO member = mModel.getAllBoardsResult().members.get(mModel.getAllBoardsResult().members.indexOf(notification.idMemberCreator));
        //holder.gravatar.setInitials(member.initials);
        holder.gravatar.setDefaultImageType(GravatarAPI.DEFAULT_IMAGE_404);
        holder.gravatar.setAvatarURL(GravatarAPI.getAvatarURLById(mModel.getGravatarId(notification.idMemberCreator)));
    }
    return convertView;
}
Also used : NotificationVO(com.chrishoekstra.trello.vo.NotificationVO)

Aggregations

NotificationVO (com.chrishoekstra.trello.vo.NotificationVO)3 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 HttpResponse (org.apache.http.HttpResponse)1 ClientProtocolException (org.apache.http.client.ClientProtocolException)1 HttpClient (org.apache.http.client.HttpClient)1 HttpGet (org.apache.http.client.methods.HttpGet)1 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)1 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)1 TypeReference (org.codehaus.jackson.type.TypeReference)1