Wednesday, April 19, 2017

Han Fast Food Code

This is the java code

package id.co.blogspot.httphanpalmbridge.palmoilreport;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.text.NumberFormat;




import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends AppCompatActivity {


    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will        // automatically handle clicks on the Home/Up button, so long        // as you specify a parent activity in AndroidManifest.xml.        int id = item.getItemId();

        //noinspection SimplifiableIfStatement        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


    /**     * This 3 methods are for burger     */

    int burgerQuantity = 1;

    /**     * This method is called when the plus button is clicked     */    public void plusBurger(View view) {
        if (burgerQuantity == 20) {
            Toast.makeText(this, "You cannot have more than 20 burgers", Toast.LENGTH_SHORT).show();
            return;
        }
        burgerQuantity = burgerQuantity + 1;
        displayQuantityBurger(burgerQuantity);
    }

    /**     * This method is called when the minus button is clicked     */    public void minBurger(View view) {
        if (burgerQuantity == 1) {
            Toast.makeText(this, "At least you have 1 burger", Toast.LENGTH_SHORT).show();
            return;
        }
        burgerQuantity = burgerQuantity - 1;
        displayQuantityBurger(burgerQuantity);
    }

    /**     * This method is called in plus min methode done, and update the number viewed in screen     */    private void displayQuantityBurger(int numberOfBurger) {
        TextView quantityTextView = (TextView) findViewById(R.id.numberBurgerText);
        quantityTextView.setText("  " + numberOfBurger);
    }


    /**     * This 3 methods are for coke     */

    int cokeQuantity = 0;

    /**     * This method is called when the plus button is clicked     */    public void plusCoke(View view) {
        if (cokeQuantity == 20) {
            Toast.makeText(this, "You cannot have more than 20 cokes", Toast.LENGTH_SHORT).show();
            return;
        }
        cokeQuantity = cokeQuantity + 1;
        displayQuantityCoke(cokeQuantity);
    }

    /**     * This method is called when the minus button is clicked     */    public void minCoke(View view) {
        if (cokeQuantity == 0) {
            Toast.makeText(this, "please check your quantity", Toast.LENGTH_SHORT).show();
            return;
        }
        cokeQuantity = cokeQuantity - 1;
        displayQuantityCoke(cokeQuantity);
    }

    /**     * This method is called in plus min methode done, and update the number viewed in screen     */    //    private void displayQuantityCoke(int numberOfCoke) {
        TextView quantityTextView = (TextView) findViewById(R.id.numberCokeText);
        quantityTextView.setText("  " + numberOfCoke);


    }

    /**     * This 3 methods are for fries     */

    int friesQuantity = 0;

    /**     * This method is called when the plus button is clicked     */    public void plusFries(View view) {
        if (friesQuantity == 20) {
            Toast.makeText(this, "You cannot have more than 20 fries", Toast.LENGTH_SHORT).show();
            return;
        }
        friesQuantity = friesQuantity + 1;
        displayQuantityFries(friesQuantity);
    }

    /**     * This method is called when the minus button is clicked     */    public void minFries(View view) {
        if (friesQuantity == 0) {
            Toast.makeText(this, "please check your quantity", Toast.LENGTH_SHORT).show();
            return;
        }
        friesQuantity = friesQuantity - 1;
        displayQuantityFries(friesQuantity);
    }

    /**     * This method is called in plus min methode done, and update the number viewed in screen     */    //    private void displayQuantityFries(int numberOfFries) {
        TextView quantityTextView = (TextView) findViewById(R.id.numberFriesText);
        quantityTextView.setText("  " + numberOfFries);


    }

    /**     * This 3 methods are for ice cream     */

    int iceQuantity = 0;

    /**     * This method is called when the plus button is clicked     */    public void plusIce(View view) {
        if (iceQuantity == 20) {
            Toast.makeText(this, "You cannot have more than 20 ice", Toast.LENGTH_SHORT).show();
            return;
        }
        iceQuantity = iceQuantity + 1;
        displayQuantityIce(iceQuantity);
    }

    /**     * This method is called when the minus button is clicked     */    public void minIce(View view) {
        if (iceQuantity == 0) {
            Toast.makeText(this, "please check your quantity", Toast.LENGTH_SHORT).show();
            return;
        }
        iceQuantity = iceQuantity - 1;
        displayQuantityIce(iceQuantity);
    }

    /**     * This method is called in plus min methode done, and update the number viewed in screen     */    //    private void displayQuantityIce(int numberOfIce) {
        TextView quantityTextView = (TextView) findViewById(R.id.numberIceText);
        quantityTextView.setText("  " + numberOfIce);


    }

    /**     * This method is called when Send Bill to Email button is clicked     */
    public void sendBill(View view) {


        CheckBox extraCheeseCheckBox = (CheckBox) findViewById(R.id.extra_cheese);
        boolean hasExtraCheese = extraCheeseCheckBox.isChecked();
        //if extra cheese check box checked, value is true on hasExtraCheese variable
        CheckBox takeAwayCheckBox = (CheckBox) findViewById(R.id.take_away);
        boolean hasTakeAway = takeAwayCheckBox.isChecked();
        CheckBox memberCheckBox = (CheckBox) findViewById(R.id.member);
        boolean hasMember = memberCheckBox.isChecked();


        //to get inputed character on text field and store it to customerName        EditText nameField = (EditText) findViewById(R.id.what_is_your_name);
        String customerName = nameField.getText().toString();


        double price = calculatePrice(hasExtraCheese, hasTakeAway, hasMember);
//        displayPrice(price);
        String priceMessage = createOrderSumary(price, hasExtraCheese, hasTakeAway, hasMember, customerName);


        Intent intent = new Intent(Intent.ACTION_SEND);
        //intent.setData(Uri.parse("mailto:")); // only email apps should handle this        //intent.putExtra(Intent.EXTRA_SUBJECT, "Just Java Coffee Order for : " + customerName);        //intent.putExtra(Intent.EXTRA_TEXT,priceMessage);        //   if (intent.resolveActivity(getPackageManager()) != null) {        //     startActivity(intent);        //}        intent.setData (Uri.parse("com.whatsapp"));
        intent.setPackage("com.whatsapp");
        intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
        intent.setType("text/plain");
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }
        displayMessage(priceMessage);
    }

    /**     * Calculates the price of the order based on the current quantity.     * @return the price     */    private double calculatePrice(boolean extraCheese, boolean takeAway, boolean member) {
        double burgerPrice = 5;
        double cokePrice = 1;
        double friesPrice = 3;
        double icePrice = 0.7;

        if (extraCheese){
            burgerPrice += 1;
        }
        double totalBurger = burgerQuantity * burgerPrice;
        double totalCoke = cokeQuantity * cokePrice;
        double totalFries = friesQuantity * friesPrice;
        double totalIce = iceQuantity * icePrice;
        double totalOrder = totalBurger + totalCoke + totalFries + totalIce;
        if (takeAway){
        totalOrder += 0.5;
        }
        if (member) {
        totalOrder = totalOrder * 0.9;
        }
        return totalOrder;
    }
    private String createOrderSumary(double price, boolean extraCheese, boolean takeAway, boolean member, String name){
        String extraCheeseText;
        if (extraCheese = true){
            extraCheeseText = " YES ";
        }
        else{
            extraCheeseText = " NO ";
        }
        String takeAwayText;
        if (takeAway = true){
            takeAwayText = " YES ";
        }
        else{
            takeAwayText = " NO ";
        }
        String memberText;
        if (member = true){
            memberText = " YES ";
        }
        else{
            memberText = " NO ";
        }

        String message ="Name :" + name + "\n";
        message += "Added extra cheese?(add $1) " + extraCheeseText +"\n";
        message += "You want take away?(add $0.5) " + takeAwayText +"\n";
        message += "Already member?(discount 10%) " + memberText +"\n";

        message = message + "Burger $5 : " + + burgerQuantity + " pcs \n";
        message = message + "Coke $1: " + cokeQuantity + " pcs \n";
        message = message + "Fries $3: " + friesQuantity + " pcs \n";
        message = message + "Ice $0.7: " + iceQuantity + " pcs \n";

        message = message + "Total : $ " + price + "\n";
        message = message + "Thank you";
        return message;
    }
    /**     * This method displays the string message value on the screen.     */    private void displayMessage(String message) {
        TextView messageTextView = (TextView) findViewById(R.id.order_summary);
        messageTextView.setText(message);
    }
}


**********************************************

this is the xml code

<?xml version="1.0" encoding="utf-8"?>
<ScrollView    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent">

<RelativeLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    app:layout_behavior="@string/appbar_scrolling_view_behavior"    tools:context="id.co.blogspot.httphanpalmbridge.palmoilreport.MainActivity"    tools:showIn="@layout/activity_main">

    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/appName"        android:text="Han Fast Food"        android:layout_marginTop="50dp"        android:textAllCaps="true"        android:layout_marginLeft="16dp"        android:textSize="16sp"/>

    <TextView        android:id="@+id/menu"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/appName"        android:layout_marginTop="16dp"        android:text="Menu"        android:layout_marginLeft="16dp"        android:textAllCaps="true"/>
<LinearLayout        android:id="@+id/burgerLinearLayout"        android:layout_below="@id/menu"        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content">
    <TextView        android:layout_width="120dp"        android:layout_height="wrap_content"        android:id="@+id/burgerText"        android:backgroundTint="@color/colorAccent"        android:text="Burger"        android:layout_marginLeft="16dp"        android:textAllCaps="true"        />
    <Button        android:layout_width="50dp"        android:layout_height="wrap_content"        android:onClick="minBurger"        android:text="-" />


    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/numberBurgerText"        android:backgroundTint="@color/colorAccent"        android:text=" 1 "        android:layout_marginLeft="16dp"        android:textAllCaps="true" />

    <Button        android:layout_width="50dp"        android:layout_marginLeft="16dp"        android:layout_height="wrap_content"        android:onClick="plusBurger"        android:text="+" />
</LinearLayout>

    <LinearLayout        android:layout_below="@id/burgerLinearLayout"        android:id="@+id/cokeLinearLayout"        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content">
        <TextView            android:layout_width="120dp"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text="Coke"            android:layout_marginLeft="16dp"            android:textAllCaps="true"            />
        <Button            android:layout_width="50dp"            android:onClick="minCoke"            android:layout_height="wrap_content"            android:text="-" />
        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text=" 0 "            android:id="@+id/numberCokeText"            android:layout_marginLeft="16dp"            android:textAllCaps="true" />
        <Button            android:layout_width="50dp"            android:onClick="plusCoke"            android:layout_marginLeft="16dp"            android:layout_height="wrap_content"            android:text="+" />
    </LinearLayout>
    <LinearLayout        android:layout_below="@id/cokeLinearLayout"        android:id="@+id/friesLinearLayout"        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content">
        <TextView            android:layout_width="120dp"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text="Fries"            android:layout_marginLeft="16dp"            android:textAllCaps="true"            />
        <Button            android:layout_width="50dp"            android:onClick="minFries"            android:layout_height="wrap_content"            android:text="-" />
        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text=" 0 "            android:id="@+id/numberFriesText"            android:layout_marginLeft="16dp"            android:textAllCaps="true" />
        <Button            android:layout_width="50dp"            android:onClick="plusFries"            android:layout_marginLeft="16dp"            android:layout_height="wrap_content"            android:text="+" />
    </LinearLayout>
    <LinearLayout        android:layout_below="@id/friesLinearLayout"        android:id="@+id/iceLinearLayout"        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content">
        <TextView            android:layout_width="120dp"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text="Ice Cream"            android:layout_marginLeft="16dp"            android:textAllCaps="true"            />
        <Button            android:layout_width="50dp"            android:onClick="minIce"            android:layout_height="wrap_content"            android:text="-" />
        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text=" 0 "            android:id="@+id/numberIceText"            android:layout_marginLeft="16dp"            android:textAllCaps="true" />
        <Button            android:layout_width="50dp"            android:onClick="plusIce"            android:layout_marginLeft="16dp"            android:layout_height="wrap_content"            android:text="+" />
    </LinearLayout>
    <LinearLayout        android:layout_below="@id/iceLinearLayout"        android:id="@+id/checkBoxLinearLayout"        android:orientation="vertical"        android:layout_width="match_parent"        android:layout_height="wrap_content">


        <CheckBox            android:layout_width="wrap_content"            android:id="@+id/extra_cheese"            android:layout_height="wrap_content"            android:text=" Extra Cheese "            />

        <CheckBox            android:layout_width="wrap_content"            android:id="@+id/take_away"            android:layout_height="wrap_content"            android:text=" Take Away "            />

        <CheckBox            android:layout_width="wrap_content"            android:id="@+id/member"            android:layout_height="wrap_content"            android:text=" Member "            />

        <EditText            android:layout_width="match_parent"            android:id="@+id/what_is_your_name"            android:layout_height="wrap_content"            android:inputType="textCapWords"            android:hint="Input Customer Name here"/>

        <Button            android:layout_width="wrap_content"            android:onClick="sendBill"            android:layout_height="wrap_content"            android:text="Send Bill to Email" />

        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:backgroundTint="@color/colorAccent"            android:text=" Order Summary : "            android:layout_marginLeft="16dp"            android:textAllCaps="true" />

        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:id="@+id/order_summary"            android:backgroundTint="@color/colorAccent"            android:text="..... "            android:layout_marginLeft="16dp"            android:textAllCaps="true" />



    </LinearLayout>


</RelativeLayout>
</ScrollView>

********************************************************************

Cheers ^^

Sunday, January 22, 2017

Review Nanas Honi Sunpride 2017 Jan 720



created by Mr.Han - www.hanpalmbridge.blogspot.com

Nanas Honi Sunpride 2017 Jan

Hi Guys



This time I made a review about pineapple that sold in modern market in Indonesia.



Hope you enjoy it



Cheers^^







 created by Mr.Han - www.hanpalmbridge.blogspot.com