如何为卡视图中的每个配置文件插入简单的评分系统? 我对此使用了SwipeCards实现。 因此,每个用户都有个人资料,当他们在相反的用户个人资料上滑动时,如果Firebase中的相反用户行业字段等于用户进行滑动,则他将在卡视图中看到个人资料速率为10,如果行业不等于个人资料速率为0,则必须滑动后立即显示,将新的个人资料带入名片视图
以下是用于将Firebase的用户个人资料获取到名片视图的代码。
在此相反的用户变量值是当前用户所在的行业
……………………………………………………
………..code start………….
public void getUsers(){
usersDb.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.child("name").getValue() != null) {
if (dataSnapshot.exists() && !dataSnapshot.child("connections").child("nope").hasChild(currentUId) && !dataSnapshot.child("connections").child("yeps").hasChild(currentUId) && dataSnapshot.child("industry").getValue().toString().equals(oppositeUser)) {
String profileImageUrl = "default";
if (!dataSnapshot.child("profileImageUrl").getValue().equals("default")) {
profileImageUrl = dataSnapshot.child("profileImageUrl").getValue().toString();
}
cards item = new cards(dataSnapshot.getKey(),dataSnapshot.child("name").getValue().toString(), profileImageUrl);
rowItems.add(item);
arrayAdapter.notifyDataSetChanged();
}
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
………..code end………….
This is the cord for adapter
……………………………………………………………………………….
Adapter
public class arrayAdapter extends ArrayAdapter<cards>{
Context context;
public arrayAdapter(Context context, int resourceId, List<cards> items){
super(context, resourceId, items);
}
public View getView(int position, View convertView, ViewGroup parent){
cards card_item = getItem(position);
if (convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item, parent, false);
}
TextView name = (TextView) convertView.findViewById(R.id.name);
// TextView score = (TextView) convertView.findViewById(R.id.scoreViewF);
ImageView image = (ImageView) convertView.findViewById(R.id.image);
name.setText(card_item.getName());
//score.setText(card_item.getScore());
switch(card_item.getProfileImageUrl()){
case "default":
Glide.with(convertView.getContext()).load(R.mipmap.ic_launcher).into(image);
break;
default:
Glide.clear(image);
Glide.with(convertView.getContext()).load(card_item.getProfileImageUrl()).into(image);
break;
}
return convertView;
………..code end………….
This is the cord for card view
…………………………………………………………………………………..
Cards.java
………..code start………….
public class cards {
private String userId;
private String name;
private String profileImageUrl;
public cards (String userId, String name, String profileImageUrl){
this.userId = userId;
this.name = name;
this.profileImageUrl = profileImageUrl;
}
public String getUserId(){
return userId;
}
public void setUserID(String userID){
this.userId = userId;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getProfileImageUrl(){
return profileImageUrl;
}
public void setProfileImageUrl(String profileImageUrl){
this.profileImageUrl = profileImageUrl;
}
}
………..code end………….