CustomList improvement

parent 558087b7
...@@ -84,5 +84,6 @@ ...@@ -84,5 +84,6 @@
<string name="fa_certificate">&#xf0a3;</string> <string name="fa_certificate">&#xf0a3;</string>
<string name="fa_flask">&#xf0c3;</string> <string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string> <string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</string>
</resources> </resources>
...@@ -23,6 +23,7 @@ import java.util.Vector; ...@@ -23,6 +23,7 @@ import java.util.Vector;
import static com.yottacode.pictogram.R.string.fa_certificate; import static com.yottacode.pictogram.R.string.fa_certificate;
import static com.yottacode.pictogram.R.string.fa_flask; import static com.yottacode.pictogram.R.string.fa_flask;
import static com.yottacode.pictogram.R.string.fa_exclamation_triangle; import static com.yottacode.pictogram.R.string.fa_exclamation_triangle;
import static com.yottacode.pictogram.R.string.fa_user_plus;
/** /**
* Creates a View for each student on the list with a photo and his/her name. * Creates a View for each student on the list with a photo and his/her name.
...@@ -30,7 +31,6 @@ import static com.yottacode.pictogram.R.string.fa_exclamation_triangle; ...@@ -30,7 +31,6 @@ import static com.yottacode.pictogram.R.string.fa_exclamation_triangle;
*/ */
public class CustomList extends ArrayAdapter<String>{ public class CustomList extends ArrayAdapter<String>{
private boolean color;
private final Activity context; private final Activity context;
private final String[] name_surname; private final String[] name_surname;
private final Vector<Bitmap> images; private final Vector<Bitmap> images;
...@@ -48,7 +48,6 @@ public class CustomList extends ArrayAdapter<String>{ ...@@ -48,7 +48,6 @@ public class CustomList extends ArrayAdapter<String>{
this.name_surname = name_surname; this.name_surname = name_surname;
this.images = images; this.images = images;
this.licenses = licenses; this.licenses = licenses;
this.color = true;
} }
/** /**
...@@ -60,16 +59,21 @@ public class CustomList extends ArrayAdapter<String>{ ...@@ -60,16 +59,21 @@ public class CustomList extends ArrayAdapter<String>{
@Override @Override
public View getView(int position, View view, ViewGroup parent) { public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater(); LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.list_single, null, true); View rowView = inflater.inflate(R.layout.list_single, null, true);
Typeface fontAwesome = Typeface.createFromAsset( getContext().getAssets(), "fonts/fontawesome-webfont.ttf" );
// Name // Name
TextView txtTitle = (TextView) rowView.findViewById(R.id.loginStudentName); TextView txtTitle = (TextView) rowView.findViewById(R.id.loginStudentName);
txtTitle.setText(name_surname[position]);
txtTitle.setTextColor(ContextCompat.getColor(context, R.color.VerdeApp));
// License, except add student view // All students info, except last item (new student)
TextView licenseView = (TextView) rowView.findViewById(R.id.loginStudentLicense);
if(!name_surname[position].equals(getContext().getString(R.string.addStudent))){ if(!name_surname[position].equals(getContext().getString(R.string.addStudent))){
// License, except add student view
TextView licenseView = (TextView) rowView.findViewById(R.id.loginStudentLicense);
licenseView.setTypeface(fontAwesome);
if(licenses[position].equals("pro")) { if(licenses[position].equals("pro")) {
licenseView.setText(fa_certificate); licenseView.setText(fa_certificate);
licenseView.setTextColor(getContext().getResources().getColor(R.color.text_primary)); licenseView.setTextColor(getContext().getResources().getColor(R.color.text_primary));
...@@ -80,35 +84,32 @@ public class CustomList extends ArrayAdapter<String>{ ...@@ -80,35 +84,32 @@ public class CustomList extends ArrayAdapter<String>{
licenseView.setText(fa_exclamation_triangle); licenseView.setText(fa_exclamation_triangle);
licenseView.setTextColor(getContext().getResources().getColor(R.color.text_danger)); licenseView.setTextColor(getContext().getResources().getColor(R.color.text_danger));
} }
Typeface font = Typeface.createFromAsset( getContext().getAssets(), "fonts/fontawesome-webfont.ttf" );
licenseView.setTypeface(font);
}
// Image
ImageView imageView = (ImageView) rowView.findViewById(R.id.loginStudentPhoto);
txtTitle.setText(name_surname[position]);
ImageView fondo = (ImageView) rowView.findViewById(R.id.fondo); // Student image
ImageView imageView = (ImageView) rowView.findViewById(R.id.loginStudentPhoto);
if (images.elementAt(position) != null){
imageView.setImageBitmap(images.elementAt(position));
}else{
imageView.setImageResource(R.drawable.anonymous_student);
}
//if(color){
// color = false;
// rowView.setBackgroundColor(ContextCompat.getColor(context, R.color.VerdeApp));
// txtTitle.setTextColor(ContextCompat.getColor(context, R.color.BlancoApp));
// fondo.setBackgroundResource(R.drawable.round_design_photo_green);
//}else{
// color = true;
rowView.setBackgroundColor(ContextCompat.getColor(context, R.color.BlancoApp));
txtTitle.setTextColor(ContextCompat.getColor(context, R.color.VerdeApp));
fondo.setBackgroundResource(R.drawable.round_design_photo_white);
//}
//imageView.setImageResource(R.drawable.user);
if (images.elementAt(position)!=null){
imageView.setImageBitmap(images.elementAt(position));
}else{ }else{
imageView.setImageResource(R.drawable.anonymous_student); // New student
TextView newStudentView = (TextView) rowView.findViewById(R.id.loginStudentNew);
newStudentView.setTypeface(fontAwesome);
newStudentView.setTextSize(64);
newStudentView.setText(fa_user_plus);
} }
// Background
ImageView fondo = (ImageView) rowView.findViewById(R.id.fondo);
fondo.setBackgroundResource(R.drawable.round_design_photo_white);
// RowView
rowView.setBackgroundColor(ContextCompat.getColor(context, R.color.BlancoApp));
return rowView; return rowView;
} }
} }
...@@ -35,6 +35,12 @@ ...@@ -35,6 +35,12 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_gravity="center" /> android:layout_gravity="center" />
<TextView
android:id="@+id/loginStudentNew"
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="center_vertical|center_horizontal" />
</FrameLayout> </FrameLayout>
<LinearLayout <LinearLayout
......
...@@ -62,13 +62,6 @@ ...@@ -62,13 +62,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -76,6 +69,13 @@ ...@@ -76,6 +69,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment