Skip to content

Instantly share code, notes, and snippets.

View jpt1122's full-sized avatar

Jay Thakkar jpt1122

  • My Dream
  • Ahmedabad
View GitHub Profile
@jpt1122
jpt1122 / Rest_Tab.java
Created April 17, 2016 07:52
How to add tab layout without letting the activity to extend TabActivity
public class Rest_Tab extends Rest_HeaderFooter {
TabHost tabHost;
LocalActivityManager mLocalActivityManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.rest_tab);
@jpt1122
jpt1122 / QuickMenuActivity.java
Created April 17, 2016 07:50
QuickAction dialog, shows action list as icon and text like the one in Gallery3D app. Currently supports vertical and horizontal layout.
//Main Activity
public class QuickMenuActivity extends Activity {
/** Called when the activity is first created. */
private static final int ID_UP = 1;
private static final int ID_DOWN = 2;
private static final int ID_SEARCH = 3;
private static final int ID_INFO = 4;
private static final int ID_ERASE = 5;
private static final int ID_OK = 6;
@jpt1122
jpt1122 / TryGallaryActivity.java
Created April 17, 2016 07:45
Awesome Gallery With Android....With Reflection
//Main Activity
public class TryGallaryActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Integer[] images = { R.drawable.img0001, R.drawable.img0030,
@jpt1122
jpt1122 / ViewPagerAdapter.java
Created April 17, 2016 07:41
ViewPager and PagerTabStrip Demo In Android
/* main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background" >
@jpt1122
jpt1122 / TestMatrix.java
Created April 17, 2016 07:27
Here is some more sample code demonstrating matrix equivalence based on the order of operations on that matrix
public class TestMatrix
{
public static void test(SomeActivity a)
{
test1(a);
test2(a);
test3(a);
}
public static void test1(SomeActivity a)
{
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCGetAutoIncKeys {
private static final String DBURL =
"jdbc:mysql://localhost:3306/mydb?user=usr&password=sql" +
@jpt1122
jpt1122 / ByteReadAndWrite.java
Created October 28, 2015 13:58
Sometimes we need to fragment large files into smaller chunks. For example, in simple application which is used with server, we need to upload files ( video, image etc. ) But if the size of file is major,uploading large files to server could get some time and we may face with some problems. In order to avoid these problems, we have to follow the…
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
@jpt1122
jpt1122 / TestStringDate.java
Last active October 28, 2015 12:27
Convert java string date : One format to another format
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TestStringDate {
public static void main(String[] args) throws ParseException {
String strValue = "2015-07-05 19:52:00";
@jpt1122
jpt1122 / FindSqrt.java
Created October 23, 2015 07:16
Find SQRT with help of Binary Search
public class FindSqrt {
public static int sqrt(int no) {
int result = 0;
int low = 0, high = (no / 2), mid = 0;
int midVal = 0;
while (low <= high) {
mid = (low + high) / 2;
System.out.println("Mid Point :" + mid);
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class LongestConsecutiveSequenceFinder {
public static void main(String[] arg) {
int[] nums = { 100, 3, 200, 1, 2, 4 };