Skip to content

Instantly share code, notes, and snippets.

View CapTen101's full-sized avatar
🏸

Tushar Rohilla CapTen101

🏸
View GitHub Profile
@CapTen101
CapTen101 / README.md
Created November 24, 2023 19:59 — forked from piyushgarg-dev/README.md
Kafka Crash Course
shutdown /s /t xxx :: xxx -> seconds before shutdown
@CapTen101
CapTen101 / hideKeyboard.java
Created February 19, 2021 19:47
This method will hide the input keyboard in Android
public static void hideKeyboard(Context context, View view) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@CapTen101
CapTen101 / saveBitmapToFile.java
Last active February 19, 2021 19:25
This gist contains few functions that can take in an image and return a compressed vesion of that image in Bitmap or File form
public File saveBitmapToFile(File file) {
try {
// BitmapFactory options to downsize the image
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
o.inSampleSize = 6;
// factor of downsizing the image
FileInputStream inputStream = new FileInputStream(file);
@CapTen101
CapTen101 / cameraAndroidX.java
Created February 19, 2021 12:19
This gist contains the code from another resource just to keep it safe and for my quick reference.
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.ImageAnalysis;
import androidx.camera.core.ImageCapture;
import androidx.camera.core.ImageCaptureException;
import androidx.camera.core.Preview;
import androidx.camera.extensions.HdrImageCaptureExtender;
import androidx.camera.lifecycle.ProcessCameraProvider;
inputStream.close();
outputStream.close();
Uri copyImage = Uri.fromFile(copyImageFile);