- Added like button
- Filter by Lname and Fname - go to browser social networks TODO: location, dynamic context menu, thinkit tab, smaller tabs, tweeter feedsmaster
parent
7ddf5ecfe6
commit
436f26acb7
@ -1,8 +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" />
|
||||
<?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>
|
@ -1,8 +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" />
|
||||
<?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>
|
@ -1,8 +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" />
|
||||
<?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>
|
@ -1,22 +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>
|
||||
<?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>
|
@ -1,24 +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"
|
||||
<?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 or use menu"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<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 or use menu"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -1,9 +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" />
|
||||
<?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>
|
@ -1,154 +1,192 @@
|
||||
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;
|
||||
private int likes;
|
||||
|
||||
|
||||
|
||||
public static final String LNAME = "lname";
|
||||
public static final String FNAME = "fname";
|
||||
public static final String COMPANY = "company";
|
||||
public static final String TWITTER = "twitter";
|
||||
public static final String LINKEDIN = "linkedin";
|
||||
public static final String FACEBOOK = "facebook";
|
||||
public static final String COUNTRY = "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;
|
||||
}
|
||||
|
||||
public int getLikes() {
|
||||
return likes;
|
||||
}
|
||||
|
||||
public void setLikes(int likes) {
|
||||
this.likes = likes;
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
package com.thinkit.lewebconnect;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import android.R.bool;
|
||||
|
||||
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;
|
||||
private int likes;
|
||||
private boolean has_facebook = false;
|
||||
private boolean has_twitter = false;
|
||||
private boolean has_linkedin = false;
|
||||
|
||||
|
||||
|
||||
public static final String LNAME = "lname";
|
||||
public static final String FNAME = "fname";
|
||||
public static final String COMPANY = "company";
|
||||
public static final String TWITTER = "twitter";
|
||||
public static final String LINKEDIN = "linkedin";
|
||||
public static final String FACEBOOK = "facebook";
|
||||
public static final String COUNTRY = "country";
|
||||
public static final String LIKES = "likes";
|
||||
public static final String ID = "user_id";
|
||||
|
||||
|
||||
|
||||
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;
|
||||
if ( twitter != null && !twitter.equals("null") && !twitter.isEmpty())
|
||||
setHas_twitter(true);
|
||||
}
|
||||
|
||||
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;
|
||||
if ( linkedin != null && !linkedin.equals("null") && !linkedin.isEmpty())
|
||||
setHas_linkedin(true);
|
||||
}
|
||||
|
||||
public String getFacebook() {
|
||||
return facebook;
|
||||
}
|
||||
|
||||
public void setFacebook(String facebook) {
|
||||
this.facebook = facebook;
|
||||
if ( facebook != null && !facebook.equals("null") && !facebook.isEmpty())
|
||||
setHas_facebook(true);
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public int getLikes() {
|
||||
return likes;
|
||||
}
|
||||
|
||||
public void setLikes(int likes) {
|
||||
this.likes = likes;
|
||||
}
|
||||
|
||||
public boolean isHas_facebook() {
|
||||
return has_facebook;
|
||||
}
|
||||
|
||||
public void setHas_facebook(boolean has_facebook) {
|
||||
this.has_facebook = has_facebook;
|
||||
}
|
||||
|
||||
public boolean isHas_twitter() {
|
||||
return has_twitter;
|
||||
}
|
||||
|
||||
public void setHas_twitter(boolean has_twitter) {
|
||||
this.has_twitter = has_twitter;
|
||||
}
|
||||
|
||||
public boolean isHas_linkedin() {
|
||||
return has_linkedin;
|
||||
}
|
||||
|
||||
public void setHas_linkedin(boolean has_linkedin) {
|
||||
this.has_linkedin = has_linkedin;
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,466 +1,467 @@
|
||||
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;
|
||||
public 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);
|
||||
TextView likes = (TextView) rowview.findViewById(R.id.likes);
|
||||
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());
|
||||
if (likes != null)
|
||||
likes.setText(String.valueOf(user.getLikes()));
|
||||
setSocial(rowview, user);
|
||||
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 setSocial(View rowview, Attendee user) {
|
||||
// TODO Auto-generated method stub
|
||||
boolean twitter = false;
|
||||
boolean linkedin = false;
|
||||
boolean facebook = false;
|
||||
|
||||
ImageView imageView = (ImageView) rowview.findViewById(R.id.icons);
|
||||
|
||||
facebook = ( user.getFacebook() != null && !user.getFacebook().equals("null") && !user.getFacebook().isEmpty());
|
||||
linkedin = ( user.getLinkedin() != null && !user.getLinkedin().equals("null") && !user.getLinkedin().isEmpty());
|
||||
twitter = ( user.getTwitter() != null && !user.getTwitter().equals("null") && !user.getTwitter().isEmpty());
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
public 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);
|
||||
TextView likes = (TextView) rowview.findViewById(R.id.likes);
|
||||
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());
|
||||
if (likes != null)
|
||||
likes.setText(String.valueOf(user.getLikes()));
|
||||
setSocial(rowview, user);
|
||||
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 setSocial(View rowview, Attendee user) {
|
||||
// TODO Auto-generated method stub
|
||||
boolean twitter;
|
||||
boolean linkedin;
|
||||
boolean facebook;
|
||||
|
||||
ImageView imageView = (ImageView) rowview.findViewById(R.id.icons);
|
||||
|
||||
facebook = user.isHas_facebook();
|
||||
linkedin = user.isHas_linkedin();
|
||||
twitter = user.isHas_twitter();
|
||||
|
||||
|
||||
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() +
|
||||
" " + value.getFname().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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,47 +1,47 @@
|
||||
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, 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();
|
||||
}
|
||||
}
|
||||
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, 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,35 +1,74 @@
|
||||
package com.thinkit.lewebconnect;
|
||||
import com.thinkit.lewebconnect.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class UserProfile extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
try {
|
||||
setContentView(R.layout.profile);
|
||||
setTitle(R.string.user_profile);
|
||||
TextView mUserName = (TextView) findViewById(R.id.profile_name);
|
||||
TextView mCompany = (TextView) findViewById(R.id.profile_company);
|
||||
TextView mCountry = (TextView) findViewById(R.id.profile_country);
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
String fname = extras.getString(Attendee.FNAME);
|
||||
String lname = extras.getString(Attendee.LNAME);
|
||||
mUserName.setText(lname + " " + fname);
|
||||
mCompany.setText(extras.getString(Attendee.COMPANY));
|
||||
mCountry.setText(extras.getString(Attendee.COUNTRY));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.thinkit.lewebconnect;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import com.thinkit.lewebconnect.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class UserProfile extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
try {
|
||||
setContentView(R.layout.profile);
|
||||
setTitle(R.string.user_profile);
|
||||
TextView mUserName = (TextView) findViewById(R.id.profile_name);
|
||||
TextView mCompany = (TextView) findViewById(R.id.profile_company);
|
||||
TextView mCountry = (TextView) findViewById(R.id.profile_country);
|
||||
final TextView mLikes = (TextView) findViewById(R.id.profile_likes);
|
||||
final Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
String fname = extras.getString(Attendee.FNAME);
|
||||
String lname = extras.getString(Attendee.LNAME);
|
||||
mUserName.setText(lname + " " + fname);
|
||||
mCompany.setText(extras.getString(Attendee.COMPANY));
|
||||
mCountry.setText(extras.getString(Attendee.COUNTRY));
|
||||
mLikes.setText(String.valueOf(extras.getInt(Attendee.LIKES)));
|
||||
}
|
||||
|
||||
final Button button = (Button) findViewById(R.id.like_button);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
incrementUser(extras.getInt(Attendee.ID));
|
||||
mLikes.setText(String.valueOf(extras.getInt(Attendee.LIKES) + 1));
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void incrementUser(int id) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
HttpGet get = new HttpGet(WebService.INCREMENT_USER + String.valueOf(id));
|
||||
HttpResponse httpResponse = httpClient.execute(get);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +1,47 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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 String INCREMENT_USER = "http://leweb.i-think-it.com/inc/?id=";
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,118 +1,118 @@
|
||||
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);
|
||||
get.setHeader("charset", "utf-8");
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
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);
|
||||
get.setHeader("charset", "utf-8");
|
||||
|
||||
HttpResponse httpResponse = httpClient.execute(get);
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
line = EntityUtils.toString(httpEntity, "UTF-8");
|
||||
|
||||
} 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…
Reference in New Issue