com.easemob.util.ImageUtils Java Examples
The following examples show how to use
com.easemob.util.ImageUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadImageTask.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
@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; } } }
Example #2
Source File: LoadImageTask.java From school_shop with MIT License | 6 votes |
@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; } } }
Example #3
Source File: EaseLoadLocalBigImgTask.java From monolog-android with MIT License | 5 votes |
@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); } }
Example #4
Source File: EaseChatRowVideo.java From monolog-android with MIT License | 5 votes |
/** * 展示视频缩略图 * * @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(); } }
Example #5
Source File: LoadVideoImageTask.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
@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; } }
Example #6
Source File: LoadLocalBigImgTask.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
@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); } }
Example #7
Source File: LoadLocalBigImgTask.java From school_shop with MIT License | 5 votes |
@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); } }
Example #8
Source File: EaseLoadLocalBigImgTask.java From monolog-android with MIT License | 4 votes |
@Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = ImageUtils.decodeScaleImage(path, width, height); return bitmap; }
Example #9
Source File: EaseShowBigImageActivity.java From monolog-android with MIT License | 4 votes |
@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(); } }); }
Example #10
Source File: EaseShowBigImageActivity.java From monolog-android with MIT License | 4 votes |
/** * 下载图片 * * @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); }
Example #11
Source File: ShowBigImage.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
@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); 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(); } }); }
Example #12
Source File: ShowBigImage.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
/** * 下载图片 * * @param remoteFilePath */ private void downloadImage(final String remoteFilePath, final Map<String, String> headers) { pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setCanceledOnTouchOutside(false); pd.setMessage("下载图片: 0%"); 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); runOnUiThread(new Runnable() { @Override public void run() { pd.setMessage("下载图片: " + progress + "%"); } }); } }; new Thread(new Runnable() { @Override public void run() { httpFileMgr.downloadFile(remoteFilePath, localFilePath, headers, callback); } }).start(); }
Example #13
Source File: LoadLocalBigImgTask.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
@Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = ImageUtils.decodeScaleImage(path, width, height); return bitmap; }
Example #14
Source File: ShowBigImage.java From school_shop with MIT License | 4 votes |
@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(); } }); }
Example #15
Source File: ShowBigImage.java From school_shop with MIT License | 4 votes |
/** * 下载图片 * * @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(); }
Example #16
Source File: LoadLocalBigImgTask.java From school_shop with MIT License | 4 votes |
@Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = ImageUtils.decodeScaleImage(path, width, height); return bitmap; }