`

enum用法

 
阅读更多

public class timeofdayManager {
        private TimeDefine mTimeDefine;
    private Context mContext;
    public static enum timeofday{DAY,EVENING,NIGHT};


    public timeofdayManager (Context context){
        mTimeDefine = new TimeDefine();
        mContext = context;
    }
    private class TimeDefine{
        private Time mTime;
        private final int SLOT_1 = 6;
        private final int SLOT_2 = 16;
        private final int SLOT_3 = 17;
        private final int SLOT_4 = 19;
       
        public TimeDefine(){
            mTime = new Time();
        }
       
        public timeofday queryTime(){
            mTime.setToNow();
            if (mTime.hour<=SLOT_2 && mTime.hour>=SLOT_1){
                return timeofday.DAY;
            }
            else if (mTime.hour>=SLOT_3 && mTime.hour<=SLOT_4){
                return timeofday.EVENING;
            }
            return timeofday.NIGHT;
        }
    }
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics