I Fetch Images from firebase database how can i make the wallpapers fit the screen i have tried the fitScale:XY but didnt work alos the function createdBitmap.
the problem is not with firebase I want to fit the image to the screen size of any device.
How can I convert the int (position) into something Bitmap can read if the solution is with the bitmap functions.
private void clickListener() {
adapter.onDataPass(new SwiperAdapter.onDataPass() {
@Override
public void onImageSave(int position, Bitmap bitmap) {
Dexter.withContext(SwiperActivity.this)
.withPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
if (multiplePermissionsReport.areAllPermissionsGranted()) {
saveImage(bitmap);
} else {
Toast.makeText(SwiperActivity.this, "please allow permission", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
permissionToken.continuePermissionRequest();
}
})
.check();
}
@Override
public void onApplyImage(int position, Bitmap bitmap) {
WallpaperManager manager = WallpaperManager.getInstance(getApplicationContext());
Toast.makeText(SwiperActivity.this,"Wallpaper successfully set",Toast.LENGTH_SHORT).show();
try {
manager.setBitmap(bitmap);
}catch (IOException e){
e.printStackTrace();
Toast.makeText(SwiperActivity.this,"Failed to set as wallpaper", Toast.LENGTH_SHORT).show();
}
}
});
}
private void clickListener(int position){
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
dataPass.onImageSave(position,bitmap);
}
});
applyWallBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
dataPass.onApplyImage(position,bitmap);
}
});
}
I want the images to fit the screen I have tried many solutions none of them worked like fitScale:XY and the createBitmap function idk what is the problem?