|
@ -1,11 +1,12 @@ |
|
|
package com.henninghall.date_picker; |
|
|
package com.henninghall.date_picker; |
|
|
|
|
|
|
|
|
import android.util.Log; |
|
|
|
|
|
import android.view.View; |
|
|
|
|
|
import android.widget.NumberPicker; |
|
|
|
|
|
import android.widget.RelativeLayout; |
|
|
import android.widget.RelativeLayout; |
|
|
|
|
|
|
|
|
import com.facebook.react.bridge.Dynamic; |
|
|
import com.facebook.react.bridge.Dynamic; |
|
|
|
|
|
import com.henninghall.date_picker.props.MaximumDateProp; |
|
|
|
|
|
import com.henninghall.date_picker.props.MinimumDateProp; |
|
|
|
|
|
import com.henninghall.date_picker.props.MinuteIntervalProp; |
|
|
|
|
|
import com.henninghall.date_picker.props.UtcProp; |
|
|
import com.henninghall.date_picker.props.VariantProp; |
|
|
import com.henninghall.date_picker.props.VariantProp; |
|
|
import com.henninghall.date_picker.props.DateProp; |
|
|
import com.henninghall.date_picker.props.DateProp; |
|
|
import com.henninghall.date_picker.props.FadeToColorProp; |
|
|
import com.henninghall.date_picker.props.FadeToColorProp; |
|
@ -14,15 +15,16 @@ import com.henninghall.date_picker.props.LocaleProp; |
|
|
import com.henninghall.date_picker.props.ModeProp; |
|
|
import com.henninghall.date_picker.props.ModeProp; |
|
|
import com.henninghall.date_picker.props.TextColorProp; |
|
|
import com.henninghall.date_picker.props.TextColorProp; |
|
|
import com.henninghall.date_picker.ui.UIManager; |
|
|
import com.henninghall.date_picker.ui.UIManager; |
|
|
|
|
|
import com.henninghall.date_picker.wheels.AmPmWheel; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
public class PickerView extends RelativeLayout { |
|
|
public class PickerView extends RelativeLayout { |
|
|
|
|
|
|
|
|
private UIManager uiManager; |
|
|
private UIManager uiManager; |
|
|
private State state = new State(); |
|
|
private State state = new State(); |
|
|
private ArrayList<String> updatedProps = new ArrayList<>(); |
|
|
private ArrayList<String> updatedProps = new ArrayList<>(); |
|
|
private boolean initialized = false; |
|
|
|
|
|
|
|
|
|
|
|
public PickerView() { |
|
|
public PickerView() { |
|
|
super(DatePickerManager.context); |
|
|
super(DatePickerManager.context); |
|
@ -30,40 +32,36 @@ public class PickerView extends RelativeLayout { |
|
|
|
|
|
|
|
|
public void update() { |
|
|
public void update() { |
|
|
|
|
|
|
|
|
if(!initialized){ |
|
|
|
|
|
|
|
|
if (didUpdate(VariantProp.name)) { |
|
|
|
|
|
this.removeAllViewsInLayout(); |
|
|
inflate(getContext(), state.derived.getRootLayout(), this); |
|
|
inflate(getContext(), state.derived.getRootLayout(), this); |
|
|
uiManager = new UIManager(state, this); |
|
|
uiManager = new UIManager(state, this); |
|
|
initialized = true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(updatedProps.contains(FadeToColorProp.name)) { |
|
|
|
|
|
|
|
|
if (didUpdate(FadeToColorProp.name)) { |
|
|
uiManager.updateFadeToColor(); |
|
|
uiManager.updateFadeToColor(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(updatedProps.contains(TextColorProp.name)) { |
|
|
|
|
|
|
|
|
if (didUpdate(TextColorProp.name, VariantProp.name)) { |
|
|
uiManager.updateTextColor(); |
|
|
uiManager.updateTextColor(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(updatedProps.contains(ModeProp.name)) { |
|
|
|
|
|
|
|
|
if (didUpdate(ModeProp.name, VariantProp.name)) { |
|
|
uiManager.updateWheelVisibility(); |
|
|
uiManager.updateWheelVisibility(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(updatedProps.contains(HeightProp.name)) { |
|
|
|
|
|
|
|
|
if (didUpdate(HeightProp.name)) { |
|
|
uiManager.updateHeight(); |
|
|
uiManager.updateHeight(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(updatedProps.contains(ModeProp.name) || updatedProps.contains(LocaleProp.name)) { |
|
|
|
|
|
|
|
|
if (didUpdate(ModeProp.name, LocaleProp.name, VariantProp.name)) { |
|
|
uiManager.updateWheelOrder(); |
|
|
uiManager.updateWheelOrder(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ArrayList<String> noDisplayValueChangeProps = new ArrayList<String>(){{ |
|
|
|
|
|
add(DateProp.name); |
|
|
|
|
|
add(FadeToColorProp.name); |
|
|
|
|
|
add(TextColorProp.name); |
|
|
|
|
|
}}; |
|
|
|
|
|
updatedProps.removeAll(noDisplayValueChangeProps); |
|
|
|
|
|
|
|
|
|
|
|
if(updatedProps.size() != 0) { |
|
|
|
|
|
|
|
|
if (didUpdate(DateProp.name, HeightProp.name, LocaleProp.name, |
|
|
|
|
|
MaximumDateProp.name, MinimumDateProp.name, MinuteIntervalProp.name, ModeProp.name, |
|
|
|
|
|
UtcProp.name, VariantProp.name |
|
|
|
|
|
)) { |
|
|
uiManager.updateDisplayValues(); |
|
|
uiManager.updateDisplayValues(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -72,6 +70,13 @@ public class PickerView extends RelativeLayout { |
|
|
updatedProps = new ArrayList<>(); |
|
|
updatedProps = new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean didUpdate(String... propNames) { |
|
|
|
|
|
for (String propName : propNames) { |
|
|
|
|
|
if (updatedProps.contains(propName)) return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void updateProp(String propName, Dynamic value) { |
|
|
public void updateProp(String propName, Dynamic value) { |
|
|
state.setProp(propName, value); |
|
|
state.setProp(propName, value); |
|
|
updatedProps.add(propName); |
|
|
updatedProps.add(propName); |
|
@ -98,5 +103,4 @@ public class PickerView extends RelativeLayout { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |