- 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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!-- When selected, use grey -->
|
<!-- When selected, use grey -->
|
||||||
<item android:drawable="@drawable/ic_tab_favorites_dark"
|
<item android:drawable="@drawable/ic_tab_favorites_dark"
|
||||||
android:state_selected="true" />
|
android:state_selected="true" />
|
||||||
<!-- When not selected, use white-->
|
<!-- When not selected, use white-->
|
||||||
<item android:drawable="@drawable/ic_tab_favorites_light" />
|
<item android:drawable="@drawable/ic_tab_favorites_light" />
|
||||||
</selector>
|
</selector>
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!-- When selected, use grey -->
|
<!-- When selected, use grey -->
|
||||||
<item android:drawable="@drawable/ic_tab_perticipents_dark"
|
<item android:drawable="@drawable/ic_tab_perticipents_dark"
|
||||||
android:state_selected="true" />
|
android:state_selected="true" />
|
||||||
<!-- When not selected, use white-->
|
<!-- When not selected, use white-->
|
||||||
<item android:drawable="@drawable/ic_tab_perticipents_light" />
|
<item android:drawable="@drawable/ic_tab_perticipents_light" />
|
||||||
</selector>
|
</selector>
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!-- When selected, use grey -->
|
<!-- When selected, use grey -->
|
||||||
<item android:drawable="@drawable/ic_tab_search_dark"
|
<item android:drawable="@drawable/ic_tab_search_dark"
|
||||||
android:state_selected="true" />
|
android:state_selected="true" />
|
||||||
<!-- When not selected, use white-->
|
<!-- When not selected, use white-->
|
||||||
<item android:drawable="@drawable/ic_tab_search_light" />
|
<item android:drawable="@drawable/ic_tab_search_light" />
|
||||||
</selector>
|
</selector>
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/tabhost"
|
android:id="@android:id/tabhost"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="5dp">
|
android:padding="5dp">
|
||||||
<TabWidget
|
<TabWidget
|
||||||
android:id="@android:id/tabs"
|
android:id="@android:id/tabs"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@android:id/tabcontent"
|
android:id="@android:id/tabcontent"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="5dp">
|
android:padding="5dp">
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TabHost>
|
</TabHost>
|
@ -1,24 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
<LinearLayout android:focusable="true"
|
<LinearLayout android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="0px" />
|
android:layout_height="0px" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+building_list/search_box"
|
android:id="@+building_list/search_box"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="type to filter or use menu"
|
android:hint="type to filter or use menu"
|
||||||
android:maxLines="1" />
|
android:maxLines="1" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@android:id/list"
|
android:id="@android:id/list"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="0dip"
|
android:layout_height="0dip"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:id="@+id/by_name"
|
<item android:id="@+id/by_name"
|
||||||
android:title="@string/filter_name" />
|
android:title="@string/filter_name" />
|
||||||
<item android:id="@+id/by_company"
|
<item android:id="@+id/by_company"
|
||||||
android:title="@string/filter_company" />
|
android:title="@string/filter_company" />
|
||||||
<item android:id="@+id/by_country"
|
<item android:id="@+id/by_country"
|
||||||
android:title="@string/filter_country" />
|
android:title="@string/filter_country" />
|
||||||
</menu>
|
</menu>
|
@ -1,154 +1,192 @@
|
|||||||
package com.thinkit.lewebconnect;
|
package com.thinkit.lewebconnect;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class Attendee{
|
import android.R.bool;
|
||||||
private int id;
|
|
||||||
private String fname;
|
public class Attendee{
|
||||||
private String lname;
|
private int id;
|
||||||
private String company;
|
private String fname;
|
||||||
private String twitter;
|
private String lname;
|
||||||
private String url;
|
private String company;
|
||||||
private String linkedin;
|
private String twitter;
|
||||||
private String facebook;
|
private String url;
|
||||||
private String country;
|
private String linkedin;
|
||||||
private int likes;
|
private String facebook;
|
||||||
|
private String country;
|
||||||
|
private int likes;
|
||||||
|
private boolean has_facebook = false;
|
||||||
public static final String LNAME = "lname";
|
private boolean has_twitter = false;
|
||||||
public static final String FNAME = "fname";
|
private boolean has_linkedin = false;
|
||||||
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 LNAME = "lname";
|
||||||
public static final String COUNTRY = "country";
|
public static final String FNAME = "fname";
|
||||||
|
public static final String COMPANY = "company";
|
||||||
|
public static final String TWITTER = "twitter";
|
||||||
public Attendee()
|
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(int id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
public Attendee()
|
||||||
|
{
|
||||||
public int getId() {
|
|
||||||
return id;
|
}
|
||||||
}
|
|
||||||
|
public Attendee(int id)
|
||||||
public void setId(int id) {
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFname() {
|
public int getId() {
|
||||||
return fname;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFname(String fname) {
|
public void setId(int id) {
|
||||||
this.fname = fname;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLname() {
|
public String getFname() {
|
||||||
return lname;
|
return fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLname(String lname) {
|
public void setFname(String fname) {
|
||||||
this.lname = lname;
|
this.fname = fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCompany() {
|
public String getLname() {
|
||||||
return company;
|
return lname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCompany(String company) {
|
public void setLname(String lname) {
|
||||||
this.company = company;
|
this.lname = lname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTwitter() {
|
public String getCompany() {
|
||||||
return twitter;
|
return company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTwitter(String twitter) {
|
public void setCompany(String company) {
|
||||||
this.twitter = twitter;
|
this.company = company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getTwitter() {
|
||||||
return url;
|
return twitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(String url) {
|
public void setTwitter(String twitter) {
|
||||||
this.url = url;
|
this.twitter = twitter;
|
||||||
}
|
if ( twitter != null && !twitter.equals("null") && !twitter.isEmpty())
|
||||||
|
setHas_twitter(true);
|
||||||
public String getLinkedin() {
|
}
|
||||||
return linkedin;
|
|
||||||
}
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
public void setLinkedin(String linkedin) {
|
}
|
||||||
this.linkedin = linkedin;
|
|
||||||
}
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
public String getFacebook() {
|
}
|
||||||
return facebook;
|
|
||||||
}
|
public String getLinkedin() {
|
||||||
|
return linkedin;
|
||||||
public void setFacebook(String facebook) {
|
}
|
||||||
this.facebook = facebook;
|
|
||||||
}
|
public void setLinkedin(String linkedin) {
|
||||||
|
this.linkedin = linkedin;
|
||||||
public String getCountry() {
|
if ( linkedin != null && !linkedin.equals("null") && !linkedin.isEmpty())
|
||||||
return country;
|
setHas_linkedin(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCountry(String country) {
|
public String getFacebook() {
|
||||||
this.country = country;
|
return facebook;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLikes() {
|
public void setFacebook(String facebook) {
|
||||||
return likes;
|
this.facebook = facebook;
|
||||||
}
|
if ( facebook != null && !facebook.equals("null") && !facebook.isEmpty())
|
||||||
|
setHas_facebook(true);
|
||||||
public void setLikes(int likes) {
|
}
|
||||||
this.likes = likes;
|
|
||||||
}
|
public String getCountry() {
|
||||||
|
return country;
|
||||||
@Override public String toString() {
|
}
|
||||||
return new String(getFname() + " " + getLname());
|
|
||||||
|
public void setCountry(String country) {
|
||||||
}
|
this.country = country;
|
||||||
|
}
|
||||||
static public class LeWebByLnameComparator implements Comparator<Attendee>
|
|
||||||
{
|
public int getLikes() {
|
||||||
|
return likes;
|
||||||
public int compare(Attendee lhs, Attendee rhs) {
|
}
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return lhs.getLname().compareToIgnoreCase(rhs.getLname());
|
public void setLikes(int likes) {
|
||||||
}
|
this.likes = likes;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
public boolean isHas_facebook() {
|
||||||
static public class LeWebByCompanyComparator implements Comparator<Attendee>
|
return has_facebook;
|
||||||
{
|
}
|
||||||
|
|
||||||
public int compare(Attendee lhs, Attendee rhs) {
|
public void setHas_facebook(boolean has_facebook) {
|
||||||
// TODO Auto-generated method stub
|
this.has_facebook = has_facebook;
|
||||||
return lhs.getCompany().compareToIgnoreCase(rhs.getCompany());
|
}
|
||||||
}
|
|
||||||
|
public boolean isHas_twitter() {
|
||||||
}
|
return has_twitter;
|
||||||
|
}
|
||||||
static public class LeWebByCountryComparator implements Comparator<Attendee>
|
|
||||||
{
|
public void setHas_twitter(boolean has_twitter) {
|
||||||
|
this.has_twitter = has_twitter;
|
||||||
public int compare(Attendee lhs, Attendee rhs) {
|
}
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return lhs.getCountry().compareToIgnoreCase(rhs.getCountry());
|
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;
|
package com.thinkit.lewebconnect;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class LeWebAdapter extends ArrayAdapter<Attendee> {
|
public class LeWebAdapter extends ArrayAdapter<Attendee> {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
public ArrayList<Attendee> users;
|
public ArrayList<Attendee> users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock used to modify the content of {@link #mObjects}. Any write operation
|
* 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
|
* 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
|
* used by the filter (see {@link #getFilter()} to make a synchronized copy of
|
||||||
* the original array of data.
|
* the original array of data.
|
||||||
*/
|
*/
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
private ArrayList<Attendee> originalUsers;
|
private ArrayList<Attendee> originalUsers;
|
||||||
private LeWebFilter filter;
|
private LeWebFilter filter;
|
||||||
|
|
||||||
|
|
||||||
private boolean mNotifyOnChange = true;
|
private boolean mNotifyOnChange = true;
|
||||||
|
|
||||||
private HashMap<String, Integer> alphaIndexer;
|
private HashMap<String, Integer> alphaIndexer;
|
||||||
private String[] sections = new String[0];
|
private String[] sections = new String[0];
|
||||||
|
|
||||||
|
|
||||||
private boolean enableSections;
|
private boolean enableSections;
|
||||||
private boolean companySections;
|
private boolean companySections;
|
||||||
private boolean countrySections;
|
private boolean countrySections;
|
||||||
|
|
||||||
|
|
||||||
public LeWebAdapter(Context context, ArrayList<Attendee> users,
|
public LeWebAdapter(Context context, ArrayList<Attendee> users,
|
||||||
boolean enableSections, boolean companySections, boolean countrySections) {
|
boolean enableSections, boolean companySections, boolean countrySections) {
|
||||||
super(context, R.layout.rowlayout, users);
|
super(context, R.layout.rowlayout, users);
|
||||||
|
|
||||||
Log.d("LeWebAdapter", "LeWebAdapter constructor");
|
Log.d("LeWebAdapter", "LeWebAdapter constructor");
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
this.filter = new LeWebFilter();
|
this.filter = new LeWebFilter();
|
||||||
this.enableSections = enableSections;
|
this.enableSections = enableSections;
|
||||||
this.companySections = companySections;
|
this.companySections = companySections;
|
||||||
this.countrySections = countrySections;
|
this.countrySections = countrySections;
|
||||||
|
|
||||||
|
|
||||||
if(enableSections)
|
if(enableSections)
|
||||||
{
|
{
|
||||||
// Log.d("LeWebAdapter", "Sections enabled");
|
// Log.d("LeWebAdapter", "Sections enabled");
|
||||||
// alphaIndexer = new HashMap<String, Integer>();
|
// alphaIndexer = new HashMap<String, Integer>();
|
||||||
// String firstChar;
|
// String firstChar;
|
||||||
// for(int i = users.size() - 1; i >= 0; i--)
|
// for(int i = users.size() - 1; i >= 0; i--)
|
||||||
// {
|
// {
|
||||||
// Attendee element = users.get(i);
|
// Attendee element = users.get(i);
|
||||||
// if (countrySections)
|
// if (countrySections)
|
||||||
// firstChar = element.getCountry().substring(0, 1).toUpperCase();
|
// firstChar = element.getCountry().substring(0, 1).toUpperCase();
|
||||||
// else if (companySections)
|
// else if (companySections)
|
||||||
// {
|
// {
|
||||||
// Log.d("Sections", "Enabling company section, getting first letter");
|
// Log.d("Sections", "Enabling company section, getting first letter");
|
||||||
// firstChar = element.getCompany().substring(0, 1).toUpperCase();
|
// firstChar = element.getCompany().substring(0, 1).toUpperCase();
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// firstChar = element.getLname().substring(0, 1).toUpperCase();
|
// firstChar = element.getLname().substring(0, 1).toUpperCase();
|
||||||
//
|
//
|
||||||
// if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A')
|
// if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A')
|
||||||
// firstChar = "A";
|
// firstChar = "A";
|
||||||
//
|
//
|
||||||
// alphaIndexer.put(firstChar, i);
|
// alphaIndexer.put(firstChar, i);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Set<String> keys = alphaIndexer.keySet();
|
// Set<String> keys = alphaIndexer.keySet();
|
||||||
//// Log.d("LeWebAdapter", keys.toString());
|
//// Log.d("LeWebAdapter", keys.toString());
|
||||||
// Iterator<String> it = keys.iterator();
|
// Iterator<String> it = keys.iterator();
|
||||||
// ArrayList<String> keyList = new ArrayList<String>();
|
// ArrayList<String> keyList = new ArrayList<String>();
|
||||||
//
|
//
|
||||||
// while(it.hasNext())
|
// while(it.hasNext())
|
||||||
// keyList.add(it.next());
|
// keyList.add(it.next());
|
||||||
//
|
//
|
||||||
// Collections.sort(keyList);
|
// Collections.sort(keyList);
|
||||||
// sections = new String[keyList.size()];
|
// sections = new String[keyList.size()];
|
||||||
// keyList.toArray(sections);
|
// keyList.toArray(sections);
|
||||||
//// Log.d("LeWebAdapter", keyList.toString());
|
//// Log.d("LeWebAdapter", keyList.toString());
|
||||||
//// Log.d("LeWebAdapter", alphaIndexer.toString());
|
//// Log.d("LeWebAdapter", alphaIndexer.toString());
|
||||||
buildHashIndexer();
|
buildHashIndexer();
|
||||||
buildSections();
|
buildSections();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildSections() {
|
public void buildSections() {
|
||||||
|
|
||||||
Set<String> keys = alphaIndexer.keySet();
|
Set<String> keys = alphaIndexer.keySet();
|
||||||
Iterator<String> it = keys.iterator();
|
Iterator<String> it = keys.iterator();
|
||||||
ArrayList<String> keyList = new ArrayList<String>();
|
ArrayList<String> keyList = new ArrayList<String>();
|
||||||
|
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
keyList.add(it.next());
|
keyList.add(it.next());
|
||||||
|
|
||||||
Collections.sort(keyList);
|
Collections.sort(keyList);
|
||||||
sections = new String[keyList.size()];
|
sections = new String[keyList.size()];
|
||||||
keyList.toArray(sections);
|
keyList.toArray(sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildHashIndexer()
|
public void buildHashIndexer()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Log.d("LeWebAdapter", "Building hashindexer");
|
// Log.d("LeWebAdapter", "Building hashindexer");
|
||||||
alphaIndexer = new HashMap<String, Integer>();
|
alphaIndexer = new HashMap<String, Integer>();
|
||||||
String firstChar;
|
String firstChar;
|
||||||
for(int i = users.size() - 1; i >= 0; i--)
|
for(int i = users.size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
Attendee element = users.get(i);
|
Attendee element = users.get(i);
|
||||||
if (countrySections)
|
if (countrySections)
|
||||||
firstChar = element.getCountry().substring(0, 1).toUpperCase();
|
firstChar = element.getCountry().substring(0, 1).toUpperCase();
|
||||||
else if (companySections)
|
else if (companySections)
|
||||||
{
|
{
|
||||||
Log.d("Sections", "Enabling company section, getting first letter");
|
Log.d("Sections", "Enabling company section, getting first letter");
|
||||||
firstChar = element.getCompany().substring(0, 1).toUpperCase();
|
firstChar = element.getCompany().substring(0, 1).toUpperCase();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
firstChar = element.getLname().substring(0, 1).toUpperCase();
|
firstChar = element.getLname().substring(0, 1).toUpperCase();
|
||||||
|
|
||||||
if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A')
|
if(firstChar.charAt(0) > 'Z' || firstChar.charAt(0) < 'A')
|
||||||
firstChar = "A";
|
firstChar = "A";
|
||||||
|
|
||||||
alphaIndexer.put(firstChar, i);
|
alphaIndexer.put(firstChar, i);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyDataSetChanged(){
|
public void notifyDataSetChanged(){
|
||||||
if (enableSections)
|
if (enableSections)
|
||||||
{
|
{
|
||||||
Log.d("notifyDataSetChanged", "...");
|
Log.d("notifyDataSetChanged", "...");
|
||||||
buildHashIndexer();
|
buildHashIndexer();
|
||||||
buildSections();
|
buildSections();
|
||||||
}
|
}
|
||||||
super.notifyDataSetChanged();
|
super.notifyDataSetChanged();
|
||||||
mNotifyOnChange = true;
|
mNotifyOnChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyDataSetInvalidated()
|
public void notifyDataSetInvalidated()
|
||||||
{
|
{
|
||||||
if(enableSections)
|
if(enableSections)
|
||||||
{
|
{
|
||||||
Log.d("notifyDataSetInvalidated", "...");
|
Log.d("notifyDataSetInvalidated", "...");
|
||||||
|
|
||||||
buildHashIndexer();
|
buildHashIndexer();
|
||||||
buildSections();
|
buildSections();
|
||||||
super.notifyDataSetInvalidated();
|
super.notifyDataSetInvalidated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotifyOnChange(boolean notifyOnChange){
|
public void setNotifyOnChange(boolean notifyOnChange){
|
||||||
mNotifyOnChange = notifyOnChange;
|
mNotifyOnChange = notifyOnChange;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context
|
LayoutInflater inflater = (LayoutInflater) context
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View rowview = inflater.inflate(R.layout.rowlayout, parent, false);
|
View rowview = inflater.inflate(R.layout.rowlayout, parent, false);
|
||||||
//Log.d("getView", "Making row ....");
|
//Log.d("getView", "Making row ....");
|
||||||
try {
|
try {
|
||||||
Attendee user = users.get(position);
|
Attendee user = users.get(position);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
TextView name_text = (TextView) rowview.findViewById(R.id.name_text);
|
TextView name_text = (TextView) rowview.findViewById(R.id.name_text);
|
||||||
TextView company = (TextView) rowview.findViewById(R.id.company_text);
|
TextView company = (TextView) rowview.findViewById(R.id.company_text);
|
||||||
TextView country = (TextView) rowview.findViewById(R.id.country_text);
|
TextView country = (TextView) rowview.findViewById(R.id.country_text);
|
||||||
TextView likes = (TextView) rowview.findViewById(R.id.likes);
|
TextView likes = (TextView) rowview.findViewById(R.id.likes);
|
||||||
if (name_text != null)
|
if (name_text != null)
|
||||||
name_text.setText(user.getLname() + " " + user.getFname());
|
name_text.setText(user.getLname() + " " + user.getFname());
|
||||||
if (company != null)
|
if (company != null)
|
||||||
company.setText(user.getCompany());
|
company.setText(user.getCompany());
|
||||||
if (country != null)
|
if (country != null)
|
||||||
country.setText(user.getCountry());
|
country.setText(user.getCountry());
|
||||||
if (likes != null)
|
if (likes != null)
|
||||||
likes.setText(String.valueOf(user.getLikes()));
|
likes.setText(String.valueOf(user.getLikes()));
|
||||||
setSocial(rowview, user);
|
setSocial(rowview, user);
|
||||||
if(enableSections && getSectionForPosition(position) != getSectionForPosition(position - 1))
|
if(enableSections && getSectionForPosition(position) != getSectionForPosition(position - 1))
|
||||||
{
|
{
|
||||||
// Log.d("getView", "Setting Header ........ " + String.valueOf(position));
|
// Log.d("getView", "Setting Header ........ " + String.valueOf(position));
|
||||||
TextView h = (TextView) rowview.findViewById(R.id.header);
|
TextView h = (TextView) rowview.findViewById(R.id.header);
|
||||||
h.setText(sections[getSectionForPosition(position)]);
|
h.setText(sections[getSectionForPosition(position)]);
|
||||||
h.setVisibility(View.VISIBLE);
|
h.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextView h = (TextView) rowview.findViewById(R.id.header);
|
TextView h = (TextView) rowview.findViewById(R.id.header);
|
||||||
h.setVisibility(View.GONE);
|
h.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return rowview;
|
return rowview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setSocial(View rowview, Attendee user) {
|
private void setSocial(View rowview, Attendee user) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
boolean twitter = false;
|
boolean twitter;
|
||||||
boolean linkedin = false;
|
boolean linkedin;
|
||||||
boolean facebook = false;
|
boolean facebook;
|
||||||
|
|
||||||
ImageView imageView = (ImageView) rowview.findViewById(R.id.icons);
|
ImageView imageView = (ImageView) rowview.findViewById(R.id.icons);
|
||||||
|
|
||||||
facebook = ( user.getFacebook() != null && !user.getFacebook().equals("null") && !user.getFacebook().isEmpty());
|
facebook = user.isHas_facebook();
|
||||||
linkedin = ( user.getLinkedin() != null && !user.getLinkedin().equals("null") && !user.getLinkedin().isEmpty());
|
linkedin = user.isHas_linkedin();
|
||||||
twitter = ( user.getTwitter() != null && !user.getTwitter().equals("null") && !user.getTwitter().isEmpty());
|
twitter = user.isHas_twitter();
|
||||||
|
|
||||||
|
|
||||||
if (facebook && twitter && linkedin){
|
if (facebook && twitter && linkedin){
|
||||||
imageView.setImageResource(R.drawable.social_all);
|
imageView.setImageResource(R.drawable.social_all);
|
||||||
}
|
}
|
||||||
else if (facebook && twitter) {
|
else if (facebook && twitter) {
|
||||||
imageView.setImageResource(R.drawable.no_linkedin);
|
imageView.setImageResource(R.drawable.no_linkedin);
|
||||||
}
|
}
|
||||||
else if (facebook && linkedin) {
|
else if (facebook && linkedin) {
|
||||||
imageView.setImageResource(R.drawable.no_twitter);
|
imageView.setImageResource(R.drawable.no_twitter);
|
||||||
}
|
}
|
||||||
else if (twitter && linkedin) {
|
else if (twitter && linkedin) {
|
||||||
imageView.setImageResource(R.drawable.no_fb);
|
imageView.setImageResource(R.drawable.no_fb);
|
||||||
}
|
}
|
||||||
else if (twitter) {
|
else if (twitter) {
|
||||||
imageView.setImageResource(R.drawable.twitter);
|
imageView.setImageResource(R.drawable.twitter);
|
||||||
}
|
}
|
||||||
else if (facebook) {
|
else if (facebook) {
|
||||||
imageView.setImageResource(R.drawable.fb);
|
imageView.setImageResource(R.drawable.fb);
|
||||||
}
|
}
|
||||||
else if (linkedin) {
|
else if (linkedin) {
|
||||||
imageView.setImageResource(R.drawable.linkedin);
|
imageView.setImageResource(R.drawable.linkedin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
imageView.setImageResource(R.drawable.no_all);
|
imageView.setImageResource(R.drawable.no_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount(){
|
public int getCount(){
|
||||||
return this.users.size();
|
return this.users.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getPositionForSection(int section)
|
public int getPositionForSection(int section)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if(!enableSections) return 0;
|
if(!enableSections) return 0;
|
||||||
if (section == sections.length)
|
if (section == sections.length)
|
||||||
section--;
|
section--;
|
||||||
String letter = sections[section];
|
String letter = sections[section];
|
||||||
|
|
||||||
return alphaIndexer.get(letter);
|
return alphaIndexer.get(letter);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
Log.d("getPositionForSection", String.valueOf(section));
|
Log.d("getPositionForSection", String.valueOf(section));
|
||||||
Log.d("getPositionForSection", "alphaindexer: " + alphaIndexer.toString());
|
Log.d("getPositionForSection", "alphaindexer: " + alphaIndexer.toString());
|
||||||
Log.d("getPositionForSection", "sections: " + getSections());
|
Log.d("getPositionForSection", "sections: " + getSections());
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSectionForPosition(int position)
|
public int getSectionForPosition(int position)
|
||||||
{
|
{
|
||||||
// Log.d("getSectionForPosition", "recievied position : " + String.valueOf(position));
|
// Log.d("getSectionForPosition", "recievied position : " + String.valueOf(position));
|
||||||
if(!enableSections) return 0;
|
if(!enableSections) return 0;
|
||||||
int prevIndex = 0;
|
int prevIndex = 0;
|
||||||
// for(int i = 0; i < sections.length; i++)
|
// for(int i = 0; i < sections.length; i++)
|
||||||
// {
|
// {
|
||||||
// if(getPositionForSection(i) > position && prevIndex <= position)
|
// if(getPositionForSection(i) > position && prevIndex <= position)
|
||||||
// {
|
// {
|
||||||
// prevIndex = i ;
|
// prevIndex = i ;
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// prevIndex = i;
|
// prevIndex = i;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < sections.length) {
|
while (i < sections.length) {
|
||||||
// Log.d("i", "------------>" + String.valueOf(i));
|
// Log.d("i", "------------>" + String.valueOf(i));
|
||||||
// Log.d("sectionsLength", "------------>" + String.valueOf(sections.length));
|
// Log.d("sectionsLength", "------------>" + String.valueOf(sections.length));
|
||||||
if (getPositionForSection(i) > position && prevIndex <= position)
|
if (getPositionForSection(i) > position && prevIndex <= position)
|
||||||
{
|
{
|
||||||
prevIndex = i;
|
prevIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prevIndex = i;
|
prevIndex = i;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
prevIndex--;
|
prevIndex--;
|
||||||
// Log.d("getSectionForPosition", "Returning : " + String.valueOf(prevIndex));
|
// Log.d("getSectionForPosition", "Returning : " + String.valueOf(prevIndex));
|
||||||
return prevIndex;
|
return prevIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getSections()
|
public Object[] getSections()
|
||||||
{
|
{
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public android.widget.Filter getFilter()
|
public android.widget.Filter getFilter()
|
||||||
{
|
{
|
||||||
if(filter == null)
|
if(filter == null)
|
||||||
filter = new LeWebFilter();
|
filter = new LeWebFilter();
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Currently filters only by Lname
|
// Currently filters only by Lname
|
||||||
private class LeWebFilter extends android.widget.Filter
|
private class LeWebFilter extends android.widget.Filter
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
// NOTE: this function is *always* called from a background thread, and
|
// NOTE: this function is *always* called from a background thread, and
|
||||||
// not the UI thread.
|
// not the UI thread.
|
||||||
Log.d("Filter", "Filter .....");
|
Log.d("Filter", "Filter .....");
|
||||||
|
|
||||||
FilterResults results = new FilterResults();
|
FilterResults results = new FilterResults();
|
||||||
|
|
||||||
|
|
||||||
if (originalUsers == null) {
|
if (originalUsers == null) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
originalUsers = new ArrayList<Attendee>(users);
|
originalUsers = new ArrayList<Attendee>(users);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (constraint == null || constraint.length() == 0) {
|
if (constraint == null || constraint.length() == 0) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
ArrayList<Attendee> list = new ArrayList<Attendee>(originalUsers);
|
ArrayList<Attendee> list = new ArrayList<Attendee>(originalUsers);
|
||||||
results.values = list;
|
results.values = list;
|
||||||
results.count = list.size();
|
results.count = list.size();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
String constraintStr = constraint.toString().toLowerCase();
|
String constraintStr = constraint.toString().toLowerCase();
|
||||||
final ArrayList<Attendee> values = originalUsers;
|
final ArrayList<Attendee> values = originalUsers;
|
||||||
final int count = values.size();
|
final int count = values.size();
|
||||||
|
|
||||||
final ArrayList<Attendee> newValues = new ArrayList<Attendee>();
|
final ArrayList<Attendee> newValues = new ArrayList<Attendee>();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final Attendee value = values.get(i);
|
final Attendee value = values.get(i);
|
||||||
final String valueText;
|
final String valueText;
|
||||||
if (companySections)
|
if (companySections)
|
||||||
{
|
{
|
||||||
valueText = value.getCompany().toLowerCase();
|
valueText = value.getCompany().toLowerCase();
|
||||||
}
|
}
|
||||||
else if (countrySections){
|
else if (countrySections){
|
||||||
valueText = value.getCountry().toLowerCase();
|
valueText = value.getCountry().toLowerCase();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
valueText = value.getLname().toLowerCase();
|
valueText = value.getLname().toLowerCase() +
|
||||||
}
|
" " + value.getFname().toLowerCase();
|
||||||
|
}
|
||||||
// First match against the whole, non-splitted value
|
|
||||||
if (valueText.startsWith(constraintStr)) {
|
// First match against the whole, non-splitted value
|
||||||
newValues.add(value);
|
if (valueText.startsWith(constraintStr)) {
|
||||||
} else {
|
newValues.add(value);
|
||||||
final String[] words = valueText.split(" ");
|
} else {
|
||||||
final int wordCount = words.length;
|
final String[] words = valueText.split(" ");
|
||||||
|
final int wordCount = words.length;
|
||||||
for (int k = 0; k < wordCount; k++) {
|
|
||||||
if (words[k].startsWith(constraintStr)) {
|
for (int k = 0; k < wordCount; k++) {
|
||||||
newValues.add(value);
|
if (words[k].startsWith(constraintStr)) {
|
||||||
break;
|
newValues.add(value);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
results.values = newValues;
|
|
||||||
results.count = newValues.size();
|
results.values = newValues;
|
||||||
} catch (Exception e) {
|
results.count = newValues.size();
|
||||||
// TODO Auto-generated catch block
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
// TODO Auto-generated catch block
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return results;
|
|
||||||
}
|
return results;
|
||||||
// constraint = constraint.toString().toLowerCase();
|
}
|
||||||
// if(constraint != null && constraint.toString().length() > 0)
|
// 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>();
|
// Log.d("Filter", "constraint not null with value <" + constraint.toString() + ">");
|
||||||
// ArrayList<Attendee> lItems = new ArrayList<Attendee>();
|
// ArrayList<Attendee> filt = new ArrayList<Attendee>();
|
||||||
// synchronized (this)
|
// ArrayList<Attendee> lItems = new ArrayList<Attendee>();
|
||||||
// {
|
// synchronized (this)
|
||||||
// lItems.addAll(users);
|
// {
|
||||||
// }
|
// lItems.addAll(users);
|
||||||
// for(int i = 0, l = lItems.size(); i < l; i++)
|
// }
|
||||||
// {
|
// for(int i = 0, l = lItems.size(); i < l; i++)
|
||||||
// Attendee m = lItems.get(i);
|
// {
|
||||||
// if (countrySections && m.getCountry().toLowerCase().contains(constraint))
|
// Attendee m = lItems.get(i);
|
||||||
// filt.add(m);
|
// if (countrySections && m.getCountry().toLowerCase().contains(constraint))
|
||||||
// else if (companySections && m.getCompany().toLowerCase().contains(constraint))
|
// filt.add(m);
|
||||||
// filt.add(m);
|
// else if (companySections && m.getCompany().toLowerCase().contains(constraint))
|
||||||
// else if (m.getLname().toLowerCase().contains(constraint))
|
// filt.add(m);
|
||||||
// filt.add(m);
|
// else if (m.getLname().toLowerCase().contains(constraint))
|
||||||
// }
|
// filt.add(m);
|
||||||
// result.count = filt.size();
|
// }
|
||||||
// result.values = filt;
|
// result.count = filt.size();
|
||||||
// }
|
// result.values = filt;
|
||||||
//// else if (constraint == null || constraint.length() == 0)
|
// }
|
||||||
//// {
|
//// else if (constraint == null || constraint.length() == 0)
|
||||||
//// ArrayList<Attendee> list = new ArrayList<Attendee>(originalUsers);
|
//// {
|
||||||
//// result.values=list;
|
//// ArrayList<Attendee> list = new ArrayList<Attendee>(originalUsers);
|
||||||
//// result.count = list.size();
|
//// result.values=list;
|
||||||
//// }
|
//// result.count = list.size();
|
||||||
// else
|
//// }
|
||||||
// {
|
// else
|
||||||
// synchronized(this)
|
// {
|
||||||
// {
|
// synchronized(this)
|
||||||
// result.values = users;
|
// {
|
||||||
// result.count = users.size();
|
// result.values = users;
|
||||||
// }
|
// result.count = users.size();
|
||||||
// }
|
// }
|
||||||
// return result;
|
// }
|
||||||
|
// return result;
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
@SuppressWarnings("unchecked")
|
||||||
// NOTE: this function is *always* called from the UI thread.
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
users = (ArrayList<Attendee>)results.values;
|
// NOTE: this function is *always* called from the UI thread.
|
||||||
if (results.count > 0) {
|
users = (ArrayList<Attendee>)results.values;
|
||||||
// buildHashIndexer();
|
if (results.count > 0) {
|
||||||
// buildSections();
|
// buildHashIndexer();
|
||||||
notifyDataSetChanged();
|
// buildSections();
|
||||||
} else {
|
notifyDataSetChanged();
|
||||||
// buildHashIndexer();
|
} else {
|
||||||
// buildSections();
|
// buildHashIndexer();
|
||||||
notifyDataSetInvalidated();
|
// buildSections();
|
||||||
}
|
notifyDataSetInvalidated();
|
||||||
// notifyDataSetChanged();
|
}
|
||||||
// clear();
|
// notifyDataSetChanged();
|
||||||
// for(int i = 0, l = originalUsers.size(); i < l; i++)
|
// clear();
|
||||||
// add(originalUsers.get(i));
|
// for(int i = 0, l = originalUsers.size(); i < l; i++)
|
||||||
// notifyDataSetInvalidated();
|
// add(originalUsers.get(i));
|
||||||
}
|
// notifyDataSetInvalidated();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
package com.thinkit.lewebconnect;
|
package com.thinkit.lewebconnect;
|
||||||
|
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class LeWebConnect extends TabActivity{
|
public class LeWebConnect extends TabActivity{
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Resources res = getResources(); // Resource object to get Drawables
|
Resources res = getResources(); // Resource object to get Drawables
|
||||||
TabHost tabHost = getTabHost(); // The activity TabHost
|
TabHost tabHost = getTabHost(); // The activity TabHost
|
||||||
TabHost.TabSpec spec; // Resusable TabSpec for each tab
|
TabHost.TabSpec spec; // Resusable TabSpec for each tab
|
||||||
Intent intent; // Reusable Intent for each tab
|
Intent intent; // Reusable Intent for each tab
|
||||||
// Create an Intent to launch an Activity for the tab (to be reused)
|
// Create an Intent to launch an Activity for the tab (to be reused)
|
||||||
intent = new Intent().setClass(this, Perticipents.class);
|
intent = new Intent().setClass(this, Perticipents.class);
|
||||||
// Initialize a TabSpec for each tab and add it to the TabHost
|
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||||
spec = tabHost
|
spec = tabHost
|
||||||
.newTabSpec("perticipents")
|
.newTabSpec("perticipents")
|
||||||
.setIndicator("",
|
.setIndicator("",
|
||||||
res.getDrawable(R.drawable.ic_tab_perticipents))
|
res.getDrawable(R.drawable.ic_tab_perticipents))
|
||||||
.setContent(intent);
|
.setContent(intent);
|
||||||
tabHost.addTab(spec);
|
tabHost.addTab(spec);
|
||||||
// Do the same for the other tabs
|
// Do the same for the other tabs
|
||||||
intent = new Intent().setClass(this, Likes.class);
|
intent = new Intent().setClass(this, Likes.class);
|
||||||
spec = tabHost
|
spec = tabHost
|
||||||
.newTabSpec("likes")
|
.newTabSpec("likes")
|
||||||
.setIndicator("",
|
.setIndicator("",
|
||||||
res.getDrawable(R.drawable.ic_tab_favorites))
|
res.getDrawable(R.drawable.ic_tab_favorites))
|
||||||
.setContent(intent);
|
.setContent(intent);
|
||||||
tabHost.addTab(spec);
|
tabHost.addTab(spec);
|
||||||
tabHost.setCurrentTab(0);
|
tabHost.setCurrentTab(0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
Log.d("Error", e.toString());
|
Log.d("Error", e.toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package com.thinkit.lewebconnect;
|
package com.thinkit.lewebconnect;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class Likes extends Activity {
|
public class Likes extends Activity {
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,35 +1,74 @@
|
|||||||
package com.thinkit.lewebconnect;
|
package com.thinkit.lewebconnect;
|
||||||
import com.thinkit.lewebconnect.R;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import android.app.Activity;
|
import java.net.MalformedURLException;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.widget.TextView;
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
public class UserProfile extends Activity {
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
import com.thinkit.lewebconnect.R;
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onCreate(savedInstanceState);
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
try {
|
import android.view.View;
|
||||||
setContentView(R.layout.profile);
|
import android.widget.Button;
|
||||||
setTitle(R.string.user_profile);
|
import android.widget.TextView;
|
||||||
TextView mUserName = (TextView) findViewById(R.id.profile_name);
|
import android.widget.Toast;
|
||||||
TextView mCompany = (TextView) findViewById(R.id.profile_company);
|
|
||||||
TextView mCountry = (TextView) findViewById(R.id.profile_country);
|
|
||||||
Bundle extras = getIntent().getExtras();
|
public class UserProfile extends Activity {
|
||||||
if (extras != null) {
|
|
||||||
String fname = extras.getString(Attendee.FNAME);
|
@Override
|
||||||
String lname = extras.getString(Attendee.LNAME);
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mUserName.setText(lname + " " + fname);
|
// TODO Auto-generated method stub
|
||||||
mCompany.setText(extras.getString(Attendee.COMPANY));
|
super.onCreate(savedInstanceState);
|
||||||
mCountry.setText(extras.getString(Attendee.COUNTRY));
|
|
||||||
}
|
try {
|
||||||
} catch (Exception e) {
|
setContentView(R.layout.profile);
|
||||||
// TODO Auto-generated catch block
|
setTitle(R.string.user_profile);
|
||||||
e.printStackTrace();
|
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;
|
package com.thinkit.lewebconnect;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class WebService {
|
public class WebService {
|
||||||
static String XML_DB_URL = "http://leweb.i-think-it.com/get/";
|
static String XML_DB_URL = "http://leweb.i-think-it.com/get/";
|
||||||
static private String FILENAME = "leweb.xml";
|
static String INCREMENT_USER = "http://leweb.i-think-it.com/inc/?id=";
|
||||||
private int bufsize = 1024;
|
static private String FILENAME = "leweb.xml";
|
||||||
private Context context;
|
private int bufsize = 1024;
|
||||||
|
private Context context;
|
||||||
public WebService(Context appcontext)
|
|
||||||
{
|
public WebService(Context appcontext)
|
||||||
Log.d("WebService", "starting web service constructor");
|
{
|
||||||
this.context = appcontext;
|
Log.d("WebService", "starting web service constructor");
|
||||||
}
|
this.context = appcontext;
|
||||||
|
}
|
||||||
|
|
||||||
public void GetRemoteDB() throws IOException
|
|
||||||
{
|
public void GetRemoteDB() throws IOException
|
||||||
Log.d("WebService", "inside getremote");
|
{
|
||||||
URL url = new URL(XML_DB_URL);
|
Log.d("WebService", "inside getremote");
|
||||||
InputStream input = url.openStream();
|
URL url = new URL(XML_DB_URL);
|
||||||
Log.d("WebService", "Opened remote streamm starting download");
|
InputStream input = url.openStream();
|
||||||
try {
|
Log.d("WebService", "Opened remote streamm starting download");
|
||||||
FileOutputStream output = context.openFileOutput(FILENAME, Context.MODE_PRIVATE);
|
try {
|
||||||
try {
|
FileOutputStream output = context.openFileOutput(FILENAME, Context.MODE_PRIVATE);
|
||||||
byte[] buffer = new byte[bufsize];
|
try {
|
||||||
int bytesRead = 0;
|
byte[] buffer = new byte[bufsize];
|
||||||
while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
|
int bytesRead = 0;
|
||||||
Log.d("WebService", new String(buffer, 0, bufsize));
|
while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
|
||||||
output.write(buffer, 0, buffer.length);
|
Log.d("WebService", new String(buffer, 0, bufsize));
|
||||||
}
|
output.write(buffer, 0, buffer.length);
|
||||||
} finally {
|
}
|
||||||
output.close();
|
} finally {
|
||||||
}
|
output.close();
|
||||||
} finally {
|
}
|
||||||
input.close();
|
} finally {
|
||||||
}
|
input.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,118 +1,118 @@
|
|||||||
package com.thinkit.lewebconnect;
|
package com.thinkit.lewebconnect;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
public class XMLfunctions {
|
public class XMLfunctions {
|
||||||
|
|
||||||
public final static Document XMLfromString(String xml){
|
public final static Document XMLfromString(String xml){
|
||||||
|
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
|
|
||||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
|
|
||||||
InputSource is = new InputSource();
|
InputSource is = new InputSource();
|
||||||
is.setCharacterStream(new StringReader(xml));
|
is.setCharacterStream(new StringReader(xml));
|
||||||
doc = db.parse(is);
|
doc = db.parse(is);
|
||||||
|
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
System.out.println("XML parse error: " + e.getMessage());
|
System.out.println("XML parse error: " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
System.out.println("Wrong XML file structure: " + e.getMessage());
|
System.out.println("Wrong XML file structure: " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("I/O exeption: " + e.getMessage());
|
System.out.println("I/O exeption: " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns element value
|
/** Returns element value
|
||||||
* @param elem element (it is XML tag)
|
* @param elem element (it is XML tag)
|
||||||
* @return Element value otherwise empty String
|
* @return Element value otherwise empty String
|
||||||
*/
|
*/
|
||||||
public final static String getElementValue( Node elem ) {
|
public final static String getElementValue( Node elem ) {
|
||||||
Node kid;
|
Node kid;
|
||||||
if( elem != null){
|
if( elem != null){
|
||||||
if (elem.hasChildNodes()){
|
if (elem.hasChildNodes()){
|
||||||
for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
|
for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
|
||||||
if( kid.getNodeType() == Node.TEXT_NODE ){
|
if( kid.getNodeType() == Node.TEXT_NODE ){
|
||||||
return kid.getNodeValue();
|
return kid.getNodeValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getXML(){
|
public static String getXML(){
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||||
HttpGet get = new HttpGet(WebService.XML_DB_URL);
|
HttpGet get = new HttpGet(WebService.XML_DB_URL);
|
||||||
get.setHeader("charset", "utf-8");
|
get.setHeader("charset", "utf-8");
|
||||||
|
|
||||||
HttpResponse httpResponse = httpClient.execute(get);
|
HttpResponse httpResponse = httpClient.execute(get);
|
||||||
HttpEntity httpEntity = httpResponse.getEntity();
|
HttpEntity httpEntity = httpResponse.getEntity();
|
||||||
line = EntityUtils.toString(httpEntity);
|
line = EntityUtils.toString(httpEntity, "UTF-8");
|
||||||
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
|
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
|
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
|
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int numResults(Document doc){
|
public static int numResults(Document doc){
|
||||||
NodeList results;
|
NodeList results;
|
||||||
try {
|
try {
|
||||||
results = doc.getElementsByTagName("user");
|
results = doc.getElementsByTagName("user");
|
||||||
//Log.d("XMLFunctions", results.toString());
|
//Log.d("XMLFunctions", results.toString());
|
||||||
return results.getLength();
|
return results.getLength();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getValue(Element item, String str) {
|
public static String getValue(Element item, String str) {
|
||||||
NodeList n = item.getElementsByTagName(str);
|
NodeList n = item.getElementsByTagName(str);
|
||||||
return XMLfunctions.getElementValue(n.item(0));
|
return XMLfunctions.getElementValue(n.item(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue