gpt4 book ai didi

java - 如何共享全屏图像android?

转载 作者:行者123 更新时间:2023-11-29 05:06:58 27 4
gpt4 key购买 nike

我通过从服务器获取来在 View 寻呼机中显示图像。我没有显示全屏图像。我添加了通过电子邮件或许多其他选项共享图像的功能。

分享图片的代码

imageView = (TouchImageView) viewpager.findViewWithTag(viewpager
.getCurrentItem());
imageView.setDrawingCacheEnabled(true);
Bitmap bitmap = imageView.getDrawingCache();
String path = Images.Media.insertImage(getContentResolver(), bitmap,
"description", null);
uri = Uri.parse(path);
Intent send_report = new Intent(Intent.ACTION_SEND);
send_report.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
send_report.putExtra(Intent.EXTRA_SUBJECT, "Give Me That Picture");
send_report.putExtra(Intent.EXTRA_STREAM, uri);
send_report.putExtra(Intent.EXTRA_TEXT, "cool picture");
send_report.setType("text/plain");
send_report.setType("image/png");
startActivityForResult(
Intent.createChooser(send_report, "Choose an Email client"), 77);

但共享的图像不是全屏图像。但我想共享实际尺寸的图像。请帮我解决这个问题。

更新查看寻呼机适配器

public class ImagePagerAdapter extends PagerAdapter {
LayoutInflater inflater;
PhotoViewAttacher attacher;
PhotoViewAttacher pic;

private DisplayImageOptions options;
private List<Wallpaper> IMAGES_LIST = AppController.getInstance()
.getPrefManger().getAllImages();




public ImagePagerAdapter(Context context) {
inflater = LayoutInflater.from(context);
options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.ic_empty)
.showImageOnFail(R.drawable.ic_error)
.resetViewBeforeLoading(true).cacheOnDisk(true)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565)
.considerExifParams(true)
.displayer(new FadeInBitmapDisplayer(300)).build();
}

@Override
public Object instantiateItem(ViewGroup container, final int position) {
final View imageLayout = inflater.inflate(
R.layout.item_pager_image, container, false);
assert imageLayout != null;
pos = position;
imageView = (TouchImageView) imageLayout.findViewById(R.id.image);
// pic=new PhotoViewAttacher(imageView);
imageView.setTag(position);

imageView.setOnDoubleTapListener(new OnDoubleTapListener() {

@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
Log.i("hello", "sinfle");
mHandler.removeCallbacks(r);
share.setVisibility(View.VISIBLE);
done.setVisibility(View.VISIBLE);
gimmy.setVisibility(View.VISIBLE);
comment.setVisibility(View.VISIBLE);
mHandler.postDelayed(r, 5 * 1000);
return false;
}

@Override
public boolean onDoubleTapEvent(MotionEvent e) {
// TODO Auto-generated method stub
Log.i("hello", "donl");

return false;
}

@Override
public boolean onDoubleTap(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
});

share.setOnClickListener(new OnClickListener() {

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

});

final ProgressBar spinner = (ProgressBar) imageLayout
.findViewById(R.id.loading);

ImageLoader.getInstance().displayImage(
IMAGES_LIST.get(position).getUrl(), imageView, options,
new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
spinner.setVisibility(View.VISIBLE);
view.setVisibility(View.GONE);
}

@Override
public void onLoadingFailed(String imageUri, View view,
FailReason failReason) {
String message = null;
switch (failReason.getType()) {
case IO_ERROR:
message = "Input/Output error";
break;
case DECODING_ERROR:
message = "Image can't be decoded";
break;
case NETWORK_DENIED:
message = "Downloads are denied";
break;
case OUT_OF_MEMORY:
message = "Out Of Memory error";
break;
case UNKNOWN:
message = "Unknown error";
break;
}
Toast.makeText(view.getContext(), message,
Toast.LENGTH_SHORT).show();

spinner.setVisibility(View.GONE);
}

@Override
public void onLoadingComplete(String imageUri,
View view, Bitmap loadedImage) {
spinner.setVisibility(View.GONE);
view.setVisibility(View.VISIBLE);


}
});

container.addView(imageLayout, 0);
return imageLayout;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}

@Override
public int getCount() {
return IMAGES_LIST.size();
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
}

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
}

@Override
public Parcelable saveState() {
return null;
}

}

最佳答案

你已经设置了 cacheOnDisk(true),所以现在你想通过以下方式从中获取图像:

File cachedImage = imageLoader.getDiscCache().get(imageUrl);
if (cachedImage.exists()) {
/// get your image from file
}

关于java - 如何共享全屏图像android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30097785/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com