Ver Fonte

2016/9/2

Bitliker há 9 anos atrás
pai
commit
74adddb093

+ 1 - 1
WeiChat/build.gradle

@@ -4,7 +4,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
 android {
     signingConfigs {
         config {
-            storeFile file('C:/Users/Arison/Desktop/applicationsignname[20150409]')
+            storeFile file('D:/config/applicationsignname[20150409]')
             storePassword '13237658359'
             keyAlias 'jie-20150409'
             keyPassword '13237658359'

+ 19 - 21
WeiChat/src/main/java/com/xzjmyk/pm/activity/BdLocationHelper.java

@@ -8,10 +8,8 @@ import com.baidu.location.BDLocation;
 import com.baidu.location.BDLocationListener;
 import com.baidu.location.LocationClient;
 import com.baidu.location.LocationClientOption;
-import com.baidu.location.LocationClientOption.LocationMode;
 import com.baidu.location.Poi;
 import com.xzjmyk.pm.activity.sp.LocationSp;
-import com.xzjmyk.pm.activity.util.StringUtils;
 
 import java.util.List;
 
@@ -23,6 +21,7 @@ public class BdLocationHelper {
     private String mAddress;
 
     private String name;
+    private List<Poi> pois;
     private String mProvinceName;// 省份
     private String mCityName;// 城市
     private String mDistrictName;// 街道
@@ -30,7 +29,6 @@ public class BdLocationHelper {
 
     private LocationClient mLocationClient = null;
     private int mFaildCount = 0;
-    private List<Poi> pois;
 
     BdLocationHelper(Context context) {
         mContext = context;
@@ -44,16 +42,20 @@ public class BdLocationHelper {
         mLocationClient = new LocationClient(context); // 声明LocationClient类
         mLocationClient.registerLocationListener(mMyLocationListener); // 注册监听函数
         LocationClientOption option = new LocationClientOption();
-        option.setLocationMode(LocationMode.Hight_Accuracy);// 设置定位模式
-        option.setCoorType("bd09ll");// 返回的定位结果是百度经纬度,默认值gcj02
-        option.setScanSpan(5000);// 设置发起定位请求的间隔时间为10s
-        option.setIsNeedAddress(true);
-        option.setNeedDeviceDirect(false);
+        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
+        option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
+        option.setScanSpan(5000);// 设置发起定位请求的间隔时间为10s;//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
+        option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
         option.setOpenGps(true);//可选,默认false,设置是否使用gps
+        option.setLocationNotify(true);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
+        option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
+        option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
+        option.setIgnoreKillProcess(false);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
+        option.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集
+        option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
+        option.setNeedDeviceDirect(false);
         mLocationClient.setLocOption(option);
         requestLocation();//重新定位
-
-
     }
 
 
@@ -82,13 +84,6 @@ public class BdLocationHelper {
             if (location != null) {
                 resultCode = location.getLocType();
             }
-            Log.i("gongpengming", StringUtils.isEmail(location.getLocationDescribe()) ? "空的" : location.getLocationDescribe());
-            if (location.getPoiList() == null || location.getPoiList().size() <= 0) {
-                Log.i("gongpengming", "location.getPoiList()不对劲");
-            } else {
-                Log.i("gongpengming", "location.getPoiList()不对劲");
-            }
-            setPois(location.getPoiList());
             // 百度定位失败
             if (resultCode != BDLocation.TypeGpsLocation && resultCode != BDLocation.TypeCacheLocation
                     && resultCode != BDLocation.TypeOffLineLocation && resultCode != BDLocation.TypeNetWorkLocation) {
@@ -105,6 +100,8 @@ public class BdLocationHelper {
             // 百度定位成功
             mLongitude = location.getLongitude();
             mLatitude = location.getLatitude();
+            name = location.getLocationDescribe();
+            pois = location.getPoiList();
             if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
                 mAddress = location.getAddrStr();
                 mProvinceName = location.getProvince();
@@ -138,12 +135,13 @@ public class BdLocationHelper {
 
     };
 
-    public List<Poi> getPois() {
-        return pois;
+
+    public String getName() {
+        return pois == null ? (name == null ? "当前位置" : name) : (pois.get(0) == null ? (name == null ? "当前位置" : name) : pois.get(0).getName());
     }
 
-    public void setPois(List<Poi> pois) {
-        this.pois = pois;
+    public void setName(String name) {
+        this.name = name;
     }
 
     // 获取经纬度

+ 1 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/crm/VisitReportPlanActivity.java

@@ -24,6 +24,7 @@ import com.xzjmyk.pm.activity.ui.erp.util.ViewUtil;
 import com.xzjmyk.pm.activity.ui.erp.view.SingleDialog;
 import com.xzjmyk.pm.activity.util.BaiduMapUtil;
 import com.xzjmyk.pm.activity.util.DateFormatUtil;
+import com.xzjmyk.pm.activity.util.TimeUtils;
 import com.xzjmyk.pm.activity.view.wheel.DateTimePicker;
 
 import java.util.ArrayList;

+ 2 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/MeetDetailsActivity.java

@@ -193,6 +193,7 @@ public class MeetDetailsActivity extends BaseActivity implements View.OnClickLis
         }
         status_tv.setText(str);
         //设置开始和结束时间的显示
+        name_tv.setText(entity.getMa_theme() == null ? "" : entity.getMa_theme());
         long startLongTime = TimeUtils.f_str_2_long(entity.getMa_starttime());
         oa_meeting_start.setText(TimeUtils.long2str(startLongTime, "MM月dd"));
         oa_meeting_start_date.setText(TimeUtils.long2str(startLongTime, "HH:mm"));
@@ -323,7 +324,7 @@ public class MeetDetailsActivity extends BaseActivity implements View.OnClickLis
                 bean.setMd_title(name_tv.getText().toString());
                 bean.setMd_mtname("");
                 bean.setMd_meetingname("");
-                bean.setMd_meetingcode("");
+                bean.setMd_meetingcode(ma_code);
                 bean.setMd_mrcode("");
                 bean.setMd_mrname("");
                 bean.setMd_starttime(entity == null ? TimeUtils.f_long_2_str(System.currentTimeMillis()) : entity.getMa_starttime());

+ 0 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/MeetingActivity.java

@@ -317,7 +317,6 @@ public class MeetingActivity extends BaseActivity {
             if (resultCode == 0x14) {
                 if ("data".equals(data.getStringExtra("data"))) {
                     list_business.setRefreshing(true);
-                    entities.clear();
                     loadNetData(1);
                 }
             } else if (resultCode == 0x15) {

+ 1 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/SaveMeetActivity.java

@@ -145,6 +145,7 @@ public class SaveMeetActivity extends BaseActivity {
         }
         progressDialog.show();
         bean.setMd_contents(strChche);
+//        bean.setMd_meetingcode(strChche);
         String url = CommonUtil.getSharedPreferences(this, "erp_baseurl") + "oa/meeting/saveMeetingDoc.action";
         final Map<String, Object> param = new HashMap<>();
         String formStore = FlexJsonUtil.toJson(bean);

+ 3 - 3
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/SigninActivity.java

@@ -8,12 +8,12 @@ import android.widget.RadioButton;
 
 import com.xzjmyk.pm.activity.R;
 import com.xzjmyk.pm.activity.ui.base.BaseActivity;
-import com.xzjmyk.pm.activity.ui.erp.fragment.SigninClickFragment;
+import com.xzjmyk.pm.activity.ui.erp.fragment.SigninFragment;
 import com.xzjmyk.pm.activity.ui.erp.fragment.SigninSetFragment;
 
 public class SigninActivity extends BaseActivity {
     private FragmentManager manager;
-    private SigninClickFragment signinFragment;
+    private SigninFragment signinFragment;
     private SigninSetFragment setFragment;
     private RadioButton setting_rb;
 
@@ -26,7 +26,7 @@ public class SigninActivity extends BaseActivity {
 
     private void initView() {
         manager = getSupportFragmentManager();
-        signinFragment = new SigninClickFragment();
+        signinFragment = new SigninFragment();
         manager.beginTransaction().add(R.id.content_fl, signinFragment).commit();
         setting_rb = (RadioButton) findViewById(R.id.setting_rb);
         setting_rb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

+ 131 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/adapter/SigninAdapter.java

@@ -0,0 +1,131 @@
+package com.xzjmyk.pm.activity.ui.erp.adapter;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.xzjmyk.pm.activity.R;
+import com.xzjmyk.pm.activity.ui.erp.fragment.SigninFragment;
+import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
+import com.xzjmyk.pm.activity.util.StringUtils;
+import com.xzjmyk.pm.activity.util.TimeUtils;
+
+import java.util.ArrayList;
+
+/**
+ * Created by gongpengming on 2016/9/1.
+ */
+public class SigninAdapter extends RecyclerView.Adapter<SigninAdapter.ViewHoler> {
+    private Context ct;
+    private ArrayList<SigninFragment.Bean> beans;
+    private String time;
+
+    public SigninAdapter(Context ct) {
+        this.ct = ct;
+        time = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");
+    }
+
+    public ArrayList<SigninFragment.Bean> getBeans() {
+        return beans;
+    }
+
+    public void setBeans(ArrayList<SigninFragment.Bean> beans) {
+        this.beans = beans;
+        time = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");
+    }
+
+    @Override
+    public ViewHoler onCreateViewHolder(ViewGroup parent, int viewType) {
+        ViewHoler holer = new ViewHoler(LayoutInflater.from(ct).inflate(R.layout.item_signin_list, parent, false));
+        return holer;
+    }
+
+    @Override
+    public void onBindViewHolder(ViewHoler holder, int position) {
+        SigninFragment.Bean b = beans.get(position);
+        holder.time.setText(b.getStartTime() == null ? "" : b.getStartTime());
+        holder.time2.setText(b.getEndTime() == null ? "" : b.getEndTime());
+        //处理签到时间
+        String start = "", end = "";
+
+        if (!ListUtils.isEmpty(b.getSigninList()) && b.getSigninList().size() > 0) {
+            String starSignin = b.getSigninList().get(0) == null ? "" : b.getSigninList().get(0);//获取到显示在签到时间的时间
+            holder.signin.setText(starSignin);//填充时间
+
+            //判断正常打卡 1.打卡时间在允许打卡时间b.getStartSignin() 到上班时间范围内b.getStartTime()
+            if (!StringUtils.isEmpty(b.getStartTime()) && !StringUtils.isEmpty(b.getStartSignin()) && starSignin.compareTo(b.getStartTime()) < 0 && starSignin.compareTo(b.getStartSignin()) > 0) {
+                start = "-1";
+            }
+            //判断迟到  1.打卡时间在上班时间getStartTime和往后的90分钟内
+            else if (!StringUtils.isEmpty(b.getStartTime()) && starSignin.compareTo(getNext90(b.getStartTime(), true)) < 0 && starSignin.compareTo(b.getStartTime()) > 0) {
+                start = "迟到";
+            } else {
+                start = "缺勤";
+            }
+        } else {
+            start = "缺勤";
+        }
+        if (!ListUtils.isEmpty(b.getSigninList()) && b.getSigninList().size() > 1) {
+            String endSignin = b.getSigninList().get(b.getSigninList().size() - 1) == null ? "" : b.getSigninList().get(b.getSigninList().size() - 1);
+            holder.signin2.setText(endSignin);
+            if (!StringUtils.isEmpty(b.getEndTime()) && getNext90(b.getEndTime(), false).compareTo(endSignin) < 0 && endSignin.compareTo(b.getEndSignnin()) > 0) {
+                end = "早退";
+            } else if (!StringUtils.isEmpty(b.getEndTime()) && !StringUtils.isEmpty(b.getEndSignnin()) && endSignin.compareTo(b.getEndTime()) > 0 && endSignin.compareTo(b.getEndSignnin()) < 0) {
+                end = "-1";
+            } else {
+                end = "缺勤";
+            }
+        } else {
+            end = "缺勤";
+        }
+        //处理标识
+        if ("-1".equals(start) || time.compareTo(b.getStartTime()) < 0) {//当前时间还没有到达上班时间,不能显示缺勤
+            holder.tag.setVisibility(View.GONE);
+        } else {
+            holder.tag.setText(start);
+            holder.tag.setVisibility(View.VISIBLE);
+        }
+        //处理标识
+        if ("-1".equals(end)) {//当前时间还没有到达下班时间
+            holder.tag2.setVisibility(View.GONE);
+        } else {
+            holder.tag2.setText(end);
+            holder.tag2.setVisibility(View.VISIBLE);
+        }
+    }
+
+    private long long90 = 90 * 1000 * 60;
+
+    private String getNext90(String hhmm, boolean isU) {//通过给出的时分获取到对应90分钟的时分
+        String chche = TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + hhmm + ":00";
+        long chchelong = isU ? long90 : (-long90);
+        return TimeUtils.long2str(TimeUtils.f_str_2_long(chche) + chchelong, "HHmm");
+    }
+
+    @Override
+    public int getItemCount() {
+        return beans == null ? 0 : beans.size();
+    }
+
+    class ViewHoler extends RecyclerView.ViewHolder {
+        TextView time,
+                signin,
+                tag,
+                time2,
+                signin2,
+                tag2;
+
+        public ViewHoler(View itemView) {
+            super(itemView);
+            time = (TextView) itemView.findViewById(R.id.time);
+            signin = (TextView) itemView.findViewById(R.id.signin);
+            tag = (TextView) itemView.findViewById(R.id.tag);
+            time2 = (TextView) itemView.findViewById(R.id.time2);
+            signin2 = (TextView) itemView.findViewById(R.id.signin2);
+            tag2 = (TextView) itemView.findViewById(R.id.tag2);
+        }
+    }
+}

+ 4 - 6
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/fragment/OutofficeFragment.java

@@ -117,17 +117,15 @@ public class OutofficeFragment extends EasyFragment implements View.OnClickListe
         AvatarHelper.getInstance().displayAvatar(loginUserId, name_img, true);
         name_tv.setText(MyApplication.getInstance().mLoginUser.getNickName());
         com_tv.setText(CommonUtil.getSharedPreferences(ct, "erp_commpany"));
-        String name = MyApplication.getInstance().getBdLocationHelper().getDistrictName();
-        String addr=MyApplication.getInstance().getBdLocationHelper().getAddress();
-        out_add_name_tv.setText( StringUtils.isEmail(name)?addr:name);
+        String name = MyApplication.getInstance().getBdLocationHelper().getName();
+        String addr = MyApplication.getInstance().getBdLocationHelper().getAddress();
+        out_add_name_tv.setText(name);
         out_add_t_tv.setText(addr);
-
         double latitude = MyApplication.getInstance().getBdLocationHelper().getLatitude();
         double longitude = MyApplication.getInstance().getBdLocationHelper().getLongitude();
         point = new LatLng(latitude, longitude);
-        baseAddr=StringUtils.isEmail(name)?addr:name;
+        baseAddr = StringUtils.isEmail(name) ? addr : name;
         BaiduMapUtil.getInstence().setMapViewPoint(mapView, point);
-
 //        BaiduMapUtil.getInstence().getPoiInfo(ct, new BaiduMapUtil.OnLocationListener() {
 //            @Override
 //            public void result(Map<String, Object> map) {

+ 2 - 3
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/fragment/SigninClickFragment.java

@@ -9,7 +9,6 @@ import android.os.Message;
 import android.support.v7.app.AlertDialog;
 import android.text.Html;
 import android.text.Spanned;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -137,7 +136,7 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
 
     @Override
     protected int inflateLayoutId() {
-        return R.layout.fragment_signin;
+        return R.layout.fragment_click_signin;
     }
 
     @Override
@@ -182,7 +181,6 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
         if (!StringUtils.isEmpty(distance)) {
             distanceOk = (int) Double.parseDouble(distance);
         }
-
         Spanned str = Html.fromHtml("<font color=\'#858585\'>距离考勤地点: " + (distanceOk == -1 ? -1 : distanceOk) + "米    " + "</font><font color=\'#f02387\'><U>地点微调</U></font>");
         return str;
     }
@@ -193,6 +191,7 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
         signin_btn.setOnClickListener(this);
         title.setOnClickListener(this);
         findViewById(R.id.unoffice_mm).setOnClickListener(this);
+        unoffice_mm.setText(getDistance(mylatitude, mylongitude));
     }
 
     private void seccess(boolean is) {

+ 549 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/fragment/SigninFragment.java

@@ -0,0 +1,549 @@
+package com.xzjmyk.pm.activity.ui.erp.fragment;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.Html;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baidu.mapapi.search.core.PoiInfo;
+import com.lidroid.xutils.ViewUtils;
+import com.lidroid.xutils.view.annotation.ViewInject;
+import com.xzjmyk.pm.activity.MyApplication;
+import com.xzjmyk.pm.activity.R;
+import com.xzjmyk.pm.activity.bean.oa.SigninBean;
+import com.xzjmyk.pm.activity.ui.base.BaseActivity;
+import com.xzjmyk.pm.activity.ui.base.EasyFragment;
+import com.xzjmyk.pm.activity.ui.erp.activity.oa.AlarmaActivity;
+import com.xzjmyk.pm.activity.ui.erp.activity.oa.LocationMapActivity;
+import com.xzjmyk.pm.activity.ui.erp.adapter.SigninAdapter;
+import com.xzjmyk.pm.activity.ui.erp.util.CodeUtil;
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
+import com.xzjmyk.pm.activity.ui.erp.util.FlexJsonUtil;
+import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
+import com.xzjmyk.pm.activity.ui.erp.util.ViewUtil;
+import com.xzjmyk.pm.activity.util.BaiduMapUtil;
+import com.xzjmyk.pm.activity.util.TimeUtils;
+import com.xzjmyk.pm.activity.view.crouton.Crouton;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * 常量:
+ * 0x11:下拉班次数据what
+ * 0x12:下拉打卡记录what
+ * 0x13:签到接口what
+ * 0x14:调转界面requestCode
+ * Created by gongpengming on 2016/9/1.
+ */
+public class SigninFragment extends EasyFragment implements View.OnClickListener {
+    private static final long DAY_TIME = 1000 * 60 * 60 * 24;
+    @ViewInject(R.id.listview)
+    private RecyclerView listview;
+    @ViewInject(R.id.seting)
+    private ImageView seting;
+    @ViewInject(R.id.title)
+    private TextView title;
+    @ViewInject(R.id.back)
+    private ImageView back;
+    @ViewInject(R.id.signin_btn)
+    private ImageView signin_btn;
+    @ViewInject(R.id.office_addr)
+    private TextView office_addr;//考勤地点
+    @ViewInject(R.id.unoffice_mm)
+    private TextView unoffice_mm;//地点微调
+
+    //变量
+    private BaseActivity ct;
+    private boolean isInCompany = false;//当前员工是否配置公司信息
+    private double companyX;//当前公司位置经度
+    private double companyY;//当前公司位置纬度
+    private int companyDistance = -1;//当前规定距离
+    private double longitude;//当前位置经度
+    private double latitude;//当前位置纬度
+    private int distance = 300;   //当前距离
+    private SigninAdapter adapter;
+    private long selectTime;//当前选择的日期的时间
+    private String code;//账号员工编号
+    private AlertDialog.Builder builder;
+    private String[] timeList = new String[5];
+    private boolean isToday = true;
+
+    private Handler handler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            String message = msg.getData().getString("result");
+            if (ct.progressDialog.isShowing())
+                ct.progressDialog.dismiss();
+            switch (msg.what) {
+                case 0x11:
+                    JSONObject jsonObject = JSON.parseObject(message);//返回对象
+                    if (jsonObject.containsKey("success") && jsonObject.getBoolean("success")) {//返回正常
+                        if (jsonObject.containsKey("comaddressset") ? jsonObject.getBoolean("comaddressset") : false) {//如果有分配公司
+                            isInCompany = true;
+                            companyDistance = Integer.parseInt(jsonObject.containsKey("distance") ? jsonObject.getString("distance") : "0");
+                            companyX = Double.parseDouble(jsonObject.containsKey("longitude") ? jsonObject.getString("longitude") : "0");
+                            companyY = Double.parseDouble(jsonObject.containsKey("latitude") ? jsonObject.getString("latitude") : "0");
+                            unoffice_mm.setText(setDistance());
+                        } else {
+                            Crouton.makeText(ct, "当前账号没有分配公司地址,请联系管理员!!");
+                        }
+                        if (jsonObject.containsKey("wd_degree") && jsonObject.getInteger("wd_degree") > 0) {//当该用户有排班
+                            //用户有排班时候
+                            setDataByDegree(jsonObject);
+                        } else {
+                            setDataByNoDegree(jsonObject);
+                        }
+                        loadLog(TimeUtils.s_long_2_str(selectTime));//获取打卡时间
+                    } else {
+                        //如果返回失败
+//                    ct.finish();
+                        Crouton.makeText(ct, "系统尚未找到您的班次,请联系管理员设置班次");
+                    }
+                    break;
+                case 0x12:
+                    if (JSON.parseObject(message).containsKey("listdata")) {
+                        setDataByLogs(JSON.parseObject(message).getJSONArray("listdata"));
+                    } else {
+                        Crouton.makeText(ct, "系统尚未找到您的打卡记录,请联系管理员设置班次");
+                    }
+                    break;
+                case 0x13:
+                    //签到成功
+                    signinOK();
+                    break;
+                default:
+                    break;
+            }
+
+        }
+    };
+
+
+    //生命周期
+    @Override
+    public void onAttach(Context ct) {
+        super.onAttach(ct);
+        this.ct = (BaseActivity) ct;
+    }
+
+    @Override
+    protected int inflateLayoutId() {
+        return R.layout.fragment_signin;
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        if (data == null) return;
+        if (requestCode == 0x14 && resultCode == LocationMapActivity.REQUCODE) {
+            PoiInfo poi = data.getParcelableExtra(LocationMapActivity.REQUESTNAME);
+            office_addr.setText("考勤地点:" + poi.name);
+            latitude = poi.location.latitude;
+            longitude = poi.location.longitude;
+            unoffice_mm.setText(setDistance());
+        }
+    }
+
+    @Override
+    public void onClick(View view) {
+        Intent intent = null;
+        switch (view.getId()) {
+            case R.id.seting:
+                intent = new Intent(ct, AlarmaActivity.class);
+                startActivity(intent);
+                break;
+            case R.id.back:
+                ct.finish();
+                break;
+            case R.id.signin_btn:
+                //TODO 判断是否可以签到
+                if (isPlay()) {
+                    CodeUtil.getInstance().getCode(ct, "CardLog", new CodeUtil.OnCodeLinstener() {
+                        @Override
+                        public void callBack(String code) {
+                            doSignin(code);
+                        }
+                    });
+                }
+                break;
+            case R.id.title:
+                showPopMenu();
+                break;
+            case R.id.unoffice_mm:
+                intent = new Intent(ct, LocationMapActivity.class);
+                startActivityForResult(intent, 0x14);
+                break;
+
+        }
+    }
+
+    @Override
+    protected void onCreateView(Bundle savedInstanceState, boolean createView) {
+        ViewUtils.inject(getmRootView());
+        init();
+        initView();
+        listener();
+    }
+
+    private void listener() {
+        seting.setOnClickListener(this);
+        back.setOnClickListener(this);
+        signin_btn.setOnClickListener(this);
+        title.setOnClickListener(this);
+        unoffice_mm.setOnClickListener(this);
+    }
+
+    private void init() {
+        longitude = MyApplication.getInstance().getBdLocationHelper().getLongitude();
+        latitude = MyApplication.getInstance().getBdLocationHelper().getLatitude();
+    }
+
+    private void initView() {
+        longitude = MyApplication.getInstance().getBdLocationHelper().getLongitude();
+        latitude = MyApplication.getInstance().getBdLocationHelper().getLatitude();
+        title.setText(TimeUtils.day_long_2_str(System.currentTimeMillis()) + "  " + TimeUtils.getWeek(System.currentTimeMillis()));
+        listview.setLayoutManager(new LinearLayoutManager(ct));
+        adapter = new SigninAdapter(ct);
+        listview.setAdapter(adapter);
+        office_addr.setText("考勤地点:" + MyApplication.getInstance().getBdLocationHelper().getName());
+        loadNetData(System.currentTimeMillis());//获取打卡班次信息
+    }
+
+    private void showPopMenu() {
+        //显示选择日期窗口
+        for (int i = 0; i < timeList.length; i++)
+            timeList[i] = TimeUtils.day_long_2_str(System.currentTimeMillis() - (DAY_TIME * i)) + "  " + TimeUtils.getWeek(System.currentTimeMillis() - (DAY_TIME * i));
+        title.setText(TimeUtils.day_long_2_str(System.currentTimeMillis()) + "  " + TimeUtils.getWeek(System.currentTimeMillis()));
+        if (builder == null) {
+            builder = new AlertDialog.Builder(ct);
+            builder.setItems(timeList, new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialogInterface, int i) {
+                    isToday = i == 0 ? true : false;
+                    title.setText(timeList[i]);
+                    if (adapter != null && adapter.getBeans() != null && adapter.getBeans().size() > 0)
+                        adapter.getBeans().clear();
+                    loadNetData(System.currentTimeMillis() - (DAY_TIME * i));
+                }
+            });
+        }
+        builder.show();
+    }
+
+    private boolean isPlay() {
+        if (companyDistance == -1) {
+            Crouton.makeText(ct, "您当前账号没有设置打卡地址信息,请联系管理员");
+            return false;
+        }
+        if (companyDistance < distance) {
+            Crouton.makeText(ct, "您当前位置距离考勤地点太远,请移往目标或重新定位");
+            return false;
+        }
+        if (!isToday) {
+            Crouton.makeText(ct, "当前所在日期无法签到");
+            return false;
+        }
+        ArrayList<Bean> beans = getDataByAdapter();
+        String time = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");
+        for (Bean e : beans) {
+            if (!StringUtils.isEmpty(e.getStartSignin()) && !StringUtils.isEmpty(e.getEndSignnin()) && time.compareTo(e.getStartSignin()) > 0 && time.compareTo(e.getEndTime()) < 0) {
+                return true;
+            }
+        }
+        Crouton.makeText(ct, "您不在打卡允许范围内,请稍后重试或联系管理员");
+        return false;
+    }
+
+    /**
+     * setData
+     */
+    private String setDistance() {
+        String dis = BaiduMapUtil.getInstence().getDistance(companyX, companyY, latitude, longitude);
+        String re = "";
+        try {
+            if (!StringUtils.isEmpty(dis)) {
+                distance = (int) Double.parseDouble(dis);
+                re = "" + Html.fromHtml("<font color=\'#858585\'>距离考勤地点: " + (distance == -1 ? -1 : distance) + "米    " + "</font><font color=\'#f02387\'><U>地点微调</U></font>");
+            }
+        } catch (ClassCastException e) {
+            e.printStackTrace();
+        }
+        return re;
+    }
+
+    //签到成功
+    private void signinOK() {
+        ArrayList<Bean> beans = getDataByAdapter();
+        String time = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");
+        for (int i = 0; i < beans.size(); i++) {
+            Bean b = beans.get(i);
+            if (!StringUtils.isEmpty(b.startSignin) && !StringUtils.isEmpty(b.endSignnin) && time.compareTo(b.startSignin) > 0 && time.compareTo(b.endSignnin) < 0) {
+                beans.get(i).getSigninList().add(time);
+            }
+        }
+        setDataForAdapter(beans);
+    }
+
+    //前后90分钟,isU--是否是上班
+    private String getEndSignin(String signin, boolean isU) {
+        String time = TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + signin + ":00";
+        long sigTime = TimeUtils.f_str_2_long(time);
+        long minTime = 0;
+        if (isU)
+            minTime = sigTime - 90 * 60 * 1000;
+        else
+            minTime = sigTime + 90 * 60 * 1000;
+        if (!TimeUtils.s_long_2_str(sigTime).equals(TimeUtils.s_long_2_str(minTime))) {
+            //不同一天
+            if (isU)
+                return "00:00";
+            else
+                return "23:59";
+        }
+        return TimeUtils.long2str(minTime, "HH:mm");
+    }
+
+    //获取打卡时间列表去除年月日和秒
+    private String clearDay(String time) {
+        return TimeUtils.long2str(TimeUtils.f_str_2_long(time), "HH:mm");
+    }
+
+    //处理数据,用户无排班时候
+    public void setDataByNoDegree(JSONObject object) {
+        ArrayList<Bean> beans = new ArrayList<>();
+        Bean b = null;
+        //上午
+        b = new Bean();
+        b.startTime = object.containsKey("as_amstarttime") ? object.getString("as_amstarttime") : "08:30";
+        b.startSignin = getEndSignin(b.startTime, true);
+        b.endTime = object.containsKey("as_amendtime") ? object.getString("as_amendtime") : "12:00";
+        b.endSignnin = getEndSignin(b.endTime, false);
+        beans.add(b);
+        //下午
+        b = new Bean();
+        b.startTime = object.containsKey("as_pmstarttime") ? object.getString("as_pmstarttime") : "13:30";
+        b.startSignin = getEndSignin(b.startTime, true);
+        b.endTime = object.containsKey("as_pmendtime") ? object.getString("as_pmendtime") : "18:00";
+        b.endSignnin = getEndSignin(b.endTime, false);
+        beans.add(b);
+        setDataForAdapter(beans);
+    }
+
+    private void bindClass(ArrayList<Bean> beans, JSONObject object) {
+        Bean b = new Bean();//上班
+        if (!object.containsKey("wd_onduty") || object.getString("wd_onduty") == null) return;
+        b.startTime = object.containsKey("wd_onduty") ? object.getString("wd_onduty") : "00:00";
+        b.startSignin = object.containsKey("wd_onbeg") ? object.getString("wd_onbeg") : "00:00";
+        b.endTime = object.containsKey("wd_offduty") ? object.getString("wd_offduty") : "00:00";
+        b.endSignnin = object.containsKey("wd_offend") ? object.getString("wd_offend") : "00:00";
+        beans.add(0, b);
+    }
+
+    //处理数据,用户有排班时候
+    public void setDataByDegree(JSONObject object) {
+        int num = object.getInteger("wd_degree");//获取排班数
+        ArrayList<Bean> beans = new ArrayList<>();
+        Bean b = null;
+        //获取打卡地点及距离
+        if (object.containsKey("Class3"))
+            bindClass(beans, object.getJSONObject("Class3"));
+        if (object.containsKey("Class2"))
+            bindClass(beans, object.getJSONObject("Class2"));
+        if (object.containsKey("Class1"))
+            bindClass(beans, object.getJSONObject("Class1"));
+        switch (num) {
+            case 3:
+                b = new Bean();//上班
+                b.startTime = object.containsKey("wd_ondutythree") ? object.getString("wd_ondutythree") : "08:30";
+                b.startSignin = object.containsKey("wd_onbeg3") ? object.getString("wd_onbeg3") : "07:00";
+                b.endTime = object.containsKey("wd_offdutythree") ? object.getString("wd_offdutythree") : "11:30";
+                b.endSignnin = object.containsKey("wd_offend3") ? object.getString("wd_offend3") : "12:00";
+                beans.add(0, b);
+            case 2:
+                b = new Bean();
+                b.startTime = object.containsKey("wd_ondutytwo") ? object.getString("wd_ondutytwo") : "--:--";
+                b.startSignin = object.containsKey("wd_onbeg2") ? object.getString("wd_onbeg2") : "07:00";
+                b.endTime = object.containsKey("wd_offdutytwo") ? object.getString("wd_offdutytwo") : "--:--";
+                b.endSignnin = object.containsKey("wd_offend2") ? object.getString("wd_offend2") : "07:00";
+                beans.add(0, b);
+            case 1:
+                b = new Bean();
+                b.startTime = object.containsKey("wd_ondutyone") ? object.getString("wd_ondutyone") : "--:--";
+                b.startSignin = object.containsKey("wd_onbeg1") ? object.getString("wd_onbeg1") : "07:00";
+                b.endTime = object.containsKey("wd_offdutyone") ? object.getString("wd_offdutyone") : "--:--";
+                b.endSignnin = object.containsKey("wd_offend1") ? object.getString("wd_offend1") : "07:00";
+                beans.add(0, b);
+                break;
+        }//添加上班签到时间完成
+        setDataForAdapter(beans);
+    }
+
+    //处理数据,获取到用户签到列表
+    public void setDataByLogs(JSONArray array) {
+        ArrayList<Bean> beans = getDataByAdapter();
+        String[] logTime = new String[array.size()];
+        for (int i = 0; i < array.size(); i++) {//获取打卡记录中的打卡时间
+            logTime[i] = clearDay(array.getJSONObject(i).containsKey("cl_time") ? (array.getJSONObject(i).getString("cl_time") == null ? " " : array.getJSONObject(i).getString("cl_time")) : " ");
+        }
+        Arrays.sort(logTime);//排序时间数组
+        Bean b = null;
+        //TODO 待优化算法处理
+        for (int i = 0; i < beans.size(); i++) {
+            b = beans.get(i);
+            for (String e : logTime) {
+                if (!StringUtils.isEmpty(b.startSignin) && !StringUtils.isEmpty(b.endSignnin) && e.compareTo(b.startSignin) > 0 && e.compareTo(b.endSignnin) < 0) {
+                    beans.get(i).signinList.add(e);
+                }
+            }
+        }
+        setDataForAdapter(beans);
+    }
+
+    //从适配器中获取数据
+    private ArrayList<Bean> getDataByAdapter() {
+        return (adapter == null ? new ArrayList<Bean>() : (adapter.getBeans() == null ? new ArrayList<Bean>() : adapter.getBeans()));
+    }
+
+    //在设置完数据以后放到适配器中
+    private void setDataForAdapter(ArrayList<Bean> beans) {
+        if (adapter == null) {
+            adapter = new SigninAdapter(ct);
+            adapter.setBeans(beans);
+            listview.setAdapter(adapter);
+        } else {
+            adapter.setBeans(beans);
+        }
+        adapter.notifyDataSetChanged();
+    }
+
+
+    /**
+     * loadDatat
+     *
+     * @param time
+     */
+    //获取打卡时间
+    private void loadNetData(long time) {
+        selectTime = time;
+        //获取网络数据
+        String url = "mobile/getWorkDate.action";
+        int date = TimeUtils.int_long_2_str(time);
+        final Map<String, Object> param = new HashMap<>();
+        param.put("date", date);
+        loadNet(url, param, 0x11);
+    }
+
+    //获取打卡记录 date:yyyy-MM-dd
+    private void loadLog(String date) {
+        //获取网络数据
+        if (StringUtils.isEmpty(code)) {
+            code = CommonUtil.getSharedPreferences(ct, "erp_username");
+        }
+        String url = "mobile/common/list.action";
+        final Map<String, Object> param = new HashMap<>();
+        param.put("currentMaster", CommonUtil.getSharedPreferences(ct, "erp_master"));
+        param.put("page", 1);
+        param.put("pageSize", 1000);
+        param.put("condition", "cl_emcode='" + code + "' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'");
+        param.put("caller", "CardLog");
+        loadNet(url, param, 0x12);
+    }
+
+    //签到
+    private void doSignin(String code) {
+        signin_btn.setFocusable(false);
+        String url = "mobile/saveCardLog.action";
+        final Map<String, Object> param = new HashMap<>();
+        SigninBean bean = new SigninBean();
+        bean.setCl_code(code);
+        bean.setCl_address(office_addr.getText().toString());
+        bean.setCl_distance(distance);
+        bean.setCl_emcode(CommonUtil.getSharedPreferences(ct, "erp_username"));
+        bean.setCl_time(TimeUtils.f_long_2_str(System.currentTimeMillis()));
+        bean.setCl_location(office_addr.getText() == null ? "" : office_addr.getText().toString());
+        bean.setCl_emname(MyApplication.getInstance().mLoginUser.getNickName());
+        bean.setCl_phone(MyApplication.getInstance().mLoginUser.getTelephone());
+        String formStore = FlexJsonUtil.toJson(bean);
+        param.put("caller", "CardLog");
+        param.put("formStore", formStore);
+        loadNet(url, param, 0x13);
+    }
+
+    //请求合并,抽取共同代码
+    private void loadNet(String urlCheche, Map<String, Object> param, int what) {
+        ct.progressDialog.show();
+        String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + urlCheche;
+        if (StringUtils.isEmpty(code)) {
+            code = CommonUtil.getSharedPreferences(ct, "erp_username");
+        }
+        param.put("emcode", code);
+        param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
+        LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
+        headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
+        ViewUtil.httpSendRequest(ct, url, param, handler, headers, what, null, null, "get");
+    }
+
+
+    public class Bean {
+        String startTime;//上班时间
+        String endTime;//
+        String startSignin;
+        String endSignnin;
+        ArrayList<String> signinList = new ArrayList<>();
+
+        public String getStartTime() {
+            return startTime;
+        }
+
+        public void setStartTime(String startTime) {
+            this.startTime = startTime;
+        }
+
+        public String getEndTime() {
+            return endTime;
+        }
+
+        public void setEndTime(String endTime) {
+            this.endTime = endTime;
+        }
+
+        public String getStartSignin() {
+            return startSignin;
+        }
+
+        public void setStartSignin(String startSignin) {
+            this.startSignin = startSignin;
+        }
+
+        public String getEndSignnin() {
+            return endSignnin;
+        }
+
+        public void setEndSignnin(String endSignnin) {
+            this.endSignnin = endSignnin;
+        }
+
+        public ArrayList<String> getSigninList() {
+            return signinList;
+        }
+
+        public void setSigninList(ArrayList<String> signinList) {
+            this.signinList = signinList;
+        }
+    }
+}

+ 5 - 6
WeiChat/src/main/java/com/xzjmyk/pm/activity/util/BaiduMapUtil.java

@@ -181,10 +181,10 @@ public class BaiduMapUtil {
 
     /**
      * 结束获取周围位置信息
-     * <p>
-     * <p>
-     * <p>
-     * <p>
+     * <p/>
+     * <p/>
+     * <p/>
+     * <p/>
      * 开始定位功能
      */
 
@@ -208,8 +208,7 @@ public class BaiduMapUtil {
 
     private LocationClientOption initLocation() {
         LocationClientOption option = new LocationClientOption();
-        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
-        );//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
+        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
         option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
         int span = 0;
         option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的

+ 882 - 963
WeiChat/src/main/java/com/xzjmyk/pm/activity/view/crouton/Crouton.java

@@ -38,6 +38,9 @@ import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import com.xzjmyk.pm.activity.R;
+import com.xzjmyk.pm.activity.ui.base.BaseActivity;
+
 /*
  * Based on an article by Cyril Mottier (http://android.cyrilmottier.com/?p=773) <br>
  */
@@ -52,1006 +55,922 @@ import android.widget.TextView;
  * {@link Activity#onDestroy()} to avoid {@link Context} leaks.
  */
 public final class Crouton {
-  private static final String NULL_PARAMETERS_ARE_NOT_ACCEPTED = "Null parameters are not accepted";
-  private static final int IMAGE_ID = 0x100;
-  private static final int TEXT_ID = 0x101;
-  private final CharSequence text;
-  private final Style style;
-  private Configuration configuration = null;
-  private final View customView;
-
-  private OnClickListener onClickListener;
-
-  private Activity activity;
-  private ViewGroup viewGroup;
-  private FrameLayout croutonView;
-  private Animation inAnimation;
-  private Animation outAnimation;
-  private LifecycleCallback lifecycleCallback = null;
-
-  /**
-   * Creates the {@link Crouton}.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should be attached
-   *     to.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   */
-  private Crouton(Activity activity, CharSequence text, Style style) {
-    if ((activity == null) || (text == null) || (style == null)) {
-      throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
-    }
-
-    this.activity = activity;
-    this.viewGroup = null;
-    this.text = text;
-    this.style = style;
-    this.customView = null;
-  }
-
-  /**
-   * Creates the {@link Crouton}.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  private Crouton(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
-    if ((activity == null) || (text == null) || (style == null)) {
-      throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
-    }
-
-    this.activity = activity;
-    this.text = text;
-    this.style = style;
-    this.viewGroup = viewGroup;
-    this.customView = null;
-  }
-
-  /**
-   * Creates the {@link Crouton}.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should be attached
-   *     to.
-   * @param customView
-   *     The custom {@link View} to display
-   */
-  private Crouton(Activity activity, View customView) {
-    if ((activity == null) || (customView == null)) {
-      throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
-    }
-
-    this.activity = activity;
-    this.viewGroup = null;
-    this.customView = customView;
-    this.style = new Style.Builder().build();
-    this.text = null;
-  }
-
-  /**
-   * Creates the {@link Crouton}.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  private Crouton(Activity activity, View customView, ViewGroup viewGroup) {
-    this(activity, customView, viewGroup, Configuration.DEFAULT);
-  }
-
-  /**
-   * Creates the {@link Crouton}.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   * @param configuration
-   *     The {@link Configuration} for this {@link Crouton}.
-   */
-  private Crouton(final Activity activity, final View customView, final ViewGroup viewGroup,
-                  final Configuration configuration) {
-    if ((activity == null) || (customView == null)) {
-      throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
-    }
-
-    this.activity = activity;
-    this.customView = customView;
-    this.viewGroup = viewGroup;
-    this.style = new Style.Builder().build();
-    this.text = null;
-    this.configuration = configuration;
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should be attached
-   *     to.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton makeText(Activity activity, CharSequence text, Style style) {
-    return new Crouton(activity, text, style);
-  }
-
-  /**
-   * 自定义设置背景色,延时时间
-   * @param activity
-   * @param text
-   * @param color
-   * @param time
-   * @return
-   */
-  public static Crouton makeText(Activity activity, CharSequence text, int color, int time){
-    Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
-    Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
-    return new Crouton(activity, text, customColor).setConfiguration(customConfiguration);
-  }
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton makeText(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
-    return new Crouton(activity, text, style, viewGroup);
-  }
-  /**
-   * 自定义设置背景色,延时时间
-   * @param activity
-   * @param text
-   * @param color
-   * @param time
-   * @return
-   */
-  public static Crouton makeText(Activity activity, CharSequence text, int color, int time, ViewGroup viewGroup){
-    Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
-    Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
-    return new Crouton(activity, text, customColor,viewGroup).setConfiguration(customConfiguration);
-  }
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton makeText(Activity activity, CharSequence text, Style style, int viewGroupResId) {
-    return new Crouton(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId));
-  }
-  /**
-   * 自定义设置背景色,延时时间
-   * @param activity
-   * @param text
-   * @param color
-   * @param time
-   * @return
-   */
-  public static Crouton makeText(Activity activity, CharSequence text, int color, int time, int viewGroupResId) {
-    Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
-    Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
-    return new Crouton(activity, text, customColor, (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(customConfiguration);
-  }
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should be attached
-   *     to.
-   * @param textResourceId
-   *     The resource id of the text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton makeText(Activity activity, int textResourceId, Style style) {
-    return makeText(activity, activity.getString(textResourceId), style);
-  }
-
-  /**
-   * 自定义设置背景色,延时时间
-   * @param activity
-   * @param textResourceId
-   * @param color
-   * @param time
-   * @return
-   */
-  public static Crouton makeText(Activity activity, int textResourceId, int color, int time) {
-    Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
-    Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
-    return makeText(activity, activity.getString(textResourceId), customColor).setConfiguration(customConfiguration);
-  }
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param textResourceId
-   *     The resource id of the text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton makeText(Activity activity, int textResourceId, Style style, ViewGroup viewGroup) {
-    return makeText(activity, activity.getString(textResourceId), style, viewGroup);
-  }
-
-  /**
-   * 自定义设置背景色,延时时间
-   * @param activity
-   * @param textResourceId
-   * @param color
-   * @param time
-   * @param viewGroup
-   * @return
-   */
-  public static Crouton makeText(Activity activity, int textResourceId, int color, int time, ViewGroup viewGroup) {
-    Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
-    Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
-    return makeText(activity, activity.getString(textResourceId), customColor, viewGroup).setConfiguration(customConfiguration);
-  }
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param textResourceId
-   *     The resource id of the text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton makeText(Activity activity, int textResourceId, Style style, int viewGroupResId) {
-    return makeText(activity, activity.getString(textResourceId), style,
-            (ViewGroup) activity.findViewById(viewGroupResId));
-  }
-
-  /**
-   * 自定义设置背景色,延时时间
-   * @param activity
-   * @param textResourceId
-   * @param color
-   * @param time
-   * @param viewGroupResId
-   * @return
-   */
-  public static Crouton makeText(Activity activity, int textResourceId, int color, int time, int viewGroupResId) {
-    Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
-    Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
-    return makeText(activity, activity.getString(textResourceId), customColor,
-            (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(customConfiguration);
-  }
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should be attached
-   *     to.
-   * @param customView
-   *     The custom {@link View} to display
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton make(Activity activity, View customView) {
-    return new Crouton(activity, customView);
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton make(Activity activity, View customView, ViewGroup viewGroup) {
-    return new Crouton(activity, customView, viewGroup);
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton make(Activity activity, View customView, int viewGroupResId) {
-    return new Crouton(activity, customView, (ViewGroup) activity.findViewById(viewGroupResId));
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   * @param configuration
-   *     The configuration for this crouton.
-   *
-   * @return The created {@link Crouton}.
-   */
-  public static Crouton make(Activity activity, View customView, int viewGroupResId,
-                             final Configuration configuration) {
-    return new Crouton(activity, customView, (ViewGroup) activity.findViewById(viewGroupResId), configuration);
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should
-   *     be attached to.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   */
-  public static void showText(Activity activity, CharSequence text, Style style) {
-    makeText(activity, text, style).show();
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  public static void showText(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
-    makeText(activity, text, style, viewGroup).show();
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  public static void showText(Activity activity, CharSequence text, Style style, int viewGroupResId) {
-    makeText(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId)).show();
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param text
-   *     The text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   * @param configuration
-   *     The configuration for this Crouton.
-   */
-  public static void showText(Activity activity, CharSequence text, Style style, int viewGroupResId,
-                              final Configuration configuration) {
-    makeText(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(configuration)
-        .show();
-  }
-
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should
-   *     be attached to.
-   * @param customView
-   *     The custom {@link View} to display
-   */
-  public static void show(Activity activity, View customView) {
-    make(activity, customView).show();
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  public static void show(Activity activity, View customView, ViewGroup viewGroup) {
-    make(activity, customView, viewGroup).show();
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text and style for a given activity
-   * and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param customView
-   *     The custom {@link View} to display
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  public static void show(Activity activity, View customView, int viewGroupResId) {
-    make(activity, customView, viewGroupResId).show();
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that the {@link Crouton} should be attached
-   *     to.
-   * @param textResourceId
-   *     The resource id of the text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   */
-  public static void showText(Activity activity, int textResourceId, Style style) {
-    showText(activity, activity.getString(textResourceId), style);
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param textResourceId
-   *     The resource id of the text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroup
-   *     The {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  public static void showText(Activity activity, int textResourceId, Style style, ViewGroup viewGroup) {
-    showText(activity, activity.getString(textResourceId), style, viewGroup);
-  }
-
-  /**
-   * Creates a {@link Crouton} with provided text-resource and style for a given
-   * activity and displays it directly.
-   *
-   * @param activity
-   *     The {@link Activity} that represents the context in which the Crouton should exist.
-   * @param textResourceId
-   *     The resource id of the text you want to display.
-   * @param style
-   *     The style that this {@link Crouton} should be created with.
-   * @param viewGroupResId
-   *     The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
-   */
-  public static void showText(Activity activity, int textResourceId, Style style, int viewGroupResId) {
-    showText(activity, activity.getString(textResourceId), style, viewGroupResId);
-  }
-
-  /**
-   * Allows hiding of a previously displayed {@link Crouton}.
-   *
-   * @param crouton
-   *     The {@link Crouton} you want to hide.
-   */
-  public static void hide(Crouton crouton) {
-    crouton.hide();
-  }
-
-  /**
-   * Cancels all queued {@link Crouton}s. If there is a {@link Crouton}
-   * displayed currently, it will be the last one displayed.
-   */
-  public static void cancelAllCroutons() {
-    Manager.getInstance().clearCroutonQueue();
-  }
-
-  /**
-   * Clears (and removes from {@link Activity}'s content view, if necessary) all
-   * croutons for the provided activity
-   *
-   * @param activity
-   *     - The {@link Activity} to clear the croutons for.
-   */
-  public static void clearCroutonsForActivity(Activity activity) {
-    Manager.getInstance().clearCroutonsForActivity(activity);
-  }
-
-  /**
-   * Cancels a {@link Crouton} immediately.
-   */
-  public void cancel() {
-    Manager manager = Manager.getInstance();
-    manager.removeCroutonImmediately(this);
-  }
-
-  /**
-   * Displays the {@link Crouton}. If there's another {@link Crouton} visible at
-   * the time, this {@link Crouton} will be displayed afterwards.
-   */
-  public void show() {
-    Manager.getInstance().add(this);
-  }
-
-  public Animation getInAnimation() {
-    if ((null == this.inAnimation) && (null != this.activity)) {
-      if (getConfiguration().inAnimationResId > 0) {
-        this.inAnimation = AnimationUtils.loadAnimation(getActivity(), getConfiguration().inAnimationResId);
-      } else {
-        measureCroutonView();
-        this.inAnimation = DefaultAnimationsBuilder.buildDefaultSlideInDownAnimation(getView());
-      }
-    }
-
-    return inAnimation;
-  }
-
-  public Animation getOutAnimation() {
-    if ((null == this.outAnimation) && (null != this.activity)) {
-      if (getConfiguration().outAnimationResId > 0) {
-        this.outAnimation = AnimationUtils.loadAnimation(getActivity(), getConfiguration().outAnimationResId);
-      } else {
-        this.outAnimation = DefaultAnimationsBuilder.buildDefaultSlideOutUpAnimation(getView());
-      }
-    }
-
-    return outAnimation;
-  }
-
-  /**
-   * @param lifecycleCallback
-   *     Callback object for notable events in the life of a Crouton.
-   */
-  public void setLifecycleCallback(LifecycleCallback lifecycleCallback) {
-    this.lifecycleCallback = lifecycleCallback;
-  }
-
-  /**
-   * Removes this {@link Crouton}.
-   *
-   * @since 1.9
-   */
-  public void hide() {
-    Manager.getInstance().removeCrouton(this);
-  }
-
-  /**
-   * Allows setting of an {@link OnClickListener} directly to a {@link Crouton} without having to use a custom view.
-   *
-   * @param onClickListener
-   *     The {@link OnClickListener} to set.
-   *
-   * @return this {@link Crouton}.
-   */
-  public Crouton setOnClickListener(OnClickListener onClickListener) {
-    this.onClickListener = onClickListener;
-    return this;
-  }
-
-  /**
-   * Set the {@link Configuration} on this {@link Crouton}, prior to showing it.
-   *
-   * @param configuration
-   *     a {@link Configuration} built using the {@link Configuration.Builder}.
-   *
-   * @return this {@link Crouton}.
-   */
-  public Crouton setConfiguration(final Configuration configuration) {
-    this.configuration = configuration;
-    return this;
-  }
-
-  @Override
-  public String toString() {
-    return "Crouton{" +
-        "text=" + text +
-        ", style=" + style +
-        ", configuration=" + configuration +
-        ", customView=" + customView +
-        ", onClickListener=" + onClickListener +
-        ", activity=" + activity +
-        ", viewGroup=" + viewGroup +
-        ", croutonView=" + croutonView +
-        ", inAnimation=" + inAnimation +
-        ", outAnimation=" + outAnimation +
-        ", lifecycleCallback=" + lifecycleCallback +
-        '}';
-  }
-
-  /**
-   * Convenience method to get the license text for embedding within your application.
-   *
-   * @return The license text.
-   */
-  public static String getLicenseText() {
-    return "This application uses the Crouton library.\n\n" +
-        "Copyright 2012 - 2013 Benjamin Weiss \n" +
-        "\n" +
-        "Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
-        "you may not use this file except in compliance with the License.\n" +
-        "You may obtain a copy of the License at\n" +
-        "\n" +
-        "   http://www.apache.org/licenses/LICENSE-2.0\n" +
-        "\n" +
-        "Unless required by applicable law or agreed to in writing, software\n" +
-        "distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
-        "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
-        "See the License for the specific language governing permissions and\n" +
-        "limitations under the License.";
-  }
-
-  //////////////////////////////////////////////////////////////////////////////////////
-  // You have reached the internal API of Crouton.
-  // If you do not plan to develop for Crouton there is nothing of interest below here.
-  //////////////////////////////////////////////////////////////////////////////////////
-
-  /**
-   * @return <code>true</code> if the {@link Crouton} is being displayed, else
-   * <code>false</code>.
-   */
-  boolean isShowing() {
-    return (null != activity) && (isCroutonViewNotNull() || isCustomViewNotNull());
-  }
-
-  private boolean isCroutonViewNotNull() {
-    return (null != croutonView) && (null != croutonView.getParent());
-  }
-
-  private boolean isCustomViewNotNull() {
-    return (null != customView) && (null != customView.getParent());
-  }
-
-  /**
-   * Removes the activity reference this {@link Crouton} is holding
-   */
-  void detachActivity() {
-    activity = null;
-  }
-
-  /**
-   * Removes the viewGroup reference this {@link Crouton} is holding
-   */
-  void detachViewGroup() {
-    viewGroup = null;
-  }
-
-  /**
-   * Removes the lifecycleCallback reference this {@link Crouton} is holding
-   */
-  void detachLifecycleCallback() {
-    lifecycleCallback = null;
-  }
-
-  /**
-   * @return the lifecycleCallback
-   */
-  LifecycleCallback getLifecycleCallback() {
-    return lifecycleCallback;
-  }
-
-  /**
-   * @return the style
-   */
-  Style getStyle() {
-    return style;
-  }
-
-  /**
-   * @return this croutons configuration
-   */
-  Configuration getConfiguration() {
-    if (null == configuration) {
-      configuration = getStyle().configuration;
-    }
-    return configuration;
-  }
-
-  /**
-   * @return the activity
-   */
-  Activity getActivity() {
-    return activity;
-  }
-
-  /**
-   * @return the viewGroup
-   */
-  ViewGroup getViewGroup() {
-    return viewGroup;
-  }
-
-  /**
-   * @return the text
-   */
-  CharSequence getText() {
-    return text;
-  }
-
-  /**
-   * @return the view
-   */
-  View getView() {
-    // return the custom view if one exists
-    if (null != this.customView) {
-      return this.customView;
-    }
-
-    // if already setup return the view
-    if (null == this.croutonView) {
-      initializeCroutonView();
-    }
-
-    return croutonView;
-  }
-
-  private void measureCroutonView() {
-    View view = getView();
-    int widthSpec;
-    if (null != viewGroup) {
-      widthSpec = View.MeasureSpec.makeMeasureSpec(viewGroup.getMeasuredWidth(), View.MeasureSpec.AT_MOST);
-    } else {
-      widthSpec = View.MeasureSpec.makeMeasureSpec(activity.getWindow().getDecorView().getMeasuredWidth(),
-          View.MeasureSpec.AT_MOST);
-    }
-
-    view.measure(widthSpec, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
-  }
-
-  private void initializeCroutonView() {
-    Resources resources = this.activity.getResources();
-
-    this.croutonView = initializeCroutonViewGroup(resources);
-
-    // create content view
-    RelativeLayout contentView = initializeContentView(resources);
-    this.croutonView.addView(contentView);
-  }
-
-  private FrameLayout initializeCroutonViewGroup(Resources resources) {
-    FrameLayout croutonView = new FrameLayout(this.activity);
-
-    if (null != onClickListener) {
-      croutonView.setOnClickListener(onClickListener);
-    }
-
-    final int height;
-    if (this.style.heightDimensionResId > 0) {
-      height = resources.getDimensionPixelSize(this.style.heightDimensionResId);
-    } else {
-      height = this.style.heightInPixels;
-    }
-
-    final int width;
-    if (this.style.widthDimensionResId > 0) {
-      width = resources.getDimensionPixelSize(this.style.widthDimensionResId);
-    } else {
-      width = this.style.widthInPixels;
+    private static final String NULL_PARAMETERS_ARE_NOT_ACCEPTED = "Null parameters are not accepted";
+    private static final int IMAGE_ID = 0x100;
+    private static final int TEXT_ID = 0x101;
+    private final CharSequence text;
+    private final Style style;
+    private Configuration configuration = null;
+    private final View customView;
+
+    private OnClickListener onClickListener;
+
+    private Activity activity;
+    private ViewGroup viewGroup;
+    private FrameLayout croutonView;
+    private Animation inAnimation;
+    private Animation outAnimation;
+    private LifecycleCallback lifecycleCallback = null;
+
+    /**
+     * Creates the {@link Crouton}.
+     *
+     * @param activity The {@link Activity} that the {@link Crouton} should be attached
+     *                 to.
+     * @param text     The text you want to display.
+     * @param style    The style that this {@link Crouton} should be created with.
+     */
+    private Crouton(Activity activity, CharSequence text, Style style) {
+        if ((activity == null) || (text == null) || (style == null)) {
+            throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
+        }
+
+        this.activity = activity;
+        this.viewGroup = null;
+        this.text = text;
+        this.style = style;
+        this.customView = null;
     }
 
-    croutonView.setLayoutParams(
-        new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
+    /**
+     * Creates the {@link Crouton}.
+     *
+     * @param activity  The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param text      The text you want to display.
+     * @param style     The style that this {@link Crouton} should be created with.
+     * @param viewGroup The {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    private Crouton(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
+        if ((activity == null) || (text == null) || (style == null)) {
+            throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
+        }
+
+        this.activity = activity;
+        this.text = text;
+        this.style = style;
+        this.viewGroup = viewGroup;
+        this.customView = null;
+    }
 
-    // set background
-    if (this.style.backgroundColorValue != Style.NOT_SET) {
-      croutonView.setBackgroundColor(this.style.backgroundColorValue);
-    } else {
-      croutonView.setBackgroundColor(resources.getColor(this.style.backgroundColorResourceId));
+    /**
+     * Creates the {@link Crouton}.
+     *
+     * @param activity   The {@link Activity} that the {@link Crouton} should be attached
+     *                   to.
+     * @param customView The custom {@link View} to display
+     */
+    private Crouton(Activity activity, View customView) {
+        if ((activity == null) || (customView == null)) {
+            throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
+        }
+
+        this.activity = activity;
+        this.viewGroup = null;
+        this.customView = customView;
+        this.style = new Style.Builder().build();
+        this.text = null;
     }
 
-    // set the background drawable if set. This will override the background
-    // color.
-    if (this.style.backgroundDrawableResourceId != 0) {
-      Bitmap background = BitmapFactory.decodeResource(resources, this.style.backgroundDrawableResourceId);
-      BitmapDrawable drawable = new BitmapDrawable(resources, background);
-      if (this.style.isTileEnabled) {
-        drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
-      }
-      croutonView.setBackgroundDrawable(drawable);
+    /**
+     * Creates the {@link Crouton}.
+     *
+     * @param activity   The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView The custom {@link View} to display
+     * @param viewGroup  The {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    private Crouton(Activity activity, View customView, ViewGroup viewGroup) {
+        this(activity, customView, viewGroup, Configuration.DEFAULT);
     }
-    return croutonView;
-  }
 
-  private RelativeLayout initializeContentView(final Resources resources) {
-    RelativeLayout contentView = new RelativeLayout(this.activity);
-    contentView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
-        RelativeLayout.LayoutParams.MATCH_PARENT));
+    /**
+     * Creates the {@link Crouton}.
+     *
+     * @param activity      The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView    The custom {@link View} to display
+     * @param viewGroup     The {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @param configuration The {@link Configuration} for this {@link Crouton}.
+     */
+    private Crouton(final Activity activity, final View customView, final ViewGroup viewGroup,
+                    final Configuration configuration) {
+        if ((activity == null) || (customView == null)) {
+            throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
+        }
+
+        this.activity = activity;
+        this.customView = customView;
+        this.viewGroup = viewGroup;
+        this.style = new Style.Builder().build();
+        this.text = null;
+        this.configuration = configuration;
+    }
 
-    // set padding
-    int padding = this.style.paddingInPixels;
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given
+     * activity.
+     *
+     * @param activity The {@link Activity} that the {@link Crouton} should be attached
+     *                 to.
+     * @param text     The text you want to display.
+     * @param style    The style that this {@link Crouton} should be created with.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton makeText(Activity activity, CharSequence text, Style style) {
+        return new Crouton(activity, text, style);
+    }
 
-    // if a padding dimension has been set, this will overwrite any padding
-    // in pixels
-    if (this.style.paddingDimensionResId > 0) {
-      padding = resources.getDimensionPixelSize(this.style.paddingDimensionResId);
+    public static void makeText(Context ct, String message) {
+        makeText((BaseActivity) ct, message, ct.getResources().getColor(R.color.light_green), 1000).show();
     }
-    contentView.setPadding(padding, padding, padding, padding);
 
-    // only setup image if one is requested
-    ImageView image = null;
-    if ((null != this.style.imageDrawable) || (0 != this.style.imageResId)) {
-      image = initializeImageView();
-      contentView.addView(image, image.getLayoutParams());
+    /**
+     * 自定义设置背景色,延时时间
+     *
+     * @param activity
+     * @param text
+     * @param color
+     * @param time
+     * @return
+     */
+    public static Crouton makeText(Activity activity, CharSequence text, int color, int time) {
+        Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
+        Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
+        return new Crouton(activity, text, customColor).setConfiguration(customConfiguration);
     }
 
-    TextView text = initializeTextView(resources);
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given
+     * activity.
+     *
+     * @param activity  The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param text      The text you want to display.
+     * @param style     The style that this {@link Crouton} should be created with.
+     * @param viewGroup The {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton makeText(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
+        return new Crouton(activity, text, style, viewGroup);
+    }
 
-    RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
-        RelativeLayout.LayoutParams.WRAP_CONTENT);
-    if (null != image) {
-      textParams.addRule(RelativeLayout.RIGHT_OF, image.getId());
+    /**
+     * 自定义设置背景色,延时时间
+     *
+     * @param activity
+     * @param text
+     * @param color
+     * @param time
+     * @return
+     */
+    public static Crouton makeText(Activity activity, CharSequence text, int color, int time, ViewGroup viewGroup) {
+        Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
+        Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
+        return new Crouton(activity, text, customColor, viewGroup).setConfiguration(customConfiguration);
     }
 
-    if ((this.style.gravity & Gravity.CENTER) != 0) {
-      textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
-    } else if ((this.style.gravity & Gravity.CENTER_VERTICAL) != 0) {
-      textParams.addRule(RelativeLayout.CENTER_VERTICAL);
-    } else if ((this.style.gravity & Gravity.CENTER_HORIZONTAL) != 0) {
-      textParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given
+     * activity.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param text           The text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton makeText(Activity activity, CharSequence text, Style style, int viewGroupResId) {
+        return new Crouton(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId));
     }
 
-    contentView.addView(text, textParams);
-    return contentView;
-  }
+    /**
+     * 自定义设置背景色,延时时间
+     *
+     * @param activity
+     * @param text
+     * @param color
+     * @param time
+     * @return
+     */
+    public static Crouton makeText(Activity activity, CharSequence text, int color, int time, int viewGroupResId) {
+        Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
+        Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
+        return new Crouton(activity, text, customColor, (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(customConfiguration);
+    }
 
-  private TextView initializeTextView(final Resources resources) {
-    TextView text = new TextView(this.activity);
-    text.setId(TEXT_ID);
-    if (this.style.fontName != null) {
-      setTextWithCustomFont(text, this.style.fontName);
-    } else if (this.style.fontNameResId != 0) {
-      setTextWithCustomFont(text, resources.getString(this.style.fontNameResId));
-    } else {
-      text.setText(this.text);
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity       The {@link Activity} that the {@link Crouton} should be attached
+     *                       to.
+     * @param textResourceId The resource id of the text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton makeText(Activity activity, int textResourceId, Style style) {
+        return makeText(activity, activity.getString(textResourceId), style);
     }
-    text.setTypeface(Typeface.DEFAULT_BOLD);
-    text.setGravity(this.style.gravity);
 
-    // set the text color if set
-    if (this.style.textColorValue != Style.NOT_SET) {
-      text.setTextColor(this.style.textColorValue);
-    } else if (this.style.textColorResourceId != 0) {
-      text.setTextColor(resources.getColor(this.style.textColorResourceId));
+    /**
+     * 自定义设置背景色,延时时间
+     *
+     * @param activity
+     * @param textResourceId
+     * @param color
+     * @param time
+     * @return
+     */
+    public static Crouton makeText(Activity activity, int textResourceId, int color, int time) {
+        Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
+        Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
+        return makeText(activity, activity.getString(textResourceId), customColor).setConfiguration(customConfiguration);
     }
 
-    // Set the text size. If the user has set a text size and text
-    // appearance, the text size in the text appearance
-    // will override this.
-    if (this.style.textSize != 0) {
-      text.setTextSize(TypedValue.COMPLEX_UNIT_SP, this.style.textSize);
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param textResourceId The resource id of the text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroup      The {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton makeText(Activity activity, int textResourceId, Style style, ViewGroup viewGroup) {
+        return makeText(activity, activity.getString(textResourceId), style, viewGroup);
     }
 
-    // Setup the shadow if requested
-    if (this.style.textShadowColorResId != 0) {
-      initializeTextViewShadow(resources, text);
+    /**
+     * 自定义设置背景色,延时时间
+     *
+     * @param activity
+     * @param textResourceId
+     * @param color
+     * @param time
+     * @param viewGroup
+     * @return
+     */
+    public static Crouton makeText(Activity activity, int textResourceId, int color, int time, ViewGroup viewGroup) {
+        Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
+        Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
+        return makeText(activity, activity.getString(textResourceId), customColor, viewGroup).setConfiguration(customConfiguration);
     }
 
-    // Set the text appearance
-    if (this.style.textAppearanceResId != 0) {
-      text.setTextAppearance(this.activity, this.style.textAppearanceResId);
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param textResourceId The resource id of the text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton makeText(Activity activity, int textResourceId, Style style, int viewGroupResId) {
+        return makeText(activity, activity.getString(textResourceId), style,
+                (ViewGroup) activity.findViewById(viewGroupResId));
     }
-    return text;
-  }
 
-  private void setTextWithCustomFont(TextView text, String fontName) {
-    if (this.text != null) {
-      SpannableString s = new SpannableString(this.text);
-      s.setSpan(new TypefaceSpan(text.getContext(), fontName), 0, s.length(),
-          Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-      text.setText(s);
+    /**
+     * 自定义设置背景色,延时时间
+     *
+     * @param activity
+     * @param textResourceId
+     * @param color
+     * @param time
+     * @param viewGroupResId
+     * @return
+     */
+    public static Crouton makeText(Activity activity, int textResourceId, int color, int time, int viewGroupResId) {
+        Style customColor = new Style.Builder().setBackgroundColorValue(color).build();
+        Configuration customConfiguration = new Configuration.Builder().setDuration(time).build();
+        return makeText(activity, activity.getString(textResourceId), customColor,
+                (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(customConfiguration);
     }
-  }
 
-  private void initializeTextViewShadow(final Resources resources, final TextView text) {
-    int textShadowColor = resources.getColor(this.style.textShadowColorResId);
-    float textShadowRadius = this.style.textShadowRadius;
-    float textShadowDx = this.style.textShadowDx;
-    float textShadowDy = this.style.textShadowDy;
-    text.setShadowLayer(textShadowRadius, textShadowDx, textShadowDy, textShadowColor);
-  }
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity   The {@link Activity} that the {@link Crouton} should be attached
+     *                   to.
+     * @param customView The custom {@link View} to display
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton make(Activity activity, View customView) {
+        return new Crouton(activity, customView);
+    }
 
-  private ImageView initializeImageView() {
-    ImageView image;
-    image = new ImageView(this.activity);
-    image.setId(IMAGE_ID);
-    image.setAdjustViewBounds(true);
-    image.setScaleType(this.style.imageScaleType);
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity   The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView The custom {@link View} to display
+     * @param viewGroup  The {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton make(Activity activity, View customView, ViewGroup viewGroup) {
+        return new Crouton(activity, customView, viewGroup);
+    }
+
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView     The custom {@link View} to display
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton make(Activity activity, View customView, int viewGroupResId) {
+        return new Crouton(activity, customView, (ViewGroup) activity.findViewById(viewGroupResId));
+    }
 
-    // set the image drawable if not null
-    if (null != this.style.imageDrawable) {
-      image.setImageDrawable(this.style.imageDrawable);
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView     The custom {@link View} to display
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @param configuration  The configuration for this crouton.
+     * @return The created {@link Crouton}.
+     */
+    public static Crouton make(Activity activity, View customView, int viewGroupResId,
+                               final Configuration configuration) {
+        return new Crouton(activity, customView, (ViewGroup) activity.findViewById(viewGroupResId), configuration);
     }
 
-    // set the image resource if not 0. This will overwrite the drawable
-    // if both are set
-    if (this.style.imageResId != 0) {
-      image.setImageResource(this.style.imageResId);
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity The {@link Activity} that the {@link Crouton} should
+     *                 be attached to.
+     * @param text     The text you want to display.
+     * @param style    The style that this {@link Crouton} should be created with.
+     */
+    public static void showText(Activity activity, CharSequence text, Style style) {
+        makeText(activity, text, style).show();
     }
 
-    RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(
-        RelativeLayout.LayoutParams.WRAP_CONTENT,
-        RelativeLayout.LayoutParams.WRAP_CONTENT);
-    imageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
-    imageParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity  The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param text      The text you want to display.
+     * @param style     The style that this {@link Crouton} should be created with.
+     * @param viewGroup The {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    public static void showText(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
+        makeText(activity, text, style, viewGroup).show();
+    }
+
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param text           The text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    public static void showText(Activity activity, CharSequence text, Style style, int viewGroupResId) {
+        makeText(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId)).show();
+    }
 
-    image.setLayoutParams(imageParams);
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param text           The text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     * @param configuration  The configuration for this Crouton.
+     */
+    public static void showText(Activity activity, CharSequence text, Style style, int viewGroupResId,
+                                final Configuration configuration) {
+        makeText(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(configuration)
+                .show();
+    }
+
+
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity   The {@link Activity} that the {@link Crouton} should
+     *                   be attached to.
+     * @param customView The custom {@link View} to display
+     */
+    public static void show(Activity activity, View customView) {
+        make(activity, customView).show();
+    }
+
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity   The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView The custom {@link View} to display
+     * @param viewGroup  The {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    public static void show(Activity activity, View customView, ViewGroup viewGroup) {
+        make(activity, customView, viewGroup).show();
+    }
+
+    /**
+     * Creates a {@link Crouton} with provided text and style for a given activity
+     * and displays it directly.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param customView     The custom {@link View} to display
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    public static void show(Activity activity, View customView, int viewGroupResId) {
+        make(activity, customView, viewGroupResId).show();
+    }
+
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity and displays it directly.
+     *
+     * @param activity       The {@link Activity} that the {@link Crouton} should be attached
+     *                       to.
+     * @param textResourceId The resource id of the text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     */
+    public static void showText(Activity activity, int textResourceId, Style style) {
+        showText(activity, activity.getString(textResourceId), style);
+    }
+
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity and displays it directly.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param textResourceId The resource id of the text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroup      The {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    public static void showText(Activity activity, int textResourceId, Style style, ViewGroup viewGroup) {
+        showText(activity, activity.getString(textResourceId), style, viewGroup);
+    }
 
-    return image;
-  }
+    /**
+     * Creates a {@link Crouton} with provided text-resource and style for a given
+     * activity and displays it directly.
+     *
+     * @param activity       The {@link Activity} that represents the context in which the Crouton should exist.
+     * @param textResourceId The resource id of the text you want to display.
+     * @param style          The style that this {@link Crouton} should be created with.
+     * @param viewGroupResId The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+     */
+    public static void showText(Activity activity, int textResourceId, Style style, int viewGroupResId) {
+        showText(activity, activity.getString(textResourceId), style, viewGroupResId);
+    }
+
+    /**
+     * Allows hiding of a previously displayed {@link Crouton}.
+     *
+     * @param crouton The {@link Crouton} you want to hide.
+     */
+    public static void hide(Crouton crouton) {
+        crouton.hide();
+    }
+
+    /**
+     * Cancels all queued {@link Crouton}s. If there is a {@link Crouton}
+     * displayed currently, it will be the last one displayed.
+     */
+    public static void cancelAllCroutons() {
+        Manager.getInstance().clearCroutonQueue();
+    }
+
+    /**
+     * Clears (and removes from {@link Activity}'s content view, if necessary) all
+     * croutons for the provided activity
+     *
+     * @param activity - The {@link Activity} to clear the croutons for.
+     */
+    public static void clearCroutonsForActivity(Activity activity) {
+        Manager.getInstance().clearCroutonsForActivity(activity);
+    }
+
+    /**
+     * Cancels a {@link Crouton} immediately.
+     */
+    public void cancel() {
+        Manager manager = Manager.getInstance();
+        manager.removeCroutonImmediately(this);
+    }
+
+    /**
+     * Displays the {@link Crouton}. If there's another {@link Crouton} visible at
+     * the time, this {@link Crouton} will be displayed afterwards.
+     */
+    public void show() {
+        Manager.getInstance().add(this);
+    }
+
+    public Animation getInAnimation() {
+        if ((null == this.inAnimation) && (null != this.activity)) {
+            if (getConfiguration().inAnimationResId > 0) {
+                this.inAnimation = AnimationUtils.loadAnimation(getActivity(), getConfiguration().inAnimationResId);
+            } else {
+                measureCroutonView();
+                this.inAnimation = DefaultAnimationsBuilder.buildDefaultSlideInDownAnimation(getView());
+            }
+        }
+
+        return inAnimation;
+    }
+
+    public Animation getOutAnimation() {
+        if ((null == this.outAnimation) && (null != this.activity)) {
+            if (getConfiguration().outAnimationResId > 0) {
+                this.outAnimation = AnimationUtils.loadAnimation(getActivity(), getConfiguration().outAnimationResId);
+            } else {
+                this.outAnimation = DefaultAnimationsBuilder.buildDefaultSlideOutUpAnimation(getView());
+            }
+        }
+
+        return outAnimation;
+    }
+
+    /**
+     * @param lifecycleCallback Callback object for notable events in the life of a Crouton.
+     */
+    public void setLifecycleCallback(LifecycleCallback lifecycleCallback) {
+        this.lifecycleCallback = lifecycleCallback;
+    }
+
+    /**
+     * Removes this {@link Crouton}.
+     *
+     * @since 1.9
+     */
+    public void hide() {
+        Manager.getInstance().removeCrouton(this);
+    }
+
+    /**
+     * Allows setting of an {@link OnClickListener} directly to a {@link Crouton} without having to use a custom view.
+     *
+     * @param onClickListener The {@link OnClickListener} to set.
+     * @return this {@link Crouton}.
+     */
+    public Crouton setOnClickListener(OnClickListener onClickListener) {
+        this.onClickListener = onClickListener;
+        return this;
+    }
+
+    /**
+     * Set the {@link Configuration} on this {@link Crouton}, prior to showing it.
+     *
+     * @param configuration a {@link Configuration} built using the {@link Configuration.Builder}.
+     * @return this {@link Crouton}.
+     */
+    public Crouton setConfiguration(final Configuration configuration) {
+        this.configuration = configuration;
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return "Crouton{" +
+                "text=" + text +
+                ", style=" + style +
+                ", configuration=" + configuration +
+                ", customView=" + customView +
+                ", onClickListener=" + onClickListener +
+                ", activity=" + activity +
+                ", viewGroup=" + viewGroup +
+                ", croutonView=" + croutonView +
+                ", inAnimation=" + inAnimation +
+                ", outAnimation=" + outAnimation +
+                ", lifecycleCallback=" + lifecycleCallback +
+                '}';
+    }
+
+    /**
+     * Convenience method to get the license text for embedding within your application.
+     *
+     * @return The license text.
+     */
+    public static String getLicenseText() {
+        return "This application uses the Crouton library.\n\n" +
+                "Copyright 2012 - 2013 Benjamin Weiss \n" +
+                "\n" +
+                "Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
+                "you may not use this file except in compliance with the License.\n" +
+                "You may obtain a copy of the License at\n" +
+                "\n" +
+                "   http://www.apache.org/licenses/LICENSE-2.0\n" +
+                "\n" +
+                "Unless required by applicable law or agreed to in writing, software\n" +
+                "distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
+                "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
+                "See the License for the specific language governing permissions and\n" +
+                "limitations under the License.";
+    }
+
+    //////////////////////////////////////////////////////////////////////////////////////
+    // You have reached the internal API of Crouton.
+    // If you do not plan to develop for Crouton there is nothing of interest below here.
+    //////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * @return <code>true</code> if the {@link Crouton} is being displayed, else
+     * <code>false</code>.
+     */
+    boolean isShowing() {
+        return (null != activity) && (isCroutonViewNotNull() || isCustomViewNotNull());
+    }
+
+    private boolean isCroutonViewNotNull() {
+        return (null != croutonView) && (null != croutonView.getParent());
+    }
+
+    private boolean isCustomViewNotNull() {
+        return (null != customView) && (null != customView.getParent());
+    }
+
+    /**
+     * Removes the activity reference this {@link Crouton} is holding
+     */
+    void detachActivity() {
+        activity = null;
+    }
+
+    /**
+     * Removes the viewGroup reference this {@link Crouton} is holding
+     */
+    void detachViewGroup() {
+        viewGroup = null;
+    }
+
+    /**
+     * Removes the lifecycleCallback reference this {@link Crouton} is holding
+     */
+    void detachLifecycleCallback() {
+        lifecycleCallback = null;
+    }
+
+    /**
+     * @return the lifecycleCallback
+     */
+    LifecycleCallback getLifecycleCallback() {
+        return lifecycleCallback;
+    }
+
+    /**
+     * @return the style
+     */
+    Style getStyle() {
+        return style;
+    }
+
+    /**
+     * @return this croutons configuration
+     */
+    Configuration getConfiguration() {
+        if (null == configuration) {
+            configuration = getStyle().configuration;
+        }
+        return configuration;
+    }
+
+    /**
+     * @return the activity
+     */
+    Activity getActivity() {
+        return activity;
+    }
+
+    /**
+     * @return the viewGroup
+     */
+    ViewGroup getViewGroup() {
+        return viewGroup;
+    }
+
+    /**
+     * @return the text
+     */
+    CharSequence getText() {
+        return text;
+    }
+
+    /**
+     * @return the view
+     */
+    View getView() {
+        // return the custom view if one exists
+        if (null != this.customView) {
+            return this.customView;
+        }
+
+        // if already setup return the view
+        if (null == this.croutonView) {
+            initializeCroutonView();
+        }
+
+        return croutonView;
+    }
+
+    private void measureCroutonView() {
+        View view = getView();
+        int widthSpec;
+        if (null != viewGroup) {
+            widthSpec = View.MeasureSpec.makeMeasureSpec(viewGroup.getMeasuredWidth(), View.MeasureSpec.AT_MOST);
+        } else {
+            widthSpec = View.MeasureSpec.makeMeasureSpec(activity.getWindow().getDecorView().getMeasuredWidth(),
+                    View.MeasureSpec.AT_MOST);
+        }
+
+        view.measure(widthSpec, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
+    }
+
+    private void initializeCroutonView() {
+        Resources resources = this.activity.getResources();
+
+        this.croutonView = initializeCroutonViewGroup(resources);
+
+        // create content view
+        RelativeLayout contentView = initializeContentView(resources);
+        this.croutonView.addView(contentView);
+    }
+
+    private FrameLayout initializeCroutonViewGroup(Resources resources) {
+        FrameLayout croutonView = new FrameLayout(this.activity);
+
+        if (null != onClickListener) {
+            croutonView.setOnClickListener(onClickListener);
+        }
+
+        final int height;
+        if (this.style.heightDimensionResId > 0) {
+            height = resources.getDimensionPixelSize(this.style.heightDimensionResId);
+        } else {
+            height = this.style.heightInPixels;
+        }
+
+        final int width;
+        if (this.style.widthDimensionResId > 0) {
+            width = resources.getDimensionPixelSize(this.style.widthDimensionResId);
+        } else {
+            width = this.style.widthInPixels;
+        }
+
+        croutonView.setLayoutParams(
+                new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
+
+        // set background
+        if (this.style.backgroundColorValue != Style.NOT_SET) {
+            croutonView.setBackgroundColor(this.style.backgroundColorValue);
+        } else {
+            croutonView.setBackgroundColor(resources.getColor(this.style.backgroundColorResourceId));
+        }
+
+        // set the background drawable if set. This will override the background
+        // color.
+        if (this.style.backgroundDrawableResourceId != 0) {
+            Bitmap background = BitmapFactory.decodeResource(resources, this.style.backgroundDrawableResourceId);
+            BitmapDrawable drawable = new BitmapDrawable(resources, background);
+            if (this.style.isTileEnabled) {
+                drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+            }
+            croutonView.setBackgroundDrawable(drawable);
+        }
+        return croutonView;
+    }
+
+    private RelativeLayout initializeContentView(final Resources resources) {
+        RelativeLayout contentView = new RelativeLayout(this.activity);
+        contentView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
+                RelativeLayout.LayoutParams.MATCH_PARENT));
+
+        // set padding
+        int padding = this.style.paddingInPixels;
+
+        // if a padding dimension has been set, this will overwrite any padding
+        // in pixels
+        if (this.style.paddingDimensionResId > 0) {
+            padding = resources.getDimensionPixelSize(this.style.paddingDimensionResId);
+        }
+        contentView.setPadding(padding, padding, padding, padding);
+
+        // only setup image if one is requested
+        ImageView image = null;
+        if ((null != this.style.imageDrawable) || (0 != this.style.imageResId)) {
+            image = initializeImageView();
+            contentView.addView(image, image.getLayoutParams());
+        }
+
+        TextView text = initializeTextView(resources);
+
+        RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
+                RelativeLayout.LayoutParams.WRAP_CONTENT);
+        if (null != image) {
+            textParams.addRule(RelativeLayout.RIGHT_OF, image.getId());
+        }
+
+        if ((this.style.gravity & Gravity.CENTER) != 0) {
+            textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
+        } else if ((this.style.gravity & Gravity.CENTER_VERTICAL) != 0) {
+            textParams.addRule(RelativeLayout.CENTER_VERTICAL);
+        } else if ((this.style.gravity & Gravity.CENTER_HORIZONTAL) != 0) {
+            textParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
+        }
+
+        contentView.addView(text, textParams);
+        return contentView;
+    }
+
+    private TextView initializeTextView(final Resources resources) {
+        TextView text = new TextView(this.activity);
+        text.setId(TEXT_ID);
+        if (this.style.fontName != null) {
+            setTextWithCustomFont(text, this.style.fontName);
+        } else if (this.style.fontNameResId != 0) {
+            setTextWithCustomFont(text, resources.getString(this.style.fontNameResId));
+        } else {
+            text.setText(this.text);
+        }
+        text.setTypeface(Typeface.DEFAULT_BOLD);
+        text.setGravity(this.style.gravity);
+
+        // set the text color if set
+        if (this.style.textColorValue != Style.NOT_SET) {
+            text.setTextColor(this.style.textColorValue);
+        } else if (this.style.textColorResourceId != 0) {
+            text.setTextColor(resources.getColor(this.style.textColorResourceId));
+        }
+
+        // Set the text size. If the user has set a text size and text
+        // appearance, the text size in the text appearance
+        // will override this.
+        if (this.style.textSize != 0) {
+            text.setTextSize(TypedValue.COMPLEX_UNIT_SP, this.style.textSize);
+        }
+
+        // Setup the shadow if requested
+        if (this.style.textShadowColorResId != 0) {
+            initializeTextViewShadow(resources, text);
+        }
+
+        // Set the text appearance
+        if (this.style.textAppearanceResId != 0) {
+            text.setTextAppearance(this.activity, this.style.textAppearanceResId);
+        }
+        return text;
+    }
+
+    private void setTextWithCustomFont(TextView text, String fontName) {
+        if (this.text != null) {
+            SpannableString s = new SpannableString(this.text);
+            s.setSpan(new TypefaceSpan(text.getContext(), fontName), 0, s.length(),
+                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+            text.setText(s);
+        }
+    }
+
+    private void initializeTextViewShadow(final Resources resources, final TextView text) {
+        int textShadowColor = resources.getColor(this.style.textShadowColorResId);
+        float textShadowRadius = this.style.textShadowRadius;
+        float textShadowDx = this.style.textShadowDx;
+        float textShadowDy = this.style.textShadowDy;
+        text.setShadowLayer(textShadowRadius, textShadowDx, textShadowDy, textShadowColor);
+    }
+
+    private ImageView initializeImageView() {
+        ImageView image;
+        image = new ImageView(this.activity);
+        image.setId(IMAGE_ID);
+        image.setAdjustViewBounds(true);
+        image.setScaleType(this.style.imageScaleType);
+
+        // set the image drawable if not null
+        if (null != this.style.imageDrawable) {
+            image.setImageDrawable(this.style.imageDrawable);
+        }
+
+        // set the image resource if not 0. This will overwrite the drawable
+        // if both are set
+        if (this.style.imageResId != 0) {
+            image.setImageResource(this.style.imageResId);
+        }
+
+        RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(
+                RelativeLayout.LayoutParams.WRAP_CONTENT,
+                RelativeLayout.LayoutParams.WRAP_CONTENT);
+        imageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
+        imageParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
+
+        image.setLayoutParams(imageParams);
+
+        return image;
+    }
 }

+ 0 - 1
WeiChat/src/main/res/layout/activity_meet_details.xml

@@ -74,7 +74,6 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="10dp"
-            android:text="crm、OA导论"
             android:textColor="@color/text_main"
             android:textSize="@dimen/text_main" />
 

+ 99 - 0
WeiChat/src/main/res/layout/fragment_click_signin.xml

@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/oa_main">
+
+    <RelativeLayout
+        android:id="@+id/top"
+        android:layout_width="match_parent"
+        android:layout_height="?attr/actionBarSize"
+        android:background="@color/antionbarcolor">
+
+        <ImageView
+            android:id="@+id/back"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:padding="10dp"
+            android:src="@drawable/back" />
+
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:drawableRight="@drawable/down"
+            android:textColor="@color/white"
+            android:textSize="@dimen/text_main" />
+
+        <ImageView
+            android:id="@+id/seting"
+            android:layout_width="40dp"
+            android:layout_height="match_parent"
+            android:layout_alignParentRight="true"
+            android:padding="8dp"
+            android:src="@drawable/setting" />
+    </RelativeLayout>
+
+    <LinearLayout
+        android:id="@+id/oa_range_addr_rl"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="8dp"
+        android:orientation="vertical"
+        android:padding="5dp">
+
+        <TextView
+            android:id="@+id/office_addr"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:drawableLeft="@drawable/oa_signin"
+            android:gravity="center_horizontal"
+            android:text="考勤地点:"
+            android:drawablePadding="10dp"
+            android:textColor="@color/text_hine" />
+
+        <TextView
+            android:id="@+id/unoffice_mm"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:text="地点微调"
+            android:textColor="@color/cadetblue" />
+    </LinearLayout>
+
+    <ImageView
+        android:id="@+id/signin_btn"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_above="@+id/oa_range_addr_rl"
+        android:layout_centerHorizontal="true"
+        android:layout_marginBottom="8dp"
+        android:clickable="true"
+        android:gravity="center"
+        android:src="@drawable/signin_btn" />
+    <View
+        android:layout_width="2px"
+        android:layout_height="match_parent"
+        android:layout_above="@+id/signin_btn"
+        android:layout_below="@+id/top"
+        android:layout_centerHorizontal="true"
+        android:background="@color/item_line" />
+    <ListView
+        android:id="@+id/listview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_above="@id/signin_btn"
+        android:layout_below="@id/top"
+        android:layout_marginTop="5dp"
+        android:clickable="false"
+        android:divider="@null"
+        android:dividerHeight="0dp"
+        android:focusable="false"
+        android:longClickable="false"
+        android:minHeight="100dp" />
+
+
+</RelativeLayout>

+ 4 - 2
WeiChat/src/main/res/layout/fragment_signin.xml

@@ -50,9 +50,9 @@
             android:layout_height="wrap_content"
             android:layout_gravity="center_horizontal"
             android:drawableLeft="@drawable/oa_signin"
+            android:drawablePadding="10dp"
             android:gravity="center_horizontal"
             android:text="考勤地点:"
-            android:drawablePadding="10dp"
             android:textColor="@color/text_hine" />
 
         <TextView
@@ -74,6 +74,7 @@
         android:clickable="true"
         android:gravity="center"
         android:src="@drawable/signin_btn" />
+
     <View
         android:layout_width="2px"
         android:layout_height="match_parent"
@@ -81,7 +82,8 @@
         android:layout_below="@+id/top"
         android:layout_centerHorizontal="true"
         android:background="@color/item_line" />
-    <ListView
+
+    <android.support.v7.widget.RecyclerView
         android:id="@+id/listview"
         android:layout_width="match_parent"
         android:layout_height="match_parent"