我通过从服务器获取来在视图寻呼机中显示图像。我没有显示全屏图像。我添加了通过电子邮件或许多其他选项共享图像的功能。
分享图片的代码
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;
}
}
答案 0 :(得分:2)
您已经设置了cacheOnDisk(true)
,所以现在您要通过以下方式拍摄图像:
File cachedImage = imageLoader.getDiscCache().get(imageUrl);
if (cachedImage.exists()) {
/// get your image from file
}
答案 1 :(得分:1)
如果您在视图寻呼机中获取当前图像的缓存,则您将获得带有边距的视图寻呼机上显示的视图。您需要从服务器下载图像。获取当前显示图像的URL在视图中寻呼机&amp;从服务器下载图像。这将解决您的问题。