mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-25 20:38:55 +02:00
use json instead of parcelable
This commit is contained in:
parent
6b67d80bc7
commit
8aecd477fa
10 changed files with 177 additions and 171 deletions
|
@ -36,8 +36,8 @@ public class ClientSettingsActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra("clientInfo", clientSettingsFragment.getClientInfo());
|
intent.putExtra("client", clientSettingsFragment.getClientInfo().toJson().toString());
|
||||||
intent.putExtra("clientInfoOriginal", clientSettingsFragment.getOriginalClientInfo());
|
intent.putExtra("clientOriginal", clientSettingsFragment.getOriginalClientInfo().toJson().toString());
|
||||||
setResult(Activity.RESULT_OK, intent);
|
setResult(Activity.RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
// super.onBackPressed();
|
// super.onBackPressed();
|
||||||
|
|
|
@ -8,6 +8,10 @@ import android.preference.PreferenceFragment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import de.badaix.snapcast.control.ClientInfo;
|
import de.badaix.snapcast.control.ClientInfo;
|
||||||
|
@ -34,9 +38,21 @@ public class ClientSettingsFragment extends PreferenceFragment {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
clientInfo = (ClientInfo) bundle.getParcelable("clientInfo");
|
try {
|
||||||
|
clientInfo = new ClientInfo(new JSONObject(bundle.getString("client")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
clientInfoOriginal = new ClientInfo(clientInfo.toJson());
|
clientInfoOriginal = new ClientInfo(clientInfo.toJson());
|
||||||
final ArrayList<Stream> streams = bundle.getParcelableArrayList("streams");
|
final ArrayList<Stream> streams = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
JSONArray jsonArray = new JSONArray(bundle.getString("streams"));
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++)
|
||||||
|
streams.add(new Stream(jsonArray.getJSONObject(i)));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
final CharSequence[] streamNames = new CharSequence[streams.size()];
|
final CharSequence[] streamNames = new CharSequence[streams.size()];
|
||||||
final CharSequence[] streamIds = new CharSequence[streams.size()];
|
final CharSequence[] streamIds = new CharSequence[streams.size()];
|
||||||
for (int i = 0; i < streams.size(); ++i) {
|
for (int i = 0; i < streams.size(); ++i) {
|
||||||
|
|
|
@ -37,6 +37,9 @@ import com.google.android.gms.appindexing.Action;
|
||||||
import com.google.android.gms.appindexing.AppIndex;
|
import com.google.android.gms.appindexing.AppIndex;
|
||||||
import com.google.android.gms.common.api.GoogleApiClient;
|
import com.google.android.gms.common.api.GoogleApiClient;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -435,8 +438,18 @@ public class MainActivity extends AppCompatActivity implements ClientListFragmen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (requestCode == 1) {
|
if (requestCode == 1) {
|
||||||
ClientInfo clientInfo = data.getParcelableExtra("clientInfo");
|
ClientInfo clientInfo = null;
|
||||||
ClientInfo clientInfoOriginal = data.getParcelableExtra("clientInfoOriginal");
|
try {
|
||||||
|
clientInfo = new ClientInfo(new JSONObject(data.getStringExtra("client")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
ClientInfo clientInfoOriginal = null;
|
||||||
|
try {
|
||||||
|
clientInfoOriginal = new ClientInfo(new JSONObject(data.getStringExtra("clientOriginal")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
Log.d(TAG, "new name: " + clientInfo.getName() + ", old name: " + clientInfoOriginal.getName());
|
Log.d(TAG, "new name: " + clientInfo.getName() + ", old name: " + clientInfoOriginal.getName());
|
||||||
if (!clientInfo.getName().equals(clientInfoOriginal.getName()))
|
if (!clientInfo.getName().equals(clientInfoOriginal.getName()))
|
||||||
remoteControl.setName(clientInfo, clientInfo.getName());
|
remoteControl.setName(clientInfo, clientInfo.getName());
|
||||||
|
@ -614,8 +627,8 @@ public class MainActivity extends AppCompatActivity implements ClientListFragmen
|
||||||
@Override
|
@Override
|
||||||
public void onPropertiesClicked(ClientInfoItem clientInfoItem) {
|
public void onPropertiesClicked(ClientInfoItem clientInfoItem) {
|
||||||
Intent intent = new Intent(this, ClientSettingsActivity.class);
|
Intent intent = new Intent(this, ClientSettingsActivity.class);
|
||||||
intent.putExtra("clientInfo", clientInfoItem.getClientInfo());
|
intent.putExtra("client", clientInfoItem.getClientInfo().toJson().toString());
|
||||||
intent.putParcelableArrayListExtra("streams", serverInfo.getStreams());
|
intent.putExtra("streams", serverInfo.getJsonStreams().toString());
|
||||||
intent.setFlags(0);
|
intent.setFlags(0);
|
||||||
startActivityForResult(intent, 1);
|
startActivityForResult(intent, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package de.badaix.snapcast.control;
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -9,17 +7,6 @@ import org.json.JSONObject;
|
||||||
* Created by johannes on 06.01.16.
|
* Created by johannes on 06.01.16.
|
||||||
*/
|
*/
|
||||||
public class ClientInfo implements JsonSerialisable {
|
public class ClientInfo implements JsonSerialisable {
|
||||||
public static final Creator<ClientInfo> CREATOR = new Creator<ClientInfo>() {
|
|
||||||
@Override
|
|
||||||
public ClientInfo createFromParcel(Parcel in) {
|
|
||||||
return new ClientInfo(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ClientInfo[] newArray(int size) {
|
|
||||||
return new ClientInfo[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private String mac;
|
private String mac;
|
||||||
private String ip;
|
private String ip;
|
||||||
private String host;
|
private String host;
|
||||||
|
@ -36,19 +23,6 @@ public class ClientInfo implements JsonSerialisable {
|
||||||
fromJson(json);
|
fromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ClientInfo(Parcel in) {
|
|
||||||
mac = in.readString();
|
|
||||||
ip = in.readString();
|
|
||||||
host = in.readString();
|
|
||||||
version = in.readString();
|
|
||||||
name = in.readString();
|
|
||||||
volume = in.readParcelable(Volume.class.getClassLoader());
|
|
||||||
lastSeen = in.readParcelable(Time_t.class.getClassLoader());
|
|
||||||
connected = in.readByte() != 0;
|
|
||||||
latency = in.readInt();
|
|
||||||
stream = in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJson(JSONObject json) {
|
public void fromJson(JSONObject json) {
|
||||||
try {
|
try {
|
||||||
|
@ -211,25 +185,5 @@ public class ClientInfo implements JsonSerialisable {
|
||||||
result = 31 * result + (stream != null ? stream.hashCode() : 0);
|
result = 31 * result + (stream != null ? stream.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeString(mac);
|
|
||||||
dest.writeString(ip);
|
|
||||||
dest.writeString(host);
|
|
||||||
dest.writeString(version);
|
|
||||||
dest.writeString(name);
|
|
||||||
dest.writeParcelable(volume, flags);
|
|
||||||
dest.writeParcelable(lastSeen, flags);
|
|
||||||
dest.writeByte((byte) (connected ? 1 : 0));
|
|
||||||
dest.writeInt(latency);
|
|
||||||
dest.writeString(stream);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package de.badaix.snapcast.control;
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by johannes on 08.01.16.
|
* Created by johannes on 08.01.16.
|
||||||
*/
|
*/
|
||||||
public interface JsonSerialisable extends Parcelable {
|
public interface JsonSerialisable {
|
||||||
public void fromJson(JSONObject json);
|
public void fromJson(JSONObject json);
|
||||||
|
|
||||||
public JSONObject toJson();
|
public JSONObject toJson();
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by johannes on 02.03.16.
|
||||||
|
*/
|
||||||
|
public class Server implements JsonSerialisable {
|
||||||
|
private String host;
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public Server(JSONObject json) {
|
||||||
|
fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromJson(JSONObject json) {
|
||||||
|
try {
|
||||||
|
host = json.getString("host");
|
||||||
|
version = json.getString("version");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject toJson() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try {
|
||||||
|
json.put("host", host);
|
||||||
|
json.put("version", version);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Server{" +
|
||||||
|
"host='" + host + '\'' +
|
||||||
|
", version='" + version + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Server server = (Server) o;
|
||||||
|
|
||||||
|
if (host != null ? !host.equals(server.host) : server.host != null) return false;
|
||||||
|
return version != null ? version.equals(server.version) : server.version == null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = host != null ? host.hashCode() : 0;
|
||||||
|
result = 31 * result + (version != null ? version.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,26 +1,64 @@
|
||||||
package de.badaix.snapcast.control;
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by johannes on 06.01.16.
|
* Created by johannes on 06.01.16.
|
||||||
*/
|
*/
|
||||||
public class ServerInfo {
|
public class ServerInfo implements JsonSerialisable {
|
||||||
private ArrayList<ClientInfo> clientInfos = new ArrayList<ClientInfo>();
|
private ArrayList<ClientInfo> clients = new ArrayList<ClientInfo>();
|
||||||
private ArrayList<Stream> streams = new ArrayList<Stream>();
|
private ArrayList<Stream> streams = new ArrayList<Stream>();
|
||||||
|
private Server server = null;
|
||||||
|
|
||||||
|
public ServerInfo(JSONObject json) {
|
||||||
|
fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
public ServerInfo() {
|
public ServerInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromJson(JSONObject json) {
|
||||||
|
try {
|
||||||
|
clear();
|
||||||
|
server = new Server(json.getJSONObject("server"));
|
||||||
|
JSONArray jStreams = json.getJSONArray("streams");
|
||||||
|
for (int i = 0; i < jStreams.length(); i++)
|
||||||
|
streams.add(new Stream(jStreams.getJSONObject(i)));
|
||||||
|
JSONArray jClients = json.getJSONArray("clients");
|
||||||
|
for (int i = 0; i < jClients.length(); i++)
|
||||||
|
clients.add(new ClientInfo(jClients.getJSONObject(i)));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject toJson() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try {
|
||||||
|
json.put("server", server.toJson());
|
||||||
|
json.put("streams", getJsonStreams());
|
||||||
|
json.put("clients", getJsonClients());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
clientInfos.clear();
|
clients.clear();
|
||||||
|
streams.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeClient(ClientInfo client) {
|
public boolean removeClient(ClientInfo client) {
|
||||||
for (int i = 0; i < clientInfos.size(); ++i) {
|
for (int i = 0; i < clients.size(); ++i) {
|
||||||
if (clientInfos.get(i).getMac().equals(client.getMac())) {
|
if (clients.get(i).getMac().equals(client.getMac())) {
|
||||||
clientInfos.remove(i);
|
clients.remove(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,19 +69,19 @@ public class ServerInfo {
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < clientInfos.size(); ++i) {
|
for (int i = 0; i < clients.size(); ++i) {
|
||||||
ClientInfo clientInfo = clientInfos.get(i);
|
ClientInfo clientInfo = clients.get(i);
|
||||||
if (clientInfo == null)
|
if (clientInfo == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (client.getMac().equals(clientInfo.getMac())) {
|
if (client.getMac().equals(clientInfo.getMac())) {
|
||||||
if (clientInfo.equals(client))
|
if (clientInfo.equals(client))
|
||||||
return false;
|
return false;
|
||||||
clientInfos.set(i, client);
|
clients.set(i, client);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clientInfos.add(client);
|
clients.add(client);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,10 +107,25 @@ public class ServerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ClientInfo> getClientInfos() {
|
public ArrayList<ClientInfo> getClientInfos() {
|
||||||
return clientInfos;
|
return clients;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Stream> getStreams() {
|
public ArrayList<Stream> getStreams() {
|
||||||
return streams;
|
return streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONArray getJsonStreams() {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
for (Stream stream : streams)
|
||||||
|
jsonArray.put(stream.toJson());
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONArray getJsonClients() {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
for (ClientInfo client : clients)
|
||||||
|
jsonArray.put(client.toJson());
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package de.badaix.snapcast.control;
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -13,18 +10,6 @@ import java.util.Map;
|
||||||
* Created by johannes on 06.01.16.
|
* Created by johannes on 06.01.16.
|
||||||
*/
|
*/
|
||||||
public class Stream implements JsonSerialisable {
|
public class Stream implements JsonSerialisable {
|
||||||
public static final Creator<Stream> CREATOR = new Creator<Stream>() {
|
|
||||||
@Override
|
|
||||||
public Stream createFromParcel(Parcel in) {
|
|
||||||
return new Stream(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Stream[] newArray(int size) {
|
|
||||||
return new Stream[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private String uri;
|
private String uri;
|
||||||
private String scheme;
|
private String scheme;
|
||||||
private String host;
|
private String host;
|
||||||
|
@ -37,17 +22,6 @@ public class Stream implements JsonSerialisable {
|
||||||
fromJson(json);
|
fromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Stream(Parcel in) {
|
|
||||||
uri = in.readString();
|
|
||||||
scheme = in.readString();
|
|
||||||
host = in.readString();
|
|
||||||
path = in.readString();
|
|
||||||
fragment = in.readString();
|
|
||||||
id = in.readString();
|
|
||||||
Bundle bundle = in.readBundle();
|
|
||||||
query = (HashMap<String, String>) bundle.getSerializable("query");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJson(JSONObject json) {
|
public void fromJson(JSONObject json) {
|
||||||
try {
|
try {
|
||||||
|
@ -79,7 +53,7 @@ public class Stream implements JsonSerialisable {
|
||||||
JSONObject jQuery = new JSONObject();
|
JSONObject jQuery = new JSONObject();
|
||||||
for (Map.Entry<String, String> entry : query.entrySet())
|
for (Map.Entry<String, String> entry : query.entrySet())
|
||||||
jQuery.put(entry.getKey(), entry.getValue());
|
jQuery.put(entry.getKey(), entry.getValue());
|
||||||
json.put("query", query);
|
json.put("query", jQuery);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -190,22 +164,4 @@ public class Stream implements JsonSerialisable {
|
||||||
", query=" + query +
|
", query=" + query +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeString(uri);
|
|
||||||
dest.writeString(scheme);
|
|
||||||
dest.writeString(host);
|
|
||||||
dest.writeString(path);
|
|
||||||
dest.writeString(fragment);
|
|
||||||
dest.writeString(id);
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putSerializable("query", query);
|
|
||||||
dest.writeBundle(bundle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package de.badaix.snapcast.control;
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -9,17 +7,6 @@ import org.json.JSONObject;
|
||||||
* Created by johannes on 06.01.16.
|
* Created by johannes on 06.01.16.
|
||||||
*/
|
*/
|
||||||
public class Time_t implements JsonSerialisable {
|
public class Time_t implements JsonSerialisable {
|
||||||
public static final Creator<Time_t> CREATOR = new Creator<Time_t>() {
|
|
||||||
@Override
|
|
||||||
public Time_t createFromParcel(Parcel in) {
|
|
||||||
return new Time_t(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Time_t[] newArray(int size) {
|
|
||||||
return new Time_t[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private long sec;
|
private long sec;
|
||||||
private long usec;
|
private long usec;
|
||||||
|
|
||||||
|
@ -32,11 +19,6 @@ public class Time_t implements JsonSerialisable {
|
||||||
this.usec = usec;
|
this.usec = usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Time_t(Parcel in) {
|
|
||||||
sec = in.readLong();
|
|
||||||
usec = in.readLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJson(JSONObject json) {
|
public void fromJson(JSONObject json) {
|
||||||
try {
|
try {
|
||||||
|
@ -101,15 +83,4 @@ public class Time_t implements JsonSerialisable {
|
||||||
result = (int) (31 * result + usec);
|
result = (int) (31 * result + usec);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeLong(sec);
|
|
||||||
dest.writeLong(usec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package de.badaix.snapcast.control;
|
package de.badaix.snapcast.control;
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -9,17 +7,6 @@ import org.json.JSONObject;
|
||||||
* Created by johannes on 06.01.16.
|
* Created by johannes on 06.01.16.
|
||||||
*/
|
*/
|
||||||
public class Volume implements JsonSerialisable {
|
public class Volume implements JsonSerialisable {
|
||||||
public static final Creator<Volume> CREATOR = new Creator<Volume>() {
|
|
||||||
@Override
|
|
||||||
public Volume createFromParcel(Parcel in) {
|
|
||||||
return new Volume(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Volume[] newArray(int size) {
|
|
||||||
return new Volume[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private boolean muted;
|
private boolean muted;
|
||||||
private int percent;
|
private int percent;
|
||||||
|
|
||||||
|
@ -32,11 +19,6 @@ public class Volume implements JsonSerialisable {
|
||||||
this.muted = muted;
|
this.muted = muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Volume(Parcel in) {
|
|
||||||
muted = in.readByte() != 0;
|
|
||||||
percent = in.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJson(JSONObject json) {
|
public void fromJson(JSONObject json) {
|
||||||
try {
|
try {
|
||||||
|
@ -101,15 +83,4 @@ public class Volume implements JsonSerialisable {
|
||||||
result = 31 * result + percent;
|
result = 31 * result + percent;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeByte((byte) (muted ? 1 : 0));
|
|
||||||
dest.writeInt(percent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue