Back to project page AndroidAPP-TorEngine.
The source code is released under:
GNU General Public License
If you think the Android project AndroidAPP-TorEngine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ironwolf.torengine; //from w ww . j a va 2 s . c om import java.io.File; import ironwolf.torengine.R; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class Economia extends Activity { final static int ECON_DIALOG_ID=5; final static int CUSTOM_DIALOG=148; String titolodialog; int id_bottone; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ecomain); Button ftpecon=(Button) findViewById(R.id.ftpecon); ftpecon.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.torengine.it/openftp/economia")); startActivity(intent); } }); final Button appsomma=(Button) findViewById(R.id.appsomma); appsomma.setOnClickListener(new OnClickListener() { public void onClick(View v) { /* Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.torengine.it/openftp/economia/economia_alessandra_somma_v1.pdf")); startActivity(intent); */ titolodialog=appsomma.getText().toString(); id_bottone=1; showDialog(CUSTOM_DIALOG); } }); final Button appganci=(Button) findViewById(R.id.appganci); appganci.setOnClickListener(new OnClickListener() { public void onClick(View v) { /* Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.torengine.it/openftp/economia/economia_marina-ganci_v1.pdf")); startActivity(intent); */ titolodialog=appganci.getText().toString(); id_bottone=2; showDialog(CUSTOM_DIALOG); } }); final Button appdomoff=(Button) findViewById(R.id.appdomoff); appdomoff.setOnClickListener(new OnClickListener() { public void onClick(View v) { /* Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://eaiuniroma2.files.wordpress.com/2012/03/domanda_e_offerta.pdf")); startActivity(intent); */ titolodialog=appdomoff.getText().toString(); id_bottone=3; showDialog(CUSTOM_DIALOG); } }); final Button appvar=(Button) findViewById(R.id.appvar); appvar.setOnClickListener(new OnClickListener() { public void onClick(View v) { /* Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://eaiuniroma2.files.wordpress.com/2012/03/variazioni_di_prezzo_e_variazioni_di_ricavo.pdf")); startActivity(intent); */ titolodialog=appvar.getText().toString(); id_bottone=4; showDialog(CUSTOM_DIALOG); } }); }//fine oncreate @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.sezmenu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { /*case R.id.check: { //controlla se ? aggiornato il link di tutti i file di geometria. }break; */ case R.id.quit: { finish(); TorEngineActivity.a.finish(); }break; case R.id.contatti: { showDialog(ECON_DIALOG_ID); }break; } return true; }; @Override // SWITCH DEL CREATE DELLE ALERT DIALOG protected Dialog onCreateDialog(int id) { Dialog dialog=null; switch(id) { case ECON_DIALOG_ID: { dialog=createGEOMDialog(); }break; case CUSTOM_DIALOG: { dialog=createCustomDialog(); }break; } return dialog; } private Dialog createGEOMDialog() { View view =getLayoutInflater().inflate(R.layout.econdialog, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Elisa Battistoni"); builder.setView(view); builder.setCancelable(false); builder.setNegativeButton("email", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent goToEconC=new Intent(Economia.this, EconomiaContatti.class); startActivity(goToEconC); } }); builder.setNeutralButton("Sito", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent goToSitoGeom= new Intent(Intent.ACTION_VIEW); goToSitoGeom.setData(Uri.parse("http://eaiuniroma2.wordpress.com/")); startActivity(goToSitoGeom); } }); builder.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(ECON_DIALOG_ID); removeDialog(ECON_DIALOG_ID); } }); AlertDialog alert = builder.create(); return alert; } private Dialog createCustomDialog() { View view=getLayoutInflater().inflate(R.layout.customdialog,null); AlertDialog.Builder builder2=new AlertDialog.Builder(this); builder2.setTitle(titolodialog); builder2.setView(view); builder2.setCancelable(false); switch(id_bottone) { case 1: { builder2.setMessage("domanda e offerta - elasticita' - preferenze del consumatore - curve di angel e beni di giffen - produzione nel breve e nel lungo periodo - monopolio"); builder2.setNegativeButton("Download", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW); File file= new File("/mnt/sdcard/download/economia_alessandra_somma_v1.pdf"); if(file.exists()) { if(file.delete()) { Toast.makeText(getApplicationContext(), "Il file precedente verr? sovrascritto...",Toast.LENGTH_LONG).show(); } } intent.setData(Uri.parse("http://www.torengine.it/openftp/economia/economia_alessandra_somma_v1.pdf")); startActivity(intent); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); builder2.setNeutralButton("Apri", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intentFile = new Intent(Intent.ACTION_VIEW); File file = new File("/mnt/sdcard/download/economia_alessandra_somma_v1.pdf"); Uri path = Uri.fromFile(file); if(file.exists()) { intentFile.setDataAndType(path, "application/pdf"); intentFile.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intentFile); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } else { Toast.makeText(getApplicationContext(), "file economia_alessandra_somma_v1.pdf non trovato nella cartella /mnt/sdcard/download",Toast.LENGTH_LONG).show(); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } } }); builder2.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); }break; //fine case 1 ----------------------------------------- case 2: { builder2.setMessage("tipi di mercato - monopolio - elasticita' - Analisi degli Investimenti - preferenze del consumatore - produzione"); builder2.setNegativeButton("Download", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW); File file= new File("/mnt/sdcard/download/economia_marina-ganci_v1.pdf"); if(file.exists()) { if(file.delete()) { Toast.makeText(getApplicationContext(), "Il file precedente verr? sovrascritto...",Toast.LENGTH_LONG).show(); } } intent.setData(Uri.parse("http://www.torengine.it/openftp/economia/economia_marina-ganci_v1.pdf")); startActivity(intent); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); builder2.setNeutralButton("Apri", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intentFile = new Intent(Intent.ACTION_VIEW); File file = new File("/mnt/sdcard/download/economia_marina-ganci_v1.pdf"); Uri path = Uri.fromFile(file); if(file.exists()) { intentFile.setDataAndType(path, "application/pdf"); intentFile.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intentFile); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } else { Toast.makeText(getApplicationContext(), "file economia_marina-ganci_v1.pdf non trovato nella cartella /mnt/sdcard/download",Toast.LENGTH_LONG).show(); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } } }); builder2.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); }break; //fine case 2 ------------------------------------------------- case 3: { builder2.setMessage("Domanda e Offerta - Appunti scritti dalla Prof Elisa Battistoni"); builder2.setNegativeButton("Download", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW); File file= new File("/mnt/sdcard/download/domanda_e_offerta.pdf"); if(file.exists()) { if(file.delete()) { Toast.makeText(getApplicationContext(), "Il file precedente verr? sovrascritto...",Toast.LENGTH_LONG).show(); } } intent.setData(Uri.parse("http://eaiuniroma2.files.wordpress.com/2012/03/domanda_e_offerta.pdf")); startActivity(intent); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); builder2.setNeutralButton("Apri", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intentFile = new Intent(Intent.ACTION_VIEW); File file = new File("/mnt/sdcard/download/domanda_e_offerta.pdf"); Uri path = Uri.fromFile(file); if(file.exists()) { intentFile.setDataAndType(path, "application/pdf"); intentFile.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intentFile); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } else { Toast.makeText(getApplicationContext(), "file domanda_e_offerta.pdf non trovato nella cartella /mnt/sdcard/download",Toast.LENGTH_LONG).show(); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } } }); builder2.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); }break; //fine case 3 ----------------------------------------------------- case 4: { builder2.setMessage("Variazioni di Prezzo e di Ricavo - Appunti scritti dalla Prof Elisa Battistoni"); builder2.setNegativeButton("Download", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW); File file= new File("/mnt/sdcard/download/variazioni_di_prezzo_e_variazioni_di_ricavo.pdf"); if(file.exists()) { if(file.delete()) { Toast.makeText(getApplicationContext(), "Il file precedente verr? sovrascritto...",Toast.LENGTH_LONG).show(); } } intent.setData(Uri.parse("http://eaiuniroma2.files.wordpress.com/2012/03/variazioni_di_prezzo_e_variazioni_di_ricavo.pdf")); startActivity(intent); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); builder2.setNeutralButton("Apri", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intentFile = new Intent(Intent.ACTION_VIEW); File file = new File("/mnt/sdcard/download/variazioni_di_prezzo_e_variazioni_di_ricavo.pdf"); Uri path = Uri.fromFile(file); if(file.exists()) { intentFile.setDataAndType(path, "application/pdf"); intentFile.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intentFile); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } else { Toast.makeText(getApplicationContext(), "file variazioni_di_prezzo_e_variazioni_di_ricavo.pdf non trovato nella cartella /mnt/sdcard/download",Toast.LENGTH_LONG).show(); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } } }); builder2.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); }break; } AlertDialog alert2 = builder2.create(); return alert2; } }