@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { TextView title = convertView != null ? (TextView) convertView : (TextView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.redbox_item_title, parent, false); title.setText(mTitle); return title; } else { if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.redbox_item_frame, parent, false); convertView.setTag(new FrameViewHolder(convertView)); } StackFrame frame = mStack[position - 1]; FrameViewHolder holder = (FrameViewHolder) convertView.getTag(); holder.mMethodView.setText(frame.getMethod()); holder.mFileView.setText(StackTraceHelper.formatFrameSource(frame)); return convertView; } }
private WebsocketJavaScriptExecutor.JSExecutorConnectCallback getExecutorConnectCallback( final SimpleSettableFuture<Boolean> future) { return new WebsocketJavaScriptExecutor.JSExecutorConnectCallback() { @Override public void onSuccess() { future.set(true); mDevLoadingViewController.hide(); mDevLoadingViewVisible = false; } @Override public void onFailure(final Throwable cause) { mDevLoadingViewController.hide(); mDevLoadingViewVisible = false; FLog.e(ReactConstants.TAG, "Unable to connect to remote debugger", cause); future.setException( new IOException( mApplicationContext.getString(R.string.catalyst_remotedbg_error), cause)); } }; }
private static int[] getDefaultColors(Context context) { Resources.Theme theme = context.getTheme(); TypedArray toolbarStyle = null; TypedArray textAppearances = null; TypedArray titleTextAppearance = null; TypedArray subtitleTextAppearance = null; try { toolbarStyle = theme .obtainStyledAttributes(new int[]{R.attr.toolbarStyle}); int toolbarStyleResId = toolbarStyle.getResourceId(0, 0); textAppearances = theme.obtainStyledAttributes( toolbarStyleResId, new int[]{ R.attr.titleTextAppearance, R.attr.subtitleTextAppearance, }); int titleTextAppearanceResId = textAppearances.getResourceId(0, 0); int subtitleTextAppearanceResId = textAppearances.getResourceId(1, 0); titleTextAppearance = theme .obtainStyledAttributes(titleTextAppearanceResId, new int[]{android.R.attr.textColor}); subtitleTextAppearance = theme .obtainStyledAttributes(subtitleTextAppearanceResId, new int[]{android.R.attr.textColor}); int titleTextColor = titleTextAppearance.getColor(0, Color.BLACK); int subtitleTextColor = subtitleTextAppearance.getColor(0, Color.BLACK); return new int[] {titleTextColor, subtitleTextColor}; } finally { recycleQuietly(toolbarStyle); recycleQuietly(textAppearances); recycleQuietly(titleTextAppearance); recycleQuietly(subtitleTextAppearance); } }
@Override public void handleReloadJS() { UiThreadUtil.assertOnUiThread(); // dismiss redbox if exists if (mRedBoxDialog != null) { mRedBoxDialog.dismiss(); } ProgressDialog progressDialog = new ProgressDialog(mApplicationContext); progressDialog.setTitle(R.string.catalyst_jsload_title); progressDialog.setMessage(mApplicationContext.getString( mIsUsingJSProxy ? R.string.catalyst_remotedbg_message : R.string.catalyst_jsload_message)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); progressDialog.show(); if (mIsUsingJSProxy) { reloadJSInProxyMode(progressDialog); } else { reloadJSFromServer(progressDialog); } }
private WebsocketJavaScriptExecutor.JSExecutorConnectCallback getExecutorConnectCallback( final ProgressDialog progressDialog, final SimpleSettableFuture<Boolean> future) { return new WebsocketJavaScriptExecutor.JSExecutorConnectCallback() { @Override public void onSuccess() { future.set(true); progressDialog.dismiss(); } @Override public void onFailure(final Throwable cause) { progressDialog.dismiss(); FLog.e(ReactConstants.TAG, "Unable to connect to remote debugger", cause); future.setException( new IOException( mApplicationContext.getString(R.string.catalyst_remotedbg_error), cause)); } }; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { TextView title = convertView != null ? (TextView) convertView : (TextView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.redbox_item_title, parent, false); title.setText(mTitle); return title; } else { if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.redbox_item_frame, parent, false); convertView.setTag(new FrameViewHolder(convertView)); } StackFrame frame = mStack[position - 1]; FrameViewHolder holder = (FrameViewHolder) convertView.getTag(); holder.mMethodView.setText(frame.getMethod()); holder.mFileView.setText(frame.getFileName() + ":" + frame.getLine()); return convertView; } }
protected RedBoxDialog(Context context, DevSupportManager devSupportManager) { super(context, R.style.Theme_Catalyst_RedBox); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.redbox_view); mDevSupportManager = devSupportManager; mStackView = (ListView) findViewById(R.id.rn_redbox_stack); mStackView.setOnItemClickListener(this); mReloadJs = (Button) findViewById(R.id.rn_redbox_reloadjs); mReloadJs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDevSupportManager.handleReloadJS(); } }); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { TextView title = convertView != null ? (TextView) convertView : (TextView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.redbox_item_title, parent, false); title.setText(mTitle); return title; } else { if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.redbox_item_frame, parent, false); convertView.setTag(new FrameViewHolder(convertView)); } StackFrame frame = mStack[position - 1]; FrameViewHolder holder = (FrameViewHolder) convertView.getTag(); holder.mMethodView.setText(frame.getMethod()); final int column = frame.getColumn(); final String columnString = column < 0 ? "" : ":" + column; holder.mFileView.setText(frame.getFileName() + ":" + frame.getLine() + columnString); return convertView; } }
@Override public void handleReloadJS() { UiThreadUtil.assertOnUiThread(); // dismiss redbox if exists if (mRedBoxDialog != null) { mRedBoxDialog.dismiss(); } AlertDialog dialog = new AlertDialog.Builder(mApplicationContext) .setTitle(R.string.catalyst_jsload_title) .setMessage(mApplicationContext.getString( mDevSettings.isRemoteJSDebugEnabled() ? R.string.catalyst_remotedbg_message : R.string.catalyst_jsload_message)) .create(); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.show(); if (mDevSettings.isRemoteJSDebugEnabled()) { reloadJSInProxyMode(dialog); } else { reloadJSFromServer(dialog); } }
private WebsocketJavaScriptExecutor.JSExecutorConnectCallback getExecutorConnectCallback( final AlertDialog progressDialog, final SimpleSettableFuture<Boolean> future) { return new WebsocketJavaScriptExecutor.JSExecutorConnectCallback() { @Override public void onSuccess() { future.set(true); progressDialog.dismiss(); } @Override public void onFailure(final Throwable cause) { progressDialog.dismiss(); FLog.e(ReactConstants.TAG, "Unable to connect to remote debugger", cause); future.setException( new IOException( mApplicationContext.getString(R.string.catalyst_remotedbg_error), cause)); } }; }
@ReactProp(name = "minimumTrackTintColor", customType = "Color") public void setMinimumTrackTintColor(ReactSlider view, Integer color) { LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent(); Drawable background = drawable.findDrawableByLayerId(android.R.id.background); if (color == null) { background.clearColorFilter(); } else { background.setColorFilter(color, PorterDuff.Mode.SRC_IN); } }
@ReactProp(name = "maximumTrackTintColor", customType = "Color") public void setMaximumTrackTintColor(ReactSlider view, Integer color) { LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent(); Drawable progress = drawable.findDrawableByLayerId(android.R.id.progress); if (color == null) { progress.clearColorFilter(); } else { progress.setColorFilter(color, PorterDuff.Mode.SRC_IN); } }
public FpsView(ReactContext reactContext) { super(reactContext); inflate(reactContext, R.layout.fps_view, this); mTextView = (TextView) findViewById(R.id.fps_text); mFrameCallback = new FpsDebugFrameCallback(ChoreographerCompat.getInstance(), reactContext); mFPSMonitorRunnable = new FPSMonitorRunnable(); setCurrentFPS(0, 0, 0, 0); }
@ReactProp(name = PROP_TEST_ID) public void setTestId(T view, String testId) { view.setTag(R.id.react_test_id, testId); // temporarily set the tag and keyed tags to avoid end to end test regressions view.setTag(testId); }
public FpsView(ReactContext reactContext) { super(reactContext); inflate(reactContext, R.layout.fps_view, this); mTextView = (TextView) findViewById(R.id.fps_text); mFrameCallback = new FpsDebugFrameCallback(Choreographer.getInstance(), reactContext); mFPSMonitorRunnable = new FPSMonitorRunnable(); setCurrentFPS(0, 0, 0, 0); }
public void reloadJSFromServer(final String bundleURL) { mDevLoadingViewController.showForUrl(bundleURL); mDevLoadingViewVisible = true; mDevServerHelper.downloadBundleFromURL( new DevServerHelper.BundleDownloadCallback() { @Override public void onSuccess() { mDevLoadingViewController.hide(); mDevLoadingViewVisible = false; UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { mReactInstanceCommandsHandler.onJSBundleLoadedFromServer(); } }); } @Override public void onProgress(@Nullable final String status, @Nullable final Integer done, @Nullable final Integer total) { mDevLoadingViewController.updateProgress(status, done, total); } @Override public void onFailure(final Exception cause) { mDevLoadingViewController.hide(); mDevLoadingViewVisible = false; FLog.e(ReactConstants.TAG, "Unable to download JS bundle", cause); UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { if (cause instanceof DebugServerException) { DebugServerException debugServerException = (DebugServerException) cause; showNewJavaError(debugServerException.getMessage(), cause); } else { showNewJavaError( mApplicationContext.getString(R.string.catalyst_jsload_error), cause); } } }); } }, mJSBundleTempFile, bundleURL); }
private FrameViewHolder(View v) { mMethodView = (TextView) v.findViewById(R.id.rn_frame_method); mFileView = (TextView) v.findViewById(R.id.rn_frame_file); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.catalyst_settings_title); addPreferencesFromResource(R.xml.preferences); }
public DevLoadingViewController(Context context) { mContext = context; mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mDevLoadingView = (TextView) inflater.inflate(R.layout.dev_loading_view, null); }