NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.asusrog.papajohns;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;

public class CustomActivity extends AppCompatActivity {
Button btnOpenDialog;
CheckBox v1,v2,v3,v4,v5,v6,v7,v8,v9;
CheckBox t1,t2,t3;
CheckBox s1,s2,s3;
String c,v,t,s,txt;
RadioGroup rg;
TextView des;
Float p;
String size,type;
Integer quan;


private static String url = "http://tootbh.com/a_papa/setPizzaC.php";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom);

btnOpenDialog = (Button)findViewById(R.id.cOrderBT);

rg = (RadioGroup) findViewById(R.id.cheeseRG);
v1 = (CheckBox) findViewById(R.id.greenPeppersCB);
v2 = (CheckBox) findViewById(R.id.mushroomsCB);
v3 = (CheckBox) findViewById(R.id.onionsCB);
v4 = (CheckBox) findViewById(R.id.tomatoesCB);
v5 = (CheckBox) findViewById(R.id.bananaPeppersCB);
v6 = (CheckBox) findViewById(R.id.pineappleTidbitsCB);
v7 = (CheckBox) findViewById(R.id.ripeOlivesCB);
v8 = (CheckBox) findViewById(R.id.greenOlivesCB);
v9 = (CheckBox) findViewById(R.id.jalapenoPeppersCB);

t1 = (CheckBox) findViewById(R.id.pepperoniCB);
t2 = (CheckBox) findViewById(R.id.beefCB);
t3 = (CheckBox) findViewById(R.id.chickenCB);

s1 = (CheckBox) findViewById(R.id.bbqRB);
s2 = (CheckBox) findViewById(R.id.ranchRB);
s3 = (CheckBox) findViewById(R.id.spinachRB);

des = (TextView) findViewById(R.id.desTV);



btnOpenDialog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
c = "Cheese: ";
v = " ";
t = " ";
s = " ";

int i = rg.getCheckedRadioButtonId();
RadioButton r = (RadioButton) findViewById(i);

c += r.getText().toString();


if (v1.isChecked()) {
v += v1.getText().toString() + ". ";
}
if (v2.isChecked()) {
v += v2.getText().toString() + ". ";
}
if (v3.isChecked()) {
v += v3.getText().toString() + ". ";
}
if (v4.isChecked()) {
v += v4.getText().toString() + ". ";
}
if (v5.isChecked()) {
v += v5.getText().toString() + ". ";
}
if (v6.isChecked()) {
v += v6.getText().toString() + ". ";
}
if (v7.isChecked()) {
v += v7.getText().toString() + ". ";
}
if (v8.isChecked()) {
v += v8.getText().toString() + ". ";
}
if (v9.isChecked()) {
v += v9.getText().toString() + ". ";
}

if (t1.isChecked()) {
t += t1.getText().toString() + ". ";
}
if (t2.isChecked()) {
t += t2.getText().toString() + ". ";
}
if (t3.isChecked()) {
t += t3.getText().toString() + ". ";
}


if (s1.isChecked()) {
s += s1.getText().toString() + ". ";
}
if (s2.isChecked()) {
s += s2.getText().toString() + ". ";
}
if (s3.isChecked()) {
s += s3.getText().toString() + ". ";
}

txt = c;
if(!v.equals(" ")){
txt += "nVegetables: " + v;}
if(!t.equals(" ")){
txt += "nTopping: " + t;}
if(!s.equals(" ")){
txt += "nSauce: " + s;}



des.setText(txt);

Toast.makeText(CustomActivity.this,txt,Toast.LENGTH_SHORT).show();

openDialog();
}
});

}

@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_custom, 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);
}

////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void openDialog(){
LayoutInflater inflater = LayoutInflater.from(CustomActivity.this);
final View subView = inflater.inflate(R.layout.dialog_signin, null);

final EditText subEditText = (EditText)subView.findViewById(R.id.quantityET);
//final TextView dscr = (TextView)subView.findViewById(R.id.desTV);
final RadioGroup rg = (RadioGroup)subView.findViewById(R.id.radioGroup);
final RadioButton[] r1 = new RadioButton[1];
final RadioButton[] r2 = new RadioButton[1]; //= (RadioButton) subView.findViewById(R.id.largeRB);
final RadioGroup rg1 = (RadioGroup)subView.findViewById(R.id.radioGroup2);


//final ImageView subImageView = (ImageView)subView.findViewById(R.id.image);
//Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
//subImageView.setImageDrawable(drawable);

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("AlertDialog");
builder.setMessage("AlertDialog Message");
builder.setView(subView);
AlertDialog alertDialog = builder.create();

builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//id.setText(subEditText.getText().toString());
Toast.makeText(CustomActivity.this, "OK", Toast.LENGTH_LONG).show();


int selectedId = rg.getCheckedRadioButtonId();
r1[0] = (RadioButton) subView.findViewById(selectedId);
int selectedId2 = rg1.getCheckedRadioButtonId();
r2[0] = (RadioButton) subView.findViewById(selectedId2);

// Toast.makeText(PizzaActivity.this, pizzaID.getText().toString(), Toast.LENGTH_SHORT).show();
/*
Toast.makeText(CustomActivity.this, r1[0].getText().toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(CustomActivity.this, r2[0].getText().toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(CustomActivity.this, subEditText.getText().toString(), Toast.LENGTH_SHORT).show();
*/
p = new Float(3.0);

new GetAsync().execute(des.getText().toString(),p.toString());

//Integer pid = Integer.valueOf(pizzaID.getText().toString());
quan = Integer.valueOf(subEditText.getText().toString());

if (r1[0].getText().toString().equals("Medium")) {
Float i = new Float(1.5);
p = p * i;
} else if (r1[0].getText().toString().equals("Large")) {
Float i = new Float(2.5);
p = p * i;
}
p = p * quan;

size = r1[0].getText().toString();
type = r2[0].getText().toString();
/*

*/



}
});

builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(CustomActivity.this, "Cancel", Toast.LENGTH_LONG).show();
}
});

builder.show();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////


class GetAsync extends AsyncTask<String, String, JSONObject> {
// Creating JSON Parser object
JSONParser jsonParser = new JSONParser();
ArrayList<String[]> listM = new ArrayList<String[]>();
ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>();
int pid;

SQLiteDatabase db;

private ProgressDialog pDialog;

private static final String TAG_SUCCESS = "success";
// private static final String TAG_MESSAGE = "message";

JSONArray menus = null;


@Override
protected void onPreExecute() {
pDialog = new ProgressDialog(CustomActivity.this);
pDialog.setMessage("Attempting login...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

@Override
protected JSONObject doInBackground(String... args) {

try {

HashMap<String, String> params = new HashMap<>();
params.put("d", args[0]);
params.put("p", args[1]);

Log.d("request", "starting");

JSONObject json = jsonParser.makeHttpRequest(
url, "GET", params);

if (json != null) {
Log.d("JSON result", json.toString());

return json;
}

} catch (Exception e) {
e.printStackTrace();
}

return null;
}

protected void onPostExecute(JSONObject json) {

int success = 0;
String message = "";

if (pDialog != null && pDialog.isShowing()) {
pDialog.dismiss();
}

if (json != null) {
Toast.makeText(CustomActivity.this, json.toString(),
Toast.LENGTH_LONG).show();

try {
success = json.getInt(TAG_SUCCESS);
//message = json.getString(TAG_MESSAGE);
} catch (JSONException e) {
e.printStackTrace();
}
}

if (success == 1) {
//Log.d("Success!", message);
Toast.makeText(CustomActivity.this, "Success!",
Toast.LENGTH_LONG).show();

try {
// Getting Array of Contacts
//menus = json.getJSONArray("menus");

//Log.d("text", menus.getString(1));
// looping through All Contacts

//JSONObject c = menus.getJSONObject(0);
pid = json.getInt("menus");





} catch (JSONException e) {
e.printStackTrace();
}

// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
// updating listview
//Log.d("gridView.setAdapter(;", listM + "");


Toast.makeText(CustomActivity.this,String.valueOf(pid)+"n"+size+"n"
+type+"n"+String.valueOf(quan)+"n"+String.valueOf(p) +"n"+ des.getText().toString(),Toast.LENGTH_LONG).show();


db = openOrCreateDatabase("papaJ", Context.MODE_PRIVATE, null);db.execSQL("CREATE TABLE IF NOT EXISTS orderItem(" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" pizzaID INT(11) NOT NULL, " +
" pizzaName VARCHAR(250) not null," +
" size VARCHAR(10) NOT NULL," +
" type VARCHAR(10) NOT NULL," +
" quan INT(2) NOT NULL," +
" price FLOAT(10) NOT NULL," +
" uid VARCHAR(250) NOT NULL );" );

String usid;
Cursor u = db.rawQuery("SELECT email as uid FROM users",null);
if(u!=null && u.moveToFirst()) {
usid = (String) u.getString(u.getColumnIndex("uid"));
}else
usid = "-1";

// db.execSQL(String.format("INSERT INTO orderItem VALUES(null,%d,'custom pizza','%s','%s',%d,%s,%s);", pid, size, type, quan, p,usid));
Toast.makeText(CustomActivity.this, "OK 123156",
Toast.LENGTH_LONG).show();

db.execSQL("INSERT INTO orderItem VALUES(null,"
+ pid
+ ","custom pizza""
+ ",'" + size + "'," +
"'" + type + "',"
+ quan + ","
+ p + ",""+usid+"");");

}
});
}else{
//Log.d("Failure", message);
Toast.makeText(CustomActivity.this, "Failure",
Toast.LENGTH_LONG).show();
}
}

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.