/** * Print XML * * @param XMLProject boolean * @return String */ public String printXML(boolean XMLProject) { String XMLString = ""; if (!printed) { XMLString += "<link.name>" + this.name + "</link.name>\r\n"; XMLString += "<link.id>" + this.id + "</link.id>\r\n"; if (p1 != null) { XMLString += "<from>\r\n"; XMLString += this.p1.printXML(XMLProject); XMLString += "</from>\r\n"; } if (p2 != null) { XMLString += "<to>\r\n"; XMLString += this.p2.printXML(XMLProject); XMLString += "</to>\r\n"; } XMLString += "<queue>\r\n"; for (MediaItem item : this.mediaItems) { XMLString += item.printXML(XMLProject); } XMLString += "</queue>\r\n"; if (this.links.size() > 0) { XMLString += "<links>\r\n"; for (Link link : this.links) { XMLString += "<link>\r\n"; XMLString += link.printXML(XMLProject); XMLString += "</link>\r\n"; } XMLString += "</links>\r\n"; } } else { XMLString += "<link.shortcut>" + this.id + "</link.shortcut>\r\n"; } this.printed = true; return XMLString; }
@Override public void run() { if (nextItemIndex >= slideshow.size()) { // if there is music playing if (mediaPlayer != null && mediaPlayer.isPlaying()) mediaPlayer.reset(); // slideshow done, reset mediaPlayer finish(); // return to launching Activity } // end if else { MediaItem item = slideshow.getMediaItemAt(nextItemIndex); if (item.getType() == MediaItem.MediaType.IMAGE) { imageView.setVisibility(View.VISIBLE); // show imageView videoView.setVisibility(View.INVISIBLE); // hide videoView new LoadImageTask().execute(Uri.parse(item.getPath())); } // end if else { imageView.setVisibility(View.INVISIBLE); // hide imageView videoView.setVisibility(View.VISIBLE); // show videoView playVideo(Uri.parse(item.getPath())); // plays the video } // end else ++nextItemIndex; } // end else } // end method run
public Bitmap run(ThreadPool.JobContext paramJobContext) { ImageCacheService localImageCacheService = this.mApplication.getImageCacheService(); BytesBufferPool.BytesBuffer localBytesBuffer = MediaItem.getBytesBufferPool().get(); Bitmap localBitmap1; try { boolean bool1 = localImageCacheService.getImageData(this.mPath, this.mType, localBytesBuffer); boolean bool2 = paramJobContext.isCancelled(); if (bool2) return null; if (bool1) { BitmapFactory.Options localOptions = new BitmapFactory.Options(); localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; if (this.mType == 2) ; Bitmap localBitmap3; for (Object localObject2 = DecodeUtils.decode( paramJobContext, localBytesBuffer.data, localBytesBuffer.offset, localBytesBuffer.length, localOptions, MediaItem.getMicroThumbPool()); ; localObject2 = localBitmap3) { if ((localObject2 == null) && (!paramJobContext.isCancelled())) Log.w("ImageCacheRequest", "decode cached failed " + debugTag()); return localObject2; localBitmap3 = DecodeUtils.decode( paramJobContext, localBytesBuffer.data, localBytesBuffer.offset, localBytesBuffer.length, localOptions, MediaItem.getThumbPool()); } } MediaItem.getBytesBufferPool().recycle(localBytesBuffer); localBitmap1 = onDecodeOriginal(paramJobContext, this.mType); return null; } finally { MediaItem.getBytesBufferPool().recycle(localBytesBuffer); } if (localBitmap1 == null) { Log.w("ImageCacheRequest", "decode orig failed " + debugTag()); return null; } if (this.mType == 2) ; for (Bitmap localBitmap2 = BitmapUtils.resizeAndCropCenter(localBitmap1, this.mTargetSize, true); paramJobContext.isCancelled(); localBitmap2 = BitmapUtils.resizeDownBySideLength(localBitmap1, this.mTargetSize, true)) return null; byte[] arrayOfByte = BitmapUtils.compressToBytes(localBitmap2); if (paramJobContext.isCancelled()) return null; localImageCacheService.putImageData(this.mPath, this.mType, arrayOfByte); return (Bitmap) localBitmap2; }
@Override protected void finalize() throws Throwable { try { if (mFileDescriptor != null) { Utils.closeSilently(mFileDescriptor); } } finally { super.finalize(); } }
public void testMediaItemSimple() throws Exception { ProtobufSchema schema = ProtobufSchemaLoader.std.parse(PROTOC_MEDIA_ITEM); final ObjectWriter w = MAPPER.writer(schema); byte[] bytes = w.writeValueAsBytes(MediaItem.buildItem()); assertNotNull(bytes); assertEquals(252, bytes.length); // let's read back for fun MediaItem output = MAPPER.readerFor(MediaItem.class).with(schema).readValue(bytes); assertNotNull(output); }
@Override public Bitmap run(JobContext jc) { if (!prepareInputFile(jc)) return null; int targetSize = MediaItem.getTargetSize(mType); Options options = new Options(); options.inPreferredConfig = Config.ARGB_8888; Bitmap bitmap = DecodeUtils.decodeThumbnail( jc, mFileDescriptor.getFileDescriptor(), options, targetSize, mType); if (jc.isCancelled() || bitmap == null) { return null; } if (mType == MediaItem.TYPE_MICROTHUMBNAIL) { bitmap = BitmapUtils.resizeAndCropCenter(bitmap, targetSize, true); } else { bitmap = BitmapUtils.resizeDownBySideLength(bitmap, targetSize, true); } return bitmap; }