// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListener {
// 
//     /**
//      * Callback method to be invoked when a group in this expandable list has
//      * been clicked.
//      * 
//      * @param parent The ExpandableListConnector where the click happened
//      * @param v The view within the expandable list/ListView that was clicked
//      * @param groupPosition The group position that was clicked
//      * @param id The row id of the group that was clicked
//      * @return True if the click was handled
//      */
//     public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id);
// 
//     /**
//      * Callback method to be invoked when a group in this expandable list has
//      * been collapsed.
//      * 
//      * @param groupPosition The group position that was collapsed
//      */
//     public void onGroupCollapse(int groupPosition);
// 
//     /**
//      * Callback method to be invoked when a group in this expandable list has
//      * been expanded.
//      * 
//      * @param groupPosition The group position that was expanded
//      */
//     public void onGroupExpand(int groupPosition);
// 
//     /**
//      * Callback method to be invoked when a child in this expandable list has
//      * been clicked.
//      * 
//      * @param parent The ExpandableListView where the click happened
//      * @param v The view within the expandable list/ListView that was clicked
//      * @param groupPosition The group position that contains the child that
//      *        was clicked
//      * @param childPosition The child position within the group
//      * @param id The row id of the child that was clicked
//      * @return True if the click was handled
//      */
//     public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id);
// }
// 
// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListenerProvider {
//     public ExpandableListListener getExpandableListListener();
// }


import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.ExpandableListView;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListener;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListenerProvider;
import at.wada811.android.library.demos.broadcastreceiver.DateTimeChangeReceiver;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
        Collections.sort(activityInfos, new Comparator<ActivityInfo>(){
            @Override
            public int compare(ActivityInfo lhs, ActivityInfo rhs){
                return lhs.name.compareTo(rhs.name);
            }
        });
        // packages の生成
        TreeSet<String> packages = new TreeSet<String>();
        // activities の生成
        HashMap<String, ArrayList<ActivityInfo>> activities = new HashMap<String, ArrayList<ActivityInfo>>();
        for(ActivityInfo activityInfo : activityInfos){
            String[] splitsPackageName = activityInfo.name.split("\\.");
            String packageName = splitsPackageName[splitsPackageName.length - 2];
            packages.add(packageName);
            ArrayList<ActivityInfo> activityList = activities.get(packageName);
            if(activityList == null){
                activityList = new ArrayList<ActivityInfo>();
            }
            activityList.add(activityInfo);
            activities.put(packageName, activityList);
        }
        mActivityListAdapter = new ActivityListAdapter(this, new ArrayList<String>(packages), activities);
        // ListFragmentを初期化
        FragmentManager fragmentManager = getSupportFragmentManager();
        ActivityListFragment activityListFragment = ActivityListFragment.newInstance("Activity Not Found!");
        fragmentManager.beginTransaction().replace(R.id.fragment, activityListFragment).commit();
        activityListFragment.setListAdapter(mActivityListAdapter);
    }

    @Override
// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListener {
// 
//     /**
//      * Callback method to be invoked when a group in this expandable list has
//      * been clicked.
//      * 
//      * @param parent The ExpandableListConnector where the click happened
//      * @param v The view within the expandable list/ListView that was clicked
//      * @param groupPosition The group position that was clicked
//      * @param id The row id of the group that was clicked
//      * @return True if the click was handled
//      */
//     public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id);
// 
//     /**
//      * Callback method to be invoked when a group in this expandable list has
//      * been collapsed.
//      * 
//      * @param groupPosition The group position that was collapsed
//      */
//     public void onGroupCollapse(int groupPosition);
// 
//     /**
//      * Callback method to be invoked when a group in this expandable list has
//      * been expanded.
//      * 
//      * @param groupPosition The group position that was expanded
//      */
//     public void onGroupExpand(int groupPosition);
// 
//     /**
//      * Callback method to be invoked when a child in this expandable list has
//      * been clicked.
//      * 
//      * @param parent The ExpandableListView where the click happened
//      * @param v The view within the expandable list/ListView that was clicked
//      * @param groupPosition The group position that contains the child that
//      *        was clicked
//      * @param childPosition The child position within the group
//      * @param id The row id of the child that was clicked
//      * @return True if the click was handled
//      */
//     public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id);
// }
// 
// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/ActivityListFragment.java
// public static interface ExpandableListListenerProvider {
//     public ExpandableListListener getExpandableListListener();
// }


// Path: AndroidLibrary@wada811Demos/src/at/wada811/android/library/demos/MainActivity.java
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.ExpandableListView;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListener;
import at.wada811.android.library.demos.ActivityListFragment.ExpandableListListenerProvider;
import at.wada811.android.library.demos.broadcastreceiver.DateTimeChangeReceiver;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;

        Collections.sort(activityInfos, new Comparator<ActivityInfo>(){
            @Override
            public int compare(ActivityInfo lhs, ActivityInfo rhs){
                return lhs.name.compareTo(rhs.name);
            }
        });
        // packages の生成
        TreeSet<String> packages = new TreeSet<String>();
        // activities の生成
        HashMap<String, ArrayList<ActivityInfo>> activities = new HashMap<String, ArrayList<ActivityInfo>>();
        for(ActivityInfo activityInfo : activityInfos){
            String[] splitsPackageName = activityInfo.name.split("\\.");
            String packageName = splitsPackageName[splitsPackageName.length - 2];
            packages.add(packageName);
            ArrayList<ActivityInfo> activityList = activities.get(packageName);
            if(activityList == null){
                activityList = new ArrayList<ActivityInfo>();
            }
            activityList.add(activityInfo);
            activities.put(packageName, activityList);
        }
        mActivityListAdapter = new ActivityListAdapter(this, new ArrayList<String>(packages), activities);
        // ListFragmentを初期化
        FragmentManager fragmentManager = getSupportFragmentManager();
        ActivityListFragment activityListFragment = ActivityListFragment.newInstance("Activity Not Found!");
        fragmentManager.beginTransaction().replace(R.id.fragment, activityListFragment).commit();
        activityListFragment.setListAdapter(mActivityListAdapter);
    }

    @Override
    public ExpandableListListener getExpandableListListener(){