Fragment

FragmentTransaction - setCustomAnimations()

  1. fragment ๊ฐ€ add ํ˜น์€ replace ๋  ๋•Œ animation ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Œ.

  2. transaction ํ๋ฆ„ ๋‚ด์—์„œ setCustomAnimations ํ˜ธ์ถœ์„ add, replace ๋ณด๋‹ค ๋’ค์—์„œ ํ•  ๊ฒฝ์šฐ animation ์ด ์ ์šฉ๋˜์ง€ ์•Š์Œ

  3. addToBackStack() ์œผ๋กœ fragment ๋ฅผ backStack ์— ๋„ฃ๋Š” ๊ฒฝ์šฐ์™€ ๋„ฃ์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์†Œ๊ฐ€ ๋‹ค๋ฆ„

setCustomAnimations(int i1, int i2) // addToBackStack X
setCustomAnimations(int i1, int i2, int i3, int i4) // addToBackStack O

FragmentTransaction - commitAllowingStateLoss()

์ผ๋ฐ˜์ ์œผ๋กœ activity ์˜ onSaveInstance() ๊ฐ€ ํ˜ธ์ถœ๋œ ์ดํ›„ commit ์„ ํ˜ธ์ถœ ํ•  ๊ฒฝ์šฐ exception ๋ฐœ์ƒํ•จ.

ํ•ด๋‹น ๋ฉ”์†Œ๋“œ๋ฅผ ์“ฐ๋ฉด activity ์˜ onSaveInstance ํ˜ธ์ถœ ์ดํ›„ ํ•ด๋‹น ๋ฉ”์†Œ๋“œ๊ฐ€ ๋ถˆ๋ ค๋„, exception ์ด throw ๋˜์ง€ ์•Š๊ณ  transaction ๋‚ด์šฉ์ด commit ๋จ. ๋‹ค๋งŒ, saveInstance ์— ์ €์žฅ๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋Š” ์ ์„ ์ธ์ง€ํ•˜๊ณ  ์‚ฌ์šฉ ํ•  ๊ฒƒ

ref : https://medium.com/inloopx/demystifying-androids-commitallowingstateloss-cb9011a544cc

Last updated

Was this helpful?