• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java EaseImageCache类的典型用法和代码示例

java 1次浏览

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

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

示例1: onPostExecute

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的package包/类
@Override
protected void onPostExecute(Bitmap result) {
	super.onPostExecute(result);
	pb.setVisibility(View.INVISIBLE);
	photoView.setVisibility(View.VISIBLE);
	if (result != null)
		EaseImageCache.getInstance().put(path, result);
	else
		result = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.ease_default_image);
	photoView.setImageBitmap(result);
}
 

开发者ID:turoDog,
项目名称:KTalk,
代码行数:13,
代码来源:EaseLoadLocalBigImgTask.java

示例2: showVideoThumbView

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的package包/类
/**
 * show video thumbnails
 * 
 * @param localThumb
 *            local path for thumbnail
 * @param iv
 * @param thumbnailUrl
 *            Url on server for thumbnails
 * @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)) {
                            EMClient.getInstance().chatManager().downloadThumbnail(message);
                        }
                    }

                }
            }
        }.execute();
    }
    
}
 

开发者ID:turoDog,
项目名称:KTalk,
代码行数:50,
代码来源:EaseChatRowVideo.java

示例3: showImageView

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的package包/类
/**
 * load image into image view
 * 
 */
private void showImageView(final String thumbernailPath, final String localFullSizePath,final EMMessage message) {
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = EaseImageCache.getInstance().get(thumbernailPath);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        imageView.setImageBitmap(bitmap);
    } else {
        AsyncTaskCompat.executeParallel( new AsyncTask<Object, Void, Bitmap>() {

            @Override
            protected Bitmap doInBackground(Object... args) {
                File file = new File(thumbernailPath);
                if (file.exists()) {
                    return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
                } else if (new File(imgBody.thumbnailLocalPath()).exists()) {
                    return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
                }
                else {
                    if (message.direct() == EMMessage.Direct.SEND) {
                        if (localFullSizePath != null && new File(localFullSizePath).exists()) {
                            return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
                        } else {
                            return null;
                        }
                    } else {
                        return null;
                    }
                }
            }

            protected void onPostExecute(Bitmap image) {
                if (image != null) {
                    imageView.setImageBitmap(image);
                    EaseImageCache.getInstance().put(thumbernailPath, image);
                }
            }
        });
    }
}
 

开发者ID:funnyzhaov,
项目名称:Tribe,
代码行数:44,
代码来源:EaseChatRowImage.java

示例4: showVideoThumbView

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的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)) {
                            EMClient.getInstance().chatManager().downloadThumbnail(message);
                        }
                    }

                }
            }
        }.execute();
    }
    
}
 

开发者ID:Rabbit00,
项目名称:MeifuGO,
代码行数:50,
代码来源:EaseChatRowVideo.java

示例5: onCreate

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的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);
	ProgressBar loadLocalPb = (ProgressBar) findViewById(R.id.pb_load_local);
	default_res = getIntent().getIntExtra("default_image", R.drawable.ease_default_avatar);
	Uri uri = getIntent().getParcelableExtra("uri");
	localFilePath = getIntent().getExtras().getString("localUrl");
	String msgId = getIntent().getExtras().getString("messageId");
	EMLog.d(TAG, "show big msgId:" + msgId );

	//show the image if it exist in local path
	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(msgId != null) {
	    downloadImage(msgId);
	}else {
		image.setImageResource(default_res);
	}

	image.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			finish();
		}
	});
}
 

开发者ID:turoDog,
项目名称:KTalk,
代码行数:47,
代码来源:EaseShowBigImageActivity.java

示例6: showImageView

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的package包/类
/**
 * load image into image view
 * 
 * @param thumbernailPath
 * @param iv
 * @param position
 * @return the image exists or not
 */
private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath,final EMMessage message) {
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = EaseImageCache.getInstance().get(thumbernailPath);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);
        return true;
    } else {
        new AsyncTask<Object, Void, Bitmap>() {

            @Override
            protected Bitmap doInBackground(Object... args) {
                File file = new File(thumbernailPath);
                if (file.exists()) {
                    return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
                } else if (new File(imgBody.thumbnailLocalPath()).exists()) {
                    return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
                }
                else {
                    if (message.direct() == EMMessage.Direct.SEND) {
                        if (localFullSizePath != null && new File(localFullSizePath).exists()) {
                            return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
                        } else {
                            return null;
                        }
                    } else {
                        return null;
                    }
                }
            }

            protected void onPostExecute(Bitmap image) {
                if (image != null) {
                    iv.setImageBitmap(image);
                    EaseImageCache.getInstance().put(thumbernailPath, image);
                } else {
                    if (message.status() == EMMessage.Status.FAIL) {
                        if (EaseCommonUtils.isNetWorkConnected(activity)) {
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    EMClient.getInstance().chatManager().downloadThumbnail(message);
                                }
                            }).start();
                        }
                    }

                }
            }
        }.execute();

        return true;
    }
}
 

开发者ID:turoDog,
项目名称:KTalk,
代码行数:64,
代码来源:EaseChatRowImage.java

示例7: onCreate

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的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");
	localFilePath = getIntent().getExtras().getString("localUrl");
	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:Rabbit00,
项目名称:MeifuGO,
代码行数:53,
代码来源:EaseShowBigImageActivity.java

示例8: downloadImage

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的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();
	File temp = new File(localFilePath);
	final String tempPath = temp.getParent() + "/temp_" + temp.getName();
	final EMCallBack callback = new EMCallBack() {
		public void onSuccess() {

			runOnUiThread(new Runnable() {
				@Override
				public void run() {
                       new File(tempPath).renameTo(new File(localFilePath));

                       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 (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) {
					    return;
					}
					if (pd != null) {
						pd.dismiss();
					}
				}
			});
		}

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

		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() {
                       if (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) {
                           return;
                       }
					pd.setMessage(str2 + progress + "%");
				}
			});
		}
	};

    EMClient.getInstance().chatManager().downloadFile(remoteFilePath, tempPath, headers, callback);

}
 

开发者ID:Rabbit00,
项目名称:MeifuGO,
代码行数:82,
代码来源:EaseShowBigImageActivity.java

示例9: onCreate

点赞 2

import com.hyphenate.easeui.model.EaseImageCache; //导入依赖的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");
	localFilePath = getIntent().getExtras().getString("localUrl");
	String secret = getIntent().getExtras().getString("secret");
	EMLog.d(TAG, "show big image uri:" + uri + " remotepath:" + remotepath);

	//show the image if it exist in local path
	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) { //download image from server
		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:HyphenateInc,
项目名称:Hyphenate-EaseUI-Android,
代码行数:53,
代码来源:EaseShowBigImageActivity.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)