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

Java ImageUtils类代码示例

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

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



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

示例1: onPreExecute

import com.hyphenate.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:turoDog,项目名称:KTalk,代码行数:14,代码来源:EaseLoadLocalBigImgTask.java


示例2: showVideoThumbView

import com.hyphenate.util.ImageUtils; //导入依赖的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: showVideoThumbView

import com.hyphenate.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)) {
                            EMClient.getInstance().chatManager().downloadThumbnail(message);
                        }
                    }

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


示例4: doInBackground

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


示例5: onCreate

import com.hyphenate.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);
	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: onCreate

import com.hyphenate.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");
	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


示例7: downloadImage

import com.hyphenate.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();
	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


示例8: onCreate

import com.hyphenate.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");
	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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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