Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

In this page you can find the example usage for android.app AlertDialog show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.updetector.MainActivity.java

/** Make sure that Bluetooth is enabled */
public void checkBluetoothEnabled() {
    if (mBluetoothAdapter == null) {
        // Device does not support Bluetooth
        AlertDialog noBluetoothAlert = new AlertDialog.Builder(this).setTitle("Bluetooth not supported.")
                .setPositiveButton("Exit", new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int id) {
                    }/*from w w  w .ja v a2s.co  m*/
                }).setCancelable(true).create();
        noBluetoothAlert.show();
        writeToConsole(
                "This phone does not have Bluetooth capability. Bluetooth connection method will not work.");
    }
    if (!mBluetoothAdapter.isEnabled()) {
        Log.e(LOG_TAG, "bluetooth not enabled yet");
        /** Ask user to enable Bluetooth */
        AlertDialog enableBluetoothDialog = new AlertDialog.Builder(this)
                .setTitle("Please enable Bluetooth on your phone.").setCancelable(false)
                .setPositiveButton("Enable Bluetooth", new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int id) {
                        startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE),
                                Constants.SENSOR_BLUETOOTH);
                    }
                }).setNegativeButton("Skip", new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int id) {
                    }
                }).create();
        enableBluetoothDialog.show();
    } else {
        //bluetooth is enabled (directed from onActivityResult())         
        SharedPreferences mPrefs = getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE);
        String carBluetoothDeviceName = null;
        if (mPrefs.contains(Constants.BLUETOOTH_CAR_DEVICE_NAME)) {
            carBluetoothDeviceName = mPrefs.getString(Constants.BLUETOOTH_CAR_DEVICE_NAME, null);
        }
        Log.e(LOG_TAG, "bluetooth enabled " + carBluetoothDeviceName);

        if (carBluetoothDeviceName != null) {
            Intent intent = new Intent(MainActivity.this, BluetoothConnectionService.class);
            startService(intent);
        } else {//ask the user to select a car bluetooth device
            selectBluetoothDevice();
        }
    }
}

From source file:com.mobiletin.inputmethod.indic.LatinIME.java

private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;/*  w  ww  . j  av  a 2 s  .co m*/
    }

    final Window window = dialog.getWindow();
    final WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = windowToken;
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    mOptionsDialog = dialog;
    dialog.show();
}

From source file:com.redhorse.quickstart.AppAll.java

public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, final long arg3) {
    // TODO Auto-generated method stub
    //      ResolveInfo info = mApps.get(position);
    ///*from w  ww. j av  a  2  s  .  c o m*/
    //      Intent i = getIntent();
    //      Bundle b = new Bundle();
    //      b.putString("msg", "open");
    //      b.putString("packageName", info.activityInfo.packageName);
    //      b.putString("name", info.activityInfo.name);
    //      i.putExtras(b);
    //      this.setResult(RESULT_OK, i);
    //      dbStart.close();
    //      this.finish();

    // TODO Auto-generated method stub
    AlertDialog opDialog = new AlertDialog.Builder(AppAll.this).setTitle("")
            .setItems(R.array.select_dialog_items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    /* User clicked so do some stuff */
                    String[] items = getResources().getStringArray(R.array.select_dialog_items);
                    ResolveInfo info = null;
                    ResolveInfo selectedinfo = null;
                    switch (which) {
                    case ITEM_ID_DELETE:
                        selectedinfo = mApps.get(arg2);
                        String packageName = selectedinfo.activityInfo.packageName;
                        String name = selectedinfo.activityInfo.name;
                        Iterator it1 = mAllApps.iterator();
                        while (it1.hasNext()) {
                            info = (ResolveInfo) it1.next();
                            if (packageName.equals(info.activityInfo.packageName)
                                    && name.equalsIgnoreCase(info.activityInfo.name)) {
                                Intent intent = new Intent();
                                Uri packageURI = Uri.parse("package:" + packageName);
                                Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
                                startActivityForResult(uninstallIntent, STARTUNINSTALL_REQUEST);
                                break;
                            }
                        }
                        break;
                    case ITEM_ID_OPEN:
                        info = mApps.get(arg2);
                        Intent i = getIntent();
                        Bundle b = new Bundle();
                        b.putString("msg", "open");
                        b.putString("packageName", info.activityInfo.packageName);
                        b.putString("name", info.activityInfo.name);
                        i.putExtras(b);
                        AppAll.this.setResult(RESULT_OK, i);
                        dbStart.close();
                        AppAll.this.finish();
                        break;
                    }
                }
            }).create();
    opDialog.show();

}

From source file:markson.visuals.sitapp.eventActivity.java

public void download() {
    AlertDialog alertDialog = new AlertDialog.Builder(eventActivity.this).setTitle(name)
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    dialog.dismiss();/*  ww  w .j  a  v  a  2 s.c  om*/

                }
            }).setNeutralButton("Open Link", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    Log.i("Opening", link);
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
                    startActivity(intent);

                }
            }).setPositiveButton("Add to Calendar", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    Log.i("Adding", name);
                    try {
                        addtocal();
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }).setMessage(description + "\n\n" + "\n\n What would you like to do?").create();
    /*alertDialog.setTitle(name);
    alertDialog.setMessage(description + "\n\n" + "\n\n What would you like to do?")
            
    alertDialog.setButton(1,"Cancel", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int which) {
            
    dialog.dismiss();
            
       }
    });
    alertDialog.setButton(2,"Open Link", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int which) {
            
          Log.i("Opening", link);
          Intent intent = new Intent(Intent.ACTION_VIEW, Uri
                .parse(link));
          startActivity(intent);
            
       }
    });
    alertDialog.setButton(3,"Add to Calendar", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int which) {
            
          Log.i("Adding", name);
          try {
             addtocal();
          } catch (ParseException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }
            
       }
    });*/

    alertDialog.show();

}

From source file:com.df.app.procedures.CarRecogniseLayout.java

/**
 * ?/* www . jav a  2s. co m*/
 */
private void showSelectCarDialog() {
    View view = LayoutInflater.from(rootView.getContext()).inflate(R.layout.vehicle_model_select, null);

    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(R.string.select_model);

    initModelSelectEdits(view);

    AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // ?Spinner?
                    if (lastCountryIndex == 0 || lastBrandIndex == 0 || lastManufacturerIndex == 0
                            || lastSeriesIndex == 0 || lastModelIndex == 0) {
                        Toast.makeText(rootView.getContext(), "", Toast.LENGTH_SHORT)
                                .show();

                        return;
                    }

                    Country country = vehicleModel.countries.get(lastCountryIndex - 1);
                    Brand brand = country.brands.get(lastBrandIndex - 1);
                    Manufacturer manufacturer = brand.manufacturers.get(lastManufacturerIndex - 1);
                    Series series = manufacturer.serieses.get(lastSeriesIndex - 1);
                    Model model = series.models.get(lastModelIndex - 1);

                    // ?seriesIdmodelId????  config:powerWindows,powerSeats...
                    getCarSettingsFromServer(series.id + "," + model.id);
                }
            }).setNegativeButton(R.string.cancel, null).create();

    dialog.show();
}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.item1:
        //// ww  w .j av a  2  s  . c o m
        //
        //mViewPager.setCurrentItem((new PageProvider().getPageCount()-1));
        // 1. Instantiate an AlertDialog.Builder with its constructor

        String[] pages = new String[850];
        for (int i = 0; i < 850; i++) {
            pages[i] = i + 1 + "";
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(ViewPagerActivity.this);

        // 2. Chain together various setter methods to set the dialog characteristics
        builder.setTitle("Go To Page").setItems(pages, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                mViewPager.setCurrentItem(849 - which);

                // The 'which' argument contains the index position
                // of the selected item
            }
        });

        // 3. Get the AlertDialog from create()
        AlertDialog dialog = builder.create();
        dialog.show();
        return true;
    case R.id.item2:
        //
        //
        //mViewPager.setCurrentItem((new PageProvider().getPageCount()-1));
        // 1. Instantiate an AlertDialog.Builder with its constructor
        AlertDialog.Builder builder2 = new AlertDialog.Builder(ViewPagerActivity.this);

        String[] juz = getResources().getStringArray(R.array.juz);

        // 2. Chain together various setter methods to set the dialog characteristics
        builder2.setTitle("Go To Juz (Parah)").setItems(juz, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (which == 0) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 1);

                }
                if (which == 1) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 31);

                }
                if (which == 2) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 59);

                }
                if (which == 3) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 87);

                }
                if (which == 4) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 115);

                }
                if (which == 5) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 143);

                }
                if (which == 6) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 171);

                }
                if (which == 7) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 199);

                }
                if (which == 8) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 227);

                }
                if (which == 9) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 255);

                }
                if (which == 10) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 283);

                }
                if (which == 11) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 311);

                }
                if (which == 12) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 339);

                }
                if (which == 13) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 367);

                }
                if (which == 14) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 395);

                }
                if (which == 15) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 423);

                }
                if (which == 16) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 451);

                }
                if (which == 17) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 479);

                }
                if (which == 18) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 507);

                }
                if (which == 19) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 535);

                }
                if (which == 20) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 561);

                }
                if (which == 21) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 589);

                }
                if (which == 22) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 615);

                }
                if (which == 23) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 643);

                }
                if (which == 24) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 669);

                }
                if (which == 25) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 699);

                }
                if (which == 26) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 729);

                }
                if (which == 27) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 759);

                }
                if (which == 28) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 789);

                }
                if (which == 29) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 821);

                }

                // The 'which' argument contains the index position
                // of the selected item
            }
        });

        // 3. Get the AlertDialog from create()
        AlertDialog dialog2 = builder2.create();
        dialog2.show();
        return true;
    case R.id.item3:
        //
        //
        //mViewPager.setCurrentItem((new PageProvider().getPageCount()-1));
        // 1. Instantiate an AlertDialog.Builder with its constructor
        AlertDialog.Builder builder3 = new AlertDialog.Builder(ViewPagerActivity.this);

        String[] surah = getResources().getStringArray(R.array.surah);

        // 2. Chain together various setter methods to set the dialog characteristics
        builder3.setTitle("Go To Surah").setItems(surah, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (which == 0) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(620 - 4);
                }
                if (which == 1) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(620 - 5);
                }
                if (which == 2) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 70);
                }
                if (which == 3) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 108);
                }
                if (which == 4) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 149);
                }
                if (which == 5) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 179);
                }
                if (which == 6) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 211);
                }
                if (which == 7) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 247);
                }
                if (which == 8) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 262);
                }
                if (which == 9) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 290);
                }
                if (which == 10) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 310);
                }
                if (which == 11) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 330);
                }
                if (which == 12) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 348);
                }
                if (which == 13) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 357);
                }
                if (which == 14) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 366);
                }
                if (which == 15) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 374);
                }
                if (which == 16) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 390);
                }
                if (which == 17) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 410);
                }
                if (which == 18) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 427);
                }
                if (which == 19) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 437);
                }
                if (which == 20) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 451);
                }
                if (which == 21) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 464);
                }
                if (which == 22) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 479);
                }
                if (which == 23) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 489);
                }
                if (which == 24) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 503);
                }
                if (which == 25) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 513);
                }
                if (which == 26) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 527);
                }
                if (which == 27) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 539);
                }
                if (which == 28) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 554);
                }
                if (which == 29) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 564);
                }
                if (which == 30) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 573);
                }
                if (which == 31) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 579);
                }
                if (which == 32) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 583);
                }
                if (which == 33) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 597);
                }
                if (which == 34) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 605);
                }
                if (which == 35) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 613);
                }
                if (which == 36) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 620);
                }
                if (which == 37) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 630);
                }
                if (which == 38) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 637);
                }
                if (which == 39) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 649);
                }
                if (which == 40) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 661);
                }
                if (which == 41) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 670);
                }
                if (which == 42) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 679);
                }
                if (which == 43) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 688);
                }
                if (which == 44) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 693);
                }
                if (which == 45) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 699);
                }
                if (which == 46) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 706);
                }
                if (which == 47) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 712);
                }
                if (which == 48) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 718);
                }
                if (which == 49) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 723);
                }
                if (which == 50) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 728);
                }
                if (which == 51) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 731);
                }
                if (which == 52) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 734);
                }
                if (which == 53) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 738);
                }
                if (which == 54) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 742);
                }
                if (which == 55) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 747);
                }
                if (which == 56) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 752);
                }
                if (which == 57) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 759);
                }
                if (which == 58) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 763);
                }
                if (which == 59) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 768);
                }
                if (which == 60) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 772);
                }
                if (which == 61) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 775);
                }
                if (which == 62) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 777);
                }
                if (which == 63) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 779);
                }
                if (which == 64) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 782);
                }
                if (which == 65) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 785);
                }
                if (which == 66) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 789);
                }
                if (which == 67) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 792);
                }
                if (which == 68) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 796);
                }
                if (which == 69) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 799);
                }
                if (which == 70) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 802);
                }
                if (which == 71) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 805);
                }
                if (which == 72) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 808);
                }
                if (which == 73) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 810);
                }
                if (which == 74) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 813);
                }
                if (which == 75) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 815);
                }
                if (which == 76) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 818);
                }
                if (which == 77) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 821);
                }
                if (which == 78) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 822);
                }
                if (which == 79) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 824);
                }
                if (which == 80) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 826);
                }
                if (which == 81) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 827);
                }
                if (which == 82) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 828);
                }
                if (which == 83) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 830);
                }
                if (which == 84) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 831);
                }
                if (which == 85) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 832);
                }
                if (which == 86) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 833);
                }
                if (which == 87) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 834);
                }
                if (which == 88) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 835);
                }
                if (which == 89) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 837);
                }
                if (which == 90) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 838);
                }
                if (which == 91) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 839);
                }
                if (which == 92) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 840);
                }
                if (which == 93) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 840);
                }
                if (which == 94) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 841);
                }
                if (which == 95) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 841);
                }
                if (which == 96) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 842);
                }
                if (which == 97) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 842);
                }
                if (which == 98) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 843);
                }
                if (which == 99) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 844);
                }
                if (which == 100) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 845);
                }
                if (which == 101) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 845);
                }
                if (which == 102) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 846);
                }
                if (which == 103) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 846);
                }
                if (which == 104) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 846);
                }
                if (which == 105) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 847);
                }
                if (which == 106) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 847);
                }
                if (which == 107) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 848);
                }
                if (which == 108) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 848);
                }
                if (which == 109) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 848);
                }
                if (which == 110) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 849);
                }
                if (which == 111) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 849);
                }
                if (which == 112) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 849);
                }
                if (which == 113) {
                    dialog.dismiss();

                    mViewPager.setCurrentItem(850 - 850);
                }

                // The 'which' argument contains the index position
                // of the selected item
            }
        });

        // 3. Get the AlertDialog from create()
        AlertDialog dialog3 = builder3.create();
        dialog3.show();
        return true;
    case R.id.item4:
        Builder builderr = new Builder(this);
        Date cDate = new Date();
        final String fDate = new SimpleDateFormat("MM/dd/yy").format(cDate);
        Date dt = new Date();
        int hours = dt.getHours();
        int minutes = dt.getMinutes();

        SimpleDateFormat sdf = new SimpleDateFormat("hh:mmaa");
        String time1 = sdf.format(dt);

        final EditText input = new EditText(this);
        InputFilter[] FilterArray = new InputFilter[1];
        FilterArray[0] = new InputFilter.LengthFilter(18);
        input.setFilters(FilterArray);

        input.setText(fDate + " " + time1.toLowerCase());
        builderr.setTitle("Bookmark").setMessage("Name your Bookmark").setView(input)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {

                        if (!input.getText().toString().equals(""))
                            saveState(input.getText().toString());
                        else
                            saveState(fDate);
                        setResult(RESULT_OK);
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                    }

                });

        builderr.show();

        return true;
    case R.id.item5:
        Intent i = new Intent(ViewPagerActivity.this, Notepadv3.class);

        startActivity(i);
        return true;
    case R.id.item6:
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Qazi+Musab")));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/developer?id=Qazi+Musab")));
        }
        return true;
    case R.id.item7:
        String appName2 = "com.qaziconsultancy.13linequran";
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName2)));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + appName2)));
        }
        return true;
    case R.id.item8:
        mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1);
        return true;
    case R.id.item9:
        mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
        return true;
    case R.id.item10:
        String[] items = new String[9];
        items[0] = "$1";
        items[1] = "$2";
        items[2] = "$3";
        items[3] = "$4";
        items[4] = "$5";
        items[5] = "$10";
        items[6] = "$20";
        items[7] = "$50";
        items[8] = "$100";

        AlertDialog.Builder chooser = new AlertDialog.Builder(ViewPagerActivity.this);
        chooser.setTitle("Contribute").setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                case 0:
                    contributeOneDollar();
                    break;
                case 1:
                    contributetwoDollars();
                    break;
                case 2:
                    contributeThreeDollars();
                    break;
                case 3:
                    contributeFourDollars();
                    break;
                case 4:
                    contributeFiveDollars();
                    break;
                case 5:
                    contributeTenDollars();
                    break;
                case 6:
                    contributeTwentyDollars();
                    break;
                case 7:
                    contributeFiftyDollars();
                    break;
                case 8:
                    contributeHundredDollars();
                    break;

                }
            }
        });

        // 3. Get the AlertDialog from create()
        AlertDialog myChooser = chooser.create();
        myChooser.show();
        return true;
    default:
        return true;
    }
}

From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java

private void checkVinAndGetCarSettings() {
    final String vinString = vin_edit.getText().toString();

    // ?/*from  w w w .jav a2s. c o m*/
    if (vinString.equals("")) {
        Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show();
        vin_edit.requestFocus();
        return;
    }

    // VIN?
    if (!Helper.isVin(vinString)) {
        AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setTitle(R.string.alert_title)
                .setMessage("VIN?: " + vinString + "\n"
                        + "VIN?????\n")
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        brandEdit.setText("");
                        brandOkButton.setEnabled(false);
                        brandSelectButton.setEnabled(false);

                        // ???VIN
                        getCarSettingsFromServer("");
                    }
                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        vin_edit.requestFocus();
                    }
                }).create();

        dialog.show();
        return;
    }

    brandEdit.setText("");
    brandOkButton.setEnabled(false);
    brandSelectButton.setEnabled(false);

    // ???VIN
    getCarSettingsFromServer("");
}

From source file:com.hybris.mobile.app.commerce.adapter.AccountPaymentAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    View rowView;/*  w ww.  j a v a 2  s  . c  om*/

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_payment_details, parent, false);
        rowView.setTag(new PaymentViewHolder(rowView, position));
    } else {
        rowView = convertView;
    }

    PaymentViewHolder mPaymentViewHolder = (PaymentViewHolder) rowView.getTag();

    final PaymentDetails paymentDetails = getItem(position);

    if (paymentDetails != null) {

        mPaymentViewHolder.paymentCardholderName.setText(paymentDetails.getAccountHolderName());
        mPaymentViewHolder.cardDetails
                .setText(paymentDetails.getCardType().getName() + "\n" + paymentDetails.getCardNumber() + "\n"
                        + paymentDetails.getExpiryMonth() + "/" + paymentDetails.getExpiryYear());

        if (paymentDetails.getBillingAddress() != null) {

            mPaymentViewHolder.billingAddress
                    .setText(StringUtils.isNotBlank(paymentDetails.getBillingAddress().getFormattedAddress())
                            ? paymentDetails.getBillingAddress().getFormattedAddress()
                            : paymentDetails.getBillingAddress().getLine1() + " "
                                    + paymentDetails.getBillingAddress().getLine2() + ",\n "
                                    + paymentDetails.getBillingAddress().getTown() + " "
                                    + paymentDetails.getBillingAddress().getPostalCode());
        }

        mPaymentViewHolder.paymentDefaultImageView.setVisibility(View.GONE);
        mPaymentViewHolder.paymentSetDefaultButton.setVisibility(View.INVISIBLE);

        mPaymentViewHolder.paymentDefaultImageView.setVisibility(position == 0 ? View.VISIBLE : View.INVISIBLE);
        //mPaymentViewHolder.paymentSetDefaultButton.setVisibility(position == 0 ? View.INVISIBLE : View.VISIBLE);
        mPaymentViewHolder.paymentDeleteButton.setVisibility(View.VISIBLE);

        mPaymentViewHolder.paymentSetDefaultButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                setDefaultPayment(paymentDetails);
                Alert.showSuccess(getContext(),
                        getContext().getString(R.string.payment_default_updated_message));

            }
        });

        mPaymentViewHolder.paymentDetailsLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mOnPaymentSelectedListener.onPaymentSelected(paymentDetails);
            }
        });
    }

    mPaymentViewHolder.paymentDeleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog;
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setMessage(R.string.payment_delete_message)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                            QueryPayment queryPayment = new QueryPayment();
                            queryPayment.setPaymentDetailsId(paymentDetails.getId());

                            CommerceApplication.getContentServiceHelper()
                                    .deleteUserPaymentDetails(new ResponseReceiverEmpty() {
                                        @Override
                                        public void onResponse(Response<EmptyResponse> response) {

                                            Alert.showSuccess(getContext(), getContext()
                                                    .getString(R.string.payment_delete_success_message));

                                            if (position < mPaymentList.size()) {
                                                mPaymentList.remove(position);
                                            }
                                            mOnPaymentSelectedListener.onPaymentListRefreshed();

                                            //Default is the first but if deleted select the next one as default
                                            if (mPaymentList != null && !mPaymentList.isEmpty()
                                                    && position == 0) {
                                                setDefaultPayment(mPaymentList.get(0));
                                            }
                                        }

                                        @Override
                                        public void onError(Response<ErrorList> response) {

                                        }
                                    }, null, queryPayment, null, false, null, null);

                            dialog.dismiss();

                        }
                    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });

            dialog = builder.create();
            dialog.show();
        }
    });

    return rowView;
}

From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = this;

    isTablet = Utils.isTablet(this);

    // Setting the default network
    sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE);
    Editor editor = sharedPreferences.edit();
    editor.putString(Constants.NETWORK, Constants.DEFAULT_NETWORK);
    editor.commit();/*from  w w w  .  j  a v  a  2s . co m*/

    // Starting the resources monitoring service
    startService(new Intent(this, DeviceMonitorService.class));

    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    // Settings menu elements
    ArrayList<MenuListElement> listElements = new ArrayList<MenuListElement>();

    listElements.add(new MenuListElement(getResources().getString(R.string.connectMenuTitle),
            getResources().getString(R.string.connectMenuSubTitle)));
    listElements.add(new MenuListElement(getResources().getString(R.string.settingsMenuTitle),
            getResources().getString(R.string.settingsMenuSubTitle)));
    listElements.add(new MenuListElement(getResources().getString(R.string.exitMenuTitle),
            getResources().getString(R.string.exitMenuSubTitle)));

    listView = (ListView) findViewById(R.id.ListViewContent);

    MenuListAdapter adapter = new MenuListAdapter(this, R.layout.menu_list_view_row, listElements);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new ListItemClickListener());

    mainRL = (RelativeLayout) findViewById(R.id.rlContainer);
    listRL = (RelativeLayout) findViewById(R.id.listContainer);

    cpuBar = (LinearLayout) findViewById(R.id.CpuBar);
    memoryBar = (LinearLayout) findViewById(R.id.MemoryBar);

    titleBarRL = (RelativeLayout) findViewById(R.id.titleLl);

    // Adding swipe gesture listener to the top bar
    titleBarRL.setOnTouchListener(new SwipeAndClickListener());

    menuButton = (Button) findViewById(R.id.menuButton);
    menuButton.setOnTouchListener(new SwipeAndClickListener());

    infoButton = (Button) findViewById(R.id.infoButton);
    infoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlertDialog dialog = new AlertDialog(NAM4JAndroidActivity.this) {

                @Override
                public boolean dispatchTouchEvent(MotionEvent event) {
                    dismiss();
                    return false;
                }

            };

            String text = getResources().getString(R.string.aboutApp);
            String title = getResources().getString(R.string.nam4j);

            dialog.setMessage(text);
            dialog.setTitle(title);
            dialog.setCanceledOnTouchOutside(true);
            dialog.show();
        }
    });

    centerButton = (Button) findViewById(R.id.centerButton);
    centerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            centerMap();
        }
    });

    isTablet = Utils.isTablet(context);

    int[] screenSize = Utils.getScreenSize(context, getWindow());
    screenWidth = screenSize[0];
    screenHeight = screenSize[1];

    // Updates the display orientation each time the device is rotated
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        screenOrientation = Orientation.LANDSCAPE;
    } else {
        screenOrientation = Orientation.PORTRAIT;
    }

    // If the device is portrait, the menu button is displayed, the menu is
    // hidden and the swipe listener is added to the menu bar
    if (screenOrientation == Orientation.PORTRAIT) {

        menuButton.setVisibility(View.VISIBLE);

        // Adding swipe gesture listener to the top bar
        titleBarRL.setOnTouchListener(new SwipeAndClickListener());

        if (isTablet) {
            menuWidth = 0.35;
        } else {
            menuWidth = 0.6;
        }
    } else {
        // If the device is a tablet in landscape, the menu button is
        // hidden, the menu is displayed, the swipe listener is not added to
        // the menu bar and the mainRL width is set to the window's width
        // minus the menu's width
        if (isTablet) {
            menuWidth = 0.2;
            menuButton.setVisibility(View.INVISIBLE);

            RelativeLayout.LayoutParams menuListLP = (LayoutParams) mainRL.getLayoutParams();

            // Setting the main view width as the container width without
            // the menu
            menuListLP.width = (int) (screenWidth * (1 - menuWidth));
            mainRL.setLayoutParams(menuListLP);

            displaySideMenu();
        } else {
            menuWidth = 0.4;
            menuButton.setVisibility(View.VISIBLE);

            // Adding swipe gesture listener to the top bar
            titleBarRL.setOnTouchListener(new SwipeAndClickListener());
        }
    }

    // Check if the device has the Google Play Services installed and
    // updated. They are necessary to use Google Maps
    int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);

    if (code != ConnectionResult.SUCCESS) {

        showErrorDialog(code);

        System.out.println("Google Play Services error");

        FrameLayout fl = (FrameLayout) findViewById(R.id.frameId);
        fl.removeAllViews();
    } else {
        // Create a new global location parameters object
        mLocationRequest = new LocationRequest();

        // Set the update interval
        mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);

        // Use high accuracy
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        // Set the interval ceiling to one minute
        mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);

        bitmapDescriptorBlue = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);

        blueCircle = BitmapDescriptorFactory
                .fromBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.blue_circle));

        bitmapDescriptorRed = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED);

        // Create a new location client, using the enclosing class to handle
        // callbacks
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(LocationServices.API).build();

        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapview)).getMap();

        if (map != null) {

            // Set default map center and zoom on Parma
            double lat = 44.7950156;
            double lgt = 10.32547;
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lgt), 12.0f));

            // Adding listeners to the map respectively for zoom level
            // change and onTap event
            map.setOnCameraChangeListener(getCameraChangeListener());
            map.setOnMapClickListener(getOnMapClickListener());

            // Set map type as normal (i.e. not the satellite view)
            map.setMapType(com.google.android.gms.maps.GoogleMap.MAP_TYPE_NORMAL);

            // Hide traffic layer
            map.setTrafficEnabled(false);

            // Enable the 'my-location' layer, which continuously draws an
            // indication of a user's current location and bearing, and
            // displays UI controls that allow the interaction with the
            // location itself
            // map.setMyLocationEnabled(true);

            ml = new HashMap<String, Marker>();

            // Get file manager for config files
            fileManager = FileManager.getFileManager();
            fileManager.createFiles();

            map.setOnMarkerClickListener(this);

        } else {
            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.setMessage("The map cannot be initialized.");
            dialog.setCancelable(true);
            dialog.setPositiveButton(getResources().getString(R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    });
            dialog.show();
        }
    }
}

From source file:com.zen.androidhtmleditor.AHEActivity.java

@SuppressLint("NewApi")
@Override//from  w  ww.  j a  v  a2  s  .  co  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    setContentView(R.layout.main);
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#4acab4"));

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    Settings.init(settings);
    //Uncomment this for non Market installs. This will allow version checking.
    //new Version(this,getVersionName(this,DeveloperToolsActivity.class),"http://androidhtmleditor.com/version.php").execute();
    deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
    getOverflowMenu();
    getActionBar().setIcon(R.drawable.icon_white);

    tabactivity = (TabActivity) this;
    tabHost = tabactivity.getTabHost();
    hsv = (HorizontalScrollView) tabactivity.findViewById(R.id.topmenu);

    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    mChecker = new LicenseChecker(this,
            new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY // Your public licensing key.
    );

    mHandler = new Handler();
    // doCheck();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (LinearLayout) findViewById(R.id.l1);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle("File(s)");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle("Server");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    Button button1 = (Button) findViewById(R.id.button1);

    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onButtonClickEvent(v);
        }
    });
    Button disconnect_button = (Button) findViewById(R.id.disconnect_button);

    disconnect_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            disconnect();
        }
    });

    /* Button button2 = (Button)findViewById(R.id.button2);
     button2.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
               
       hsv.setVisibility(View.GONE);
       v.setVisibility(View.GONE);
       RelativeLayout rl = (RelativeLayout)v.getParent();
       Button button1 = (Button)findViewById(R.id.button1);
       button1.setVisibility(View.VISIBLE);
       Button button3 = (Button)findViewById(R.id.button3);
       button3.setVisibility(View.VISIBLE);
               
       ImageView logo = (ImageView)findViewById(R.id.logo);
       logo.setVisibility(View.VISIBLE);
               
       TextView slogan = (TextView)findViewById(R.id.appSlogan);
       slogan.setVisibility(View.VISIBLE);
               
       ScrollView frontLayout = (ScrollView)findViewById(R.id.front);
       frontLayout.setVisibility(View.VISIBLE);
               
       TextView appTitle = (TextView)findViewById(R.id.appTitle);
       appTitle.setVisibility(View.VISIBLE);
               
       Button backButton = (Button)rl.findViewById(R.id.backButton);
       backButton.setVisibility(View.GONE);
       arrayAdapter.clear();
       arrayAdapter.notifyDataSetChanged();
       TextView pathInfo = (TextView)rl.findViewById(R.id.path);
        pathInfo.setText("");
        folderPath = "";
       //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute();
        connectedTo = -1;
                
                
                
                
        Toast.makeText(AHEActivity.this, "Disconnected", Toast.LENGTH_SHORT).show();
    }
     });*/

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent SettingsIntent = new Intent(AHEActivity.this, Settings.class);
            startActivity(SettingsIntent);
        }
    });

    /*Button backButton = (Button)findViewById(R.id.backButton);
    backButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       String[] pathBits = folderPath.split("/");
       folderPath = "";
       for(int i=0;i<pathBits.length-1;i++){
          folderPath += pathBits[i]+"/";
       }
       arrayAdapter.clear();
               
       //connectedTo
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        String currentServers = settings.getString("Accounts", "");
        if(currentServers.equals("")){}else{
       Gson gson = new Gson();
        SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
        List<Result> results = response.data;
        Result l = results.get(connectedTo);
                
       if(l.serverName!="" && l.userName!="" && l.port.trim()!=""){
               
          if(l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")){
             new MyFetchTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }else if(l.sftp.equals("3")){
             new FetchSSLTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }
               
       }
                
        }
    }
    });*/

    TextView pathInfo = (TextView) findViewById(R.id.path);
    pathInfo.setText(folderPath);

    lstTest = (ListView) findViewById(R.id.list);
    // lstTest.setDividerHeight(10);
    lstTest.setPadding(0, 5, 0, 5);
    alrts = new ArrayList<String[]>();
    arrayAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, alrts);
    lstTest.setAdapter(arrayAdapter);

    lstTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final View d = v;
            final CharSequence[] items = { "Delete", "Rename", "Chmod", "Download" };

            TextView t = (TextView) v.findViewById(R.id.fileFolderName);
            final String oldName = t.getText().toString();

            final int position = pos;

            AlertDialog.Builder builder = new AlertDialog.Builder(AHEActivity.this);
            builder.setTitle("Choose Action");
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {

                    if (item == 0) {
                        AlertDialog.Builder dbuilder = new AlertDialog.Builder(AHEActivity.this);
                        dbuilder.setMessage("Delete this file?").setCancelable(false)
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                        deleteFile(d);
                                        dialog.cancel();
                                    }
                                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();

                                    }
                                });
                        AlertDialog dalert = dbuilder.create();
                        dalert.show();

                    } else if (item == 1) {

                        final Dialog renameDialog = new Dialog(AHEActivity.this);
                        renameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        renameDialog.setContentView(R.layout.renamediag);

                        renameDialog.setCancelable(true);

                        Button closeServer = (Button) renameDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                renameDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) renameDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) renameDialog.findViewById(R.id.themeLink);
                                String newName = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        new RenameTask(l.serverName, l.userName, l.passWord, oldName, newName,
                                                folderPath, l.sftp, l.port, position).execute();

                                        renameDialog.cancel();
                                    }
                                }
                            }
                        });
                        renameDialog.show();
                    } else if (item == 2) {

                        final Dialog chmodDialog = new Dialog(AHEActivity.this);
                        chmodDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        chmodDialog.setContentView(R.layout.chmoddiag);

                        chmodDialog.setCancelable(true);

                        Button closeServer = (Button) chmodDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                chmodDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) chmodDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) chmodDialog.findViewById(R.id.themeLink);
                                String perms = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                            new ChmodTask(l.serverName, l.userName, l.passWord, oldName, perms,
                                                    folderPath, l.sftp, l.port, position).execute();
                                        } else {
                                            Toast.makeText(AHEActivity.this,
                                                    "CHMOD could not be performed on your server via sftp",
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                        chmodDialog.cancel();
                                    }
                                }
                            }
                        });
                        chmodDialog.show();

                    } else if (item == 3) {

                        //Make new class to download a file
                        SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
                        String currentServers = settings.getString("Accounts", "");
                        if (currentServers.equals("")) {
                        } else {
                            Gson gson = new Gson();
                            SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
                            List<Result> results = response.data;
                            Result l = results.get(connectedTo);

                            if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                    new DlTask(l.serverName, l.userName, l.passWord, oldName, l.sftp, l.port)
                                            .execute();

                                }
                            }
                        }
                    }

                    //Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();

                }
            });
            AlertDialog alert = builder.create();
            alert.show();
            return true;

        }
    });

    lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {

            loadFileFolder(v);

        }
    });

}