Не могли бы вы помочь понять, как оптимизировать время загрузки?
Следующий код используется для добавления представления на главном экране. запустить-
Код: Выделить всё
private void loadWidgets(WidgetInfo info, FrameLayout
frameLayoutContainer, AppWidgetHostView view) {
if (info.getAppWidgetInfo() != null) {
frameLayoutContainer.removeAllViews();
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
view.setPadding(WIDGET_PADDING, WIDGET_PADDING, WIDGET_PADDING, WIDGET_PADDING);
frameLayoutContainer.addView(view);
frameLayoutContainer.invalidate();
} else {
frameLayoutContainer.removeAllViews();
frameLayoutContainer.invalidate();
frameLayoutContainer.setBackgroundColor(Color.TRANSPARENT);
}
}
private void bindWidget(WidgetInfo info) {
if (info.getAppWidgetInfo() == null || info.getAppWidgetInfo().provider == null) {
return;
}
try {
AppWidgetManager widgetManager = AppWidgetManager
.getInstance(requireContext().getApplicationContext());
boolean bindWidgetStatus = widgetManager
.bindAppWidgetIdIfAllowed(info.getWidgetId(), info.getAppWidgetInfo().provider);
} catch (Exception e) {
Log.e(TAG, "bindWidget Unexpected error: " + e.getMessage());
e.printStackTrace();
}
}
Как мы можем ускорить широковещательную рассылку?
Подробнее здесь: https://stackoverflow.com/questions/793 ... on-boot-up