本文整理匯總了Java中android.graphics.drawable.Drawable.createFromPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.createFromPath方法的具體用法?Java Drawable.createFromPath怎麽用?Java Drawable.createFromPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.createFromPath方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActivityResult
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_RQ) {
if (resultCode == RESULT_OK) {
imagePath = data.getDataString().replace("file:", "");
ImageUtil.saveThumbnail(imagePath);
drawable = Drawable.createFromPath(imagePath);
entryImage.setImageDrawable(drawable);
} else if(data != null) {
Exception e = (Exception) data.getSerializableExtra(MaterialCamera.ERROR_EXTRA);
e.printStackTrace();
}
}
}
示例2: getView
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(mResource, parent, false);
}
LogEntry entry = logEntries.get(position);
date = (TextView) convertView.findViewById(R.id.log_info_date);
date.setText(entry.getDate());
desc = (TextView) convertView.findViewById(R.id.log_info_desc);
desc.setText(entry.getDescription());
if (entry.getImageLocation() != null && !entry.getImageLocation().equals("")) {
entryImage = (ImageView) convertView.findViewById(R.id.entry_image);
Drawable d = Drawable.createFromPath(entry.getImageLocation());
entryImage.setImageDrawable(d);
}
return convertView;
}
示例3: getView
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Plant plant = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(mResource, parent, false);
}
TextView plantName = (TextView) convertView.findViewById(R.id.plant_name);
plantName.setText(plant.getName());
TextView plantStartDate = (TextView) convertView.findViewById(R.id.plant_start_date);
plantStartDate.setText(plant.getStartDate());
ImageView plantImage = (ImageView) convertView.findViewById(R.id.plant_image);
Drawable d = Drawable.createFromPath(plant.getImageLocation());
plantImage.setImageDrawable(d);
return convertView;
}
示例4: setBackground
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void setBackground() {
String type = Setting.getBType(this);
//display("Type is " + type);
switch (type) {
case Setting.TYPE_COLOR:
gameRl.setBackgroundColor(Setting.getBColor(this));
break;
case Setting.TYPE_IMAGE:
Uri path = Setting.getBImage(this);
File f = new File(getRealPathFromURI(path));
Drawable d = Drawable.createFromPath(f.getAbsolutePath());
gameRl.setBackground(d);
break;
default:
gameRl.setBackgroundResource(R.drawable.wood_small);
break;
}
}
示例5: getDrawableFromDisk
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Nullable
private Drawable getDrawableFromDisk(File file) {
Drawable drawable = Drawable.createFromPath(file.getAbsolutePath());
if (drawable != null) {
int picHeight = calculatePicHeight(drawable);
drawable.setBounds(0, 0, mPicWidth, picHeight);
}
return drawable;
}
示例6: getByPath
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* get drawable by path
*
* @param filePath
* @return
*/
public static Drawable getByPath(final String filePath) {
Drawable drawable = WeakCache.getCache(TAG).get(filePath);
if (drawable == null) {
try {
drawable = Drawable.createFromPath(filePath);
WeakCache.getCache(TAG).put(filePath, drawable);
} catch (Throwable e){
LogUtil.e("[DrawableUtil-getByPath Failed]", e);
}
}
return drawable;
}
示例7: onActivityResult
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_RQ) {
if (resultCode == RESULT_OK) {
imagePath = data.getDataString().replace("file:", "");
ImageUtil.saveImage(imagePath);
Drawable d = Drawable.createFromPath(imagePath);
addImageButton.setImageDrawable(d);
} else if(data != null) {
Exception e = (Exception) data.getSerializableExtra(MaterialCamera.ERROR_EXTRA);
e.printStackTrace();
}
}
}
示例8: loadWallpaper
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void loadWallpaper() {
Settings settings = new Settings();
settings = settingsService.loadByName(Const.SETTINGS.SETTINGS_WALLPAPER);
if (!settings.getValue().equals(Const.SETTINGS.SETTINGS_WALLPAPER_DEFAULT)) {
Drawable back = Drawable.createFromPath(settings.getValue());
wallpaper.setImageDrawable(back);
wallpaper.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
wallpaper.setImageDrawable(null);
}
}
示例9: createFromPathBuffer
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static Drawable createFromPathBuffer(String str) {
Drawable drawable = null;
try {
drawable = Drawable.createFromPath(str);
} catch (OutOfMemoryError e) {
Log.w(TAG, "Resutil fetchImage OutOfMemoryError:" + e.toString());
}
return drawable;
}
示例10: getArtworkDownloaded
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* Return the artwork saved previously
* Retrieve it from sdcard with the name bounded to the albumid
*
* @param context
* @param albumid
* @return
*/
public static Drawable getArtworkDownloaded(Context context, long albumid) {
Drawable bm;
String path = (context
.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
+ "/.Thunder_Music/" + Long.toString(albumid) + ".jpg");
bm = Drawable.createFromPath(path);
return bm;
}
示例11: onCreate
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle data = getIntent().getExtras();
if (data.containsKey("plant")) {
currentPlant = (Plant) data.getSerializable("plant");
}
editImage = null;
if (data.containsKey("log_image")) {
editImage = data.getString("log_image");
imagePath = editImage;
}
editNote = null;
if (data.containsKey("log_notes")) {
editNote = data.getString("log_notes");
}
editDesc = null;
if (data.containsKey("log_desc")) {
editDesc = data.getString("log_desc");
}
editId = 0;
if (data.containsKey("log_id")) {
editId = data.getInt("log_id");
}
entryDescription = (EditText) findViewById(R.id.entry_description);
entryNotes = (EditText) findViewById(R.id.entry_notes);
entryImage = (ImageButton) findViewById(R.id.add_image_button);
dateCalendar = (CalendarView) findViewById(R.id.date_calendar);
setDate = new Date();
dateCalendar.setOnDateClickListener(new CalendarView.OnDateClickListener() {
@Override
public void onDateClick(Date date) {
setDate = date;
}
});
entryNotes.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
return false;
}
});
if (editDesc != null) {
entryDescription.setText(editDesc);
}
if (editNote != null) {
entryNotes.setText(editNote);
}
if (editImage != null) {
drawable = Drawable.createFromPath(editImage);
entryImage.setImageDrawable(drawable);
}
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
HashMap<String, Serializable> map = new HashMap<String, Serializable>();
map.put("plant", currentPlant);
setToolbarClickBackButton(PlantInfoActivity.class, map);
setTitle("Add Log Entry");
}
示例12: doBindTask
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void doBindTask() {
File cachedFile;
try {
cachedFile = SocialResHelper.getCachedFile(this.mContext, this.mUrl);
} catch (Exception e) {
Log.e(SocialResHelper.TAG, "can't get from cache.", e);
if (this.mBindListener != null) {
this.mBindListener.onEnd(STATUS.FAIL, null, null);
}
cachedFile = null;
}
Drawable createFromPath;
switch (this.mLoadMode) {
case LOAD_CACHE_ONLY:
if (this.mBindListener != null) {
this.mBindListener.onStart(LoadMode.LOAD_CACHE_ONLY);
this.mBindListener.onFetchStart(FetchLocale.FETCH_FROM_LOCALE_CACHE);
}
if (cachedFile == null || !cachedFile.exists()) {
Log.e(SocialResHelper.TAG, "cache is not exists");
return;
}
createFromPath = Drawable.createFromPath(cachedFile.getAbsolutePath());
if (createFromPath == null) {
cachedFile.delete();
}
doBind(this.mContext, this.mImageView, createFromPath, this.isBackground,
this.mBindListener, this.mBindAnimation, this.mTransRoundCorner, this
.mDefaultRid);
return;
case LOAD_CACHE_ELSE_NETWORK:
if (this.mBindListener != null) {
this.mBindListener.onStart(LoadMode.LOAD_CACHE_ELSE_NETWORK);
this.mBindListener.onFetchStart(FetchLocale.FETCH_FROM_LOCALE_CACHE);
}
if (cachedFile == null || !cachedFile.exists()) {
fetchNetElsCache(null);
return;
}
createFromPath = Drawable.createFromPath(cachedFile.getAbsolutePath());
if (createFromPath == null) {
cachedFile.delete();
}
doBind(this.mContext, this.mImageView, createFromPath, this.isBackground,
this.mBindListener, this.mBindAnimation, this.mTransRoundCorner, this
.mDefaultRid);
return;
case LOAD_NETWORK_ELSE_CACHE:
if (this.mBindListener != null) {
this.mBindListener.onStart(LoadMode.LOAD_NETWORK_ELSE_CACHE);
}
fetchNetElsCache(null);
return;
default:
return;
}
}