Skip to content

Instantly share code, notes, and snippets.

View rahulshah456's full-sized avatar
🎯
Focusing

Rahul Kumar Shah rahulshah456

🎯
Focusing
View GitHub Profile
private List<MediaImage> queryStorage(String relativePath) {
List<MediaImage> mediaImages = new ArrayList<>();
// query items
String[] projection = new String[] {
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.HEIGHT,
MediaStore.Images.Media.WIDTH,
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
if (savedInstanceState == null) {
initFragments()
} else {
atHome = savedInstanceState.getBoolean("atHome")
/** Basic ISO Date Format for Simple Date Format */
public static final String ISO_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
SimpleDateFormat format = new SimpleDateFormat(ISO_DATE_FORMAT,Locale.ENGLISH);
String dateTimeString = format.format(new Date());
Log.d(TAG, "onCreate: dateTimeString = " + dateTimeString);
try {
Date date = format.parse(dateTimeString);
if (date!=null){
// General Bitmap Function to Merge Respective Array of Images
public Bitmap combineBitmaps(List<Bitmap> bitmapList) {
Bitmap collage;
int width = 0, height=bitmapList.get(0).getHeight();
for (Bitmap bitmap : bitmapList){
width+=bitmap.getWidth();
Log.d(TAG, "combineBitmaps: height = " + bitmap.getHeight());
Log.d(TAG, "combineBitmaps: width = " + bitmap.getWidth());
if (bitmap.getHeight()>height){
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="material_colors">
<item name="red_50" type="color">#fde0dc</item>
<item name="red_100" type="color">#f9bdbb</item>
<item name="red_200" type="color">#f69988</item>
<item name="red_300" type="color">#f36c60</item>
<item name="red_400" type="color">#e84e40</item>
<item name="red_500" type="color">#e51c23</item>
@rahulshah456
rahulshah456 / loadJSONFromAsset()
Created November 2, 2019 17:45
Read Json data from android assets
private String loadJSONFromAsset() {
String json;
try {
InputStream is = mContext.getAssets().open("banners.json");
int size = is.available();
byte[] buffer = new byte[size];
int status = is.read(buffer);
Log.d(TAG, "loadJSONFromAsset: status = " + status);
is.close();
json = new String(buffer, StandardCharsets.UTF_8);
public ArrayList<ImagesFolder> SearchStorage() {
folders.clear();
int position = 0;
Uri uri;
Cursor cursor;
int column_index_data, column_index_folder_name;
String absolutePathOfImage = null;
uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
public void GenerateCheckSum(){
String txnAmount = feeEditText.getText().toString().trim();
//creating payTM object
//containing all the values required
final PayTM payTM = new PayTM(
M_ID,
CHANNEL_ID,