Example usage for android.app Dialog getWindow

List of usage examples for android.app Dialog getWindow

Introduction

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

Prototype

public @Nullable Window getWindow() 

Source Link

Document

Retrieve the current Window for the activity.

Usage

From source file:org.openhab.habdroid.ui.OpenHABInfoFragment.java

@Override
public void onStart() {
    super.onStart();
    Dialog dialog = getDialog();/*from ww  w.j a v a2 s.c om*/
    if (dialog != null) {

        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        int height = ViewGroup.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setLayout(width, height);
    }
}

From source file:com.pileproject.drive.setting.machine.NxtThresholdFragment.java

/**
 * This function should be called in {@link DialogFragment#onActivityCreated(Bundle)}.
 * Otherwise, the dialog size will never be changed
 *///from w  w  w.ja v a 2 s .c o m
private void resizeDialog() {
    Dialog dialog = getDialog();

    DisplayMetrics metrics = getResources().getDisplayMetrics();

    // resize window large enough to display list views
    int dialogWidth = (int) (metrics.widthPixels * 0.8);

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;
    dialog.getWindow().setAttributes(lp);
}

From source file:edu.berkeley.boinc.attach.AcctMgrFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    // request a window without the title
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

From source file:com.pileproject.drive.setting.app.CopyrightNoticeFragment.java

/**
 * This function should be called in {@link DialogFragment#onActivityCreated(Bundle)}.
 * Otherwise, the dialog size will never be changed.
 *///from  w  w  w .  ja  v a  2 s  .co m
private void resizeDialog() {
    Dialog dialog = getDialog();

    DisplayMetrics metrics = getResources().getDisplayMetrics();

    // resize window large enough to display list views
    int dialogWidth = (int) (metrics.widthPixels * 0.9);
    int dialogHeight = (int) (metrics.heightPixels * 0.9);

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;
    lp.height = dialogHeight;
    dialog.getWindow().setAttributes(lp);
}

From source file:com.chenenyu.areapicker.AreaPicker.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    return dialog;
}

From source file:com.mimp.fragment.institucion.PlanTrabajoPage.java

public void btnAgregar() {
    final Dialog dialog = new Dialog(this.getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    //dialog.setCancelable(false);
    dialog.setContentView(R.layout.dialog_plan_trabajo);

    TextView lblResponsable = (TextView) dialog.findViewById(R.id.lblResponsable);
    lblResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblResponsable.getTextSize() + SizeText);

    TextView lblDResponsable = (TextView) dialog.findViewById(R.id.lblDResponsable);
    lblDResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblDResponsable.getTextSize() + SizeText);

    TextView lblObejtivo = (TextView) dialog.findViewById(R.id.lblObejtivo);
    lblObejtivo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblObejtivo.getTextSize() + SizeText);

    TextView lblMeta = (TextView) dialog.findViewById(R.id.lblMeta);
    lblMeta.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblMeta.getTextSize() + SizeText);

    TextView lblActividad = (TextView) dialog.findViewById(R.id.lblActividad);
    lblActividad.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblActividad.getTextSize() + SizeText);

    TextView lblCronograma = (TextView) dialog.findViewById(R.id.lblCronograma);
    lblCronograma.setTextSize(TypedValue.COMPLEX_UNIT_DIP, lblCronograma.getTextSize() + SizeText);

    final EditText txtObejtivo = (EditText) dialog.findViewById(R.id.txtObejtivo);
    txtObejtivo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtObejtivo.getTextSize() + SizeText);
    txtObejtivo.setText("");

    final EditText txtActividad = (EditText) dialog.findViewById(R.id.txtActividad);
    txtActividad.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtActividad.getTextSize() + SizeText);
    txtActividad.setText("");

    final EditText txtCronograma = (EditText) dialog.findViewById(R.id.txtCronograma);
    txtCronograma.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtCronograma.getTextSize() + SizeText);
    txtCronograma.setText("");

    final EditText txtMeta = (EditText) dialog.findViewById(R.id.txtMeta);
    txtMeta.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtMeta.getTextSize() + SizeText);
    txtMeta.setText("");

    final EditText txtResponsable = (EditText) dialog.findViewById(R.id.txtResponsable);
    txtResponsable.setTextSize(TypedValue.COMPLEX_UNIT_DIP, txtResponsable.getTextSize() + SizeText);
    txtResponsable.setText("");

    Button btnAgregar = (Button) dialog.findViewById(R.id.btnAgregar);
    btnAgregar.setOnClickListener(new View.OnClickListener() {
        @Override/*from www .  j  av  a2s . co  m*/
        public void onClick(View v) {
            clsPlanTrabajo entidad = new clsPlanTrabajo();
            entidad.setActividad(txtActividad.getText().toString());
            entidad.setCronograma(txtCronograma.getText().toString());
            entidad.setMeta(txtMeta.getText().toString());
            entidad.setObejtivo(txtObejtivo.getText().toString());
            entidad.setResponsable(txtResponsable.getText().toString());
            list.add(entidad);
            getListaPlanTrabajo();
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:com.minerva.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    checkAndRequestPermissions();// w w w .j av  a  2s.com

    LOG_TAG = MainActivity.this.getClass().getSimpleName();

    Log.i(LOG_TAG, "Creating application Main Activity...");

    // *** Setting up the Toolbar ***
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // *** Handling navigation buttons and clicks ***
    BottomNavigationView bottomNavigationVew = (BottomNavigationView) findViewById(R.id.navigation);
    bottomNavigationVew
            .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    switch (item.getItemId()) {
                    case R.id.action_camera:
                        Log.i(LOG_TAG, "Accessing Camera Activity...");
                        Intent cameraIntent = new Intent(MainActivity.this, CameraActivity.class);
                        startActivity(cameraIntent);
                        break;
                    case R.id.action_gallery:
                        Log.i(LOG_TAG, "Accessing Gallery Activity...");
                        Intent galleryIntent = new Intent(MainActivity.this, GalleryActivity.class);
                        startActivity(galleryIntent);
                        break;
                    case R.id.action_home:
                        break;
                    }

                    return false;
                }
            });

    // *** Handling first time use ***

    SharedPreferences settings = getSharedPreferences(PREFS_NAME1, 0);

    //if (settings.getBoolean("my_first_time1", false)) {
    //the app is being launched for first time, do something

    // *** First time task ***
    final Dialog alertDialog = new Dialog(this);
    alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alertDialog.setContentView(R.layout.navigation);
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    alertDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);

    alertDialog.show();

    Button gotIt = (Button) alertDialog.findViewById(R.id.gotIt);
    gotIt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
        }
    });
    // record the fact that the app has been started at least once
    //  settings.edit().putBoolean("my_first_time", false).commit();
}

From source file:com.procleus.brime.ui.LabelsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    ((MainActivity) getActivity()).setActionBarTitle("Labels");
    ((MainActivity) getActivity()).showFloatingActionButton(true);
    final View v = inflater.inflate(R.layout.labels_gragment, container, false);
    final NotesDbHelperOld tn = new NotesDbHelperOld(getActivity());

    labelsRetrieved = new ArrayList<String>();
    labelsRetrieved = tn.retrieveLabel();

    listView = (ListView) v.findViewById(R.id.listLabel);
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
            android.R.layout.simple_list_item_1, labelsRetrieved);
    listView.setAdapter(arrayAdapter);/*from w  ww  .ja va 2 s.c om*/
    ImageButton addLabelBtn = (ImageButton) v.findViewById(R.id.addLabelBtn);

    addLabelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            addLabelFunc(v, tn);
        }
    });

    /*/WORK OF LONG ITEM CLICK LISTENER*/

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {

            final Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.dialog_label);
            dialog.show();

            final Button negative = (Button) dialog.findViewById(R.id.btn_no_label);
            final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label);

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

                    dialog.dismiss();

                }
            });

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

                    Log.i("brinjal", "Yes");

                    tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position)));
                    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
                            android.R.layout.simple_list_item_1, labelsRetrieved);
                    listView.setAdapter(arrayAdapter);
                    dialog.dismiss();

                }

            });

            return true;

        }
    });

    return v;
}

From source file:com.king.base.BaseActivity.java

private void setDialogWindow(Dialog dialog, float widthRatio) {
    Window window = dialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    int width = Math.min(getWidthPixels(), getHeightPixels());
    lp.width = (int) (width * widthRatio);
    window.setAttributes(lp);/*ww w .ja v  a 2 s . c o m*/
}

From source file:com.procleus.brime.ui.LabelsFragment.java

@Override
public void onResume() {
    super.onResume();
    NotesDbHelperOld tn = new NotesDbHelperOld(getContext());
    labelsRetrieved = tn.retrieveLabel();
    listView = (ListView) getView().findViewById(R.id.listLabel);
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
            android.R.layout.simple_list_item_1, labelsRetrieved);
    listView.setAdapter(arrayAdapter);//from   ww w  .j  a v a 2s .c  om

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {

            final Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.dialog_label);
            dialog.show();

            final Button negative = (Button) dialog.findViewById(R.id.btn_no_label);
            final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label);

            /*/This is Database Spinner Retreival*/
            /* Spinner getting Data from dataBase*/

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

                    dialog.dismiss();

                }
            });

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

                    Log.i("brinjalResume", "Yes");

                    NotesDbHelperOld tn = new NotesDbHelperOld(getActivity());
                    tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position)));
                    labelsRetrieved = tn.retrieveLabel();
                    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
                            android.R.layout.simple_list_item_1, labelsRetrieved);
                    listView.setAdapter(arrayAdapter);
                    dialog.dismiss();
                }

            });

            return true;

        }
    });

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Toast.makeText(getActivity(),
                    "Inside in label" + ":" + String.valueOf(parent.getItemAtPosition(position)),
                    Toast.LENGTH_SHORT).show();
            Intent i = new Intent(getActivity(), LabelOpenActivity.class);
            i.putExtra("label", String.valueOf(parent.getItemAtPosition(position)));
            startActivity(i);

        }
    });

}