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:org.rm3l.maoni.ui.MaoniActivity.java

private void initScreenCaptureView(@NonNull final Intent intent) {
    final ImageButton screenshotThumb = (ImageButton) findViewById(R.id.maoni_screenshot);

    final TextView touchToPreviewTextView = (TextView) findViewById(R.id.maoni_screenshot_touch_to_preview);
    if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) {
        touchToPreviewTextView.setText(intent.getCharSequenceExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT));
    }/*from w  w  w  . ja v a  2s  . c  o m*/

    final View screenshotContentView = findViewById(R.id.maoni_include_screenshot_content);
    if (!TextUtils.isEmpty(mScreenshotFilePath)) {
        final File file = new File(mScreenshotFilePath.toString());
        if (file.exists()) {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.VISIBLE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.VISIBLE);
            }
            if (screenshotThumb != null) {
                //Thumbnail - load with smaller resolution so as to reduce memory footprint
                screenshotThumb.setImageBitmap(
                        ViewUtils.decodeSampledBitmapFromFilePath(file.getAbsolutePath(), 100, 100));
            }

            // Hook up clicks on the thumbnail views.
            if (screenshotThumb != null) {
                screenshotThumb.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        final Dialog imagePreviewDialog = new Dialog(MaoniActivity.this);

                        imagePreviewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        imagePreviewDialog.getWindow()
                                .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

                        imagePreviewDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialogInterface) {
                                //nothing;
                            }
                        });

                        imagePreviewDialog.setContentView(R.layout.maoni_screenshot_preview);

                        final View.OnClickListener clickListener = new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                imagePreviewDialog.dismiss();
                            }
                        };

                        final ImageView imageView = (ImageView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image);
                        imageView.setImageURI(Uri.fromFile(file));

                        final DrawableView drawableView = (DrawableView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image_drawable_view);
                        final DrawableViewConfig config = new DrawableViewConfig();
                        // If the view is bigger than canvas, with this the user will see the bounds
                        config.setShowCanvasBounds(true);
                        config.setStrokeWidth(57.0f);
                        config.setMinZoom(1.0f);
                        config.setMaxZoom(1.0f);
                        config.setStrokeColor(mHighlightColor);
                        final View decorView = getWindow().getDecorView();
                        config.setCanvasWidth(decorView.getWidth());
                        config.setCanvasHeight(decorView.getHeight());
                        drawableView.setConfig(config);
                        drawableView.bringToFront();

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_highlight_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mHighlightColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_blackout_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mBlackoutColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_close)
                                .setOnClickListener(clickListener);

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_undo)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        drawableView.undo();
                                    }
                                });

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_save)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        ViewUtils.exportViewToFile(MaoniActivity.this,
                                                imagePreviewDialog.findViewById(
                                                        R.id.maoni_screenshot_preview_image_view_updated),
                                                new File(mScreenshotFilePath.toString()));
                                        initScreenCaptureView(intent);
                                        imagePreviewDialog.dismiss();
                                    }
                                });

                        imagePreviewDialog.setCancelable(true);
                        imagePreviewDialog.setCanceledOnTouchOutside(false);

                        imagePreviewDialog.show();
                    }
                });
            }
        } else {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.GONE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.GONE);
            }
        }
    } else {
        if (mIncludeScreenshot != null) {
            mIncludeScreenshot.setVisibility(View.GONE);
        }
        if (screenshotContentView != null) {
            screenshotContentView.setVisibility(View.GONE);
        }
    }
}

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

private Dialog showSingleChoiceDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_single_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.CustomDialog);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override//ww  w .ja va  2s  .c o m
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.tv_confirm:
                onDialogClickLisenter.viewClick("tv_confirm");
                dismiss();
                break;
            }
        }
    };
    TextView tv_confirm = (TextView) convertView.findViewById(R.id.tv_confirm);
    TextView tv_explain = (TextView) convertView.findViewById(R.id.tv_explain);

    tv_explain.setText(StringConstant.TEXT_SHOW_AFTER_CALL_POLICE_SUCCESS);
    if (onDialogClickLisenter != null) {
        onDialogClickLisenter.controlView(tv_confirm, null, null, tv_explain);
    }
    tv_confirm.setOnClickListener(listener);

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

From source file:com.citrus.sdk.fragments.SavedOptions.java

private void processCardFlow(final String txnId, final String signature, final String token) {
    final Dialog cvvDialog = new Dialog(getActivity());
    LayoutInflater inflater = (LayoutInflater) getActivity().getApplicationContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    cvvDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    View view = inflater.inflate(R.layout.cvv, null);
    final EditText cvvEditText = (EditText) view.findViewById(R.id.cvvText);
    final TextView errorText = (TextView) view.findViewById(R.id.errorText);
    Button payButton = (Button) view.findViewById(R.id.payButton);
    payButton.setOnClickListener(new OnClickListener() {

        @Override/*from w  w w. ja va2s.co m*/
        public void onClick(View v) {
            if (TextUtils.isEmpty(cvvEditText.getText().toString())
                    || cvvEditText.getText().toString().length() < 3) {
                errorText.setText("Invalid cvv");
            } else {
                fillDetails(txnId, signature, token, cvvEditText.getText().toString());
                cvvDialog.dismiss();
            }
        }
    });
    cvvDialog.setContentView(view);
    cvvDialog.show();
}

From source file:reportsas.com.formulapp.Formulario.java

public void btnScan_click() {
    if (parametroScan == null) {
        callScaner();/*from w ww . j  a  v  a  2 s . c om*/
    } else {
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialog_scaner);
        dialog.setTitle("Lectura Codigo  de Barras");

        TextView textoS = (TextView) dialog.findViewById(R.id.tvScan);
        Button Button1 = (Button) dialog.findViewById(R.id.NuevoScan);
        Button Button2 = (Button) dialog.findViewById(R.id.btn_close);

        textoS.setText(parametroScan.getValor());

        Button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                callScaner();
                dialog.dismiss();
            }
        });

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

                dialog.dismiss();
            }
        });

        dialog.show();
    }

}

From source file:reportsas.com.formulapp.Formulario.java

public void CapturaF() {
    if (parametroCam == null) {

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 1);

    } else {/*from  ww  w .  j  a v  a  2  s .c om*/

        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialog_imagen);
        dialog.setTitle("Captura de Formulario");
        byte[] decodedByte = Base64.decode(parametroCam.getValor(), 0);

        ImageView imageview = (ImageView) dialog.findViewById(R.id.ImaVcaptura);
        Button Button1 = (Button) dialog.findViewById(R.id.NuevaToma);
        Button Button2 = (Button) dialog.findViewById(R.id.btn_cerrar);

        imageview.setImageBitmap(BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length));
        Button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, 1);
                dialog.dismiss();
            }
        });

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

                dialog.dismiss();
            }
        });

        dialog.show();

    }

}

From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsReceivePaymentMainFragment.java

/**
 * ??//from  w w  w  . j ava 2s. co m
 * @param message
 * @param positive
 * @param negative
 * @param positiveEnable
 * @param negativeEnable
 */
private void showDefaultCardDialog(String message, String positive, String negative, boolean positiveEnable,
        boolean negativeEnable) {
    message = "??????????";

    //newDialog?
    Dialog dialog = new Dialog(getActivity(), R.style.MyDialogStyleBottom);
    //ContentView
    dialog.setContentView(R.layout.sms_default_card_dialog);
    dialog.findViewById(R.id.select_card).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            selectReceiveBankCard();
        }
    });
    dialog.findViewById(R.id.add_card).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            addReceiveBankCard();
        }
    });

    dialog.findViewById(R.id.select_card).setEnabled(positiveEnable);
    dialog.findViewById(R.id.add_card).setEnabled(negativeEnable);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

From source file:net.momodalo.app.vimtouch.VimTouch.java

public void showCmdHistory() {

    final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim);

    // Setting dialogview
    Window window = dialog.getWindow();
    window.setGravity(Gravity.BOTTOM);//from  ww  w  . j ava  2s .  com

    window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    dialog.setTitle(null);
    dialog.setContentView(R.layout.hist_list);
    dialog.setCancelable(true);

    LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout);
    if (AndroidCompat.SDK >= 11) {
        layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE
                | LinearLayout.SHOW_DIVIDER_END);
    }
    LayoutParams params = layout.getLayoutParams();
    params.width = mScreenWidth;
    layout.setLayoutParams(params);

    LayoutInflater inflater = LayoutInflater.from(this);
    boolean exists = false;

    for (int i = 1; i <= 10; i++) {
        TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false);
        String cmd = Exec.getCmdHistory(i);
        if (cmd.length() == 0)
            break;
        exists = true;
        button.setText(":" + cmd);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                TextView text = (TextView) v;
                CharSequence cmd = text.getText();
                Exec.doCommand(cmd.subSequence(1, cmd.length()).toString());
                dialog.dismiss();
            }
        });
        layout.addView((View) button);
    }

    if (exists)
        dialog.show();
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

public void createBackup(final boolean RecoveryBackup) {
    String prefix;//from w w  w  . j a va2 s. co  m
    String CurrentName;
    String EXT;
    if (RecoveryBackup) {
        prefix = "recovery";
        EXT = mDevice.getRecoveryExt();
        CurrentName = mDevice.getRecoveryVersion();
    } else {
        prefix = "kernel";
        EXT = mDevice.getKernelExt();
        CurrentName = mDevice.getKernelVersion();
    }
    final Dialog dialog = new Dialog(mContext);
    dialog.setTitle(R.string.setname);
    dialog.setContentView(R.layout.dialog_input);
    final Button bGoBackup = (Button) dialog.findViewById(R.id.bGoBackup);
    final EditText etFileName = (EditText) dialog.findViewById(R.id.etFileName);
    final CheckBox optName = (CheckBox) dialog.findViewById(R.id.cbOptInput);
    final String NameHint = prefix + "-from-" + Calendar.getInstance().get(Calendar.DATE) + "-"
            + Calendar.getInstance().get(Calendar.MONTH) + "-" + Calendar.getInstance().get(Calendar.YEAR) + "-"
            + Calendar.getInstance().get(Calendar.HOUR) + ":" + Calendar.getInstance().get(Calendar.MINUTE)
            + EXT;
    optName.setText(CurrentName);
    optName.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            etFileName.setEnabled(!optName.isChecked());
        }
    });

    etFileName.setHint(NameHint);
    bGoBackup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String EXT;
            File Path;
            final int JOB;
            if (RecoveryBackup) {
                EXT = mDevice.getRecoveryExt();
                Path = PathToRecoveryBackups;
                JOB = FlashUtil.JOB_BACKUP_RECOVERY;
            } else {
                EXT = mDevice.getKernelExt();
                Path = PathToKernelBackups;
                JOB = FlashUtil.JOB_BACKUP_KERNEL;
            }

            String Name = "";
            if (optName.isChecked()) {
                Name = optName.getText().toString() + EXT;
            } else {
                if (etFileName.getText() != null && !etFileName.getText().toString().equals("")) {
                    Name = etFileName.getText().toString();
                }

                if (Name.equals("")) {
                    Name = String.valueOf(etFileName.getHint());
                }

                if (!Name.endsWith(EXT)) {
                    Name = Name + EXT;
                }
            }

            final File fBACKUP = new File(Path, Name);
            Runnable rBackup = new Runnable() {
                @Override
                public void run() {
                    FlashUtil BackupCreator = new FlashUtil(mShell, mContext, mDevice, fBACKUP, JOB);
                    BackupCreator.setRunAtEnd(ReloadBackupDrawer);
                    BackupCreator.execute();
                }
            };
            if (fBACKUP.exists()) {
                Toast.makeText(mContext, R.string.backupalready, Toast.LENGTH_SHORT).show();
            } else {
                rBackup.run();
            }
            dialog.dismiss();

        }
    });
    dialog.show();
}

From source file:com.birdeye.MainActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Prefs.usernames.isSet()) {
        Prefs.usernames.set(Twitter.getSessionManager().getActiveSession().getUserName());
    }//from ww w  .j a v a  2s.c  o  m

    setContentView(R.layout.main);
    ButterKnife.bind(this);

    // hideSystemUI(this);
    Chartboost.startWithAppId(MainActivity.this, "57552756f6cd4526e365b9d1",
            "239b2e3aa657ccdcdf0b9674c8750f077b5e0aed");
    Chartboost.setLoggingLevel(CBLogging.Level.ALL);
    Chartboost.setDelegate(delegate);
    Chartboost.onCreate(this);

    tv_cancel = (TextView) findViewById(R.id.tv_cancel);
    tvSetTimer = (Button) findViewById(R.id.tvSetTimer);

    if (!BillingProcessor.isIabServiceAvailable(MainActivity.this)) {
        // showToast("In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16");
        onBackPressed();
    }

    bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() {
        @Override
        public void onProductPurchased(String productId, TransactionDetails details) {
            showToast("onProductPurchased: " + productId);
            // updateTextViews();
        }

        @Override
        public void onBillingError(int errorCode, Throwable error) {
            showToast("onBillingError: " + Integer.toString(errorCode));
        }

        @Override
        public void onBillingInitialized() {
            showToast("onBillingInitialized");
            readyToPurchase = true;
            //updateTextViews();
        }

        @Override
        public void onPurchaseHistoryRestored() {
            showToast("onPurchaseHistoryRestored");
            for (String sku : bp.listOwnedProducts())
                Log.d(LOG_TAG, "Owned Managed Product: " + sku);
            for (String sku : bp.listOwnedSubscriptions())
                Log.d(LOG_TAG, "Owned Subscription: " + sku);
            //updateTextViews();
            Log.i(LOG_TAG, String.format("%s is%s subscribed", SUBSCRIPTION_ID,
                    bp.isSubscribed(SUBSCRIPTION_ID) ? "" : " not"));
        }
    });

    subs = bp.getSubscriptionListingDetails(SUBSCRIPTION_ID);
    // showToast(subs != null ? subs.toString() : "Failed to load subscription details");

    if (subs == null) {
        //  showToast(subs != null ? subs.toString() : "Failed to load subscription details");
        Globals.hasPaid = false;
    } else {
        Globals.hasPaid = true;
    }

    if (Globals.hasPaid) {
        tvSetTimer.setVisibility(View.VISIBLE);

        message4.setVisibility(View.VISIBLE);
        message5.setVisibility(View.VISIBLE);
        message6.setVisibility(View.VISIBLE);
        message7.setVisibility(View.VISIBLE);
        message8.setVisibility(View.VISIBLE);
        message9.setVisibility(View.VISIBLE);
        message10.setVisibility(View.VISIBLE);
        message11.setVisibility(View.VISIBLE);
        message12.setVisibility(View.VISIBLE);
        message13.setVisibility(View.VISIBLE);
        message14.setVisibility(View.VISIBLE);
        message15.setVisibility(View.VISIBLE);
        message16.setVisibility(View.VISIBLE);
        message17.setVisibility(View.VISIBLE);
        message18.setVisibility(View.VISIBLE);
        message19.setVisibility(View.VISIBLE);
        message20.setVisibility(View.VISIBLE);
        message21.setVisibility(View.VISIBLE);
        message22.setVisibility(View.VISIBLE);
        message23.setVisibility(View.VISIBLE);
        message24.setVisibility(View.VISIBLE);
        message25.setVisibility(View.VISIBLE);

        ets = Arrays.asList(usernames, hashtags, message1, message2, message3, message4, message5, message6,
                message7, message8, message9, message10, message11, message12, message13, message14, message15,
                message16, message17, message18, message19, message20, message21, message22, message23,
                message24, message25);

    } else {
        tvSetTimer.setVisibility(View.GONE);
        message4.setVisibility(View.GONE);
        message5.setVisibility(View.GONE);
        message6.setVisibility(View.GONE);
        message7.setVisibility(View.GONE);
        message8.setVisibility(View.GONE);
        message9.setVisibility(View.GONE);
        message10.setVisibility(View.GONE);
        message11.setVisibility(View.GONE);
        message12.setVisibility(View.GONE);
        message13.setVisibility(View.GONE);
        message14.setVisibility(View.GONE);
        message15.setVisibility(View.GONE);
        message16.setVisibility(View.GONE);
        message17.setVisibility(View.GONE);
        message18.setVisibility(View.GONE);
        message19.setVisibility(View.GONE);
        message20.setVisibility(View.GONE);
        message21.setVisibility(View.GONE);
        message22.setVisibility(View.GONE);
        message23.setVisibility(View.GONE);
        message24.setVisibility(View.GONE);
        message25.setVisibility(View.GONE);
        ets = Arrays.asList(usernames, hashtags, message1, message2, message3);
    }

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

            final Dialog dialog = new Dialog(MainActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
            dialog.setContentView(R.layout.input_time);
            dialog.setCancelable(true);

            Button bt_set = (Button) dialog.findViewById(R.id.bt_set);
            final EditText et_time = (EditText) dialog.findViewById(R.id.et_time);

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

                    if (et_time.getText().toString().equalsIgnoreCase("")) {
                        Toast.makeText(MainActivity.this, "Please enter time to auto shut down",
                                Toast.LENGTH_SHORT).show();
                    }

                    else {

                        int valueTimer = Integer.parseInt(et_time.getText().toString()) * 1000;

                        initateCounter(valueTimer);
                        tv_cancel.setText("Auto ShutDown started");
                        tvSetTimer.setVisibility(View.GONE);
                        tv_cancel.setVisibility(View.VISIBLE);
                        dialog.dismiss();
                    }

                }
            });

            dialog.show();

        }
    });

    cameras.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, Facing.values()));
    //noinspection ConstantConditions
    cameras.setSelection(Prefs.facing.get().ordinal());
    cameras.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Prefs.facing.set(Facing.values()[position]);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    for (TextInputEditText et : ets) {
        DrawableCompat.setTint(et.getBackground(), ContextCompat.getColor(this, R.color.colorAccent));
        final TextInputLayout til = textLayout(et);
        til.setError(null);
        til.setErrorEnabled(false);
    }

    TextViews.setText(usernames, Prefs.usernames.get());
    TextViews.setText(hashtags, Prefs.hashtags.get());
    TextViews.setText(message1, Prefs.message1.get());
    TextViews.setText(message2, Prefs.message2.get());
    TextViews.setText(message3, Prefs.message3.get());

    TextViews.setText(message4, Prefs.message4.get());
    TextViews.setText(message5, Prefs.message5.get());
    TextViews.setText(message6, Prefs.message6.get());
    TextViews.setText(message7, Prefs.message7.get());
    TextViews.setText(message8, Prefs.message8.get());
    TextViews.setText(message9, Prefs.message9.get());
    TextViews.setText(message10, Prefs.message10.get());
    TextViews.setText(message11, Prefs.message11.get());
    TextViews.setText(message12, Prefs.message12.get());
    TextViews.setText(message13, Prefs.message13.get());
    TextViews.setText(message14, Prefs.message14.get());
    TextViews.setText(message15, Prefs.message15.get());
    TextViews.setText(message16, Prefs.message16.get());
    TextViews.setText(message17, Prefs.message17.get());
    TextViews.setText(message18, Prefs.message18.get());
    TextViews.setText(message19, Prefs.message19.get());
    TextViews.setText(message20, Prefs.message20.get());
    TextViews.setText(message21, Prefs.message21.get());
    TextViews.setText(message22, Prefs.message22.get());
    TextViews.setText(message23, Prefs.message23.get());
    TextViews.setText(message24, Prefs.message24.get());
    TextViews.setText(message25, Prefs.message25.get());

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    getWindow().setBackgroundDrawableResource(R.color.bg);

    mAdView = (AdView) findViewById(R.id.adView);
    mInterstitialAd = new InterstitialAd(this);

    // set the ad unit ID
    mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));

    adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            // Check the LogCat to get your test device ID
            .addTestDevice("EB02375D2DA62FFA0F6F145AD2302B3D").build();

    // adRequest = new AdRequest.Builder().build();

    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
        }

        @Override
        public void onAdClosed() {
            //   Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            //  Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAdLeftApplication() {
            //  Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAdOpened() {
            super.onAdOpened();
        }
    });

    mAdView.loadAd(adRequest);
    mInterstitialAd.loadAd(adRequest);

    mInterstitialAd.setAdListener(new AdListener() {
        public void onAdLoaded() {
            showInterstitial();
        }

        @Override
        public void onAdClosed() {
            Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode,
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAdLeftApplication() {
            Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAdOpened() {
            Toast.makeText(getApplicationContext(), "Ad is opened!", Toast.LENGTH_SHORT).show();
        }
    });

    if (Globals.hasPaid) {
        tv_cancel.setVisibility(View.GONE);
        mAdView.setVisibility(View.GONE);
    } else {

        // initateCounter(120000);
        startRepeatingTask();
        mAdView.setVisibility(View.VISIBLE);
    }

}

From source file:com.nbplus.vbroadlauncher.fragment.LoadIoTDevicesDialogFragmentStatus.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = new Dialog(
            getActivity()/*new ContextThemeWrapper(getActivity(), R.style.FullScreenDialog)*/);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    setRetainInstance(true);/*  ww  w.  j a  v  a 2  s.  c om*/
    originalOrientation = getActivity().getRequestedOrientation();
    getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    // fullscreen without statusbar
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    dialog.setCancelable(false);
    this.setCancelable(false);

    // disable back key
    dialog.setOnKeyListener(this);

    // set content view
    View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_iot_devices, null, false);
    dialog.setContentView(v);

    // grid view
    mGridView = (GridView) v.findViewById(R.id.iot_devices_grid);
    mGridView.setEmptyView(v.findViewById(android.R.id.empty));

    // set button control
    mCloseButton = (ImageButton) v.findViewById(R.id.btn_close);
    mCloseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG, "onClick btnClose..");
            ((BaseActivity) getActivity()).dismissProgressDialog();
            Intent sendIntent = new Intent();
            sendIntent.setAction(Constants.ACTION_IOT_DEVICE_LIST);
            sendIntent.putExtra(Constants.EXTRA_IOT_DEVICE_CANCELED, true);
            LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(sendIntent);

            dismiss();
        }
    });

    mRefreshButton = (Button) v.findViewById(R.id.btn_refresh);
    mRefreshButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG, "onClick btnRefresh..");
            ((BaseActivity) getActivity()).showProgressDialog();

            IoTInterface.getInstance().getDevicesList(DeviceTypes.ALL, LoadIoTDevicesDialogFragmentStatus.this,
                    true);
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ((BaseActivity) getActivity()).dismissProgressDialog();
                }
            }, 6000);
        }
    });

    mSendButton = (Button) v.findViewById(R.id.btn_send);
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG, "onClick btnSend..");
            ((BaseActivity) getActivity()).dismissProgressDialog();
            showSyncAlertDialog();
        }
    });

    mGridView.setOnItemClickListener(this);

    return dialog;
}