Skip to content

Instantly share code, notes, and snippets.

View hitesh-dhamshaniya's full-sized avatar
🎯
Focusing

Hitesh Dhamshaniya hitesh-dhamshaniya

🎯
Focusing
View GitHub Profile
@hitesh-dhamshaniya
hitesh-dhamshaniya / InfinitePagerAdapter.java
Created October 17, 2017 05:32
Endless View Pager for Android
package com.infiteviewpager;
import android.database.DataSetObserver;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import com.devdigital.providence.utils.Logger;
@hitesh-dhamshaniya
hitesh-dhamshaniya / AESHelper.java
Created June 22, 2017 06:01
AESHelper for Encrypt and decrypt
package com.utils;
import android.util.Base64;
import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@hitesh-dhamshaniya
hitesh-dhamshaniya / Single Selection in Group NavigatioView Android
Created May 6, 2017 13:23
How to set shared checkable behavior across all groups in NavigationView?
Here's the solution.
Step 1: Remove
android:checkableBehavior="single"
from both groups.
Step 2: Add the following logic to the listener:
mUiNavigationView.setNavigationItemSelectedListener(
@hitesh-dhamshaniya
hitesh-dhamshaniya / Transparent status bar
Created May 2, 2017 08:51
FullScreenAndroid - Transparent status bar
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
//use this to make transparent both status and navigationbar, add 24dp marginTop to toolbar in xml
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// use this to make transparent status bar, No need to add 24dp marginTop to toolbar.
/*w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
w.setExitTransition(null);
}
}
Here I would like to make list of good useful libs. starting with TarsosDSP sound lib
1) https://github.com/JorenSix/TarsosDSP
2) http://cmusphinx.sourceforge.net/wiki/tutorialandroid
public Bitmap getScreenshotFromRecyclerView(RecyclerView view) {
RecyclerView.Adapter adapter = view.getAdapter();
Bitmap bigBitmap = null;
if (adapter != null) {
int size = adapter.getItemCount();
int height = 0;
Paint paint = new Paint();
int iHeight = 0;
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
@hitesh-dhamshaniya
hitesh-dhamshaniya / Full Screen
Created July 18, 2016 06:21
Full Screen Appcompact Activity Transparent Navigation and Status bar
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
@hitesh-dhamshaniya
hitesh-dhamshaniya / gist:3f3723ed441b8be254357e66d6186b57
Created June 28, 2016 13:32
SMTP Mail sender help to send mail from Android application without user interaction.
public class SmtpSendMail {
public static void sendMail() {
// Recipient's email ID needs to be mentioned.
String to = "hitesh.dhamshaniya@devdigital.com";
// Sender's email ID needs to be mentioned
String from = to;//"web@gmail.com";
// Assuming you are sending email from localhost
// String host = "localhost";
/**
* Performs rotation over bitmap
*
* @param bitmap
* Input bitmap for rotate
* @param orientation
* Value of image orientation
* @return Rotated bitmap
*/
public static Bitmap rotateBitmap(Bitmap bitmap, int orientation) {
import android.util.Base64;
import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import javax.crypto.BadPaddingException;