Search in sources :

Example 1 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project Meizhi by drakeet.

the class PictureActivity method setupPhotoAttacher.

private void setupPhotoAttacher() {
    mPhotoViewAttacher = new PhotoViewAttacher(mImageView);
    mPhotoViewAttacher.setOnViewTapListener((view, v, v1) -> hideOrShowToolbar());
    // @formatter:off
    mPhotoViewAttacher.setOnLongClickListener(v -> {
        new AlertDialog.Builder(PictureActivity.this).setMessage(getString(R.string.ask_saving_picture)).setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss()).setPositiveButton(android.R.string.ok, (dialog, which) -> {
            saveImageToGallery();
            dialog.dismiss();
        }).show();
        return true;
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) ToolbarActivity(me.drakeet.meizhi.ui.base.ToolbarActivity) Environment(android.os.Environment) Shares(me.drakeet.meizhi.util.Shares) Toasts(me.drakeet.meizhi.util.Toasts) ImageView(android.widget.ImageView) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) File(java.io.File) MenuItem(android.view.MenuItem) Picasso(com.squareup.picasso.Picasso) RxMeizhi(me.drakeet.meizhi.util.RxMeizhi) AlertDialog(android.support.v7.app.AlertDialog) MobclickAgent(com.umeng.analytics.MobclickAgent) Menu(android.view.Menu) Bind(butterknife.Bind) ViewCompat(android.support.v4.view.ViewCompat) R(me.drakeet.meizhi.R) Subscription(rx.Subscription) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher)

Example 2 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project 9GAG by Mixiaoxiao.

the class MxxScaleImageView method initAttacher.

public void initAttacher() {
    mPhotoViewAttacher = new PhotoViewAttacher(this);
    mPhotoViewAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View arg0, float arg1, float arg2) {
            //				((View)getParent()).setBackgroundColor(Color.argb(0, 0, 0, 0));
            if (imageViewListener != null)
                imageViewListener.onSingleTap();
        }
    });
    mPhotoViewAttacher.setScaleType(ScaleType.FIT_CENTER);
    mPhotoViewAttacher.update();
}
Also used : PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) MxxBlurView(com.mixiaoxiao.android.blur.MxxBlurView) View(android.view.View)

Example 3 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project Talon-for-Twitter by klinker24.

the class PhotoFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    activity = getActivity();
    Bundle args = getArguments();
    url = args.getString("url");
    final View root = inflater.inflate(R.layout.photo_dialog_layout, container, false);
    picture = (NetworkedCacheableImageView) root.findViewById(R.id.picture);
    PhotoViewAttacher mAttacher = new PhotoViewAttacher(picture);
    picture.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() {

        @Override
        public void onImageLoaded(CacheableBitmapDrawable result) {
            LinearLayout spinner = (LinearLayout) root.findViewById(R.id.list_progress);
            spinner.setVisibility(View.GONE);
        }
    }, 0, // no transform
    true);
    mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            try {
                activity.finish();
            } catch (Exception e) {
            // activity is null
            }
        }
    });
    return root;
}
Also used : NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) Bundle(android.os.Bundle) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) LinearLayout(android.widget.LinearLayout)

Example 4 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project Talon-for-Twitter by klinker24.

the class PhotoViewerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    try {
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    } catch (Exception e) {
        Log.e(LOGGER_TAG, "", e);
    }
    if (Build.VERSION.SDK_INT > 18) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    url = getIntent().getStringExtra("url");
    if (url == null) {
        finish();
        return;
    }
    // get higher quality imgur pictures
    if (url.contains("imgur")) {
        url = url.replace("t.jpg", ".jpg");
    }
    if (url.contains("insta")) {
        url = url.substring(0, url.length() - 1) + "l";
    }
    boolean fromCache = getIntent().getBooleanExtra("from_cache", true);
    boolean doRestart = getIntent().getBooleanExtra("restart", true);
    final boolean fromLauncher = getIntent().getBooleanExtra("from_launcher", false);
    AppSettings settings = new AppSettings(context);
    if (Build.VERSION.SDK_INT > 18 && settings.uiExtras) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
    setContentView(R.layout.photo_dialog_layout);
    if (!doRestart || getIntent().getBooleanExtra("config_changed", false)) {
        LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
        spinner.setVisibility(View.GONE);
    }
    picture = (NetworkedCacheableImageView) findViewById(R.id.picture);
    PhotoViewAttacher mAttacher = new PhotoViewAttacher(picture);
    picture.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() {

        @Override
        public void onImageLoaded(CacheableBitmapDrawable result) {
            LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
            spinner.setVisibility(View.GONE);
        }
    }, 0, // no transform
    fromCache);
    mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            ((Activity) context).finish();
        }
    });
    ActionBar ab = getActionBar();
    if (ab != null) {
        ColorDrawable transparent = new ColorDrawable(getResources().getColor(android.R.color.transparent));
        ab.setBackgroundDrawable(transparent);
        ab.setDisplayHomeAsUpEnabled(false);
        ab.setDisplayShowHomeEnabled(false);
        ab.setTitle("");
        ab.setIcon(transparent);
    }
}
Also used : AppSettings(com.klinker.android.twitter.settings.AppSettings) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) View(android.view.View) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) LinearLayout(android.widget.LinearLayout) ActionBar(android.app.ActionBar)

Example 5 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project 9GAG by stormzhang.

the class ImageViewActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_imageview);
    ButterKnife.inject(this);
    setTitle(R.string.view_big_image);
    mAttacher = new PhotoViewAttacher(photoView);
    mAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

        @Override
        public void onPhotoTap(View view, float x, float y) {
            finish();
        }
    });
    String imageUrl = getIntent().getStringExtra(IMAGE_URL);
    DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisc(true).considerExifParams(true).build();
    ImageLoader.getInstance().displayImage(imageUrl, photoView, options, new SimpleImageLoadingListener() {

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            progressWheel.setVisibility(View.GONE);
            mAttacher.update();
        }
    }, new ImageLoadingProgressListener() {

        @Override
        public void onProgressUpdate(String imageUri, View view, int current, int total) {
            progressWheel.setProgress(360 * current / total);
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ImageLoadingProgressListener(com.nostra13.universalimageloader.core.assist.ImageLoadingProgressListener) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) InjectView(butterknife.InjectView) PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)16 View (android.view.View)12 ImageView (android.widget.ImageView)11 Bitmap (android.graphics.Bitmap)4 Bundle (android.os.Bundle)4 TextView (android.widget.TextView)4 Intent (android.content.Intent)3 LinearLayout (android.widget.LinearLayout)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Menu (android.view.Menu)2 ButterKnife (butterknife.ButterKnife)2 InjectView (butterknife.InjectView)2 NetworkedCacheableImageView (com.klinker.android.twitter.views.NetworkedCacheableImageView)2 CacheableBitmapDrawable (uk.co.senab.bitmapcache.CacheableBitmapDrawable)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Resources (android.content.res.Resources)1 TypedArray (android.content.res.TypedArray)1