// Path: Chatting/src/cn/jmessage/android/uikit/chatting/utils/IdHelper.java
// public class IdHelper {
// 
//     public static int getLayout(Context context, String layoutName) {
//         return context.getResources().getIdentifier(layoutName, "layout",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getViewID(Context context, String IDName) {
//         return context.getResources().getIdentifier(IDName, "id",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getDrawable(Context context, String drawableName) {
//         return context.getResources().getIdentifier(drawableName, "drawable",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getAttr(Context context, String attrName) {
//         return context.getResources().getIdentifier(attrName, "attr",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getString(Context context, String stringName) {
//         return context.getResources().getIdentifier(stringName, "string",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getStyle(Context context, String styleName) {
//         return context.getResources().getIdentifier(styleName, "style",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int[] getResourceDeclareStyleableIntArray(Context context, String name) {
//         try {
//             Field[] fields2 = Class.forName(context.getPackageName() + ".R$styleable").getFields();
// 
//             //browse all fields
//             for (Field f : fields2) {
//                 //pick matching field
//                 if (f.getName().equals(name)) {
//                     //return as int array
//                     return (int[]) f.get(null);
//                 }
//             }
//         } catch (Throwable t) {
//             t.printStackTrace();
//         }
// 
//         return null;
//     }
// 
//     public static int getAnim(Context context, String animName) {
//         return context.getResources().getIdentifier(animName, "anim",
//                 context.getApplicationContext().getPackageName());
//     }
// }


import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import cn.jmessage.android.uikit.chatting.utils.IdHelper;
                /**
                 * when state of ListView is SCROLL_STATE_FLING(ListView is scrolling but finger has leave screen) and
                 * first item(header layout) is visible and header status is not HEADER_STATUS_LOADING, then hide first
                 * item, set second item visible and set hasReachedTop true.
                 */
                if (mOffset == PAGE_MESSAGE_COUNT){
                    onDropDown();
                }
                hasReachedTop = true;
            } else if (currentScrollState == SCROLL_STATE_FLING && hasReachedTop) {
                setSelection(0);
            }
        }

        if (onScrollListener != null) {
            onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
        }
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        if (isDropDownStyle) {
            currentScrollState = scrollState;

            if (currentScrollState == SCROLL_STATE_IDLE) {
                hasReachedTop = false;
            }
        }

        if (onScrollListener != null) {
// Path: Chatting/src/cn/jmessage/android/uikit/chatting/utils/IdHelper.java
// public class IdHelper {
// 
//     public static int getLayout(Context context, String layoutName) {
//         return context.getResources().getIdentifier(layoutName, "layout",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getViewID(Context context, String IDName) {
//         return context.getResources().getIdentifier(IDName, "id",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getDrawable(Context context, String drawableName) {
//         return context.getResources().getIdentifier(drawableName, "drawable",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getAttr(Context context, String attrName) {
//         return context.getResources().getIdentifier(attrName, "attr",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getString(Context context, String stringName) {
//         return context.getResources().getIdentifier(stringName, "string",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int getStyle(Context context, String styleName) {
//         return context.getResources().getIdentifier(styleName, "style",
//                 context.getApplicationContext().getPackageName());
//     }
// 
//     public static int[] getResourceDeclareStyleableIntArray(Context context, String name) {
//         try {
//             Field[] fields2 = Class.forName(context.getPackageName() + ".R$styleable").getFields();
// 
//             //browse all fields
//             for (Field f : fields2) {
//                 //pick matching field
//                 if (f.getName().equals(name)) {
//                     //return as int array
//                     return (int[]) f.get(null);
//                 }
//             }
//         } catch (Throwable t) {
//             t.printStackTrace();
//         }
// 
//         return null;
//     }
// 
//     public static int getAnim(Context context, String animName) {
//         return context.getResources().getIdentifier(animName, "anim",
//                 context.getApplicationContext().getPackageName());
//     }
// }


// Path: Chatting/src/cn/jmessage/android/uikit/chatting/DropDownListView.java
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import cn.jmessage.android.uikit.chatting.utils.IdHelper;

                /**
                 * when state of ListView is SCROLL_STATE_FLING(ListView is scrolling but finger has leave screen) and
                 * first item(header layout) is visible and header status is not HEADER_STATUS_LOADING, then hide first
                 * item, set second item visible and set hasReachedTop true.
                 */
                if (mOffset == PAGE_MESSAGE_COUNT){
                    onDropDown();
                }
                hasReachedTop = true;
            } else if (currentScrollState == SCROLL_STATE_FLING && hasReachedTop) {
                setSelection(0);
            }
        }

        if (onScrollListener != null) {
            onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
        }
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        if (isDropDownStyle) {
            currentScrollState = scrollState;

            if (currentScrollState == SCROLL_STATE_IDLE) {
                hasReachedTop = false;
            }
        }

        if (onScrollListener != null) {
            onScrollListener.onScrollStateChanged(view, scrollState);