Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

In this page you can find the example usage for android.app Dialog setContentView.

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:co.taqat.call.CallActivity.java

private void showAcceptCallUpdateDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
    d.setAlpha(200);/*w  w  w  .  j  a v  a  2 s. c o m*/
    dialog.setContentView(R.layout.dialog);
    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);
    dialog.getWindow().setBackgroundDrawable(d);

    TextView customText = (TextView) dialog.findViewById(R.id.customText);
    customText.setText(getResources().getString(R.string.add_video_dialog));
    Button delete = (Button) dialog.findViewById(R.id.delete_button);
    delete.setText(R.string.accept);
    Button cancel = (Button) dialog.findViewById(R.id.cancel);
    cancel.setText(R.string.decline);

    delete.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            int camera = getPackageManager().checkPermission(Manifest.permission.CAMERA, getPackageName());
            Log.i("[Permission] Camera permission is "
                    + (camera == PackageManager.PERMISSION_GRANTED ? "granted" : "denied"));

            if (camera == PackageManager.PERMISSION_GRANTED) {
                CallActivity.instance().acceptCallUpdate(true);
            } else {
                checkAndRequestPermission(Manifest.permission.CAMERA, PERMISSIONS_REQUEST_CAMERA);
            }

            dialog.dismiss();
        }
    });

    cancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (CallActivity.isInstanciated()) {
                CallActivity.instance().acceptCallUpdate(false);
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:org.csp.everyaware.offline.Map.java

private void insertAnnDialog(final ExtendedLatLng annLatLng) {
    final Dialog insertDialog = new Dialog(Map.this);
    insertDialog.setContentView(R.layout.insert_dialog);
    insertDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    insertDialog.setTitle(R.string.annotation_insertion);
    insertDialog.setCancelable(false);/*from  www.  j  av  a 2s  .  c om*/

    //get reference to send button
    final Button sendButton = (Button) insertDialog.findViewById(R.id.send_button);
    sendButton.setEnabled(false); //active only if there's text

    //get reference to cancel/close window button
    final Button cancelButton = (Button) insertDialog.findViewById(R.id.cancel_button);
    cancelButton.setEnabled(true); //active all time
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            insertDialog.dismiss();
        }
    });

    //get reference to edittext in which user writes annotation
    final EditText editText = (EditText) insertDialog.findViewById(R.id.annotation_editText);
    editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //if modified text length is more than 0, activate send button
            if (s.length() > 0)
                sendButton.setEnabled(true);
            else
                sendButton.setEnabled(false);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    //get checkbox references
    CheckBox facebookChBox = (CheckBox) insertDialog.findViewById(R.id.facebook_checkBox);
    CheckBox twitterChBox = (CheckBox) insertDialog.findViewById(R.id.twitter_checkBox);

    //activate check boxes depends from log in facebook/twitter
    boolean[] logs = new boolean[2];
    logs[0] = Utils.getValidFbSession(getApplicationContext());
    logs[1] = Utils.getValidTwSession(getApplicationContext());

    facebookChBox.setEnabled(logs[0]);
    twitterChBox.setEnabled(logs[1]);

    //checked on check boxes
    final boolean[] checkeds = Utils.getShareCheckedOn(getApplicationContext());
    if (checkeds[0] == true)
        facebookChBox.setChecked(true);
    else
        facebookChBox.setChecked(false);
    if (checkeds[1] == true)
        twitterChBox.setChecked(true);
    else
        twitterChBox.setChecked(false);

    facebookChBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean checked) {
            Utils.setShareCheckedOn(checked, checkeds[1], getApplicationContext());
            checkeds[0] = checked;
        }
    });

    twitterChBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean checked) {
            Utils.setShareCheckedOn(checkeds[0], checked, getApplicationContext());
            checkeds[1] = checked;
        }
    });

    //send annotation to server and on facebook/twitter if user is logged on 
    sendButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //1 - read inserted annotation
            String annotation = editText.getText().toString();

            //2 - update record on db with annotation and save recordId            
            double recordId = annLatLng.mRecordId;

            int result = mDbManager.updateRecordAnnotation(recordId, annotation);

            if (result == 1)
                Toast.makeText(getApplicationContext(), "Updated record", Toast.LENGTH_LONG).show();
            else
                Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_LONG).show();

            boolean[] checks = Utils.getShareCheckedOn(getApplicationContext());

            //3 - share on facebook is user wants and internet is active now
            if (checks[0] == true) {
                Record annotatedRecord = mDbManager.loadRecordById(recordId);
                try {
                    FacebookManager fb = FacebookManager.getInstance(null, null);
                    if (fb != null)
                        fb.postMessageOnWall(annotatedRecord);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            //4 - share on twitter is user wants and internet is active now
            if (checks[1] == true) {
                Record annotatedRecord = mDbManager.loadRecordById(recordId);

                try {
                    TwitterManager twManager = TwitterManager.getInstance(null);
                    twManager.postMessage(annotatedRecord);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            //5 - show marker for annotated record
            Record annotatedRecord = mDbManager.loadRecordById(recordId);

            String userAnn = annotatedRecord.mUserData1;

            if (!userAnn.equals("") && (annotatedRecord.mValues[0] != 0)) {
                BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.annotation_marker);
                Marker marker = mGoogleMap.addMarker(new MarkerOptions()
                        .position(new LatLng(annotatedRecord.mValues[0], annotatedRecord.mValues[1]))
                        .title("BC: " + String.valueOf(annotatedRecord.mBcMobile) + " "
                                + getResources().getString(R.string.micrograms))
                        .snippet("Annotation: " + userAnn).icon(icon).anchor(0f, 1f));
            }

            insertDialog.dismiss();
        }
    });

    insertDialog.show();
}

From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java

/**
 * Show frequency dialog//from w  w w . j  a  v a  2  s  . c  o m
 */
private void showFrequencyPurchaseDialog(final int value) {
    final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.alert_dialog_main);
    final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title);
    final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg);
    final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt);
    Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn);
    Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn);
    final RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.myRadioGroup);

    final RadioButton radioOneMonth = (RadioButton) dialog.findViewById(R.id.oneMonth);
    final RadioButton radioThreeMonth = (RadioButton) dialog.findViewById(R.id.threeMonth);
    final RadioButton radioSixMonth = (RadioButton) dialog.findViewById(R.id.sixMonth);
    final RadioButton radioOneYear = (RadioButton) dialog.findViewById(R.id.oneYear);

    //long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);
    radioGroup.setVisibility(View.VISIBLE);
    alertTitle.setText("Purchase Product");
    if (value == updateDurationValue[0]) {
        alertMsg.setText("Buy Update Frequency for 1 Minutes");
        //radioOneMonth.setChecked(true);
        if (userType == PurchaseStatus.FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[1]) {
        alertMsg.setText("Buy Update Frequency for 2 Minutes");
        if (userType == PurchaseStatus.SEMI_FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[2]) {
        alertMsg.setText("Buy Update Frequency for 3 Minutes");

        if (userType == PurchaseStatus.PARTIAL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    }
    alertEditTxt.setVisibility(View.GONE);

    radioOneMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
            }
        }
    });
    radioThreeMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
            }
        }
    });
    radioSixMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
            }
        }
    });
    radioOneYear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
            }
        }
    });
    cancelBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);

            // Set Spinner
            setSpinnerUpdateTime(updateTime);
            firstSelect = false;
        }
    });
    okBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            if (radioOneMonth.isChecked() || radioThreeMonth.isChecked() || radioSixMonth.isChecked()
                    || radioOneYear.isChecked()) {
                // One min update
                if (value == updateDurationValue[0] && radioOneMonth.isChecked()) {
                    fullPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioThreeMonth.isChecked()) {
                    fullPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioSixMonth.isChecked()) {
                    fullPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioOneYear.isChecked()) {
                    fullPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Two min update
                else if (value == updateDurationValue[1] && radioOneMonth.isChecked()) {
                    semiparticalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioThreeMonth.isChecked()) {
                    semiparticalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioSixMonth.isChecked()) {
                    semiparticalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioOneYear.isChecked()) {
                    semiparticalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Three min update
                else if (value == updateDurationValue[2] && radioOneMonth.isChecked()) {
                    particalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioThreeMonth.isChecked()) {
                    particalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioSixMonth.isChecked()) {
                    particalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioOneYear.isChecked()) {
                    particalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }

                long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF,
                        AppConstants.DEFAULT_TIME_INTERVAL);
                // Set Spinner
                setSpinnerUpdateTime(updateTime);
                firstSelect = false;
                dialog.dismiss();
            } else {
                dialog.show();
                Utils.showToast("Select durations");
                //Toast.makeText(getActivity(), "Select durations", Toast.LENGTH_LONG).show();
            }
        }
    });
    dialog.show();
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

private Dialog showRegionChoiceDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_region_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.CustomDialog);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override//from  ww w . j a  va  2 s  .  c o m
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.layout_back:
                if (onDialogBackClickLisenter != null) {
                    onDialogBackClickLisenter.onClickBack(titleText, regionBeans, v);
                }
                break;
            }
        }
    };

    tvTitle = (TextView) convertView.findViewById(R.id.tv_region_name);
    listView = (ListView) convertView.findViewById(R.id.list_view);
    layoutBack = (LinearLayout) convertView.findViewById(R.id.layout_back);
    adapter = new RegionListAdapter(regionBeans, mContext);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (onDialogBackClickLisenter != null) {
                onDialogBackClickLisenter.onItemClickListener(position, id);
            }

        }
    });

    tvTitle.setText(titleText);
    layoutBack.setOnClickListener(listener);

    dialog.setContentView(convertView);
    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    return dialog;
}

From source file:org.csp.everyaware.offline.Map.java

/****************** OTTIENE RIFERIMENTO AI BOTTONI *********************************/

public void getButtonRefs() {
    mZoomControls = (LinearLayout) findViewById(R.id.zoomLinearLayout);
    mZoomControls.setVisibility(View.GONE);

    mTrackLengthBtn = (Button) findViewById(R.id.trackLengthBtn);
    mFollowCamBtn = (Button) findViewById(R.id.followCameraBtn);
    mZoomOutBtn = (Button) findViewById(R.id.zoomOutBtn);
    mZoomInBtn = (Button) findViewById(R.id.zoomInBtn);
    mInsertAnnBtn = (Button) findViewById(R.id.insertAnnBtn);
    mShareBtn = (Button) findViewById(R.id.shareBtn);

    mTrackLengthBtn.setVisibility(View.GONE);
    mInsertAnnBtn.setVisibility(View.GONE);

    mZoomOutBtn.setOnClickListener(new OnClickListener() {
        @Override//w w w .  j  a v  a 2  s . c o  m
        public void onClick(View arg0) {
            // Zoom out
            try {
                mGoogleMap.moveCamera(CameraUpdateFactory.zoomBy(-1f));
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
            //read and save actual zoom level
            mZoom = mGoogleMap.getCameraPosition().zoom;
        }
    });

    mZoomInBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // Zoom in
            try {
                mGoogleMap.moveCamera(CameraUpdateFactory.zoomBy(1f));
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
            //read and save actual zoom level
            mZoom = mGoogleMap.getCameraPosition().zoom;
        }
    });

    mShareBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            mFacebookManager = FacebookManager.getInstance(Map.this, mFacebookHandler);
            mTwitterManager = TwitterManager.getInstance(Map.this);

            final Dialog dialog = new Dialog(Map.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.share_dialog);
            //dialog.setTitle("Activate login on...");

            getShareButtonsRef(dialog);

            dialog.show();
        }
    });

    mFollowCamBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            //mCameraTrackOn = !mCameraTrackOn;
            setCameraTracking();

            if (mCameraTrackOn) {
                try {
                    if (Utils.lastPhoneLocation != null)
                        mGoogleMap.animateCamera(
                                CameraUpdateFactory.newLatLng(new LatLng(Utils.lastPhoneLocation.getLatitude(),
                                        Utils.lastPhoneLocation.getLongitude())));
                    else if (Utils.lastNetworkLocation != null)
                        mGoogleMap.animateCamera(CameraUpdateFactory
                                .newLatLng(new LatLng(Utils.lastNetworkLocation.getLatitude(),
                                        Utils.lastNetworkLocation.getLongitude())));
                } catch (NullPointerException e) {
                    e.printStackTrace();
                }
            }
        }
    });

    mShareBtn.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View arg0) {
            Toast toast = Toast.makeText(getApplicationContext(),
                    getResources().getString(R.string.share_btn_text), Toast.LENGTH_LONG);
            toast.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 250); //250 from top on a 480x800 screen
            toast.show();
            return false;
        }
    });

    //status icons references
    mGpsStatus = (ImageView) findViewById(R.id.gpsStatusIv);
    mInterUplStatus = (ImageView) findViewById(R.id.interUplStatusIv);

    //gps status icon initialization
    mGpsStatus.setBackgroundResource(R.drawable.gps_off);

    //read network type index on which upload data is allowed: 0 - only wifi; 1 - both wifi and mobile
    int networkTypeIndex = Utils.getUploadNetworkTypeIndex(getApplicationContext());

    //1 - is internet connection available? 
    boolean[] connectivity = Utils.haveNetworkConnection(getApplicationContext());

    //if user wants to upload only on wifi networks, connectivity[0] (network connectivity) must be true
    if (networkTypeIndex == 0) {
        if (connectivity[0])
            mConnectivityOn = true;
        else
            mConnectivityOn = false;
    } else //if user wants to upload both on wifi/mobile networks
        mConnectivityOn = connectivity[0] || connectivity[1];

    //network status icon initialization
    if (mConnectivityOn) {
        mInterUplStatus.setBackgroundResource(R.drawable.internet_on);
        Utils.uploadOn = Constants.INTERNET_ON_INT;
    } else {
        mInterUplStatus.setBackgroundResource(R.drawable.internet_off);
        Utils.uploadOn = Constants.INTERNET_OFF_INT;
    }

    //button to get from server black carbon levels around user
    mGetBcLevelsBtn = (Button) findViewById(R.id.getBcLevelsBtn);
    mGetBcLevelsBtn.setVisibility(View.VISIBLE);
    mGetBcLevelsBtn.setOnClickListener(mGetBcLevelsOnClickListener);

    //bcLayout.addView(mGetBcLevelsBtn);
    mSpectrum = (LinearLayout) findViewById(R.id.spectrumLinearLayout);
    mSpectrum.setVisibility(View.VISIBLE);
}

From source file:biz.bokhorst.xprivacy.ActivityApp.java

private void optionHelp() {
    // Show help/* w w  w  .ja va  2  s  . c  om*/
    Dialog dialog = new Dialog(ActivityApp.this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.menu_help);
    dialog.setContentView(R.layout.help);
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
    ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
    ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());
    dialog.setCancelable(true);
    dialog.show();
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

/**
 * ?=item ?/*from www  .ja  va 2s.co m*/
 *
 * @param mContext
 * @return
 */
private Dialog showConfirmOrCancelDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_double_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.mystyle);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.tv_cancel:
                if (onDialogClickLisenter != null)
                    onDialogClickLisenter.viewClick(StringConstant.tv_cancel);
                dismiss();
                break;
            case R.id.tv_confirm:
                if (onDialogClickLisenter != null)
                    onDialogClickLisenter.viewClick(StringConstant.tv_confirm);
                dismiss();
                break;
            default:
                break;
            }
        }
    };
    TextView tv_cancel = (TextView) convertView.findViewById(R.id.tv_cancel);
    TextView tv_confirm = (TextView) convertView.findViewById(R.id.tv_confirm);
    TextView tv_title = (TextView) convertView.findViewById(R.id.tv_title);
    TextView tv_content = (TextView) convertView.findViewById(R.id.tv_content);

    if (onDialogClickLisenter != null) {
        onDialogClickLisenter.controlView(tv_confirm, tv_cancel, tv_title, tv_content);
    }
    tv_cancel.setOnClickListener(listener);
    tv_confirm.setOnClickListener(listener);
    dialog.setContentView(convertView);
    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    return dialog;
}

From source file:group.pals.android.lib.ui.filechooser.utils.ui.history.HistoryFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(_ClassName, "onCreateDialog()");
    Dialog dialog = new Dialog(getActivity(), R.style.Afc_Theme_Dialog_Dark) {

        @Override// ww w  .  j  a  v a  2  s. c  o m
        public boolean onCreateOptionsMenu(Menu menu) {
            getActivity().getMenuInflater().inflate(R.menu.afc_viewgroup_history, menu);
            return super.onCreateOptionsMenu(menu);
        }// onCreateOptionsMenu()

        @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
            menu.findItem(R.id.afc_menuitem_clear)
                    .setEnabled(mHistoryCursorAdapter != null && mHistoryCursorAdapter.getGroupCount() > 0);
            return true;
        }// onPrepareOptionsMenu()

        @Override
        public boolean onMenuItemSelected(int featureId, MenuItem item) {
            if (BuildConfig.DEBUG)
                Log.d(_ClassName, "onMenuItemSelected() in Dialog");

            Ui.showSoftKeyboard(mSearchView, false);

            if (item.getItemId() == R.id.afc_menuitem_clear)
                doConfirmClearHistory();

            return true;
        }// onMenuItemSelected()
    };

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setOnKeyListener(mDialogOnKeyListener);

    Ui.adjustDialogSizeForLargeScreen(dialog);

    return dialog;
}

From source file:org.opendatakit.tables.activities.TableDisplayActivity.java

private void showDialogLocNuoc() {
    final ViewFragmentType fage = this.mCurrentFragmentType;
    final Dialog dialog = new Dialog(context);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    View layout = inflater.inflate(R.layout.dialog_loc, null);
    dialog.addContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    dialog.setContentView(R.layout.dialog_loc);
    final ListView lv = (ListView) dialog.findViewById(R.id.list_loc);
    TextView title = (TextView) dialog.findViewById(R.id.title);
    List<Model> list = new ArrayList<Model>();
    if (this.getTableId().equals("kdv_dnn_hogiadinh")) {
        list = SqliteLoc.getThonNuoc();/*from w  w w . j a va2  s  .co  m*/
    }
    if (this.getTableId().equals("kdv_vs_hogiadinh")) {
        list = SqliteLoc.getThonGiaDinh();
    }
    if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
        list = SqliteLoc.getThonCongCong();
    }
    if (loc_position >= 0 && list.size() > 0) {
        Model m = new Model(list.get(loc_position).getName(), true);
        list.set(loc_position, m);
    }
    if (list.size() == 0) {
        title.setText(getString(R.string.dialogloc));
    }
    adapter = new Adapter(this, list);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Model model = (Model) (lv.getItemAtPosition(position));
            String selectedFromList = model.getName();
            Intent intent = getIntent();
            intent.putExtra("loc", selectedFromList);
            intent.putExtra("loc_position", String.valueOf(position));
            intent.putExtra("all", "0");
            intent.putExtra("timkiem", "null");
            switch (fage) {
            case SPREADSHEET:
                intent.putExtra("page", "SPREADSHEET");
                break;
            case LIST:
                intent.putExtra("page", "LIST");
                break;
            case MAP:
                intent.putExtra("page", "MAP");
                break;
            case DETAIL:
                intent.putExtra("page", "DETAIL");
                break;
            default:
                break;
            }
            finish();
            startActivity(intent);
        }
    });
    dialog.show();
}

From source file:com.BeatYourRecord.SubmitActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog = new Dialog(SubmitActivity.this);

    switch (id) {
    case 10:/*www .  ja va 2s  . c om*/
        // Create out AlterDialog
        /*  Builder builder = new AlertDialog.Builder(this);
          dialog4.setContentView(R.layout.legal1);
          builder.setMessage();
          builder.setCancelable(true);
                
          AlertDialog dialog4 = builder.create();
          dialog4.show();
          return super.onCreateDialog(id);*/

        dialog.setContentView(R.layout.okbutton);

        TextView legalText1 = (TextView) dialog.findViewById(R.id.legal);

        legalText1.setText("Please Login using your email and password.");

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }

        });
        break;
    case 11:

        dialog.setContentView(R.layout.okbutton);
        dialog.setTitle("Note");
        TextView legalText12 = (TextView) dialog.findViewById(R.id.legal);

        legalText12.setText(
                "You are not connected to wifi. Upload times on 3g/4g can be long. To upload later click ok and then back");

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }

        });
        break;

    //break;
    case DIALOG_LEGAL:
        //dialog.setTitle("Terms of Service");
        dialog.setContentView(R.layout.legal);

        TextView legalText = (TextView) dialog.findViewById(R.id.legal);

        legalText.setText(Util.readFile(this, R.raw.legal).toString());

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
                ///////////////////////////////////////////////////////////////////////
                File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml");
                if (f.exists() && logout.equals("yes") == false) {
                    Log.v("androids a bitch", "das");
                } else {
                    iregistered();
                }

                getAuthTokenWithPermission(youTubeName);
            }
        });
        dialog.findViewById(R.id.notagree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });

        break;
    }

    return dialog;
}