<commit_before>package cc.rainwave.android;

import cc.rainwave.android.api.Session;
import cc.rainwave.android.api.types.ScheduleOrganizer;
import cc.rainwave.android.api.types.Song;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.IOException;

public class NowPlayingActivity extends Activity {
	private static final String TAG = "NowPlaying";
	
	private ScheduleOrganizer mOrganizer;
	
	private Session mSession;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_nowplaying);
        initialize();
    }
    
    private void initialize() {
    	try {
			mSession = Session.makeSession();
			
			// TODO: Make this happen somewhere other than the UI thread.
			mOrganizer = mSession.asyncGet();
			
			updateSchedule();
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
    
    private void updateSchedule() {
    	if(mOrganizer == null) return;
    	
    	
    	Song current = mOrganizer.getCurrentSong();
    	((TextView) findViewById(R.id.np_songTitle)).setText(current.song_title);
    	((TextView) findViewById(R.id.np_albumTitle)).setText(current.album_name);
    	((TextView) findViewById(R.id.np_artist)).setText(current.collapseArtists());
    	
    	// TODO: Make this happen somewhere other than the UI thread.
    	try {
    	    Drawable albumArt = mSession.fetchAlbumArt(current.album_art);
    	    ((ImageView) findViewById(R.id.np_albumArt)).setImageDrawable(albumArt);
    	}
    	catch(IOException e) {
    	    e.printStackTrace();
    	}
    }
}<commit_msg>Fetching of now playing info moved to separate thread<commit_after>package cc.rainwave.android;

import cc.rainwave.android.api.Session;
import cc.rainwave.android.api.types.ScheduleOrganizer;
import cc.rainwave.android.api.types.Song;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.IOException;
import java.net.MalformedURLException;

public class NowPlayingActivity extends Activity {
	private static final String TAG = "NowPlaying";
	
	private ScheduleOrganizer mOrganizer;
	
	private Session mSession;
	
	private FetchInfo mFetchInfo;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_nowplaying);
    }
    
    @Override
    public void onStart() {
        super.onStart();
    }
    
    @Override
    public void onResume() {
        super.onResume();
        if(mSession == null) {
            initializeSession();
        }
        
        fetchSchedules();
    }
    
    private void initializeSession() {
        try {
            mSession = Session.makeSession();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    
    private void fetchSchedules() {
        if(mSession == null) {
            // TODO: Some error here.
            return;
        }
        
        if(mFetchInfo == null) {
            mFetchInfo = new FetchInfo();
            mFetchInfo.execute(mSession);
        }
    }
    
    private void updateSchedule() {
    	if(mOrganizer == null) return;
    	
    	Song current = mOrganizer.getCurrentSong();
    	((TextView) findViewById(R.id.np_songTitle)).setText(current.song_title);
    	((TextView) findViewById(R.id.np_albumTitle)).setText(current.album_name);
    	((TextView) findViewById(R.id.np_artist)).setText(current.collapseArtists());
    	
    	// TODO: Make this happen somewhere other than the UI thread.
    	try {
    	    Drawable albumArt = mSession.fetchAlbumArt(current.album_art);
    	    ((ImageView) findViewById(R.id.np_albumArt)).setImageDrawable(albumArt);
    	}
    	catch(IOException e) {
    	    e.printStackTrace();
    	}
    }
    
    /**
     * Fetches the now playing info.
     * @author pkilgo
     *
     */
    protected class FetchInfo extends AsyncTask<Session, Integer, ScheduleOrganizer> {

        @Override
        protected ScheduleOrganizer doInBackground(Session... s) {
            try {
                return s[0].asyncGet();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
        
        protected void onPostExecute(ScheduleOrganizer result) {
            super.onPostExecute(result);
            mOrganizer = result;
            updateSchedule();
            mFetchInfo = null;
        }
        
    }
}
{'fraction_non_alphanumeric': 0.10130515848353014, 'fraction_numerical': 0.00020716801325875285, 'mean_word_length': 2.5683665927568367, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5518902', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1343, 'n_words': 287}