public class AnalysisFragmentStandard extends Fragment implements AnalysisFragmentInterface
When you use the Component API without the Android Support Library, the AnalyzeDocumentFragmentStandard displays the captured or imported document and an activity indicator while the document is being analyzed by the Gini API.
Note: You can use the activity indicator message to display a message under the activity indicator by overriding the string resource named gv_analysis_activity_indicator_message. The message is displayed for images only.
For PDF documents the first page is shown (only on Android 5.0 Lollipop and newer) along with the PDF's filename and number of pages above the page. On Android KitKat and older only the PDF's filename is shown with the preview area left empty.
Include the AnalyzeDocumentFragmentStandard into your layout by using the AnalysisFragmentStandard.createInstance(Document, String) factory method to create an instance and display it using the android.app.FragmentManager.
An AnalysisFragmentListener instance must be available until the AnalysisFragmentStandard is attached to an activity. Failing to do so will throw an exception.
The listener instance can be provided either implicitly by making the hosting Activity implement the AnalysisFragmentListener interface or explicitly by
setting the listener using AnalysisFragmentCompat.setListener(AnalysisFragmentListener).
Your Activity is automatically set as the listener in AnalysisFragmentStandard.onCreate(Bundle).
See the AnalysisActivity for details.
| Constructor and Description |
|---|
AnalysisFragmentStandard() |
| Modifier and Type | Method and Description |
|---|---|
static AnalysisFragmentStandard |
createInstance(Document document,
java.lang.String documentAnalysisErrorMessage)
Factory method for creating a new instance of the Fragment using the provided document.
|
void |
hideError()
Call this method to hide the error shown before with
AnalysisFragmentInterface.showError(String, String, View.OnClickListener) or
AnalysisFragmentInterface.showError(String, int). |
void |
onDocumentAnalyzed()
You should call this method after you've received the analysis results from the Gini API.
|
void |
onNoExtractionsFound()
You should call this method after you've received the analysis results from the Gini API
without the required extractions.
|
void |
setListener(AnalysisFragmentListener listener)
Set a listener for analysis events.
|
void |
showAlertDialog(java.lang.String message,
java.lang.String positiveButtonTitle,
DialogInterface.OnClickListener positiveButtonClickListener,
java.lang.String negativeButtonTitle,
DialogInterface.OnClickListener negativeButtonClickListener,
DialogInterface.OnCancelListener cancelListener) |
void |
showError(java.lang.String message,
int duration)
Call this method when you need to show an error message to the user in the Analysis
Screen.
|
void |
showError(java.lang.String message,
java.lang.String buttonTitle,
View.OnClickListener onClickListener)
Call this method when you need to show an error message with an invokable action to the user
in the Analysis Screen.
|
void |
startScanAnimation()
You should call this method when you start the document analysis using the Gini API.
|
void |
stopScanAnimation()
You should call this method when the document analysis has finished.
|
public void hideError()
AnalysisFragmentInterface
Call this method to hide the error shown before with
AnalysisFragmentInterface.showError(String, String, View.OnClickListener) or
AnalysisFragmentInterface.showError(String, int).
hideError in interface AnalysisFragmentInterfacepublic void onNoExtractionsFound()
AnalysisFragmentInterfaceYou should call this method after you've received the analysis results from the Gini API without the required extractions.
onNoExtractionsFound in interface AnalysisFragmentInterfacepublic void onDocumentAnalyzed()
AnalysisFragmentInterfaceYou should call this method after you've received the analysis results from the Gini API.
onDocumentAnalyzed in interface AnalysisFragmentInterfacepublic void showError(java.lang.String message,
java.lang.String buttonTitle,
View.OnClickListener onClickListener)
AnalysisFragmentInterfaceCall this method when you need to show an error message with an invokable action to the user in the Analysis Screen.
showError in interface AnalysisFragmentInterfacemessage - a short error messagebuttonTitle - if not null and not empty, shows a button with the given titleonClickListener - listener for the buttonpublic void showError(java.lang.String message,
int duration)
AnalysisFragmentInterfaceCall this method when you need to show an error message to the user in the Analysis Screen.
showError in interface AnalysisFragmentInterfacemessage - a short error messageduration - how long should the error message be shown in mspublic void startScanAnimation()
AnalysisFragmentInterfaceYou should call this method when you start the document analysis using the Gini API.
startScanAnimation in interface AnalysisFragmentInterfacepublic void stopScanAnimation()
AnalysisFragmentInterfaceYou should call this method when the document analysis has finished.
stopScanAnimation in interface AnalysisFragmentInterfacepublic void setListener(AnalysisFragmentListener listener)
AnalysisFragmentInterfaceSet a listener for analysis events.
By default the hosting Activity is expected to implement
the AnalysisFragmentListener. In case that is not feasible you may set the
listener using this method.
Note: the listener is expected to be available until the fragment is attached to an activity. Make sure to set the listener before that.
setListener in interface AnalysisFragmentInterfacelistener - AnalysisFragmentListener instancepublic static AnalysisFragmentStandard createInstance(Document document, java.lang.String documentAnalysisErrorMessage)
Factory method for creating a new instance of the Fragment using the provided document.
You may pass in an optional analysis error message. This error message is shown to the user with a retry button.
Note: Always use this method to create new instances. Document is required and an exception is thrown if it's missing.
document - must be the Document from (Document)documentAnalysisErrorMessage - an optional error message shown to the userpublic void showAlertDialog(java.lang.String message,
java.lang.String positiveButtonTitle,
DialogInterface.OnClickListener positiveButtonClickListener,
java.lang.String negativeButtonTitle,
DialogInterface.OnClickListener negativeButtonClickListener,
DialogInterface.OnCancelListener cancelListener)