Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dhaval Patel Dhaval2404

🏠
Working from home
View GitHub Profile
@Dhaval2404
Dhaval2404 / InputStreamRequestBody.kt
Last active May 20, 2021
Upload Uri using Retrofit
View InputStreamRequestBody.kt
import android.content.ContentResolver
import android.content.Context
import android.net.Uri
import android.provider.OpenableColumns
import android.webkit.MimeTypeMap
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okio.BufferedSink
import okio.source
@Dhaval2404
Dhaval2404 / main.dart
Created Apr 18, 2021
Geolocator didChangeAppLifecycleState loop issue
View main.dart
import 'dart:async';
import 'package:baseflow_plugin_template/baseflow_plugin_template.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
/// Defines the main theme color.
final MaterialColor themeMaterialColor =
BaseflowPluginExample.createMaterialColor(
const Color.fromRGBO(48, 49, 60, 1));
@Dhaval2404
Dhaval2404 / Adapter Template
Created May 5, 2020
Android Studio Template
View Adapter Template
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME} #end
import androidx.recyclerview.widget.RecyclerView
#parse("File Header.java")
class ${NAME} : BaseAdapter<${MODEL_CLASS}, {BINDING_CLASS}, ${NAME}.${VIEWHOLDER_CLASS}>() {
override fun getLayout() = R.layout.${LAYOUT_FILE_NAME}
override fun getViewHolder(binding: ${VIEWHOLDER_CLASS}) =
View ImagePickerActivity.kt
package com.github.dhaval2404.imagepicker.util
import android.content.Intent
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
/**
* Inline Activity Result
@Dhaval2404
Dhaval2404 / ImagePickerActivity.java
Last active Apr 24, 2019
Image Picker Demo Activity
View ImagePickerActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.github.dhaval2404.imagepicker.ImagePicker;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
View android-studio.desktop
[Desktop Entry]
Encoding=UTF-8
Version=2.2.3
Type=Application
Terminal=false
Icon=someicon
Exec=sh /path/to/android-studio-2.2.3/bin/studio.sh
Icon=/path/to/android-studio-2.2.3/bin/studio.png
Name=Android Studio 2.2.3
Categories=Application;Development;Java;IDE;Android
@Dhaval2404
Dhaval2404 / build.gradle
Created Jan 17, 2017
Change build apk file name.
View build.gradle
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def setOutputAPKName(applicationVariants) {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def SEPARATOR = "_"
def project = "AppName"
def buildType = variant.variantData.variantConfiguration.buildType.name
def versionName = "v" + variant.versionName
View pull_private_data.sh
#Run this script to copy android app private data to your desktop. Use below command
#./pull_private_data.sh app_package_name local_directory_path >> ./pull_private_data.sh com.niyantras.homifiandroid /home/dhaval/app_data
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
packageName=$1;
localDirectory=$2;
echo "Package Name=$packageName"
View Stetho
//In Application Class
@Override
public void onCreate() {
super.onCreate();
Stetho.InitializerBuilder initializerBuilder =
Stetho.newInitializerBuilder(this);
// Enable Chrome DevTools
initializerBuilder.enableWebKitInspector(
@Dhaval2404
Dhaval2404 / AppCompactBaseDialogFragment.java
Created Jun 22, 2016
AppCompatDialogFragment Dialog with fullscreen and No Title
View AppCompactBaseDialogFragment.java
public abstract class AppCompactBaseDialogFragment extends AppCompatDialogFragment{
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE, 0);
}
@Override
public void onResume() {