use of android.widget.DatePicker in project iNaturalistAndroid by inaturalist.
the class ExploreFiltersActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.setElevation(0);
actionBar.setLogo(R.drawable.ic_arrow_back);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.filters);
mHelper = new ActivityHelper(this);
setContentView(R.layout.explore_filters);
Intent intent = getIntent();
if (savedInstanceState == null) {
mSearchFilters = (ExploreSearchFilters) intent.getSerializableExtra(SEARCH_FILTERS);
} else {
mSearchFilters = (ExploreSearchFilters) savedInstanceState.getSerializable("mSearchFilters");
}
mHandler = new Handler();
mApplyFilters = (Button) findViewById(R.id.apply_filters);
mTaxonicIcons = (RecyclerView) findViewById(R.id.taxonic_icons);
mShowMyObservationsCheckbox = (View) findViewById(R.id.show_my_observations_checkbox);
mShowMyObservationsRow = (ViewGroup) findViewById(R.id.show_my_observations);
mProjectPic = (ImageView) findViewById(R.id.project_pic);
mProjectName = (TextView) findViewById(R.id.project_name);
mClearProject = (ImageView) findViewById(R.id.clear_project);
mUserPic = (ImageView) findViewById(R.id.user_pic);
mUserName = (TextView) findViewById(R.id.user_name);
mClearUser = (ImageView) findViewById(R.id.clear_user);
mResearchGradeCheckbox = (View) findViewById(R.id.research_grade_checkbox);
mNeedsIdCheckbox = (View) findViewById(R.id.needs_id_checkbox);
mCasualGradeCheckbox = (View) findViewById(R.id.casual_grade_checkbox);
mOptionDateAny = (RadioButton) findViewById(R.id.option_date_any);
mOptionDateExact = (RadioButton) findViewById(R.id.option_date_exact);
mOptionDateMinMax = (RadioButton) findViewById(R.id.option_date_min_max);
mOptionDateMonths = (RadioButton) findViewById(R.id.option_date_months);
mDateAny = (TextView) findViewById(R.id.date_any);
mDateExact = (Spinner) findViewById(R.id.date_exact);
mDateMin = (Spinner) findViewById(R.id.date_min);
mDateMax = (Spinner) findViewById(R.id.date_max);
mDateMonths = (Spinner) findViewById(R.id.date_months);
mDateAny.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOptionDateAny.performClick();
}
});
mClearUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSearchFilters.user = null;
refreshViewState();
}
});
mUserName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String searchUrl = INaturalistService.API_HOST + "/users/autocomplete";
Intent intent = new Intent(ExploreFiltersActivity.this, ItemSearchActivity.class);
intent.putExtra(ItemSearchActivity.RETURN_RESULT, true);
intent.putExtra(ItemSearchActivity.SEARCH_HINT_TEXT, getString(R.string.search_users));
intent.putExtra(ItemSearchActivity.SEARCH_URL, searchUrl);
intent.putExtra(ItemSearchActivity.IS_USER, true);
startActivityForResult(intent, REQUEST_CODE_SEARCH_USERS);
}
});
mClearProject.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSearchFilters.project = null;
refreshViewState();
}
});
mProjectName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ExploreFiltersActivity.this, ItemSearchActivity.class);
intent.putExtra(ItemSearchActivity.RETURN_RESULT, true);
intent.putExtra(ItemSearchActivity.SEARCH_HINT_TEXT, getString(R.string.search_projects));
intent.putExtra(ItemSearchActivity.SEARCH_URL, INaturalistService.API_HOST + "/projects/autocomplete");
startActivityForResult(intent, REQUEST_CODE_SEARCH_PROJECTS);
}
});
mApp = (INaturalistApp) getApplicationContext();
SharedPreferences prefs = mApp.getPrefs();
final String currentUsername = prefs.getString("username", null);
final String currentUserIconUrl = prefs.getString("user_icon_url", null);
mShowMyObservationsCheckbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
view.setSelected(!view.isSelected());
if (view.isSelected()) {
// Show my observations
try {
JSONObject myUser = new JSONObject();
myUser.put("login", currentUsername);
myUser.put("icon_url", currentUserIconUrl);
mSearchFilters.user = myUser;
} catch (JSONException e) {
e.printStackTrace();
}
} else {
mSearchFilters.user = null;
}
refreshViewState();
}
});
mShowMyObservationsRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mShowMyObservationsCheckbox.performClick();
}
});
mShowMyObservationsRow.setVisibility(currentUsername == null ? View.GONE : View.VISIBLE);
View.OnClickListener onDataQualityCheckbox = new View.OnClickListener() {
@Override
public void onClick(View view) {
String qualityGrade;
if (view == mResearchGradeCheckbox) {
qualityGrade = ExploreSearchFilters.QUALITY_GRADE_RESEARCH;
} else if (view == mNeedsIdCheckbox) {
qualityGrade = ExploreSearchFilters.QUALITY_GRADE_NEEDS_ID;
} else {
qualityGrade = ExploreSearchFilters.QUALITY_GRADE_CASUAL;
}
view.setSelected(!view.isSelected());
if (view.isSelected()) {
mSearchFilters.qualityGrade.add(qualityGrade);
} else {
mSearchFilters.qualityGrade.remove(qualityGrade);
}
refreshViewState();
}
};
mResearchGradeCheckbox.setOnClickListener(onDataQualityCheckbox);
mNeedsIdCheckbox.setOnClickListener(onDataQualityCheckbox);
mCasualGradeCheckbox.setOnClickListener(onDataQualityCheckbox);
// Show date/calendar picker dialog
View.OnTouchListener onShowDate = new View.OnTouchListener() {
@Override
public boolean onTouch(final View view, MotionEvent event) {
if (event.getAction() != MotionEvent.ACTION_UP) {
return false;
}
Bundle args = new Bundle();
Date initialDate = null, minDate = null, maxDate = new Date();
// Set the initial dates for the calendar view
if (view == mDateExact)
initialDate = mSearchFilters.observedOn;
if (view == mDateMin) {
initialDate = mSearchFilters.observedOnMinDate;
maxDate = mSearchFilters.observedOnMaxDate != null ? mSearchFilters.observedOnMaxDate : new Date();
}
if (view == mDateMax) {
initialDate = mSearchFilters.observedOnMaxDate;
minDate = mSearchFilters.observedOnMinDate;
maxDate = new Date();
}
args.putSerializable("date", initialDate != null ? initialDate : new Date());
if (minDate != null)
args.putSerializable("min_date", minDate);
if (maxDate != null)
args.putSerializable("max_date", maxDate);
DatePickerFragment newFragment = new DatePickerFragment();
newFragment.setArguments(args);
newFragment.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker dp, int year, int month, int dayOfMonth) {
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, dayOfMonth);
Date date = calendar.getTime();
// Update the date
if (view == mDateExact) {
mSearchFilters.observedOn = date;
mSearchFilters.dateFilterType = ExploreSearchFilters.DATE_TYPE_EXACT_DATE;
} else if (view == mDateMin) {
mSearchFilters.observedOnMinDate = date;
mSearchFilters.dateFilterType = ExploreSearchFilters.DATE_TYPE_MIN_MAX_DATE;
} else if (view == mDateMax) {
mSearchFilters.observedOnMaxDate = date;
mSearchFilters.dateFilterType = ExploreSearchFilters.DATE_TYPE_MIN_MAX_DATE;
}
refreshViewState();
}
});
newFragment.show(getSupportFragmentManager(), "datePicker");
return true;
}
};
mDateExact.setOnTouchListener(onShowDate);
mDateMin.setOnTouchListener(onShowDate);
mDateMax.setOnTouchListener(onShowDate);
mDateMonths.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() != MotionEvent.ACTION_UP) {
return false;
}
List<String> monthsNames = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
monthsNames.add(monthToString(i));
}
Set<Integer> selectedPositions = new HashSet<>();
for (Integer month : mSearchFilters.observedOnMonths) {
selectedPositions.add(month - 1);
}
mHelper.multipleChoiceSelection(getString(R.string.choose_months), monthsNames, selectedPositions, new ActivityHelper.OnMultipleChoices() {
@Override
public void onMultipleChoices(Set<Integer> selectedPositions) {
mSearchFilters.observedOnMonths.clear();
for (Integer position : selectedPositions) {
mSearchFilters.observedOnMonths.add(position + 1);
}
mSearchFilters.dateFilterType = ExploreSearchFilters.DATE_TYPE_MONTHS;
refreshViewState();
}
});
return true;
}
});
LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mTaxonicIcons.setLayoutManager(layoutManager);
mApplyFilters.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Return the search filters
if (!mSearchFilters.iconicTaxa.isEmpty()) {
// Iconic taxa have been chosen - clear out the taxon filter
mSearchFilters.taxon = null;
}
Intent data = new Intent();
data.putExtra(SEARCH_FILTERS, mSearchFilters);
setResult(RESULT_OK, data);
finish();
}
});
}
use of android.widget.DatePicker in project ttdj by soonphe.
the class ToolDateTimePicker method show.
public void show(Calendar calendar, final DateSelCallBack callBack) {
if (calendar == null) {
calendar = Calendar.getInstance();
}
switch(chooseType) {
case DATE:
new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
Calendar calendar = Calendar.getInstance();
calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
String date = formatDateTime(calendar.getTime(), DF_YYYY_MM_DD);
targetView.setText(date);
callBack.dateChange(calendar);
}
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE)).show();
break;
case TIME:
new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int hourOfDay, int minute) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, timePicker.getCurrentHour(), timePicker.getCurrentMinute());
targetView.setText(formatDateTime(calendar.getTime(), DF_HH_MM_SS));
}
}, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true).show();
break;
default:
LinearLayout dateTimeLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.view_datetime, null);
datePicker = (DatePicker) dateTimeLayout.findViewById(R.id.datepicker);
timePicker = (TimePicker) dateTimeLayout.findViewById(R.id.timepicker);
initDateTimePicker(datePicker, timePicker);
timePicker.setIs24HourView(true);
timePicker.setOnTimeChangedListener(mOnTimeChangedListener);
dialog = new AlertDialog.Builder(context).setTitle(nowDateTime).setView(dateTimeLayout).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
targetView.setText(nowDateTime);
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
targetView.setText("");
}
}).show();
mOnDateChangedListener.onDateChanged(null, 0, 0, 0);
break;
}
}
use of android.widget.DatePicker in project ttdj by soonphe.
the class ToolDateTimePicker method show.
public void show() {
Calendar c = Calendar.getInstance();
switch(chooseType) {
case DATE:
new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
Calendar calendar = Calendar.getInstance();
calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
targetView.setText(formatDateTime(calendar.getTime(), DF_YYYY_MM_DD));
}
}, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE)).show();
break;
case TIME:
new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int hourOfDay, int minute) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, timePicker.getCurrentHour(), timePicker.getCurrentMinute());
targetView.setText(formatDateTime(calendar.getTime(), DF_HH_MM_SS));
}
}, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true).show();
break;
default:
LinearLayout dateTimeLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.view_datetime, null);
datePicker = (DatePicker) dateTimeLayout.findViewById(R.id.datepicker);
timePicker = (TimePicker) dateTimeLayout.findViewById(R.id.timepicker);
initDateTimePicker(datePicker, timePicker);
timePicker.setIs24HourView(true);
timePicker.setOnTimeChangedListener(mOnTimeChangedListener);
dialog = new AlertDialog.Builder(context).setTitle(nowDateTime).setView(dateTimeLayout).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
targetView.setText(nowDateTime);
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
targetView.setText("");
}
}).show();
mOnDateChangedListener.onDateChanged(null, 0, 0, 0);
break;
}
}
use of android.widget.DatePicker in project Osmand by osmandapp.
the class MapillaryFiltersFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final MapActivity mapActivity = (MapActivity) getActivity();
final OsmandSettings settings = getSettings();
final MapillaryPlugin plugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final int backgroundColor = ContextCompat.getColor(getActivity(), nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_mapillary_filters, null);
view.findViewById(R.id.mapillary_filters_linear_layout).setBackgroundColor(backgroundColor);
final View toggleRow = view.findViewById(R.id.toggle_row);
final boolean selected = settings.SHOW_MAPILLARY.get();
final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
int toggleIconColorId;
int toggleIconId;
if (selected) {
toggleIconId = R.drawable.ic_action_view;
toggleIconColorId = nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light;
} else {
toggleIconId = R.drawable.ic_action_hide;
toggleIconColorId = nightMode ? 0 : R.color.icon_color;
}
((AppCompatTextView) toggleRow.findViewById(R.id.toggle_row_title)).setText(toggleActionStringId);
final Drawable drawable = getIcon(toggleIconId, toggleIconColorId);
((AppCompatImageView) toggleRow.findViewById(R.id.toggle_row_icon)).setImageDrawable(drawable);
final CompoundButton toggle = (CompoundButton) toggleRow.findViewById(R.id.toggle_row_toggle);
toggle.setOnCheckedChangeListener(null);
toggle.setChecked(selected);
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.getDashboard().refreshContent(true);
}
});
toggleRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle.setChecked(!toggle.isChecked());
}
});
final Button reloadTile = (Button) view.findViewById(R.id.button_reload_tile);
reloadTile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ResourceManager manager = getMyApplication().getResourceManager();
manager.clearCacheAndTiles(TileSourceManager.getMapillaryVectorSource());
manager.clearCacheAndTiles(TileSourceManager.getMapillaryRasterSource());
mapActivity.refreshMap();
}
});
final int colorRes = nightMode ? R.color.color_white : R.color.icon_color;
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_user_icon)).setImageDrawable(getIcon(R.drawable.ic_action_user, colorRes));
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_date_icon)).setImageDrawable(getIcon(R.drawable.ic_action_data, colorRes));
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_tile_cache_icon)).setImageDrawable(getIcon(R.drawable.ic_layer_top_dark, colorRes));
final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view);
textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, getMyApplication()));
String selectedUsername = settings.MAPILLARY_FILTER_USERNAME.get();
if (!selectedUsername.equals("") && settings.USE_MAPILLARY_FILTER.get()) {
textView.setText(selectedUsername);
textView.setSelection(selectedUsername.length());
}
textView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
hideKeyboard();
mapActivity.getDashboard().refreshContent(true);
}
});
textView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == EditorInfo.IME_ACTION_DONE) {
hideKeyboard();
mapActivity.getDashboard().refreshContent(true);
return true;
}
return false;
}
});
textView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
view.findViewById(R.id.warning_linear_layout).setVisibility(View.GONE);
if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || settings.MAPILLARY_FILTER_TO_DATE.get() != 0 || settings.MAPILLARY_FILTER_FROM_DATE.get() != 0) {
changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true);
} else {
changeButtonState((Button) view.findViewById(R.id.button_apply), .5f, false);
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
ImageView imageView = (ImageView) view.findViewById(R.id.warning_image_view);
imageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_small_warning, getResources().getColor(R.color.color_warning)));
final EditText dateFromEt = (EditText) view.findViewById(R.id.date_from_edit_text);
final DatePickerDialog.OnDateSetListener dateFromDialog = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker v, int year, int monthOfYear, int dayOfMonth) {
Calendar from = Calendar.getInstance();
from.set(Calendar.YEAR, year);
from.set(Calendar.MONTH, monthOfYear);
from.set(Calendar.DAY_OF_MONTH, dayOfMonth);
dateFromEt.setText(dateFormat.format(from.getTime()));
settings.MAPILLARY_FILTER_FROM_DATE.set(from.getTimeInMillis());
changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true);
mapActivity.getDashboard().refreshContent(true);
}
};
dateFromEt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Calendar now = Calendar.getInstance();
new DatePickerDialog(mapActivity, dateFromDialog, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)).show();
}
});
dateFromEt.setCompoundDrawablesWithIntrinsicBounds(null, null, getContentIcon(R.drawable.ic_action_arrow_drop_down), null);
final EditText dateToEt = (EditText) view.findViewById(R.id.date_to_edit_text);
final DatePickerDialog.OnDateSetListener dateToDialog = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker v, int year, int monthOfYear, int dayOfMonth) {
Calendar to = Calendar.getInstance();
to.set(Calendar.YEAR, year);
to.set(Calendar.MONTH, monthOfYear);
to.set(Calendar.DAY_OF_MONTH, dayOfMonth);
dateToEt.setText(dateFormat.format(to.getTime()));
settings.MAPILLARY_FILTER_TO_DATE.set(to.getTimeInMillis());
changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true);
mapActivity.getDashboard().refreshContent(true);
}
};
dateToEt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Calendar now = Calendar.getInstance();
new DatePickerDialog(mapActivity, dateToDialog, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)).show();
}
});
dateToEt.setCompoundDrawablesWithIntrinsicBounds(null, null, getContentIcon(R.drawable.ic_action_arrow_drop_down), null);
if (settings.USE_MAPILLARY_FILTER.get()) {
long to = settings.MAPILLARY_FILTER_TO_DATE.get();
if (to != 0) {
dateToEt.setText(dateFormat.format(new Date(to)));
}
long from = settings.MAPILLARY_FILTER_FROM_DATE.get();
if (from != 0) {
dateFromEt.setText(dateFormat.format(new Date(from)));
}
}
final Button apply = (Button) view.findViewById(R.id.button_apply);
changeButtonState(apply, .5f, false);
apply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = textView.getText().toString();
String dateFrom = dateFromEt.getText().toString();
String dateTo = dateToEt.getText().toString();
if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("")) {
settings.USE_MAPILLARY_FILTER.set(true);
}
if (dateFrom.equals("")) {
settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
}
if (dateTo.equals("")) {
settings.MAPILLARY_FILTER_TO_DATE.set(0L);
}
if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) {
view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE);
} else {
mapActivity.getDashboard().hideDashboard();
}
changeButtonState(apply, .5f, false);
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
hideKeyboard();
}
});
final Button clear = (Button) view.findViewById(R.id.button_clear);
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textView.setText("");
dateFromEt.setText("");
dateToEt.setText("");
settings.USE_MAPILLARY_FILTER.set(false);
settings.MAPILLARY_FILTER_USER_KEY.set("");
settings.MAPILLARY_FILTER_USERNAME.set("");
settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
settings.MAPILLARY_FILTER_TO_DATE.set(0L);
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
hideKeyboard();
}
});
return view;
}
use of android.widget.DatePicker in project AndFrameWorks by scwang90.
the class AfDialogBuilder method selectDate.
/**
* 选择日期
* @param title 标题
* @param value 默认时间
* @param listener 监听器
*/
@Override
public Dialog selectDate(CharSequence title, Date value, final OnDateSetListener listener) {
Calendar calender = Calendar.getInstance();
calender.setTime(value);
int year = calender.get(Calendar.YEAR);
int month = calender.get(Calendar.MONTH);
int day = calender.get(Calendar.DAY_OF_MONTH);
AlertDialog tDialog = new DatePickerDialog(mContext, new SafeListener(listener), year, month, day) {
@Override
public void show() {
super.show();
if (listener instanceof OnDateSetVerifyListener) {
getButton(BUTTON_POSITIVE).setOnClickListener(v -> {
try {
DatePicker picker = AfReflecter.getMemberByType(this, DatePicker.class);
if (picker == null) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
} else if (((OnDateSetVerifyListener) listener).onPreDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth())) {
this.dismiss();
super.onClick(this, BUTTON_POSITIVE);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
}
}
};
if (title != null && title.length() > 0) {
tDialog.setTitle(title);
}
tDialog.show();
tDialog.setCancelable(true);
return tDialog;
}
Aggregations