قطعه

برنامه خود را به چندین صفحه مستقل که در یک Activity میزبانی می شوند، تقسیم کنید.
آخرین به روز رسانی انتشار پایدار نامزد انتشار نسخه بتا انتشار آلفا
24 جولای 2024 1.8.2 - - -

اعلام وابستگی ها

برای افزودن وابستگی به Fragment، باید مخزن Google Maven را به پروژه خود اضافه کنید. برای اطلاعات بیشتر ، مخزن Maven Google را بخوانید.

وابستگی‌های مصنوعات مورد نیاز خود را در فایل build.gradle برای برنامه یا ماژول خود اضافه کنید:

شیار

dependencies {
    def fragment_version = "1.8.2"

    // Java language implementation
    implementation "androidx.fragment:fragment:$fragment_version"
    // Kotlin
    implementation "androidx.fragment:fragment-ktx:$fragment_version"
    // Compose
    implementation "androidx.fragment:fragment-compose:$fragment_version"
    // Testing Fragments in Isolation
    debugImplementation "androidx.fragment:fragment-testing-manifest:$fragment_version"
    androidTestImplementation "androidx.fragment:fragment-testing:$fragment_version"
}

کاتلین

dependencies {
    val fragment_version = "1.8.2"

    // Java language implementation
    implementation("androidx.fragment:fragment:$fragment_version")
    // Kotlin
    implementation("androidx.fragment:fragment-ktx:$fragment_version")
    // Compose
    implementation("androidx.fragment:fragment-compose:$fragment_version")
    // Testing Fragments in Isolation
    debugImplementation("androidx.fragment:fragment-testing:$fragment_version")
}

برای اطلاعات بیشتر درباره وابستگی‌ها، به افزودن وابستگی‌های ساخت نگاه کنید.

بازخورد

بازخورد شما به بهتر شدن Jetpack کمک می کند. اگر مسائل جدیدی کشف کردید یا ایده هایی برای بهبود این کتابخانه دارید، به ما اطلاع دهید. لطفاً قبل از ایجاد کتابخانه جدید، به مسائل موجود در این کتابخانه نگاهی بیندازید. با کلیک کردن روی دکمه ستاره می توانید رای خود را به یک موضوع موجود اضافه کنید.

یک شماره جدید ایجاد کنید

برای اطلاعات بیشتر به مستندات ردیاب مشکل مراجعه کنید.

نسخه 1.8

نسخه 1.8.2

24 جولای 2024

androidx.fragment:fragment-*:1.8.2 منتشر شد. نسخه 1.8.2 حاوی این commit ها است.

رفع اشکال

  • AndroidFragment اکنون به‌درستی مواردی را که قطعه والد در پشته Fragment قرار می‌گیرد، کنترل می‌کند، و از مشکلات «هیچ نمایی برای شناسه» در هنگام بازگشت به آن قطعه اجتناب می‌کند. ( I94608 )
  • قطعات اضافه شده از طریق روش FragmentTransaction.add که یک ViewGroup را می گیرد، اکنون قبل از رفتن به onStart() منتظر onContainerAvailable می شود. این روی کاربران آن API تأثیر می‌گذارد، مانند AndroidFragment ، که اکنون منتظر می‌ماند تا AndroidFragment دوباره وارد ترکیب شود و سپس آن را از طریق onStart() منتقل کند. ( I94608 )

نسخه 1.8.1

26 ژوئن 2024

androidx.fragment:fragment-*:1.8.1 منتشر شد. نسخه 1.8.1 شامل این commit ها است.

رفع اشکال

  • مشکلی را برطرف کرد که در آن قطعات بدون کانتینر بلافاصله هنگام شروع یک حرکت پیش‌بینی کننده برگشت DESTROYED شدند. اکنون آنها تا زمانی که ژست کامل شود در حالت CREATED نگه داشته می شوند. ( If6b83 , b/345244539 )

نسخه 1.8.0

12 ژوئن 2024

androidx.fragment:fragment-*:1.8.0 منتشر شد. نسخه 1.8.0 شامل این commit ها است.

تغییرات مهم از 1.7.0

  • آرتیفکت fragment-compose اکنون حاوی AndroidFragment Composable است که اجازه می‌دهد قطعات را از طریق نام کلاس قطعه به سلسله مراتب Compose اضافه کنید. به طور خودکار ذخیره و بازیابی وضعیت قطعه را انجام می دهد. این باید به عنوان جایگزینی مستقیم برای رویکرد توصیه شده قبلی استفاده از AndroidViewBinding برای افزایش یک Fragment استفاده شود.
  • پاسخ به تماس onBackStackChangeCancelled در رابط OnBackStackChangedListener FragmentManager اکنون به عنوان بخشی از اجرای عملیات در FragmentManager فعال می‌شود و آن را مطابق با زمان‌بندی پاسخ به تماس onBackStackChangeCommitted نزدیک‌تر می‌کند.

نسخه 1.8.0-rc01

29 مه 2024

androidx.fragment:fragment-*:1.8.0-rc01 منتشر شد. نسخه 1.8.0-rc01 حاوی این commit ها است.

رفع اشکال

  • پاسخ به تماس onBackStackChangeCancelled در رابط FragmentManagers OnBackStackChangedListener اکنون به عنوان بخشی از اجرای عملیات در FragmentManager فعال می‌شود و آن را مطابق با زمان‌بندی پاسخ به تماس onBackStackChangeCommitted نزدیک‌تر می‌کند. ( I5ebfb , b/332916112 )

نسخه 1.8.0-beta01

14 مه 2024

androidx.fragment:fragment-*:1.8.0-beta01 منتشر شد. نسخه 1.8.0-beta01 حاوی این تعهدات است.

رفع اشکال

  • از Fragment 1.7.1 : Predictive Back اکنون فقط برای تراکنش‌هایی اجرا می‌شود که در آن همه قطعات دارای Animator یا Seekable Androidx Transition هستند. این مشکلی را برطرف می کند که در آن لغو یک تراکنش تا حدی قابل جستجو می تواند باعث سیاه شدن صفحه شود. ( I43037 , b/339169168 )

نسخه 1.8.0-alpha02

17 آوریل 2024

androidx.fragment:fragment-*:1.8.0-alpha02 منتشر شد. نسخه 1.8.0-alpha02 حاوی این تعهدات است.

رفع اشکال

  • From Fragment 1.7.0-rc02 : گزارش هایی اضافه شد تا نشان دهد چرا تنظیم یک sharedElement بدون هیچ گونه انتقال دیگری اجرا نمی شود. ( Iec48e )
  • از Fragment 1.7.0-rc02 : اشکالی را برطرف کرد که در آن اگر یک عنصر مشترک غیرقابل جستجو به تراکنش‌هایی اضافه شود که در آن همه انتقال‌های دیگر قابل جستجو هستند، خرابی رخ می‌دهد. اکنون معامله به درستی غیرقابل جستجو در نظر گرفته می شود. ( I18ccd )

نسخه 1.8.0-alpha01

3 آوریل 2024

androidx.fragment:fragment-*:1.8.0-alpha01 منتشر شد. نسخه 1.8.0-alpha01 حاوی این تعهدات است.

ویژگی های جدید

  • AndroidFragment Composable جدید اجازه می دهد تا قطعات را از طریق نام کلاس قطعه به سلسله مراتب Compose اضافه کنید. به طور خودکار ذخیره و بازیابی وضعیت قطعه را انجام می دهد. این می تواند به عنوان یک جایگزین مستقیم برای AndroidViewBinding Composable استفاده شود. ( b/312895363 , Icf841 )

تغییرات اسناد و مدارک

  • اسناد به روز شده برای OnBackStackChangedListener APIها برای نشان دادن زمان فراخوانی و نحوه استفاده از آنها. ( I0bfd9 )

به روز رسانی وابستگی

نسخه 1.7

نسخه 1.7.1

14 مه 2024

androidx.fragment:fragment-*:1.7.1 منتشر شد. نسخه 1.7.1 حاوی این commit ها است.

رفع اشکال

  • پیش‌بینی‌کننده اکنون فقط برای تراکنش‌هایی اجرا می‌شود که در آن‌ها همه قطعات دارای Animator یا Seekable Androidx Transition هستند. این مشکلی را برطرف می کند که در آن لغو یک تراکنش تا حدی قابل جستجو باعث ایجاد صفحه خالی می شود. ( I43037 , b/339169168 )

نسخه 1.7.0

1 مه 2024

androidx.fragment:fragment-*:1.7.0 منتشر شد. نسخه 1.7.0 شامل این commit ها است.

پشتیبانی پیش بینی کننده ژست برگشتی

  • Fragments اکنون هنگام استفاده از Animator یا هنگام استفاده از AndroidX Transition 1.5.0 از Predictive درون برنامه پشتیبانی می کند. این به کاربران اجازه می دهد تا قبل از تصمیم به انجام تراکنش از طریق تکمیل ژست یا لغو، با جستجوی Animator/Transition از ژست برگشت برای دیدن قطعه قبلی استفاده کنند.
سیستم انتقال منبع XML پشتیبان پیشگویانه
Animation R.anim خیر
Animator R.animator آره
Transition چارچوب R.transition خیر
AndroidX Transition با Transition 1.4.1 یا کمتر R.transition خیر
AndroidX Transition با Transition 1.5.0 R.transition آره

اگر بعد از انتخاب ژست پیش‌بینی کننده پیش‌بینی در Fragments، مشکلی در پشتیبانی Predictive Back در Fragments مشاهده کردید، لطفاً با یک پروژه نمونه که مشکل شما را بازتولید می‌کند ، مشکلی را علیه Fragment ثبت کنید . می‌توانید با استفاده از FragmentManager.enabledPredictiveBack(false) در onCreate() فعالیت خود، پیش‌بینی‌کننده را غیرفعال کنید.

FragmentManager.OnBackStackChangedListener() اکنون به ترتیب onBackStackChangeProgressed() و onBackStackChangeCancelled() را برای دریافت پیشرفت پیش‌بینی‌کننده برگشت و رویدادهای لغو شده ارائه می‌کند.

آرتیفکت قطعه سازی

یک مصنوع fragment-compose جدید ایجاد شده است که بر روی پشتیبانی از برنامه‌هایی تمرکز دارد که در حال حرکت از معماری مبتنی بر قطعه به معماری کاملاً مبتنی بر Compose هستند.

اولین ویژگی موجود در این مصنوع جدید، یک روش پسوند content در Fragment است که با ایجاد یک ComposeView برای شما و تنظیم ViewCompositionStrategy صحیح، به دنبال آسان‌تر کردن استفاده از Compose برای رابط کاربری یک Fragment است.

  class ExampleFragment : Fragment() {

      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ) = content {
          // Write your @Composable content here
          val viewModel: ExampleViewModel = viewModel()

          // or extract it into a separate, testable method
          ExampleComposable(viewModel)
      }
  }

نسخه 1.7.0-rc02

17 آوریل 2024

androidx.fragment:fragment-*:1.7.0-rc02 منتشر شد. نسخه 1.7.0-rc02 حاوی این commit ها است.

رفع اشکال

  • گزارش‌هایی اضافه شد تا نشان دهد چرا تنظیم یک sharedElement بدون هیچ گونه انتقال دیگری اجرا نمی‌شود. ( Iec48e )
  • رفع اشکالی که در آن اگر یک عنصر مشترک غیرقابل جستجو به تراکنش‌هایی اضافه شود که در آن همه انتقال‌های دیگر قابل جستجو هستند، خرابی رخ می‌دهد. اکنون معامله به درستی غیرقابل جستجو در نظر گرفته می شود. ( I18ccd )

نسخه 1.7.0-rc01

3 آوریل 2024

androidx.fragment:fragment-*:1.7.0-rc01 منتشر شد. نسخه 1.7.0-rc01 حاوی این commit ها است.

به روز رسانی وابستگی

نسخه 1.7.0-beta01

20 مارس 2024

androidx.fragment:fragment-*:1.7.0-beta01 منتشر شد. نسخه 1.7.0-beta01 حاوی این تعهدات است.

تغییرات API

  • FragmentHostCallback اکنون در Kotlin نوشته شده است به طوری که پوچ پذیری نوع عمومی Host با پوچ بودن نوع برگشتی onGetHost() مطابقت دارد. ( I40af5 )

رفع اشکال

  • مشکلی را برطرف کرد که در آن هنگام انجام یک حرکت پیشگویانه بازگشت بر روی قطعه ای که در یک کانتینر نیست، آن قطعه هرگز از بین نمی رفت. Fragment اکنون بلافاصله به حالت نهایی منتقل می شود. ( Ida0d9 )
  • مشکلی در Fragments رفع شد که در آن قطع کردن انتقال‌های ورودی با یک حرکت پیش‌گویانه، نمای ورودی را از بین می‌برد و یک صفحه خالی باقی می‌ماند. ( ID3f22 , b/319531491 )

نسخه 1.7.0-alpha10

7 فوریه 2024

androidx.fragment:fragment-*:1.7.0-alpha10 منتشر شد. نسخه 1.7.0-alpha10 حاوی این commit ها است.

رفع اشکال

  • مشکل شناخته شده در نسخه قبلی Fragment برطرف شد که در آن با استفاده از پشتیبانی Fragment's Predictive Back برای Animator یا AndroidX Transition، اگر هیچ FragmentManager.OnBackStackChangedListener از طریق addOnBackStackChangedListener اضافه نشده باشد، Fragments یک NullPointerException از handleOnBackProgressed پرتاب می کند. ( I7c835 )

نسخه 1.7.0-alpha09

24 ژانویه 2024

androidx.fragment:fragment-*:1.7.0-alpha09 منتشر شد. نسخه 1.7.0-alpha09 حاوی این commit ها است.

آرتیفکت قطعه سازی

یک مصنوع fragment-compose جدید ایجاد شده است که بر روی پشتیبانی از برنامه‌هایی تمرکز دارد که در حال حرکت از معماری مبتنی بر قطعه به معماری کاملاً مبتنی بر Compose هستند.

اولین ویژگی موجود در این مصنوع جدید، یک روش پسوند content در Fragment است که با ایجاد یک ComposeView برای شما و تنظیم ViewCompositionStrategy صحیح، به دنبال آسان‌تر کردن استفاده از Compose برای رابط کاربری یک Fragment است. ( 561cb7 , b/258046948 )

class ExampleFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ) = content {
        // Write your @Composable content here
        val viewModel: ExampleViewModel = viewModel()

        // or extract it into a separate, testable method
        ExampleComposable(viewModel)
    }
}

ویژگی های جدید

  • FragmentManager.OnBackStackChangedListener() اکنون به ترتیب onBackStackChangeProgressed() و onBackStackChangeCancelled() را برای دریافت پیشرفت پیش‌بینی‌کننده برگشت و رویدادهای لغو شده ارائه می‌کند. ( 214b87 )

مشکل شناخته شده

  • هنگام استفاده از پشتیبانی Fragment's Predictive Back برای Animator یا AndroidX Transition، اگر هیچ FragmentManager.OnBackStackChangedListener از طریق addOnBackStackChangedListener اضافه نشده باشد، Fragments یک NullPointerException را از handleOnBackProgressed پرتاب می کند. افزودن دستی شنونده، خرابی را برطرف خواهد کرد. در نسخه بعدی Fragments یک راه حل برای این موضوع در دسترس خواهد بود.

نسخه 1.7.0-alpha08

10 ژانویه 2024

androidx.fragment:fragment-*:1.7.0-alpha08 منتشر شد. نسخه 1.7.0-alpha08 حاوی این commit ها است.

پاک کردن

نسخه 1.7.0-alpha07

29 نوامبر 2023

androidx.fragment:fragment-*:1.7.0-alpha07 منتشر شد. نسخه 1.7.0-alpha07 حاوی این commit ها است.

رفع اشکال

  • رفع NullPointerException ناشی از تنظیم یک انتقال عنصر مشترک و عدم تنظیم یک enter/exitTransition نیز. ( I8472b )
  • از Fragment 1.6.2 : هنگامی که Fragment یک FragmentContainerView باد می‌شود، حالات آن مانند FragmentManager ، Host و id اکنون در پاسخ به تماس onInflate قابل دسترسی هستند. ( I1e44c , b/307427423 )
  • از Fragment 1.6.2 : وقتی از clearBackStack برای حذف مجموعه‌ای از قطعات استفاده می‌کنید، اکنون ViewModel هر قطعه تودرتو با پاک شدن ViewModels های قطعه والد پاک می‌شود. ( I6d83c , b/296173018 )

نسخه 1.7.0-alpha06

4 اکتبر 2023

androidx.fragment:fragment-*:1.7.0-alpha06 منتشر شد. نسخه 1.7.0-alpha06 حاوی این commit ها است.

به روز رسانی وابستگی

  • قطعات به‌روزرسانی شده‌اند تا به API جدید animateToStart که در Transition 1.5.0-alpha04 اضافه شده است وابسته باشند.

نسخه 1.7.0-alpha05

20 سپتامبر 2023

androidx.fragment:fragment-*:1.7.0-alpha05 منتشر شد. نسخه 1.7.0-alpha05 حاوی این commit ها است.

ویژگی های جدید

  • Fragments اکنون هنگام استفاده از Androidx Transitions از Predictive Back پشتیبانی می کند. این به شما امکان می دهد قبل از تصمیم به انجام یا لغو تراکنش از طریق ژست کامل شده، از ژست برگشتی برای جستجوی قطعه قبلی با Androidx Transition سفارشی خود استفاده کنید. برای فعال کردن این ویژگی باید به نسخه Transition 1.5.0-alpha03 وابسته باشید. ( Ib49b4 , b/285175724 )

مشکلات شناخته شده

  • در حال حاضر مشکلی وجود دارد که در آن پس از اینکه یک ژست برگشتی را با یک انتقال یک بار لغو کردید، دفعه بعد که ژست برگشتی را شروع کردید، تغییر را اجرا نمی کند و باعث ایجاد صفحه خالی می شود. این ممکن است به دلیل مشکلی در کتابخانه Transition باشد. ( b/300157785 ). اگر این مشکل را مشاهده کردید، لطفاً با پروژه نمونه‌ای که مشکل شما را بازتولید می‌کند ، مشکلی را علیه Fragment ثبت کنید . می‌توانید با استفاده از FragmentManager.enabledPredictiveBack(false) در onCreate() فعالیت خود، پیش‌بینی‌کننده را غیرفعال کنید.

نسخه 1.7.0-alpha04

6 سپتامبر 2023

androidx.fragment:fragment-*:1.7.0-alpha04 منتشر شد. نسخه 1.7.0-alpha04 حاوی این commit ها است.

رفع اشکال

  • مشکلی هنگام لغو یک حرکت پیش‌بینی کننده برگشت که در آن قطعات نتوانستند به حالت چرخه زندگی صحیح برسند، برطرف شد. ( I7cffe , b/297379023 )
  • رگرسیون‌هایی که در آن انیمیشن‌ها اجازه داشتند با Transitions اجرا شوند، رفع شد. ( I59f36 )
  • مشکلی در هنگام استفاده از Predictive Back با قطعاتی که تلاش برای دو بار بازگشت سریع پشت سر هم در دومین تا آخرین قطعه در پشته پشته باعث خرابی می‌شد، برطرف شد. ( Ifa1a4 )

نسخه 1.7.0-alpha03

23 آگوست 2023

androidx.fragment:fragment-*:1.7.0-alpha03 منتشر شد. نسخه 1.7.0-alpha03 حاوی این commit ها است.

رفع اشکال

  • مشکل Fragments در هنگام استفاده از پیش‌بینی بازگشت که باعث می‌شد اولین قطعه در پشته پشتی مدیر فرگمنت نادیده گرفته شود و هنگام استفاده از سیستم بازگشت از طریق پیمایش 3 دکمه یا حرکت پیش‌بینی کننده بازگشت، فعالیت تمام شود، برطرف شد. ( I0664b , b/295231788 )

نسخه 1.7.0-alpha02

9 آگوست 2023

androidx.fragment:fragment-*:1.7.0-alpha02 منتشر شد. نسخه 1.7.0-alpha02 حاوی این commit ها است.

رفع اشکال

  • هنگام استفاده از قطعات با اشاره‌های پیش‌بینی‌کننده برگشت از API 34، اگر از سیستم انتقالی استفاده می‌کنید که از جستجو ( Animations ، Transitions ) پشتیبانی نمی‌کند یا اصلاً هیچ انتقالی وجود ندارد، بخش‌ها اکنون منتظر می‌مانند تا ژست کامل شود و قبل از اجرای اکشن برگشتی. ( I8100c )

نسخه 1.7.0-alpha01

7 ژوئن 2023

androidx.fragment:fragment-*:1.7.0-alpha01 منتشر شد. این نسخه در یک شعبه داخلی توسعه یافته است.

ویژگی های جدید

  • بخش‌ها اکنون هنگام استفاده از Animator از Predictive درون برنامه پشتیبانی می‌کنند. این به شما امکان می دهد قبل از تصمیم به انجام تراکنش از طریق ژست تکمیل شده یا لغو، از ژست برگشت برای دیدن قطعه قبلی با Animator سفارشی خود استفاده کنید. همچنین می‌توانید این رفتار جدید را با استفاده از enablePredictiveBack() آزمایشی و با دادن عبارت false غیرفعال کنید.

نسخه 1.6

نسخه 1.6.2

1 نوامبر 2023

androidx.fragment:fragment-*:1.6.2 منتشر شد. نسخه 1.6.2 حاوی این commit ها است.

رفع اشکال

  • وقتی Fragment یک FragmentContainerView باد می‌شود، حالات آن مانند FragmentManager ، Host و id اکنون در پاسخ به تماس onInflate قابل دسترسی هستند. ( I1e44c , b/307427423 )
  • هنگامی که clearBackStack برای حذف مجموعه‌ای از قطعات استفاده می‌کنید، پس از پاک شدن ViewModels های قطعه والد، ViewModel هر قطعه تو در تو پاک می‌شود. ( I6d83c , b/296173018 )

نسخه 1.6.1

26 جولای 2023

androidx.fragment:fragment-*:1.6.1 منتشر شد. نسخه 1.6.1 حاوی این commit ها است.

رفع اشکال

  • مشکلی را برطرف کرد که در آن وضعیت ذخیره شده ذخیره شده در زمان توقف فعالیت اما از بین نرفت، حتی پس از اینکه نمونه قطعه به حالت RESUMED بازگردانده شد، به اشتباه در حافظه پنهان ذخیره می شد. این باعث می‌شود که در صورت استفاده از API پشته‌های چندگانه برای ذخیره و بازیابی آن قطعه، از حالت ذخیره‌شده مجدداً استفاده شود. ( I71288 , b/246289075 )

به روز رسانی وابستگی

  • بخش اکنون به فعالیت 1.7.2 بستگی دارد. این مشکلی را برطرف می کند که در آن کاربران Kotlin نمی توانند ComponentDialog بدون وابستگی صریح به Activity گسترش دهند. ( b/287509323 )

نسخه 1.6.0

7 ژوئن 2023

androidx.fragment:fragment-*:1.6.0 منتشر شد. نسخه 1.6.0 حاوی این commit ها است.

تغییرات مهم از 1.5.0

  • حالت ذخیره شده Fragment s به طور کامل بین حالت کتابخانه خصوصی (کلاس های Parcelable سفارشی) و حالت ارائه شده توسط توسعه دهنده تقسیم شده است، که اکنون همیشه در یک Bundle ذخیره می شود که امکان تعیین دقیق محل مبدا وضعیت یک قطعه را فراهم می کند.
  • رابط FragmentManager.OnBackStackChangedListener با دو فراخوان اضافی onBackStackChangeStarted و onBackStackChangeCommitted گسترش یافته است که به ترتیب با هر Fragment درست قبل از افزودن/حذف از پشته قطعه و بلافاصله پس از انجام تراکنش فراخوانی می شوند.
  • FragmentStrictMode یک WrongNestedHierarchyViolation جدید اضافه کرد که تشخیص می‌دهد چه زمانی یک قطعه فرزند در سلسله‌مراتب View والدینش تودرتو شده است، اما به childFragmentManager والدین اضافه نمی‌شود.
  • API های Fragment و FragmentManager که یک Intent یا IntentSender می گیرند، اکنون به درستی با @NonNull حاشیه نویسی می شوند تا از ارسال یک مقدار تهی جلوگیری شود، زیرا یک مقدار تهی همیشه فوراً APIهای فریمورک اندروید مربوطه را که این روش ها به آن ها تماس می گیرند، خراب می کند.
  • اکنون DialogFragment دسترسی به ComponentDialog زیرین را از طریق API requireComponentDialog() فراهم می‌کند.
  • Fragment اکنون به Lifecycle 2.6.1 بستگی دارد.
  • بخش اکنون به SavedState 1.2.1 بستگی دارد.
  • Fragment اکنون به ProfileInstaller 1.3.0 بستگی دارد.
  • آرتیفکت fragment-testing-manifest ورودی های مانیفست را از بقیه اجزای تست قطعه جدا می کند. این بدان معنی است که شما می توانید کارهای زیر را انجام دهید:

    debugImplementation("androidx.fragment:fragment-testing-manifest:X.Y.Z")
    androidTestImplementation("androidx.fragment:fragment-testing:X.Y.Z")
    

    این کار از تداخل ناشی از تغییر نسخه بین fragment-testing و androidx.test جلوگیری می کند

نسخه 1.6.0-rc01

10 مه 2023

androidx.fragment:fragment-*:1.6.0-rc01 منتشر شد. نسخه 1.6.0-rc01 حاوی این commit ها است.

رفع اشکال

  • مشکلی که باعث می‌شود ActivityResult با کد درخواست نادرست ارسال شود، هنگامی که چندین درخواست startActivityForResult به طور متوالی انجام شده است، رفع شد. ( If0b9d , b/249519359 )
  • مشکلی را برطرف کرد که در آن تماس‌های برگشتی onBackStackChangeListener برای تراکنش‌هایی ارسال می‌شد که اگر با تراکنش‌هایی که تغییر می‌کردند، عملاً پشته را تغییر نمی‌دادند. ( I0eb5c , b/279306628 )

نسخه 1.6.0-beta01

19 آوریل 2023

androidx.fragment:fragment-*:1.6.0-beta01 منتشر شد. نسخه 1.6.0-beta01 حاوی این تعهدات است.

رفع اشکال

  • استفاده از postponeEnterTransition با بازه زمانی و سپس جایگزینی قطعه به تعویق افتاده دیگر منجر به نشت قطعه به تعویق افتاده نمی شود. ( I2ec7d , b/276375110 )
  • فراخوان‌های جدید onBackStackChangeStarted و onBackStackChangeCommitted اکنون فقط یک قطعه را یک بار ارسال می‌کنند، حتی اگر چندین تراکنش حاوی یک قطعه باشد. ( IC6b69 )

نسخه 1.6.0-alpha09

5 آوریل 2023

androidx.fragment:fragment-*:1.6.0-alpha09 منتشر شد. نسخه 1.6.0-alpha09 حاوی این commit ها است.

تغییرات API

  • اکنون DialogFragment دسترسی به ComponentDialog زیرین را از طریق API requireComponentDialog() فراهم می‌کند. ( I022e3 , b/234274777 )
  • API های commitNow() ، executePendingTransactions() و popBackStackImmediate() با @MainThread حاشیه نویسی شده اند، به این معنی که اکنون به جای اینکه منتظر شکست در زمان اجرا بمانند، وقتی از رشته اصلی فراخوانی نمی شوند، خطاهای ساخت ایجاد می کنند. ( Ic9665 , b/236538905 )

رفع اشکال

  • یک اشکال در FragmentManager که ذخیره و بازیابی در همان فریم می‌تواند باعث خرابی شود، رفع شد. ( Ib36af , b/246519668 )
  • فراخوان‌های OnBackStackChangedListener onBackStackChangeStarted و onBackStackChangeCommitted اکنون فقط زمانی اجرا می‌شوند که پشته برگشتی FragmentManager تغییر کند. ( I66055 , b/274788957 )

نسخه 1.6.0-alpha08

22 مارس 2023

androidx.fragment:fragment-*:1.6.0-alpha08 منتشر شد. نسخه 1.6.0-alpha08 حاوی این commit ها است.

تغییر رفتار

  • زمان پاسخ به تماس OnBackStackChangedListener.onBackStackChangeCommited برای اجرا قبل از اجرای عملیات قطعه تنظیم شده است. این تضمین می‌کند که هیچ‌وقت به یک قطعه که جدا شده است، فراخوان ارسال نمی‌شود. ( I66a76 , b/273568280 )

رفع اشکال

  • از Fragment 1.5.6 : مشکلی را برطرف کرد که در آن فراخوانی clearFragmentResultListener در یک setFragmentResultListener کار نمی‌کند، اگر Lifecycle از قبل STARTED بود و یک نتیجه از قبل در دسترس بود. ( If7458 )

به روز رسانی های وابستگی

نسخه 1.6.0-alpha07

8 مارس 2023

androidx.fragment:fragment-*:1.6.0-alpha07 منتشر شد. نسخه 1.6.0-alpha07 حاوی این commit ها است.

رفع اشکال

  • از Fragment 1.5.6 : مشکلی را برطرف کرد که در آن حذف هر بخش، چه موارد منو را اضافه کرده باشد یا نه، منوی فعالیت را باطل می‌کند. ( 50f098 , b/244336571 )

نسخه 1.6.0-alpha06

22 فوریه 2023

androidx.fragment:fragment-*:1.6.0-alpha06 منتشر شد. نسخه 1.6.0-alpha06 حاوی این commit ها است.

تغییر رفتار

  • پاسخ به تماس جدید onBackStackChangedStarted در onBackStackChangedListener FragmentManager اکنون قبل از اینکه قطعات شروع به حرکت به حالت های هدف خود کنند، اجرا می شود. ( I34726 )

نسخه 1.6.0-alpha05

8 فوریه 2023

androidx.fragment:fragment-*:1.6.0-alpha05 منتشر شد. نسخه 1.6.0-alpha05 حاوی این commit ها است.

ویژگی های جدید

  • رابط FragmentManager.OnBackStackChagnedListener اکنون دو فراخوان اضافی را ارائه می دهد، onBackStackChangeStarted و onBackStackChangeCommitted ، که به اطلاعات بیشتر و کنترل زمانی که تغییرات پشته پشته در FragmentManager رخ می دهد اجازه می دهد. ( Ib7ce5 , b/238686802 )

تغییرات API

  • APIهای Fragment و FragmentManager که یک Intent یا IntentSender می گیرند، اکنون به درستی با @NonNull حاشیه نویسی می شوند تا از ارسال یک مقدار تهی جلوگیری شود، زیرا یک مقدار تهی همیشه فوراً APIهای چارچوب Android مربوطه را خراب می کند. ( I06fd4 )

نسخه 1.6.0-alpha04

7 دسامبر 2022

androidx.fragment:fragment-*:1.6.0-alpha04 منتشر شد. نسخه 1.6.0-alpha04 حاوی این commit ها است.

ویژگی های جدید

  • FragmentStrictMode یک WrongNestedHierarchyViolation جدید اضافه کرد که تشخیص می‌دهد چه زمانی یک قطعه فرزند در سلسله‌مراتب View والدینش تودرتو شده است، اما به childFragmentManager والدین اضافه نمی‌شود. ( I72521 , b/249299268 )

تغییرات رفتار

  • Fragments اکنون وضعیت SavedStateRegistry خود را قبل از onAttach() بازیابی می‌کند و اطمینان حاصل می‌کند که از همه روش‌های چرخه حیات رو به بالا در دسترس است. ( I1e2b1 )

تغییرات API

  • آرتیفکت fragment-testing-manifest ورودی های مانیفست را از بقیه اجزای تست قطعه جدا می کند. این بدان معنی است که شما می توانید کارهای زیر را انجام دهید:
debugImplementation("androidx.fragment:fragment-testing-manifest:X.Y.Z")
androidTestImplementation("androidx.fragment:fragment-testing:X.Y.Z")

این کار از تداخل ناشی از کج بودن نسخه بین fragment-testing و androidx.test جلوگیری می کند. ( I8e534 ، b/128612536 )

رفع اشکال

  • از Fragment 1.5.5 : بخش‌ها دیگر حالت ViewModel را به‌عنوان بخشی از وضعیت ذخیره‌شده در رجیستری مشاهده نمی‌کنند. ( I10d2b , b/253546214 )

نسخه 1.6.0-alpha03

5 اکتبر 2022

androidx.fragment:fragment:1.6.0-alpha03 ، androidx.fragment:fragment-ktx:1.6.0-alpha03 و androidx.fragment:fragment-testing:1.6.0-alpha03 منتشر شدند. نسخه 1.6.0-alpha03 حاوی این commit ها است.

تغییرات API

  • کلاس‌هایی که DialogFragment گسترش می‌دهند، اکنون ملزم به فراخوانی super در override‌های onDismiss() هستند. ( I14798 , b/238928865 )

رفع اشکال

  • رگرسیون های ثابت ناشی از ادغام واسط های پاسخگوی تماس ارائه دهنده جدید ( OnConfigurationChangedProvider ، OnMultiWindowModeChangedProvider ، OnTrimMemoryProvider ، OnPictureInPictureModeChangedProvider ) برای اطمینان از اینکه قطعات همیشه تماس های مناسب را دریافت می کنند. ( I9b380 , I34581 , ( I8dfe6 , b/242570955 ), If9d6b , Id0096 , I690b3 , I2cba2 )

نسخه 1.6.0-alpha02

24 آگوست 2022

androidx.fragment:fragment:1.6.0-alpha02 ، androidx.fragment:fragment-ktx:1.6.0-alpha02 و androidx.fragment:fragment-testing:1.6.0-alpha02 منتشر شدند. نسخه 1.6.0-alpha02 حاوی این commit ها است.

رفع اشکال

  • از Fragment 1.5.2 : مشکلی را برطرف کرد که در آن اجرای همزمان popBackStack() و یک تراکنش replace() می‌تواند باعث شود که قطعات خروجی Animation / Animator اشتباه را اجرا کنند. ( Ib1c07 , b/214835303 )

نسخه 1.6.0-alpha01

27 جولای 2022

androidx.fragment:fragment:1.6.0-alpha01 ، androidx.fragment:fragment-ktx:1.6.0-alpha01 و androidx.fragment:fragment-testing:1.6.0-alpha01 منتشر شدند. نسخه 1.6.0-alpha01 حاوی این commit ها است.

تغییرات رفتار

  • حالت ذخیره شده Fragment s به طور کامل بین حالت کتابخانه خصوصی (کلاس های Parcelable سفارشی) و حالت ارائه شده توسط توسعه دهنده تقسیم شده است، که اکنون همیشه در یک Bundle ذخیره می شود که امکان تعیین دقیق محل مبدا وضعیت یک قطعه را فراهم می کند. ( b/207158202 )

رفع اشکال

  • از Fragment 1.5.1 : یک رگرسیون را در DialogFragmentCallbacksDetector برطرف کنید که در آن استفاده از نسخه لینت همراه با AGP 7.4 باعث از کار افتادن پرز می شود. ( b/237567009 )

به روز رسانی وابستگی

نسخه 1.5

نسخه 1.5.7

19 آوریل 2023

androidx.fragment:fragment:1.5.7 ، androidx.fragment:fragment-ktx:1.5.7 و androidx.fragment:fragment-testing:1.5.7 منتشر شده‌اند. نسخه 1.5.7 حاوی این commit ها است.

رفع اشکال

  • استفاده از postponeEnterTransition با بازه زمانی و سپس جایگزینی قطعه به تعویق افتاده دیگر منجر به نشت قطعه به تعویق افتاده نمی شود. ( I2ec7d , b/276375110 )

نسخه 1.5.6

22 مارس 2023

androidx.fragment:fragment:1.5.6 ، androidx.fragment:fragment-ktx:1.5.6 و androidx.fragment:fragment-testing:1.5.6 منتشر شده‌اند. نسخه 1.5.6 حاوی این commit ها است.

رفع اشکال

  • مشکلی را برطرف کرد که در آن حذف هر بخش، چه موارد منو اضافه کرده باشد یا نه، منوی فعالیت را باطل می‌کند. ( 50f098 , b/244336571 )
  • مشکلی که در آن فراخوانی clearFragmentResultListener در یک setFragmentResultListener کار نمی‌کند، اگر Lifecycle از قبل STARTED بود و یک نتیجه از قبل در دسترس بود، برطرف شد. ( If7458 )

نسخه 1.5.5

7 دسامبر 2022

androidx.fragment:fragment:1.5.5 ، androidx.fragment:fragment-ktx:1.5.5 و androidx.fragment:fragment-testing:1.5.5 منتشر شدند. نسخه 1.5.5 حاوی این commit ها است.

رفع اشکال

  • قطعات دیگر حالت ViewModel را به‌عنوان بخشی از وضعیت ذخیره‌شده در رجیستری مشاهده نمی‌کنند. ( I10d2b , b/253546214 )

نسخه 1.5.4

24 اکتبر 2022

androidx.fragment:fragment:1.5.4 ، androidx.fragment:fragment-ktx:1.5.4 و androidx.fragment:fragment-testing:1.5.4 منتشر شدند. نسخه 1.5.4 حاوی این commit ها است.

رفع اشکال

  • خطای استفاده از FragmentController سفارشی با میزبانی که واسط پاسخ تماس ارائه‌دهنده را پیاده‌سازی نمی‌کند ( OnConfigurationChangedProvider ، OnMultiWindowModeChangedProvider ، OnTrimMemoryProvider ، OnPictureInPictureModeChangedProvider ) و فراخوانی قطعه قطعه قطعه‌سازی برای deprecat کردن dispatch، رفع شد. ( I9b380 )

نسخه 1.5.3

21 سپتامبر 2022

androidx.fragment:fragment:1.5.3 ، androidx.fragment:fragment-ktx:1.5.3 و androidx.fragment:fragment-testing:1.5.3 منتشر شده‌اند. نسخه 1.5.3 حاوی این commit ها است.

رفع اشکال

  • خطایی را برطرف کرد که باعث می‌شد فرگمنت‌ها در پشته پشتی تماس‌های onMultiWindowModeChanged() ، onPictureInPictureModeChanged() ، onLowMemory() و onConfigurationChanged() را دریافت کنند. ( I34581 , I8dfe6 , b/242570955 )
  • قطعات فرزند تودرتو دیگر چندین تماس onMultiWindowModeChanged() ، onPictureInPictureModeChanged() ، onLowMemory() یا onConfigurationChanged() دریافت نخواهند کرد. ( I690b3 , Id0096 , If9d6b , I2cba2 )

نسخه 1.5.2

10 آگوست 2022

androidx.fragment:fragment:1.5.2 ، androidx.fragment:fragment-ktx:1.5.2 و androidx.fragment:fragment-testing:1.5.2 منتشر شده‌اند. نسخه 1.5.2 حاوی این commit ها است.

رفع اشکال

  • مشکلی را برطرف کرد که در آن اجرای همزمان popBackStack() و یک تراکنش replace() می‌توانست باعث شود که فرگمنت‌های خروجی Animation / Animator اشتباه را اجرا کنند. ( Ib1c07 , b/214835303 )

نسخه 1.5.1

27 جولای 2022

androidx.fragment:fragment:1.5.1 ، androidx.fragment:fragment-ktx:1.5.1 و androidx.fragment:fragment-testing:1.5.1 منتشر شدند. نسخه 1.5.1 حاوی این commit ها است.

رفع اشکال

  • یک رگرسیون را در DialogFragmentCallbacksDetector برطرف کنید که در آن استفاده از نسخه lint همراه با AGP 7.4 باعث از کار افتادن پرزها می شود. ( b/237567009 )

به روز رسانی وابستگی

نسخه 1.5.0

29 ژوئن 2022

androidx.fragment:fragment:1.5.0 ، androidx.fragment:fragment-ktx:1.5.0 و androidx.fragment:fragment-testing:1.5.0 منتشر شدند. نسخه 1.5.0 حاوی این commit ها است.

تغییرات مهم از 1.4.0

  • CreationExtras Integration - Fragment اکنون توانایی ارائه ViewModelProvider.Factory بدون حالت را از طریق Lifecycle 2.5.0 's CreationExtras دارد.
  • Component Dialog Integration - DialogFragment اکنون از ComponentDialog از طریق Activity 1.5.0 به عنوان گفتگوی پیش فرض برگردانده شده توسط onCreateDialog() استفاده می کند.
  • Saved Instance State Refactoring - قطعات شروع به تغییر روش ذخیره حالت نمونه خود کرده اند. این تلاشی است برای کمک به شناسایی واضح وضعیت ذخیره شده در قطعه و منبع حالت. تغییرات فعلی شامل موارد زیر است:
    • FragmentManager اکنون حالت نمونه ذخیره شده خود را به جای مستقیماً در یک Parcelable سفارشی در یک Bundle ذخیره می کند.
    • نتایج تنظیم شده از طریق Fragment Result APIs که هنوز تحویل داده نشده اند، اکنون جدا از وضعیت داخلی FragmentManager ذخیره می شوند.
    • وضعیت مرتبط با هر قطعه جداگانه اکنون جدا از وضعیت داخلی FragmentManager ذخیره می شود، بنابراین به شما امکان می دهد مقدار حالت ذخیره شده مرتبط با یک قطعه جداگانه را با شناسه های منحصر به فرد موجود در گزارش اشکال زدایی Fragment مرتبط کنید.

سایر تغییرات

  • FragmentStrictMode اکنون این امکان را برای فرگمنت های شخص ثالث خصوصی برای دور زدن جریمه های نقض خاص با استفاده از allowViolation() با نام کلاس ارائه می دهد.
  • API های Fragment برای ارائه منو به ActionBar فعالیت شما منسوخ شده است. API های MenuHost و MenuProvider اضافه شده در Activity 1.4.0 یک سطح API معادل قابل آزمایش و آگاه از چرخه حیات را ارائه می دهند که قطعات باید از آن استفاده کنند.

نسخه 1.5.0-rc01

11 مه 2022

androidx.fragment:fragment:1.5.0-rc01 ، androidx.fragment:fragment-ktx:1.5.0-rc01 و androidx.fragment:fragment-testing:1.5.0-rc01 منتشر شدند. نسخه 1.5.0-rc01 حاوی این commit ها است.

Refactoring حالت نمونه ذخیره شده

  • حالت مرتبط با هر قطعه جداگانه اکنون جدا از وضعیت داخلی FragmentManager ذخیره می شود، بنابراین به شما امکان می دهد مقدار وضعیت ذخیره شده مرتبط با یک قطعه را با شناسه های منحصر به فرد موجود در گزارش اشکال زدایی Fragment مرتبط کنید. ( a153e0 , b/207158202 )

نسخه 1.5.0-beta01

20 آوریل 2022

androidx.fragment:fragment:1.5.0-beta01 ، androidx.fragment:fragment-ktx:1.5.0-beta01 و androidx.fragment:fragment-testing:1.5.0-beta01 منتشر شدند. نسخه 1.5.0-beta01 حاوی این تعهدات است.

تغییرات API

  • DialogFragment یک متد جدید dismissNow اضافه کرده است که از commitNow برای برابری با تابع showNow استفاده می کند. توجه داشته باشید که این باعث نمی‌شود که Dialog فوراً رد شود، بلکه فقط به‌صورت همزمان وضعیت FragmentManager را به‌روزرسانی می‌کند. ( I15c36 , b/72644830 )

Refactoring حالت نمونه ذخیره شده

  • FragmentManager اکنون حالت نمونه ذخیره شده خود را به جای مستقیماً در یک Parcelable سفارشی در یک Bundle ذخیره می کند. این اولین گام در ارائه شفافیت بیشتر در مورد آنچه واقعاً توسط Fragments ذخیره می شود است. ( I93807 , b/207158202 )
  • نتایج تنظیم شده از طریق Fragment Result APIهایی که هنوز تحویل داده نشده اند، اکنون جدا از وضعیت داخلی FragmentManager ذخیره می شوند. این به شفافیت بیشتر در مورد نتایجی که به عنوان بخشی از حالت نمونه ذخیره شده شما ذخیره می شود، اجازه می دهد. ( I6ea12 , b/207158202 )

نسخه 1.5.0-alpha05

6 آوریل 2022

androidx.fragment:fragment:1.5.0-alpha05 ، androidx.fragment:fragment-ktx:1.5.0-alpha05 و androidx.fragment:fragment-testing:1.5.0-alpha05 منتشر شدند. نسخه 1.5.0-alpha05 حاوی این commit ها است.

تغییرات API

نسخه 1.5.0-alpha04

23 مارس 2022

androidx.fragment:fragment:1.5.0-alpha04 ، androidx.fragment:fragment-ktx:1.5.0-alpha04 و androidx.fragment:fragment-testing:1.5.0-alpha04 منتشر شدند. نسخه 1.5.0-alpha04 حاوی این commit ها است.

تغییرات API

  • API های Fragment برای ارائه منو به ActionBar فعالیت شما منسوخ شده اند زیرا قطعه شما را محکم به فعالیت شما متصل می کنند و به صورت مجزا قابل آزمایش نیستند. API های MenuHost و MenuProvider اضافه شده در Activity 1.4.0-alpha01 یک سطح API معادل قابل آزمایش و آگاه از چرخه حیات را ارائه می دهند که قطعات باید از آن استفاده کنند. ( I50a59 , I20758 )

رفع اشکال

  • SavedStateViewFactory اکنون از استفاده از CreationExtras پشتیبانی می کند، حتی زمانی که با SavedStateRegistryOwner مقداردهی اولیه شده باشد. اگر موارد اضافی ارائه شود، آرگومان های اولیه نادیده گرفته می شوند. ( I6c43b , b/224844583 )

نسخه 1.5.0-alpha03

23 فوریه 2022

androidx.fragment:fragment:1.5.0-alpha03 ، androidx.fragment:fragment-ktx:1.5.0-alpha03 و androidx.fragment:fragment-testing:1.5.0-alpha03 منتشر شدند. نسخه 1.5.0-alpha03 حاوی این commit ها است.

تغییرات API

  • اکنون می توانید CreationExtras به توابع by viewModels() و by activityViewModels() ارسال کنید. ( Ibefe7 , b/217601110 )

تغییرات رفتار

  • اکنون DialogFragment از ComponentDialog به عنوان گفتگوی پیش‌فرض برگردانده شده توسط onCreateDialog() استفاده می‌کند. ( If3784 , b/217618170 )

نسخه 1.5.0-alpha02

9 فوریه 2022

androidx.fragment:fragment:1.5.0-alpha02 ، androidx.fragment:fragment-ktx:1.5.0-alpha02 و androidx.fragment:fragment-testing:1.5.0-alpha02 آزاد می شود. نسخه 1.5.0-alpha02 شامل این تعهدات است.

ویژگی های جدید

  • FragmentStrictMode اکنون توانایی قطعات شخص ثالث خصوصی را برای دور زدن مجازات های تخلف خاص با استفاده از allowViolation() با نام کلاس ارائه می دهد. ( i8f678 )

نسخه 1.5.0-alpha01

26 ژانویه 2022

androidx.fragment:fragment:1.5.0-alpha01 ، androidx.fragment:fragment-ktx:1.5.0-alpha01 و androidx.fragment:fragment-testing:1.5.0-alpha01 آزاد می شود. نسخه 1.5.0-alpha01 شامل این تعهدات است.

ویژگی های جدید

رفع اشکال

  • از قطعه 1.4.1 : FragmentContainerView دیگر یک استثناء حالت غیرقانونی را به وجود نمی آورد وقتی که شناسه های مشاهده شده از XML دارای مقادیر منفی هستند. ( IC185B ، B/213086140 )
  • از قطعه 1.4.1 : هنگام استفاده از یک Lambda Custom ownerProducer با عملکرد Lazy by viewModels() ، اکنون از defaultViewModelProviderFactory از آن مالک استفاده می کند اگر یک ViewModelProvider.Factory Custom Custom.fective به جای اینکه همیشه از کارخانه قطعه استفاده کند ارائه نمی شود. ( i56170 ، b/214106513 )
  • برای اولین بار از یک registerForActivityResult() پاسخ به تماس یک Fragment ، تصادف هنگام دسترسی به یک ViewModel را برطرف کرد. ( IEA2B3 )

نسخه 1.4

نسخه 1.4.1

26 ژانویه 2022

androidx.fragment:fragment:1.4.1 ، androidx.fragment:fragment-ktx:1.4.1 ، و androidx.fragment:fragment-testing:1.4.1 منتشر می شود. نسخه 1.4.1 شامل این تعهدات است.

رفع اشکال

  • FragmentContainerView دیگر هنگامی که شناسه های مشاهده شده از XML دارای مقادیر منفی هستند ، یک استثناء حالت غیرقانونی را به وجود نمی آورد. ( IC185B ، B/213086140 )
  • در هنگام استفاده از یک Lambda ownerProducer Custom با عملکرد Lazy by viewModels() ، اکنون از defaultViewModelProviderFactory از آن مالک استفاده می کند اگر یک ViewModelProvider.Factory به جای اینکه همیشه از کارخانه قطعه استفاده کند ، ارائه نمی شود. ( i56170 ، b/214106513 )

نسخه 1.4.0

17 نوامبر 2021

androidx.fragment:fragment:1.4.0 ، androidx.fragment:fragment-ktx:1.4.0 و androidx.fragment:fragment-testing:1.4.0 منتشر می شود. نسخه 1.4.0 شامل این تعهدات است.

تغییرات مهم از 1.3.0

  • API های FragmentStrictMode چک های زمان اجرا را ارائه می دهند که به شما امکان می دهد تأیید کنید که برنامه یا کتابخانه های شما به آنها وابسته است ، API های قطعه ای مستهلک نمی نامند. هنگامی که یک تخلف تشخیص داده شد ، می توانید یک پیام ورود به سیستم را چاپ کنید ، شنونده سفارشی خود را تحریک کنید یا برنامه خود را خراب کنید. FragmentStrictMode.Policy که کنترل می کند چه مواردی را فعال می کند و چه "مجازات ها" را می توان از طریق روش جدید setStrictModePolicy() بر روی یک FragmentManager کرد. این سیاست در مورد آن FragmentManager و از نظر انتقادی برای هر مدیران قطعه قطعه که سیاست منحصر به فرد خود را تعیین نمی کنند ، اعمال می شود. برای قطعات به StrictMode مراجعه کنید.
  • FragmentContainerView اکنون روشی getFragment() را ارائه می دهد که قطعه ای را که اخیراً به ظرف اضافه شده است ، باز می گرداند. این از همان منطق findFragmentById() با شناسه FragmentContainerView استفاده می کند ، اما اجازه می دهد تا تماس را زنجیر کنید.

    val navController = binding.container.getFragment<NavHostFragment>().navController
    
  • FragmentScenario اکنون Closeable است و به شما امکان می دهد از آن با روش use کوتلین یا امتحان کردن با منابع استفاده کنید.

  • اضافه شده FragmentTransaction#TRANSIT_FRAGMENT_MATCH_ACTIVITY_{OPEN, CLOSE} برای مشخص کردن اینکه آیا انیمیشن استاندارد انتقال فعالیت گرفته شده از موضوع شما در انتقال قطعات را فعال می کند.

  • API آزمایشی FragmentManager.enableNewStateManager(boolean) حذف شده است و مدیر دولت جدید اکنون تنها گزینه موجود است.

چند پشته پشت

The FragmentManager یک پشته پشتی را که از معاملات قطعه ای که از addToBackStack() حفظ می کند. این به شما امکان می دهد تا با استفاده از مکانیسم های صرفه جویی در حالت با قطعات ، آن معاملات را پاپ کرده و به حالت قبلی برگردانید تا قطعات خود بتوانند وضعیت خود را به درستی بازیابی کنند.

این نسخه با ارائه سه API های جدید FragmentManager : saveBackStack(String name) ، restoreBackStack(String name) و clearBackStack(String name) بر این مکانیسم ها گسترش می یابد. این API ها از همان name addToBackStack() استفاده می کنند تا وضعیت FragmentTransaction و وضعیت هر قطعه ای را که در آن معاملات اضافه شده است ، نجات دهد و به شما امکان می دهد بعداً آن معاملات و قطعات آنها را با وضعیت خود بازیابی کنید. این به شما امکان می دهد با صرفه جویی در پشته پشتی فعلی و بازیابی یک پشته پشتی ذخیره شده ، به طور موثر بین پشته های چند پشتی "مبادله" کنید.

saveBackStack() به طور مشابه با popBackStack() عمل می کند زیرا این امر ناهمزمان است و باعث می شود تمام معاملات قطعه ای به آن نام خاص برگردد تا معکوس شود ("ظاهر شده") و هر قطعه اضافه شده برای از بین بردن و حذف شدن ، اما در چند مورد متفاوت است روشهای مهم:

  • saveBackStack() همیشه فراگیر است.
  • بر خلاف popBackStack() که اگر نام مشخص شده در پشته پشتی پیدا نشده باشد یا اگر نام تهی پیدا نشده باشد ، تمام معاملات را در قسمت پشتی پاپ می کند ، اگر قبلاً مرتکب معامله قطعه قطعه نشده با استفاده از addToBackStack() saveBackStack() هیچ کاری نمی کند. addToBackStack() با آن نام دقیق و غیر تهی.
  • وضعیت تمام قطعات اضافه شده از آن معاملات ذخیره می شود. این بدان معنی است که وضعیت نمای هر قطعه ذخیره می شود ، onSaveInstanceState() از هر قطعه خوانده می شود و حالت ترمیم می شود ، و هر نمونه ViewModel مرتبط با آن قطعات حفظ می شود (و onCleared() به آنها فراخوانی نمی شود).

معاملات قطعه ای که می تواند با saveBackStack() استفاده شود باید معیارهای خاصی را رعایت کند:

  • هر معامله قطعه ای باید از setReorderingAllowed(true) استفاده کند تا اطمینان حاصل شود که معاملات به عنوان یک عملیات واحد و اتمی قابل ترمیم هستند.
  • مجموعه معاملات ذخیره شده باید به خود اختصاصی باشد (یعنی آنها نباید صریحاً به قطعات خارج از آن مجموعه معاملات مراجعه کنند) تا اطمینان حاصل شود که می توانند در هر زمان بعدی ترمیم شوند ، مهم نیست که چه تغییراتی در پشت پشته ایجاد شده است. در زمان مداخله
  • هیچ قطعه ای که ذخیره شود نمی تواند یک قطعه نگهدارنده باشد یا یک قطعه حفظ شده در مجموعه گذرا از قطعات کودک خود داشته باشد تا اطمینان حاصل شود که FragmentManager پس از ذخیره پشته پشت ، هیچ گونه اشاراتی را به قطعات ذخیره شده باز نمی گرداند.

مشابه saveBackStack() ، restoreBackStack() و clearBackStack() ، که می تواند یک پشته که قبلاً ذخیره شده را بازیابی می کند یا به ترتیب یک پشته پشتی ذخیره شده را پاک کرده است ، به ترتیب ، هر دو هیچ کاری انجام نمی دهند اگر قبلاً saveBackStack() با همان نام خوانده نشده باشید.

برای اطلاعات بیشتر ، به چندین پشته پشتی مراجعه کنید: شیرجه عمیق .

نسخه 1.4.0-RC01

3 نوامبر 2021

androidx.fragment:fragment:1.4.0-rc01 بدون تغییر از قطعه 1.4.0-beta01 منتشر شد. نسخه 1.4.0-RC01 شامل این تعهدات است.

نسخه 1.4.0-beta01

27 اکتبر 2021

androidx.fragment:fragment:1.4.0-beta01 ، androidx.fragment:fragment-ktx:1.4.0-beta01 ، و androidx.fragment:fragment-testing:1.4.0-beta01 منتشر می شود. نسخه 1.4.0-beta01 شامل این تعهدات است.

رفع اشکال

  • قطعات والدین اکنون قبل از شروع تماس با خود ، کل سلسله مراتب خود onHiddenChanged() در کل سلسله مراتب خود اعزام می کنند. ( IEDC20 ، B/77504618 )
  • صفحه کلید اکنون هنگام رفتن از یک قطعه با یک صفحه کلید باز به یک قطعه با نمای بازیافت ، به طور خودکار بسته می شود. ( i8b842 ، b/196852211 )
  • DialogFragment اکنون برای کلیه معاملات که هنگام تماس با شما show() ، showNow() یا dismiss() ایجاد می کند ، از setReorderingAllowed(true) استفاده می کند. ( IE2C14 )
  • هشدار بسیار طولانی در مورد DetachAndAttachFragmentInSameFragmentTransaction به DetachAndAttachSameFragment کوتاه شده است. ( e9eca3 )

نسخه 1.4.0-alpha10

29 سپتامبر 2021

androidx.fragment:fragment:1.4.0-alpha10 ، androidx.fragment:fragment-ktx:1.4.0-alpha10 و androidx.fragment:fragment-testing:1.4.0-alpha10 آزاد می شود. نسخه 1.4.0-alpha10 شامل این تعهدات است.

لینت

  • Added the DetachAndAttachFragmentInSameFragmentTransaction lint warning for detecting calling both detach() and attach() on the same Fragment in the same FragmentTransaction - as these complementary operations cancel each other out when done in the same transaction, they must be split into separate transactions to actually do هر چیزی. ( AOSP/1832956 ، b/200867930 )
  • خطای خط قطعه FragmentAddMenuProvider قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه addMenuProvider قطعه قطعه قطعه قطعه MenuHost قطعه قطعه قطعه قطعه قطعه قطعه اثر مشاهده کرد. ( AOSP/1830457 ، B/200326272 )

به روزرسانی مستندات

  • پیام استهلاک برای API که اکنون توسط API های نتیجه فعالیت ، یعنی startActivityForResult ، startIntentSenderForResult ، onActivityResult ، requestPermissions ، و onRequestPermissionsResult انجام شده است ، همه با جزئیات بیشتر گسترش یافته اند. ( CCE80F )
  • پیام استهلاک برای onActivityCreated() برای هر دو Fragment و DialogFragment با جزئیات بیشتر گسترش یافته است. ( 224DB4 )

نسخه 1.4.0-alpha09

15 سپتامبر 2021

androidx.fragment:fragment:1.4.0-alpha09 ، androidx.fragment:fragment-ktx:1.4.0-alpha09 و androidx.fragment:fragment-testing:1.4.0-alpha09 آزاد می شود. نسخه 1.4.0-alpha09 شامل این تعهدات است.

ویژگی های جدید

  • اکنون می توانید با clearBackStack(name) تماس بگیرید تا هر ایالت را که قبلاً با saveBackStack(name) ذخیره شده بود ، پاک کنید. ( i70cd7 )

تغییرات API

  • کلاس FragmentContainerView در Kotlin بازنویسی شده است و اطمینان می دهد که عملکرد getFragment به درستی به باطل احترام می گذارد. ( if694a ، b/189629145 )
  • FlatmentStrictMode اکنون در Kotlin ( I11767 ، b/199183506 ) نوشته شده است

رفع اشکال

  • مسئله ای را برطرف کرد که وضعیت قطعه ای که با setReorderingAllowed(true) اضافه شده است و سپس بلافاصله قبل از اجرای معاملات در انتظار حذف می شود ، به درستی پاک نمی شود. ( i8ccb8 )

نسخه 1.4.0-alpha08

1 سپتامبر 2021

androidx.fragment:fragment:1.4.0-alpha08 ، androidx.fragment:fragment-ktx:1.4.0-alpha08 و androidx.fragment:fragment-testing:1.4.0-alpha08 آزاد می شود. نسخه 1.4.0-alpha08 شامل این تعهدات است.

رفع اشکال

  • بررسی Lint UseRequireInsteadOfGet را بهبود بخشید تا بتواند پرانتز بهتر را انجام دهد. ( I2D865 )
  • برای رسیدگی به موارد لبه اضافی ، بررسی LINT UseGetLayoutInflater را بهبود بخشید. ( IE5423 )

نسخه 1.4.0-alpha07

18 آگوست 2021

androidx.fragment:fragment:1.4.0-alpha07 ، androidx.fragment:fragment-ktx:1.4.0-alpha07 و androidx.fragment:fragment-testing:1.4.0-alpha07 بدون تغییر قابل توجه آزاد می شوند. نسخه 1.4.0-alpha07 شامل این تعهدات است.

نسخه 1.4.0-alpha06

4 آگوست 2021

androidx.fragment:fragment:1.4.0-alpha06 ، androidx.fragment:fragment-ktx:1.4.0-alpha06 و androidx.fragment:fragment-testing:1.4.0-alpha06 آزاد می شود. نسخه 1.4.0-alpha06 شامل این تعهدات است.

رفع اشکال

  • مسئله ای را با پشته های پشتی چندگانه هنگامی که به سرعت در حال تعویض بین پشته های پشتی است که به عنوان IllegalStateException ضمن بازگرداندن یک FragmentTransaction یا به عنوان کپی دوم از یک قطعه ظاهر می شود. ( i9039f )
  • مسئله ای را برطرف کرد که FragmentManager حتی پس از ترمیم آن ایالت ، نسخه ای از ایالت را که قبلاً از طریق saveBackStack() ذخیره شده بود ، نگه داشته باشد. ( IED212 )
  • روش dismissAllowingStateLoss() روش DialogFragment دیگر وقتی پس از ذخیره حالت ، هنگام افزودن به طور خاص دیالوگ از طریق روش show(FragmentTransaction, String) دیگر خراب نمی شود. ( i84422 )

نسخه 1.4.0-alpha05

21 جولای 2021

androidx.fragment:fragment:1.4.0-alpha05 ، androidx.fragment:fragment-ktx:1.4.0-alpha05 و androidx.fragment:fragment-testing:1.4.0-alpha05 آزاد می شود. نسخه 1.4.0-alpha05 شامل این تعهدات است.

رفع اشکال

  • از قطعه 1.3.6 : نمای قطعه اکنون به درستی تنظیم شده است که هنگام استفاده از hide() هنگامی که نمای ریشه دارای مجموعه transitionGroup=”true” GONE . ( AOSP/1766655 ، B/193603427 )
  • از قطعه 1.3.6 : FragmentActivity اکنون همیشه حالت ذخیره شده را باز می کند زیرا اولین عملیات خود در تماس با چرخه عمر است که بر آن غلبه می کند. ( i6db7a )

به روزرسانی وابستگی

نسخه 1.4.0-alpha04

30 ژوئن 2021

androidx.fragment:fragment:1.4.0-alpha04 ، androidx.fragment:fragment-ktx:1.4.0-alpha04 و androidx.fragment:fragment-testing:1.4.0-alpha04 آزاد می شود. نسخه 1.4.0-alpha04 شامل این تعهدات است.

تغییرات API

  • FragmentManager اکنون برای نجات وضعیت خود از SavedStateRegistry در زیر کاپوت استفاده می کند. روشهای saveAllState() و restoreSavedState() نیز در FragmentController کاهش یافته است. اگر از FragmentController برای میزبانی قطعات خارج از FragmentActivity استفاده می کنید ، باید FragmentHostCallbacks خود را SavedStateRegistryOwner اجرا کنید. ( IBA68E ، B/188734238 )

رفع اشکال

  • مسئله ای را برطرف کرد که در آن فراخوان برای saveBackStack() به عنوان بخشی از پشتیبانی از پشته های پشتی چندگانه ، هنگامی که همزمان با اجرای یک FragmentTransaction که از replace() شکست می خورد. ( i73137 )
  • رفع یک NullPointerException که بعد از بازگرداندن دستی یک پشته ذخیره شده که حاوی معاملات متعدد در هنگام استفاده از API restoreBackStack() برای پشتیبانی از پشته های چندگانه است ، رخ می دهد. این مسئله همچنین مسئله ای را برطرف کرد که در آن setReorderingAllowed(true) برای همه معاملات بررسی نشده بود. ( i8c593 )
  • مسئله ای را برطرف کرد که FragmentManager به طور نادرست به بازگرداندن حالت قبلاً نجات یافته قطعات حتی پس از برداشتن این قطعات از FragmentManager ادامه می دهد ، بنابراین باعث می شود حالت نجات یافته به طور مداوم با گذشت زمان رشد کند. ( i1fb8e )

نسخه 1.4.0-alpha03

16 ژوئن 2021

androidx.fragment:fragment:1.4.0-alpha03 ، androidx.fragment:fragment-ktx:1.4.0-alpha03 و androidx.fragment:fragment-testing:1.4.0-alpha03 آزاد می شوند. نسخه 1.4.0-alpha03 شامل این تعهدات است.

ویژگی های جدید

  • تمام کلاسهای Violation قطعه قطعه قطعه قطعه شده با پیام های خطای دقیق تر که جزئیات این تخلف را توضیح می دهد ، به روز شده است. ( b/187871638 )
    • FragmentTagUsageViolation اکنون حاوی پیام خطای مفصلی تر است که ظرف ظرف والدین را که این قطعه به آن اضافه شده است ، کانتینر می کند. ( IC33A7 )
    • اکنون WrongFragmentContainerViolation اکنون پیام خطای مفصلی تری دارد که شامل ظرفی است که این قطعه به آن اضافه شده است. ( IB55F8 )
    • کلاسهای مورد استفاده برای TargetFragmentUsageViolation اکنون پیام های خطای مفصلی دارند که شامل قطعه ای است که باعث تخلف و هرگونه اطلاعات دیگر می شود. ( ICC6AC )
    • کلاسهای گسترش RetainInstanceUsageViolation اکنون پیام های خطای مفصلی دارند که شامل قطعه ای است که باعث تخلف می شود. ( i6bd55 )
    • FragmentReuseViolation اکنون دارای پیام خطای مفصلی تر است که شامل شناسه قبلی این قطعه است. ( i28ce2 )
    • SetUserVisibleHintViolation اکنون دارای پیام خطای مفصلی تر است که شامل آنچه که کاربر قابل مشاهده در آن تنظیم شده است ، شامل می شود. ( IB2D5F )

تغییرات رفتار

  • محدودیت فراخوانی fitsSystemWindows را در یک FragmentContainerView برگردانید - این دیگر برنامه شما را خراب نمی کند. ( 6B8DDD ، b/190622202 )

رفع اشکال

  • از قطعه 1.3.5 : رگرسیون در انتقال عناصر مشترک معرفی شده در قطعه 1.3.4 توسط AOSP/1679887 . قطعات اکنون به طور صحیح گروه های انتقال را اداره می کنند (یا مستقیماً از طریق transitionGroup="true" یا به طور غیرمستقیم از طریق یک transitionName یا background تنظیم شده) تنظیم می شوند و عناصر مشترک دیگر شاخص های IndexOutOfBoundsException پرتاب نمی کنند. ( I16484 ، b/188679569 ، b/188969304 )
  • هنگامی که سعی در پنهان کردن یک قطعه از بین بردن دارید ، دیگر FragmentManager خراب نمی شود. ( i573dd ، b/183634730 )
  • بررسی LINT OnCreateDialogIncorrectCallback هنگام ارزیابی یک متغیر سطح بالا دیگر خراب نمی شود. ( 0a9efa ، b/189967522 )

نسخه 1.4.0-alpha02

2 ژوئن 2021

androidx.fragment:fragment:1.4.0-alpha02 ، androidx.fragment:fragment-ktx:1.4.0-alpha02 و androidx.fragment:fragment-testing:1.4.0-alpha02 آزاد می شود. نسخه 1.4.0-alpha02 شامل این تعهدات است.

ویژگی های جدید

  • در صورت فعال شدن ورود به سیستم از طریق FragmentManager ، صرف نظر از خط مشی حالت دقیق فعلی که مورد استفاده قرار می گیرد ، همیشه نقض های مربوط به ورود به FragmentStrictMode را وارد می کنند. ( I02DF6 ، B/187872638 )
  • FragmentStrictMode اکنون از معافیت کلاس های Fragment خاص از Violation حالت سخت پشتیبانی می کند و به آن کلاس اجازه می دهد تا هرگونه مجازات را دور بزند. ( ib4e5d ، b/184786736 )

  • کلاس Violation FragmentStrictMode برای افزودن اطلاعات ساختار بر اساس هر تخلف گسترش یافته است. این به شما امکان می دهد دقیقاً آنچه را که باعث تخلف به همراه قطعه نقض شده شده است تأیید کنید ( IF5118 ، B/187871150 ) ، هر Violation شامل موارد زیر است:

    • اکنون WrongFragmentContainerViolation اکنون حاوی ViewGroup است که این Fragment در تلاش است تا به آن اضافه شود. ( i83c75 ، b/187871150 )
    • TargetFragmentUsageViolation به ، SetTargetFragmentUsageViolation ، GetTargetFragmentUsageViolation و GetTargetFragmentRequestCodeUsageViolation گسترش یافته است ، با SetTargetFragmentUsageViolation حاوی قطعه هدف و کد درخواست. ( i741b4 ، b/187871150 )
    • SetUserVisibleHintViolation اکنون حاوی مقدار بولی است که به setUserVisibleHint() منتقل شده است. ( i00585 ، b/187871150 )
    • FragmentTagUsageViolation اکنون حاوی گروه دیدگاه است که برچسب <fragment> در تلاش بود تا یک قطعه را به داخل ببخشد. ( i5dbbc ، b/187871150 )
    • FragmentReuseViolation اکنون حاوی شناسه منحصر به فرد نمونه قبلی Fragment است که باعث ایجاد ویروس شده است. ( i0544d ، b/187871150 )
    • RetainInstanceUsageViolation در حال حاضر انتزاعی است و دارای دو زیر کلاس ، SetRetainInstanceUsageViolation و GetRetainInstanceUsageViolation است که نمایانگر این دو مورد برای نوع تخلف است. ( IC81E5 ، B/187871150 )

تغییرات رفتار

  • FragmentContainerView اکنون هنگام تلاش برای تغییر ویژگی fitsSystemWindow به صورت برنامه ای یا از طریق XML ، استثنائی را به وجود می آورد. insets باید توسط دیدگاه هر قطعه جداگانه انجام شود. ( IE6651 ، b/187304502 )

نسخه 1.4.0-alpha01

18 مه 2021

androidx.fragment:fragment:1.4.0-alpha01 ، androidx.fragment:fragment-ktx:1.4.0-alpha01 و androidx.fragment:fragment-testing:1.4.0-alpha01 آزاد می شود. نسخه 1.4.0-alpha01 حاوی این commit ها است.

ویژگی های جدید

  • FragmentContainerView اکنون روشی getFragment() را ارائه می دهد که قطعه ای را که اخیراً به ظرف اضافه شده است ، باز می گرداند. این از همان منطق findFragmentById() با شناسه FragmentContainerView استفاده می کند ، اما اجازه می دهد تا تماس را زنجیر کنید. ( IFE17A ، B/162527857 )

    val navController = binding.container.getFragment<NavHostFragment>().navController
    
  • اضافه شده FragmentTransaction#TRANSIT_FRAGMENT_MATCH_ACTIVITY_{OPEN, CLOSE} برای مشخص کردن اینکه آیا انیمیشن استاندارد انتقال فعالیت گرفته شده از موضوع شما در انتقال قطعات را فعال می کند. ( i46652 )

چند پشته پشت

The FragmentManager یک پشته پشتی را که از معاملات قطعه ای که از addToBackStack() حفظ می کند. این به شما امکان می دهد تا با استفاده از مکانیسم های صرفه جویی در حالت با قطعات ، آن معاملات را پاپ کرده و به حالت قبلی برگردانید تا قطعات خود بتوانند وضعیت خود را به درستی بازیابی کنند.

این نسخه با ارائه دو API های جدید FragmentManager : saveBackStack(String name) و restoreBackStack(String name) بر این مکانیسم ها گسترش می یابد. این API ها از همان name addToBackStack() استفاده می کنند تا وضعیت FragmentTransaction و وضعیت هر قطعه ای را که در آن معاملات اضافه شده است ، نجات دهد و به شما امکان می دهد بعداً آن معاملات و قطعات آنها را با وضعیت خود بازیابی کنید. این به شما امکان می دهد با صرفه جویی در پشته پشتی فعلی و بازیابی یک پشته پشتی ذخیره شده ، به طور موثر بین پشته های چند پشتی "مبادله" کنید.

saveBackStack() به طور مشابه با popBackStack() عمل می کند زیرا این امر ناهمزمان است و باعث می شود تمام معاملات قطعه ای به آن نام خاص برگردد تا معکوس شود ("ظاهر شده") و هر قطعه اضافه شده برای از بین بردن و حذف شدن ، اما در چند مورد متفاوت است روشهای مهم:

  • saveBackStack() همیشه فراگیر است.
  • بر خلاف popBackStack() که اگر نام مشخص شده در پشته پشتی پیدا نشده باشد یا اگر نام تهی پیدا نشده باشد ، تمام معاملات را در قسمت پشتی پاپ می کند ، اگر قبلاً مرتکب معامله قطعه قطعه نشده با استفاده از addToBackStack() saveBackStack() هیچ کاری نمی کند. addToBackStack() با آن نام دقیق و غیر تهی.
  • وضعیت تمام قطعات اضافه شده از آن معاملات ذخیره می شود. این بدان معنی است که وضعیت نمای هر قطعه ذخیره می شود ، onSaveInstanceState() از هر قطعه خوانده می شود و حالت ترمیم می شود ، و هر نمونه ViewModel مرتبط با آن قطعات حفظ می شود (و onCleared() به آنها فراخوانی نمی شود).

معاملات قطعه ای که می تواند با saveBackStack() استفاده شود باید معیارهای خاصی را رعایت کند:

  • هر معامله قطعه ای باید از setReorderingAllowed(true) استفاده کند تا اطمینان حاصل شود که معاملات به عنوان یک عملیات واحد و اتمی قابل ترمیم هستند.
  • مجموعه معاملات ذخیره شده باید به خود اختصاصی باشد (یعنی آنها نباید صریحاً به قطعات خارج از آن مجموعه معاملات مراجعه کنند) تا اطمینان حاصل شود که می توانند در هر زمان بعدی ترمیم شوند ، مهم نیست که چه تغییراتی در پشت پشته ایجاد شده است. در زمان مداخله
  • هیچ قطعه ای که ذخیره شود نمی تواند یک قطعه نگهدارنده باشد یا یک قطعه حفظ شده در مجموعه گذرا از قطعات کودک خود داشته باشد تا اطمینان حاصل شود که FragmentManager پس از ذخیره پشته پشت ، هیچ گونه اشاراتی را به قطعات ذخیره شده باز نمی گرداند.

مشابه saveBackStack() ، restoreBackStack() اگر قبلاً saveBackStack() با همین نام خوانده نشده اید ، هیچ کاری نمی کند. ( b/80029773 )

قطعه قطعه قطعه قطعه شده

API های FragmentStrictMode چک های زمان اجرا را ارائه می دهند که به شما امکان می دهد تأیید کنید که برنامه یا کتابخانه های شما به آنها وابسته است ، API های قطعه ای مستهلک نمی نامند. هنگامی که یک تخلف تشخیص داده شد ، می توانید یک پیام ورود به سیستم را چاپ کنید ، شنونده سفارشی خود را تحریک کنید یا برنامه خود را خراب کنید. FragmentStrictMode.Policy که کنترل می کند چه مواردی را فعال می کند و چه "مجازات ها" را می توان از طریق روش جدید setStrictModePolicy() بر روی یک FragmentManager کرد. این سیاست در مورد آن FragmentManager و از نظر انتقادی برای هر مدیران قطعه قطعه که سیاست منحصر به فرد خود را تعیین نمی کنند ، اعمال می شود. ( #123 ، #131 ، #150 ، b/143774122 )

  • detectFragmentReuse() تشخیص می دهد که آیا یک نمونه Fragment که قبلاً حذف شده است دوباره به یک FragmentManager داده می شود. شما هرگز نباید پس از نابودی و حذف از یک FragmentManager ، با یک نمونه Fragment ارتباط برقرار کنید و یا از آن استفاده کنید. ( #142 ، b/153738653 )
  • detectFragmentTagUsage() هنگام استفاده از برچسب <fragment> در طرح XML خود را تشخیص می دهد. شما همیشه باید هنگام تورم قطعات به عنوان بخشی از طرح خود از FragmentContainerView استفاده کنید. ( #141 ، b/153738235 )
  • detectWrongFragmentContainer() هنگامی که یک قطعه را به یک ظروف اضافه می کنید که یک قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعهATENERVIEW است FragmentContainerView . شما همیشه باید از FragmentContainerView به عنوان ظرف برای قطعات موجود در طرح خود استفاده کنید. ( #146 ، b/181137036 )
  • detectRetainInstanceUsage() هنگام استفاده از API های setRetainInstance() یا getRetainInstance() استفاده می کنید. ( #140 ، b/153737954 )
  • detectSetUserVisibleHint() هنگام استفاده از API از setUserVisibleHint() استفاده می کنید. ( #136 ، b/153738974 )
  • detectTargetFragmentUsage() هنگام استفاده از APIS از setTargetFragment() ، getTargetFragment() یا getTargetRequestCode() استفاده می کنید. ( #139 ، b/153737745 )

تغییرات API

چک های جدید

  • بررسی LINT UseGetLayoutInflater اکنون هنگام استفاده از LayoutInflater.from(Context) در یک DialogFragment هشدار می دهد - همیشه باید از روش getLayoutInflater() قطعه دیالوگ استفاده کنید تا مناسب برای LayoutInflater را بدست آورید. ( #156 ، b/170781346 )
  • بررسی LINT DialogFragmentCallbacksDetector اکنون هشدار می دهد که هنگام تماس با setOnCancelListener یا setOnDismissListener در روش onCreateDialog() روش DialogFragment - این شنوندگان متعلق به خود DialogFragment است و شما باید onCancel() و onDismiss() را نادیده بگیرید تا این تماس تلفنی را دریافت کنید. ( #171 ، b/181780047 ، b/187524311 )

رفع اشکال

  • از قطعه 1.3.4 : رگرسیون معرفی شده در قطعه 1.3.3 هنگام استفاده از ViewTreeViewModelStoreOwner.get() API با ViewModelProvider یا روش JetPack از viewModel() در داخل یک قطعه. این موارد استفاده اکنون به درستی از ViewModelProvider.Factory ارائه شده توسط قطعه شما در صورتی که getDefaultViewModelProviderFactory() را تحت الشعاع قرار می دهد () (همانطور که @AndroidEntryPoint در هنگام استفاده از HILT انجام می دهد) استفاده می کند. اگر این روش را نادیده نگیرید ، یک SavedStateViewModelFactory که وضعیت خود را در کنار دیدگاه این قطعه ذخیره و بازیابی می کند ، به عنوان کارخانه پیش فرض ایجاد می شود. ( i5cbfa ، b/186097368 )
  • از قطعه 1.3.4 : هنگام استفاده از FragmentContainerView در API 29 ، insets دیگر به طور نامحدودی اعزام نمی شود و مشکلات مربوط به موارد BottomNavigationBar و FloatingActionButton را برطرف می کند. ( i1bb78 ، b/186012452 )
  • از قطعه 1.3.4 : اکنون می توانید پس از مرگ فرآیند ، بسته نرم افزاری حاصل از قطعه قطعه قطعه قطعه شده خود را بازیابی کنید. ( i65932 ، b/187443158 )
  • از قطعه 1.3.4 : هنگام انجام یک انتقال عنصر مشترک در یک گروه View ، اگر گروه ViewGroup دارای transitionGroup به False باشد ، اکنون به درستی در حال انتقال است. ( i99675 )

مشارکت خارجی

نسخه 1.3

نسخه 1.3.6

21 جولای 2021

androidx.fragment:fragment:1.3.6 ، androidx.fragment:fragment-ktx:1.3.6 ، و androidx.fragment:fragment-testing:1.3.6 منتشر می شود. نسخه 1.3.6 شامل این تعهدات است.

رفع اشکال

  • از قطعه 1.4.0-alpha03 : هنگامی که سعی در پنهان کردن یک قطعه حذف دارید ، دیگر FragmentManager نمی شود. ( i573dd ، b/183634730 )
  • وقتی نمای ریشه دارای hide() transitionGroup=”true” است ، دیدگاه این قطعه به درستی تنظیم GONE است. ( AOSP/1766655 ، B/193603427 )
  • FragmentActivity اکنون همیشه حالت ذخیره شده را باز می کند زیرا اولین عملیات خود در تماس با چرخه عمر است که از آن غلبه می کند. ( i6db7a )

به روزرسانی وابستگی

نسخه 1.3.5

16 ژوئن 2021

androidx.fragment:fragment:1.3.5 ، androidx.fragment:fragment-ktx:1.3.5 ، و androidx.fragment:fragment-testing:1.3.5 منتشر می شود. نسخه 1.3.5 شامل این تعهدات است.

رفع اشکال

  • یک رگرسیون در انتقال عناصر مشترک معرفی شده در قطعه 1.3.4 توسط AOSP/1679887 . قطعات اکنون به طور صحیح گروه های انتقال را اداره می کنند (یا مستقیماً از طریق transitionGroup="true" یا به طور غیرمستقیم از طریق یک transitionName یا background تنظیم شده) تنظیم می شوند و عناصر مشترک دیگر شاخص های IndexOutOfBoundsException پرتاب نمی کنند. ( I16484 ، b/188679569 ، b/188969304 )

نسخه 1.3.4

18 مه 2021

androidx.fragment:fragment:1.3.4 ، androidx.fragment:fragment-ktx:1.3.4 ، و androidx.fragment:fragment-testing:1.3.4 منتشر می شود. نسخه 1.3.4 شامل این تعهدات است.

رفع اشکال

  • رفع رگرسیون معرفی شده در قطعه 1.3.3 هنگام استفاده از ViewTreeViewModelStoreOwner.get() API با ViewModelProvider یا روش JetPack از viewModel() در داخل یک قطعه هنگام استفاده از HILT. این موارد استفاده اکنون به درستی از ViewModelProvider.Factory ارائه شده توسط قطعه شما در صورت غلبه بر getDefaultViewModelProviderFactory() (همانطور که @AndroidEntryPoint قطعات حاشیه نویسی انجام می دهند) استفاده می کنند. اگر این روش را نادیده نگیرید ، یک SavedStateViewModelFactory که وضعیت خود را در کنار دیدگاه این قطعه ذخیره و بازیابی می کند ، به عنوان کارخانه پیش فرض ایجاد می شود. ( i5cbfa ، b/186097368 )
  • هنگام استفاده از FragmentContainerView در API 29 ، Insets دیگر به طور نامحدود اعزام نمی شود و مشکلات مربوط به BottomNavigationBar و FloatingActionButton را برطرف می کند. ( i1bb78 ، b/186012452 )
  • اکنون می توانید پس از مرگ فرآیند ، بسته نرم افزاری خود را از بسته نتیجه قطعه بازیابی کنید. ( i65932 ، b/187443158 )
  • هنگام انجام یک انتقال عناصر مشترک در یک گروه View ، اگر ViewGroup دارای transitionGroup به False باشد ، اکنون به درستی انتقال خواهد یافت. ( i99675 )

نسخه 1.3.3

21 آوریل 2021

androidx.fragment:fragment:1.3.3 ، androidx.fragment:fragment-ktx:1.3.3 ، و androidx.fragment:fragment-testing:1.3.3 منتشر می شود. نسخه 1.3.3 شامل این تعهدات است.

ویژگی های جدید

  • با استفاده از SavedStateViewModelFactory اکنون هنگام استفاده از SavedStateRegistryOwner با استفاده از ViewTreeSavedStateRegistryOwner.get() با دیدگاه این قطعه استفاده می شود. ( I21ACF ، B/181577191 )

رفع اشکال

  • رگرسیون معرفی شده در قطعه 1.3.2 را برطرف کرد که باعث می شود انیمیشن های popEnter هنگام استفاده از یک FragmentTransaction که شامل یک عملیات setPrimaryNavFragment است ، مانند مواردی که توسط NavHostFragment استفاده می شود ، اجرا شود. ( i38c87 ، b/183877426 )
  • FragmentContainerView اکنون تضمین می کند که هر Fragment مجموعه جدیدی از WindowInsets را اعزام می کند ، و اطمینان می دهد که هر قطعه اکنون می تواند به طور مستقل از آن استفاده کند. ( i63f68 ، b/172153900 )
  • DialogFragment اکنون به درستی مواردی را انجام می دهد که یک قطعه کودک به یک ظروف اضافه شده است که دارای همان شناسه در کلاس Dialog سفارشی شما است ، و در هنگام استفاده مجدد از شناسه هایی که از طریق دیالوگ هایی مانند BottomSheetDialog استفاده می شود ، مسائل سلسله مراتبی را برطرف می کند. ( IE6279 ، b/180021387 )
  • FragmentManager.dump() اکنون به درستی اولین قطعه در لیست قطعات فعال را نشان می دهد. ( IF5C33 ، B/183705451 )

رفع اشکال مدیر دولت جدید

  • مدیر دولت جدید Fragment اکنون به درستی انتقال های خروج را با عملیات پنهان انجام می دهد. ( i9e4de ، b/184830265 )

نسخه 1.3.2

24 مارس 2021

androidx.fragment:fragment:1.3.2 ، androidx.fragment:fragment-ktx:1.3.2 ، و androidx.fragment:fragment-testing:1.3.2 منتشر می شود. نسخه 1.3.2 شامل این تعهدات است.

رفع اشکال مدیر دولت جدید

  • هنگام اجرای هر دو عملیات popBackStack() و commit() با هم ، آخرین عملیات اکنون به جای اجرای برخی از انیمیشن های پاپ و برخی از انیمیشن ها ، جهت همه انیمیشن ها را تنظیم می کند. ( I7072E ، B/181142246 )
  • نماهای درون یک سلسله مراتب عناصر مشترک دیگر هنگام انجام یک انتقال عناصر مشترک ، دیگر نام انتقال آنها را پاک نمی کند. ( i4d4a6 ، b/179934757 )

به روزرسانی های وابستگی

  • قطعه اکنون به فعالیت 1.2.2 بستگی دارد ، و مسئله ای را با استفاده از قطعه 1.3.1 یا بالاتر بررسی InvalidFragmentVersionForActivityResult کند.
  • قطعه اکنون به چرخه عمر 2.3.1 بستگی دارد.

نسخه 1.3.1

10 مارس 2021

androidx.fragment:fragment:1.3.1 ، androidx.fragment:fragment-ktx:1.3.1 ، و androidx.fragment:fragment-testing:1.3.1 منتشر می شود. نسخه 1.3.1 شامل این تعهدات است.

ویژگی های جدید

  • گفتگوهای درون یک DialogFragment می تواند از طریق دکوراسیون خود به صاحبان Viewtree دسترسی پیدا کند و اطمینان حاصل کند که می توان از DialogFragment با ComposeView استفاده کرد. ( IB9290 ، B/180691023 )

رفع اشکال

  • قطعاتی که با استفاده از FragmentContainerView در یک فعالیت از قبل RESUMED انجام می شوند ، پس از تغییر پیکربندی به درستی نشان داده شده اند. ( IE14C8 ، B/180538371 )
  • دیگر در پایان قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه قطعه بسیار خیلی } ((خیلی ((خیلی خیلی ((((بالاترین)) دیگر دیگر toString() ( i54705 ، b) b/17771088 )
  • روشهای بیش از حد در تکه تکه شدن اکنون به درستی روش پایه Javadoc را به ارث می برند ( I736CE ، B/139548782 )
  • اسناد مربوط به setFragmentResult و setFragmentResultListener اسناد پارامترهای خود را به روز کرده اند تا منعکس کنند که آنها دیگر تهی نمی کنند ( I990BA ، b/178348386 )

رفع اشکال مدیر دولت جدید

  • رفع نشت حافظه در قطعات ناشی از mFocusedView ( IB4E9E ، B/179925887 )
  • قطعات اکنون به درستی هنگام استفاده از معاملات نمایش/پنهان کردن به درستی onCreateOptionsMenu می کنند ( i8bce8 ، b/180255554 )
  • قطعات کودک با انتقال که قبل از شروع قطعه شروع می شود ، اکنون به درستی از RESUMED گرفته می شود ( IC11E6 ، B/180825150 )
  • قطعات تورم با استفاده از برچسب <fragment> اکنون همیشه آن را از RESUMED می گیرند ( i452ac ، ( i9fa49 )

به روزرسانی های وابستگی

نسخه 1.3.0

10 فوریه 2021

androidx.fragment:fragment:1.3.0 ، androidx.fragment:fragment-ktx:1.3.0 ، و androidx.fragment:fragment-testing:1.3.0 منتشر می شود. نسخه 1.3.0 حاوی این commit ها است.

تغییرات اساسی از 1.2.0

  • New State Manager : A significant rewrite of the internals of FragmentManager has fixed numerous issues around the dispatch of lifecycle events, animations and transitions, and how postponed fragments are handled.
  • Activity Result API Integration : Added support for the ActivityResultRegistry API introduced in Activity 1.2.0 to handle startActivityForResult() + onActivityResult() as well as requestPermissions() + onRequestPermissionsResult() flows without overriding methods in your Fragment in addition to providing hooks for testing these flows. See the updated Getting a Result from an Activity .

    • This release fixes a number of issues around invalid request codes and the dispatch of permission requests that prevent the Activity Result API from working on previous versions of FragmentActivity . You must upgrade to Fragment 1.3.0 to use the Activity Result APIs in a FragmentActivity or AppCompatActivity .
  • Fragment Result API : Added support for passing results between two Fragments via new APIs on FragmentManager . This works for hierarchy fragments (parent/child), DialogFragments, and fragments in Navigation and ensures that results are only sent to your Fragment while it is at least STARTED . The target fragment APIs have been deprecated in favor of these new APIs. See Get Results using the Fragment Result API .

  • FragmentOnAttachListener : The onAttachFragment() callback on FragmentActivity and Fragment have been deprecated. A new FragmentOnAttachListener has been added to provide a more flexible alternative, allowing delegation of onAttachFragment() to separate, testable listeners and support for adding a listener to FragmentManagers other than your direct child FragmentManager.

  • FragmentScenario Improvements : The FragmentScenario class from the fragment-testing artifact has been rewritten in Kotlin and has received a number of improvements:

    • FragmentScenario now uses setMaxLifecycle() to implement moveToState() , ensuring consistent behavior on all API levels and decoupling the Fragment's state from the underlying Activity.
    • FragmentScenario now supports setting an initial Lifecycle.State to support asserting the fragment's state before moving to each Lifecycle.State for the first time.
    • There is now an alternative to the FragmentScenario API of onFragment in the form of the Kotlin reified extension method withFragment that allows you to return a value. Notably, it rethrows exceptions raised in the given block.
  • ViewTree Support : Fragment now supports the ViewTreeLifecycleOwner.get(View) , ViewTreeViewModelStoreOwner.get(View) , and ViewTreeSavedStateRegistryOwner APIs added in Lifecycle 2.3.0 and SavedState 1.1.0 such that it will return the Fragment as the ViewModelStoreOwner , and a SavedStateRegistryOwner and LifecycleOwner tied to the fragment's view Lifecycle when using a View within a Fragment .

  • TRANSIT_ animation changes : The fragment default effects, TRANSIT_FRAGMENT_OPEN , TRANSIT_FRAGMENT_CLOSE , and TRANSIT_FRAGMENT_FADE , now use Animator instead of Animation . The resources used to build these animators are now private.

  • setRetainInstance() deprecation : The setRetainInstance() method on Fragments has been deprecated. With the introduction of ViewModels , developers have a specific API for retaining state that can be associated with Activities, Fragments, and Navigation graphs. This allows developers to use a normal, not retained Fragment and keep the specific state they want retained separate, avoiding a common source of leaks while maintaining the useful properties of a single creation and destruction of the retained state (namely, the constructor of the ViewModel and the onCleared() callback it receives).

  • ViewPager 1 adapter deprecation : With the release of ViewPager2 1.0.0 , the FragmentPagerAdapter and FragmentStatePagerAdapter classes for interacting with ViewPager have been deprecated. See Migrate from ViewPager to ViewPager2 .

Version 1.3.0-rc02

27 ژانویه 2021

androidx.fragment:fragment:1.3.0-rc02 , androidx.fragment:fragment-ktx:1.3.0-rc02 , and androidx.fragment:fragment-testing:1.3.0-rc02 are released. Version 1.3.0-rc02 contains these commits.

رفع اشکال

  • Fixed an issue where a parent DialogFragment would appear above a child DialogFragment after a configuration change; child dialog fragments now always appear above a parent dialog fragment. ( I30806 , b/177439520 )
  • Fixed issue where doing a hide operation with an Animation would cause the hiding fragment to flash at the end of the animation. ( I57e22 , b/175417675 )
  • Fragments with transitions added before the view hierarchy is attached now properly reach RESUMED . ( I1fc1d , b/177154873 )

New State Manager Bug Fixes

  • The Fragment's view Lifecycle now properly handles cases where the Fragment's view is destroyed before the Lifecycle reaches CREATED , avoiding exceptions stating “no event down from INITIALIZED”. ( eda2bd , b/176138645 )
  • Fragments that use an Animator now appear in the proper order when using FragmentContainerView . ( Id9aa3 , b/176089197 )

نسخه 1.3.0-rc01

16 دسامبر 2020

androidx.fragment:fragment:1.3.0-rc01 , androidx.fragment:fragment-ktx:1.3.0-rc01 , and androidx.fragment:fragment-testing:1.3.0-rc01 are released. نسخه 1.3.0-rc01 حاوی این commit ها است.

رفع اشکال

  • onPrepareOptionsMenu() now follows the same logic as onCreateOptionsMenu() and is no longer called when a parent fragment calls setMenuVisibility(false) . ( Id7de8 , b/173203654 )

New State Manager Bug Fixes

  • Fixed leak and visual artifact when adding a fragment with an Animation to a FragmentContainerView and then interrupting that addition with a pop operation. ( I952d8 )
  • Fixed an issue where the fragment's view would remain in the view hierarchy if it was replaced during its onCreate() or onViewCreated() methods. ( I8a7d5 )
  • Focus is now properly restored to Fragment root views when they are resumed. ( Ifc84b )
  • Combining pop and replace operations in the same fragment transaction will now show the proper animations ( Ifd4e4 , b/170328691 )

Version 1.3.0-beta02

2 دسامبر 2020

androidx.fragment:fragment:1.3.0-beta02 , androidx.fragment:fragment-ktx:1.3.0-beta02 , and androidx.fragment:fragment-testing:1.3.0-beta02 are released. Version 1.3.0-beta02 contains these commits.

ویژگی های جدید

  • FragmentScenario has been fully converted to Kotlin while maintaining source and binary compatibility via usage of Kotlin 1.4's functional interfaces for FragmentAction . ( I19d31 )

تغییرات رفتار

  • FragmentContainerViews that do not inflate a fragment using the class or android:name attribute can now be used outside of a FragmentActivity . ( Id4397 , b/172266337 )
  • Attempting to set the max lifecycle of a fragment to DESTROYED will now throw an IllegalArgumentException ( Ie7651 , b/170765622 )
  • Initializing a FragmentScenario with a DESTROYED state will now throw an IllegalArgumentException ( I73590 , b/170765622 )

New State Manager Bug Fixes

  • Fixed an issue where the view would not reach its final state if you interrupt a fragment transition that was using an Animator or one of the TRANSIT_FRAGMENT_ options. ( I92426 , b/169874632 )
  • Fixed an issue that prevented fragments with an exiting Animation from being properly destroyed. ( I83d65 )
  • Exiting fragments that have their effects reversed now correctly cancel and restart with the proper entering effect. ( I62226 , b/167092035 )
  • Fixed an issue where the exit Animator of a hide() would not run. ( Id7ffe )
  • Fragments now properly appear when postponed and then immediately started. ( Ie713b , b/170022857 )
  • Fragments that remove their focused view during an animation will no longer attempt to restore the focus on the detached view once they reach RESUMED ( I38c65 , b/172925703 )

مشارکت خارجی

  • FragmentFactory now caches fragment classes separately for different ClassLoader instances. Thanks Simon Schiller! ( #87 , b/113886460 )

نسخه 1.3.0-beta01

1 اکتبر 2020

androidx.fragment:fragment:1.3.0-beta01 , androidx.fragment:fragment-ktx:1.3.0-beta01 , and androidx.fragment:fragment-testing:1.3.0-beta01 are released. نسخه 1.3.0-beta01 حاوی این تعهدات است.

ویژگی های جدید

  • setMaxLifecycle() now supports setting the Lifecycle state to INITIALIZING as long as the fragment has not been moved to CREATED . ( b/159662173 )

تغییرات API

تغییرات رفتار

  • Fragment resource files have been correctly made private. ( aosp/1425237 )

رفع اشکال

  • Fragments inflated using the <fragment> tag will now properly wait until their views are added to a container before moving to STARTED ( I02f4c )
  • Fragments that are visible and then setMaxLifecycle() to CREATED now properly run their exit effects. ( b/165822335 )
  • Removing a detached fragment that is not added to the back stack no longer causes a memory leak. Courtesy of Nicklas Ansman Giertz! ( b/166489383 )
  • Active fragments will now always have a non-null FragmentManager and fragments with a non-null FragmentManager will always be considered active. ( aosp/1422346 )
  • The fragment default effects, TRANSIT_FRAGMENT_OPEN , TRANSIT_FRAGMENT_CLOSE , and TRANSIT_FRAGMENT_FADE , now use Animator instead of Animation . ( b/166155034 )

New State Manager Bug Fixes

  • Fragments now properly restore their view focus state from right before they start their animation. ( Icc256 )
  • Fragments that only have a shared element transition now properly complete their special effects meaning they actually move to their final state ( Iaebc7 , b/166658128 )
  • Fragment views are now always removed from the container before being destroyed. ( Id5876 )
  • The new state manager now consistently removes the exiting fragment view before adding the entering one. ( I41a6e )
  • Explicit changes to a fragment view's visibility are now respected by the new state manager. This means that if you set an entering fragment's view to INVISIBLE before the animation begins, it will actually stay invisible. ( b/164481490 )
  • Fragments now prioritize Animators over Animations , meaning a fragment with both will only run the Animator and ignore the Animation . ( b/167579557 )
  • The new state manager no longer causes fragments to flash when using entering animations. ( b/163084315 )

مشکل شناخته شده

When using the new state manager, if you press back during an entering special effect instead of returning to the previous fragment, the old fragment is never re-added, resulting in a blank screen. ( b/167259187 , b/167092035 , b/168442830 )

Version 1.3.0-alpha08

19 آگوست 2020

androidx.fragment:fragment:1.3.0-alpha08 , androidx.fragment:fragment-ktx:1.3.0-alpha08 , and androidx.fragment:fragment-testing:1.3.0-alpha08 are released. Version 1.3.0-alpha08 contains these commits.

New State Manager

This release includes a major refactoring of the internal state management of FragmentManager which affects the dispatch of lifecycle methods, animations and transitions, and how postponed transactions are handled. این به طور پیش فرض فعال است. See the Fragments: Rebuilding the Internals blog post for more details. ( b/139536619 , b/147749580 )

  • An experimental API in FragmentManager.enableNewStateManager(boolean) can be used to control whether FragmentManager uses the new state manager. ( I7b6ee )

The following issues are fixed only when using the new state manager:

  • The previous fragment of a replace operation is now correctly stopped before the new fragment is started. ( b/161654580 )
  • Fragments now prevent multiple competing animations on the same fragments, avoiding cases where an Animation would override all Transition effects or an Animator and a Transition on an individual fragment would both run. ( b/149569323 )
  • The enterTransition and exitTranstion of all fragments entering and exiting are now ran rather than only the last entering fragment and the first exiting fragment. ( b/149344150 )
  • Postponed fragments no longer get stuck at the CREATED state but instead move to STARTED with other fragments. ( b/129035555 )
  • Fixed an issue where FragmentManager would execute operations out of order when mixing a postponed re-ordered transaction and a non-reordered transaction. ( b/147297731 )
  • Popping multiple fragments simultaneously will no longer result in intermediate fragments being temporarily visible when postponing fragments. ( b/37140383 )
  • FragmentManager now returns the correct fragments when calling findFragmentById() or findFragmentByTag() from within the onAttachFragment() callback. ( b/153082833 )
  • Fragments no longer call onCreateView() on fragments being destroyed when the fragment replacing them is postponed. ( b/143915710 )
  • The error message when attempting to combine framework Transition and AndroidX Transition instances now mentions the fragment with the invalid transition. ( b/155574969 )

تغییرات رفتار

  • You can now call launch() on an ActivityResultLauncher in the onCreate() lifecycle method of a fragment. ( b/161464278 )
  • Calling registerForActivityResult() after onCreate() now throws an exception indicating that this is not allowed rather than silently failing to deliver results after a configuration change. ( b/162255449 )
  • FragmentActivity now uses the OnContextAvailableListener API introduced in Activity 1.2.0-alpha08 to restore the state of the FragmentManager . Any listeners added to subclasses of FragmentActivity will run after this listener. ( I513da )

رفع اشکال

  • ActivityOptions passed through when using startIntentSenderForResult() are now respected. ( b/162247961 )

مشکل شناخته شده

  • When using the new state manager, directly setting the visibility of the fragment's root view after onViewCreated() and before onResume() results in the visibility you set being overridden by FragmentManager , who controls the visibility of the root view. As a workaround, you should always use the hide() and show() operations to change the visibility of your fragment. ( b/164481490 )

Version 1.3.0-alpha07

22 جولای 2020

androidx.fragment:fragment:1.3.0-alpha07 , androidx.fragment:fragment-ktx:1.3.0-alpha07 , and androidx.fragment:fragment-testing:1.3.0-alpha07 are released. Version 1.3.0-alpha07 contains these commits.

ویژگی های جدید

  • FragmentScenario now supports setting an initial Lifecycle state of CREATED , STARTED , or RESUMED rather than always moving the Fragment to the RESUMED state. ( b/159662750 )
  • Added an alternative to the FragmentScenario API of onFragment in the form of the Kotlin reified extension method withFragment that allows you to return a value. Notably, it rethrows exceptions raised in the given block. ( b/158697631 )

تغییرات رفتار

  • FragmentScenario now uses setMaxLifecycle() to implement moveToState() , ensuring consistent behavior on all API levels and decoupling the Fragment's state from the underlying Activity. ( b/156527405 )
  • The SavedStateRegistryOwner returned by ViewTreeSavedStateRegistryOwner is now tied to the fragment view's Lifecycle. This ensures that it has its state saved and restore at the same time as the fragment's view. ( b/158503763 )

رفع اشکال

  • Fragments now wait for the fragment's view to be attached before calling ViewCompat.requestApplyInsets() , avoiding cases where the inset request was being dropped. ( b/158095749 )
  • Calling clearFragmentResultListener now properly clears the lifecycle observer. ( b/159274993 )

Version 1.3.0-alpha06

10 ژوئن 2020

androidx.fragment:fragment:1.3.0-alpha06 , androidx.fragment:fragment-ktx:1.3.0-alpha06 , and androidx.fragment:fragment-testing:1.3.0-alpha06 are released. Version 1.3.0-alpha06 contains these commits.

ویژگی های جدید

  • The onAttachFragment() callback on FragmentActivity and Fragment have been deprecated. A new FragmentOnAttachListener has been added to provide a more flexible alternative, allowing delegation of onAttachFragment() to separate, testable listeners and support for adding a listener to FragmentManagers other than your direct child FragmentManager. ( I06d3d )

رفع اشکال

  • Parent fragments now have their view state restored before their child fragments, fixing a visual ordering issue after a configuration change when a DialogFragment would show another DialogFragment as a child fragment. ( b/157195715 )
  • Fixed an issue where the UseRequireInsteadOfGet Lint check would not handle chained usages of the ?. و !! operators correctly. ( b/157677616 )

نسخه 1.3.0-alpha05

20 مه 2020

androidx.fragment:fragment:1.3.0-alpha05 , androidx.fragment:fragment-ktx:1.3.0-alpha05 , and androidx.fragment:fragment-testing:1.3.0-alpha05 are released. نسخه 1.3.0-alpha05 حاوی این commit ها است.

ویژگی های جدید

تغییرات API

  • The setFragmentResult() and setFragmentResultListener() APIs now take a non-null Bundle and FragmentResultListener , respectively. To explicitly clear a previously set result or listener, use the new clearFragmentResult() and clearFragmentResultListener() methods. ( b/155416778 )
  • The setFragmentResultListener() Kotlin extensions that take a lambda are now marked as inline . ( b/155323404 )

تغییرات رفتار

  • The previously deprecated startActivityForResult() , startIntentSenderForResult() , and requestPermissions on Fragment now internally use ActivityResultRegistry , thus removing the restriction on using only the lower bits (below 0xFFFF ) for your request codes when using those APIs. ( b/155518741 )

Documentation Updates

  • Expanded the documentation on the Fragment(@LayoutRes int) and DialogFragment(@LayoutRes int) constructors to clarify that they should be called from your subclasses' no argument constructor when using the default FragmentFactory . ( b/153042497 )

Version 1.3.0-alpha04

29 آوریل 2020

androidx.fragment:fragment:1.3.0-alpha04 , androidx.fragment:fragment-ktx:1.3.0-alpha04 , and androidx.fragment:fragment-testing:1.3.0-alpha04 are released. نسخه 1.3.0-alpha04 حاوی این commit ها است.

ویژگی های جدید

  • Added support for passing results between two Fragments via new APIs on FragmentManager . This works for hierarchy fragments (parent/child), DialogFragments, and fragments in Navigation and ensures that results are only sent to your Fragment while it is at least STARTED . ( b/149787344 )

تغییرات API

  • The target fragment APIs have been deprecated. To pass data between fragments the new Fragment Result APIs should be used instead. ( b/149787344 )
  • The startActivityForResult() / onActivityResult() and requestPermissions() / onRequestPermissionsResult() APIs on Fragment have been deprecated. Please use the Activity Result APIs . ( aosp/1290887 )
  • Breaking change from Activity 1.2.0-alpha04 : the prepareCall() method has been renamed to registerForActivityResult() . ( aosp/1278717 )

رفع اشکال

  • The fragment's getViewLifecycleOwner() is now stopped before onSaveInstanceState() is called, mirroring the behavior of the fragment's lifecycle. ( b/154645875 )
  • Calling setMenuVisibility(false) on a fragment now correctly changes the visibility of menus provided by its child fragments. ( b/153593580 )
  • Fixed an illegalStateException when adding a fragment to a DialogFragment 's view hierarchy with FragmentContainerView . ( b/154366601 )
  • The getDefaultViewModelProviderFactory() method on fragments no longer crashes when hosting your fragments outside of an activity. ( b/153762914 )

نسخه 1.3.0-alpha03

1 آوریل 2020

androidx.fragment:fragment:1.3.0-alpha03 , androidx.fragment:fragment-ktx:1.3.0-alpha03 , and androidx.fragment:fragment-testing:1.3.0-alpha03 are released. نسخه 1.3.0-alpha03 حاوی این commit ها است.

تغییرات API

  • The prepareCall methods on Fragment are now final . ( b/152439361 )

رفع اشکال

  • Fixed a regression introduced in Fragment 1.3.0-alpha02 when using BottomSheetDialogFragment . ( b/151652127 , aosp/1263328 , aosp/1265163 )
  • Fixed a crash when using prepareCall from a fragment after a configuration change. ( b/152137004 )
  • Fixed an issue where shared element and exit transitions are ignored when using setTargetFragment() . ( b/152023196 )
  • From Fragment 1.2.4 : Updated the Fragment ProGuard rules to allow obfuscation of kept fragments. ( b/151605338 )
  • From Fragment 1.2.4 : Disabled the FragmentLiveDataObserve Lint rule on DialogFragment classes as their lifecycle and view lifecycle are always in sync, making it safe to use either this or viewLifecycleOwner when calling observe . ( b/151765086 )

Dependency Changes

  • Fragments depend on Activity 1.2.0-alpha03 , which had significant improvements to the Activity Result API introduced in Activity 1.2.0-alpha02 .

نسخه 1.3.0-alpha02

18 مارس 2020

androidx.fragment:fragment:1.3.0-alpha02 , androidx.fragment:fragment-ktx:1.3.0-alpha02 , and androidx.fragment:fragment-testing:1.3.0-alpha02 are released. نسخه 1.3.0-alpha02 حاوی این commit ها است.

ویژگی های جدید

  • Added support for the ActivityResultRegistry API introduced in Activity 1.2.0-alpha02 to handle the startActivityForResult() + onActivityResult() as well as requestPermissions() + onRequestPermissionsResult() flows without overriding methods in your Fragment in addition to providing hooks for testing these flows . See the updated Getting a Result from an Activity . ( b/125158199 )

تغییرات API

  • DialogFragment now provides a constructor that takes a @LayoutRes that indicates the layout that onCreateView() should inflate by default. ( b/150327080 )
  • The onActivityCreated() method is now deprecated. Code touching the fragment's view should be done in onViewCreated() (which is called immediately before onActivityCreated() ) and other initialization code should be in onCreate() . To receive a callback specifically when the activity's onCreate() is complete, a LifeCycleObserver should be registered on the activity's Lifecycle in onAttach() , and removed once the onCreate() callback is received. ( b/144309266 )

رفع اشکال

  • From Fragment 1.2.3 : Fixed a bug in DialogFragment that caused a StackOverflowError when calling getLayoutInflater() from within onCreateDialog() . ( b/117894767 , aosp/1258664 )
  • From Fragment 1.2.3 : Reduced the scope of Fragment's included ProGuard rules to ensure that unused Fragment classes can be stripped. ( b/149665169 )
  • From Fragment 1.2.3 : Fixed false positives in the UseRequireInsteadOfGet Lint check when using a local variable name that shadowed the Kotlin property name. ( b/149891163 )
  • From Fragment 1.2.3 : FragmentContainerView no longer throws an UnsupportedOperationException for using the incorrect constructor in layout preview. ( b/149707833 )

مشکلات شناخته شده

  • BottomSheetDialogFragment no longer properly positions its dialog on the screen. ( b/151652127 )

نسخه 1.3.0-alpha01

4 مارس 2020

androidx.fragment:fragment:1.3.0-alpha01 , androidx.fragment:fragment-ktx:1.3.0-alpha01 , and androidx.fragment:fragment-testing:1.3.0-alpha01 are released. نسخه 1.3.0-alpha01 حاوی این commit ها است.

ویژگی های جدید

تغییرات API

  • The setRetainInstance() method on Fragments has been deprecated. With the introduction of ViewModels , developers have a specific API for retaining state that can be associated with Activities, Fragments, and Navigation graphs. This allows developers to use a normal, not retained Fragment and keep the specific state they want retained separate, avoiding a common source of leaks while maintaining the useful properties of a single creation and destruction of the retained state (namely, the constructor of the ViewModel and the onCleared() callback it receives). ( b/143911815 )
  • With the release of ViewPager2 1.0.0 , the FragmentPagerAdapter and FragmentStatePagerAdapter classes for interacting with ViewPager have been deprecated. See Migrate from ViewPager to ViewPager2 . ( b/145132715 )

رفع اشکال

  • Fragment ProGuard rules now correctly only keep the default constructors Fragment classes that are used rather than for all Fragment instances, fixing a regression introduced in Fragment 1.2.1 . ( b/149665169
  • The require___() Lint rules added in Fragment 1.2.2 no longer false positive on local variables that share the same name as the shadowed Kotlin property names (ie, view ). ( b/149891163 )
  • FragmentContainerView no longer throws an UnsupportedOperationException when using the layout preview in Android Studio. ( b/149707833 )
  • Fixed an issue where retained fragments that were added after the state is saved would not be continually recreated and then destroyed after each configuration change. ( b/145832397 )

Version 1.2.5

Version 1.2.5

10 ژوئن 2020

androidx.fragment:fragment:1.2.5 , androidx.fragment:fragment-ktx:1.2.5 , and androidx.fragment:fragment-testing:1.2.5 are released. Version 1.2.5 contains these commits.

رفع اشکال

  • The fragment's getViewLifecycleOwner() is now stopped before onSaveInstanceState() is called, mirroring the behavior of the fragment's lifecycle. This was previously released in Fragment 1.3.0-alpha04 . ( b/154645875 )
  • Calling setMenuVisibility(false) on a fragment now correctly changes the visibility of menus provided by its child fragments. This was previously released in Fragment 1.3.0-alpha04 . ( b/153593580 )

Version 1.2.4

Version 1.2.4

1 آوریل 2020

androidx.fragment:fragment:1.2.4 , androidx.fragment:fragment-ktx:1.2.4 , and androidx.fragment:fragment-testing:1.2.4 are released. Version 1.2.4 contains these commits.

رفع اشکال

  • Updated the Fragment ProGuard rules to allow obfuscation of kept fragments. ( b/151605338 )
  • Disabled the FragmentLiveDataObserve Lint rule on DialogFragment classes as their lifecycle and view lifecycle are always in sync, making it safe to use either this or viewLifecycleOwner when calling observe . ( b/151765086 )

Version 1.2.3

Version 1.2.3

18 مارس 2020

androidx.fragment:fragment:1.2.3 , androidx.fragment:fragment-ktx:1.2.3 , and androidx.fragment:fragment-testing:1.2.3 are released. Version 1.2.3 contains these commits.

رفع اشکال

  • Fixed a bug in DialogFragment that caused a StackOverflowError when calling getLayoutInflater() from within onCreateDialog() . ( b/117894767 , aosp/1258665 )
  • Reduced the scope of Fragment's included ProGuard rules to ensure that unused Fragment classes can be stripped. ( b/149665169 )
  • Fixed false positives in the UseRequireInsteadOfGet Lint check when using a local variable name that shadowed the Kotlin property name. ( b/149891163 )
  • FragmentContainerView no longer throws an UnsupportedOperationException for using the incorrect constructor in layout preview. ( b/149707833 )

Version 1.2.2

Version 1.2.2

February 19, 2020

androidx.fragment:fragment:1.2.2 , androidx.fragment:fragment-ktx:1.2.2 , and androidx.fragment:fragment-testing:1.2.2 are released. Version 1.2.2 contains these commits.

New Lint checks

  • Lint suggests using the viewLifecycleOwner as the LifecycleOwner to calls into OnBackPressedDispatcher in onCreateView() , onViewCreated() , and onActivityCreated() . ( b/142117657 )
  • Added a new Lint check that confirms that you are using the correct debugImplementation when using the fragment-testing artifact. ( b/141500106 )
  • Fragments now suggest using the associated require___() methods for more descriptive error messages instead of checkNotNull(get___()) , requireNonNull(get___()) , or get___()!! for all of the Fragment APIs that include both a get and require equivalent. ( aosp/1202883 )

رفع اشکال

  • Fixed the Fragment ProGuard files to avoid R8 warnings ( b/148963981 )
  • Improved the existing Lint check suggesting using viewLifecycleOwner when using observe to also handle the livedata-ktx extension method version of observe . ( b/148996309 )
  • Fixed the formatting for many of the Lint checks ( aosp/1157012 )

External contributions

  • Thanks to Zac Sweers for contributing the require___() Lint checks on behalf of Slack! ( aosp/1202883 )

Version 1.2.1

Version 1.2.1

5 فوریه 2020

androidx.fragment:fragment:1.2.1 , androidx.fragment:fragment-ktx:1.2.1 , and androidx.fragment:fragment-testing:1.2.1 are released. Version 1.2.1 contains these commits .

رفع اشکال

  • Fragments added via the add and replace methods that take a Class instance (or the Kotlin reified versions) now have their default constructor kept by ProGuard. ( b/148181315 )
  • FragmentStatePagerAdapter and FragmentPagerAdapter no longer catch exceptions thrown by FragmentManager when running finishUpdate() . ( aosp/1208711 )
  • Fixed an issue where FragmentManager.findFragment() did not work with fragments added via the <fragment> tag. ( b/147784323 )
  • Fragments inflated using the <fragment> tag now always receive a call to onInflate() before onCreate() when in the layout. ( aosp/1215856 )
  • Calling toString() on a FragmentManager instance no longer throws a NullPointerException when the Activity is already destroyed. ( b/148189412 )

Dependency changes

Version 1.2.0

Version 1.2.0

22 ژانویه 2020

androidx.fragment:fragment:1.2.0 , androidx.fragment:fragment-ktx:1.2.0 , and androidx.fragment:fragment-testing:1.2.0 are released. Version 1.2.0 contains these commits .

Important changes since 1.1.0

  • FragmentContainerView : The FragmentContainerView is the strongly recommended container for dynamically added Fragments, replacing usage of FrameLayout or other layouts. It also supports the same class , android:name , and optional android:tag as the <fragment> tag, but uses a normal FragmentTransaction to add this initial fragment, instead of the custom code path used by <fragment> .
  • onDestroyView() timing : Fragments now wait for exit animations, exit framework transitions, and exit AndroidX transitions (when using Transition 1.3.0 ) to complete before calling onDestroyView() .
  • Class based add() and replace() : Added new overloads of add() and replace() on FragmentTransaction that take a Class<? extends Fragment> and optional Bundle of arguments. These methods use your FragmentFactory to construct an instance of the Fragment to add. Kotlin extensions that use reified types (ie, fragmentTransaction.replace<YourFragment>(R.id.container) ) have also been added to fragment-ktx .
  • Lifecycle ViewModel SavedState Integration : SavedStateViewModelFactory is now the default factory used when using by viewModels() , by activityViewModels() , the ViewModelProvider constructor, or ViewModelProviders.of() with a Fragment.
  • New Lint checks : Added a new Lint check that ensures you are using getViewLifecycleOwner() when observing LiveData from onCreateView() , onViewCreated() , or onActivityCreated() .
  • getFragmentManager() deprecation : The getFragmentManager() and requireFragmentManager() methods on Fragment have been deprecated and replaced with a single getParentFragmentManager() method, which returns the non-null FragmentManager the Fragment is added to (you can use isAdded() to determine if it is safe to call).
  • FragmentManager.enableDebugLogging() deprecation : The static FragmentManager.enableDebugLogging method has been deprecated. FragmentManager now respects Log.isLoggable() for the tag FragmentManager , allowing you to enable either DEBUG or VERBOSE logging without re-compiling your app.

مشکلات شناخته شده

  • Fragments referenced only via the class or android:name attribute on a FragmentContainerView are not kept by ProGuard automatically, requiring that you manually add a keep rule for each fragment class. ( b/142601969 )
  • When adding a NavHostFragment using class or android:name in XML with FragmentContainerView , you cannot use findNavController() in onCreate() of your Activity. ( b/142847973 )

Version 1.2.0-rc05

8 ژانویه 2020

androidx.fragment:fragment:1.2.0-rc05 , androidx.fragment:fragment-ktx:1.2.0-rc05 , and androidx.fragment:fragment-testing:1.2.0-rc05 are released. Version 1.2.0-rc05 contains these commits .

رفع اشکال

  • Fixed a regression in Fragment 1.2.0-rc04 when using the <fragment> tag which caused onViewCreated() to be called incorrectly during activity destruction. ( b/146290333 )
  • Fragments added with the <fragment> tag now properly have their non-config cleared even when they are only sometimes in the layout (ie, only in your landscape layout). As a consequence, these Fragments are now correctly moved to CREATED even when not in your layout instead of being instantiated but never moving through any lifecycle methods. ( b/145769287 )

Version 1.2.0-rc04

18 دسامبر 2019

androidx.fragment:fragment:1.2.0-rc04 , androidx.fragment:fragment-ktx:1.2.0-rc04 , and androidx.fragment:fragment-testing:1.2.0-rc04 are released. Version 1.2.0-rc04 contains these commits .

رفع اشکال

  • Adjusted the animations for TRANSIT_FRAGMENT_OPEN , TRANSIT_FRAGMENT_CLOSE , and TRANSIT_FRAGMENT_FADE to avoid visual issues. ( b/145468417 )

Version 1.2.0-rc03

4 دسامبر 2019

androidx.fragment:fragment:1.2.0-rc03 , androidx.fragment:fragment-ktx:1.2.0-rc03 , and androidx.fragment:fragment-testing:1.2.0-rc03 are released. Version 1.2.0-rc03 contains these commits .

رفع اشکال

  • Fixed an unintentional behavior change where Fragments who have been removed are still returned by findFragmentById() / findFragmentByTag() while their exit animations/transitions run. ( b/143982969 , aosp/1167585 )
  • Child fragments are now correctly stopped before their parents when the containing activity calls onSaveInstanceState() . ( b/144380645 )
  • Fixed an issue where Views were incorrectly marked INVISIBLE after popping a hidden Fragment. ( b/70793925 )
  • Fragment shared element transitions now handle Views that have been rotated, scaled, etc. ( b/142835261 )

Documentation Updates

  • Clarified the deprecation documentation around setUserVisibleHint() . ( b/143897055 )
  • Improved the documentation on setFragmentFactory() and getFragmentFactory() to better indicate that setting a FragmentFactory will also affect child FragmentManagers. ( aosp/1170095 )

Dependency changes

  • Fragments now depends on Lifecycle 2.2.0-rc03 , Lifecycle ViewModel SavedState 1.0.0-rc03 , and Activity 1.1.0-rc03 .

Version 1.2.0-rc02

7 نوامبر 2019

androidx.fragment:fragment:1.2.0-rc02 , androidx.fragment:fragment-ktx:1.2.0-rc02 , and androidx.fragment:fragment-testing:1.2.0-rc02 are released. Version 1.2.0-rc02 contains these commits .

رفع اشکال

  • When in Kotlin, the LintFix for using getViewLifecycleOwner() when observing LiveData from onCreateView() , onViewCreated() , or onActivityCreated() (introduced in Fragment 1.2.0-rc01 ) now uses the Kotlin property access syntax viewLifecycleOwner instead of getViewLifecycleOwner() . ( aosp/1143821 )

Version 1.2.0-rc01

23 اکتبر 2019

androidx.fragment:fragment:1.2.0-rc01 , androidx.fragment:fragment-ktx:1.2.0-rc01 , and androidx.fragment:fragment-testing:1.2.0-rc01 are released. Version 1.2.0-rc01 contains these commits .

ویژگی های جدید

  • FragmentContainerView now supports the class attribute in addition to android:name , mirroring the functionality of the <fragment> tag. ( b/142722242 )
  • Added a new Lint check that ensures you are using getViewLifecycleOwner() when observing LiveData from onCreateView() , onViewCreated() , or onActivityCreated() . ( b/137122478 )

رفع اشکال

  • The onDismiss and onCancel callbacks on DialogFragment now guarantee that the DialogInterface passed to them is non-null and that getDialog() returns non-null when they are executed. ( b/141974033 )
  • FragmentContainerView now adds the Fragment defined by class or android:name as part of inflation, ensuring that findFragmentById() and findFragmentByTag() work immediately afterwards. ( b/142520327 )
  • Fixed an IllegalStateException in FragmentContainerView due to the state being saved. ( b/142580713 )
  • Fixed an UnsupportedOperationException in FragmentContainerView when the FragmentContainerView class is obfuscated. ( b/142657034 )

مشکلات شناخته شده

  • Fragments referenced only via the class or android:name attribute on a FragmentContainerView are not kept by ProGuard automatically, requiring that you manually add a keep rule for each fragment class. We have disabled the Lint rule suggesting moving to FragmentContainerView until this is fixed via aapt2 . ( b/142601969 )

Version 1.2.0-beta02

11 اکتبر 2019

androidx.fragment:fragment:1.2.0-beta02 , androidx.fragment:fragment-ktx:1.2.0-beta02 , and androidx.fragment:fragment-testing:1.2.0-beta02 are released. Version 1.2.0-beta02 contains these commits .

رفع اشکال

  • Fixed an issue where Fragment's onInflate() did not receive proper attributes from FragmentContainerView , breaking cases such as NavHostFragment . ( b/142421837 )

Version 1.2.0-beta01

9 اکتبر 2019

androidx.fragment:fragment:1.2.0-beta01 , androidx.fragment:fragment-ktx:1.2.0-beta01 , and androidx.fragment:fragment-testing:1.2.0-beta01 are released. Version 1.2.0-beta01 contains these commits .

ویژگی های جدید

  • FragmentContainerView adds support for adding an initial fragment with added support for the android:name and optional android:tag XML attributes. Unlike the <fragment> tag, FragmentContainerView uses a normal FragmentTransaction under the hood to add the initial fragment, allowing further FragmentTransaction operations on the FragmentContainerView and enables the usage of View Binding for the layout. ( b/139830628 , b/141177981 )
  • Fragments now contains a Lint warning offering a quick fix to replace <fragment> with FragmentContainerView . ( b/139830056 )

رفع اشکال

  • Fixed a ClassCastException when using androidx.transition . ( b/140680619 )
  • When using Transition 1.3.0-beta01 , Fragments now wait for androidx.transition transitions (in addition to framework transitions and animations, which were fixed in Fragment 1.2.0-alpha03 and Fragment 1.2.0-alpha02 , respectively) to finish before dispatching onDestroyView() . ( aosp/1119841 )
  • When using Transition 1.3.0-beta01 , Fragments now properly cancel androidx.transition transitions before starting new transitions / animations on the same container. ( aosp/1119841 )
  • Fixed an issue on API 17 and lower when using androidx.transition transitions on the root view of your Fragment when using FragmentContainerView . ( b/140361893 )
  • The fragment-testing artifact now depends on AndroidX Test 1.2.0 , fixing an incompatibility with the latest Espresso 3.2.0. ( b/139100149 )
  • Removed usage of Log.w in FragmentManager. ( aosp/1126468 )

مشکلات شناخته شده

  • Fragment's onInflate() do not receive proper attributes from FragmentContainerView , breaking cases such as NavHostFragment . ( b/142421837 )

Version 1.2.0-alpha04

18 سپتامبر 2019

androidx.fragment:fragment:1.2.0-alpha04 , androidx.fragment-ktx:example:1.2.0-alpha04 , and androidx.fragment:fragment-testing:1.2.0-alpha04 are released. Version 1.2.0-alpha04 contains these commits .

API changes

  • The getFragmentManager() and requireFragmentManager() methods on Fragment have been deprecated and replaced with a single getParentFragmentManager() method, which returns the non-null FragmentManager the Fragment is added to (you can use isAdded() to determine if it is safe to زنگ زدن). ( b/140574496 )
  • The static FragmentManager.enableDebugLogging method has been deprecated. FragmentManager now respects Log.isLoggable() for the tag FragmentManager , allowing you to enable either DEBUG or VERBOSE logging without re-compiling your app. ( aosp/1116591 )

رفع اشکال

  • Fragments are now properly destroyed while exit animations on other fragments are running. ( b/140574199 )
  • Fixed an issue where Fragments would call Activity.findViewById() where before it did not. ( aosp/1116431 )

Version 1.2.0-alpha03

5 سپتامبر 2019

androidx.fragment:fragment:1.2.0-alpha03 , androidx.fragment:fragment-ktx:1.2.0-alpha03 , and androidx.fragment:fragment-testing:1.2.0-alpha03 are released. The commits included in this version can be found here .

API changes

رفع اشکال

  • FragmentContainerView now properly reverses the draw order when popping fragments off the back stack. ( b/139104187 )
  • Fixed an issue where the wrong animation would run when both popping a fragment and adding a new fragment at the same time. ( b/111659726 )
  • Fragments now wait for transitions (in addition to animations, which was fixed in Fragment 1.2.0-alpha02 ) to finish before dispatching onDestroyView() . ( b/138741697 )

Version 1.2.0-alpha02

7 آگوست 2019

androidx.fragment:fragment:1.2.0-alpha02 , androidx.fragment:fragment-ktx:1.2.0-alpha02 , and androidx.fragment:fragment-testing:11.2.0-alpha02 is released. The commits included in this version can be found here .

ویژگی های جدید

  • SavedStateViewModelFactory is now the default factory used when using by viewModels() , by activityViewModels() , the ViewModelProvider constructor, or ViewModelProviders.of() with a Fragment . ( b/135716331 )
  • The default animations when using TRANSIT_FRAGMENT_OPEN , TRANSIT_FRAGMENT_CLOSE , TRANSIT_FRAGMENT_FADE with setTransition on a FragmentTransaction have been updated to match the animations used by activities on Android 10 devices. ( aosp/1012812 , aosp/1014730 )

API changes

  • Introduces FragmentContainerView as the strongly recommended container for dynamically added Fragments, replacing usage of FrameLayout , etc. as it fixes animation z-ordering issues and window insets dispatching to Fragments. ( b/37036000 , aosp/985243 , b/136494650 )
  • Added a static FragmentManager.findFragment(View) method to retrieve the containing Fragment from a view inflated by a fragment. A Kotlin extension is also available in fragment-ktx . ( aosp/1090757 )
  • Added new overloads of add() and replace() on FragmentTransaction that take a Class<? extends Fragment> and optional Bundle of arguments. These methods use your FragmentFactory to construct an instance of the Fragment to add. Kotlin extension that use reified types (ie, fragmentTransaction.replace<YourFragment>(R.id.container) ) have also been added to fragment-ktx . ( b/126124987 )
  • @MainThread annotations have been added to Fragment lifecycle callbacks. ( b/127272564 )
  • The breadcrumb title related APIs on FragmentTransaction and FragmentManager.BackStackEntry have been deprecated. ( b/138252944 )
  • The setTransitionStyle method on FragmentTransaction has been deprecated. ( aosp/1011537 )
  • Many of the methods in FragmentManager are no longer abstract . FragmentManager itself remains abstract and should not be directly instantiated or extended; you should continue to only get an existing instance from getSupportFragmentManager() , getChildFragmentManager() , etc.

رفع اشکال

  • From Fragment 1.1.0-rc04 : Fragments now correctly cancel postponed transitions on Fragments have been popped. ( b/138251858 )
  • From Fragment 1.1.0-rc03 : Fixed an issue where calling postponeEnterTransition() with a timeout more than once would not cancel previous timeouts. ( b/137797118 )
  • From Fragment 1.1.0-rc02 : Fixed a crash in FragmentPagerAdapter and FragmentStatePagerAdapter when removing the current item. ( b/137209870 )
  • Fragments now wait for animations to finish before dispatching onDestroyView() . ( b/136110528 )
  • Fragment animations from child fragments and their descendants are now properly handled when animating the parent Fragment. ( b/116675313 )
  • Fixed a NullPointerException when using shared element transitions and combining a pop and add operation. ( b/120507394 )
  • Added a workaround to IllegalStateException s when using FragmentPagerAdapter and FragmentStatePagerAdapter in Robolectric tests. ( b/137201343 )

Version 1.2.0-alpha01

2 جولای 2019

androidx.fragment:fragment:1.2.0-alpha01 , androidx.fragment:fragment-ktx:1.2.0-alpha01 , and androidx.fragment:fragment-testing:1.2.0-alpha01 are released. The commits included in this version can be found here .

ویژگی های جدید

  • FragmentManager now calls requestApplyInsets() after attaching the Fragment's view and directly before calling onViewCreated() , ensuring that your view always has the correct insets. ( b/135945162 )

رفع اشکال

  • Fixed a NullPointerException when popping a FragmentTransaction that used setPrimaryNavigationFragment() before replace() . ( b/134673465 )

Version 1.1.0

Version 1.1.0

5 سپتامبر 2019

androidx.fragment:fragment:1.1.0 , androidx.fragment:fragment-ktx:1.1.0 , and androidx.fragment:fragment-testing:1.1.0 are released. The commits included in this version can be found here .

Important Changes since 1.0.0

  • fragment-testing : The fragment-testing artifact provides a FragmentScenario class for testing a fragment in isolation. See Test your app's fragments documentation for more details.
  • FragmentFactory : You can now set a FragmentFactory on a FragmentManager to manage the creation of fragment instances, removing the strict requirement to have a no-argument constructor.
  • Kotlin Property Delegates for ViewModels : The fragment-ktx artifact now contains two Kotlin property delegates: by viewModels() for accessing ViewModels associated with the individual fragment and by activityViewModels() for accessing ViewModels scoped to the activity.
  • Max Lifecycle : You can now set a max Lifecycle state for a Fragment by calling setMaxLifecycle() on a FragmentTransaction . This replaces the now deprecated setUserVisibleHint() . FragmentPagerAdapter and FragmentStatePagerAdapter have a new constructor that allows you to switch to the new behavior.
  • FragmentActivity LayoutId constructor : Subclasses of FragmentActivity can now optionally call into a constructor on FragmentActivity that takes an R.layout ID, indicating the layout that should be set as the content view as an alternative to calling setContentView() in onCreate() . This does not change the requirement that your subclass have a no-argument constructor.
  • Fragment LayoutId constructor : Subclasses of Fragment can now optionally call into a constructor on Fragment that takes an R.layout ID, indicating the layout that should be used for this fragment as an alternative to overriding onCreateView() . The inflated layout can be configured in onViewCreated() .
  • Postpone with a timeout : A new overload of postponeEnterTransition() has been added that takes a timeout.

Version 1.1.0-rc04

7 آگوست 2019

androidx.fragment:fragment:1.1.0-rc04 , androidx.fragment:fragment-ktx:1.1.0-rc04 , and androidx.fragment:fragment-testing:1.1.0-rc04 is released. The commits included in this version can be found here .

رفع اشکال

  • Fragments now correctly cancel postponed transitions on Fragments have been popped. ( b/138251858 )

Version 1.1.0-rc03

19 جولای 2019

androidx.fragment:fragment:1.1.0-rc03 , androidx.fragment:fragment-ktx:1.1.0-rc03 , and androidx.fragment:fragment-testing:1.1.0-rc03 is released. The commits included in this version can be found here .

رفع اشکال

  • Fixed an issue where calling postponeEnterTransition() with a timeout more than once would not cancel previous timeouts. ( b/137797118 )

Version 1.1.0-rc02

17 جولای 2019

androidx.fragment:fragment:1.1.0-rc02 , androidx.fragment:fragment-ktx:1.1.0-rc02 , and androidx.fragment-testing:fragment:1.1.0-rc02 are released. The commits included in this version can be found here .

رفع اشکال

  • Fixed a crash in FragmentPagerAdapter and FragmentStatePagerAdapter when removing the current item. ( b/137209870 )

Version 1.1.0-rc01

2 جولای 2019

androidx.fragment:fragment:1.1.0-rc01 , androidx.fragment:fragment-ktx:1.1.0-rc01 , and androidx.fragment:fragment-testing:1.1.0-rc01 are released. The commits included in this version can be found here .

رفع اشکال

  • Fragments now properly update their visibility when using show() or hide() operations while the transition is running. ( b/133385058 )
  • Fixed a NullPointerException when popping a FragmentTransaction that used setPrimaryNavigationFragment() before replace() . ( b/134673465 )

نسخه 1.1.0-beta01

5 ژوئن 2019

androidx.fragment:fragment:1.1.0-beta01 , androidx.fragment:fragment-ktx:1.1.0-beta01 , and androidx.fragment:fragment-testing:1.1.0-beta01 are released. The commits included in this version can be found here .

رفع اشکال

  • androidx.lifecycle.Lifecycle callbacks (specifically related to STARTED , RESUMED , PAUSED , STOPPED , and DESTROYED ) for nested Fragments are now properly nested. ( b/133497591 )
  • OnBackPressedCallback instances registered in a Fragment's onCreate() now properly take precedence over the child FragmentManager. ( b/133175997 )
  • Child fragments are no longer animated when their parent fragment is being replaced. ( b/121017790 )
  • Fragments animations and transitions are now ignored when using animateLayoutChanges="true" , fixing an issue where Fragments were not properly destroyed. ( b/116257087 )

Version 1.1.0-alpha09

16 مه 2019

androidx.fragment:fragment:1.1.0-alpha09 , androidx.fragment:fragment-ktx:1.1.0-alpha09 , and androidx.fragment:fragment-testing:1.1.0-alpha09 are released. The commits included in this version can be found here .

API changes

  • Fragments now receive a callback to a new onPrimaryNavigationFragmentChanged(boolean) method when the primary navigation fragment changes. aosp/960857

رفع اشکال

  • Menu Items inflated by a child Fragment are now correctly removed when the Parent Fragment is removed. b/131581013

Version 1.1.0-alpha08

7 مه 2019

androidx.fragment:fragment:1.1.0-alpha08 , androidx.fragment:fragment-ktx:1.1.0-alpha08 , and androidx.fragment:fragment-testing:1.1.0-alpha08 are released. The commits included in this version can be found here .

This release is incompatible with Preferences 1.1.0-alpha01 through 1.1.0-alpha04. Please upgrade to Preferences 1.1.0-alpha05 when using this version of Fragments.

ویژگی های جدید

  • Added a new overload of postponeEnterTransition() that takes a timeout, after which the Fragment will automatically call startPostponedEnterTransition() b/120803208

API changes

  • Breaking change: the previously deprecated FragmentFactory instantiate method that took a Bundle has been removed. aosp/953856
  • Breaking change: The RESUME_ONLY_CURRENT_FRAGMENT and USE_SET_USER_VISIBLE_HINT constants in FragmentPagerAdapter and FragmentStatePagerAdapter have been renamed to BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT and BEHAVIOR_SET_USER_VISIBLE_HINT , respectively. aosp/954782

رفع اشکال

  • Fragments that have had their lifecycle capped via setMaxLifecycle() no longer get resumed before reaching their final state. b/131557151
  • When using setMaxLifecycle(Lifecycle.State.CREATED) , Fragments will properly have their view destroyed. aosp/954180

Version 1.1.0-alpha07

25 آوریل 2019

androidx.fragment:fragment:1.1.0-alpha07 , androidx.fragment:fragment-ktx:1.1.0-alpha07 , and androidx.fragment:fragment-testing:1.1.0-alpha07 are released. The commits included in this version can be found here .

ویژگی های جدید

  • You can now set a max Lifecycle state for a Fragment by calling setMaxLifecycle() on a FragmentTransaction . This replaces the now deprecated setUserVisibleHint() . FragmentPagerAdapter and FragmentStatePagerAdapter have a new constructor that allows you to switch to the new behavior. ( b/129780800 )

تغییرات API

  • moveToState(STARTED) on FragmentScenario can now only be called on API 24+ devices. ( b/129880016 )

تغییرات رفتار

  • As a consequence of ( b/129907905 ), fragments on the back stack will not get a callback to onCreateView() when the hosting activity is recreated. onCreateView() will now only be called when the fragment becomes visible (ie, the back stack is popped).

رفع اشکال

  • Fixed an issue when using a <fragment> tag in XML and the contentLayoutId constructor of FragmentActivity or AppCompatActivity . ( b/129907905 )
  • Corrected an issue where fragments on the back stack would not be moved to at least CREATED after a configuration change, causing ViewModels and child retained fragments to not be properly disposed. ( b/129593351 )
  • Fixed a crash in restoreSaveState caused by a desync of the retained fragments after the instance state is saved. ( b/130433793 ) ( aosp/947824 )
  • Fixed issues where an OnBackPressedCallback added with a fragment lifecycle would not be called if the FragmentManager had a back stack. See androidx.activity 1.0.0-alpha07 for more details. ( aosp/948209 )
  • Fragments no longer enforce LAYER_TYPE_HARDWARE for animations. If you specifically need a hardware layer animation, please set it as part of your animation. ( b/129486478 )

Version 1.1.0-alpha06

3 آوریل 2019

androidx.fragment:fragment:1.1.0-alpha06 , androidx.fragment:fragment-ktx:1.1.0-alpha06 , and androidx.fragment:fragment-testing:1.1.0-alpha06 are released. The commits included in this version can be found here .

ویژگی های جدید

  • Exceptions thrown by FragmentManager now include the Fragment's name in the message. ( b/67759402 )

تغییرات API

  • Fragment and FragmentActivity now contain a second constructor that takes a @LayoutRes int , which replaces the previous behavior of annotating your class with @ContentView . This approach works in both app and library modules. ( b/128352521 )
  • FragmentActivity's onActivityResult() is now properly marked as @CallSuper . ( b/127971684 )
  • The FragmentFactory's instantiate method that takes an argument Bundle has been deprecated and apps should use the new instantiate overload that does not take a Bundle. ( b/128836103 )
  • FragmentScenario methods are now properly annotated with @StyleRes . ( aosp/924193 )
  • FragmentTabHost has been deprecated. ( b/127971835 )
  • FragmentActivity's getThemedContext() has been removed. ( aosp/934078 )

رفع اشکال

  • Fixed a regression in 1.1.0-alpha05 that caused the incoming Fragment to flash on the screen. ( b/129405432 )
  • Fixed an issue where the primary navigation fragment would be lost after a popBackStack+replace+popBackStack series of operations. ( b/124332597 )
  • Fixed an issue when using @ContentView constructors on your Activity when restoring Fragment state. ( b/127313094 )
  • Corrected the logic of setTargetFragment() when replacing an existing target Fragment with a Fragment not yet attached to the FragmentManager. ( aosp/932156 )

Version 1.1.0-alpha05

13 مارس 2019

androidx.fragment:fragment:1.1.0-alpha05 , androidx.fragment:fragment-ktx:1.1.0-alpha05 , and androidx.fragment:fragment-testing:1.1.0-alpha05 are released. The full list of commits included in this version can be found here .

ویژگی های جدید

  • @ContentView annotation lookups are now cached ( b/123709449 )

Behavior changes

  • Calling remove() , hide() , show() , detach() , and setPrimaryNavigationFragment() with a Fragment attached to a different FragmentManager now throws an IllegalStateException rather than silently failing ( aosp/904301 )

رفع اشکال

  • onNewIntent for FragmentActivity is now correctly marked with @CallSuper ( b/124120586 )
  • Fixed an issue where DialogFragment 's onDismiss() could be called twice when using getDialog().dismiss() or getDialog().cancel() ( b/126563750 )

نسخه 1.1.0-alpha04

7 فوریه 2019

androidx.fragment:fragment 1.1.0-alpha04 , androidx.fragment:fragment-ktx 1.1.0-alpha04 , and androidx.fragment:fragment-testing 1.1.0-alpha04 are released.

ویژگی های جدید

  • Added support for the @ContentView class annotation that allows you to indicate which layout XML file should be inflated as an alternative to overriding onCreateView() . It is recommended to do view related work in onViewCreated() . ( aosp/837619 )
  • fragment-testing now depends on androidx.test:core-ktx 1.1.0 stable ( b/121209673 )
  • You can now use openActionBarOverflowOrOptionsMenu with FragmentScenario to test Fragment hosted options menus ( b/121126668 )

API changes

  • Added a requireArguments() method which returns a @NonNull Bundle or throws an IllegalStateException ( b/121196360 )
  • Added a note that getLifecycle() , getViewLifecycleOwner() , and getViewLifecycleOwnerLiveData() should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. ( aosp/880714 )
  • Added a note that getViewModelStore() should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. ( aosp/880713 )
  • Fixed an issue with binary compatibility with previous releases of Fragments. ( aosp/887877 ) ( aosp/889834 )

رفع اشکال

  • Target fragments are correctly cleared out when you pass null to setTargetFragment() . ( aosp/849969 )
  • Fixed an issue where target Fragments were sometimes unavailable in or after onDestroy() . ( b/122312935 )
  • DialogFragment's onDismiss() is now called before onDestroy() . ( aosp/874133 ) ( aosp/890734 )

Version 1.1.0-alpha03

17 دسامبر 2018

ویژگی های جدید

  • Fragment now implements BundleSavedStateRegistryOwner and depends on the newly released SavedState library [ aosp/824380 ]
  • A by activityViewModels Kotlin property delegate has been added to retrieve ViewModels associated with the containing Activity [ b/119050253 ]
  • The by viewModels Kotlin property delegate has been expanded to take an optional lambda method for getting the ViewModelStoreOwner , allowing you to pass in the parent Fragment or other custom ViewModelStoreOwner with code such as val viewModel: MyViewModel by viewModels(::requireParentFragment) [ b/119050253 ]

API changes

  • FragmentScenario now allows you to specify a theme such as Theme.AppCompat [ b/119054431 ]. This is a breaking change.
  • Added a requireView() method which returns a @NonNull View or throws an IllegalStateException [ b/120241368 ]
  • Added a requireParentFragment() method which returns a @NonNull Fragment or throws an IllegalStateException [ b/112103783 ]

رفع اشکال

  • Fixed IllegalStateException: Failure saving state b/120814739
  • Fragments being restored from saved instance state will now always receive a non-null Bundle [ b/119794496 ]
  • Removed Fragments no longer reuse their Lifecycle object if re-added [ b/118880674 ]

نسخه 1.1.0-alpha02

3 دسامبر 2018

ویژگی های جدید

  • FragmentScenario's Kotlin extensions now let you use a lambda for Fragment construction as an alternative to passing in a FragmentFactory instance. ( aosp/812913 )

رفع اشکال

  • Fixed an IllegalStateException when using nested Fragments on the back stack ( b/119256498 )
  • Fixed crash when using FragmentScenario.recreate() with a FragmentFactory ( aosp/820540 )
  • Fixed an issue where target Fragments were not accessible after the Fragment was removed ( aosp/807634 )

نسخه 1.1.0-alpha01

5 نوامبر 2018

This is the first release of the fragment-testing artifact and FragmentScenario which is built on top of the androidx.test:core APIs. See the Fragment testing documentation for more details.

ویژگی های جدید

  • New FragmentScenario class for testing Fragments in isolation.
  • You can now set a FragmentFactory on any FragmentManager to control how new Fragment instances are instantiated.
  • Added a new by viewModels() Kotlin property delegate for retrieving ViewModels from a Fragment.
  • Pending input events (such as clicks) are now canceled in a Fragment's onStop() .

API changes

  • Significantly expanded the nullability annotations across the Fragment API surface.

رفع اشکال

  • Fix an issue which caused Fragment operations to fail from within LiveData (b/77944637)

مشکلات شناخته شده

  • Target Fragments cannot be accessed after a Fragment has been removed from the FragmentManager.
  • fragment-testing depends on androidx.test:core:1.0.0-beta01 instead of the correct androidx.test:core:1.0.0 .