Skip to content

Instantly share code, notes, and snippets.

View deepak786's full-sized avatar
🎯
Focusing

Deepak Goyal deepak786

🎯
Focusing
View GitHub Profile
@deepak786
deepak786 / InstagramLikeColorTransition.txt
Last active April 27, 2022 14:30
Instagram Like Gradient Color Transition in Android
/******This Gist explains how to create instagram like Gradient color transition in android.******/
1. Create some gradient color drawables inside drawable Folder.
a) color1.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#c44e4e"
android:endColor="#dcb9b9"
android:angle="0"/>
@deepak786
deepak786 / VerticalViewPager.java
Created January 19, 2016 23:51
Vertical View Pager with Depth Page transformation
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class VerticalViewPager extends ViewPager {
public VerticalViewPager(Context context) {
super(context);
@deepak786
deepak786 / Palette.txt
Created December 22, 2015 21:26
Palette (Library to get colour filters from Image Bitmap)
1. Add library to gradle.
compile 'com.android.support:palette-v7:23.0.1'
2. Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
public void onGenerated(Palette p) {
// Use generated instance
p.getDarkMutedColor(ContextCompat.getColor(getActivity(), R.color.textColorWhite));
p.getDarkVibrantColor(ContextCompat.getColor(getActivity(), R.color.textColorWhite));
p.getLightMutedColor(ContextCompat.getColor(getActivity(), R.color.textColorWhite));
p.getLightVibrantColor(ContextCompat.getColor(getActivity(), R.color.textColorWhite));
p.getMutedColor(ContextCompat.getColor(getActivity(), R.color.textColorWhite));
@deepak786
deepak786 / customFont.txt
Last active January 11, 2017 10:19
How to use the custom font inside the entire app. This example is for how to use custom font for all textviews inside the app.
// add fonts inside the *assets/fonts* folder
// create a class named customTextView.java
public class customTextView extends TextView {
private static final String SCHEMA = "http://schemas.android.com/apk/res/android";
public customTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
getStyle(attrs, context);
@deepak786
deepak786 / List view Recycler Listener.txt
Last active January 11, 2017 10:20
Use of Recycler Listener on ListView when the listItem is Recycled for later use. For example you can use this to stop playing audio or video when listitem becomes invisible like Facebook, Instagram, Twitter
yourListView.setRecyclerListener(new RecyclerListener() {
@Override
public void onMovedToScrapHeap(View view) {
// get the holder of the list item from where you can update ui, stop media player etc.
Holder holder = (Holder)view.getTag();
if(holder.mp!=null && holder.mp.isPlaying()){
holder.mp.pause();
holder.imageViewPlay.setBackgroundResource(R.drawable.icon_play);
}
@deepak786
deepak786 / ListView OnScroll AddItem.txt
Created October 8, 2015 18:16
How to use ListView OnScroll to load item when we reach end of the ListView.
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
@deepak786
deepak786 / OCR Using Tesseract.txt
Last active September 15, 2023 12:26
How to use Tesseract library for OCR.
1. Download the tesseract library from the following link named libs.zip.
https://www.dropbox.com/s/9fwqz88sck3xlk4/libs.zip?dl=0
2. Extract the zip folder.
* If you are using Eclipse then copy all the files and folders from libs folder to libs folder in your project.
* if you are using Android Studio then Copy all th e folders from libs folder to src/main/jniLibs folder in your project and copy the classes.jar to libs folder.
3. Add image containing text inside your downloads folder and give the name a.png.
4. create folder named tessdata inside the assets folder in your project.