Android Open Source - nagare Download Thread






From Project

Back to project page nagare.

License

The source code is released under:

Copyright (c) 2011 peterh@sapros.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the ...

If you think the Android project nagare listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.giantrabbit.nagare;
//  w w  w  .j a  v a 2  s.c  o m
import android.content.Context;
import android.os.Process;

import java.net.URL;
import java.net.URLConnection;

public class DownloadThread extends Thread
{
  public Context m_context;
  public String m_errors = "";
  public URL m_url;
  public ShoutcastFile m_shoutcast_file = null;
  
  public DownloadThread(Context context, URL url)
  {
    m_context = context;
    m_url = url;
  }
  
  public void done()
  {
    if (m_shoutcast_file != null)
    {
      m_shoutcast_file.done();
    }
  }
  
  public String errors()
  {
    if (m_shoutcast_file != null)
    {
      return m_errors + m_shoutcast_file.errors();
    }
    return m_errors;
  }
  
  public void run()
  {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    try
    {
      URLConnection connection = m_url.openConnection();
      connection.setRequestProperty("User-Agent", "Nagare");
      connection.connect();
      m_shoutcast_file = new ShoutcastFile(m_context, connection);
      m_shoutcast_file.download(this, connection.getInputStream());
    }
    catch (Exception e)
    {
      m_errors += e.toString() + "\n";
    }
  }
}




Java Source Code List

com.giantrabbit.nagare.DownloadThread.java
com.giantrabbit.nagare.INagareService.java
com.giantrabbit.nagare.M3UFile.java
com.giantrabbit.nagare.NagareService.java
com.giantrabbit.nagare.Nagare.java
com.giantrabbit.nagare.PlayListFactory.java
com.giantrabbit.nagare.PlayListFile.java
com.giantrabbit.nagare.PlayList.java
com.giantrabbit.nagare.PlsFile.java
com.giantrabbit.nagare.ShoutcastFile.java