• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ImageUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.easemob.util.ImageUtils的典型用法代码示例。如果您正苦于以下问题:Java ImageUtils类的具体用法?Java ImageUtils怎么用?Java ImageUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ImageUtils类属于com.easemob.util包,在下文中一共展示了ImageUtils类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doInBackground

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
	protected Bitmap doInBackground(Object... args) {
		thumbnailPath = (String)args[0];
		localFullSizePath = (String)args[1];
        remotePath = (String)args[2];
		chatType = (ChatType) args[3];		
		iv = (ImageView)args[4];		
//		if(args[2] != null) {
		    activity = (Activity) args[5];
//		}
		message = (EMMessage) args[6];
		File file = new File(thumbnailPath);
		if(file.exists()){
			return ImageUtils.decodeScaleImage(thumbnailPath, 120, 120);
		}
		else{
			if(message.direct==EMMessage.Direct.SEND)
			{
				return ImageUtils.decodeScaleImage(localFullSizePath, 120, 120);
			}else{
				return null;
			}
		}
		
	}
 
开发者ID:macyuan,项目名称:TAG,代码行数:26,代码来源:LoadImageTask.java


示例2: doInBackground

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Object... args) {
	thumbnailPath = (String) args[0];
	localFullSizePath = (String) args[1];
	remotePath = (String) args[2];
	chatType = (ChatType) args[3];
	iv = (ImageView) args[4];
	// if(args[2] != null) {
	activity = (Activity) args[5];
	// }
	message = (EMMessage) args[6];
	File file = new File(thumbnailPath);
	if (file.exists()) {
		return ImageUtils.decodeScaleImage(thumbnailPath, 160, 160);
	} else {
		if (message.direct == EMMessage.Direct.SEND) {
			return ImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
		} else {
			return null;
		}
	}
	

}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:25,代码来源:LoadImageTask.java


示例3: doInBackground

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Object... params) {
	thumbnailPath = (String) params[0];
	thumbnailUrl = (String) params[1];
	iv = (ImageView) params[2];
	activity = (Activity) params[3];
	message = (EMMessage) params[4];
	adapter = (BaseAdapter) params[5];
	if (new File(thumbnailPath).exists()) {
		return ImageUtils.decodeScaleImage(thumbnailPath, 120, 120);
	} else {
		return null;
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:15,代码来源:LoadVideoImageTask.java


示例4: onPreExecute

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
protected void onPreExecute() {
	super.onPreExecute();
	int degree = ImageUtils.readPictureDegree(path);
	if (degree != 0) {
		pb.setVisibility(View.VISIBLE);
		photoView.setVisibility(View.INVISIBLE);
	} else {
		pb.setVisibility(View.INVISIBLE);
		photoView.setVisibility(View.VISIBLE);
	}

}
 
开发者ID:macyuan,项目名称:TAG,代码行数:14,代码来源:LoadLocalBigImgTask.java


示例5: showVideoThumbView

import com.easemob.util.ImageUtils; //导入依赖的package包/类
/**
 * 展示视频缩略图
 * 
 * @param localThumb
 *            本地缩略图路径
 * @param iv
 * @param thumbnailUrl
 *            远程缩略图路径
 * @param message
 */
private void showVideoThumbView(final String localThumb, final ImageView iv, String thumbnailUrl, final EMMessage message) {
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = EaseImageCache.getInstance().get(localThumb);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);

    } else {
        new AsyncTask<Void, Void, Bitmap>() {

            @Override
            protected Bitmap doInBackground(Void... params) {
                if (new File(localThumb).exists()) {
                    return ImageUtils.decodeScaleImage(localThumb, 160, 160);
                } else {
                    return null;
                }
            }
            
            @Override
            protected void onPostExecute(Bitmap result) {
                super.onPostExecute(result);
                if (result != null) {
                    EaseImageCache.getInstance().put(localThumb, result);
                    iv.setImageBitmap(result);

                } else {
                    if (message.status == EMMessage.Status.FAIL) {
                        if (EaseCommonUtils.isNetWorkConnected(activity)) {
                            EMChatManager.getInstance().asyncFetchMessage(message);
                        }
                    }

                }
            }
        }.execute();
    }
    
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:50,代码来源:EaseChatRowVideo.java


示例6: onPreExecute

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
protected void onPreExecute() {
    super.onPreExecute();
    int degree = ImageUtils.readPictureDegree(path);
    if (degree != 0) {
        pb.setVisibility(View.VISIBLE);
        photoView.setVisibility(View.INVISIBLE);
    } else {
        pb.setVisibility(View.INVISIBLE);
        photoView.setVisibility(View.VISIBLE);
    }

}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:14,代码来源:EaseLoadLocalBigImgTask.java


示例7: showVideoThumbView

import com.easemob.util.ImageUtils; //导入依赖的package包/类
/**
 * 展示视频缩略图
 *
 * @param localThumb   本地缩略图路径
 * @param iv
 * @param thumbnailUrl 远程缩略图路径
 * @param message
 */
private void showVideoThumbView(final String localThumb, final ImageView iv, String thumbnailUrl, final EMMessage message) {
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = EaseImageCache.getInstance().get(localThumb);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);

    } else {
        new AsyncTask<Void, Void, Bitmap>() {

            @Override
            protected Bitmap doInBackground(Void... params) {
                if (new File(localThumb).exists()) {
                    return ImageUtils.decodeScaleImage(localThumb, 160, 160);
                } else {
                    return null;
                }
            }

            @Override
            protected void onPostExecute(Bitmap result) {
                super.onPostExecute(result);
                if (result != null) {
                    EaseImageCache.getInstance().put(localThumb, result);
                    iv.setImageBitmap(result);

                } else {
                    if (message.status == EMMessage.Status.FAIL) {
                        if (EaseCommonUtils.isNetWorkConnected(activity)) {
                            EMChatManager.getInstance().asyncFetchMessage(message);
                        }
                    }

                }
            }
        }.execute();
    }

}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:48,代码来源:EaseChatRowVideo.java


示例8: onCreate

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	setContentView(R.layout.activity_show_big_image);
	super.onCreate(savedInstanceState);

	image = (PhotoView) findViewById(R.id.image);
	loadLocalPb = (ProgressBar) findViewById(R.id.pb_load_local);

	default_res = getIntent().getIntExtra("default_image", R.drawable.default_avatar);
	showAvator = getIntent().getBooleanExtra("showAvator", false);
	username = getIntent().getStringExtra("username");
	deleteAfterDownload = getIntent().getBooleanExtra("delete", false);
	
	Uri uri = getIntent().getParcelableExtra("uri");
	String remotepath = getIntent().getExtras().getString("remotepath");
	String secret=getIntent().getExtras().getString("secret");
	System.err.println("show big image uri:" + uri + " remotepath:" + remotepath);

	if (uri != null && new File(uri.getPath()).exists()) {
		System.err.println("showbigimage file exists. directly show it");
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		// int screenWidth = metrics.widthPixels;
		// int screenHeight =metrics.heightPixels;
		bitmap = ImageCache.getInstance().get(uri.getPath());
		if (bitmap == null) {
			LoadLocalBigImgTask task = new LoadLocalBigImgTask(this, uri.getPath(), image, loadLocalPb, ImageUtils.SCALE_IMAGE_WIDTH,
					ImageUtils.SCALE_IMAGE_HEIGHT);
			if (android.os.Build.VERSION.SDK_INT > 10) {
				task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				task.execute();
			}
		} else {
			image.setImageBitmap(bitmap);
		}
	} else if (remotepath != null) {
		System.err.println("download remote image");
		Map<String,String> maps=new HashMap<String,String>();
		//maps.put("Authorization", "Bearer "+EMChatConfig.getInstance().AccessToken());
		maps.put("Authorization", "Bearer "+EMChatManager.getInstance().getAccessToken());
		if(!TextUtils.isEmpty(secret))
		{
			maps.put("share-secret", secret);
		}
		maps.put("Accept", "application/octet-stream");
		downloadImage(remotepath,maps);
	} else {
		image.setImageResource(default_res);
	}

	image.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			finish();
		}
	});
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:60,代码来源:ShowBigImage.java


示例9: onCreate

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.alert_dialog);
		mTextView = (TextView) findViewById(R.id.title);
		mButton = (Button) findViewById(R.id.btn_cancel);
		imageView = (ImageView) findViewById(R.id.image);
		editText = (EditText) findViewById(R.id.edit);
		//提示内容
		String msg = getIntent().getStringExtra("msg");
		//提示标题
		String title = getIntent().getStringExtra("title");
//		voicePath = getIntent().getStringExtra("voicePath");
		position = getIntent().getIntExtra("position", -1);
		//是否显示取消标题
		boolean isCanceTitle=getIntent().getBooleanExtra("titleIsCancel", false);
		//是否显示取消按钮
		boolean isCanceShow = getIntent().getBooleanExtra("cancel", false);
		//是否显示文本编辑框
		isEditextShow = getIntent().getBooleanExtra("editTextShow",false);
		//转发复制的图片的path
		String path = getIntent().getStringExtra("forwardImage");
		if(msg != null)
		    ((TextView)findViewById(R.id.alert_message)).setText(msg);
		if(title != null)
			mTextView.setText(title);
		if(isCanceTitle){
			mTextView.setVisibility(View.GONE);
		}
		if(isCanceShow)
			mButton.setVisibility(View.VISIBLE);
		if(path != null){
			 //优先拿大图,没有去取缩略图
			if(!new File(path).exists())
				path = DownloadImageTask.getThumbnailImagePath(path);
		    imageView.setVisibility(View.VISIBLE);
		    ((TextView)findViewById(R.id.alert_message)).setVisibility(View.GONE);
		    if(ImageCache.getInstance().get(path) != null){
		        imageView.setImageBitmap(ImageCache.getInstance().get(path));
		    }else{
		        Bitmap bm = ImageUtils.decodeScaleImage(path, 150, 150);
		        imageView.setImageBitmap(bm);
		        ImageCache.getInstance().put(path, bm);
		    }
		    
		}
		if(isEditextShow){
			editText.setVisibility(View.VISIBLE);
			
		}
	}
 
开发者ID:macyuan,项目名称:TAG,代码行数:52,代码来源:AlertDialog.java


示例10: doInBackground

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Void... params) {
	Bitmap bitmap = ImageUtils.decodeScaleImage(path, width, height);
	return bitmap;
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:6,代码来源:LoadLocalBigImgTask.java


示例11: onCreate

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	setContentView(R.layout.ease_activity_show_big_image);
	super.onCreate(savedInstanceState);

	image = (EasePhotoView) findViewById(R.id.image);
	loadLocalPb = (ProgressBar) findViewById(R.id.pb_load_local);
	default_res = getIntent().getIntExtra("default_image", R.drawable.ease_default_avatar);
	Uri uri = getIntent().getParcelableExtra("uri");
	String remotepath = getIntent().getExtras().getString("remotepath");
	String secret = getIntent().getExtras().getString("secret");
	EMLog.d(TAG, "show big image uri:" + uri + " remotepath:" + remotepath);

	//本地存在,直接显示本地的图片
	if (uri != null && new File(uri.getPath()).exists()) {
		EMLog.d(TAG, "showbigimage file exists. directly show it");
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		// int screenWidth = metrics.widthPixels;
		// int screenHeight =metrics.heightPixels;
		bitmap = EaseImageCache.getInstance().get(uri.getPath());
		if (bitmap == null) {
			EaseLoadLocalBigImgTask task = new EaseLoadLocalBigImgTask(this, uri.getPath(), image, loadLocalPb, ImageUtils.SCALE_IMAGE_WIDTH,
					ImageUtils.SCALE_IMAGE_HEIGHT);
			if (android.os.Build.VERSION.SDK_INT > 10) {
				task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				task.execute();
			}
		} else {
			image.setImageBitmap(bitmap);
		}
	} else if (remotepath != null) { //去服务器下载图片
		EMLog.d(TAG, "download remote image");
		Map<String, String> maps = new HashMap<String, String>();
		if (!TextUtils.isEmpty(secret)) {
			maps.put("share-secret", secret);
		}
		downloadImage(remotepath, maps);
	} else {
		image.setImageResource(default_res);
	}

	image.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			finish();
		}
	});
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:52,代码来源:EaseShowBigImageActivity.java


示例12: downloadImage

import com.easemob.util.ImageUtils; //导入依赖的package包/类
/**
 * 下载图片
 * 
 * @param remoteFilePath
 */
private void downloadImage(final String remoteFilePath, final Map<String, String> headers) {
	String str1 = getResources().getString(R.string.Download_the_pictures);
	pd = new ProgressDialog(this);
	pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
	pd.setCanceledOnTouchOutside(false);
	pd.setMessage(str1);
	pd.show();
	localFilePath = getLocalFilePath(remoteFilePath);
	final EMCallBack callback = new EMCallBack() {
		public void onSuccess() {

			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					DisplayMetrics metrics = new DisplayMetrics();
					getWindowManager().getDefaultDisplay().getMetrics(metrics);
					int screenWidth = metrics.widthPixels;
					int screenHeight = metrics.heightPixels;

					bitmap = ImageUtils.decodeScaleImage(localFilePath, screenWidth, screenHeight);
					if (bitmap == null) {
						image.setImageResource(default_res);
					} else {
						image.setImageBitmap(bitmap);
						EaseImageCache.getInstance().put(localFilePath, bitmap);
						isDownloaded = true;
					}
					if (pd != null) {
						pd.dismiss();
					}
				}
			});
		}

		public void onError(int error, String msg) {
			EMLog.e(TAG, "offline file transfer error:" + msg);
			File file = new File(localFilePath);
			if (file.exists()&&file.isFile()) {
				file.delete();
			}
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					pd.dismiss();
					image.setImageResource(default_res);
				}
			});
		}

		public void onProgress(final int progress, String status) {
			EMLog.d(TAG, "Progress: " + progress);
			final String str2 = getResources().getString(R.string.Download_the_pictures_new);
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					
					pd.setMessage(str2 + progress + "%");
				}
			});
		}
	};

    EMChatManager.getInstance().downloadFile(remoteFilePath, localFilePath, headers, callback);

}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:71,代码来源:EaseShowBigImageActivity.java


示例13: EInit

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
public void EInit() {
	super.EInit();
	image = (PhotoView) findViewById(R.id.image);
	loadLocalPb = (ProgressBar) findViewById(R.id.pb_load_local);
	default_res = getIntent().getIntExtra("default_image", R.drawable.mini_avatar_shadow);
	Uri uri = getIntent().getParcelableExtra("uri");
	String remotepath = getIntent().getExtras().getString("remotepath");
	String secret = getIntent().getExtras().getString("secret");
	EMLog.d(TAG, "show big image uri:" + uri + " remotepath:" + remotepath);

	//本地存在,直接显示本地的图片
	if (uri != null && new File(uri.getPath()).exists()) {
		EMLog.d(TAG, "showbigimage file exists. directly show it");
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		// int screenWidth = metrics.widthPixels;
		// int screenHeight =metrics.heightPixels;
		bitmap = ImageCache.getInstance().get(uri.getPath());
		if (bitmap == null) {
			LoadLocalBigImgTask task = new LoadLocalBigImgTask(this, uri.getPath(), image, loadLocalPb, ImageUtils.SCALE_IMAGE_WIDTH,
					ImageUtils.SCALE_IMAGE_HEIGHT);
			if (android.os.Build.VERSION.SDK_INT > 10) {
				task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				task.execute();
			}
		} else {
			image.setImageBitmap(bitmap);
		}
	} else if (remotepath != null) { //去服务器下载图片
		EMLog.d(TAG, "download remote image");
		Map<String, String> maps = new HashMap<String, String>();
		if (!TextUtils.isEmpty(secret)) {
			maps.put("share-secret", secret);
		}
		downloadImage(remotepath, maps);
	} else {
		image.setImageResource(default_res);
	}

	image.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			finish();
		}
	});
}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:49,代码来源:ShowBigImage.java


示例14: downloadImage

import com.easemob.util.ImageUtils; //导入依赖的package包/类
/**
 * 下载图片
 * 
 * @param remoteFilePath
 */
private void downloadImage(final String remoteFilePath, final Map<String, String> headers) {
	String str1 = getResources().getString(R.string.Download_the_pictures);
	pd = new ProgressDialog(this);
	pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
	pd.setCanceledOnTouchOutside(false);
	pd.setMessage(str1);
	pd.show();
	localFilePath = getLocalFilePath(remoteFilePath);
	final EMCallBack callback = new EMCallBack() {
		public void onSuccess() {

			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					DisplayMetrics metrics = new DisplayMetrics();
					getWindowManager().getDefaultDisplay().getMetrics(metrics);
					int screenWidth = metrics.widthPixels;
					int screenHeight = metrics.heightPixels;

					bitmap = ImageUtils.decodeScaleImage(localFilePath, screenWidth, screenHeight);
					if (bitmap == null) {
						image.setImageResource(default_res);
					} else {
						image.setImageBitmap(bitmap);
						ImageCache.getInstance().put(localFilePath, bitmap);
						isDownloaded = true;
					}
					if (pd != null) {
						pd.dismiss();
					}
				}
			});
		}

		public void onError(int error, String msg) {
			EMLog.e(TAG, "offline file transfer error:" + msg);
			File file = new File(localFilePath);
			if (file.exists()&&file.isFile()) {
				file.delete();
			}
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					pd.dismiss();
					image.setImageResource(default_res);
				}
			});
		}

		public void onProgress(final int progress, String status) {
			EMLog.d(TAG, "Progress: " + progress);
			final String str2 = getResources().getString(R.string.Download_the_pictures_new);
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					
					pd.setMessage(str2 + progress + "%");
				}
			});
		}
	};

    EMChatManager.getInstance().downloadFile(remoteFilePath, localFilePath, headers, callback);

}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:71,代码来源:ShowBigImage.java


示例15: onCreate

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	setContentView(R.layout.ease_activity_show_big_image);
	super.onCreate(savedInstanceState);

	image = (EasePhotoView) findViewById(R.id.image);
	loadLocalPb = (ProgressBar) findViewById(R.id.pb_load_local);
	default_res = getIntent().getIntExtra("default_image", R.drawable.ease_default_avatar);
	Uri uri = getIntent().getParcelableExtra("uri");
	String remotepath = getIntent().getExtras().getString("remotepath");
	String secret = getIntent().getExtras().getString("secret");
	msgId = getIntent().getExtras().getString(EaseConstant.EASE_ATTR_REVOKE_MSG_ID);
	
	EMLog.d(TAG, "show big image uri:" + uri + " remotepath:" + remotepath);

	//本地存在,直接显示本地的图片
	if (uri != null && new File(uri.getPath()).exists()) {
		EMLog.d(TAG, "showbigimage file exists. directly show it");
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		// int screenWidth = metrics.widthPixels;
		// int screenHeight =metrics.heightPixels;
		bitmap = EaseImageCache.getInstance().get(uri.getPath());
		if (bitmap == null) {
			EaseLoadLocalBigImgTask task = new EaseLoadLocalBigImgTask(this, uri.getPath(), image, loadLocalPb, ImageUtils.SCALE_IMAGE_WIDTH,
					ImageUtils.SCALE_IMAGE_HEIGHT);
			if (android.os.Build.VERSION.SDK_INT > 10) {
				task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				task.execute();
			}
		} else {
			image.setImageBitmap(bitmap);
		}
	} else if (remotepath != null) { //去服务器下载图片
		EMLog.d(TAG, "download remote image");
		Map<String, String> maps = new HashMap<String, String>();
		if (!TextUtils.isEmpty(secret)) {
			maps.put("share-secret", secret);
		}
		downloadImage(remotepath, maps);
	} else {
		image.setImageResource(default_res);
	}

	image.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
		    removeMessage();
			finish();
		}
	});
}
 
开发者ID:easemob,项目名称:easeui,代码行数:55,代码来源:EaseShowBigImageActivity.java


示例16: onCreate

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	setContentView(R.layout.activity_show_big_image);
	super.onCreate(savedInstanceState);

	image = (PhotoView) findViewById(R.id.image);
	loadLocalPb = (ProgressBar) findViewById(R.id.pb_load_local);
	default_res = getIntent().getIntExtra("default_image", R.drawable.ic_avatar);
	Uri uri = getIntent().getParcelableExtra("uri");
	String remotepath = getIntent().getExtras().getString("remotepath");
	String secret = getIntent().getExtras().getString("secret");
	System.err.println("show big image uri:" + uri + " remotepath:" + remotepath);

	//本地存在,直接显示本地的图片
	if (uri != null && new File(uri.getPath()).exists()) {
		System.err.println("showbigimage file exists. directly show it");
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		// int screenWidth = metrics.widthPixels;
		// int screenHeight =metrics.heightPixels;
		bitmap = ImageCache.getInstance().get(uri.getPath());
		if (bitmap == null) {
			LoadLocalBigImgTask task = new LoadLocalBigImgTask(this, uri.getPath(), image, loadLocalPb, ImageUtils.SCALE_IMAGE_WIDTH,
					ImageUtils.SCALE_IMAGE_HEIGHT);
			if (android.os.Build.VERSION.SDK_INT > 10) {
				task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			} else {
				task.execute();
			}
		} else {
			image.setImageBitmap(bitmap);
		}
	} else if (remotepath != null) { //去服务器下载图片
		System.err.println("download remote image");
		Map<String, String> maps = new HashMap<String, String>();
		if (!TextUtils.isEmpty(secret)) {
			maps.put("share-secret", secret);
		}
		downloadImage(remotepath, maps);
	} else {
		image.setImageResource(default_res);
	}

	image.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			finish();
		}
	});
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:52,代码来源:ShowBigImage.java


示例17: downloadImage

import com.easemob.util.ImageUtils; //导入依赖的package包/类
/**
 * 下载图片
 * 
 * @param remoteFilePath
 */
private void downloadImage(final String remoteFilePath, final Map<String, String> headers) {
	String str1 = getResources().getString(R.string.Download_the_pictures);
	pd = new ProgressDialog(this);
	pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
	pd.setCanceledOnTouchOutside(false);
	pd.setMessage(str1);
	pd.show();
	localFilePath = getLocalFilePath(remoteFilePath);
	final HttpFileManager httpFileMgr = new HttpFileManager(this, EMChatConfig.getInstance().getStorageUrl());
	final CloudOperationCallback callback = new CloudOperationCallback() {
		public void onSuccess(String resultMsg) {

			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					DisplayMetrics metrics = new DisplayMetrics();
					getWindowManager().getDefaultDisplay().getMetrics(metrics);
					int screenWidth = metrics.widthPixels;
					int screenHeight = metrics.heightPixels;

					bitmap = ImageUtils.decodeScaleImage(localFilePath, screenWidth, screenHeight);
					if (bitmap == null) {
						image.setImageResource(default_res);
					} else {
						image.setImageBitmap(bitmap);
						ImageCache.getInstance().put(localFilePath, bitmap);
						isDownloaded = true;
					}
					if (pd != null) {
						pd.dismiss();
					}
				}
			});
		}

		public void onError(String msg) {
			Log.e("###", "offline file transfer error:" + msg);
			File file = new File(localFilePath);
			if (file.exists()&&file.isFile()) {
				file.delete();
			}
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					pd.dismiss();
					image.setImageResource(default_res);
				}
			});
		}

		public void onProgress(final int progress) {
			Log.d("ease", "Progress: " + progress);
			final String str2 = getResources().getString(R.string.Download_the_pictures_new);
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					
					pd.setMessage(str2 + progress + "%");
				}
			});
		}
	};

	new Thread(new Runnable() {
		@Override
		public void run() {
			httpFileMgr.downloadFile(remoteFilePath, localFilePath, headers, callback);
		}
	}).start();
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:76,代码来源:ShowBigImage.java


示例18: onCreate

import com.easemob.util.ImageUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.alert_dialog);
	mTextView = (TextView) findViewById(R.id.title);
	mButton = (Button) findViewById(R.id.btn_cancel);
	imageView = (ImageView) findViewById(R.id.image);
	editText = (EditText) findViewById(R.id.edit);
	//提示内容
	String msg = getIntent().getStringExtra("msg");
	//提示标题
	String title = getIntent().getStringExtra("title");
	position = getIntent().getIntExtra("position", -1);
	//是否显示取消标题
	boolean isCanceTitle=getIntent().getBooleanExtra("titleIsCancel", false);
	//是否显示取消按钮
	boolean isCanceShow = getIntent().getBooleanExtra("cancel", false);
	//是否显示文本编辑框
	isEditextShow = getIntent().getBooleanExtra("editTextShow",false);
	//转发复制的图片的path
	String path = getIntent().getStringExtra("forwardImage");
	//
	String edit_text = getIntent().getStringExtra("edit_text");
	
	if(msg != null)
	    ((TextView)findViewById(R.id.alert_message)).setText(msg);
	if(title != null)
		mTextView.setText(title);
	if(isCanceTitle){
		mTextView.setVisibility(View.GONE);
	}
	if(isCanceShow)
		mButton.setVisibility(View.VISIBLE);
	if(path != null){
		 //优先拿大图,没有去取缩略图
		if(!new File(path).exists())
			path = DownloadImageTask.getThumbnailImagePath(path);
	    imageView.setVisibility(View.VISIBLE);
	    ((TextView)findViewById(R.id.alert_message)).setVisibility(View.GONE);
	    if(ImageCache.getInstance().get(path) != null){
	        imageView.setImageBitmap(ImageCache.getInstance().get(path));
	    }else{
	        Bitmap bm = ImageUtils.decodeScaleImage(path, 150, 150);
	        imageView.setImageBitmap(bm);
	        ImageCache.getInstance().put(path, bm);
	    }
	    
	}
	if(isEditextShow){
		editText.setVisibility(View.VISIBLE);
		editText.setText(edit_text);
	}
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:54,代码来源:AlertDialog.java



注:本文中的com.easemob.util.ImageUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BegunBy类代码示例发布时间:2022-05-23
下一篇:
Java KettleVariablesList类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap