Fix opening rules

This commit is contained in:
Victor Shcherb 2013-06-26 00:30:02 +02:00
parent 1bd73e31a6
commit f7ae9e2c12
2 changed files with 14 additions and 14 deletions

View file

@ -6,7 +6,7 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.util.OpeningHoursParser.BasicDayOpeningHourRule; import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import net.osmand.util.OpeningHoursParser.OpeningHoursRule; import net.osmand.util.OpeningHoursParser.OpeningHoursRule;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
@ -40,7 +40,7 @@ public class OpeningHoursView {
this.ctx = ctx; this.ctx = ctx;
} }
public View createOpeningHoursEditView(List<BasicDayOpeningHourRule> t){ public View createOpeningHoursEditView(List<BasicOpeningHourRule> t){
this.time = new TimeAdapter(t); this.time = new TimeAdapter(t);
// editing object // editing object
time.add(null); time.add(null);
@ -80,15 +80,15 @@ public class OpeningHoursView {
return view; return view;
} }
private class TimeAdapter extends ArrayAdapter<BasicDayOpeningHourRule> { private class TimeAdapter extends ArrayAdapter<BasicOpeningHourRule> {
public TimeAdapter(List<BasicDayOpeningHourRule> l ){ public TimeAdapter(List<BasicOpeningHourRule> l ){
super(ctx, R.layout.open_hours_list_item, l); super(ctx, R.layout.open_hours_list_item, l);
} }
@Override @Override
public View getView(final int position, View convertView, ViewGroup parent) { public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView; View row = convertView;
final BasicDayOpeningHourRule item = getItem(position); final BasicOpeningHourRule item = getItem(position);
if(item == null){ if(item == null){
TextView text = new TextView(getContext()); TextView text = new TextView(getContext());
text.setText(ctx.getString(R.string.add_new_rule)); text.setText(ctx.getString(R.string.add_new_rule));
@ -98,7 +98,7 @@ public class OpeningHoursView {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
BasicDayOpeningHourRule r = new BasicDayOpeningHourRule(); BasicOpeningHourRule r = new BasicOpeningHourRule();
r.setStartTime(timePickerStart.getCurrentHour()*60 + timePickerStart.getCurrentMinute()); r.setStartTime(timePickerStart.getCurrentHour()*60 + timePickerStart.getCurrentMinute());
r.setEndTime(timePickerEnd.getCurrentHour()*60 + timePickerEnd.getCurrentMinute()); r.setEndTime(timePickerEnd.getCurrentHour()*60 + timePickerEnd.getCurrentMinute());
@ -155,7 +155,7 @@ public class OpeningHoursView {
} }
} }
public void showDaysDialog(final BasicDayOpeningHourRule item, final int positionToAdd) { public void showDaysDialog(final BasicOpeningHourRule item, final int positionToAdd) {
Builder b = new AlertDialog.Builder(ctx); Builder b = new AlertDialog.Builder(ctx);
boolean add = positionToAdd > -1; boolean add = positionToAdd > -1;
@ -207,7 +207,7 @@ public class OpeningHoursView {
public void updateTimePickers() { public void updateTimePickers() {
if (selectedRule > -1) { if (selectedRule > -1) {
BasicDayOpeningHourRule item = time.getItem(selectedRule); BasicOpeningHourRule item = time.getItem(selectedRule);
if (item != null) { if (item != null) {
notifyingTime = false; notifyingTime = false;
timePickerStart.setCurrentHour(item.getStartTime() / 60); timePickerStart.setCurrentHour(item.getStartTime() / 60);
@ -222,7 +222,7 @@ public class OpeningHoursView {
public List<OpeningHoursRule> getTime() { public List<OpeningHoursRule> getTime() {
List<OpeningHoursRule> rules = new ArrayList<OpeningHoursRule>(); List<OpeningHoursRule> rules = new ArrayList<OpeningHoursRule>();
for (int i = 0; i < time.getCount(); i++) { for (int i = 0; i < time.getCount(); i++) {
BasicDayOpeningHourRule r = time.getItem(i); BasicOpeningHourRule r = time.getItem(i);
if (r != null) { if (r != null) {
rules.add(r); rules.add(r);
} }

View file

@ -24,7 +24,7 @@ import net.osmand.plus.activities.DialogProvider;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OpeningHoursView; import net.osmand.plus.activities.OpeningHoursView;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
import net.osmand.util.OpeningHoursParser.BasicDayOpeningHourRule; import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import net.osmand.util.OpeningHoursParser.OpeningHours; import net.osmand.util.OpeningHoursParser.OpeningHours;
import net.osmand.util.OpeningHoursParser.OpeningHoursRule; import net.osmand.util.OpeningHoursParser.OpeningHoursRule;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -528,12 +528,12 @@ public class EditingPOIActivity implements DialogProvider {
return null; return null;
} }
List<BasicDayOpeningHourRule> simple = null; List<BasicOpeningHourRule> simple = null;
if(time != null){ if(time != null){
simple = new ArrayList<BasicDayOpeningHourRule>(); simple = new ArrayList<BasicOpeningHourRule>();
for(OpeningHoursRule r : time.getRules()){ for(OpeningHoursRule r : time.getRules()){
if(r instanceof BasicDayOpeningHourRule){ if(r instanceof BasicOpeningHourRule){
simple.add((BasicDayOpeningHourRule) r); simple.add((BasicOpeningHourRule) r);
} else { } else {
time = null; time = null;
break; break;