Update print jobs appropriately in the print settings.
- Always use a fresh print job as once the print job goes away it cannot be read. Before we were stuck with the last state which might not been the last state - make loaders relative to fragment to avoid loader id duplications with other ids of the activity. Fixes: 28315242 Change-Id: I57eeb64b44b5d77b2092c22b175407131f7baf97
This commit is contained in:
@@ -63,7 +63,6 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
private Preference mMessagePreference;
|
private Preference mMessagePreference;
|
||||||
|
|
||||||
private PrintJobId mPrintJobId;
|
private PrintJobId mPrintJobId;
|
||||||
private PrintJob mPrintJob;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
@@ -134,19 +133,23 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
PrintJob printJob = getPrintJob();
|
||||||
|
|
||||||
|
if (printJob != null) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case MENU_ITEM_ID_CANCEL: {
|
case MENU_ITEM_ID_CANCEL: {
|
||||||
getPrintJob().cancel();
|
printJob.cancel();
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MENU_ITEM_ID_RESTART: {
|
case MENU_ITEM_ID_RESTART: {
|
||||||
getPrintJob().restart();
|
printJob.restart();
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@@ -161,10 +164,7 @@ public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PrintJob getPrintJob() {
|
private PrintJob getPrintJob() {
|
||||||
if (mPrintJob == null) {
|
return mPrintManager.getPrintJob(mPrintJobId);
|
||||||
mPrintJob = mPrintManager.getPrintJob(mPrintJobId);
|
|
||||||
}
|
|
||||||
return mPrintJob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUi() {
|
private void updateUi() {
|
||||||
|
@@ -606,7 +606,7 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
|
public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
|
||||||
if (id == LOADER_ID_PRINTERS_LOADER) {
|
if (id == LOADER_ID_PRINTERS_LOADER) {
|
||||||
return new PrintersLoader(getActivity());
|
return new PrintersLoader(getContext());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -115,12 +115,10 @@ public class PrintSettingsFragment extends ProfileSettingsPreferenceFragment
|
|||||||
getPreferenceScreen().removePreference(mActivePrintJobsCategory);
|
getPreferenceScreen().removePreference(mActivePrintJobsCategory);
|
||||||
|
|
||||||
mPrintJobsController = new PrintJobsController();
|
mPrintJobsController = new PrintJobsController();
|
||||||
getActivity().getLoaderManager().initLoader(LOADER_ID_PRINT_JOBS_LOADER, null,
|
getLoaderManager().initLoader(LOADER_ID_PRINT_JOBS_LOADER, null, mPrintJobsController);
|
||||||
mPrintJobsController);
|
|
||||||
|
|
||||||
mPrintServicesController = new PrintServicesController();
|
mPrintServicesController = new PrintServicesController();
|
||||||
getActivity().getLoaderManager().initLoader(LOADER_ID_PRINT_SERVICES, null,
|
getLoaderManager().initLoader(LOADER_ID_PRINT_SERVICES, null, mPrintServicesController);
|
||||||
mPrintServicesController);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -294,7 +292,7 @@ public class PrintSettingsFragment extends ProfileSettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public Loader<List<PrintJobInfo>> onCreateLoader(int id, Bundle args) {
|
public Loader<List<PrintJobInfo>> onCreateLoader(int id, Bundle args) {
|
||||||
if (id == LOADER_ID_PRINT_JOBS_LOADER) {
|
if (id == LOADER_ID_PRINT_JOBS_LOADER) {
|
||||||
return new PrintJobsLoader(getActivity());
|
return new PrintJobsLoader(getContext());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user