Example usage for android.app Dialog setOnCancelListener

List of usage examples for android.app Dialog setOnCancelListener

Introduction

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

Prototype

public void setOnCancelListener(@Nullable OnCancelListener listener) 

Source Link

Document

Set a listener to be invoked when the dialog is canceled.

Usage

From source file:jp.co.noxi.app.NXDialog.java

void setOnCancelListenerInternal(final OnCancelListener listener) {
    final Dialog dialog = getDialog();
    if ((listener == null) || (dialog == null)) {
        return;/*from   w w w. ja v  a2 s .c om*/
    }

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            listener.onCancel(NXDialog.this);
        }
    });
}

From source file:dev.dworks.apps.asecure.MainActivity.java

private void showLoginDialog() {
    final SharedPreferences.Editor editor = mSharedPreferences.edit();
    final boolean passwordSet = !TextUtils.isEmpty(password);
    final String setPassword = password;

    LayoutInflater layoutInflater = LayoutInflater.from(this);
    final View loginView = layoutInflater.inflate(R.layout.dialog_login, null);
    TextView header = (TextView) loginView.findViewById(R.id.login_header);
    final EditText password = (EditText) loginView.findViewById(R.id.password);
    final EditText password_repeat = (EditText) loginView.findViewById(R.id.password_repeat);

    final Button login = (Button) loginView.findViewById(R.id.login_button);
    //Button cancel = (Button) loginView.findViewById(R.id.cancel_button);

    if (!passwordSet) {
        password_repeat.setVisibility(View.VISIBLE);
        header.setVisibility(View.VISIBLE);
    } else {/*from  w  w w .j a  v a2  s. co m*/
        password.setVisibility(View.GONE);
        password_repeat.setVisibility(View.VISIBLE);
        password_repeat.setHint(R.string.login_pwd);
    }
    header.setText(!passwordSet ? getString(R.string.login_message) : getString(R.string.msg_login));

    final Dialog dialog = new Dialog(this, R.style.Theme_Asecure_DailogLogin);
    dialog.setContentView(loginView);
    dialog.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
    dialog.show();

    password_repeat.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == R.id.login_button || actionId == EditorInfo.IME_NULL
                    || actionId == EditorInfo.IME_ACTION_DONE) {
                login.performClick();
                return true;
            }
            return false;
        }
    });
    login.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (passwordSet) {
                final String passwordString = password_repeat.getText().toString();
                if (TextUtils.isEmpty(passwordString) || passwordString.compareTo(setPassword) != 0) {
                    password_repeat.startAnimation(shake);
                    password_repeat.setError(getString(R.string.msg_wrong_password));
                    return;
                }
            } else {
                final String passwordString = password_repeat.getText().toString();
                final String passwordRepeatString = password_repeat.getText().toString();
                if (TextUtils.isEmpty(passwordString)) {
                    password.startAnimation(shake);
                    password.setError(getString(R.string.msg_pwd_empty));
                    return;
                }
                if (TextUtils.isEmpty(passwordRepeatString)) {
                    password_repeat.startAnimation(shake);
                    password_repeat.setError(getString(R.string.msg_pwd_empty));
                    return;
                } else if (passwordString.compareTo(passwordRepeatString) != 0) {
                    password_repeat.startAnimation(shake);
                    password_repeat.setError(getString(R.string.msg_pwd_dont_match));
                    return;
                }
                editor.putString("LoginPasswordPref", password.getText().toString());
                editor.commit();
            }
            dialog.dismiss();
        }
    });

    /*        cancel.setOnClickListener(new OnClickListener(){
            
             @Override
             public void onClick(View arg0) {
    dialog.dismiss();
    finish();
             }});*/
}

From source file:de.tum.in.tumcampus.fragments.SettingsFragment.java

/**
 * Sets up the action bar for an {@link PreferenceScreen}
 *//*from   w  ww. j a va2s  .c  o  m*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void initializeActionBar(PreferenceScreen preferenceScreen) {
    final Dialog dialog = preferenceScreen.getDialog();

    //Check if dialog is open and if we are on a supported android version
    if (dialog != null && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        //Setup a dialog back button pressed listener
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                mContext.finish();
            }
        });
    }
}

From source file:com.openerp.addons.idea.product.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.Dash_Board:

        Dash_Board detail = new Dash_Board();
        FragmentListener frag = (FragmentListener) getActivity();
        frag.startDetailFragment(detail);

        return true;

    case R.id.Search_product:

        final Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.product_search_custom_dialog);
        //   dialog.setTitle("Product Search");
        dialog.setOnCancelListener(new OnCancelListener() {

            @Override//from ww w.j a va 2  s .c om
            public void onCancel(DialogInterface dialog) {

                dialog.dismiss();
            }
        });

        AutoCompleteTextView autotext = (AutoCompleteTextView) dialog
                .findViewById(R.id.autoCompleteTextView_product_search);
        final ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,
                OEHelper.datatemplate);
        TextView txv = (TextView) dialog.findViewById(R.id.textView1);
        Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Georgia.ttf");
        autotext.setTypeface(font, Typeface.BOLD);
        autotext.setAdapter(adapter);
        txv.setTypeface(font, Typeface.BOLD);
        autotext.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

                String name = adapter.getItem(arg2).toString();
                callmethod_for_position_productdetail(OEHelper.datatemplate.indexOf(name));
                dialog.dismiss();
            }
        });

        dialog.show();
        return true;
    }
    return true;
}

From source file:com.vk.sdk.dialogs.VKShareDialog.java

@NonNull
@Override//ww w.jav  a  2s  .  c  o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    View mInternalView = LayoutInflater.from(context).inflate(R.layout.vk_share_dialog, null);

    assert mInternalView != null;

    mSendButton = (Button) mInternalView.findViewById(R.id.sendButton);
    mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress);
    mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer);
    mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText);
    mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView);

    LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout);

    mSendButton.setOnClickListener(sendButtonPress);

    //Attachment text
    if (savedInstanceState != null) {
        mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY));
        mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY);
        mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY);
        mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY);
    } else if (mAttachmentText != null) {
        mShareTextField.setText(mAttachmentText);
    }

    //Attachment photos
    mPhotoLayout.removeAllViews();
    if (mAttachmentImages != null) {
        for (VKUploadImage mAttachmentImage : mAttachmentImages) {
            addBitmapToPreview(mAttachmentImage.mImageData);
        }
        mPhotoLayout.setVisibility(View.VISIBLE);
    }

    if (mExistingPhotos != null) {
        processExistingPhotos();
    }
    if (mExistingPhotos == null && mAttachmentImages == null) {
        mPhotoLayout.setVisibility(View.GONE);
    }

    //Attachment link
    if (mAttachmentLink != null) {
        TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle),
                linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost);

        linkTitle.setText(mAttachmentLink.linkTitle);
        linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl));
        mAttachmentLinkLayout.setVisibility(View.VISIBLE);
    } else {
        mAttachmentLinkLayout.setVisibility(View.GONE);
    }
    Dialog result = new Dialog(context);
    result.requestWindowFeature(Window.FEATURE_NO_TITLE);
    result.setContentView(mInternalView);
    result.setCancelable(true);
    result.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (mListener != null) {
                mListener.onVkShareCancel();
            }
            VKShareDialog.this.dismiss();
        }
    });
    return result;
}

From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java

@Override
public void handle(final Activity activity, final CancellableTask task, final Callback callback) {
    try {/*  w  ww .  ja  v  a2s  . com*/
        final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName))
                .getHttpClient();
        final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey
                + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : "");
        String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL;
        Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) };
        String htmlChallenge;
        if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) {
            htmlChallenge = lastChallenge.getRight();
        } else {
            htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL,
                    HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient,
                    null, task, false);
        }
        lastChallenge = null;

        Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge);
        if (challengeMatcher.find()) {
            final String challenge = challengeMatcher.group(1);
            HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl(
                    scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey,
                    HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient,
                    null, task);
            try {
                InputStream imageStream = responseModel.stream;
                final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream);

                final String message;
                Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>")
                        .matcher(htmlChallenge);
                if (messageMatcher.find())
                    message = RegexUtils.removeHtmlTags(messageMatcher.group(1));
                else
                    message = null;

                final Bitmap candidateBitmap;
                Matcher candidateMatcher = Pattern
                        .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"")
                        .matcher(htmlChallenge);
                if (candidateMatcher.find()) {
                    Bitmap bmp = null;
                    try {
                        byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT);
                        bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length);
                    } catch (Exception e) {
                    }
                    candidateBitmap = bmp;
                } else
                    candidateBitmap = null;

                activity.runOnUiThread(new Runnable() {
                    final int maxX = 3;
                    final int maxY = 3;
                    final boolean[] isSelected = new boolean[maxX * maxY];

                    @SuppressLint("InlinedApi")
                    @Override
                    public void run() {
                        LinearLayout rootLayout = new LinearLayout(activity);
                        rootLayout.setOrientation(LinearLayout.VERTICAL);

                        if (candidateBitmap != null) {
                            ImageView candidateView = new ImageView(activity);
                            candidateView.setImageBitmap(candidateBitmap);
                            int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50
                                    + 0.5f);
                            candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize));
                            candidateView.setScaleType(ImageView.ScaleType.FIT_XY);
                            rootLayout.addView(candidateView);
                        }

                        if (message != null) {
                            TextView textView = new TextView(activity);
                            textView.setText(message);
                            CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance);
                            textView.setLayoutParams(
                                    new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                            LinearLayout.LayoutParams.WRAP_CONTENT));
                            rootLayout.addView(textView);
                        }

                        FrameLayout frame = new FrameLayout(activity);
                        frame.setLayoutParams(
                                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));

                        final ImageView imageView = new ImageView(activity);
                        imageView.setLayoutParams(new FrameLayout.LayoutParams(
                                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
                        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                        imageView.setImageBitmap(challengeBitmap);
                        frame.addView(imageView);

                        final LinearLayout selector = new LinearLayout(activity);
                        selector.setLayoutParams(new FrameLayout.LayoutParams(
                                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
                        AppearanceUtils.callWhenLoaded(imageView, new Runnable() {
                            @Override
                            public void run() {
                                selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(),
                                        imageView.getHeight()));
                            }
                        });
                        selector.setOrientation(LinearLayout.VERTICAL);
                        selector.setWeightSum(maxY);
                        for (int y = 0; y < maxY; ++y) {
                            LinearLayout subSelector = new LinearLayout(activity);
                            subSelector.setLayoutParams(new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
                            subSelector.setOrientation(LinearLayout.HORIZONTAL);
                            subSelector.setWeightSum(maxX);
                            for (int x = 0; x < maxX; ++x) {
                                FrameLayout switcher = new FrameLayout(activity);
                                switcher.setLayoutParams(new LinearLayout.LayoutParams(0,
                                        LinearLayout.LayoutParams.MATCH_PARENT, 1f));
                                switcher.setTag(new int[] { x, y });
                                switcher.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        int[] coord = (int[]) v.getTag();
                                        int index = coord[1] * maxX + coord[0];
                                        isSelected[index] = !isSelected[index];
                                        v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0)
                                                : Color.TRANSPARENT);
                                    }
                                });
                                subSelector.addView(switcher);
                            }
                            selector.addView(subSelector);
                        }

                        frame.addView(selector);
                        rootLayout.addView(frame);

                        Button checkButton = new Button(activity);
                        checkButton.setLayoutParams(
                                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));
                        checkButton.setText(android.R.string.ok);
                        rootLayout.addView(checkButton);

                        ScrollView dlgView = new ScrollView(activity);
                        dlgView.addView(rootLayout);

                        final Dialog dialog = new Dialog(activity);
                        dialog.setTitle("Recaptcha");
                        dialog.setContentView(dlgView);
                        dialog.setCanceledOnTouchOutside(false);
                        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                if (!task.isCancelled()) {
                                    callback.onError("Cancelled");
                                }
                            }
                        });
                        dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                                ViewGroup.LayoutParams.WRAP_CONTENT);
                        dialog.show();

                        checkButton.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                if (task.isCancelled())
                                    return;
                                Async.runAsync(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            List<NameValuePair> pairs = new ArrayList<NameValuePair>();
                                            pairs.add(new BasicNameValuePair("c", challenge));
                                            for (int i = 0; i < isSelected.length; ++i)
                                                if (isSelected[i])
                                                    pairs.add(new BasicNameValuePair("response",
                                                            Integer.toString(i)));

                                            HttpRequestModel request = HttpRequestModel.builder()
                                                    .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8"))
                                                    .setCustomHeaders(new Header[] {
                                                            new BasicHeader(HttpHeaders.REFERER, usingURL) })
                                                    .build();
                                            String response = HttpStreamer.getInstance().getStringFromUrl(
                                                    usingURL, request, httpClient, null, task, false);
                                            String hash = "";
                                            Matcher matcher = Pattern.compile(
                                                    "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<",
                                                    Pattern.DOTALL).matcher(response);
                                            if (matcher.find())
                                                hash = matcher.group(1);

                                            if (hash.length() > 0) {
                                                Recaptcha2solved.push(publicKey, hash);
                                                activity.runOnUiThread(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        callback.onSuccess();
                                                    }
                                                });
                                            } else {
                                                lastChallenge = Pair.of(usingURL, response);
                                                throw new RecaptchaException(
                                                        "incorrect answer (hash is empty)");
                                            }
                                        } catch (final Exception e) {
                                            Logger.e(TAG, e);
                                            if (task.isCancelled())
                                                return;
                                            handle(activity, task, callback);
                                        }
                                    }
                                });
                            }
                        });
                    }
                });
            } finally {
                responseModel.release();
            }
        } else
            throw new Exception("can't parse recaptcha challenge answer");
    } catch (final Exception e) {
        Logger.e(TAG, e);
        if (!task.isCancelled()) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    callback.onError(e.getMessage() != null ? e.getMessage() : e.toString());
                }
            });
        }
    }
}

From source file:org.catrobat.catroid.ui.dialogs.CustomIconContextMenu.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final String menuTitle = getArguments().getString(BUNDLE_ARGUMENTS_MENU_TITLE);

    Dialog dialog = new AlertDialog.Builder(getActivity()).setTitle(menuTitle)
            .setIcon(R.drawable.ic_dialog_menu_generic)
            .setAdapter(menuAdapter, new DialogInterface.OnClickListener() {
                @Override/* w w w  .j a v  a  2  s  .  c o  m*/
                public void onClick(DialogInterface dialoginterface, int position) {
                    CustomContextMenuItem item = (CustomContextMenuItem) menuAdapter.getItem(position);

                    if (clickListener != null) {
                        clickListener.onClick(item.contextMenuItemId);
                    }
                }
            }).setInverseBackgroundForced(true).create();

    dialog.setCanceledOnTouchOutside(true);
    dialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            dismiss();
        }
    });

    return dialog;
}

From source file:Steps.StepsFragment.java

private void showStickerMoreInfo(final Sticker clickedSticker) {
    // custom dialog
    clickedSticker.getName();// w ww . ja v  a  2s.com
    Log.d("NAMe", clickedSticker.getName());

    final Dialog dialog = new Dialog(getActivity());

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    dialog.setContentView(R.layout.sticker_dialog);
    ImageView image = (ImageView) (dialog).findViewById(R.id.image);

    //get the correct image
    String file = clickedSticker.getImagesrc();
    file = file.substring(0, file.lastIndexOf(".")); //trim the extension
    Resources resources = getActivity().getResources();
    int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName());
    image.setImageBitmap(SampleImage.decodeSampledBitmapFromResource(getResources(), resourceId, 250, 250));

    //load the additional details and information
    TextView id = (TextView) (dialog).findViewById(R.id.sticker_id);
    id.setText("#" + Integer.toString(clickedSticker.getId()));

    TextView status = (TextView) (dialog).findViewById(R.id.sticker_status);
    //at this poinrt only glued and notSticker available glued=1 notGlued=0
    String statuss = clickedSticker.getStatus().equals(2) ? "1" : "0";
    Integer count = clickedSticker.getCount();
    status.setText("(" + statuss + " glued, " + count + " left)");

    TextView title = (TextView) (dialog).findViewById(R.id.sticker_title);
    title.setText(clickedSticker.getName());

    TextView rarity = (TextView) (dialog).findViewById(R.id.rarity);
    rarity.setText(clickedSticker.getPopularity());

    TextView movie = (TextView) (dialog).findViewById(R.id.sticker_movie);
    movie.setText(clickedSticker.getMovie());
    //set the layout to have the same widh and height as the  windows screen

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = width;
    lp.height = height;
    dialog.getWindow().setAttributes(lp);
    RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout);
    dialog.show();
    // if button is clicked, close the custom dialog
    mainLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }

    });
    //listen for the inf tab
    ImageView info = (ImageView) (dialog).findViewById(R.id.info_image);
    info.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showInfoDialog(clickedSticker);
        }

    });

}

From source file:Steps.StepsFragment.java

private void showNewSticker(final Sticker sticker_1, final Sticker sticker_2, final Sticker sticker_3) {
    // custom dialog

    final Dialog dialog = new Dialog(getActivity());

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override/*w w  w .  j a  va2  s .c o  m*/
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.setContentView(R.layout.new_stickers_dialog);
    //get the correct image -1st sticker

    ImageView image = (ImageView) (dialog).findViewById(R.id.sticker1);
    image.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showStickerMoreInfo(sticker_1);
        }
    });
    String file = sticker_1.getImagesrc();
    file = file.substring(0, file.lastIndexOf(".")); //trim the extension
    Resources resources = getActivity().getResources();
    int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName());
    TextView number = (TextView) (dialog).findViewById(R.id.text_sticker1);
    number.setText("#" + Integer.toString(sticker_1.getId()));
    RelativeLayout image_layout = (RelativeLayout) (dialog).findViewById(R.id.sticker1_layout);
    ImageView imageCategory = (ImageView) (dialog).findViewById(R.id.category_image1);
    determineCategoty(imageCategory, sticker_1);
    determinePicture(sticker_1, image, resourceId);
    animate(image_layout, 3000);

    //get the correct image -2nd sticker
    ImageView image2 = (ImageView) (dialog).findViewById(R.id.sticker2);
    image2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showStickerMoreInfo(sticker_2);
        }
    });
    String file2 = sticker_2.getImagesrc();
    file2 = file2.substring(0, file2.lastIndexOf(".")); //trim the extension
    Resources resources2 = getActivity().getResources();
    int resourceId2 = resources2.getIdentifier(file2, "drawable", getActivity().getPackageName());
    TextView number2 = (TextView) (dialog).findViewById(R.id.text_sticker2);
    number2.setText("#" + Integer.toString(sticker_2.getId()));
    RelativeLayout image_layout2 = (RelativeLayout) (dialog).findViewById(R.id.sticker2_layout);
    ImageView imageCategory2 = (ImageView) (dialog).findViewById(R.id.category_image2);
    determineCategoty(imageCategory2, sticker_2);
    determinePicture(sticker_2, image2, resourceId2);
    animate(image_layout2, 3000);

    //get the correct image -3rd sticker
    ImageView image3 = (ImageView) (dialog).findViewById(R.id.sticker3);
    image3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showStickerMoreInfo(sticker_3);
        }
    });
    String file3 = sticker_3.getImagesrc();
    file3 = file3.substring(0, file3.lastIndexOf(".")); //trim the extension
    Resources resources3 = getActivity().getResources();
    int resourceId3 = resources3.getIdentifier(file3, "drawable", getActivity().getPackageName());

    TextView number3 = (TextView) (dialog).findViewById(R.id.text_sticker3);
    number3.setText("#" + Integer.toString(sticker_3.getId()));
    RelativeLayout image_layout3 = (RelativeLayout) (dialog).findViewById(R.id.sticker3_layout);
    ImageView imageCategory3 = (ImageView) (dialog).findViewById(R.id.category_image3);
    determineCategoty(imageCategory3, sticker_3);
    determinePicture(sticker_3, image3, resourceId3);
    animate(image_layout3, 3000);

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    //set the layout to have the same widh and height as the  windows screen
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = width;
    lp.height = height;
    dialog.getWindow().setAttributes(lp);
    RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout);
    dialog.show();
    // if button is clicked, close the custom dialog
    Button doneButton = (Button) (dialog).findViewById(R.id.doneButton);
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }

    });
}