Java Android:ProgressDialog循环未显示
我尝试在应用程序中实现一个加载循环,因为它从上一个活动转换到这个活动。由于此活动中有大量计算,它在进行计算时会变成黑屏长达10到15秒,一旦计算完成,它将显示一个图像,如onCreate:Java Android:ProgressDialog循环未显示,java,android,Java,Android,我尝试在应用程序中实现一个加载循环,因为它从上一个活动转换到这个活动。由于此活动中有大量计算,它在进行计算时会变成黑屏长达10到15秒,一旦计算完成,它将显示一个图像,如onCreate:resultImage.setImageBitmap(finalBitmap)中所示 然而,圆圈并没有出现,它仍然是旧的黑屏到图像的过渡 导入: progressDialog = new ProgressDialog(this); progressDialog.setTitle(null);
resultImage.setImageBitmap(finalBitmap)中所示代码>
然而,圆圈并没有出现,它仍然是旧的黑屏到图像的过渡
导入:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
导入android.app.ProgressDialog代码>
声明:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
private ProgressDialog代码>
已初始化:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
使其可见:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
progressDialog.show()代码>
随着代码的进展更改了其消息:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
progressDialog.setMessage(“查找对象…”)代码>
progressDialog.setMessage(“计算面积…”)代码>
progressDialog.setMessage(“计算高度…”)代码>
。。。等等
onCreate:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
@覆盖
创建时的公共void(Bundle savedInstanceState){
progressDialog=新建progressDialog(此);
progressDialog.setTitle(空);
progressDialog.setCancelable(假);
progressDialog.setMessage(“处理…”);
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u auto\u test);
如果(!OpenCVLoader.initDebug()){
Log.d(“opencv”、“OpenCVLoader.initDebug()-ERROR”);
}否则{
Log.d(“opencv”、“OpenCVLoader.initDebug()-OK”);
}
字符串filePath=getIntent().getStringExtra(文件路径);
ArrayList f=新的ArrayList();
文件目录=新文件(文件路径);
文件[]列表文件;
listFile=dir.listFiles();
用于(文件e:listFile){
f、 添加(例如getAbsolutePath());
}
路径=f;
重置变量();
progressDialog.setMessage(“查找对象…”);
对于(int xx=0;xx0){
progressDialog.setMessage(“计算面积…”);
平均黑区=黑区/环路计数器;
Log.e(“平均黑色面积”、“平均黑色面积的30%”加上串值of(平均黑色面积*0.3)+“平均黑色面积的110%”加上串值of(平均黑色面积*1.1));
Log.e(“Loopcounter”,String.valueOf(Loopcounter));
}
重置变量();
Log.e(“~”,“~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
Log.e(“最低绿色”,String.valueOf(绿色区域));
Log.e(“~”,“~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
progressDialog.setMessage(“计算高度…”);
int frameNumber=0;
对于(int x=0;x
代码文件链接:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
@Override
public void onCreate(Bundle savedInstanceState) {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(null);
progressDialog.setCancelable(false);
progressDialog.setMessage("Processing...");
progressDialog.show();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_test);
if (!OpenCVLoader.initDebug()) {
Log.d("opencv", "OpenCVLoader.initDebug() - ERROR");
} else {
Log.d("opencv", "OpenCVLoader.initDebug() - OK");
}
String filePath = getIntent().getStringExtra(FILEPATH);
ArrayList<String> f = new ArrayList<String>();
File dir = new File(filePath);
File[] listFile;
listFile = dir.listFiles();
for (File e : listFile) {
f.add(e.getAbsolutePath());
}
paths = f;
resetVariables();
progressDialog.setMessage("Finding Objects...");
for (int xx = 0; xx < paths.size(); xx++) {
Bitmap areaBitmap = BitmapFactory.decodeFile(paths.get(xx));
getArea(areaBitmap);
}
if (loopCounter > 0) {
progressDialog.setMessage("Calculating Areas...");
meanBlackArea = blackArea / loopCounter;
Log.e("meanBlackArea", "30% of mean black " + String.valueOf(meanBlackArea * 0.3) + " 110% of mean black " + String.valueOf(meanBlackArea * 1.1));
Log.e("Loopcounter", String.valueOf(loopCounter));
}
resetVariables();
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Log.e("Lowest Green", String.valueOf(greenArea));
Log.e("~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
progressDialog.setMessage("Calculating Height...");
int frameNumber = 0;
for (int x = 0; x < paths.size(); x++) {
Bitmap calculationsBitmap = BitmapFactory.decodeFile(paths.get(x));
numRectBlack = 0;
numRectGreen = 0;
tempBitmap = findCombineBitmap(calculationsBitmap);
if (check == true) {
if (Double.isInfinite(tempLineHeightCm) == false) {
frameNumber = x;
finalBitmap = tempBitmap;
}
}
}
progressDialog.setMessage("Tidying Up...");
TextView tvR = (TextView) findViewById(R.id.tvR);
if(tempLineHeightCm==0) {
tvR.setText("We could not detect a bounce!\nPlease do the following and try again:\n1. Remove all foreign objects from testing grounds.\n2.Make sure that there are ample lighting on the testing grounds.");
}else{
tvR.setText("Frame " + frameNumber + ", Bounce Height = " + tempLineHeightCm + "cm");
ImageView resultImage = (ImageView) findViewById(R.id.resultImage);
resultImage.setImageBitmap(finalBitmap);
progressDialog.dismiss();
}
}
注:
MainActivity.java有一个工作循环
java是我正在研究的一个
显示ProgressDialog
,启动新的AsyncTask
并在后台执行繁重的计算。AsyncTask
完成后,隐藏进度对话框并转到下一个活动
如果您不知道如何使用AsyncTask
,请检查参考文件显示进度对话框
,启动新的AsyncTask
,并在后台执行繁重的计算。AsyncTask
完成后,隐藏进度对话框并转到下一个活动
如果您不知道如何使用AsyncTask
,请查看参考资料