@Override public void destroy() { UiThreadUtil.assertOnUiThread(); if (mUseDeveloperSupport) { mDevSupportManager.setDevSupportEnabled(false); } moveToBeforeCreateLifecycleState(); if (mReactContextInitAsyncTask != null) { mReactContextInitAsyncTask.cancel(true); } mMemoryPressureRouter.destroy(mApplicationContext); if (mCurrentReactContext != null) { mCurrentReactContext.destroy(); mCurrentReactContext = null; mHasStartedCreatingInitialContext = false; } mCurrentActivity = null; ResourceDrawableIdHelper.getInstance().clear(); }
@ReactProp(name = "src") public void setSrc(@Nullable ReadableMap src) { if (src != null) { String uriString = src.getString("uri"); if (uriString == null || uriString.isEmpty()) { //TODO: give warning about this return; } if (src.hasKey("width") && src.hasKey("height")) { mImageWidth = src.getInt("width"); mImageHeight = src.getInt("height"); } else { mImageWidth = 0; mImageHeight = 0; } mUri = Uri.parse(uriString); if (mUri.getScheme() == null) { mUri = ResourceDrawableIdHelper.getInstance().getResourceDrawableUri(getThemedContext(), uriString); } } }
/** * Destroy this React instance and the attached JS context. */ public void destroy() { UiThreadUtil.assertOnUiThread(); if (mUseDeveloperSupport) { mDevSupportManager.setDevSupportEnabled(false); } moveToBeforeCreateLifecycleState(); if (mReactContextInitAsyncTask != null) { mReactContextInitAsyncTask.cancel(true); } if (mCreateReactContextThread != null) { mCreateReactContextThread.interrupt(); mCreateReactContextThread = null; } mMemoryPressureRouter.destroy(mApplicationContext); if (mCurrentReactContext != null) { mCurrentReactContext.destroy(); mCurrentReactContext = null; mHasStartedCreatingInitialContext = false; } mCurrentActivity = null; ResourceDrawableIdHelper.getInstance().clear(); }
private Bitmap loadArtwork(String url, boolean local) { Bitmap bitmap = null; try { // If we are running the app in debug mode, the "local" image will be served from htt://localhost:8080, so we need to check for this case and load those images from URL if(local && !url.startsWith("http")) { // Gets the drawable from the RN's helper for local resources ResourceDrawableIdHelper helper = ResourceDrawableIdHelper.getInstance(); Drawable image = helper.getResourceDrawable(getReactApplicationContext(), url); if(image instanceof BitmapDrawable) { bitmap = ((BitmapDrawable)image).getBitmap(); } else { bitmap = BitmapFactory.decodeFile(url); } } else { // Open connection to the URL and decodes the image URLConnection con = new URL(url).openConnection(); con.connect(); InputStream input = con.getInputStream(); bitmap = BitmapFactory.decodeStream(input); input.close(); } } catch(IOException ex) { Log.w("MusicControl", "Could not load the artwork", ex); } return bitmap; }
public void setShadowImageUri(String uriStr) { shadowDrawable = (NinePatchDrawable) ResourceDrawableIdHelper.getInstance().getResourceDrawable(getContext(),uriStr); }
@ReactProp(name = "inlineImageLeft") public void setInlineImageLeft(ReactEditText view, @Nullable String resource) { int id = ResourceDrawableIdHelper.getInstance().getResourceDrawableId(view.getContext(), resource); view.setCompoundDrawablesWithIntrinsicBounds(id, 0, 0, 0); }
public void setLoadingIndicatorSource(@Nullable String name) { Drawable drawable = ResourceDrawableIdHelper.getInstance().getResourceDrawable(getContext(), name); mLoadingImageDrawable = drawable != null ? (Drawable) new AutoRotateDrawable(drawable, 1000) : null; mIsDirty = true; }