This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
329 additions
and
1 deletion.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
Android/app/src/main/java/com/thesis/smukov/anative/Adapters/ContactsAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.thesis.smukov.anative.Adapters; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
import android.widget.TextView; | ||
|
||
import com.thesis.smukov.anative.Models.Contact; | ||
import com.thesis.smukov.anative.R; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by smuko on 05-Jul-16. | ||
*/ | ||
public class ContactsAdapter extends BaseAdapter { | ||
|
||
private final List<Contact> lstContacts; | ||
private Activity context; | ||
|
||
public ContactsAdapter(Activity context, List<Contact> contacts) { | ||
this.context = context; | ||
this.lstContacts = contacts; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
if (lstContacts != null) { | ||
return lstContacts.size(); | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
@Override | ||
public Contact getItem(int position) { | ||
if (lstContacts != null) { | ||
return lstContacts.get(position); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return position; | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
ViewHolder holder; | ||
Contact contact = getItem(position); | ||
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
|
||
if (convertView == null) { | ||
convertView = vi.inflate(R.layout.list_item_contact, null); | ||
holder = createViewHolder(convertView); | ||
convertView.setTag(holder); | ||
} else { | ||
holder = (ViewHolder) convertView.getTag(); | ||
} | ||
|
||
holder.txtFullName.setText(contact.getFullName()); | ||
holder.txtEmployment.setText(contact.getEmployment()); | ||
holder.txtEducation.setText(contact.getEducation()); | ||
|
||
return convertView; | ||
} | ||
|
||
public void add(Contact contact) { | ||
lstContacts.add(contact); | ||
} | ||
|
||
public void add(List<Contact> contacts) { | ||
lstContacts.addAll(contacts); | ||
} | ||
|
||
private ViewHolder createViewHolder(View v) { | ||
ViewHolder holder = new ViewHolder(); | ||
holder.txtFullName = (TextView) v.findViewById(R.id.profile_name); | ||
holder.txtEmployment = (TextView) v.findViewById(R.id.txtEmployment); | ||
holder.txtEducation = (TextView) v.findViewById(R.id.txtEducation); | ||
return holder; | ||
} | ||
|
||
private static class ViewHolder { | ||
public TextView txtFullName; | ||
public TextView txtEmployment; | ||
public TextView txtEducation; | ||
} | ||
|
||
} |
92 changes: 92 additions & 0 deletions
92
Android/app/src/main/java/com/thesis/smukov/anative/Models/Contact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.thesis.smukov.anative.Models; | ||
|
||
/** | ||
* Created by smuko on 05-Jul-16. | ||
*/ | ||
public class Contact { | ||
private Long id; | ||
private Long userId; | ||
private String firstName; | ||
private String lastName; | ||
private String employment; | ||
private String education; | ||
private String knowledgeableIn; | ||
private String interests; | ||
private String currentGoals; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Long getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(Long userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public String getFullName() { | ||
return firstName + " " + lastName; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getEmployment() { | ||
return employment; | ||
} | ||
|
||
public void setEmployment(String employment) { | ||
this.employment = employment; | ||
} | ||
|
||
public String getEducation() { | ||
return education; | ||
} | ||
|
||
public void setEducation(String education) { | ||
this.education = education; | ||
} | ||
|
||
public String getKnowledgeableIn() { | ||
return knowledgeableIn; | ||
} | ||
|
||
public void setKnowledgeableIn(String knowledgeableIn) { | ||
this.knowledgeableIn = knowledgeableIn; | ||
} | ||
|
||
public String getInterests() { | ||
return interests; | ||
} | ||
|
||
public void setInterests(String interests) { | ||
this.interests = interests; | ||
} | ||
|
||
public String getCurrentGoals() { | ||
return currentGoals; | ||
} | ||
|
||
public void setCurrentGoals(String currentGoals) { | ||
this.currentGoals = currentGoals; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...rc/main/java/com/thesis/smukov/anative/NavigationFragment/BaseNavigationListFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.thesis.smukov.anative.NavigationFragment; | ||
|
||
import android.app.ListFragment; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.view.View; | ||
|
||
|
||
public abstract class BaseNavigationListFragment extends ListFragment | ||
implements INavigationFragment{ | ||
|
||
protected View myView; | ||
protected FloatingActionButton fab; | ||
|
||
protected abstract void prepareFloatingActionButton(); | ||
} |
78 changes: 78 additions & 0 deletions
78
Android/app/src/main/java/com/thesis/smukov/anative/NavigationFragment/ContactsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.thesis.smukov.anative.NavigationFragment; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.thesis.smukov.anative.Adapters.ContactsAdapter; | ||
import com.thesis.smukov.anative.Models.Contact; | ||
import com.thesis.smukov.anative.R; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by smuko on 05-Jul-16. | ||
*/ | ||
public class ContactsFragment extends BaseNavigationListFragment { | ||
|
||
private ContactsAdapter adapter; | ||
private ArrayList<Contact> lstContacts; | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
myView = inflater.inflate(R.layout.contacts_layout, container, false); | ||
return myView; | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
|
||
prepareFloatingActionButton(); | ||
|
||
loadContacts(); | ||
} | ||
|
||
@Override | ||
protected void prepareFloatingActionButton() { | ||
if(fab == null){ | ||
fab = (FloatingActionButton) getActivity().findViewById(R.id.fab); | ||
} | ||
fab.hide(); | ||
} | ||
|
||
public void displayContact(Contact contact) { | ||
adapter.add(contact); | ||
adapter.notifyDataSetChanged(); | ||
} | ||
|
||
private void loadContacts(){ | ||
|
||
lstContacts = new ArrayList<Contact>(); | ||
|
||
Contact con = new Contact(); | ||
con.setFirstName("Gregory"); | ||
con.setLastName("House"); | ||
con.setEmployment("Head of Diagnostic @ PPT Hospital"); | ||
con.setEducation("Attended Hopkins University 1979-1984"); | ||
lstContacts.add(con); | ||
Contact con2 = new Contact(); | ||
con2.setFirstName("Hugh"); | ||
con2.setLastName("Laurie"); | ||
con2.setEmployment("Actor, Writer, Director, Author, etc."); | ||
con2.setEducation("Attended Selwyn College, Cambridge 1978 - 1984"); | ||
lstContacts.add(con2); | ||
|
||
adapter = new ContactsAdapter(getActivity(), new ArrayList<Contact>()); | ||
setListAdapter(adapter); | ||
|
||
for(int i=0; i<lstContacts.size(); i++) { | ||
Contact contact = lstContacts.get(i); | ||
displayContact(contact); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ListView android:id="@id/android:list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_weight="1" | ||
android:drawSelectorOnTop="false"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:paddingTop="7dp" | ||
android:paddingBottom="7dp"> | ||
|
||
<include layout="@layout/profile_header"/> | ||
|
||
<Space | ||
android:layout_width="20dp" | ||
android:layout_height="20dp" /> | ||
|
||
<TextView | ||
android:id="@+id/txtEmployment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:text="@string/hint_employment" | ||
android:textSize="16sp" | ||
android:ellipsize="middle" | ||
/> | ||
|
||
|
||
<TextView | ||
android:id="@+id/txtEducation" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="16sp" | ||
android:layout_gravity="center_horizontal" | ||
android:text="@string/hint_faculty" /> | ||
|
||
</LinearLayout> |