use of com.bumptech.glide.request.RequestOptions in project PhotoBlog-Android-Blog-App by akshayejh.
the class SetupActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setup);
Toolbar setupToolbar = findViewById(R.id.setupToolbar);
setSupportActionBar(setupToolbar);
getSupportActionBar().setTitle("Account Setup");
firebaseAuth = FirebaseAuth.getInstance();
user_id = firebaseAuth.getCurrentUser().getUid();
firebaseFirestore = FirebaseFirestore.getInstance();
storageReference = FirebaseStorage.getInstance().getReference();
setupImage = findViewById(R.id.setup_image);
setupName = findViewById(R.id.setup_name);
setupBtn = findViewById(R.id.setup_btn);
setupProgress = findViewById(R.id.setup_progress);
setupProgress.setVisibility(View.VISIBLE);
setupBtn.setEnabled(false);
firebaseFirestore.collection("Users").document(user_id).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
if (task.getResult().exists()) {
String name = task.getResult().getString("name");
String image = task.getResult().getString("image");
mainImageURI = Uri.parse(image);
setupName.setText(name);
RequestOptions placeholderRequest = new RequestOptions();
placeholderRequest.placeholder(R.drawable.default_image);
Glide.with(SetupActivity.this).setDefaultRequestOptions(placeholderRequest).load(image).into(setupImage);
}
} else {
String error = task.getException().getMessage();
Toast.makeText(SetupActivity.this, "(FIRESTORE Retrieve Error) : " + error, Toast.LENGTH_LONG).show();
}
setupProgress.setVisibility(View.INVISIBLE);
setupBtn.setEnabled(true);
}
});
setupBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String user_name = setupName.getText().toString();
if (!TextUtils.isEmpty(user_name) && mainImageURI != null) {
setupProgress.setVisibility(View.VISIBLE);
if (isChanged) {
user_id = firebaseAuth.getCurrentUser().getUid();
File newImageFile = new File(mainImageURI.getPath());
try {
compressedImageFile = new Compressor(SetupActivity.this).setMaxHeight(125).setMaxWidth(125).setQuality(50).compressToBitmap(newImageFile);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
compressedImageFile.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] thumbData = baos.toByteArray();
UploadTask image_path = storageReference.child("profile_images").child(user_id + ".jpg").putBytes(thumbData);
image_path.addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
storeFirestore(task, user_name);
} else {
String error = task.getException().getMessage();
Toast.makeText(SetupActivity.this, "(IMAGE Error) : " + error, Toast.LENGTH_LONG).show();
setupProgress.setVisibility(View.INVISIBLE);
}
}
});
} else {
storeFirestore(null, user_name);
}
}
}
});
setupImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(SetupActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(SetupActivity.this, "Permission Denied", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(SetupActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 1);
} else {
BringImagePicker();
}
} else {
BringImagePicker();
}
}
});
}
use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.
the class GlideUtils method loadImageViewPriority.
// 设置下载优先级
public static void loadImageViewPriority(Context mContext, String path, ImageView mImageView) {
RequestOptions options = new RequestOptions().priority(Priority.NORMAL);
Glide.with(mContext).load(path).apply(options).into(mImageView);
}
use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.
the class GlideUtils method loadImageViewLodingSize.
// 设置加载中以及加载失败图片并且指定大小
public static void loadImageViewLodingSize(Context mContext, String path, int width, int height, ImageView mImageView, int lodingImage, int errorImageView) {
RequestOptions options = new RequestOptions().centerCrop().override(width, height).placeholder(lodingImage).error(errorImageView);
Glide.with(mContext).load(path).apply(options).into(mImageView);
}
use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.
the class GlideUtils method loadImageViewCache.
// 设置跳过内存缓存
public static void loadImageViewCache(Context mContext, String path, ImageView mImageView) {
RequestOptions options = new RequestOptions().skipMemoryCache(true);
Glide.with(mContext).load(path).apply(options).into(mImageView);
}
use of com.bumptech.glide.request.RequestOptions in project MyBaseApplication by BanShouWeng.
the class GlideUtils method loadImageViewDiskCache.
/**
* 策略解说:
* <p>
* all:缓存源资源和转换后的资源
* <p>
* none:不作任何磁盘缓存
* <p>
* source:缓存源资源
* <p>
* result:缓存转换后的资源
*/
// 设置缓存策略
public static void loadImageViewDiskCache(Context mContext, String path, ImageView mImageView) {
RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL);
Glide.with(mContext).load(path).apply(options).into(mImageView);
}
Aggregations