Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dhaval Patel Dhaval2404

🏠
Working from home
View GitHub Profile
@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() {
View Log Filter
Exclude Tag
^(?!(tag1|tag2|tag3))
Include and Exclde Tag
(?=(IncludeTag1|IncludeTag2|IncludeTag3))(?!(ExcludeTag1))
Samsung Device:
^(?!(ViewRootImpl|dalvikvm|Timeline|OpenGLRenderer|Adreno-EGL|DisplayManagerGlobal|ApplicationPackageManager|DisplayManager|AbsListView|Qmage|GC))
Micromax Device:
@Dhaval2404
Dhaval2404 / Logger.java
Last active Oct 12, 2015
Wrapper class for Android Log. Here it's very easy to print Log on consol as well as you can store log in file also.
View Logger.java
package com.dhaval2404.log
import android.util.Log;
import android.os.Environment;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
You can’t perform that action at this time.