Follow

Upgrading version 2.0.0 to 2.1.0

The standard KGDocumentPicker is now deprecated. You should change your projects to use either theKGDocumentLinearPicker (visually identical to the KGDocumentPicker) or the newKGDocumentGridPicker as the deprecated picker is liable to be removed from subsequent versions of the framework.

The following changes are needed to switch to KGDocumentLinearPicker or KGDocumentGridPicker.

In DocumentPickerViewController.java you need to change the type of the documentPicker instance variable to eitherKGDocumentLinearPicker or KGDocumentGridPicker.

  private DocumentLinearPicker documentPicker;

You will also need to adapt any assignments you make to the instance variable in code to cast to the right class.

    documentPicker = (DocumentLinearPicker)findViewById(R.id.documentPicker);

You also need to update the type of the picker in the layout file documentpickerview.xml:

    <com.kaldorgroup.pugpig.ui.DocumentLinearPicker
            android:id="@+id/documentPicker"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="@android:color/transparent"/>

Updated DocumentPickerDelegate interface

Whether you update your picker class or not, you must update your DocumentPickerDelegate as the methods have changed.

The signatures of the documentPickerDidAddControlsForDocumentdocumentPickerDidRefreshDocument anddocumentPickerWillRenderDocument methods need changing in DocumentPickerViewController. The type of first argument needs be changed to AbstractDocumentPicker to account for alternative document pickers such as the KGDocumentGridPicker or theKGDocumentLinearPicker which supersedes the KGDocumentPicker.

  @Override
  public void documentPickerDidAddControlsForDocument(AbstractDocumentPicker picker, Document document, View view)
  @Override
  public void documentPickerDidRefreshDocument(AbstractDocumentPicker picker, Document document, View view)
  @Override
  public void documentPickerWillRenderDocument(AbstractDocumentPicker picker, Document document, View view, float offset)

You must add a documentPickerDidRemoveDocument method to DocumentPickerViewController in order to conform to the updatedDocumentPickerDelegate interface.

  @Override
  public boolean documentPickerDidRemoveDocument(AbstractDocumentPicker picker, Document document, View view) {
    return true;
  }

Important note if you are using a downloadDelegateButton

If you implemented a downloadDelegateButton with an assigned listener in the old DocumentPicker class, you must have code similar to the following:

mainActionButton.setOnClickListener(new View.OnClickListener() {
@Override
  public void onClick(View view) {
    processOpenButtonPressed();
  }
});
public void processOpenButtonPressed() {
  AppDelegate appDelegate = (AppDelegate) Application.delegate();
  switch (currentDocument.state()) {
    case DocumentStates.Downloaded:
      appDelegate.openDocument(currentDocument);
      break;
    case DocumentStates.New:
      appDelegate.downloadDocument(currentDocument);
      break;
    case DocumentStates.Updated:
      appDelegate.downloadDocument(currentDocument);
      break;
    default:
      break;
  }
}

The new DocumentLinearPicker class correctly implements the downloadDelegateButton to trigger the same behaviour as the framework supplied download button, i.e., triggering Download/Update functionalities if the device is online and new content is available or Read/View if a copy of the available content already exists on the device.

This means that one should remove the above code and must not implement its own listener and connect it to the download button as the DocumentLinearPicker class already takes care of that and doing so will affect the performance and functionality of the application.

Note regarding KGDocumentGridPicker

Some methods are specific to the KGDocumentLinearPicker and will cause compiler warning if you choose to use theKGDocumentGridPicker. E.g.

    documentPicker.setShouldSnap(true);

Such lines must be removed or at least commented out in order to use the grid picker.

Other fixes

Add the following code to the viewDidUnload()method in DocumentViewController to properly unload it.

    searchControl = null;
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk