Example usage for android.widget ImageView post

List of usage examples for android.widget ImageView post

Introduction

In this page you can find the example usage for android.widget ImageView post.

Prototype

public boolean post(Runnable action) 

Source Link

Document

Causes the Runnable to be added to the message queue.

Usage

From source file:com.popdeem.sdk.uikit.fragment.dialog.PDUINotificationDialogFragment.java

@NonNull
@Override/* w  w  w  .j  a v a2s  . c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(getActivity(), R.style.AlertDialogCustom));
    Bundle args = getArguments();
    if (args == null) {
        created = false;
        return builder.create();
    }

    final String title = args.getString("title", null);
    final String message = args.getString("message", null);
    final String imageUrl = args.getString("image", null);
    final String targetUrl = args.getString("targetUrl", null);
    final String deepLink = args.getString("deepLink", null);
    final String messageId = args.getString("messageId", null);

    if (title == null || message == null) {
        created = false;
        return builder.create();
    }

    // Dialog View
    View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_pd_notification_dialog, null,
            false);
    builder.setView(dialogView);

    // Title
    TextView textView = (TextView) dialogView.findViewById(R.id.pd_notification_dialog_title_text_view);
    textView.setText(title);

    // Message
    textView = (TextView) dialogView.findViewById(R.id.pd_notification_dialog_message_text_view);
    textView.setText(message);

    // Image
    final ImageView imageView = (ImageView) dialogView.findViewById(R.id.pd_notification_dialog_image_view);
    if (imageUrl != null && !imageUrl.isEmpty()) {
        imageView.setVisibility(View.VISIBLE);
        imageView.post(new Runnable() {
            @Override
            public void run() {
                Glide.with(getActivity()).load(imageUrl).dontAnimate()
                        //                            .override(imageView.getWidth(), 1)
                        .into(imageView);
            }
        });
    }

    // Buttons
    final DialogInterface.OnClickListener negativeClick = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            markMessageAsRead(messageId);
        }
    };
    if (targetUrl == null && deepLink == null) {
        builder.setPositiveButton(android.R.string.ok, negativeClick);
    } else {
        builder.setPositiveButton(R.string.pd_notification_go_button_text,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        markMessageAsRead(messageId);

                        String url = targetUrl != null ? targetUrl : imageUrl;
                        if (url != null && !url.startsWith("http://") && !url.startsWith("https://")) {
                            url = "http://" + url;
                        }
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        startActivity(intent);
                    }
                });
        builder.setNegativeButton(android.R.string.cancel, negativeClick);
    }

    return builder.create();
}

From source file:piuk.blockchain.android.ui.NewAccountFragment.java

public void refreshCaptcha(View view) {
    final ImageView captchaImage = (ImageView) view.findViewById(R.id.captcha_image);

    new Thread(new Runnable() {
        public void run() {
            try {
                final Bitmap b = loadBitmap("https://blockchain.info/kaptcha.jpg");
                captchaImage.post(new Runnable() {
                    public void run() {
                        captchaImage.setImageBitmap(b);
                    }/*from   w ww.  j a va 2  s .c om*/
                });
            } catch (Exception e) {

                captchaImage.post(new Runnable() {
                    public void run() {
                        Toast.makeText(getActivity().getApplication(), R.string.toast_error_downloading_captcha,
                                Toast.LENGTH_LONG).show();
                    }
                });

                e.printStackTrace();
            }
        }
    }).start();
}

From source file:galilei.kelimekavanozu.view.ImageAdapter.java

@Override
public Object instantiateItem(ViewGroup container, final int position) {
    if (context.get() != null) {
        final int drawableId = theme.getImageList().get(position + 1);
        final ImageView view = new ImageView(context.get());
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setContentDescription(context.get().getResources().getString(R.string.content_desc_poempic));
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setAdjustViewBounds(true);//from  w ww.  j a v a2 s  . co  m
        view.setTag(drawableId);
        container.addView(view, 0);
        view.post(new Runnable() {
            @Override
            public void run() {
                ImageLoader.getImageLoader().load(drawableId, view);
            }
        });
        return view;
    }
    return null;
}

From source file:piuk.blockchain.android.ui.dialogs.NewAccountDialog.java

public void refreshCaptcha(View view) {
    final ImageView captchaImage = (ImageView) view.findViewById(R.id.captcha_image);

    new Thread(new Runnable() {
        public void run() {
            try {
                final Bitmap b = loadBitmap("https://" + Constants.BLOCKCHAIN_DOMAIN + "/kaptcha.jpg");
                captchaImage.post(new Runnable() {
                    public void run() {
                        captchaImage.setImageBitmap(b);
                    }//from   ww w.  j ava  2  s . c om
                });
            } catch (Exception e) {

                captchaImage.post(new Runnable() {
                    public void run() {
                        Activity activity = getActivity();

                        if (activity == null)
                            return;

                        Toast.makeText(activity, R.string.toast_error_downloading_captcha, Toast.LENGTH_LONG)
                                .show();
                    }
                });

                e.printStackTrace();
            }
        }
    }).start();
}

From source file:com.vti.managers.DrawableManager.java

public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable(drawableMap.get(urlString));
    } else {/* ww  w .  ja v a  2  s . c  o  m*/
        Thread thread = new Thread() {
            @Override
            public void run() {
                final Drawable drawable = fetchDrawable(urlString);
                if (!drawableMap.containsKey(urlString)) {
                    drawableMap.put(urlString, drawable);
                }
                if (null != drawable) {
                    imageView.post(new Runnable() {
                        @Override
                        public void run() {
                            imageView.setImageDrawable(drawable);
                        }
                    });
                }

            }
        };
        thread.start();
    }

}

From source file:com.social.services.managers.DrawableManager.java

public void fetchDrawableOnThread(final String urlString, final ImageView imageView) {
    if (drawableMap.containsKey(urlString)) {
        imageView.setImageDrawable(drawableMap.get(urlString));
    } else {//from   w w  w.j  a v a2  s. c  o m
        Thread thread = new Thread() {
            @Override
            public void run() {
                final Drawable drawable = fetchDrawable(urlString);
                if (!drawableMap.containsKey(urlString)) {
                    drawableMap.put(urlString, drawable);
                }
                if (null != drawable) {
                    imageView.post(new Runnable() {

                        @Override
                        public void run() {
                            imageView.setImageDrawable(drawable);
                        }
                    });
                }

            }
        };
        thread.start();
    }

}

From source file:com.cw.litenote.note_add.Note_addCameraImage.java

void showContinueConfirmationDialog() {
    setContentView(R.layout.note_add_camera_image);
    setTitle(R.string.note_take_picture_continue_dlg_title);

    // Continue button
    Button okButton = (Button) findViewById(R.id.note_add_new_picture_continue);
    okButton.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_camera, 0, 0, 0);
    // OK/*from  ww  w  .  j  av  a  2s . co  m*/
    okButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {

            // take image without confirmation dialog 
            noteId = null; // set null for Insert
            takeImageWithName();
            UtilImage.bShowExpandedImage = false; // set for getting new row Id
        }
    });

    // cancel button
    Button cancelButton = (Button) findViewById(R.id.note_add_new_picture_cancel);
    cancelButton.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_close_clear_cancel, 0, 0,
            0);
    // cancel
    cancelButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            setResult(RESULT_CANCELED);
            if ((UtilImage.mExpandedImageView != null)
                    && (UtilImage.mExpandedImageView.getVisibility() == View.VISIBLE)
                    && (UtilImage.bShowExpandedImage == true)) {
                UtilImage.closeExpandedImage();
            }
            finish();
        }
    });

    final String pictureUri = cameraImageUri;
    final ImageView imageView = (ImageView) findViewById(R.id.expanded_image_after_take);

    imageView.post(new Runnable() {
        @Override
        public void run() {
            try {
                UtilImage.showImage(imageView, pictureUri, Note_addCameraImage.this);
            } catch (IOException e) {
                e.printStackTrace();
                System.out.println("show image error");
            }
        }
    });
}

From source file:de.hackerspacebremen.fragments.StatusFragment.java

private void startAnimation() {
    final ImageView imgStatus = StatusViewHolder.get().imgStatus;
    StatusViewHolder.get().imgStatus.setBackgroundResource(R.anim.clock_animation);

    // Get the background, which has been compiled to an AnimationDrawable
    // object.//ww  w . j a va 2 s  . co  m
    statusAnimation = (AnimationDrawable) imgStatus.getBackground();

    // Start the animation (looped playback by default).
    imgStatus.post(new Runnable() {

        @Override
        public void run() {
            statusAnimation.start();
        }
    });
}

From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingCursorAdapter.java

/**
 * Show the imageView and start its animation drawable.
 *///ww  w . jav a 2  s.com
private void startAnimation(final ImageView imageView) {
    if (imageView.getVisibility() != View.VISIBLE) {
        Log.v(TAG, "startAnimation");
        imageView.setVisibility(View.VISIBLE);
        final AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
        // On some devices, directly calling start() on the animation does not work.
        // We have to wait until the ImageView is visible before starting the animation.
        imageView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @SuppressWarnings("deprecation")
            @Override
            public void onGlobalLayout() {
                if (!animationDrawable.isRunning()) {
                    imageView.post(() -> {
                        animationDrawable.setVisible(true, false);
                        animationDrawable.start();
                    });
                }
                imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
        });
    }
}

From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java

@Override
public final void zoomTo(float scale, float focalX, float focalY) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        imageView.post(new AnimatedZoomRunnable(getScale(), scale, focalX, focalY));
    }/*from w  ww .  j  a va2s  . co  m*/
}