Skip to content

Instantly share code, notes, and snippets.

View vmasullo's full-sized avatar
💭
Contact me if you like.

Vincenzo Masullo vmasullo

💭
Contact me if you like.
View GitHub Profile
@udacityandroid
udacityandroid / WeatherContract.java
Created July 26, 2016 21:54
Contract class for a weather application called Sunshine
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@udacityandroid
udacityandroid / list_item.xml
Created May 13, 2016 21:08
Miwok App: Miwok app: List Item Views with pressed states
<?xml version="1.0" encoding="utf-8"?>
<!-- Layout for a single list item -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:background="@color/tan_background"
android:orientation="horizontal">
@udacityandroid
udacityandroid / Helper Method - releaseMediaPlayer()
Last active May 19, 2023 05:51
Miwok app: Cleaning up MediaPlayer resources
/**
* Clean up the media player by releasing its resources.
*/
private void releaseMediaPlayer() {
// If the media player is not null, then it may be currently playing a sound.
if (mMediaPlayer != null) {
// Regardless of the current state of the media player, release its resources
// because we no longer need it.
mMediaPlayer.release();
anonymous
anonymous / MainActivity.java
Created April 2, 2016 01:02
Activity Lifecycle exercise
package com.example.android.lifecycle;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@udacityandroid
udacityandroid / MainActivity.java
Created June 27, 2015 23:17
Android for Beginners : Menu Solution Code
package com.example.android.menu;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@udacityandroid
udacityandroid / MainActivity.java
Created June 27, 2015 21:54
Android for Beginners : Cookies Solution Code
package com.example.android.cookies;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@udacityandroid
udacityandroid / strings.xml
Last active February 6, 2023 17:58
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>
@udacityandroid
udacityandroid / Code snippet from MainActivity.java
Last active February 6, 2023 14:25
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;
}
@udacityandroid
udacityandroid / MainActivity.java
Last active December 22, 2023 08:49
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.
@udacityandroid
udacityandroid / Code snippet in SmoothieActivity.java
Last active February 6, 2023 13:54
Android for Beginners : If/Else Smoothie Quiz
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.");