<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.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.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class PlaylistRemoveActivity extends ListActivity implements StatusChangeListener, OnClickListener {
	private ArrayList<HashMap<String, Object>> songlist = new ArrayList<HashMap<String, Object>>();
	private List<Music> musics;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		MPDApplication app = (MPDApplication) getApplication();
		setContentView(R.layout.playlist_removelist_activity);
		this.setTitle("Remove Songs");
		try {
			MPDPlaylist playlist = app.oMPDAsyncHelper.oMPD.getPlaylist();

			playlist.refresh();
			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());
				item.put("marked", false);
				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_removelist_item, new String[] { "play", "title",
					"artist", "marked" }, new int[] { R.id.picture, android.R.id.text1, android.R.id.text2, R.id.removeCBox });

			setListAdapter(songs);
		} catch (MPDServerException e) {
		}

		app.oMPDAsyncHelper.addStatusChangeListener(this);

		ListView trackList = getListView();
		trackList.setOnCreateContextMenuListener(this);
		((TouchInterceptor) trackList).setDropListener(mDropListener);
		((TouchInterceptor) trackList).setRemoveListener(mRemoveListener);
		trackList.setCacheColorHint(0);

		Button button = (Button) findViewById(R.id.Remove);
		button.setOnClickListener(this);

		button = (Button) findViewById(R.id.Cancel);
		button.setOnClickListener(this);

	}

	/**
	 * Marks the selected item for deletion
	 * */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {<commit_msg>Implemented song moving. The update bug is still there<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.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.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class PlaylistRemoveActivity extends ListActivity implements StatusChangeListener, OnClickListener {
	private ArrayList<HashMap<String, Object>> songlist = new ArrayList<HashMap<String, Object>>();
	private List<Music> musics;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		MPDApplication app = (MPDApplication) getApplication();
		setContentView(R.layout.playlist_removelist_activity);
		this.setTitle("Remove Songs");
		try {
			MPDPlaylist playlist = app.oMPDAsyncHelper.oMPD.getPlaylist();

			playlist.refresh();
			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());
				item.put("marked", false);
				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_removelist_item, new String[] { "play", "title",
					"artist", "marked" }, new int[] { R.id.picture, android.R.id.text1, android.R.id.text2, R.id.removeCBox });

			setListAdapter(songs);
		} catch (MPDServerException e) {
		}

		app.oMPDAsyncHelper.addStatusChangeListener(this);

		ListView trackList = getListView();
		trackList.setOnCreateContextMenuListener(this);
		((TouchInterceptor) trackList).setDropListener(mDropListener);
		((TouchInterceptor) trackList).setRemoveListener(mRemoveListener);
		trackList.setCacheColorHint(0);

		Button button = (Button) findViewById(R.id.Remove);
		button.setOnClickListener(this);

		button = (Button) findViewById(R.id.Cancel);
		button.setOnClickListener(this);

	}

	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());
				item.put("marked", false);
				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_removelist_item, new String[] { "play", "title",
					"artist", "marked" }, new int[] { R.id.picture, android.R.id.text1, android.R.id.text2, R.id.removeCBox });

			setListAdapter(songs);
		} catch (MPDServerException e) {
		}

	}

	/**
	 * Marks the selected item for deletion
	 * */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
{'fraction_non_alphanumeric': 0.13287631271878647, 'fraction_numerical': 0.005105017502917153, 'mean_word_length': 5.155296229802514, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '3833958', 'n_tokens_mistral': 2528, 'n_tokens_neox': 2270, 'n_words': 417}