Android Open Source - you2peer Group List File






From Project

Back to project page you2peer.

License

The source code is released under:

Apache License

If you think the Android project you2peer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.u2p.ui.component;
//w w  w  .j a  v  a2  s.  c o  m
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.util.Log;

public class GroupListFile {
  private HashMap<String,ArrayList<ItemFile>> listGroup;
  
  public GroupListFile(){
    listGroup=new HashMap<String,ArrayList<ItemFile>>();
  }
  
  public void addListFileToGroup(String group,ArrayList<ItemFile> files){
    if(!listGroup.containsKey(group)){
      listGroup.put(group, files);
    }else{
      List<ItemFile> aux=listGroup.get(group);
      List<String> auxNames = new ArrayList<String>();
      for(ItemFile i: aux){
        Log.d("GL", "AUX"+i.getName()+ " is in list PREVIOUS");
        auxNames.add(i.getName());
      }
      for(ItemFile i: files)
        Log.d("GL", "FILES: "+i.getName()+ " is in lis PREVIOUS");
      if(aux.size()!=0){
        for(ItemFile file:files){
          if(!auxNames.contains(file.getName())){
            aux.add(file);
            Log.d("GL", file.getName()+" ADDED to list");
          }
        }
      }else{
        aux.addAll(files);
      }
      for(ItemFile i:aux)
        Log.d("GL", i.getName() + " is in FINAL list");
      /*List<ItemFile> toAdd = new ArrayList<ItemFile>();
      if(aux.size()!=0){
        for(ItemFile i:aux){
          for(ItemFile f:files){
            if(!aux.contains(f) && !toAdd.contains(f))
              toAdd.add(f);
          }
        }
        aux.addAll(toAdd);
      }else{
        aux.addAll(files);
      }*/
    }
  }
  
  public ArrayList<ItemFile> getListFile(String group){
    return this.listGroup.get(group);
  }
  
  public ItemFile getFile(String group,String name){
    if(listGroup.containsKey(group)){
      List<ItemFile> aux=listGroup.get(group);
      for(ItemFile file:aux){
        if(file.getName().equals(name))
          return file;
      }
    }
    return null;
  }
  
  public void addFileToGroup(ItemFile file){
    if(listGroup.containsKey(file.getGroup())){
      List<ItemFile> aux=listGroup.get(file.getGroup());
      ItemFile auxFile = null;
      for(ItemFile f:aux){
        Log.d("DB","f "+f.getName()+" "+file.getName());
        if(f.getName().equals(file.getName())){
          Log.d("DB","equals");
          auxFile = f;
          break;
        }
        
      }
      if(auxFile != null){
        aux.remove(auxFile);
        Log.d("DB","remove");
        aux.add(file);
        Log.d("DB","add");
      }
    }
  }
}




Java Source Code List

com.u2p.core.comm.Client.java
com.u2p.core.comm.Server.java
com.u2p.core.db.DbDataSource.java
com.u2p.core.db.DbFile.java
com.u2p.core.db.DbGroups.java
com.u2p.core.db.DbU2P.java
com.u2p.core.db.DbUser.java
com.u2p.core.nsd.NsdHelper.java
com.u2p.events.ActivityEventsGenerator.java
com.u2p.events.ActivityEventsListener.java
com.u2p.events.ActivityEvents.java
com.u2p.events.FileEvent.java
com.u2p.events.ListEvent.java
com.u2p.events.NewClientEvent.java
com.u2p.events.NewGroupList.java
com.u2p.events.ServerEventsGenerator.java
com.u2p.events.ServerEventsListener.java
com.u2p.events.VoteEvent.java
com.u2p.messages.ACK.java
com.u2p.messages.Authentication.java
com.u2p.messages.FileAnswer.java
com.u2p.messages.FileRequest.java
com.u2p.messages.ListAnswer.java
com.u2p.messages.ListRequest.java
com.u2p.messages.NewFile.java
com.u2p.messages.StillAlive.java
com.u2p.messages.VoteFile.java
com.u2p.ui.FileDetailsActivity.java
com.u2p.ui.FileSelectionActivity.java
com.u2p.ui.MainActivity.java
com.u2p.ui.adapters.ItemFileAdapter.java
com.u2p.ui.component.GroupListFile.java
com.u2p.ui.component.ItemFile.java
com.u2p.ui.component.LoginDialogFragment.java