Skip to content

Instantly share code, notes, and snippets.

View AhmadVatani's full-sized avatar

Ahmad Vatani AhmadVatani

  • Tehran, Iran
View GitHub Profile
@AhmadVatani
AhmadVatani / AdapterHorizontalList.java
Last active July 15, 2016 06:49
Android Horizontal Listview using RecycleView
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
public class AdapterHorizontalList extends RecyclerView.Adapter<AdapterHorizontalList.ViewHolder> {
@AhmadVatani
AhmadVatani / Util.java
Created August 12, 2016 13:58
Sets ListView height dynamically based on the height of the items.
/**
* Sets ListView height dynamically based on the height of the items.
*
* @param listView to be resized
* @return true if the listView is successfully resized, false otherwise
*/
public static boolean setListViewHeightBasedOnItems(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter != null) {
int numberOfItems = listAdapter.getCount();
@AhmadVatani
AhmadVatani / SocketConnection.java
Last active April 13, 2017 10:50
Android socket connection example
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
public class SocketConnection {