working on several issues

parent 12fa8213
......@@ -47,6 +47,8 @@
<string name="exitingApp">Exiting the app</string>
<string name="serverError">There is a server error. Try again later</string>
<string name="firstlogin">Login by using your user and password. In other case, register as new user on the website </string>
<string name="addStudent">Add student</string>
<string name="getLicenseStudent">Please, enter a student license</string>
<!--Semantic grammar -->
<string name="loadingGrammar">Please wait, loading vocabulary</string>
......
......@@ -49,7 +49,8 @@
<string name="exitingApp">Saliendo de la aplicación</string>
<string name="serverError">Fallo accediendo al Servidor. Inténtelo más tarde</string>
<string name="firstlogin">Por favor, introduzca su usuario y clave, o bien registrese en </string>
<string name="addStudent">Añadir estudiante</string>
<string name="getLicenseStudent">Por favor, introduzca el número de licencia del estudiante</string>
<!--Semantic grammar -->
<string name="loadingGrammar">Por favor espere, cargando vocabulario</string>
......
......@@ -50,6 +50,9 @@
<string name="exitingApp">Saliendo de la aplicación</string>
<string name="serverError">Error en el servidor de datos. Inténtelo más tarde</string>
<string name="firstlogin">Por favor, introduzca su usuario y clave, o bien registrese en </string>
<string name="addStudent">Añadir estudiante</string>
<string name="getLicenseStudent">Por favor, introduzca el número de licencia del estudiante</string>
<!--Semantic grammar -->
<string name="loadingGrammar">Please wait, loading vocabulary</string>
......
......@@ -74,7 +74,7 @@ public class CustomList extends ArrayAdapter<String>{
//}
//imageView.setImageResource(R.drawable.user);
if (images.size()>0){
if (images.elementAt(position)!=null){
imageView.setImageBitmap(images.elementAt(position));
}else{
imageView.setImageResource(R.drawable.anonymous_student);
......
package com.yottacode.pictogram.tabletlibrary.gui.login;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.GridView;
import com.yottacode.net.RestapiWrapper;
......@@ -83,11 +87,37 @@ public class StudentFragmentGrid extends Fragment{
Intent pictogramActivity = new Intent(getActivity(), VOCA.class);
startActivity(pictogramActivity);
} else {
new_user(i);
download_supervisors(PCBcontext.getPcbdb().getCurrentUser().get_id_stu());
if (this.nameStudents[i].equals(getString(R.string.addStudent)))
register_student();
else {
new_user(i);
download_supervisors(PCBcontext.getPcbdb().getCurrentUser().get_id_stu());
}
}
}
private void register_student() {
AlertDialog.Builder alert = new AlertDialog.Builder(this.getActivity());
final EditText edittext = new EditText(this.getActivity());
alert.setMessage(getString(R.string.getLicenseStudent));
alert.setTitle(getString(R.string.addStudent));
alert.setView(edittext);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//What ever you want to do with the value
String license = edittext.getText().toString();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// what ever you want to do with No option.
}
});
alert.show();
}
private void new_user(int i) {
JSONObject st = this.downloaded_students.get(i);
......@@ -145,10 +175,11 @@ public class StudentFragmentGrid extends Fragment{
}
}
private void show_student_list_online() {
final Vector<Img> imgs = new Vector<>(downloaded_students.size());
this.nameStudents=new String[downloaded_students.size()];
this.idStudents=new Vector<>(downloaded_students.size());
this.imageStudents=new Vector<>(downloaded_students.size());
int listsize=downloaded_students.size()+1;
final Vector<Img> imgs = new Vector<>(listsize);
this.nameStudents=new String[listsize];
this.idStudents=new Vector<>(listsize);
this.imageStudents=new Vector<>(listsize);
for (int i = 0; i < downloaded_students.size(); i++) {
JSONObject st;
......@@ -168,6 +199,10 @@ public class StudentFragmentGrid extends Fragment{
}
} //for
nameStudents[listsize-1]=getString(R.string.addStudent);
idStudents.add(-1);
imgs.add(new Img(-1,null,Img.STUDENT)); //it's required to download student's images
progressDialog= ProgressDialog.show(getActivity(), getString(R.string.imguserLoadingMsg),
getString(R.string.userLoadingTxt), false, false);
ImgDownloader downloader = new ImgDownloader(getActivity(), new ImgDownloader.iImgDownloaderListener() {
......@@ -314,19 +349,7 @@ public class StudentFragmentGrid extends Fragment{
e.printStackTrace();
}
}
switch (students.length()) {
case 0:
GUITools.show_alert(getActivity(), R.string.loginErrorTxt,getString(R.string.noStudentsError), new GUITools.iOKListener() {
@Override
public void ok() {
PCBcontext.getNetService().restart_app(true);
}
});
break;
default:
show_student_list_online();
}
show_student_list_online();
}
@Override
public void result(JSONObject result) {
......
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