Skip to content

Instantly share code, notes, and snippets.

@kangear
Created December 23, 2014 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kangear/c995798c1e780e2bed8d to your computer and use it in GitHub Desktop.
Save kangear/c995798c1e780e2bed8d to your computer and use it in GitHub Desktop.
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