<commit_before>package com.codingspezis.android.metalonly.player.stream;

import android.content.*;
import android.os.*;
import android.widget.*;

/**
 * listener for stream (e.g. meta data)
 * 
 */
class StreamWatcher implements OnStreamListener {

	/**
	 * 
	 */
	private final PlayerService playerService;

	/**
	 * @param playerService
	 */
	StreamWatcher(PlayerService playerService) {
		this.playerService = playerService;
	}

	private String metadata;

	@Override
	public void metadataReceived(String data) {
		if (!data.equals(metadata) && data.trim().length() != 0) {
			// here we have new meta data
			metadata = data;
			this.playerService.addSongToHistory(metadata);
			this.playerService.playerService.notify(metadata);

			Intent metaIntent = new Intent(PlayerService.INTENT_METADATA);
			metaIntent.putExtra(PlayerService.EXTRA_META, data);
			this.playerService.sendBroadcast(metaIntent);
		}
	}

	public String getMetadata() {
		return metadata;
	}

	public void deleteMetadata() {
		metadata = null;
	}

	@Override
	public void errorOccurred(final String err, final boolean canPlay) {
		(new Handler(this.playerService.playerService.getMainLooper()))
				.post(new Runnable() {
					@Override
					public void run() {
						Toast.makeText(
								StreamWatcher.this.playerService.playerService,
								err, Toast.LENGTH_LONG).show();
						if (!canPlay) {
							Intent tmpIntent = new Intent(
									PlayerService.INTENT_STATUS);
							tmpIntent.putExtra(PlayerService.EXTRA_CONNECTED,
									false);
							StreamWatcher.this.playerService
									.sendBroadcast(tmpIntent);
						}
					}
				});
	}

	@Override
	public void streamTimeout() {
		this.playerService.clear(); // TODO: clean clean method

		/*
		 * TODO: make som noise here
		 * 
		 * Intent tmpIntent = new Intent(timeoutIntendAction);
		 * sendBroadcast(tmpIntent);
		 */
	}<commit_msg>Fixed ghosty play status on lost connection<commit_after>package com.codingspezis.android.metalonly.player.stream;

import android.content.*;
import android.os.*;
import android.widget.*;

/**
 * listener for stream (e.g. meta data)
 * 
 */
class StreamWatcher implements OnStreamListener {

	/**
	 * 
	 */
	private final PlayerService playerService;

	/**
	 * @param playerService
	 */
	StreamWatcher(PlayerService playerService) {
		this.playerService = playerService;
	}

	private String metadata;

	@Override
	public void metadataReceived(String data) {
		if (!data.equals(metadata) && data.trim().length() != 0) {
			// here we have new meta data
			metadata = data;
			this.playerService.addSongToHistory(metadata);
			this.playerService.playerService.notify(metadata);

			Intent metaIntent = new Intent(PlayerService.INTENT_METADATA);
			metaIntent.putExtra(PlayerService.EXTRA_META, data);
			this.playerService.sendBroadcast(metaIntent);
		}
	}

	public String getMetadata() {
		return metadata;
	}

	public void deleteMetadata() {
		metadata = null;
	}

	@Override
	public void errorOccurred(final String err, final boolean canPlay) {
		(new Handler(this.playerService.playerService.getMainLooper()))
				.post(new Runnable() {
					@Override
					public void run() {
						Toast.makeText(
								StreamWatcher.this.playerService.playerService,
								err, Toast.LENGTH_LONG).show();
						if (!canPlay) {
							Intent tmpIntent = new Intent(
									PlayerService.INTENT_STOP); // status will be sent automatically
							StreamWatcher.this.playerService
									.sendBroadcast(tmpIntent);
						}
					}
				});
	}

	@Override
	public void streamTimeout() {
		this.playerService.clear(); // TODO: clean clean method

		/*
		 * TODO: make som noise here
		 * 
		 * Intent tmpIntent = new Intent(timeoutIntendAction);
		 * sendBroadcast(tmpIntent);
		 */
	}
{'fraction_non_alphanumeric': 0.1118508655126498, 'fraction_numerical': 0.0005326231691078562, 'mean_word_length': 3.4661117717003567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5108530', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1086, 'n_words': 245}