@Override public void setupView() { sliderBr = (Slider) rootView.findViewById(R.id.slider_br); sliderCn = (Slider) rootView.findViewById(R.id.slider_cn); sliderBr.setOnValueChangedListener( new Slider.OnValueChangedListener() { @Override public void onValueChanged(int value) { sendBrightnessResult(value); } }); sliderCn.setOnValueChangedListener( new Slider.OnValueChangedListener() { @Override public void onValueChanged(int value) { sendContrastsResult(value); } }); filterListView = (RecyclerView) rootView.findViewById(R.id.edit_filter_list); setupFilterList(); setupSliderValue(DEFAULT_BRIGHTNESS, sliderBr); setupSliderValue(DEFAULT_CONTRAST, sliderCn); }
@Override public void onAction(EditorAction action) { switch (action) { case RESET_IMAGE: sliderBr.setValue(DEFAULT_BRIGHTNESS); sliderCn.setValue(DEFAULT_CONTRAST); break; } }
private void setupSliderValue(final int value, final Slider slider) { ViewTreeObserver viewTreeObserver = slider.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { slider.getViewTreeObserver().removeOnGlobalLayoutListener(this); slider.setValue(value); } }); } }