mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 21:28:08 +00:00
android: replace State java class by an enum
This commit is contained in:
parent
b21ac0cc00
commit
0ce2d7cdfb
1 changed files with 32 additions and 40 deletions
|
|
@ -18,7 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)}
|
||||
|
|
@ -30,104 +29,97 @@ public interface LinphoneCall {
|
|||
* Linphone call states
|
||||
*
|
||||
*/
|
||||
static class State {
|
||||
@SuppressWarnings("unchecked")
|
||||
static private Vector values = new Vector();
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
enum State {
|
||||
/**
|
||||
* Idle
|
||||
*/
|
||||
public final static State Idle = new State(0,"Idle");
|
||||
Idle(0, "Idle"),
|
||||
/**
|
||||
* Incoming call received.
|
||||
*/
|
||||
public final static State IncomingReceived = new State(1,"IncomingReceived");
|
||||
IncomingReceived(1, "IncomingReceived"),
|
||||
/**
|
||||
* Outgoing call initialiazed.
|
||||
*/
|
||||
public final static State OutgoingInit = new State(2,"OutgoingInit");
|
||||
OutgoingInit(2, "OutgoingInit"),
|
||||
/**
|
||||
* Outgoing call in progress.
|
||||
*/
|
||||
public final static State OutgoingProgress = new State(3,"OutgoingProgress");
|
||||
OutgoingProgress(3, "OutgoingProgress"),
|
||||
/**
|
||||
* Outgoing call ringing.
|
||||
*/
|
||||
public final static State OutgoingRinging = new State(4,"OutgoingRinging");
|
||||
OutgoingRinging(4, "OutgoingRinging"),
|
||||
/**
|
||||
* Outgoing call early media
|
||||
*/
|
||||
public final static State OutgoingEarlyMedia = new State(5,"OutgoingEarlyMedia");
|
||||
OutgoingEarlyMedia(5, "OutgoingEarlyMedia"),
|
||||
/**
|
||||
* Connected
|
||||
*/
|
||||
public final static State Connected = new State(6,"Connected");
|
||||
Connected(6, "Connected"),
|
||||
/**
|
||||
* Streams running
|
||||
*/
|
||||
public final static State StreamsRunning = new State(7,"StreamsRunning");
|
||||
StreamsRunning(7, "StreamsRunning"),
|
||||
/**
|
||||
* Paussing
|
||||
* Pausing
|
||||
*/
|
||||
public final static State Pausing = new State(8,"Pausing");
|
||||
Pausing(8, "Pausing"),
|
||||
/**
|
||||
* Paused
|
||||
*/
|
||||
public final static State Paused = new State(9,"Paused");
|
||||
Paused(9, "Paused"),
|
||||
/**
|
||||
* Resuming
|
||||
*/
|
||||
public final static State Resuming = new State(10,"Resuming");
|
||||
Resuming(10, "Resuming"),
|
||||
/**
|
||||
* Refered
|
||||
*/
|
||||
public final static State Refered = new State(11,"Refered");
|
||||
Refered(11,"Refered"),
|
||||
/**
|
||||
* Error
|
||||
*/
|
||||
public final static State Error = new State(12,"Error");
|
||||
Error(12,"Error"),
|
||||
/**
|
||||
* Call end
|
||||
*/
|
||||
public final static State CallEnd = new State(13,"CallEnd");
|
||||
|
||||
CallEnd(13,"CallEnd"),
|
||||
/**
|
||||
* Paused by remote
|
||||
*/
|
||||
public final static State PausedByRemote = new State(14,"PausedByRemote");
|
||||
|
||||
PausedByRemote(14,"PausedByRemote"),
|
||||
/**
|
||||
* The call's parameters are updated, used for example when video is asked by remote
|
||||
*/
|
||||
public static final State CallUpdatedByRemote = new State(15, "CallUpdatedByRemote");
|
||||
|
||||
CallUpdatedByRemote(15, "CallUpdatedByRemote"),
|
||||
/**
|
||||
* We are proposing early media to an incoming call
|
||||
*/
|
||||
public static final State CallIncomingEarlyMedia = new State(16,"CallIncomingEarlyMedia");
|
||||
|
||||
CallIncomingEarlyMedia(16,"CallIncomingEarlyMedia"),
|
||||
/**
|
||||
* The remote accepted the call update initiated by us
|
||||
*/
|
||||
public static final State CallUpdated = new State(17, "CallUpdated");
|
||||
|
||||
CallUpdated(17, "CallUpdated"),
|
||||
/**
|
||||
* The call object is now released.
|
||||
*/
|
||||
public static final State CallReleased = new State(18,"CallReleased");
|
||||
CallReleased(18,"CallReleased");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private State(int value,String stringValue) {
|
||||
mValue = value;
|
||||
values.addElement(this);
|
||||
mStringValue=stringValue;
|
||||
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
private State(int v, String desc) {
|
||||
this.mValue = v;
|
||||
this.mStringValue = desc;
|
||||
}
|
||||
|
||||
public static State fromInt(int value) {
|
||||
|
||||
for (int i=0; i<values.size();i++) {
|
||||
State state = (State) values.elementAt(i);
|
||||
if (state.mValue == value) return state;
|
||||
State[] allStates = State.values();
|
||||
for (int i=0; i<allStates.length;i++) {
|
||||
if (allStates[i].mValue == value)
|
||||
return allStates[i];
|
||||
}
|
||||
throw new RuntimeException("state not found ["+value+"]");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue