@@ -59,7 +59,6 @@ class PdfViewerKotlinSnippets {
5959 }
6060 // [END android_pdf_viewer_create_compat_activity_kotlin]
6161
62-
6362 // [START android_pdf_viewer_extend_fragment_kotlin]
6463 @RequiresExtension(extension = Build .VERSION_CODES .S , version = 13 )
6564 class PdfViewerFragmentExtended : PdfViewerFragment () {
@@ -102,18 +101,18 @@ class PdfViewerKotlinSnippets {
102101 if (pdfViewerFragment == null ) {
103102 val fragmentManager: FragmentManager = supportFragmentManager
104103
105- // Fragment initialization.
106- pdfViewerFragment = PdfViewerFragmentExtended ()
107- val transaction: FragmentTransaction = fragmentManager.beginTransaction()
108-
109- // Replace an existing fragment in a container with an instance of a new fragment.
110- transaction.replace(
111- R .id.fragment_container_view,
112- pdfViewerFragment!! ,
113- PDF_VIEWER_FRAGMENT_TAG
114- )
115- transaction.commitAllowingStateLoss()
116- fragmentManager.executePendingTransactions()
104+ // Fragment initialization.
105+ pdfViewerFragment = PdfViewerFragmentExtended ()
106+ val transaction: FragmentTransaction = fragmentManager.beginTransaction()
107+
108+ // Replace an existing fragment in a container with an instance of a new fragment.
109+ transaction.replace(
110+ R .id.fragment_container_view,
111+ pdfViewerFragment!! ,
112+ PDF_VIEWER_FRAGMENT_TAG
113+ )
114+ transaction.commitAllowingStateLoss()
115+ fragmentManager.executePendingTransactions()
117116 }
118117 }
119118
@@ -150,7 +149,7 @@ class PdfViewerKotlinSnippets {
150149 }
151150
152151 /* * Enable nested classes. **/
153- class ClassHolder3 : AppCompatActivity () {
152+ class ClassHolder3 : AppCompatActivity () {
154153
155154 private var pdfViewerFragment: PdfViewerFragment ? = null
156155
@@ -162,13 +161,13 @@ class PdfViewerKotlinSnippets {
162161 if (pdfViewerFragment == null ) {
163162 pdfViewerFragment =
164163 supportFragmentManager
165- .findFragmentByTag(PDF_VIEWER_FRAGMENT_TAG ) as PdfViewerFragment ?
164+ .findFragmentByTag(PDF_VIEWER_FRAGMENT_TAG ) as PdfViewerFragment ?
166165 }
167166
168167 }
169168
170169 // [START android_pdf_viewer_launch_file_picker_kotlin]
171- @RequiresExtension(extension= Build .VERSION_CODES .S , version= 13 )
170+ @RequiresExtension(extension = Build .VERSION_CODES .S , version = 13 )
172171 class MainActivity : AppCompatActivity () {
173172 private var pdfViewerFragment: PdfViewerFragment ? = null
174173 private var filePicker =
@@ -198,19 +197,19 @@ class PdfViewerKotlinSnippets {
198197 // [END android_pdf_viewer_launch_file_picker_kotlin]
199198
200199 // [START android_pdf_viewer_style_fragment_kotlin]
201- @RequiresExtension(extension= Build .VERSION_CODES .S , version= 13 )
200+ @RequiresExtension(extension = Build .VERSION_CODES .S , version = 13 )
202201 private fun initialisePdfViewerFragment () {
203202 // This condition can be skipped if you want to create a new fragment everytime
204203 if (pdfViewerFragment == null ) {
205- val fragmentManager: FragmentManager = supportFragmentManager
204+ val fragmentManager: FragmentManager = supportFragmentManager
206205
207- // Create styling options
208- val stylingOptions = PdfStylingOptions (R .style.pdfContainerStyle)
206+ // Create styling options
207+ val stylingOptions = PdfStylingOptions (R .style.pdfContainerStyle)
209208
210- // Fragment initialization
211- pdfViewerFragment = PdfViewerFragment .newInstance(stylingOptions)
209+ // Fragment initialization
210+ pdfViewerFragment = PdfViewerFragment .newInstance(stylingOptions)
212211
213- // .. execute fragment transaction
212+ // .. execute fragment transaction
214213 }
215214 }
216215 // [END android_pdf_viewer_style_fragment_kotlin]
@@ -219,11 +218,10 @@ class PdfViewerKotlinSnippets {
219218 private const val PDF_VIEWER_FRAGMENT_TAG = " pdf_viewer_fragment_tag"
220219 }
221220
222- }
223221
224222 // [START android_pdf_viewer_style_fragment_constructor_kotlin]
225- @RequiresExtension(extension= Build .VERSION_CODES .S , version= 13 )
226- class StyledPdfViewerFragment : PdfViewerFragment {
223+ @RequiresExtension(extension = Build .VERSION_CODES .S , version = 13 )
224+ class StyledPdfViewerFragment : PdfViewerFragment {
227225
228226 constructor () : super ()
229227
@@ -242,7 +240,7 @@ class PdfViewerKotlinSnippets {
242240 class ClassHolder4 {
243241
244242 // [START android_pdf_viewer_full_code_kotlin]
245- @RequiresExtension(extension= Build .VERSION_CODES .S , version= 13 )
243+ @RequiresExtension(extension = Build .VERSION_CODES .S , version = 13 )
246244 class MainActivity : AppCompatActivity () {
247245
248246 private var pdfViewerFragment: PdfViewerFragment ? = null
@@ -261,7 +259,7 @@ class PdfViewerKotlinSnippets {
261259 if (pdfViewerFragment == null ) {
262260 pdfViewerFragment =
263261 supportFragmentManager
264- .findFragmentByTag(PDF_VIEWER_FRAGMENT_TAG ) as PdfViewerFragment ?
262+ .findFragmentByTag(PDF_VIEWER_FRAGMENT_TAG ) as PdfViewerFragment ?
265263 }
266264
267265 val getContentButton: MaterialButton = findViewById(R .id.launch_button)
@@ -278,23 +276,23 @@ class PdfViewerKotlinSnippets {
278276 if (pdfViewerFragment == null ) {
279277 val fragmentManager: FragmentManager = supportFragmentManager
280278
281- // Create styling options
282- // val stylingOptions = PdfStylingOptions(R.style.pdfContainerStyle)
283-
284- // Fragment initialization
285- // For customization
286- // pdfViewerFragment = PdfViewerFragment.newInstance(stylingOptions)
287- pdfViewerFragment = PdfViewerFragmentExtended ()
288- val transaction: FragmentTransaction = fragmentManager.beginTransaction()
289-
290- // Replace an existing fragment in a container with an instance of a new fragment
291- transaction.replace(
292- R .id.fragment_container_view,
293- pdfViewerFragment!! ,
294- PDF_VIEWER_FRAGMENT_TAG
295- )
296- transaction.commitAllowingStateLoss()
297- fragmentManager.executePendingTransactions()
279+ // Create styling options
280+ // val stylingOptions = PdfStylingOptions(R.style.pdfContainerStyle)
281+
282+ // Fragment initialization
283+ // For customization
284+ // pdfViewerFragment = PdfViewerFragment.newInstance(stylingOptions)
285+ pdfViewerFragment = PdfViewerFragmentExtended ()
286+ val transaction: FragmentTransaction = fragmentManager.beginTransaction()
287+
288+ // Replace an existing fragment in a container with an instance of a new fragment
289+ transaction.replace(
290+ R .id.fragment_container_view,
291+ pdfViewerFragment!! ,
292+ PDF_VIEWER_FRAGMENT_TAG
293+ )
294+ transaction.commitAllowingStateLoss()
295+ fragmentManager.executePendingTransactions()
298296 }
299297 }
300298
0 commit comments