// Path: lay-s/src/main/java/com/hadlink/lay_s/conf/C.java
// public final class C {
// 
//     /**
//      * 主机
//      */
//     public static final class Host {
//         public static final String host = "http://eptapi.imchehu.com/";
//         public static final String BAIDU_IMAGES_URLS = "http://image.baidu.com/data/imgs";
//     }
// 
//     /**
//      * 列表常量
//      */
//     public static final class List {
//         //每页加载数
//         public static final int numPerPage = 10;
//     }
// 
// }


import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import com.hadlink.lay_s.conf.C;

/*
 *    Copyright (c) 2016, lyao. lomoliger@hotmail.com
 *
 *     Part of the code from the open source community,
 *     thanks stackOverflow & gitHub .
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 */

package com.hadlink.lay_s.utils;




public class UriHelper {

    private static volatile UriHelper instance = null;

    /**
     * 20 datas per page
     */
    public static final int PAGE_LIMIT = 200;


    private UriHelper() {
    }

    public static UriHelper getInstance() {
        if (null == instance) {
            synchronized (UriHelper.class) {
                if (null == instance) {
                    instance = new UriHelper();
                }
            }
        }
        return instance;
    }

    public int calculateTotalPages(int totalNumber) {
        if (totalNumber > 0) {
            return totalNumber % PAGE_LIMIT != 0 ? (totalNumber / PAGE_LIMIT + 1) : totalNumber / PAGE_LIMIT;
        } else {
            return 0;
        }
    }

    public String getImagesListUrl(String category, int pageNum) {
        StringBuffer sb = new StringBuffer();
// Path: lay-s/src/main/java/com/hadlink/lay_s/conf/C.java
// public final class C {
// 
//     /**
//      * 主机
//      */
//     public static final class Host {
//         public static final String host = "http://eptapi.imchehu.com/";
//         public static final String BAIDU_IMAGES_URLS = "http://image.baidu.com/data/imgs";
//     }
// 
//     /**
//      * 列表常量
//      */
//     public static final class List {
//         //每页加载数
//         public static final int numPerPage = 10;
//     }
// 
// }


// Path: lay-s/src/main/java/com/hadlink/lay_s/utils/UriHelper.java
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import com.hadlink.lay_s.conf.C;


/*
 *    Copyright (c) 2016, lyao. lomoliger@hotmail.com
 *
 *     Part of the code from the open source community,
 *     thanks stackOverflow & gitHub .
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 */

package com.hadlink.lay_s.utils;




public class UriHelper {

    private static volatile UriHelper instance = null;

    /**
     * 20 datas per page
     */
    public static final int PAGE_LIMIT = 200;


    private UriHelper() {
    }

    public static UriHelper getInstance() {
        if (null == instance) {
            synchronized (UriHelper.class) {
                if (null == instance) {
                    instance = new UriHelper();
                }
            }
        }
        return instance;
    }

    public int calculateTotalPages(int totalNumber) {
        if (totalNumber > 0) {
            return totalNumber % PAGE_LIMIT != 0 ? (totalNumber / PAGE_LIMIT + 1) : totalNumber / PAGE_LIMIT;
        } else {
            return 0;
        }
    }

    public String getImagesListUrl(String category, int pageNum) {
        StringBuffer sb = new StringBuffer();
        sb.append(C.Host.BAIDU_IMAGES_URLS);