Class DocumentComparisonDialog

  • All Implemented Interfaces:

    
    public class DocumentComparisonDialog
    
                        

    Dialog for visually comparing two versions of a document. This dialog offers a point selection wizard, that will guide users through the process of aligning two documents with each other, so that visual comparison can be performed. Show this dialog by calling show. To make sure the dialog is restored properly across configuration changes, call restore within your activity's onCreate() method.

    
    class MyActivity : FragmentActivity(), ComparisonDialogListener {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            if(savedInstanceState != null) {
                // If this activity is recreated after a configuration change, calling restore() ensures that the document will have the
                // correct callback (this activity) if it was shown before the configuration change. If no dialog was shown, this call is a
                // no-op.
                DocumentComparisonDialogImpl.restore(this, this)
            }
        }
    
        fun showComparisonDialog() {
           val outputFile = filesDir.resolve("comparison-result.pdf")
           val oldDocument = ComparisonDocument(oldDocumentSource, 0, Color.GREEN)
           val newDocument = ComparisonDocument(newDocumentSource, 0, Color.RED)
           DocumentComparisonDialog.show(this, configuration, oldDocument, newDocument, outputFile, this)
        }
    
        // ...
    }
    
    • Constructor Detail

      • DocumentComparisonDialog

        DocumentComparisonDialog()
    • Method Detail

      • restore

         static void restore(@NonNull() FragmentActivity fragmentActivity, @NonNull() ComparisonDialogListener listener)

        Restores the document comparison dialog after a configuration change. This method has to be called after recreating the hosting activity to reset the callback object. This should be called inside the activity's `onCreate()` method.

        
        class MyActivity : FragmentActivity(), ComparisonDialogListener {
            override fun onCreate(savedInstanceState: Bundle?) {
                super.onCreate(savedInstanceState)
                if(savedInstanceState != null) {
                    // If this activity is recreated after a configuration change, calling restore() ensures that the document will have the
                    // correct callback (this activity) if it was shown before the configuration change. If no dialog was shown, this call is a
                    // no-op.
                    DocumentComparisonDialogImpl.restore(this, this)
                }
            }
        
            // ...
        }
        
        Parameters:
        fragmentActivity - Activity that hosts the document comparison dialog fragment.
        listener - ComparisonDialogListener to set on any visible comparison dialog.