2015-08-04 11:05:47 +00:00
|
|
|
/*
|
2017-06-12 22:30:41 +00:00
|
|
|
* Copyright (C) 2013-2017 microG Project Team
|
2015-08-04 11:05:47 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.microg.gms.wearable;
|
|
|
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
|
|
|
import com.google.android.gms.wearable.Asset;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
public class DataItemInternal {
|
|
|
|
public final String host;
|
|
|
|
public final String path;
|
|
|
|
public final Uri uri;
|
|
|
|
public byte[] data;
|
|
|
|
private Map<String, Asset> assets = new HashMap<String, Asset>();
|
|
|
|
|
|
|
|
public DataItemInternal(String host, String path) {
|
|
|
|
this.host = host;
|
|
|
|
this.path = path;
|
|
|
|
this.uri = new Uri.Builder().scheme("wear").authority(host).path(path).build();
|
|
|
|
}
|
|
|
|
|
2015-11-17 16:20:13 +00:00
|
|
|
public DataItemInternal(Uri uri) {
|
|
|
|
this.uri = uri;
|
|
|
|
this.host = uri.getAuthority();
|
|
|
|
this.path = uri.getPath();
|
|
|
|
}
|
|
|
|
|
2015-08-04 11:05:47 +00:00
|
|
|
public DataItemInternal addAsset(String key, Asset asset) {
|
|
|
|
this.assets.put(key, asset);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Map<String, Asset> getAssets() {
|
|
|
|
return Collections.unmodifiableMap(new HashMap<String, Asset>(assets));
|
|
|
|
}
|
2016-08-04 09:36:03 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
final StringBuilder sb = new StringBuilder("DataItemInternal{");
|
|
|
|
sb.append("uri=").append(uri);
|
2016-11-07 21:49:59 +00:00
|
|
|
sb.append(", assets=").append(assets.size());
|
2016-08-04 09:36:03 +00:00
|
|
|
sb.append('}');
|
|
|
|
return sb.toString();
|
|
|
|
}
|
2015-08-04 11:05:47 +00:00
|
|
|
}
|