File tree Expand file tree Collapse file tree 4 files changed +52
-28
lines changed
xupdate-lib/src/main/java/com/xuexiang/xupdate Expand file tree Collapse file tree 4 files changed +52
-28
lines changed Original file line number Diff line number Diff line change @@ -63,13 +63,15 @@ public UpdateEntity parseJson(String json) {
6363 /**
6464 * 进行本地版本判断[防止服务端出错,本来是不需要更新,但是服务端返回是需要更新]
6565 *
66- * @param checkResult
67- * @return
66+ * @param checkResult 版本更新检查返回的结果
67+ * @return 版本更新结果
6868 */
69- private CheckVersionResult doLocalCompare (CheckVersionResult checkResult ) {
70- if (checkResult .getUpdateStatus () != CheckVersionResult .NO_NEW_VERSION ) { //服务端返回需要更新
69+ protected CheckVersionResult doLocalCompare (CheckVersionResult checkResult ) {
70+ //服务端返回需要更新
71+ if (checkResult .getUpdateStatus () != CheckVersionResult .NO_NEW_VERSION ) {
7172 int lastVersionCode = checkResult .getVersionCode ();
72- if (lastVersionCode <= UpdateUtils .getVersionCode (XUpdate .getContext ())) { //最新版本小于等于现在的版本,不需要更新
73+ //最新版本小于等于现在的版本,不需要更新
74+ if (lastVersionCode <= UpdateUtils .getVersionCode (XUpdate .getContext ())) {
7375 checkResult .setRequireUpgrade (CheckVersionResult .NO_NEW_VERSION );
7476 }
7577 }
Original file line number Diff line number Diff line change @@ -329,19 +329,27 @@ private void installApp() {
329329 @ Override
330330 public void handleStart () {
331331 if (isShowing ()) {
332- mNumberProgressBar .setVisibility (View .VISIBLE );
333- mBtnUpdate .setVisibility (View .GONE );
334- if (mPromptEntity .isSupportBackgroundUpdate ()) {
335- mBtnBackgroundUpdate .setVisibility (View .VISIBLE );
336- } else {
337- mBtnBackgroundUpdate .setVisibility (View .GONE );
338- }
332+ doStart ();
333+ }
334+ }
335+
336+ private void doStart () {
337+ mNumberProgressBar .setVisibility (View .VISIBLE );
338+ mNumberProgressBar .setProgress (0 );
339+ mBtnUpdate .setVisibility (View .GONE );
340+ if (mPromptEntity .isSupportBackgroundUpdate ()) {
341+ mBtnBackgroundUpdate .setVisibility (View .VISIBLE );
342+ } else {
343+ mBtnBackgroundUpdate .setVisibility (View .GONE );
339344 }
340345 }
341346
342347 @ Override
343348 public void handleProgress (float progress ) {
344349 if (isShowing ()) {
350+ if (mNumberProgressBar .getVisibility () == View .GONE ) {
351+ doStart ();
352+ }
345353 mNumberProgressBar .setProgress (Math .round (progress * 100 ));
346354 mNumberProgressBar .setMax (100 );
347355 }
Original file line number Diff line number Diff line change @@ -358,20 +358,27 @@ private void installApp() {
358358 @ Override
359359 public void handleStart () {
360360 if (!isFinishing ()) {
361- mNumberProgressBar .setVisibility (View .VISIBLE );
362- mNumberProgressBar .setProgress (0 );
363- mBtnUpdate .setVisibility (View .GONE );
364- if (getPromptEntity ().isSupportBackgroundUpdate ()) {
365- mBtnBackgroundUpdate .setVisibility (View .VISIBLE );
366- } else {
367- mBtnBackgroundUpdate .setVisibility (View .GONE );
368- }
361+ doStart ();
362+ }
363+ }
364+
365+ private void doStart () {
366+ mNumberProgressBar .setVisibility (View .VISIBLE );
367+ mNumberProgressBar .setProgress (0 );
368+ mBtnUpdate .setVisibility (View .GONE );
369+ if (mPromptEntity .isSupportBackgroundUpdate ()) {
370+ mBtnBackgroundUpdate .setVisibility (View .VISIBLE );
371+ } else {
372+ mBtnBackgroundUpdate .setVisibility (View .GONE );
369373 }
370374 }
371375
372376 @ Override
373377 public void handleProgress (float progress ) {
374378 if (!isFinishing ()) {
379+ if (mNumberProgressBar .getVisibility () == View .GONE ) {
380+ doStart ();
381+ }
375382 mNumberProgressBar .setProgress (Math .round (progress * 100 ));
376383 mNumberProgressBar .setMax (100 );
377384 }
Original file line number Diff line number Diff line change @@ -401,20 +401,27 @@ private void installApp() {
401401 @ Override
402402 public void handleStart () {
403403 if (!UpdateDialogFragment .this .isRemoving ()) {
404- mNumberProgressBar .setVisibility (View .VISIBLE );
405- mNumberProgressBar .setProgress (0 );
406- mBtnUpdate .setVisibility (View .GONE );
407- if (getPromptEntity ().isSupportBackgroundUpdate ()) {
408- mBtnBackgroundUpdate .setVisibility (View .VISIBLE );
409- } else {
410- mBtnBackgroundUpdate .setVisibility (View .GONE );
411- }
404+ doStart ();
405+ }
406+ }
407+
408+ private void doStart () {
409+ mNumberProgressBar .setVisibility (View .VISIBLE );
410+ mNumberProgressBar .setProgress (0 );
411+ mBtnUpdate .setVisibility (View .GONE );
412+ if (mPromptEntity .isSupportBackgroundUpdate ()) {
413+ mBtnBackgroundUpdate .setVisibility (View .VISIBLE );
414+ } else {
415+ mBtnBackgroundUpdate .setVisibility (View .GONE );
412416 }
413417 }
414418
415419 @ Override
416420 public void handleProgress (float progress ) {
417421 if (!UpdateDialogFragment .this .isRemoving ()) {
422+ if (mNumberProgressBar .getVisibility () == View .GONE ) {
423+ doStart ();
424+ }
418425 mNumberProgressBar .setProgress (Math .round (progress * 100 ));
419426 mNumberProgressBar .setMax (100 );
420427 }
You can’t perform that action at this time.
0 commit comments