Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

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

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:com.aniruddhc.acemusic.player.Dialogs.ID3sSongEditorDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mContext = getActivity();// w  ww.j a  v a2s .  c  o m
    parentActivity = getActivity();
    dialogFragment = this;

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_edit_id3_artist_album_dialog,
            null);

    titleText = (TextView) rootView.findViewById(R.id.edit_title_text);
    artistText = (TextView) rootView.findViewById(R.id.edit_artist_text);
    albumText = (TextView) rootView.findViewById(R.id.edit_album_text);
    albumArtistText = (TextView) rootView.findViewById(R.id.edit_album_artist_text);
    genreText = (TextView) rootView.findViewById(R.id.edit_genre_text);
    producerText = (TextView) rootView.findViewById(R.id.edit_producer_text);
    yearText = (TextView) rootView.findViewById(R.id.edit_year_text);
    trackText = (TextView) rootView.findViewById(R.id.edit_track_text);
    ofText = (TextView) rootView.findViewById(R.id.text_of);
    commentsText = (TextView) rootView.findViewById(R.id.edit_comment_text);

    titleEditText = (EditText) rootView.findViewById(R.id.edit_title_field);
    artistEditText = (EditText) rootView.findViewById(R.id.edit_artist_field);
    albumEditText = (EditText) rootView.findViewById(R.id.edit_album_field);
    albumArtistEditText = (EditText) rootView.findViewById(R.id.edit_album_artist_field);
    genreEditText = (EditText) rootView.findViewById(R.id.edit_genre_field);
    producerEditText = (EditText) rootView.findViewById(R.id.edit_producer_field);
    yearEditText = (EditText) rootView.findViewById(R.id.edit_year_field);
    trackEditText = (EditText) rootView.findViewById(R.id.edit_track_field);
    trackTotalEditText = (EditText) rootView.findViewById(R.id.edit_track_total_field);
    commentsEditText = (EditText) rootView.findViewById(R.id.edit_comment_field);

    titleCheckbox = (CheckBox) rootView.findViewById(R.id.title_checkbox);
    artistCheckbox = (CheckBox) rootView.findViewById(R.id.artist_checkbox);
    albumCheckbox = (CheckBox) rootView.findViewById(R.id.album_checkbox);
    albumArtistCheckbox = (CheckBox) rootView.findViewById(R.id.album_artist_checkbox);
    genreCheckbox = (CheckBox) rootView.findViewById(R.id.genre_checkbox);
    producerCheckbox = (CheckBox) rootView.findViewById(R.id.producer_checkbox);
    yearCheckbox = (CheckBox) rootView.findViewById(R.id.year_checkbox);
    trackCheckbox = (CheckBox) rootView.findViewById(R.id.track_checkbox);
    commentCheckbox = (CheckBox) rootView.findViewById(R.id.comment_checkbox);

    titleText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    ofText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    artistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumArtistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    genreText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    producerText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    yearText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    trackText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    ofText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    commentsText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);

    titleEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackTotalEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    artistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumArtistEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    genreEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    producerEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    yearEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackTotalEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    commentsEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Keep all the fields locked by default.
    titleCheckbox.setChecked(false);
    artistCheckbox.setChecked(false);
    albumCheckbox.setChecked(false);
    albumArtistCheckbox.setChecked(false);
    genreCheckbox.setChecked(false);
    producerCheckbox.setChecked(false);
    yearCheckbox.setChecked(false);
    trackCheckbox.setChecked(false);
    commentCheckbox.setChecked(false);

    //Disable all EditTexts by default.
    titleEditText.setEnabled(false);
    artistEditText.setEnabled(false);
    albumEditText.setEnabled(false);
    albumArtistEditText.setEnabled(false);
    genreEditText.setEnabled(false);
    producerEditText.setEnabled(false);
    yearEditText.setEnabled(false);
    trackEditText.setEnabled(false);
    commentsEditText.setEnabled(false);

    //Register click registers on each checkbox.
    titleCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                titleEdited = true;
                titleEditText.setEnabled(true);
            } else {
                titleEdited = false;
                titleEditText.setEnabled(false);
            }

        }

    });

    artistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                artistEdited = true;
                artistEditText.setEnabled(true);
                ;
            } else {
                artistEdited = false;
                artistEditText.setEnabled(false);
            }

        }

    });

    albumArtistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumEdited = true;
                albumEditText.setEnabled(true);
                ;
            } else {
                albumEdited = false;
                albumEditText.setEnabled(false);
            }

        }

    });

    albumCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumArtistEdited = true;
                albumArtistEditText.setEnabled(true);
                ;
            } else {
                albumArtistEdited = false;
                albumArtistEditText.setEnabled(false);
            }

        }

    });

    genreCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                genreEdited = true;
                genreEditText.setEnabled(true);
                ;
            } else {
                genreEdited = false;
                genreEditText.setEnabled(false);
            }

        }

    });

    producerCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                producerEdited = true;
                producerEditText.setEnabled(true);
                ;
            } else {
                producerEdited = false;
                producerEditText.setEnabled(false);
            }

        }

    });

    yearCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                yearEdited = true;
                yearEditText.setEnabled(true);
                ;
            } else {
                yearEdited = false;
                yearEditText.setEnabled(false);
            }

        }

    });

    trackCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                trackEdited = true;
                trackEditText.setEnabled(true);
                ;
            } else {
                trackEdited = false;
                trackEditText.setEnabled(false);
            }

        }

    });

    commentCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                commentEdited = true;
                commentsEditText.setEnabled(true);
                ;
            } else {
                commentEdited = false;
                commentsEditText.setEnabled(false);
            }

        }

    });

    //Get the song uri.
    SONG_URI = getArguments().getString("SONG");

    //Get the calling Fragment and retrieve the child view from it.
    CALLING_FRAGMENT = getArguments().getString("CALLING_FRAGMENT");

    if (SONG_URI != null) {

        //Populate the ArrayLists with the song tags.
        try {
            getSongTags(SONG_URI);
        } catch (CannotReadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (TagException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ReadOnlyFileException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidAudioFrameException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.edit_tags);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.save, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            boolean saveSucceeded = saveSongTags(SONG_URI);

            //Check if the write operations succeeded. If they didn't, display an error message.
            if (saveSucceeded == true) {
                Toast.makeText(getActivity().getApplicationContext(), R.string.song_tags_saved,
                        Toast.LENGTH_SHORT).show();

                /*               //Reinitialize the calling fragment.
                               if (CALLING_FRAGMENT.equals("SONGS_FRAGMENT")) {
                        
                        
                               } else if (CALLING_FRAGMENT.equals("ARTISTS_FLIPPED_SONGS_FRAGMENT")) {
                                  //ArtistsFlippedSongsFragment.getCursor();
                                  ArtistsFlippedSongsFragment.songsListViewAdapter.notifyDataSetChanged();
                               } else if (CALLING_FRAGMENT.equals("ALBUMS_FLIPPED_FRAGMENT")) {
                                  AlbumsFlippedFragment.getCursor();
                                  AlbumsFlippedFragment.albumsFlippedListViewAdapter.notifyDataSetChanged();
                               } else if (CALLING_FRAGMENT.equals("ALBUM_ARTISTS_FLIPPED_SONGS_FRAGMENT")) {
                                  AlbumArtistsFlippedSongsFragment.getCursor();
                                  AlbumArtistsFlippedSongsFragment.songsListViewAdapter.notifyDataSetChanged();
                               } else if (CALLING_FRAGMENT.equals("GENRES_FLIPPED_SONGS_FRAGMENT")) {
                                  GenresFlippedFragment.getCursor();
                                  GenresFlippedFragment.genresFlippedListViewAdapter.notifyDataSetChanged();
                               }*/

            } else {
                Toast.makeText(parentActivity, R.string.error_occurred_tags, Toast.LENGTH_LONG).show();
            }

        }

    });

    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

        }

    });

    return builder.create();

}

From source file:com.abc.driver.TruckActivity.java

public void chooseTruckLength(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    GridView gridView1 = new GridView(this);
    gridView1.setNumColumns(3);/*  w  ww  .ja  v a 2 s  .  com*/
    // (GridView)findViewById(R.id.gridView1);
    SimpleAdapter adapter = new SimpleAdapter(this, mTruckLengthList, R.layout.truck_length_griditem,
            new String[] { "TITLE", "TLENGTH" }, new int[] { R.id.griditem_title, R.id.griditem_length, });

    gridView1.setAdapter(adapter);
    builder.setTitle("Please Choose");
    builder.setInverseBackgroundForced(true);
    builder.setView(gridView1);
    final Dialog dialog = builder.create();

    gridView1.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            mTLtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText());
            mTruckLength = ((TextView) view.findViewById(R.id.griditem_length)).getText().toString();
            mUpdateTruckTask = new UpdateTruckTask();
            mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(),
                    "" + app.getUser().getMyTruck().getTypeId(), mTruckLength,
                    "" + app.getUser().getMyTruck().getWeightId(),
                    "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId());

            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.timemachine.controller.ControllerActivity.java

private void createConnectDialog() {
    // Load saved IP address
    String serverIP = prefs.getString("serverIP", "");
    // Instantiate an AlertDialog.Builder with its constructor
    AlertDialog.Builder connectDialogBuilder = new AlertDialog.Builder(ControllerActivity.this);
    // Get the layout inflater
    LayoutInflater inflater = ControllerActivity.this.getLayoutInflater();
    // Inflate the custom view
    final View connectDialogLayout = inflater.inflate(R.layout.connect_dialog, null);
    // Get the text box
    final EditText ipTextbox = (EditText) connectDialogLayout.findViewById(R.id.ipAddress);
    // Restore previous IP
    ipTextbox.setText(serverIP);/*  w w w  .  j  a  v a 2s . c om*/
    // Set layout and title
    connectDialogBuilder.setView(connectDialogLayout);
    connectDialogBuilder.setTitle(connectDialogTitle);
    // Prevent the dialog from canceling when users click outside the dialog
    connectDialogBuilder.setCancelable(false);
    // Add actionButtons
    connectDialogBuilder.setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            showProcessDialog("Connecting to server...");
            // Get the text written in IP address section
            ipText = ipTextbox.getText().toString();
            // Save IP address
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("serverIP", ipText);
            editor.commit();
            // Connect Websocket
            setupSocketConnection(ipText);
        }
    });
    buildDisconnectDialog();
    // Create the AlertDialog
    connectDialog = connectDialogBuilder.create();
    connectDialog.setOwnerActivity(ControllerActivity.this);
    connectDialog.show();
}

From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java

/**
 * Function that is called when you press the add tag
 * /*from   w  w w.j a v  a2s  .  c o m*/
 * Creates a alert dialog that gives the user the option 
 * of adding a previously added tag or entering a new tag name
 * 
 * @param view
 */
public void addTagButton(View view) {
    final EditText enterTag = new EditText(this);
    final Spinner tagSpinner = new Spinner(this);
    //Linear layout that holds enterTag and tagSpinner views
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    tagSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View arg1, int position, long id) {
            enterTag.setText(parent.getItemAtPosition(position).toString());
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub      
        }
    });

    enterTag.setHint("Enter tag");
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    //get all the tags currently added to claims in application claimlist
    ArrayList<Tag> tags = ClaimListController.getTagList();
    String t[] = new String[tags.size()];
    for (int i = 0; i < tags.size(); i++) {
        t[i] = tags.get(i).getName();
    }
    //create a arrayadaptor for displaying the tagSpinner view, and set it
    ArrayAdapter<String> tagA = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, t);
    tagSpinner.setAdapter(tagA);
    //add views to linear layout and set the Linear layout view as the alert dialog view 
    ll.addView(tagSpinner);
    ll.addView(enterTag);
    alert.setView(ll);

    alert.setPositiveButton("Add", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            Tag tag = new Tag(enterTag.getText().toString());
            if (theClaim.getTagList().getTag(enterTag.getText().toString()) != null) {
                return;
            }
            ClaimListController.addTag(theClaim, tag);
            tagAdaptor.notifyDataSetChanged();
        }
    });
    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    alert.show();
}

From source file:com.abc.driver.TruckActivity.java

public void chooseTruckType(View v) {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    GridView gridView1 = new GridView(this);
    gridView1.setNumColumns(3);/*from w w  w.ja  va 2  s . c o m*/
    // (GridView)findViewById(R.id.gridView1);
    SimpleAdapter adapter = new SimpleAdapter(this, mTruckTypeList, R.layout.truck_type_griditem,
            new String[] { "PIC", "TITLE", "TTYPE" },
            new int[] { R.id.griditem_pic, R.id.griditem_title, R.id.griditem_type, });

    gridView1.setAdapter(adapter);
    builder.setTitle("Please Choose");
    builder.setInverseBackgroundForced(true);
    builder.setView(gridView1);
    final Dialog dialog = builder.create();

    gridView1.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            mTTtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText());
            mTruckType = ((TextView) view.findViewById(R.id.griditem_type)).getText().toString();

            mUpdateTruckTask = new UpdateTruckTask();
            mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(), mTruckType,
                    "" + app.getUser().getMyTruck().getLengthId(),
                    "" + app.getUser().getMyTruck().getWeightId(),
                    "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId());
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:at.wada811.android.dialogfragments.AlertDialogFragment.java

private void setView(AlertDialog.Builder builder) {
    final Bundle args = getArguments();
    boolean useView = args.getBoolean(VIEW, false);
    if (!useView) {
        return;//from   w  w w.  j  a  v a 2s.c om
    }
    DialogFragmentCallback listener = getDialogFragmentCallback();
    if (listener == null) {
        throw new RuntimeException("DialogEventListenerPovider has not implemented.");
    }
    View view = listener.getView(this);
    if (view == null) {
        throw new NullPointerException("DialogEventListener#getView returns null.");
    }
    builder.setView(view);
}

From source file:org.thoughtland.xlocation.ActivityShare.java

@SuppressLint("InflateParams")
public static boolean registerDevice(final ActivityBase context) {
    int userId = Util.getUserId(Process.myUid());
    if (Util.hasProLicense(context) == null
            && !PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingRegistered, false)) {
        // Get accounts
        String email = null;//from w  w  w . j  a  v  a2s. c om
        for (Account account : AccountManager.get(context).getAccounts())
            if ("com.google".equals(account.type)) {
                email = account.name;
                break;
            }

        LayoutInflater LayoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = LayoutInflater.inflate(R.layout.register, null);
        final EditText input = (EditText) view.findViewById(R.id.etEmail);
        if (email != null)
            input.setText(email);

        // Build dialog
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.msg_register);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setView(view);
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        String email = input.getText().toString();
                        if (Patterns.EMAIL_ADDRESS.matcher(email).matches())
                            new RegisterTask(context).executeOnExecutor(mExecutor, email);
                    }
                });
        alertDialogBuilder.setNegativeButton(context.getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Do nothing
                    }
                });

        // Show dialog
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();

        return false;
    }
    return true;
}

From source file:com.undatech.opaque.RemoteCanvasActivity.java

/**
 * Creates the help dialog for this activity.
 *//*from  w  w  w.  ja  va 2 s  . c o m*/
private Dialog createHelpDialog() {
    AlertDialog.Builder adb = new AlertDialog.Builder(this).setMessage(R.string.input_method_help_text)
            .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // We don't have to do anything.
                }
            });
    Dialog d = adb.setView(new ListView(this)).create();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(d.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    d.show();
    d.getWindow().setAttributes(lp);
    return d;
}

From source file:com.mocap.MocapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    /*/* ww w .jav  a2s .c  o m*/
            connection = new ServiceConnection() {
    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        try {
            mService = IInAppBillingService.Stub.asInterface(service);
            
        } catch (Exception e) {
            Log.i(TAG2, "InappBillingservice erreur: "+e);
        }
            
    }
            
    @Override
    public void onServiceDisconnected(ComponentName name) {
        mService = null;
    }
            };
            
            
            this.getActivity().bindService(new Intent("android.vending.billing.InAppBillingService.BIND"), connection, getActivity().getBaseContext().BIND_AUTO_CREATE);
            Log.i(TAG2, "InappBillingservice OK: ");
            
    */

    // processArguments();
    fa = super.getActivity();

    View layout = inflater.inflate(R.layout.layout_opengl, container, false);//com.mocap.MyGLSurfaceView
    final MyGLSurfaceView GLView = (MyGLSurfaceView) layout.findViewById(R.id.glsurfaceview);

    final ImageButton mInitButton = (ImageButton) layout.findViewById(R.id.init);
    final ImageButton mRefreshButton = (ImageButton) layout.findViewById(R.id.refresh);
    final ImageButton mStopButton = (ImageButton) layout.findViewById(R.id.stop);
    final ImageButton mStartButton = (ImageButton) layout.findViewById(R.id.start);
    final ImageButton mSaveButton = (ImageButton) layout.findViewById(R.id.save_file);
    final ImageButton mZommPlusButton = (ImageButton) layout.findViewById(R.id.zoomplus);
    final ImageButton mZommMoinsButton = (ImageButton) layout.findViewById(R.id.zoommoins);

    mRefreshButton.setEnabled(false);
    mRefreshButton.getDrawable().setAlpha(150);
    mStopButton.setEnabled(false);
    mStopButton.getDrawable().setAlpha(150);
    mStartButton.setEnabled(false);
    mStartButton.getDrawable().setAlpha(150);

    mSaveButton.setEnabled(false);
    mSaveButton.getDrawable().setAlpha(150);
    mZommPlusButton.setEnabled(false);
    mZommPlusButton.getDrawable().setAlpha(150);
    mZommMoinsButton.setEnabled(false);
    mZommMoinsButton.getDrawable().setAlpha(150);

    // Create the helper, passing it our context and the public key to verify signatures with
    Log.i(TAG2, "Creating IAB helper.");
    mHelper = new IabHelper(getActivity(), base64EncodedPublicKey);

    // enable debug logging (for a production application, you should set this to false).
    mHelper.enableDebugLogging(true);

    // Start setup. This is asynchronous and the specified listener
    // will be called once setup completes.
    Log.i(TAG2, "Starting setup.");
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            Log.i(TAG2, "Setup finished.");

            if (!result.isSuccess()) {
                // Oh noes, there was a problem.
                complain("Problem setting up in-app billing: " + result);
                return;
            }

            // Have we been disposed of in the meantime? If so, quit.
            if (mHelper == null)
                return;

            // IAB is fully set up. Now, let's get an inventory of stuff we own.
            Log.i(TAG2, "Setup successful. Querying inventory.");
            mHelper.queryInventoryAsync(mGotInventoryListener);
        }
    });

    mInitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            LayoutInflater inflater = getActivity().getLayoutInflater();

            final View alertDialogView = inflater.inflate(R.layout.init_dialog, null);
            builder.setView(alertDialogView);
            builder.setMessage(R.string.Init_phrase);
            builder.setTitle(R.string.Init_titre);
            builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    try {
                        GLView.onInitGravity();
                        Toast.makeText(getActivity(), "Init Gravity: ", Toast.LENGTH_SHORT).show();
                        mStartButton.setEnabled(true);
                        mStartButton.getDrawable().setAlpha(255);
                        mZommMoinsButton.setEnabled(true);
                        mZommMoinsButton.getDrawable().setAlpha(255);
                        mZommPlusButton.setEnabled(true);
                        mZommPlusButton.getDrawable().setAlpha(255);

                    } catch (Exception e) {
                        e.printStackTrace();
                        Toast.makeText(getActivity(), "Erreur save login: " + e, Toast.LENGTH_SHORT).show();
                    }
                }
            });
            builder.setNegativeButton(R.string.Annuler, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    try {

                    } catch (Exception e) {
                        e.printStackTrace();
                        Toast.makeText(getActivity(), "Erreur save login: " + e, Toast.LENGTH_SHORT).show();
                    }
                }
            });
            builder.show();
            //activation des sensors

        }
    });
    mRefreshButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //activation des sensors
            GLView.onRefresh();
            Toast.makeText(getActivity(), "Refresh: ", Toast.LENGTH_SHORT).show();
            mStartButton.setEnabled(true);
            mStartButton.getDrawable().setAlpha(255);
            mStopButton.setEnabled(false);
            mStopButton.getDrawable().setAlpha(150);
            mSaveButton.setEnabled(false);
            mSaveButton.getDrawable().setAlpha(150);
            mZommMoinsButton.setEnabled(true);
            mZommMoinsButton.getDrawable().setAlpha(255);
            mZommPlusButton.setEnabled(true);
            mZommPlusButton.getDrawable().setAlpha(255);

        }
    });

    mStartButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //activation des sensors
            GLView.onSensorsStart();
            mStartButton.setEnabled(false);
            mStartButton.getDrawable().setAlpha(150);
            mStopButton.setEnabled(true);
            mStopButton.getDrawable().setAlpha(255);
            mInitButton.setEnabled(false);
            mInitButton.getDrawable().setAlpha(150);
            Toast.makeText(getActivity(), "Start: ", Toast.LENGTH_SHORT).show();
        }
    });

    mStopButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //pause des sensor
            GLView.onSensorsPause();
            mStartButton.setEnabled(true);
            mStartButton.getDrawable().setAlpha(255);
            mStopButton.setEnabled(false);
            mStopButton.getDrawable().setAlpha(150);
            mSaveButton.setEnabled(true);
            mSaveButton.getDrawable().setAlpha(255);
            mInitButton.setEnabled(true);
            mInitButton.getDrawable().setAlpha(255);
            mRefreshButton.setEnabled(true);
            mRefreshButton.getDrawable().setAlpha(250);

            Toast.makeText(getActivity(), "Stop: ", Toast.LENGTH_SHORT).show();

            //enregistrer le fichier .obj
            //SaveOBJ(getActivity(),GLView);
        }
    });
    mSaveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onUpgradeAppButtonClicked(v);

            //pause des sensor
            /*
                            ArrayList skuList = new ArrayList();
                            skuList.add(inappid);
                            Bundle querySkus = new Bundle();
                            querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
                            Bundle skuDetails;
                    
                            try {
            Log.i(TAG, "Pas Erreur div: " + mService.toString());
                    
            skuDetails = mService.getSkuDetails(3, getActivity().getPackageName(),
                    "inapp", querySkus);
                    
            int response = skuDetails.getInt("RESPONSE_CODE");
                    
            if(response == 0)
            {
                ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
                    
                for (String thisResponse : responseList)
                {
                    JSONObject object = new JSONObject(thisResponse);
                    String sku = object.getString("productId");
                    String price = object.getString("price");
                    if (sku.equals(inappid)){
                        Log.i(TAG, "Price: "+price);
                        Bundle buyIntentBundle = mService
                                .getBuyIntent(3, getActivity().getPackageName()
                                        , sku, "inapp"
                                        , "test");
                        PendingIntent pendingIntent = buyIntentBundle
                                .getParcelable("BUY_INTENT");
                        getActivity().startIntentSenderForResult(
                                pendingIntent.getIntentSender(),1001,
                                new Intent(), Integer.valueOf(0),
                                        Integer.valueOf(0), Integer.valueOf(0));
                    
                    
                    }
                    
                }
            }
                    
                            //} catch (RemoteException e) {
                             //  Log.i(TAG, "Erreur remote: "+e);
                           // }
                         //catch (JSONException e) {
                         //    Log.i(TAG, "Erreur json: " + e);
                        }
                     catch (Exception e) {
                         Log.i(TAG, "Erreur div: "+ e);
                    }
            */

        }
    });
    mZommPlusButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            GLView.onChangeCam(1);
        }
    });
    mZommMoinsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            GLView.onChangeCam(-1);
        }
    });

    if (mText != null) {
        mTextView.setText(mText);
        Log.i("SimpleTextFragment", mText);
    }
    return layout;
}