com.facebook.react.uimanager.IllegalViewOperationException Java Examples

The following examples show how to use com.facebook.react.uimanager.IllegalViewOperationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 7 votes vote down vote up
@ReactMethod
public void play(final int reactTag) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.play();
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #2
Source File: YouTubeModule.java    From react-native-youtube with MIT License 6 votes vote down vote up
@ReactMethod
public void getVideosIndex(final int reactTag, final Promise promise) {
    try {
        UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new UIBlock() {
            public void execute (NativeViewHierarchyManager nvhm) {
                YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag);
                YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag);
                int index = youTubeManager.getVideosIndex(youTubeView);
                promise.resolve(index);
            }
        });
    } catch (IllegalViewOperationException e) {
        promise.reject(E_MODULE_ERROR, e);
    }
}
 
Example #3
Source File: NavigationBarColorModule.java    From react-native-navigation-bar-color with MIT License 6 votes vote down vote up
@ReactMethod
public void hideNavigationBar(Promise promise) {
    try {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (getCurrentActivity() != null) {
                    View decorView = getCurrentActivity().getWindow().getDecorView();
                    decorView.setSystemUiVisibility(UI_FLAG_HIDE_NAV_BAR);
                }
            }
        });
    } catch (IllegalViewOperationException e) {
        WritableMap map = Arguments.createMap();
        map.putBoolean("success", false);
        promise.reject("error", e);
    }
}
 
Example #4
Source File: NavigationBarColorModule.java    From react-native-navigation-bar-color with MIT License 6 votes vote down vote up
@ReactMethod
public void showNavigationBar(Promise promise) {
    try {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (getCurrentActivity() != null) {
                    View decorView = getCurrentActivity().getWindow().getDecorView();
                    int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
                    decorView.setSystemUiVisibility(uiOptions);
                }
            }
        });
    } catch (IllegalViewOperationException e) {
        WritableMap map = Arguments.createMap();
        map.putBoolean("success", false);
        promise.reject("error", e);
    }
}
 
Example #5
Source File: ReactViewGroup.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
protected void dispatchDraw(Canvas canvas) {
  try {
    dispatchOverflowDraw(canvas);
    super.dispatchDraw(canvas);
  } catch (StackOverflowError e) {
    // Adding special exception management for StackOverflowError for logging purposes.
    // This will be removed in the future.
    RootView rootView = RootViewUtil.getRootView(ReactViewGroup.this);
    if (rootView != null) {
      rootView.handleException(e);
    } else {
      if (getContext() instanceof  ReactContext) {
        ReactContext reactContext = (ReactContext) getContext();
        reactContext.handleException(new IllegalViewOperationException("StackOverflowException", this, e));
      } else {
        throw e;
      }
    }
  }
}
 
Example #6
Source File: FlurryModule.java    From react-native-flurry-sdk with Apache License 2.0 6 votes vote down vote up
@ReactMethod
public void getConfigStringMap(ReadableMap keyAndDefault, Promise promise) {
    try {
        WritableMap map = Arguments.createMap();
        if (keyAndDefault != null) {
            ReadableMapKeySetIterator iterator = keyAndDefault.keySetIterator();
            while (iterator.hasNextKey()) {
                String key = iterator.nextKey();
                String defaultValue = keyAndDefault.getString(key);
                map.putString(key, FlurryConfig.getInstance().getString(key, defaultValue));
            }
        }
        promise.resolve(map);
    } catch (IllegalViewOperationException e) {
        promise.reject("Flurry.getConfigString", e);
    }
}
 
Example #7
Source File: Login.java    From imsdk-android with MIT License 6 votes vote down vote up
@ReactMethod
public void getLoginInfo(
        Callback successCallback,
        Callback errorCallback) {
    try {
        WritableNativeMap map = new WritableNativeMap();
        map.putString("userid", CurrentPreference.getInstance().getUserid());

        map.putString("token", CurrentPreference.getInstance().getToken());
        map.putString("q_auth", CurrentPreference.getInstance().getVerifyKey() == null ? "404" : CurrentPreference.getInstance().getVerifyKey());
        map.putString("c_key", getCKey());
        map.putDouble("timestamp", System.currentTimeMillis());

        successCallback.invoke(map);
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #8
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void setFullscreen(final int reactTag, final boolean fullscreen) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.setFullscreen(fullscreen, fullscreen);
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #9
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void state(final int reactTag, final Promise promise) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          PlayerState playerState = playerView.mPlayer.getState();
          promise.resolve(stateToInt(playerState));
        } else {
          promise.reject("RNJW Error", "Player is null");
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    promise.reject("RNJW Error", e);
  }
}
 
Example #10
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void position(final int reactTag, final Promise promise) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          promise.resolve((Double.valueOf(playerView.mPlayer.getPosition()).intValue()));
        } else {
          promise.reject("RNJW Error", "Player is null");
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    promise.reject("RNJW Error", e);
  }
}
 
Example #11
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void setControls(final int reactTag, final boolean show) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.setControls(show);
          playerView.mPlayer.getConfig().setControls(show);
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #12
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void setPlaylistIndex(final int reactTag, final int index) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.setCurrentAudioTrack(index);
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #13
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void seekTo(final int reactTag, final double time) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.seek(time);
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #14
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void stop(final int reactTag) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.stop();
          playerView.userPaused = true;
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #15
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void pause(final int reactTag) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.pause();
          playerView.userPaused = true;
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #16
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void setSpeed(final int reactTag, final float speed) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          playerView.mPlayer.setPlaybackRate(speed);
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #17
Source File: RNJWPlayerModule.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
@ReactMethod
public void toggleSpeed(final int reactTag) {
  try {
    UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
    uiManager.addUIBlock(new UIBlock() {
      public void execute (NativeViewHierarchyManager nvhm) {
        RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);

        if (playerView != null && playerView.mPlayer != null) {
          float rate = playerView.mPlayer.getPlaybackRate();
          if (rate < 2) {
            playerView.mPlayer.setPlaybackRate(rate += 0.5);
          } else {
            playerView.mPlayer.setPlaybackRate((float) 0.5);
          }
        }
      }
    });
  } catch (IllegalViewOperationException e) {
    throw e;
  }
}
 
Example #18
Source File: YouTubeModule.java    From react-native-youtube with MIT License 6 votes vote down vote up
@ReactMethod
public void getCurrentTime(final int reactTag, final Promise promise) {
    try {
        UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new UIBlock() {
            public void execute (NativeViewHierarchyManager nvhm) {
                YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag);
                YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag);
                int currentTime = youTubeManager.getCurrentTime(youTubeView);
                promise.resolve(currentTime);
            }
        });
    } catch (IllegalViewOperationException e) {
        promise.reject(E_MODULE_ERROR, e);
    }
}
 
Example #19
Source File: YouTubeModule.java    From react-native-youtube with MIT License 6 votes vote down vote up
@ReactMethod
public void getDuration(final int reactTag, final Promise promise) {
    try {
        UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new UIBlock() {
            public void execute (NativeViewHierarchyManager nvhm) {
                YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag);
                YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag);
                int duration = youTubeManager.getDuration(youTubeView);
                promise.resolve(duration);
            }
        });
    } catch (IllegalViewOperationException e) {
        promise.reject(E_MODULE_ERROR, e);
    }
}
 
Example #20
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void getDailyCalorieSamples(double startDate,
                                   double endDate,
                                   boolean basalCalculation,
                                   Callback errorCallback,
                                   Callback successCallback) {

    try {
        successCallback.invoke(mGoogleFitManager.getCalorieHistory().aggregateDataByDate((long) startDate, (long) endDate, basalCalculation));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #21
Source File: TabLayoutManager.java    From react-native-android-kit with MIT License 5 votes vote down vote up
@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()
					)
			);
	}
}
 
Example #22
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void saveFood(ReadableMap foodSample,
                     Callback errorCallback,
                     Callback successCallback) {
    try {
        successCallback.invoke(mGoogleFitManager.getCalorieHistory().saveFood(foodSample));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #23
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void getDailyNutritionSamples(double startDate,
                                     double endDate,
                                     Callback errorCallback,
                                     Callback successCallback) {
    try {
        successCallback.invoke(mGoogleFitManager.getNutritionHistory().aggregateDataByDate((long) startDate, (long) endDate));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #24
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void saveWeight(ReadableMap weightSample,
                       Callback errorCallback,
                       Callback successCallback) {

    try {
        BodyHistory bodyHistory = mGoogleFitManager.getBodyHistory();
        bodyHistory.setDataType(DataType.TYPE_WEIGHT);
        successCallback.invoke(bodyHistory.save(weightSample));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #25
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void deleteWeight(ReadableMap options, Callback errorCallback, Callback successCallback) {
    try {
        BodyHistory bodyHistory = mGoogleFitManager.getBodyHistory();
        bodyHistory.setDataType(DataType.TYPE_WEIGHT);
        successCallback.invoke(bodyHistory.delete(options));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #26
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void deleteHeight(ReadableMap options, Callback errorCallback, Callback successCallback) {
    try {
        BodyHistory bodyHistory = mGoogleFitManager.getBodyHistory();
        bodyHistory.setDataType(DataType.TYPE_HEIGHT);
        successCallback.invoke(bodyHistory.delete(options));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #27
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void isAvailable(Callback errorCallback, Callback successCallback) { // true if GoogleFit installed
    try {
        successCallback.invoke(isAvailableCheck());
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #28
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void isEnabled(Callback errorCallback, Callback successCallback) { // true if permission granted
    try {
        successCallback.invoke(isEnabledCheck());
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #29
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void getBloodPressureSamples(double startDate,
                                    double endDate,
                                    Callback errorCallback,
                                    Callback successCallback) {
    try {
        HeartrateHistory heartrateHistory = mGoogleFitManager.getHeartrateHistory();
        heartrateHistory.setDataType(HealthDataTypes.TYPE_BLOOD_PRESSURE);
        successCallback.invoke(heartrateHistory.getHistory((long)startDate, (long)endDate));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}
 
Example #30
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 5 votes vote down vote up
@ReactMethod
public void getHeartRateSamples(double startDate,
                                double endDate,
                                Callback errorCallback,
                                Callback successCallback) {

    try {
        HeartrateHistory heartrateHistory = mGoogleFitManager.getHeartrateHistory();
        heartrateHistory.setDataType(DataType.TYPE_HEART_RATE_BPM);
        successCallback.invoke(heartrateHistory.getHistory((long)startDate, (long)endDate));
    } catch (IllegalViewOperationException e) {
        errorCallback.invoke(e.getMessage());
    }
}