use of android.widget.DatePicker in project DroidShows by ltGuillaume.
the class ViewEpisode method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
this.overridePendingTransition(R.anim.right_enter, R.anim.right_exit);
super.onCreate(savedInstanceState);
setContentView(R.layout.view_episode);
db = SQLiteStore.getInstance(this);
View view = findViewById(R.id.viewEpisodes);
view.setOnTouchListener(swipeDetect);
serieId = getIntent().getStringExtra("serieId");
serieName = getIntent().getStringExtra("serieName");
episodeId = getIntent().getStringExtra("episodeId");
String query = "SELECT seasonNumber, episodeNumber, episodeName, overview, rating, firstAired, imdbId, seen FROM episodes " + "WHERE id = '" + episodeId + "' AND serieId='" + serieId + "'";
Cursor c = db.Query(query);
c.moveToFirst();
if (c != null && c.isFirst()) {
int seasonNumberCol = c.getColumnIndex("seasonNumber");
int episodeNumberCol = c.getColumnIndex("episodeNumber");
int enameCol = c.getColumnIndex("episodeName");
int overviewCol = c.getColumnIndex("overview");
int ratingCol = c.getColumnIndex("rating");
int airedCol = c.getColumnIndex("firstAired");
int imdbIdCol = c.getColumnIndex("imdbId");
int seenCol = c.getColumnIndex("seen");
String firstAired = c.getString(airedCol);
if (!firstAired.equals("") && !firstAired.equals("null")) {
try {
Date epDate = SQLiteStore.dateFormat.parse(firstAired);
firstAired = SimpleDateFormat.getDateInstance().format(epDate);
} catch (ParseException e) {
Log.e(SQLiteStore.TAG, e.getMessage());
}
} else {
firstAired = "";
}
int seasonNumber = c.getInt(seasonNumberCol);
int episodeNumber = c.getInt(episodeNumberCol);
episodeName = c.getString(enameCol);
String overview = c.getString(overviewCol);
String rating = c.getString(ratingCol);
imdbId = c.getString(imdbIdCol);
seen = c.getInt(seenCol);
c.close();
setTitle(serieName + " - " + (getString(R.string.messages_ep).isEmpty() ? "" : getString(R.string.messages_ep) + " ") + seasonNumber + (episodeNumber < 10 ? "x0" : "x") + episodeNumber);
TextView episodeNameV = (TextView) findViewById(R.id.episodeName);
episodeNameV.setText(episodeName);
TextView ratingV = (TextView) findViewById(R.id.rating);
if (!rating.equalsIgnoreCase("null") && !rating.equals(""))
ratingV.setText("IMDb: " + rating);
else
ratingV.setText("IMDb Info");
ratingV.setOnTouchListener(swipeDetect);
final CheckBox seenCheckBox = (CheckBox) findViewById(R.id.seen);
seenCheckBox.setChecked(seen > 0);
check(seenCheckBox);
seenCheckBox.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View arg0) {
int year = 0, month = 0, day = 0;
if (seen > 1) {
year = seen / 10000;
month = seen % 10000 / 100 - 1;
day = seen % 100;
} else {
Calendar cal = Calendar.getInstance();
year = cal.get(Calendar.YEAR);
month = cal.get(Calendar.MONTH);
day = cal.get(Calendar.DAY_OF_MONTH);
}
dateDialog = new DatePickerDialog(seenCheckBox.getContext(), new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int month, int day) {
seen = 10000 * year + 100 * (month + 1) + day;
seenCheckBox.setChecked(seen > 1);
check(seenCheckBox);
}
}, year, month, day);
dateDialog.show();
return true;
}
});
if (!firstAired.equalsIgnoreCase("null") && !firstAired.equals("")) {
TextView firstAiredV = (TextView) findViewById(R.id.firstAired);
firstAiredV.setText(firstAired);
firstAiredV.setVisibility(View.VISIBLE);
}
if (!overview.equalsIgnoreCase("null") && !overview.equals("")) {
TextView overviewV = (TextView) findViewById(R.id.overview);
overviewV.setText(overview);
findViewById(R.id.overviewField).setVisibility(View.VISIBLE);
}
Cursor cwriters = db.Query("SELECT writer FROM writers WHERE episodeId='" + episodeId + "' AND serieId='" + serieId + "'");
cwriters.moveToFirst();
if (cwriters != null && cwriters.isFirst()) {
do {
writers.add(cwriters.getString(0));
} while (cwriters.moveToNext());
}
cwriters.close();
if (!writers.isEmpty()) {
TextView writersV = (TextView) findViewById(R.id.writer);
writersV.setText(writers.toString().replace("]", "").replace("[", ""));
writersV.setOnTouchListener(swipeDetect);
View writerField = (View) findViewById(R.id.writerField);
writerField.setOnTouchListener(swipeDetect);
writerField.setVisibility(View.VISIBLE);
}
Cursor cdirectors = db.Query("SELECT director FROM directors WHERE episodeId='" + episodeId + "' AND serieId='" + serieId + "'");
cdirectors.moveToFirst();
if (cdirectors != null && cdirectors.isFirst()) {
do {
directors.add(cdirectors.getString(0));
} while (cdirectors.moveToNext());
}
cdirectors.close();
if (!directors.isEmpty()) {
TextView directorsV = (TextView) findViewById(R.id.director);
directorsV.setText(directors.toString().replace("]", "").replace("[", ""));
directorsV.setOnTouchListener(swipeDetect);
View directorField = (View) findViewById(R.id.directorField);
directorField.setOnTouchListener(swipeDetect);
directorField.setVisibility(View.VISIBLE);
}
Cursor cgs = db.Query("SELECT guestStar FROM guestStars WHERE episodeId='" + episodeId + "' AND serieId='" + serieId + "'");
cgs.moveToFirst();
if (cgs != null && cgs.isFirst()) {
do {
guestStars.add(cgs.getString(0));
} while (cgs.moveToNext());
}
cgs.close();
if (!guestStars.isEmpty()) {
TextView guestStarsV = (TextView) findViewById(R.id.guestStars);
guestStarsV.setText(guestStars.toString().replace("]", "").replace("[", ""));
guestStarsV.setOnTouchListener(swipeDetect);
View guestStarsField = (View) findViewById(R.id.guestStarsField);
guestStarsField.setOnTouchListener(swipeDetect);
guestStarsField.setVisibility(View.VISIBLE);
}
}
Intent testForApp = new Intent(Intent.ACTION_VIEW, Uri.parse("imdb:///find"));
if (getApplicationContext().getPackageManager().resolveActivity(testForApp, 0) == null)
uri = "http://m.imdb.com/";
}
use of android.widget.DatePicker in project android by nextcloud.
the class ExpirationDatePickerDialogFragment method onCreateDialog.
/**
* {@inheritDoc}
*
* @return A new dialog to let the user choose an expiration date that will be bound to a share link.
*/
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Chosen date received as an argument must be later than tomorrow ; default to tomorrow in other case
final Calendar chosenDate = Calendar.getInstance();
long tomorrowInMillis = chosenDate.getTimeInMillis() + DateUtils.DAY_IN_MILLIS;
long chosenDateInMillis = requireArguments().getLong(ARG_CHOSEN_DATE_IN_MILLIS);
chosenDate.setTimeInMillis(Math.max(chosenDateInMillis, tomorrowInMillis));
// Create a new instance of DatePickerDialog
DatePickerDialog dialog = new DatePickerDialog(requireActivity(), R.style.FallbackDatePickerDialogTheme, this, chosenDate.get(Calendar.YEAR), chosenDate.get(Calendar.MONTH), chosenDate.get(Calendar.DAY_OF_MONTH));
// show unset button only when date is already selected
if (chosenDateInMillis > 0) {
dialog.setButton(Dialog.BUTTON_NEUTRAL, getText(R.string.share_via_link_unset_password), (dialog1, which) -> {
if (onExpiryDateListener != null) {
onExpiryDateListener.onDateUnSet();
}
});
}
dialog.show();
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
// Prevent days in the past may be chosen
DatePicker picker = dialog.getDatePicker();
picker.setMinDate(tomorrowInMillis - 1000);
// Enforce spinners view; ignored by MD-based theme in Android >=5, but calendar is REALLY buggy
// in Android < 5, so let's be sure it never appears (in tablets both spinners and calendar are
// shown by default)
picker.setCalendarViewShown(false);
return dialog;
}
use of android.widget.DatePicker in project xDrip by NightscoutFoundation.
the class NoteSearch method setupGui.
private void setupGui() {
this.dateButton1 = (Button) findViewById(R.id.button_date1);
this.dateButton2 = (Button) findViewById(R.id.button_date2);
this.searchTextField = (EditText) findViewById(R.id.searchTextField);
updateButtonText();
// register search button on keyboard
searchTextField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
doSearch(true);
return true;
}
return false;
}
});
searchTextField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
last_keypress_time = JoH.tsl();
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
searchOnKeyPress();
}
}, KEY_PAUSE);
}
});
// add Calendar to buttons
dateButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new DatePickerDialog(NoteSearch.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date1.set(year, monthOfYear, dayOfMonth);
updateButtonText();
}
}, date1.get(Calendar.YEAR), date1.get(Calendar.MONTH), date1.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
});
dateButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new DatePickerDialog(NoteSearch.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date2.set(year, monthOfYear, dayOfMonth);
updateButtonText();
}
}, date2.get(Calendar.YEAR), date2.get(Calendar.MONTH), date2.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
});
}
use of android.widget.DatePicker in project xDrip-plus by jamorham.
the class NoteSearch method setupGui.
private void setupGui() {
this.dateButton1 = (Button) findViewById(R.id.button_date1);
this.dateButton2 = (Button) findViewById(R.id.button_date2);
this.searchTextField = (EditText) findViewById(R.id.searchTextField);
updateButtonText();
// register search button on keyboard
searchTextField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
doSearch(true);
return true;
}
return false;
}
});
searchTextField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
last_keypress_time = JoH.tsl();
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
searchOnKeyPress();
}
}, KEY_PAUSE);
}
});
// add Calendar to buttons
dateButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new DatePickerDialog(NoteSearch.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date1.set(year, monthOfYear, dayOfMonth);
updateButtonText();
}
}, date1.get(Calendar.YEAR), date1.get(Calendar.MONTH), date1.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
});
dateButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new DatePickerDialog(NoteSearch.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date2.set(year, monthOfYear, dayOfMonth);
updateButtonText();
}
}, date2.get(Calendar.YEAR), date2.get(Calendar.MONTH), date2.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
});
}
use of android.widget.DatePicker in project xDrip-plus by jamorham.
the class BGHistory method setupButtons.
private void setupButtons() {
Button prevButton = (Button) findViewById(R.id.button_prev);
Button nextButton = (Button) findViewById(R.id.button_next);
this.dateButton1 = (Button) findViewById(R.id.button_date1);
this.daysSpinner = (Spinner) findViewById(R.id.daysspinner);
prevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
date1.add(Calendar.DATE, -noDays);
setupCharts();
}
});
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
date1.add(Calendar.DATE, +noDays);
setupCharts();
}
});
dateButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dialog = new DatePickerDialog(BGHistory.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date1.set(year, monthOfYear, dayOfMonth);
setupCharts();
}
}, date1.get(Calendar.YEAR), date1.get(Calendar.MONTH), date1.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
});
String[] vals = new String[14];
vals[0] = 1 + " day";
for (int i = 1; i < vals.length; i++) {
vals[i] = (i + 1) + " days";
}
daysSpinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, vals));
daysSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
noDays = position + 1;
setupCharts();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
noDays = 1;
setupCharts();
}
});
}
Aggregations