Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AH Werkplanner code snippet
package owenselles.com.werkplanner;
import android.app.DatePickerDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import java.util.Calendar;
import owenselles.com.werkplanner.logics.SaveDetails;
import owenselles.com.werkplanner.logics.StorageManager;
public class StartScreen extends AppCompatActivity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
SaveDetails details = StorageManager.getSaveDetails(getApplicationContext()); // load first time
if (!details.darkTheme) {
setTheme(R.style.LightAppTheme_NoActionBar);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.start_screen);
Button button = findViewById(R.id.continueButton);
button.setOnClickListener(this);
}
@Override
public void onClick(final View view) {
final SaveDetails details = StorageManager.getSaveDetails(getApplicationContext());
final Calendar calendar = DateAssist.create();
DatePickerDialog dialog = new DatePickerDialog(view.getContext(), android.R.style.Theme_Holo, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int dayOfMonth) {
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
details.birthDate = calendar;
details.saveChanges(getApplicationContext());
finish();
}
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
dialog.setTitle("Geboortedatum");
dialog.setMessage("Vul uw geboortedatum in:");
dialog.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.