简体   繁体   English

为什么 Google 弃用 ProgressDialog class?

[英]Why did Google deprecate ProgressDialog class?

While browsing to find an alternative to PrgressDialog class I found this article and the writer mentioned this:在浏览寻找 PrgressDialog class 的替代品时,我发现了这篇文章,作者提到了这一点:

As we know Progress Dialog is depreciated in API level 26正如我们所知,进度对话框在 API 级别 26 中折旧

because It prevents the user to interact with the app.因为它会阻止用户与应用程序交互。 Let me explain to you why this is bad.让我向你解释为什么这是不好的。 As we show the Progress Dialog It runs and blocks the UI and user can't interact with the App.正如我们展示的进度对话框,它运行并阻止 UI,用户无法与应用程序交互。 Until our request is successful or fails basically we get the response of the request whatever we started.在我们的请求成功或失败之前,基本上无论我们开始什么,我们都会得到请求的响应。

Like Example suppose we are fetching some list of data in Navigation drawer home and started showing the Progress Dialog and as you know It will block the UI and User can't do anything.像示例一样,假设我们正在导航抽屉主页中获取一些数据列表并开始显示进度对话框,如您所知,它将阻止 UI,用户无法执行任何操作。 Ever user can't open navigation drawer and choose something else etc things.任何用户都无法打开导航抽屉并选择其他内容等。 App UI is blocked, no interaction.应用程序 UI 被阻止,没有交互。

Question 1, I want to ask you, Is it good to keep the user moving between the activities or fragments without blocking the UI even if the connection with the server still running (not finished yet)?问题1,我想问你,即使与服务器的连接仍在运行(尚未完成),让用户在活动或片段之间移动而不阻塞 UI 是否很好? I think that will cause a lot of problems我认为这会导致很多问题

Even when I replace ProgressDialog with the alternative, I still want to block the UI, So do you see any difference?即使当我用替代品替换 ProgressDialog 时,我仍然想阻止 UI,所以你看到有什么不同吗?

Maybe I did not understand the idea clearly.也许我没有清楚地理解这个想法。

Question 2, Could you tell me why Google deprecated ProgressDialog class?问题 2,您能告诉我为什么 Google 弃用 ProgressDialog class 吗?

from the docs it's clear that从文档中可以清楚地看出

ProgressDialog is a modal dialog, which prevents the user from interacting with the app. ProgressDialog 是一个模态对话框,可防止用户与应用程序交互。 Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI.您不应使用此 class,而应使用 ProgressBar 之类的进度指示器,它可以嵌入到应用程序的 UI 中。 Alternatively, you can use a notification to inform the user of the task's progress.或者,您可以使用通知来通知用户任务的进度。

https://developer.android.com/reference/android/app/ProgressDialog.html https://developer.android.com/reference/android/app/ProgressDialog.html

What I believe It makes your activity partially visible thus lifecycle method onPause will be called.我相信它使您的活动部分可见,因此生命周期方法 onPause 将被调用。

As Lifecycle aware component (live data, view model) are being developed and pushed by google/android.由于生命周期感知组件(实时数据、视图模型)正在由 google/android 开发和推动。 So, It makes sense they want to deprecate it and push ProgressBar as a option that is embedded or part of the same UI.因此,他们想要弃用它并将 ProgressBar 作为嵌入的选项或同一 UI 的一部分是有道理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM