// Path: application/src/main/java/com/projectsexception/myapplist/model/AppInfo.java
// public class AppInfo implements Comparable<AppInfo>, Parcelable {
//     
//     private final Collator sCollator = Collator.getInstance();
//     
//     private String packageName;
//     private String name;
//     private boolean installed;
// 
//     public String getPackageName() {
//         return packageName;
//     }
// 
//     public void setPackageName(String packageName) {
//         this.packageName = packageName;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public boolean isInstalled() {
//         return installed;
//     }
// 
//     public void setInstalled(boolean installed) {
//         this.installed = installed;
//     }
// 
//     @Override
//     public int compareTo(AppInfo another) {
//         if (!installed && another.installed) {
//             return -1;
//         } else  if (installed && !another.installed) {
//             return 1;
//         }
//         return sCollator.compare(getName(), another.getName());
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(name);
//         dest.writeString(packageName);
//         dest.writeString(Boolean.toString(installed));
//     }
//     
//     public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() {
// 
//         @Override
//         public AppInfo createFromParcel(Parcel source) {
//             AppInfo appInfo = new AppInfo();
//             appInfo.setName(source.readString());
//             appInfo.setPackageName(source.readString());
//             appInfo.setInstalled(Boolean.parseBoolean(source.readString()));
//             return appInfo;
//         }
// 
//         @Override
//         public AppInfo[] newArray(int size) {
//             return new AppInfo[size];
//         }
//         
//         
//     };
//     
// 
// }


import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import com.projectsexception.myapplist.model.AppInfo;
package com.projectsexception.myapplist.xml;




public class AppXMLHandler extends DefaultHandler {
    
    private static final String PACKAGE_ELEMENT = "package";
    private static final String NAME_ELEMENT = "name";
    private static final String APP_ELEMENT = "app";
    
    private ArrayList<AppInfo> appInfoList;
    
    @Override
    public void startDocument() throws SAXException {
        appInfoList = new ArrayList<AppInfo>();
    }
    
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        if (APP_ELEMENT.equals(getName(localName, qName))) {
            // Aplication
            String name = getAttribute(attributes, NAME_ELEMENT);
            String packageName = getAttribute(attributes, PACKAGE_ELEMENT);
            if (name != null && packageName != null) {
// Path: application/src/main/java/com/projectsexception/myapplist/model/AppInfo.java
// public class AppInfo implements Comparable<AppInfo>, Parcelable {
//     
//     private final Collator sCollator = Collator.getInstance();
//     
//     private String packageName;
//     private String name;
//     private boolean installed;
// 
//     public String getPackageName() {
//         return packageName;
//     }
// 
//     public void setPackageName(String packageName) {
//         this.packageName = packageName;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public boolean isInstalled() {
//         return installed;
//     }
// 
//     public void setInstalled(boolean installed) {
//         this.installed = installed;
//     }
// 
//     @Override
//     public int compareTo(AppInfo another) {
//         if (!installed && another.installed) {
//             return -1;
//         } else  if (installed && !another.installed) {
//             return 1;
//         }
//         return sCollator.compare(getName(), another.getName());
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(name);
//         dest.writeString(packageName);
//         dest.writeString(Boolean.toString(installed));
//     }
//     
//     public static final Parcelable.Creator<AppInfo> CREATOR = new Parcelable.Creator<AppInfo>() {
// 
//         @Override
//         public AppInfo createFromParcel(Parcel source) {
//             AppInfo appInfo = new AppInfo();
//             appInfo.setName(source.readString());
//             appInfo.setPackageName(source.readString());
//             appInfo.setInstalled(Boolean.parseBoolean(source.readString()));
//             return appInfo;
//         }
// 
//         @Override
//         public AppInfo[] newArray(int size) {
//             return new AppInfo[size];
//         }
//         
//         
//     };
//     
// 
// }


// Path: application/src/main/java/com/projectsexception/myapplist/xml/AppXMLHandler.java
import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import com.projectsexception.myapplist.model.AppInfo;

package com.projectsexception.myapplist.xml;




public class AppXMLHandler extends DefaultHandler {
    
    private static final String PACKAGE_ELEMENT = "package";
    private static final String NAME_ELEMENT = "name";
    private static final String APP_ELEMENT = "app";
    
    private ArrayList<AppInfo> appInfoList;
    
    @Override
    public void startDocument() throws SAXException {
        appInfoList = new ArrayList<AppInfo>();
    }
    
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        if (APP_ELEMENT.equals(getName(localName, qName))) {
            // Aplication
            String name = getAttribute(attributes, NAME_ELEMENT);
            String packageName = getAttribute(attributes, PACKAGE_ELEMENT);
            if (name != null && packageName != null) {
                AppInfo appInfo = new AppInfo();