<commit_before>package com.namelessdev.mpdroid;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.a0z.mpd.MPDPlaylist;
import org.a0z.mpd.MPDServerException;
import org.a0z.mpd.MPDStatus;
import org.a0z.mpd.Music;
import org.a0z.mpd.event.MPDConnectionStateChangedEvent;
import org.a0z.mpd.event.MPDPlaylistChangedEvent;
import org.a0z.mpd.event.MPDRandomChangedEvent;
import org.a0z.mpd.event.MPDRepeatChangedEvent;
import org.a0z.mpd.event.MPDStateChangedEvent;
import org.a0z.mpd.event.MPDTrackChangedEvent;
import org.a0z.mpd.event.MPDUpdateStateChangedEvent;
import org.a0z.mpd.event.MPDVolumeChangedEvent;
import org.a0z.mpd.event.StatusChangeListener;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class PlaylistActivity extends ListActivity implements OnClickListener, OnMenuItemClickListener, StatusChangeListener {
	private ArrayList<HashMap<String, Object>> songlist;
	private List<Music> musics;
	private int arrayListId;
	private int songId;
	private String title;

	public static final int MAIN = 0;
	public static final int CLEAR = 1;
	public static final int EDIT = 2;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		MPDApplication app = (MPDApplication) getApplication();
		setContentView(R.layout.playlist_activity);
		this.setTitle(R.string.nowPlaying);
		app.oMPDAsyncHelper.addStatusChangeListener(this);
		ListView list = getListView();
		/*
		 * LinearLayout test = (LinearLayout)list.getChildAt(1); ImageView img = (ImageView)test.findViewById(R.id.picture); //ImageView img =
		 * (ImageView)((LinearLayout)list.getItemAtPosition(3)).findViewById(R.id.picture);
		 * img.setImageDrawable(getResources().getDrawable(R.drawable.gmpcnocover));
		 */

		registerForContextMenu(list);

		Button button = (Button) findViewById(R.id.headerButton);
		button.setVisibility(View.VISIBLE);
		button.setOnClickListener(this);

		TextView title = (TextView) findViewById(R.id.headerText);
		title.setText(this.getTitle());

		ImageView icon = (ImageView) findViewById(R.id.headerIcon);
		icon.setImageDrawable(getResources().getDrawable(R.drawable.ic_tab_playlists_selected));

	}

	protected void update() {
		MPDApplication app = (MPDApplication) getApplicationContext();
		try {
			MPDPlaylist playlist = app.oMPDAsyncHelper.oMPD.getPlaylist();
			playlist.refresh();
			songlist = new ArrayList<HashMap<String, Object>>();
			musics = playlist.getMusics();
			for (Music m : musics) {
				HashMap<String, Object> item = new HashMap<String, Object>();
				item.put("songid", m.getSongId());
				item.put("artist", m.getArtist());
				item.put("title", m.getTitle());
				if (m.getSongId() == app.oMPDAsyncHelper.oMPD.getStatus().getSongId())
					item.put("play", android.R.drawable.ic_media_play);
				else
					item.put("play", 0);
				songlist.add(item);
			}
			SimpleAdapter songs = new SimpleAdapter(this, songlist, R.layout.playlist_list_item, new String[] { "play", "title", "artist" },
					new int[] { R.id.picture, android.R.id.text1, android.R.id.text2 });

			setListAdapter(songs);
		} catch (MPDServerException e) {
		}<commit_msg>Big optimisation, thanks to shortfuse<commit_after>package com.namelessdev.mpdroid;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.a0z.mpd.MPDPlaylist;
import org.a0z.mpd.MPDServerException;
import org.a0z.mpd.MPDStatus;
import org.a0z.mpd.Music;
import org.a0z.mpd.event.MPDConnectionStateChangedEvent;
import org.a0z.mpd.event.MPDPlaylistChangedEvent;
import org.a0z.mpd.event.MPDRandomChangedEvent;
import org.a0z.mpd.event.MPDRepeatChangedEvent;
import org.a0z.mpd.event.MPDStateChangedEvent;
import org.a0z.mpd.event.MPDTrackChangedEvent;
import org.a0z.mpd.event.MPDUpdateStateChangedEvent;
import org.a0z.mpd.event.MPDVolumeChangedEvent;
import org.a0z.mpd.event.StatusChangeListener;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class PlaylistActivity extends ListActivity implements OnClickListener, OnMenuItemClickListener, StatusChangeListener {
	private ArrayList<HashMap<String, Object>> songlist;
	private List<Music> musics;
	private int arrayListId;
	private int songId;
	private String title;

	public static final int MAIN = 0;
	public static final int CLEAR = 1;
	public static final int EDIT = 2;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		MPDApplication app = (MPDApplication) getApplication();
		setContentView(R.layout.playlist_activity);
		this.setTitle(R.string.nowPlaying);
		app.oMPDAsyncHelper.addStatusChangeListener(this);
		ListView list = getListView();
		/*
		 * LinearLayout test = (LinearLayout)list.getChildAt(1); ImageView img = (ImageView)test.findViewById(R.id.picture); //ImageView img =
		 * (ImageView)((LinearLayout)list.getItemAtPosition(3)).findViewById(R.id.picture);
		 * img.setImageDrawable(getResources().getDrawable(R.drawable.gmpcnocover));
		 */

		registerForContextMenu(list);

		Button button = (Button) findViewById(R.id.headerButton);
		button.setVisibility(View.VISIBLE);
		button.setOnClickListener(this);

		TextView title = (TextView) findViewById(R.id.headerText);
		title.setText(this.getTitle());

		ImageView icon = (ImageView) findViewById(R.id.headerIcon);
		icon.setImageDrawable(getResources().getDrawable(R.drawable.ic_tab_playlists_selected));

	}

	protected void update() {
		MPDApplication app = (MPDApplication) getApplicationContext();
		try {
			MPDPlaylist playlist = app.oMPDAsyncHelper.oMPD.getPlaylist();
			playlist.refresh();
			songlist = new ArrayList<HashMap<String, Object>>();
			musics = playlist.getMusics();
			int playingID = app.oMPDAsyncHelper.oMPD.getStatus().getSongId();
			for (Music m : musics) {
				HashMap<String, Object> item = new HashMap<String, Object>();
				item.put("songid", m.getSongId());
				item.put("artist", m.getArtist());
				item.put("title", m.getTitle());
				if (m.getSongId() == playingID)
					item.put("play", android.R.drawable.ic_media_play);
				else
					item.put("play", 0);
				songlist.add(item);
			}
			SimpleAdapter songs = new SimpleAdapter(this, songlist, R.layout.playlist_list_item, new String[] { "play", "title", "artist" },
					new int[] { R.id.picture, android.R.id.text1, android.R.id.text2 });

			setListAdapter(songs);
		} catch (MPDServerException e) {
		}
{'fraction_non_alphanumeric': 0.12327443401435671, 'fraction_numerical': 0.005797901711761457, 'mean_word_length': 5.503590664272891, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7586752', 'n_tokens_mistral': 2544, 'n_tokens_neox': 2318, 'n_words': 433}