Skip to content

Instantly share code, notes, and snippets.

View marwa-eltayeb's full-sized avatar

Marwa Eltayeb marwa-eltayeb

View GitHub Profile
@marwa-eltayeb
marwa-eltayeb / HistoricApiResponse.kt
Created July 3, 2021 23:09
Parse JSON nested keys with its value
package com.marwaeltayeb.currencyexchange.data.model
import com.google.gson.annotations.SerializedName
data class HistoricApiResponse(
@SerializedName("base")
val base: String,
@SerializedName("end_date")
val endAt: String,
@SerializedName("rates")
@marwa-eltayeb
marwa-eltayeb / RateApiResponse.kt
Created July 3, 2021 23:07
Parse the JSON key with the value
package com.marwaeltayeb.currencyexchange.data.model
import com.google.gson.annotations.SerializedName
data class RateApiResponse(
@SerializedName("rates")
val rates: Map<String, Double>,
@SerializedName("base")
val base: String,
@SerializedName("date")
@marwa-eltayeb
marwa-eltayeb / onCreate method in MainActivity.java
Created May 16, 2017 20:14 — forked from udacityandroid/onCreate method in MainActivity.java
Use OnClickListeners for All Categories - onCreate method in MainActivity.java
// Find the View that shows the numbers category
TextView numbers = (TextView) findViewById(R.id.numbers);
// Set a click listener on that View
numbers.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(numbersIntent);
@marwa-eltayeb
marwa-eltayeb / strings.xml
Created May 15, 2017 16:06 — forked from udacityandroid/strings.xml
Android for Beginners : Spanish Localization Solution. This would be saved in the res/values-es/strings.xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for the application. [CHAR LIMIT=12] -->
<string name="app_name">Sólo Java</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Nombre</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Ingredientes</string>
int numberOfSmoothiesTillPrize = 10;
if (numberOfSmoothiesTillPrize > 9) {
Log.v("SmoothieActivity", "Congratulations, you get a free smoothie!");
numberOfSmoothiesTillPrize = numberOfSmoothiesTillPrize - 10;
} else {
Log.v("SmoothieActivity", "No free smoothie this time.");
}
Log.v("SmoothieActivity", "You currently have " + numberOfSmoothiesTillPrize + " out of 10 smoothies needed for your next free smoothie.");
int numberOfEmailsInInbox = 0;
int numberOfDraftEmails = 2;
String emailMessage = "You have " + numberOfEmailsInInbox + " emails. ";
String draftMessage = "You have " + numberOfDraftEmails + " email drafts.";
if (numberOfEmailsInInbox == 0) {
emailMessage = "You have no new messages. ";
}
if (numberOfDraftEmails == 0) {
draftMessage = "You have no new drafts.";
@marwa-eltayeb
marwa-eltayeb / Code snippet in WeatherActivity.java
Created May 14, 2017 19:19 — forked from udacityandroid/Code snippet in WeatherActivity.java
Android for Beginners : If/Else Weather Sample Quiz
boolean isRaining = true;
if (isRaining) {
Log.v("WeatherActivity", "It's raining, better bring an umbrella.");
} else {
Log.v("WeatherActivity", "It's unlikely to rain.");
}
Log.v("WeatherActivity", "Thank you for using the WhetherWeather App.");
boolean isRaining = false;
Log.v("WeatherActivity", "Thank you for using the WhetherWeather App.");
if (isRaining) {
Log.v("WeatherActivity", "It's raining, better bring an umbrella.");
} else {
Log.v("WeatherActivity", "It's unlikely to rain.");
}