Search in sources :

Example 1 with ImageLoader

use of org.moire.ultrasonic.util.ImageLoader in project ultrasonic by ultrasonic.

the class ChatAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ChatMessage message = this.getItem(position);
    ViewHolder holder;
    int layout;
    String messageUser = message.getUsername();
    Date messageTime = new java.util.Date(message.getTime());
    String messageText = message.getMessage();
    String me = Util.getUserName(activity, Util.getActiveServer(activity));
    layout = messageUser.equals(me) ? R.layout.chat_item_reverse : R.layout.chat_item;
    if (convertView == null) {
        convertView = inflateView(layout, parent);
        holder = createViewHolder(layout, convertView);
    } else {
        holder = (ViewHolder) convertView.getTag();
        if (!holder.chatMessage.equals(message)) {
            convertView = inflateView(layout, parent);
            holder = createViewHolder(layout, convertView);
        }
    }
    holder.chatMessage = message;
    DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(activity);
    String messageTimeFormatted = String.format("[%s]", timeFormat.format(messageTime));
    ImageLoader imageLoader = activity.getImageLoader();
    if (imageLoader != null) {
        imageLoader.loadAvatarImage(holder.avatar, messageUser, false, holder.avatar.getWidth(), false, true);
    }
    holder.username.setText(messageUser);
    holder.message.setText(messageText);
    holder.time.setText(messageTimeFormatted);
    return convertView;
}
Also used : ChatMessage(org.moire.ultrasonic.domain.ChatMessage) DateFormat(java.text.DateFormat) ImageLoader(org.moire.ultrasonic.util.ImageLoader) Date(java.util.Date)

Example 2 with ImageLoader

use of org.moire.ultrasonic.util.ImageLoader in project ultrasonic by ultrasonic.

the class SubsonicTabActivity method getImageLoader.

public synchronized ImageLoader getImageLoader() {
    if (IMAGE_LOADER == null || !IMAGE_LOADER.isRunning()) {
        IMAGE_LOADER = new ImageLoader(this, Util.getImageLoaderConcurrency(this));
        IMAGE_LOADER.startImageLoader();
    }
    return IMAGE_LOADER;
}
Also used : ImageLoader(org.moire.ultrasonic.util.ImageLoader)

Example 3 with ImageLoader

use of org.moire.ultrasonic.util.ImageLoader in project ultrasonic by ultrasonic.

the class SettingsFragment method setImageLoaderConcurrency.

private static void setImageLoaderConcurrency(int concurrency) {
    SubsonicTabActivity instance = SubsonicTabActivity.getInstance();
    if (instance != null) {
        ImageLoader imageLoader = instance.getImageLoader();
        if (imageLoader != null) {
            imageLoader.stopImageLoader();
            imageLoader.setConcurrency(concurrency);
        }
    }
}
Also used : SubsonicTabActivity(org.moire.ultrasonic.activity.SubsonicTabActivity) ImageLoader(org.moire.ultrasonic.util.ImageLoader)

Aggregations

ImageLoader (org.moire.ultrasonic.util.ImageLoader)3 DateFormat (java.text.DateFormat)1 Date (java.util.Date)1 SubsonicTabActivity (org.moire.ultrasonic.activity.SubsonicTabActivity)1 ChatMessage (org.moire.ultrasonic.domain.ChatMessage)1