use of android.widget.DatePicker in project AdMoney by ErnestoGonAr.
the class Reporte_Egresos method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
initData();
} catch (NullPointerException e) {
Toast toast = Toast.makeText(this, "No hay Egresos", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
setContentView(R.layout.activity_reporte__egresos);
pieChart = (PieChart) findViewById(R.id.grafico_egresos);
pieChart.setRotationEnabled(true);
pieChart.setHoleRadius(30f);
pieChart.setCenterTextSize(10);
pieChart.setEntryLabelTextSize(4);
pieChart.setTransparentCircleAlpha(0);
Description d = pieChart.getDescription();
d.setText("");
pieChart.setDescription(d);
pieChart.getLegend().setOrientation(Legend.LegendOrientation.VERTICAL);
pieChart.getLegend().setTextSize(12);
pieChart.getLegend().setPosition(Legend.LegendPosition.LEFT_OF_CHART);
if (xData.length == 0)
return;
addData();
pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, Highlight h) {
Log.d(TAG, "onValueSelected: Value selected from chart");
Log.d(TAG, e.toString());
Log.d(TAG, h.toString());
int pos1 = e.toString().indexOf("Entry, x: 0.0 y: ");
String res = e.toString().substring(pos1 + 17);
for (int i = 0; i < yData.length; i++) {
if (yData[i] == Float.parseFloat(res)) {
pos1 = i;
break;
}
}
String categoria = xData[pos1];
Toast.makeText(Reporte_Egresos.this, "Ha gastado $" + res + " en " + categoria, Toast.LENGTH_LONG).show();
}
@Override
public void onNothingSelected() {
}
});
spinner = (Spinner) findViewById(R.id.spinner_r_egresos);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calendar.setText("Selecciona una fecha");
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
año = 2017;
mes = 5;
diad = 17;
calendar = (EditText) findViewById(R.id.fecha_r_egresos);
calendar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// To show current date in the datepicker
final Calendar mcurrentDate = Calendar.getInstance();
mYear = mcurrentDate.get(Calendar.YEAR);
mMonth = mcurrentDate.get(Calendar.MONTH);
mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
DatePickerDialog mDatePicker = new DatePickerDialog(Reporte_Egresos.this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
// TODO Auto-generated method stub
año = selectedyear;
mes = selectedmonth + 1;
diad = selectedday;
calendar.setText(selectedyear + "-" + (selectedmonth + 1) + "-" + selectedday);
}
}, mYear, mMonth, mDay);
mDatePicker.setTitle("Selecciona fecha");
mDatePicker.show();
}
});
consultar = (Button) findViewById(R.id.consultar_e);
consultar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (calendar.getText().toString().equals("Selecciona una fecha")) {
calendar.requestFocus();
calendar.callOnClick();
return;
}
String[][] data;
switch(spinner.getSelectedItemPosition()) {
case 1:
String dia = calendar.getText().toString();
data = bd.obtenerEgresos(diad + "", mes + "", año + "");
if (data == null) {
Toast toast = Toast.makeText(getApplicationContext(), "No hay registros para esta fecha", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
pieChart.setVisibility(View.INVISIBLE);
break;
}
pieChart.clear();
initData(data);
addData();
pieChart.setVisibility(View.VISIBLE);
break;
case 2:
data = bd.obtenerEgresos(mes + "", año + "");
if (data == null) {
Toast toast = Toast.makeText(getApplicationContext(), "No hay registros para esta fecha", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
pieChart.setVisibility(View.INVISIBLE);
break;
}
pieChart.clear();
initData(data);
addData();
pieChart.setVisibility(View.VISIBLE);
break;
case 3:
data = bd.obtenerEgresos(año + "");
if (data == null) {
Toast toast = Toast.makeText(getApplicationContext(), "No hay registros para esta fecha", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
pieChart.setVisibility(View.INVISIBLE);
break;
}
pieChart.clear();
initData(data);
addData();
pieChart.setVisibility(View.VISIBLE);
break;
default:
pieChart.clear();
initData();
addData();
pieChart.setVisibility(View.VISIBLE);
break;
}
}
});
}
use of android.widget.DatePicker in project IITB-App by wncc.
the class AddEventFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
container.removeAllViews();
view = inflater.inflate(R.layout.fragment_add_event, container, false);
ButterKnife.bind(this, view);
eventPictureImageView = view.findViewById(R.id.ib_eventImage);
progressDialog = new ProgressDialog(getContext());
cb_permission.setVisibility(View.GONE);
cb_public.setVisibility(View.GONE);
et_mapLocation.setVisibility(View.GONE);
close.setVisibility(View.GONE);
open.setVisibility(View.VISIBLE);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
start.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
}
}, mHour, mMin, true);
timePickerDialog.show();
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_start = new Timestamp(millis);
}
});
end.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
end.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
}
}, mHour, mMin, true);
timePickerDialog.show();
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_end = new Timestamp(millis);
}
});
if (cb_permission.isChecked()) {
publicStatus = 1;
} else
publicStatus = 0;
advancedMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cb_public.getVisibility() == View.VISIBLE) {
open.setVisibility(View.VISIBLE);
close.setVisibility(View.GONE);
cb_permission.setVisibility(View.GONE);
cb_public.setVisibility(View.GONE);
et_mapLocation.setVisibility(View.GONE);
} else {
close.setVisibility(View.VISIBLE);
open.setVisibility(View.GONE);
cb_permission.setVisibility(View.VISIBLE);
cb_public.setVisibility(View.VISIBLE);
et_mapLocation.setVisibility(View.VISIBLE);
}
}
});
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
}
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
});
createEvent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.show();
sendImage();
}
});
return view;
}
use of android.widget.DatePicker in project curb by irijwj.
the class InformationCreateFragment method onM_AddInfoEditDateClicked.
@OnClick(R.id.add_info_edit_date)
public void onM_AddInfoEditDateClicked() {
DatePicker lc_datePicker = new DatePicker(m_activity);
lc_datePicker.setElevation(3);
ConstraintLayout.LayoutParams lc_layoutParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lc_layoutParams.setMarginStart(16);
m_InfoDetailConstraintLayout.addView(lc_datePicker, lc_layoutParams);
lc_datePicker.setVisibility(View.VISIBLE);
Calendar lc_calendar = Calendar.getInstance();
int lc_currentYear = lc_calendar.get(Calendar.YEAR);
int lc_currentMonth = lc_calendar.get(Calendar.MONTH);
int lc_currentDay = lc_calendar.get(Calendar.DAY_OF_MONTH);
lc_datePicker.init(lc_currentYear, lc_currentMonth, lc_currentDay, new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
setDate(year, monthOfYear, dayOfMonth);
view.setVisibility(View.GONE);
}
});
}
use of android.widget.DatePicker in project BloodHub by kazijehangir.
the class AddAppointmentActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_appointment);
setTitle("Add Appointment");
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
spinner = (Spinner) findViewById(R.id.spin1);
set = (EditText) findViewById(R.id.editText);
set1 = (EditText) findViewById(R.id.editText2);
radioGroup = (RadioGroup) findViewById(R.id.radio);
hospitals = new ArrayList<String>();
keys = new ArrayList<String>();
FirebaseDatabase.getInstance().getReference().child("users").orderByChild("account_type").equalTo("organization").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot child : dataSnapshot.getChildren()) {
User user = child.getValue(User.class);
hospitals.add(user.username);
keys.add(child.getKey());
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, hospitals);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new Dialog(AddAppointmentActivity.this);
dialog.setTitle("Set Date");
dialog.setContentView(R.layout.set_date);
dialog.show();
final Button setDate = (Button) dialog.findViewById(R.id.set_date);
final DatePicker datePicker = (DatePicker) dialog.findViewById(R.id.datePicker);
datePicker.setMinDate(System.currentTimeMillis() - 1000);
setDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
day = datePicker.getDayOfMonth();
month = datePicker.getMonth();
year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);
pdate = calendar.getTime();
date = DateFormat.getDateInstance().format(pdate);
set.setText(date);
dialog.cancel();
}
});
}
});
set1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new Dialog(AddAppointmentActivity.this);
dialog.setTitle("Set Time");
dialog.setContentView(R.layout.set_time);
dialog.show();
final Button setTime = (Button) dialog.findViewById(R.id.set_time);
final TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.timePicker);
setTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hour = timePicker.getCurrentHour();
minute = timePicker.getCurrentMinute();
if (hour >= 12) {
time = "PM";
} else {
time = "AM";
}
if (hour > 12) {
hour = hour - 12;
}
if (minute > 10) {
time = minute + " " + time;
} else {
time = "0" + minute + " " + time;
}
if (hour > 10) {
time = hour + ":" + time;
} else {
time = "0" + hour + ":" + time;
}
set1.setText(time);
dialog.cancel();
}
});
}
});
Button submit = (Button) findViewById(R.id.submit_button1);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
String transport_text = (String) radioButton.getText();
if (transport_text.equals("Yes")) {
transport = true;
} else {
transport = false;
}
Appointment appointment = new Appointment(user.getUid(), keys.get(spinner.getSelectedItemPosition()), date, time, transport);
FirebaseDatabase.getInstance().getReference().child("appointments").push().setValue(appointment);
dialog = new Dialog(AddAppointmentActivity.this);
dialog.setTitle("Submit Request");
dialog.setContentView(R.layout.popup_appointment_submit);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button request = (Button) dialog.findViewById(R.id.button_ok);
request.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddAppointmentActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
});
}
use of android.widget.DatePicker in project BloodHub by kazijehangir.
the class AddDonorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
mEmail = user.getEmail();
// INITIALIZE FIREBASE DB
db = FirebaseDatabase.getInstance().getReference().child("donors");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_donor);
setTitle("Add Donor");
name = (AutoCompleteTextView) findViewById(R.id.name);
bloodgroup = (Spinner) findViewById(R.id.spin);
age = (EditText) findViewById(R.id.age);
number = (EditText) findViewById(R.id.editText2);
address = (EditText) findViewById(R.id.editText3);
donorOrigin = (EditText) findViewById(R.id.editText4);
lastDonated = (EditText) findViewById(R.id.editText);
final EditText set = (EditText) findViewById(R.id.editText);
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(AddDonorActivity.this);
builder.setTitle("Last donated");
builder.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (options[which] == "Set date") {
final Dialog dialog1;
dialog1 = new Dialog(AddDonorActivity.this);
dialog1.setTitle("Set Date and Time");
dialog1.setContentView(R.layout.set_date);
dialog1.show();
final Button setDate = (Button) dialog1.findViewById(R.id.set_date);
final DatePicker datePicker = (DatePicker) dialog1.findViewById(R.id.datePicker);
setDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
date = datePicker.getDayOfMonth();
month = datePicker.getMonth();
year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
pdate = calendar.getTime();
String date = DateFormat.getDateInstance().format(pdate);
set.setText(date);
dialog1.cancel();
}
});
} else {
set.setText("Never");
}
}
});
builder.show();
}
});
Button addDonor = (Button) findViewById(R.id.add_donor);
addDonor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Context context = getApplicationContext();
dName = name.getText().toString();
dBloodgroup = bloodgroup.getSelectedItem().toString();
dAge = age.getText().toString();
dNumber = number.getText().toString();
dAddress = address.getText().toString();
ddonorOrigin = donorOrigin.getText().toString();
dLastDonated = lastDonated.getText().toString();
View focusView = null;
if (TextUtils.isEmpty(dName)) {
name.setError("Name cannot be empty");
focusView = name;
} else if (TextUtils.isEmpty(dNumber)) {
number.setError("Number cannot be empty");
} else {
Donor donor = new Donor(user.getUid(), dName, dBloodgroup, dNumber, dAddress, dLastDonated, ddonorOrigin, dAge);
try {
db.push().setValue(donor);
dialog = new Dialog(AddDonorActivity.this);
dialog.setTitle("Add Donor");
dialog.setContentView(R.layout.popup_donor);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button submit = (Button) dialog.findViewById(R.id.button_ok);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddDonorActivity.this, MainActivityOrg.class);
startActivity(intent);
}
});
} catch (DatabaseException e) {
Toast.makeText(context, "Error occurred", Toast.LENGTH_SHORT).show();
}
}
// else if(dBloodgroup) {
// bloodgroup.setError("Blood group can not be empty");
// }
}
});
}
Aggregations