Android Open Source - intent_radio State






From Project

Back to project page intent_radio.

License

The source code is released under:

Copyright (c) 2014 Stephen Blott 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 Soft...

If you think the Android project intent_radio 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 org.smblott.intentradio;
//from   w  w  w  . jav a 2s.  c om
import android.content.Context;
import android.content.Intent;

public class State extends Logger
{
   private static Context context = null;
   private static String intent_state = null;

   public static final String STATE_STOP         = "stop";
   public static final String STATE_ERROR        = "error";
   public static final String STATE_COMPLETE     = "complete";
   public static final String STATE_PAUSE        = "play/pause";

   public static final String STATE_PLAY         = "play";
   public static final String STATE_BUFFER       = "play/buffering";
   public static final String STATE_DUCK         = "play/duck";
   public static final String STATE_DISCONNECTED = "play/disconnected";

   private static String current_state = STATE_STOP;
   private static boolean current_isNetworkUrl = false;

   public static void set_state(Context context, String s, boolean isNetworkUrl)
   {
      if ( s == null )
         return;

      if ( intent_state == null )
         intent_state = context.getString(R.string.intent_state);

      log("State.set_state(): ", s);
      current_state = s;
      current_isNetworkUrl = isNetworkUrl;
      Notify.note(isNetworkUrl);

      Intent intent = new Intent(intent_state);
      intent.putExtra("state", current_state);
      intent.putExtra("url", IntentPlayer.url);
      intent.putExtra("name", IntentPlayer.name);

      log("Broadcast: ", intent_state);
      log("Broadcast: state=", current_state);
      context.sendBroadcast(intent);
   }

   public static void get_state(Context context)
      { set_state(context, current_state, current_isNetworkUrl); }

   public static String current()
      { return current_state; }

   public static boolean is(String s)
      { return current_state.equals(s); }

   public static String text()
   {
      if ( is(STATE_STOP)         ) return "Stopped";
      if ( is(STATE_ERROR)        ) return "Error";
      if ( is(STATE_COMPLETE)     ) return "Complete";
      if ( is(STATE_PLAY)         ) return "Playing";
      if ( is(STATE_BUFFER)       ) return "Buffering..";
      if ( is(STATE_DUCK)         ) return "Ducked";
      if ( is(STATE_PAUSE)        ) return "Paused..";
      if ( is(STATE_DISCONNECTED) ) return "No network connection.";

      // Should not happen.
      return "Unknown";
   }

   // Paused is not in any of the following classes.
   //
   public static boolean is_playing()
      { return is(STATE_PLAY) || is(STATE_BUFFER) || is(STATE_DUCK); }

   public static boolean is_stopped()
      { return State.is(STATE_STOP) || State.is(STATE_ERROR) || State.is(STATE_COMPLETE); }

   public static boolean is_want_playing()
      { return is_playing() || is(STATE_ERROR); }
}




Java Source Code List

org.smblott.intentradio.Build.java
org.smblott.intentradio.ClipButtons.java
org.smblott.intentradio.Clipper.java
org.smblott.intentradio.Connectivity.java
org.smblott.intentradio.CopyResource.java
org.smblott.intentradio.Counter.java
org.smblott.intentradio.HttpGetter.java
org.smblott.intentradio.IntentPlayer.java
org.smblott.intentradio.IntentRadio.java
org.smblott.intentradio.Intents.java
org.smblott.intentradio.Later.java
org.smblott.intentradio.Logger.java
org.smblott.intentradio.Metadata.java
org.smblott.intentradio.Notify.java
org.smblott.intentradio.Now.java
org.smblott.intentradio.PlaylistM3u.java
org.smblott.intentradio.PlaylistPls.java
org.smblott.intentradio.Playlist.java
org.smblott.intentradio.PreferenceActivity.java
org.smblott.intentradio.Prefs.java
org.smblott.intentradio.ReadRawTextFile.java
org.smblott.intentradio.State.java
org.smblott.intentradio.WifiLocker.java