Skip to content

Instantly share code, notes, and snippets.

View ZafarDorna's full-sized avatar
:octocat:
Data Science & Big data enthusiast

Abu Zafar Mohammad Saleh ZafarDorna

:octocat:
Data Science & Big data enthusiast
View GitHub Profile
@ZafarDorna
ZafarDorna / Code snippet from MainActivity.java
Created September 18, 2016 04:22 — forked from udacityandroid/Code snippet from MainActivity.java
Android for Beginners : Negative Number of Cups of Coffee Extra Challenge Solution
/**
* This method is called when the plus button is clicked.
*/
public void increment(View view) {
if (quantity == 100) {
// Show an error message as a toast
Toast.makeText(this, "You cannot have more than 100 coffees", Toast.LENGTH_SHORT).show();
// Exit this method early because there's nothing left to do
return;
}
@ZafarDorna
ZafarDorna / Code snippet in WeatherActivity.java
Created September 15, 2016 23:37 — 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.");
@ZafarDorna
ZafarDorna / Code snippet in WeatherActivity.java
Created September 15, 2016 23:37 — forked from udacityandroid/Code snippet in WeatherActivity.java
Android for Beginners : If/Else Weather Quiz
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.");
}
@ZafarDorna
ZafarDorna / MainActivity.java
Created September 14, 2016 09:41 — forked from udacityandroid/MainActivity.java
Android for Beginners : Add the Chocolate Topping Checkbox Solution Java
package com.example.android.justjava;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
/**
* This app displays an order form to order coffee.
@ZafarDorna
ZafarDorna / MainActivity.java
Created September 13, 2016 08:42 — forked from udacityandroid/MainActivity.java
Android for Beginners : Cookies Starting Code
package com.example.android.cookies;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
@ZafarDorna
ZafarDorna / TextView.java
Created September 6, 2016 03:04 — forked from udacityandroid/TextView.java
Android for Beginners : Simplified TextView class
/**
* Displays text to the user.
*/
public class TextView extends View {
// String value
private String mText;
// Text color of the text
private int mTextColor;
@ZafarDorna
ZafarDorna / ImageView.java
Created September 6, 2016 03:04 — forked from udacityandroid/ImageView.java
Android for Beginners : Simplified ImageView class
/**
* Displays an image, such as an icon.
*/
public class ImageView extends View {
// Resource ID for the source image that should be displayed in the ImageView.
private int mImageId;
// Context of the app
private Context mContext;
@ZafarDorna
ZafarDorna / Method 1
Created September 3, 2016 15:40 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
/**
* Get the email account name.
*
* @return the name of the account.
*/
private String getAccountName() {
return "[email protected]";
return "[email protected]";
}
@ZafarDorna
ZafarDorna / Method 1
Created August 31, 2016 14:21 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
private String createCalendarEventReminder(String eventName, String location, int minutesAway) {
String reminder = "You have an upcoming event in " + minutesAway + " minutes.";
reminder = reminder + " It is " + eventName + " held at " + location + ".";
return reminder;
}
@ZafarDorna
ZafarDorna / Option A
Created August 31, 2016 11:12 — forked from udacityandroid/Option A
Android Development for Beginners : Calculate the Price Method
/**
* Calculates the price of the order based on the current quantity.
*
* @return the price
*/
private int calculate price(int quantity {
int price = quantity * 5;
return price;
}