initial commit

master
spike 13 years ago
commit 129e8c9c0f

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

@ -0,0 +1,2 @@
/bin
/gen

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LeWebConnect2011</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,5 @@
#Tue Nov 29 22:35:36 CET 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.source=1.5

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thinkit.lewebconnect"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:debuggable="true">
<activity
android:label="@string/app_name"
android:name=".LeWebConnect"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".Perticipents"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:label="@string/app_name"
android:name=".Likes"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:label="@string/app_name"
android:name=".Search"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>

@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_favorites_dark"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_favorites_light" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_perticipents_dark"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_perticipents_light" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_search_dark"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_search_light" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
</FrameLayout>
</LinearLayout>
</TabHost>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
</FrameLayout>
</LinearLayout>
</TabHost>

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px" />
<EditText
android:id="@+building_list/search_box"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="type to filter"
android:maxLines="1" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
</LinearLayout>

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" android:background="#025874"/>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#002531">
<ImageView
android:id="@+id/icons"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:src="@drawable/no_all" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_weight="4">
<TextView
android:id="@+id/name_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="40px"/>
<TextView
android:id="@+id/company_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2px"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25px" />
<TextView
android:id="@+id/country_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2px"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25px" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/by_name"
android:title="@string/filter_name" />
<item android:id="@+id/by_company"
android:title="@string/filter_company" />
<item android:id="@+id/by_country"
android:title="@string/filter_country" />
</menu>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, LeWebConnectActivity!</string>
<string name="app_name">LeWebConnect</string>
<string name="search_hint">Type in a persone or a company name </string>
<string name="filter_name">By Name</string>
<string name="filter_company">By Company</string>
<string name="filter_country">By Country</string>
</resources>

@ -0,0 +1,134 @@
package com.thinkit.lewebconnect;
import java.util.Comparator;
public class Attendee{
private int id;
private String fname;
private String lname;
private String company;
private String twitter;
private String url;
private String linkedin;
private String facebook;
private String country;
public Attendee()
{
}
public Attendee(int id)
{
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getTwitter() {
return twitter;
}
public void setTwitter(String twitter) {
this.twitter = twitter;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getLinkedin() {
return linkedin;
}
public void setLinkedin(String linkedin) {
this.linkedin = linkedin;
}
public String getFacebook() {
return facebook;
}
public void setFacebook(String facebook) {
this.facebook = facebook;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
@Override public String toString() {
return new String(getFname() + " " + getLname());
}
static public class LeWebByLnameComparator implements Comparator<Attendee>
{
public int compare(Attendee lhs, Attendee rhs) {
// TODO Auto-generated method stub
return lhs.getLname().compareToIgnoreCase(rhs.getLname());
}
}
static public class LeWebByCompanyComparator implements Comparator<Attendee>
{
public int compare(Attendee lhs, Attendee rhs) {
// TODO Auto-generated method stub
return lhs.getCompany().compareToIgnoreCase(rhs.getCompany());
}
}
static public class LeWebByCountryComparator implements Comparator<Attendee>
{
public int compare(Attendee lhs, Attendee rhs) {
// TODO Auto-generated method stub
return lhs.getCountry().compareToIgnoreCase(rhs.getCountry());
}
}
}

@ -0,0 +1,458 @@
package com.thinkit.lewebconnect;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.SectionIndexer;
import android.widget.TextView;
public class LeWebAdapter extends ArrayAdapter<Attendee> {
private final Context context;
private ArrayList<Attendee> users;
/**
* Lock used to modify the content of {@link #mObjects}. Any write operation
* performed on the array should be synchronized on this lock. This lock is also
* used by the filter (see {@link #getFilter()} to make a synchronized copy of
* the original array of data.
*/
private final Object mLock = new Object();
private ArrayList<Attendee> originalUsers;
private LeWebFilter filter;
private boolean mNotifyOnChange = true;
private HashMap<String, Integer> alphaIndexer;
private String[] sections = new String[0];
private boolean enableSections;
private boolean companySections;
private boolean countrySections;
public LeWebAdapter(Context context, ArrayList<Attendee> users,
boolean enableSections, boolean companySections, boolean countrySections) {
super(context, R.layout.rowlayout, users);
Log.d("LeWebAdapter", "LeWebAdapter constructor");
this.context = context;
this.users = users;
this.filter = new LeWebFilter();
this.enableSections = enableSections;
this.companySections = companySections;
this.countrySections = countrySections;
if(enableSections)
{
// Log.d("LeWebAdapter", "Sections enabled");
// alphaIndexer = new HashMap<String, Integer>();
// String firstChar;
// for(int i = users.size() - 1; i >= 0; i--)
// {
// Attendee element = users.get(i);
// if (countrySections)
// firstChar = element.getCountry().substring(0, 1).toUpperCase();
// else if (companySections)
// {
// Log.d("Sections", "Enabling company section, getting first letter");
// firstChar = element.getCompany().substring(0, 1).toUpperCase();
// }
// else
// firstChar = element.getLname().substring(0, 1).toUpperCase();
//
// if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A')
// firstChar = "A";
//
// alphaIndexer.put(firstChar, i);
// }
//
// Set<String> keys = alphaIndexer.keySet();
//// Log.d("LeWebAdapter", keys.toString());
// Iterator<String> it = keys.iterator();
// ArrayList<String> keyList = new ArrayList<String>();
//
// while(it.hasNext())
// keyList.add(it.next());
//
// Collections.sort(keyList);
// sections = new String[keyList.size()];
// keyList.toArray(sections);
//// Log.d("LeWebAdapter", keyList.toString());
//// Log.d("LeWebAdapter", alphaIndexer.toString());
buildHashIndexer();
buildSections();
}
}
public void buildSections() {
Set<String> keys = alphaIndexer.keySet();
Iterator<String> it = keys.iterator();
ArrayList<String> keyList = new ArrayList<String>();
while(it.hasNext())
keyList.add(it.next());
Collections.sort(keyList);
sections = new String[keyList.size()];
keyList.toArray(sections);
}
public void buildHashIndexer()
{
try {
// Log.d("LeWebAdapter", "Building hashindexer");
alphaIndexer = new HashMap<String, Integer>();
String firstChar;
for(int i = users.size() - 1; i >= 0; i--)
{
Attendee element = users.get(i);
if (countrySections)
firstChar = element.getCountry().substring(0, 1).toUpperCase();
else if (companySections)
{
Log.d("Sections", "Enabling company section, getting first letter");
firstChar = element.getCompany().substring(0, 1).toUpperCase();
}
else
firstChar = element.getLname().substring(0, 1).toUpperCase();
if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A')
firstChar = "A";
alphaIndexer.put(firstChar, i);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void notifyDataSetChanged(){
if (enableSections)
{
Log.d("notifyDataSetChanged", "...");
buildHashIndexer();
buildSections();
}
super.notifyDataSetChanged();
mNotifyOnChange = true;
}
@Override
public void notifyDataSetInvalidated()
{
if(enableSections)
{
Log.d("notifyDataSetInvalidated", "...");
buildHashIndexer();
buildSections();
super.notifyDataSetInvalidated();
}
}
public void setNotifyOnChange(boolean notifyOnChange){
mNotifyOnChange = notifyOnChange;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowview = inflater.inflate(R.layout.rowlayout, parent, false);
//Log.d("getView", "Making row ....");
try {
Attendee user = users.get(position);
if (user != null)
{
TextView name_text = (TextView) rowview.findViewById(R.id.name_text);
TextView company = (TextView) rowview.findViewById(R.id.company_text);
TextView country = (TextView) rowview.findViewById(R.id.country_text);
if (name_text != null)
name_text.setText(user.getLname() + " " + user.getFname());
if (company != null)
company.setText(user.getCompany());
if (country != null)
country.setText(user.getCountry());
ImageView imageView = (ImageView) rowview.findViewById(R.id.icons);
setImage(imageView, user);
// imageView.setVisibility(View.GONE);
if(enableSections && getSectionForPosition(position) != getSectionForPosition(position - 1))
{
// Log.d("getView", "Setting Header ........ " + String.valueOf(position));
TextView h = (TextView) rowview.findViewById(R.id.header);
h.setText(sections[getSectionForPosition(position)]);
h.setVisibility(View.VISIBLE);
}
else
{
TextView h = (TextView) rowview.findViewById(R.id.header);
h.setVisibility(View.GONE);
}
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return rowview;
}
private void setImage(ImageView imageView, Attendee user) {
// TODO Auto-generated method stub
boolean facebook = false;
boolean twitter = false;
boolean linkedin = false;
if ( user.getFacebook() != null && !user.getFacebook().equals("null") && !user.getFacebook().isEmpty())
facebook = true;
if ( user.getLinkedin() != null && !user.getLinkedin().equals("null") && !user.getLinkedin().isEmpty())
linkedin = true;
if ( user.getTwitter() != null && !user.getTwitter().equals("null") && !user.getTwitter().isEmpty())
twitter = true;
if (facebook && twitter && linkedin)
imageView.setImageResource(R.drawable.social_all);
else if (facebook && twitter)
imageView.setImageResource(R.drawable.no_linkedin);
else if (facebook && linkedin)
imageView.setImageResource(R.drawable.no_twitter);
else if (twitter && linkedin)
imageView.setImageResource(R.drawable.no_fb);
else if (twitter)
imageView.setImageResource(R.drawable.twitter);
else if (facebook)
imageView.setImageResource(R.drawable.fb);
else if (linkedin)
imageView.setImageResource(R.drawable.linkedin);
else
imageView.setImageResource(R.drawable.no_all);
}
@Override
public int getCount(){
return this.users.size();
}
public int getPositionForSection(int section)
{
try {
if(!enableSections) return 0;
if (section == sections.length)
section--;
String letter = sections[section];
return alphaIndexer.get(letter);
} catch (Exception e) {
// TODO: handle exception
Log.d("getPositionForSection", String.valueOf(section));
Log.d("getPositionForSection", "alphaindexer: " + alphaIndexer.toString());
Log.d("getPositionForSection", "sections: " + getSections());
//e.printStackTrace();
}
return 0;
}
public int getSectionForPosition(int position)
{
// Log.d("getSectionForPosition", "recievied position : " + String.valueOf(position));
if(!enableSections) return 0;
int prevIndex = 0;
// for(int i = 0; i < sections.length; i++)
// {
// if(getPositionForSection(i) > position && prevIndex <= position)
// {
// prevIndex = i ;
// break;
// }
// prevIndex = i;
// }
int i = 0;
while (i < sections.length) {
// Log.d("i", "------------>" + String.valueOf(i));
// Log.d("sectionsLength", "------------>" + String.valueOf(sections.length));
if (getPositionForSection(i) > position && prevIndex <= position)
{
prevIndex = i;
break;
}
prevIndex = i;
i++;
}
prevIndex--;
// Log.d("getSectionForPosition", "Returning : " + String.valueOf(prevIndex));
return prevIndex;
}
public Object[] getSections()
{
return sections;
}
@Override
public android.widget.Filter getFilter()
{
if(filter == null)
filter = new LeWebFilter();
return filter;
}
// Currently filters only by Lname
private class LeWebFilter extends android.widget.Filter
{
@Override
protected FilterResults performFiltering(CharSequence constraint) {
// NOTE: this function is *always* called from a background thread, and
// not the UI thread.
Log.d("Filter", "Filter .....");
FilterResults results = new FilterResults();
if (originalUsers == null) {
synchronized (mLock) {
originalUsers = new ArrayList<Attendee>(users);
}
}
if (constraint == null || constraint.length() == 0) {
synchronized (mLock) {
ArrayList<Attendee> list = new ArrayList<Attendee>(originalUsers);
results.values = list;
results.count = list.size();
}
} else {
try {
String constraintStr = constraint.toString().toLowerCase();
final ArrayList<Attendee> values = originalUsers;
final int count = values.size();
final ArrayList<Attendee> newValues = new ArrayList<Attendee>();
for (int i = 0; i < count; i++) {
final Attendee value = values.get(i);
final String valueText;
if (companySections)
{
valueText = value.getCompany().toLowerCase();
}
else if (countrySections){
valueText = value.getCountry().toLowerCase();
}
else {
valueText = value.getLname().toLowerCase();
}
// First match against the whole, non-splitted value
if (valueText.startsWith(constraintStr)) {
newValues.add(value);
} else {
final String[] words = valueText.split(" ");
final int wordCount = words.length;
for (int k = 0; k < wordCount; k++) {
if (words[k].startsWith(constraintStr)) {
newValues.add(value);
break;
}
}
}
}
results.values = newValues;
results.count = newValues.size();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return results;
}
// constraint = constraint.toString().toLowerCase();
// if(constraint != null && constraint.toString().length() > 0)
// {
// Log.d("Filter", "constraint not null with value <" + constraint.toString() + ">");
// ArrayList<Attendee> filt = new ArrayList<Attendee>();
// ArrayList<Attendee> lItems = new ArrayList<Attendee>();
// synchronized (this)
// {
// lItems.addAll(users);
// }
// for(int i = 0, l = lItems.size(); i < l; i++)
// {
// Attendee m = lItems.get(i);
// if (countrySections && m.getCountry().toLowerCase().contains(constraint))
// filt.add(m);
// else if (companySections && m.getCompany().toLowerCase().contains(constraint))
// filt.add(m);
// else if (m.getLname().toLowerCase().contains(constraint))
// filt.add(m);
// }
// result.count = filt.size();
// result.values = filt;
// }
//// else if (constraint == null || constraint.length() == 0)
//// {
//// ArrayList<Attendee> list = new ArrayList<Attendee>(originalUsers);
//// result.values=list;
//// result.count = list.size();
//// }
// else
// {
// synchronized(this)
// {
// result.values = users;
// result.count = users.size();
// }
// }
// return result;
@SuppressWarnings("unchecked")
protected void publishResults(CharSequence constraint, FilterResults results) {
// NOTE: this function is *always* called from the UI thread.
users = (ArrayList<Attendee>)results.values;
if (results.count > 0) {
// buildHashIndexer();
// buildSections();
notifyDataSetChanged();
} else {
// buildHashIndexer();
// buildSections();
notifyDataSetInvalidated();
}
// notifyDataSetChanged();
// clear();
// for(int i = 0, l = originalUsers.size(); i < l; i++)
// add(originalUsers.get(i));
// notifyDataSetInvalidated();
}
}
}

@ -0,0 +1,53 @@
package com.thinkit.lewebconnect;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;
import android.widget.TextView;
public class LeWebConnect extends TabActivity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, Perticipents.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost
.newTabSpec("perticipents")
.setIndicator("",
res.getDrawable(R.drawable.ic_tab_perticipents))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, Search.class);
spec = tabHost
.newTabSpec("search")
.setIndicator("", res.getDrawable(R.drawable.ic_tab_search))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Likes.class);
spec = tabHost
.newTabSpec("likes")
.setIndicator("",
res.getDrawable(R.drawable.ic_tab_favorites))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
} catch (Exception e) {
// TODO: handle exception
Log.d("Error", e.toString());
e.printStackTrace();
}
}
}

@ -0,0 +1,13 @@
package com.thinkit.lewebconnect;
import android.app.Activity;
import android.os.Bundle;
public class Likes extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

@ -0,0 +1,214 @@
package com.thinkit.lewebconnect;
import java.util.ArrayList;
import java.util.Collections;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.thinkit.lewebconnect.Attendee.LeWebByCompanyComparator;
import com.thinkit.lewebconnect.Attendee.LeWebByCountryComparator;
import com.thinkit.lewebconnect.Attendee.LeWebByLnameComparator;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.sax.Element;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Filterable;
import android.widget.ListView;
import android.widget.Toast;
public class Perticipents extends ListActivity {
/** Called when the activity is first created. */
private static String TAG = "Perticipents";
private ArrayList<Attendee> users;
private EditText filterText = null;
ArrayAdapter<Attendee> adapter = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String xml;
xml = XMLfunctions.getXML();
Document doc = XMLfunctions.XMLfromString(xml);
int numResults = XMLfunctions.numResults(doc);
//Log.d(TAG, "numResults length: " + String.valueOf(numResults));
if((numResults <= 0)) {
Toast.makeText(this, "Please make sure connection is available !", Toast.LENGTH_LONG).show();
finish();
}
NodeList nodes = doc.getElementsByTagName("user");
try {
users = new ArrayList<Attendee>();
//fill in the list items from the XML document
for (int i = 0; i < nodes.getLength(); i++) {
Node e = (Node)nodes.item(i);
users.add(NodeToAttendee(e));
}
Collections.sort(users, new LeWebByLnameComparator());
setContentView(R.layout.perticipents);
filterText= (EditText) findViewById(R.building_list.search_box);
filterText.addTextChangedListener(filterTextWatcher);
ListView lv = getListView();
lv.setFastScrollEnabled(true);
lv.setTextFilterEnabled(false);
adapter = new LeWebAdapter(this, users, true, false, false);
setListAdapter(adapter);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
private TextWatcher filterTextWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@SuppressWarnings("unchecked")
public void onTextChanged(CharSequence s, int start, int before,
int count) {
ListView lv = getListView();
Log.d("onTextChanged", s.toString());
Log.d("getCount", String.valueOf(lv.getAdapter().getCount()));
adapter = (ArrayAdapter<Attendee>) lv.getAdapter();
adapter.getFilter().filter(s);
Log.d("getCount", String.valueOf(lv.getAdapter().getCount()));
}
};
@Override
protected void onDestroy() {
super.onDestroy();
filterText.removeTextChangedListener(filterTextWatcher);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater infalter = getMenuInflater();
infalter.inflate(R.menu.attendies, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.by_name:
{
try {
Collections.sort(users, new LeWebByLnameComparator());
adapter = new LeWebAdapter(this, users, true, false, false);
ListView lv = getListView();
lv.setTextFilterEnabled(false);
lv.setAdapter(adapter);
lv.refreshDrawableState();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(this, "Filtering by Name!", Toast.LENGTH_LONG).show();
break;
}
case R.id.by_country:
{
try {
Collections.sort(users, new LeWebByCountryComparator());
adapter = new LeWebAdapter(this, users, true, false, true);
ListView lv = getListView();
lv.setTextFilterEnabled(false);
lv.setAdapter(adapter);
lv.refreshDrawableState();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(this, "Filtered by country.", Toast.LENGTH_LONG).show();
break;
}
case R.id.by_company:
{
try {
Collections.sort(users, new LeWebByCompanyComparator());
adapter = new LeWebAdapter(this, users, true, true, false);
ListView lv = getListView();
lv.setTextFilterEnabled(false);
lv.setAdapter(adapter);
lv.refreshDrawableState();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(this, "Filtered by company.", Toast.LENGTH_LONG).show();
break;
}
}
return super.onOptionsItemSelected(item);
}
public Attendee NodeToAttendee(Node userNode)
{
NamedNodeMap attrs = userNode.getAttributes();
String fname = attrs.getNamedItem("fname").getTextContent();
String lname = attrs.getNamedItem("lname").getTextContent();
String company = attrs.getNamedItem("company").getTextContent();
String country = attrs.getNamedItem("country").getTextContent();
String facebook = attrs.getNamedItem("facebook").getTextContent();
String twitter = attrs.getNamedItem("twitter").getTextContent();
Attendee user = new Attendee();
user.setFname(fname);
user.setLname(lname);
user.setCompany(company);
user.setCountry(country);
user.setFacebook(facebook);
user.setTwitter(twitter);
return user;
}
}

@ -0,0 +1,15 @@
package com.thinkit.lewebconnect;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Search extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("search view");
setContentView(textview); }
}

@ -0,0 +1,46 @@
package com.thinkit.lewebconnect;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import android.content.Context;
import android.util.Log;
public class WebService {
static String XML_DB_URL = "http://leweb.i-think-it.com/get/";
static private String FILENAME = "leweb.xml";
private int bufsize = 1024;
private Context context;
public WebService(Context appcontext)
{
Log.d("WebService", "starting web service constructor");
this.context = appcontext;
}
public void GetRemoteDB() throws IOException
{
Log.d("WebService", "inside getremote");
URL url = new URL(XML_DB_URL);
InputStream input = url.openStream();
Log.d("WebService", "Opened remote streamm starting download");
try {
FileOutputStream output = context.openFileOutput(FILENAME, Context.MODE_PRIVATE);
try {
byte[] buffer = new byte[bufsize];
int bytesRead = 0;
while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
Log.d("WebService", new String(buffer, 0, bufsize));
output.write(buffer, 0, buffer.length);
}
} finally {
output.close();
}
} finally {
input.close();
}
}
}

@ -0,0 +1,117 @@
package com.thinkit.lewebconnect;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import android.util.Log;
public class XMLfunctions {
public final static Document XMLfromString(String xml){
Document doc = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
doc = db.parse(is);
} catch (ParserConfigurationException e) {
System.out.println("XML parse error: " + e.getMessage());
return null;
} catch (SAXException e) {
System.out.println("Wrong XML file structure: " + e.getMessage());
return null;
} catch (IOException e) {
System.out.println("I/O exeption: " + e.getMessage());
return null;
}
return doc;
}
/** Returns element value
* @param elem element (it is XML tag)
* @return Element value otherwise empty String
*/
public final static String getElementValue( Node elem ) {
Node kid;
if( elem != null){
if (elem.hasChildNodes()){
for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
if( kid.getNodeType() == Node.TEXT_NODE ){
return kid.getNodeValue();
}
}
}
}
return "";
}
public static String getXML(){
String line = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet(WebService.XML_DB_URL);
HttpResponse httpResponse = httpClient.execute(get);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (MalformedURLException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (IOException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
}
return line;
}
public static int numResults(Document doc){
NodeList results;
try {
results = doc.getElementsByTagName("user");
//Log.d("XMLFunctions", results.toString());
return results.getLength();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
public static String getValue(Element item, String str) {
NodeList n = item.getElementsByTagName(str);
return XMLfunctions.getElementValue(n.item(0));
}
}
Loading…
Cancel
Save