Back to project page TaskFramework.
The source code is released under:
Apache License
If you think the Android project TaskFramework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright 2014 zhenguo (jingle1267@163.com) */*from w w w. java 2 s . com*/ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.worthed.framework; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; /** * ???? ?????????????????flag????????single????????sync?????????service???????readCache???????writeCache?? * Created by jingle1267@163.com on 14-9-28. */ public class Task implements Parcelable { public static final Creator<Task> CREATOR = new Creator<Task>() { @Override public Task createFromParcel(Parcel parcel) { return new Task(parcel); } @Override public Task[] newArray(int i) { return new Task[i]; } }; /** * ??????? */ protected String flag; /** * ??????????,???,????????????????????????? ????????? */ protected boolean single = false; /** * ???????????? */ protected boolean sync = true; /** * ???????????????? */ protected boolean service = false; /** * ???????????????? */ protected boolean readCache = false; /** * ?????????????? */ protected boolean saveCache = false; public Task(String flag) { this.flag = flag; } public Task(Parcel source) { this.flag = source.readString(); this.single = source.readInt() == 0 ? false : true; this.sync = source.readInt() == 0 ? false : true; this.service = source.readInt() == 0 ? false : true; this.readCache = source.readInt() == 0 ? false : true; this.saveCache = source.readInt() == 0 ? false : true; } @Override public void writeToParcel(Parcel dest, int i) { dest.writeString(this.flag); dest.writeInt(this.single ? 1 : 0); dest.writeInt(this.sync ? 1 : 0); dest.writeInt(this.service ? 1 : 0); dest.writeInt(this.readCache ? 1 : 0); dest.writeInt(this.saveCache ? 1 : 0); } @Override public int describeContents() { return 0; } @Override public boolean equals(Object o) { if (o instanceof Task) { Task task = (Task) o; if (!TextUtils.isEmpty(task.flag) && !TextUtils.isEmpty(flag) && task.flag.equals(flag)) { return true; } if (TextUtils.isEmpty(task.flag) && TextUtils.isEmpty(flag)) { return true; } else { return false; } } else { return false; } } @Override public int hashCode() { return (TextUtils.isEmpty(this.flag) ? "" : this.flag).hashCode(); } public boolean isSingle() { return single; } public void setSingle(boolean single) { this.single = single; } public boolean isSync() { return sync; } public void setSync(boolean sync) { this.sync = sync; } public boolean isService() { return service; } public void setService(boolean service) { this.service = service; } public boolean isReadCache() { return readCache; } public void setReadCache(boolean readCache) { this.readCache = readCache; } public boolean isSaveCache() { return saveCache; } public void setSaveCache(boolean saveCache) { this.saveCache = saveCache; } public String getFlag() { return flag; } /** * Task??? */ public static class Builder{ private Task task; public Builder(String flag) { task = new Task(flag); } /** * ?????????? * @param isSync * @return */ public Builder setSync(boolean isSync) { task.setSync(isSync); return this; } /** * ???????????? * @param isSingle * @return */ public Builder setSingle(boolean isSingle) { task.setSingle(isSingle); return this; } /** * ?????????????? * @param isService * @return */ public Builder setService(boolean isService) { task.setService(isService); return this; } /** * ????????? * @param isReadCache * @return */ public Builder setReadCache(boolean isReadCache) { task.setReadCache(isReadCache); return this; } /** * ??????????? * @param isSaveCache * @return */ public Builder setSaveCache(boolean isSaveCache) { task.setSaveCache(isSaveCache); return this; } /** * ??Task * @return */ public Task create() { return task; } } }