21
21
import android .content .Context ;
22
22
import android .net .Uri ;
23
23
import android .os .ParcelFileDescriptor ;
24
+ import android .util .Log ;
24
25
25
26
import org .json .JSONException ;
26
27
import org .json .JSONObject ;
33
34
* The Skygear Asset Model.
34
35
*/
35
36
public class Asset {
37
+ private static final String TAG = "Skygear SDK" ;
36
38
37
39
/**
38
40
* The Name.
@@ -248,6 +250,7 @@ private Asset buildFromInputStream() {
248
250
249
251
private Asset buildFromByteArray () {
250
252
ensureStateIsNonNull (this .mimeType , "MimeType" );
253
+ warnRedundantStateIfNeeded (this .size , "Size" , "data" );
251
254
252
255
long size = this .data .length ;
253
256
InputStream inputStream = new ByteArrayInputStream (this .data );
@@ -257,6 +260,8 @@ private Asset buildFromByteArray() {
257
260
258
261
private Asset buildFromUri () {
259
262
ensureStateIsNonNull (this .context , "Context" );
263
+ warnRedundantStateIfNeeded (this .mimeType , "MimeType" , "uri" );
264
+ warnRedundantStateIfNeeded (this .size , "Size" , "uri" );
260
265
261
266
ContentResolver contentResolver = context .getContentResolver ();
262
267
InputStream inputStream ;
@@ -280,5 +285,11 @@ private static void ensureStateIsNonNull(Object state, String name) {
280
285
throw new IllegalStateException (name + " must be set first" );
281
286
}
282
287
}
288
+
289
+ private static void warnRedundantStateIfNeeded (Object state , String name , String context ) {
290
+ if (state != null ) {
291
+ Log .w (TAG , name + " would be ignored when using " + context + " as data source" );
292
+ }
293
+ }
283
294
}
284
295
}
0 commit comments