Skip to content

Instantly share code, notes, and snippets.

@talhahasanzia
talhahasanzia / object_creation.js
Last active February 8, 2017 08:49
Node JS tutorials.
function User() {
this.id=0;
this.name="";
this.description="";
this.newDescription=function (newDescriptionData) {
this.description=newDescriptionData;
};
@talhahasanzia
talhahasanzia / assets.java
Created February 22, 2017 07:55
Assets folder URI
Uri.parse("file:///android_asset/myfile.mp3")
@talhahasanzia
talhahasanzia / Compass.java
Last active May 9, 2017 07:15
Java direction to specific place compass.
@Override
public void onSensorChanged( SensorEvent event )
{
if ( currentLocation != null )
{
// get accelerometer data
if ( event.sensor.getType() == Sensor.TYPE_ACCELEROMETER )
@talhahasanzia
talhahasanzia / build.gradle
Last active June 5, 2017 08:12
APIs inclusion.
// tests
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.10.19"
@talhahasanzia
talhahasanzia / drop_shadow.xml
Created June 16, 2017 08:00
Drop shadow effect for all android versions
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<gradient
android:angle="360"
android:centerColor="#dcdcdc"
android:endColor="#e7e7e7"
android:gradientRadius="360"
@talhahasanzia
talhahasanzia / FirstRecylerAdapter.java
Created June 18, 2017 18:40
Recyler adapter with view holder pattern
public class FirstRecylerAdapter extends RecyclerView.Adapter<FirstRecylerAdapter.MyViewHolder> {
private List<Integer> imageList;
public class MyViewHolder extends RecyclerView.ViewHolder {
public ImageView image;
public MyViewHolder(View view) {
super(view);
image = (ImageView) view.findViewById(R.id.image);
@talhahasanzia
talhahasanzia / MyListView.java
Created June 19, 2017 07:06
Listview with extra spaces (padding)
public class MyListView extends ListView
{
private android.view.ViewGroup.LayoutParams params;
private int oldCount = 0;
public MyListView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
@talhahasanzia
talhahasanzia / ExpandableListAdapter.java
Last active June 21, 2017 09:24
Expandable List View boiler plate
public class ExpandableListAdapter extends BaseExpandableListAdapter
{
private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;
public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
@talhahasanzia
talhahasanzia / FlipViewAnimation.java
Created June 23, 2017 07:58
Android flip view vertical animation (native).
public class FlipViewAnimation{
public static void flip( View firstView, View secondView, float duration)
{
firstView.animate().rotationX(90).setDuration(duration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
firstView.setVisibility(View.GONE);
secondView.setRotationX(-90);
@talhahasanzia
talhahasanzia / LoaderCursor.java
Created June 29, 2017 06:54
Loaders example android
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software