Methods Summary |
---|
public final void | destroy()
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring destroy - session destroyed");
}
destroyNoCheck();
|
private void | destroyNoCheck()
stopPrinterDiscovery();
try {
mPrintManager.destroyPrinterDiscoverySession(mObserver, mUserId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error destroying printer discovery session", re);
} finally {
mObserver = null;
mPrinters.clear();
}
|
protected final void | finalize()
if (!isDestroyedNoCheck()) {
Log.e(LOG_TAG, "Destroying leaked printer discovery session");
destroyNoCheck();
}
super.finalize();
|
public final java.util.List | getPrinters()
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring get printers - session destroyed");
return Collections.emptyList();
}
return new ArrayList<PrinterInfo>(mPrinters.values());
|
private void | handlePrintersAdded(java.util.List addedPrinters)
if (isDestroyed()) {
return;
}
// No old printers - do not bother keeping their position.
if (mPrinters.isEmpty()) {
final int printerCount = addedPrinters.size();
for (int i = 0; i < printerCount; i++) {
PrinterInfo printer = addedPrinters.get(i);
mPrinters.put(printer.getId(), printer);
}
notifyOnPrintersChanged();
return;
}
// Add the printers to a map.
ArrayMap<PrinterId, PrinterInfo> addedPrintersMap =
new ArrayMap<PrinterId, PrinterInfo>();
final int printerCount = addedPrinters.size();
for (int i = 0; i < printerCount; i++) {
PrinterInfo printer = addedPrinters.get(i);
addedPrintersMap.put(printer.getId(), printer);
}
// Update printers we already have.
for (PrinterId oldPrinterId : mPrinters.keySet()) {
PrinterInfo updatedPrinter = addedPrintersMap.remove(oldPrinterId);
if (updatedPrinter != null) {
mPrinters.put(oldPrinterId, updatedPrinter);
}
}
// Add the new printers, i.e. what is left.
mPrinters.putAll(addedPrintersMap);
// Announce the change.
notifyOnPrintersChanged();
|
private void | handlePrintersRemoved(java.util.List printerIds)
if (isDestroyed()) {
return;
}
boolean printersChanged = false;
final int removedPrinterIdCount = printerIds.size();
for (int i = 0; i < removedPrinterIdCount; i++) {
PrinterId removedPrinterId = printerIds.get(i);
if (mPrinters.remove(removedPrinterId) != null) {
printersChanged = true;
}
}
if (printersChanged) {
notifyOnPrintersChanged();
}
|
public final boolean | isDestroyed()
throwIfNotCalledOnMainThread();
return isDestroyedNoCheck();
|
private boolean | isDestroyedNoCheck()
return (mObserver == null);
|
public final boolean | isPrinterDiscoveryStarted()
throwIfNotCalledOnMainThread();
return mIsPrinterDiscoveryStarted;
|
private void | notifyOnPrintersChanged()
if (mListener != null) {
mListener.onPrintersChanged();
}
|
public final void | setOnPrintersChangeListener(android.print.PrinterDiscoverySession$OnPrintersChangeListener listener)
throwIfNotCalledOnMainThread();
mListener = listener;
|
public final void | startPrinterDiscovery(java.util.List priorityList)
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring start printers discovery - session destroyed");
return;
}
if (!mIsPrinterDiscoveryStarted) {
mIsPrinterDiscoveryStarted = true;
try {
mPrintManager.startPrinterDiscovery(mObserver, priorityList, mUserId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error starting printer discovery", re);
}
}
|
public final void | startPrinterStateTracking(PrinterId printerId)
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring start printer state tracking - session destroyed");
return;
}
try {
mPrintManager.startPrinterStateTracking(printerId, mUserId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error starting printer state tracking", re);
}
|
public final void | stopPrinterDiscovery()
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring stop printers discovery - session destroyed");
return;
}
if (mIsPrinterDiscoveryStarted) {
mIsPrinterDiscoveryStarted = false;
try {
mPrintManager.stopPrinterDiscovery(mObserver, mUserId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error stopping printer discovery", re);
}
}
|
public final void | stopPrinterStateTracking(PrinterId printerId)
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring stop printer state tracking - session destroyed");
return;
}
try {
mPrintManager.stopPrinterStateTracking(printerId, mUserId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error stopping printer state tracking", re);
}
|
private static void | throwIfNotCalledOnMainThread()
if (!Looper.getMainLooper().isCurrentThread()) {
throw new IllegalAccessError("must be called from the main thread");
}
|
public final void | validatePrinters(java.util.List printerIds)
if (isDestroyed()) {
Log.w(LOG_TAG, "Ignoring validate printers - session destroyed");
return;
}
try {
mPrintManager.validatePrinters(printerIds, mUserId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error validating printers", re);
}
|