1 /* 2 * Copyright (C) 2016 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.googlecode.android_scripting.facade.ui; 18 19 import android.app.ProgressDialog; 20 21 /** 22 * Wrapper class for progress dialog running in separate thread 23 * 24 * @author MeanEYE.rcf (meaneye.rcf (at) gmail.com) 25 */ 26 class ProgressDialogTask extends DialogTask { 27 28 private final int mStyle; 29 private final int mMax; 30 private final String mTitle; 31 private final String mMessage; 32 private final Boolean mCancelable; 33 34 public ProgressDialogTask(int style, int max, String title, String message, boolean cancelable) { 35 mStyle = style; 36 mMax = max; 37 mTitle = title; 38 mMessage = message; 39 mCancelable = cancelable; 40 } 41 42 @Override 43 public void onCreate() { 44 super.onCreate(); 45 mDialog = new ProgressDialog(getActivity()); 46 ((ProgressDialog) mDialog).setProgressStyle(mStyle); 47 ((ProgressDialog) mDialog).setMax(mMax); 48 mDialog.setCancelable(mCancelable); 49 mDialog.setTitle(mTitle); 50 ((ProgressDialog) mDialog).setMessage(mMessage); 51 mDialog.show(); 52 mShowLatch.countDown(); 53 } 54 } 55