This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Calendar c = Calendar.getInstance(); | |
year = c.get(Calendar.YEAR); | |
month = c.get(Calendar.MONTH); | |
day = c.get(Calendar.DAY_OF_MONTH); | |
DatePickerDialog datePickerDialog = new DatePickerDialog(this, | |
new DatePickerDialog.OnDateSetListener() { | |
@Override | |
public void onDateSet(DatePicker view, int year, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hour = c.get(Calendar.HOUR_OF_DAY); | |
minute = c.get(Calendar.MINUTE); | |
TimePickerDialog timePickerDialog = new TimePickerDialog(this, | |
new TimePickerDialog.OnTimeSetListener() { | |
@Override | |
public void onTimeSet(TimePicker view, int hourOfDay, | |
int minute) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setup the alert builder | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle(getString(R.string.notice)); | |
builder.setMessage(getString(R.string.alert_title)); | |
// add the buttons | |
builder.setPositiveButton(getString(R.string.launch_app), new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
Toast.makeText(AlertsActivity.this, getString(R.string.launch_app) + " " + getString(R.string.click), Toast.LENGTH_SHORT).show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add this dependency in gradle file | |
implementation 'androidx.cardview:cardview:1.0.0' | |
<androidx.cardview.widget.CardView | |
android:layout_width="match_parent" | |
android:layout_height="148dp" | |
android:layout_marginTop="16dp" | |
app:cardCornerRadius="8dp"> | |
<androidx.constraintlayout.widget.ConstraintLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gradients | |
// gradient_1.xml in drawable folder | |
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
<gradient | |
android:angle="225" | |
android:endColor="#1a2980" | |
android:startColor="#26d0ce" /> | |
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
android:shape="rectangle"> | |
<gradient | |
android:angle="0" | |
android:centerColor="#1976d2" | |
android:centerX="0.1" | |
android:centerY="0.1" | |
android:endColor="#6200ea" | |
android:gradientRadius="100" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.google.android.material:material:1.2.0-alpha02' | |
<com.google.android.material.floatingactionbutton.FloatingActionButton | |
android:id="@+id/fab" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="bottom|end" | |
android:layout_margin="@dimen/space_16" | |
android:src="@android:drawable/ic_dialog_email" | |
android:tint="@color/light_green" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Snackbar snackbar = Snackbar | |
.make(view, R.string.error_occured, Snackbar.LENGTH_LONG) | |
.setAction(R.string.retry, new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Toast.makeText(AlertsActivity.this, getString(R.string.retry_message), Toast.LENGTH_LONG).show(); | |
} | |
}); | |
snackbar.setActionTextColor(Color.RED); | |
View snackbarView = snackbar.getView(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gradle dependencies | |
implementation 'com.squareup.retrofit2:retrofit:2.9.0' | |
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
public class User { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface OnGetUsersCallback { | |
void onSuccess(List<User> users); | |
void onError(); | |
} |
OlderNewer