Skip to content

Instantly share code, notes, and snippets.

@Camden5S
Camden5S / final.java
Created March 31, 2019 10:18
This is what the file should look like:
package com.example.carouselpicker;
import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
@Camden5S
Camden5S / order.java
Created March 31, 2019 10:17
here the code creates the DrinkID and order. It then sends this list of numbers to the arduino.
//FINAL ORDER BUTTON (POPUP, SENDS DRINK ARRAY TO ARDUINO)
//------------------------------------------------
public void onClickOrder(View view) {
//The Functions bellow are converting intiger values into strings which can then be written to the arduino via a Serial Connection
String VodkaOrder = Integer.toString(Vodka_Measure);
String RumOrder = Integer.toString(Rum_Measure);
String GinOrder = Integer.toString(Gin_Measure);
String WhiskeyOrder = Integer.toString(Whiskey_Measure);
@Camden5S
Camden5S / test.java
Created March 31, 2019 10:15
now we need to create the order button that shows the popup for the final order. here you can select the size of the drink.
//BUTTON TO INITIATE POPUP
public void ShowPopup(View v) {
TextView txtclose;
Button btnOrder;
myDialog.setContentView(R.layout.custompopup);
txtclose = (TextView) myDialog.findViewById(R.id.txtclose);
btnOrder = (Button) myDialog.findViewById(R.id.btnorder);
txtclose.setOnClickListener(new View.OnClickListener() {
@Override
@Camden5S
Camden5S / java.java
Created March 31, 2019 10:14
In this section of code we are adding click functionality to each image. When the desired drink is in the center of the carousel, the code is ran for each case.
//---------------------------------------------
// DRINK SELECTORS / DRINK RECIPES
//---------------------------------------------
//VODKA BASED DRINKS
carouselPicker1.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@Camden5S
Camden5S / drink.java
Last active March 31, 2019 10:10
In this section of code we are adding click functionality to each image. When the desired drink is in the center of the carousel, the code is ran for each case. For example, when the first item (case 0) is selected, we assign values to each variable - designing the drink we want. In this case, we also display a toast message (small popup).
//---------------------------------------------
// DRINK SELECTORS / DRINK RECIPES
//---------------------------------------------
//VODKA BASED DRINKS
carouselPicker1.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@Camden5S
Camden5S / mainactivity.java
Created March 31, 2019 10:03
Here we are actually creating the carousels and the items within them. Each item has an image associated with it. The name of each drink is already included in the image so it makes it easy to view.
//---------------------------------------------
// DRINK ITEMS / IMAGES ON CAROUSEL!
//---------------------------------------------
carouselPicker1 = findViewById(R.id.carouselPicker1);
carouselPicker2 = findViewById(R.id.carouselPicker2);
carouselPicker3 = findViewById(R.id.carouselPicker3);
//VODKA BASED DRINKS