@Override Animation createAnimationImpl(View view, int x, int y, int width, int height) { float fromValue = isReverse() ? 1.0f : 0.0f; float toValue = isReverse() ? 0.0f : 1.0f; if (mAnimatedProperty != null) { switch (mAnimatedProperty) { case OPACITY: return new OpacityAnimation(view, fromValue, toValue); case SCALE_XY: return new ScaleAnimation( fromValue, toValue, fromValue, toValue, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); default: throw new IllegalViewOperationException( "Missing animation for property : " + mAnimatedProperty); } } throw new IllegalViewOperationException("Missing animated property from animation config"); }
@ReactMethod public void set( final boolean disabled, final Promise promise ) { try { mActivity.runOnUiThread( new Runnable() { @Override public void run() { WritableMap result = new WritableNativeMap(); Window window = mActivity.getWindow(); if ( disabled ) { window.addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ); } else { window.clearFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ); } promise.resolve( result ); } } ); } catch ( IllegalViewOperationException e ) { promise.reject( e.getMessage() ); } }
@ReactMethod public void getDailyStepCountSamples(double startDate, double endDate, Callback errorCallback, Callback successCallback) { try { successCallback.invoke(mGoogleFitManager.getStepHistory().aggregateDataByDate((long)startDate, (long)endDate)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void getDailyDistanceSamples(double startDate, double endDate, Callback errorCallback, Callback successCallback) { try { successCallback.invoke(mGoogleFitManager.getDistanceHistory().aggregateDataByDate((long)startDate, (long)endDate)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void getWeightSamples(double startDate, double endDate, Callback errorCallback, Callback successCallback) { try { successCallback.invoke(mGoogleFitManager.getWeightsHistory().displayLastWeeksData((long)startDate, (long)endDate)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void getDailyCalorieSamples(double startDate, double endDate, Callback errorCallback, Callback successCallback) { try { successCallback.invoke(mGoogleFitManager.getCalorieHistory().aggregateDataByDate((long)startDate, (long)endDate)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void saveWeight(ReadableMap weightSample, Callback errorCallback, Callback successCallback) { try { successCallback.invoke(mGoogleFitManager.getWeightsHistory().saveWeight(weightSample)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void deleteWeight(ReadableMap weightSample, Callback errorCallback, Callback successCallback) { try { successCallback.invoke(mGoogleFitManager.getWeightsHistory().deleteWeight(weightSample)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void isAvailable(Callback errorCallback, Callback successCallback) { // true if GoogleFit installed try { successCallback.invoke(isAvailableCheck()); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
@ReactMethod public void isEnabled(Callback errorCallback, Callback successCallback) { // true if permission granted try { successCallback.invoke(isEnabledCheck()); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
/** * Function to return the file path of the folder where the converter will look for files * * @param promise - promise to return file path */ @ReactMethod public void getFilePath(Promise promise) { try { promise.resolve(Environment.getExternalStorageDirectory().toString()); } catch (IllegalViewOperationException e) { promise.reject(e); } }
public void initializeFromConfig(ReadableMap data, int globalDuration) { mAnimatedProperty = data.hasKey("property") ? AnimatedPropertyType.fromString(data.getString("property")) : null; mDurationMs = data.hasKey("duration") ? data.getInt("duration") : globalDuration; mDelayMs = data.hasKey("delay") ? data.getInt("delay") : 0; if (!data.hasKey("type")) { throw new IllegalArgumentException("Missing interpolation type."); } mInterpolator = getInterpolator(InterpolatorType.fromString(data.getString("type"))); if (!isValid()) { throw new IllegalViewOperationException("Invalid layout animation : " + data); } }
public void initializeFromConfig(ReadableMap data, int globalDuration) { mAnimatedProperty = data.hasKey("property") ? AnimatedPropertyType.fromString(data.getString("property")) : null; mDurationMs = data.hasKey("duration") ? data.getInt("duration") : globalDuration; mDelayMs = data.hasKey("delay") ? data.getInt("delay") : 0; mInterpolator = data.hasKey("type") ? getInterpolator(InterpolatorType.fromString(data.getString("type"))) : null; if (!isValid()) { throw new IllegalViewOperationException("Invalid layout animation : " + data); } }
@Override public void receiveCommand(TabLayoutView root, int commandId, @Nullable ReadableArray args) { Assertions.assertNotNull(root); Assertions.assertNotNull(args); switch (commandId) { case COMMAND_SETUPWITHVIEWPAGER: ViewPager viewPager = (ViewPager) root.getRootView().findViewById(args.getInt(0)); if (viewPager != null) { root.setupWithViewPager(viewPager); ReadableArray tabsSettingsArray = args.getArray(1); if (!this.addTabs(root, tabsSettingsArray)) { throw new IllegalViewOperationException( "One or more tabs was/were not created: an error occurred (ReadableArray null and/or TabLayoutView null) in " + getClass().getSimpleName() ); } } else { throw new IllegalViewOperationException( "Nonexistent ViewPager instance. Null value received by " + getClass().getSimpleName() ); } break; default: throw new IllegalArgumentException( String.format( "Unsupported command %d received by %s.", commandId, getClass().getSimpleName() ) ); } }
private static void buildSpannedFromTextCSSNode( ReactTextShadowNode textShadowNode, SpannableStringBuilder sb, List<SetSpanOperation> ops) { int start = sb.length(); if (textShadowNode.mText != null) { sb.append(textShadowNode.mText); } for (int i = 0, length = textShadowNode.getChildCount(); i < length; i++) { ReactShadowNode child = textShadowNode.getChildAt(i); if (child instanceof ReactTextShadowNode) { buildSpannedFromTextCSSNode((ReactTextShadowNode) child, sb, ops); } else if (child instanceof ReactTextInlineImageShadowNode) { // We make the image take up 1 character in the span and put a corresponding character into // the text so that the image doesn't run over any following text. sb.append(INLINE_IMAGE_PLACEHOLDER); ops.add( new SetSpanOperation( sb.length() - INLINE_IMAGE_PLACEHOLDER.length(), sb.length(), ((ReactTextInlineImageShadowNode) child).buildInlineImageSpan())); } else { throw new IllegalViewOperationException("Unexpected view type nested under text node: " + child.getClass()); } child.markUpdateSeen(); } int end = sb.length(); if (end >= start) { if (textShadowNode.mIsColorSet) { ops.add(new SetSpanOperation(start, end, new ForegroundColorSpan(textShadowNode.mColor))); } if (textShadowNode.mIsBackgroundColorSet) { ops.add(new SetSpanOperation( start, end, new BackgroundColorSpan(textShadowNode.mBackgroundColor))); } if (textShadowNode.mFontSize != UNSET) { ops.add(new SetSpanOperation(start, end, new AbsoluteSizeSpan(textShadowNode.mFontSize))); } if (textShadowNode.mFontStyle != UNSET || textShadowNode.mFontWeight != UNSET || textShadowNode.mFontFamily != null) { ops.add(new SetSpanOperation( start, end, new CustomStyleSpan( textShadowNode.mFontStyle, textShadowNode.mFontWeight, textShadowNode.mFontFamily, textShadowNode.getThemedContext().getAssets()))); } if (textShadowNode.mIsUnderlineTextDecorationSet) { ops.add(new SetSpanOperation(start, end, new UnderlineSpan())); } if (textShadowNode.mIsLineThroughTextDecorationSet) { ops.add(new SetSpanOperation(start, end, new StrikethroughSpan())); } if (textShadowNode.mTextShadowOffsetDx != 0 || textShadowNode.mTextShadowOffsetDy != 0) { ops.add(new SetSpanOperation( start, end, new ShadowStyleSpan( textShadowNode.mTextShadowOffsetDx, textShadowNode.mTextShadowOffsetDy, textShadowNode.mTextShadowRadius, textShadowNode.mTextShadowColor))); } if (!Float.isNaN(textShadowNode.getEffectiveLineHeight())) { ops.add(new SetSpanOperation( start, end, new CustomLineHeightSpan(textShadowNode.getEffectiveLineHeight()))); } ops.add(new SetSpanOperation(start, end, new ReactTagSpan(textShadowNode.getReactTag()))); } }
private static void buildSpannedFromTextCSSNode( ReactTextShadowNode textCSSNode, SpannableStringBuilder sb, List<SetSpanOperation> ops) { int start = sb.length(); if (textCSSNode.mText != null) { sb.append(textCSSNode.mText); } for (int i = 0, length = textCSSNode.getChildCount(); i < length; i++) { CSSNode child = textCSSNode.getChildAt(i); if (child instanceof ReactTextShadowNode) { buildSpannedFromTextCSSNode((ReactTextShadowNode) child, sb, ops); } else if (child instanceof ReactTextInlineImageShadowNode) { // We make the image take up 1 character in the span and put a corresponding character into // the text so that the image doesn't run over any following text. sb.append(INLINE_IMAGE_PLACEHOLDER); ops.add( new SetSpanOperation( sb.length() - INLINE_IMAGE_PLACEHOLDER.length(), sb.length(), ((ReactTextInlineImageShadowNode) child).buildInlineImageSpan())); } else { throw new IllegalViewOperationException("Unexpected view type nested under text node: " + child.getClass()); } ((ReactShadowNode) child).markUpdateSeen(); } int end = sb.length(); if (end >= start) { if (textCSSNode.mIsColorSet) { ops.add(new SetSpanOperation(start, end, new ForegroundColorSpan(textCSSNode.mColor))); } if (textCSSNode.mIsBackgroundColorSet) { ops.add(new SetSpanOperation( start, end, new BackgroundColorSpan(textCSSNode.mBackgroundColor))); } if (textCSSNode.mFontSize != UNSET) { ops.add(new SetSpanOperation(start, end, new AbsoluteSizeSpan(textCSSNode.mFontSize))); } if (textCSSNode.mFontStyle != UNSET || textCSSNode.mFontWeight != UNSET || textCSSNode.mFontFamily != null) { ops.add(new SetSpanOperation( start, end, new CustomStyleSpan( textCSSNode.mFontStyle, textCSSNode.mFontWeight, textCSSNode.mFontFamily, textCSSNode.getThemedContext().getAssets()))); } if (textCSSNode.mTextShadowOffsetDx != 0 || textCSSNode.mTextShadowOffsetDy != 0) { ops.add(new SetSpanOperation( start, end, new ShadowStyleSpan( textCSSNode.mTextShadowOffsetDx, textCSSNode.mTextShadowOffsetDy, textCSSNode.mTextShadowRadius, textCSSNode.mTextShadowColor))); } ops.add(new SetSpanOperation(start, end, new ReactTagSpan(textCSSNode.getReactTag()))); } }
private static void buildSpannedFromTextCSSNode( ReactTextShadowNode textCSSNode, SpannableStringBuilder sb, List<SetSpanOperation> ops) { int start = sb.length(); if (textCSSNode.mText != null) { sb.append(textCSSNode.mText); } for (int i = 0, length = textCSSNode.getChildCount(); i < length; i++) { CSSNode child = textCSSNode.getChildAt(i); if (child instanceof ReactTextShadowNode) { buildSpannedFromTextCSSNode((ReactTextShadowNode) child, sb, ops); } else if (child instanceof ReactTextInlineImageShadowNode) { // We make the image take up 1 character in the span and put a corresponding character into // the text so that the image doesn't run over any following text. sb.append(INLINE_IMAGE_PLACEHOLDER); ops.add( new SetSpanOperation( sb.length() - INLINE_IMAGE_PLACEHOLDER.length(), sb.length(), ((ReactTextInlineImageShadowNode) child).buildInlineImageSpan())); } else { throw new IllegalViewOperationException("Unexpected view type nested under text node: " + child.getClass()); } ((ReactShadowNode) child).markUpdateSeen(); } int end = sb.length(); if (end >= start) { if (textCSSNode.mIsColorSet) { ops.add(new SetSpanOperation(start, end, new ForegroundColorSpan(textCSSNode.mColor))); } if (textCSSNode.mIsBackgroundColorSet) { ops.add(new SetSpanOperation( start, end, new BackgroundColorSpan(textCSSNode.mBackgroundColor))); } if (textCSSNode.mFontSize != UNSET) { ops.add(new SetSpanOperation(start, end, new AbsoluteSizeSpan(textCSSNode.mFontSize))); } if (textCSSNode.mFontStyle != UNSET || textCSSNode.mFontWeight != UNSET || textCSSNode.mFontFamily != null) { ops.add(new SetSpanOperation( start, end, new CustomStyleSpan( textCSSNode.mFontStyle, textCSSNode.mFontWeight, textCSSNode.mFontFamily, textCSSNode.getThemedContext().getAssets()))); } if (textCSSNode.mIsUnderlineTextDecorationSet) { ops.add(new SetSpanOperation(start, end, new UnderlineSpan())); } if (textCSSNode.mIsLineThroughTextDecorationSet) { ops.add(new SetSpanOperation(start, end, new StrikethroughSpan())); } if (textCSSNode.mTextShadowOffsetDx != 0 || textCSSNode.mTextShadowOffsetDy != 0) { ops.add(new SetSpanOperation( start, end, new ShadowStyleSpan( textCSSNode.mTextShadowOffsetDx, textCSSNode.mTextShadowOffsetDy, textCSSNode.mTextShadowRadius, textCSSNode.mTextShadowColor))); } ops.add(new SetSpanOperation(start, end, new ReactTagSpan(textCSSNode.getReactTag()))); } }
private static void buildSpannedFromTextCSSNode( ReactTextShadowNode textCSSNode, SpannableStringBuilder sb, List<SetSpanOperation> ops) { int start = sb.length(); if (textCSSNode.mText != null) { sb.append(textCSSNode.mText); } for (int i = 0, length = textCSSNode.getChildCount(); i < length; i++) { CSSNodeDEPRECATED child = textCSSNode.getChildAt(i); if (child instanceof ReactTextShadowNode) { buildSpannedFromTextCSSNode((ReactTextShadowNode) child, sb, ops); } else if (child instanceof ReactTextInlineImageShadowNode) { // We make the image take up 1 character in the span and put a corresponding character into // the text so that the image doesn't run over any following text. sb.append(INLINE_IMAGE_PLACEHOLDER); ops.add( new SetSpanOperation( sb.length() - INLINE_IMAGE_PLACEHOLDER.length(), sb.length(), ((ReactTextInlineImageShadowNode) child).buildInlineImageSpan())); } else { throw new IllegalViewOperationException("Unexpected view type nested under text node: " + child.getClass()); } ((ReactShadowNode) child).markUpdateSeen(); } int end = sb.length(); if (end >= start) { if (textCSSNode.mIsColorSet) { ops.add(new SetSpanOperation(start, end, new ForegroundColorSpan(textCSSNode.mColor))); } if (textCSSNode.mIsBackgroundColorSet) { ops.add(new SetSpanOperation( start, end, new BackgroundColorSpan(textCSSNode.mBackgroundColor))); } if (textCSSNode.mFontSize != UNSET) { ops.add(new SetSpanOperation(start, end, new AbsoluteSizeSpan(textCSSNode.mFontSize))); } if (textCSSNode.mFontStyle != UNSET || textCSSNode.mFontWeight != UNSET || textCSSNode.mFontFamily != null) { ops.add(new SetSpanOperation( start, end, new CustomStyleSpan( textCSSNode.mFontStyle, textCSSNode.mFontWeight, textCSSNode.mFontFamily, textCSSNode.getThemedContext().getAssets()))); } if (textCSSNode.mIsUnderlineTextDecorationSet) { ops.add(new SetSpanOperation(start, end, new UnderlineSpan())); } if (textCSSNode.mIsLineThroughTextDecorationSet) { ops.add(new SetSpanOperation(start, end, new StrikethroughSpan())); } if (textCSSNode.mTextShadowOffsetDx != 0 || textCSSNode.mTextShadowOffsetDy != 0) { ops.add(new SetSpanOperation( start, end, new ShadowStyleSpan( textCSSNode.mTextShadowOffsetDx, textCSSNode.mTextShadowOffsetDy, textCSSNode.mTextShadowRadius, textCSSNode.mTextShadowColor))); } if (!Float.isNaN(textCSSNode.getEffectiveLineHeight())) { ops.add(new SetSpanOperation( start, end, new CustomLineHeightSpan(textCSSNode.getEffectiveLineHeight()))); } ops.add(new SetSpanOperation(start, end, new ReactTagSpan(textCSSNode.getReactTag()))); } }