// Path: framework/src/main/java/com/kifile/android/cornerstone/impl/Cornerstone.java
// public class Cornerstone extends AbstractDataProviderManager {
// 
//     private static Cornerstone sInstance;
// 
//     private Cornerstone() {
//         // Make Cornerstone singleton.
//     }
// 
//     /**
//      * Use singleton here.
//      *
//      * @return
//      */
//     public static Cornerstone getInstance() {
//         if (sInstance == null) {
//             synchronized (Cornerstone.class) {
//                 if (sInstance == null) {
//                     sInstance = new Cornerstone();
//                 }
//             }
//         }
//         return sInstance;
//     }
// 
//     public static void registerProvider(String key, Class<? extends DataProvider> providerClazz) {
//         getInstance().register(key, providerClazz);
//     }
// 
//     public static DataProvider obtainProvider(String key) {
//         return getInstance().obtain(key);
//     }
// 
//     public static void releaseProvider(String key) {
//         getInstance().release(key);
//     }
// }
// 
// Path: app/src/main/java/com/kifile/android/sample/cornerstone/data/SampleDataProvider.java
// public class SampleDataProvider extends AbstractDataProvider<List<Class>> {
// 
//     public static final String KEY = SampleDataProvider.class.getSimpleName();
// 
//     public SampleDataProvider() {
//         SampleActivityFetcher fetcher = new SampleActivityFetcher();
//         fetcher.addActivity(SampleActivity.class);
//         fetcher.addActivity(ContactFetcherActivity.class);
//         fetcher.addActivity(HttpActivity.class);
//         setFetcher(fetcher);
//     }
// 
//     public class SampleActivityFetcher implements DataFetcher<List<Class>> {
// 
//         private List<Class> mActivities;
// 
//         public SampleActivityFetcher() {
//             mActivities = new ArrayList<>();
//         }
// 
//         public void addActivity(Class clazz) {
//             mActivities.add(clazz);
//         }
// 
//         @Override
//         public List<Class> fetch() {
//             return mActivities;
//         }
//     }
// 
// }


import android.app.Activity;
import android.app.Fragment;
import com.kifile.android.cornerstone.impl.Cornerstone;
import com.kifile.android.sample.cornerstone.data.SampleDataProvider;
package com.kifile.android.sample.cornerstone;



/**
 * The sample of using DataProvider in Fragment.
 *
 * @author kifile
 */
public class SampleFragment extends Fragment {

    private SampleDataProvider mProvider;

//    private DataObserver<JSONObject> mObserver = new DataObserver<JSONObject>() {
//        @Override
//        public void onDataChanged(JSONObject jsonObject) {
//            getActivity().setTitle(jsonObject.toString());
//        }
//    };

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (mProvider == null) {
            mProvider =
                    (SampleDataProvider) Cornerstone.obtainProvider(SampleDataProvider.KEY);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
//        mProvider.registerDataObserver(mObserver);
    }

    @Override
    public void onPause() {
//        mProvider.unregisterDataObserver(mObserver);
        super.onPause();
    }

// Path: framework/src/main/java/com/kifile/android/cornerstone/impl/Cornerstone.java
// public class Cornerstone extends AbstractDataProviderManager {
// 
//     private static Cornerstone sInstance;
// 
//     private Cornerstone() {
//         // Make Cornerstone singleton.
//     }
// 
//     /**
//      * Use singleton here.
//      *
//      * @return
//      */
//     public static Cornerstone getInstance() {
//         if (sInstance == null) {
//             synchronized (Cornerstone.class) {
//                 if (sInstance == null) {
//                     sInstance = new Cornerstone();
//                 }
//             }
//         }
//         return sInstance;
//     }
// 
//     public static void registerProvider(String key, Class<? extends DataProvider> providerClazz) {
//         getInstance().register(key, providerClazz);
//     }
// 
//     public static DataProvider obtainProvider(String key) {
//         return getInstance().obtain(key);
//     }
// 
//     public static void releaseProvider(String key) {
//         getInstance().release(key);
//     }
// }
// 
// Path: app/src/main/java/com/kifile/android/sample/cornerstone/data/SampleDataProvider.java
// public class SampleDataProvider extends AbstractDataProvider<List<Class>> {
// 
//     public static final String KEY = SampleDataProvider.class.getSimpleName();
// 
//     public SampleDataProvider() {
//         SampleActivityFetcher fetcher = new SampleActivityFetcher();
//         fetcher.addActivity(SampleActivity.class);
//         fetcher.addActivity(ContactFetcherActivity.class);
//         fetcher.addActivity(HttpActivity.class);
//         setFetcher(fetcher);
//     }
// 
//     public class SampleActivityFetcher implements DataFetcher<List<Class>> {
// 
//         private List<Class> mActivities;
// 
//         public SampleActivityFetcher() {
//             mActivities = new ArrayList<>();
//         }
// 
//         public void addActivity(Class clazz) {
//             mActivities.add(clazz);
//         }
// 
//         @Override
//         public List<Class> fetch() {
//             return mActivities;
//         }
//     }
// 
// }


// Path: app/src/main/java/com/kifile/android/sample/cornerstone/SampleFragment.java
import android.app.Activity;
import android.app.Fragment;
import com.kifile.android.cornerstone.impl.Cornerstone;
import com.kifile.android.sample.cornerstone.data.SampleDataProvider;

package com.kifile.android.sample.cornerstone;



/**
 * The sample of using DataProvider in Fragment.
 *
 * @author kifile
 */
public class SampleFragment extends Fragment {

    private SampleDataProvider mProvider;

//    private DataObserver<JSONObject> mObserver = new DataObserver<JSONObject>() {
//        @Override
//        public void onDataChanged(JSONObject jsonObject) {
//            getActivity().setTitle(jsonObject.toString());
//        }
//    };

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (mProvider == null) {
            mProvider =
                    (SampleDataProvider) Cornerstone.obtainProvider(SampleDataProvider.KEY);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
//        mProvider.registerDataObserver(mObserver);
    }

    @Override
    public void onPause() {
//        mProvider.unregisterDataObserver(mObserver);
        super.onPause();
    }

    @Override