photo of last receivers appears

This commit is contained in:
Rubén Martín Hidalgo 2016-08-04 19:42:11 +02:00
parent 850a8503c9
commit 30fb32194b
3 changed files with 50 additions and 24 deletions

View File

@ -24,7 +24,6 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -32,8 +31,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.ksoap2.serialization.SoapObject;
@ -42,9 +41,11 @@ import java.util.Vector;
import es.ugr.swad.swadroid.Constants;
import es.ugr.swad.swadroid.R;
import es.ugr.swad.swadroid.analytics.SWADroidTracker;
import es.ugr.swad.swadroid.gui.ImageFactory;
import es.ugr.swad.swadroid.model.User;
import es.ugr.swad.swadroid.modules.Module;
import es.ugr.swad.swadroid.modules.login.Login;
import es.ugr.swad.swadroid.utils.Utils;
import es.ugr.swad.swadroid.webservices.SOAPClient;
/**
@ -77,6 +78,8 @@ public class Messages extends Module {
private ArrayList<String> arrayReceiversNames;
private ArrayList<String> arrayPhotos;
/**
* Message's subject
*/
@ -114,6 +117,7 @@ public class Messages extends Module {
receiversNames = "";
arrayReceivers = new ArrayList<>();
arrayReceiversNames = new ArrayList<>();
arrayPhotos = new ArrayList<>();
eventCode = getIntent().getLongExtra("eventCode", 0);
setContentView(R.layout.messages_screen);
@ -143,6 +147,7 @@ public class Messages extends Module {
Intent intent = new Intent (Messages.this, SearchUsers.class);
intent.putExtra("receivers", arrayReceivers);
intent.putExtra("receiversNames", arrayReceiversNames);
intent.putExtra("receiversPhotos", arrayPhotos);
startActivityForResult(intent, Constants.SEARCH_USERS_REQUEST_CODE);
}
});
@ -214,7 +219,6 @@ public class Messages extends Module {
receiversNames = "";
for (int i = 0; i < csSize; i++) {
SoapObject pii = (SoapObject) soap.getProperty(i);
String nickname = pii.getProperty("userNickname").toString();
String firstname = pii.getProperty("userFirstname").toString();
String surname1 = pii.getProperty("userSurname1").toString();
String surname2 = pii.getProperty("userSurname2").toString();
@ -299,6 +303,7 @@ public class Messages extends Module {
if (data != null) {
arrayReceivers = data.getStringArrayListExtra("receivers");
arrayReceiversNames = data.getStringArrayListExtra("receiversNames");
arrayPhotos = data.getStringArrayListExtra("receiversPhotos");
receivers = "";
receiversNames = sender;
for(int i=0; i<arrayReceivers.size(); i++){
@ -316,12 +321,23 @@ public class Messages extends Module {
final LinearLayout linearLayout = (LinearLayout) inflater.inflate(id, null, false);
final TextView textName = (TextView) linearLayout.findViewById(R.id.textName);
TextView textName = (TextView) linearLayout.findViewById(R.id.textName);
textName.setText(arrayReceiversNames.get(i).toString());
final TextView textNickname = (TextView) linearLayout.findViewById(R.id.textNickname);
textNickname.setText(arrayReceivers.get(i).toString());
ImageView photo = (ImageView) linearLayout.findViewById(R.id.imageView);
String userPhoto = arrayPhotos.get(i).toString();
if (Utils.connectionAvailable(this)
&& (userPhoto != null) && !userPhoto.equals("")
&& !userPhoto.equals(Constants.NULL_VALUE)) {
ImageFactory.displayImage(getApplicationContext(), userPhoto, photo, true, true,
R.drawable.usr_bl, R.drawable.usr_bl, R.drawable.usr_bl);
} else {
Log.d(TAG, "No connection or no photo " + userPhoto);
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.topMargin = 7;
@ -334,8 +350,10 @@ public class Messages extends Module {
button.setOnClickListener( new View.OnClickListener() {
public void onClick(View view){
layout.removeView(linearLayout);
arrayReceivers.remove(textNickname.getText().toString());
arrayReceiversNames.remove(textName.getText().toString());
int position = arrayReceivers.indexOf(textNickname.getText().toString());
arrayReceivers.remove(position);
arrayReceiversNames.remove(position);
arrayPhotos.remove(position);
}
});
}

View File

@ -45,9 +45,10 @@ public class SearchUsers extends Module implements SearchView.OnQueryTextListene
private String search;
private ArrayList<String> arrayReceivers;
private ArrayList<String> arrayReceiversNames;
private ArrayList<String> arrayPhotos;
private UsersAdapter adapter;
private CheckBox checkbox;
private UsersList userFilters = new UsersList();
private UsersList userFilters;
private LinearLayout progressLayout;
private boolean hideMenu = false;
private long courseCode;
@ -59,6 +60,8 @@ public class SearchUsers extends Module implements SearchView.OnQueryTextListene
setContentView(R.layout.list_users);
setTitle(R.string.actionBarAddUser);
userFilters = new UsersList();
//users list
lvUsers = (ListView) findViewById(R.id.listItems);
lvUsers.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
@ -75,6 +78,7 @@ public class SearchUsers extends Module implements SearchView.OnQueryTextListene
arrayReceiversNames.remove(userFilters.getUsers().get(position).getUserFirstname() + " " +
userFilters.getUsers().get(position).getUserSurname1() + " " +
userFilters.getUsers().get(position).getUserSurname2());
arrayPhotos.remove(userFilters.getUsers().get(position).getUserPhoto());
}
else{
checkbox.setChecked(true);
@ -83,6 +87,7 @@ public class SearchUsers extends Module implements SearchView.OnQueryTextListene
arrayReceiversNames.add(userFilters.getUsers().get(position).getUserFirstname() + " " +
userFilters.getUsers().get(position).getUserSurname1() + " " +
userFilters.getUsers().get(position).getUserSurname2());
arrayPhotos.add(userFilters.getUsers().get(position).getUserPhoto());
}
}
});
@ -94,6 +99,7 @@ public class SearchUsers extends Module implements SearchView.OnQueryTextListene
arrayReceivers = getIntent().getStringArrayListExtra("receivers");
arrayReceiversNames = getIntent().getStringArrayListExtra("receiversNames");
arrayPhotos = getIntent().getStringArrayListExtra("receiversPhotos");
search = "";
@ -160,6 +166,7 @@ public class SearchUsers extends Module implements SearchView.OnQueryTextListene
Intent intent = new Intent();
intent.putExtra("receivers", arrayReceivers); // send receivers to parent activity
intent.putExtra("receiversNames", arrayReceiversNames);
intent.putExtra("receiversPhotos", arrayPhotos);
/*
String receivers = "";
for(int i=0; i<arrayReceivers.size(); i++)

View File

@ -71,7 +71,8 @@
android:src="@drawable/ic_action_add_receiver"
android:layout_height="50dp"
android:layout_width="50dp"
android:layout_marginRight="5dp"/>
android:layout_marginRight="5dp"
android:layout_marginBottom="9dp"/>
</LinearLayout>
<View