Created
December 23, 2014 03:32
-
-
Save kangear/c995798c1e780e2bed8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrintJob { | |
/** total job pages */ | |
static long mTotalPageNum; | |
/** finally Done job pages */ | |
static long mDonePages; | |
/** Current page number */ | |
static long mCurrentPageNum; | |
/** job start time */ | |
static long mStartTime; | |
/** job end time*/ | |
static long mEndTime; | |
/** current page progress */ | |
static int mCurrentProgress; | |
/** total progress */ | |
static int mProgress; | |
/** job state 1.ready 2.doing 3.suspend 4.stop 5.done*/ | |
static int mJobState; | |
/** job id */ | |
static int mJobId; | |
static final int JOB_STATE_READY = 1; | |
static final int JOB_STATE_DOING = 2; | |
static final int JOB_STATE_SUSPEND = 3; | |
static final int JOB_STATE_STOP = 4; | |
static final int JOB_STATE_DONE = 5; | |
PrintJob(long totalPageNum) throws Exception { | |
if(totalPageNum != 1) { | |
throw new Exception(""); | |
} | |
mTotalPageNum = totalPageNum; | |
mDonePages = 0; | |
mCurrentPageNum = 0; | |
mStartTime = System.currentTimeMillis(); | |
mEndTime = 0; | |
mCurrentProgress = 0; | |
mProgress = 0; | |
mJobState = 1; | |
} | |
/** | |
* the TotalPageNum is only 1; | |
*/ | |
PrintJob() { | |
mTotalPageNum = 1; | |
mDonePages = 0; | |
mCurrentPageNum = 0; | |
mStartTime = System.currentTimeMillis(); | |
mEndTime = 0; | |
mCurrentProgress = 0; | |
mProgress = 0; | |
updateJobState(JOB_STATE_READY); | |
} | |
void updateProgress(int currentProgress) { | |
mCurrentProgress = currentProgress; | |
mProgress += currentProgress / mTotalPageNum; | |
} | |
void updateJobState(int jobState) { | |
mJobState = jobState; | |
} | |
void doPrintJob() { | |
updateJobState(JOB_STATE_DOING); | |
doPrintOnePage(1); | |
updateJobState(JOB_STATE_DONE); | |
} | |
public static void doPrintOnePage(long currentPageNum) { | |
if(currentPageNum < 0) | |
return; | |
String pageCmd = "-dFirstPage="+currentPageNum + " -dLastPage=" + currentPageNum; | |
System.out.println(pageCmd); | |
} | |
public static void main(String[] args) { | |
doPrintOnePage(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment