Bug 982172 - Encapsulate DatasetRequest fields. r=lucasr

This commit is contained in:
Josh Dover 2014-03-17 09:06:17 -07:00
parent c01f9e4e40
commit afdd8bbb9f
2 changed files with 16 additions and 8 deletions

View File

@ -175,7 +175,7 @@ public class DynamicPanel extends HomeFragment {
bundle.putParcelable(DATASET_REQUEST, request);
// Ensure one loader per dataset
final int loaderId = generateLoaderId(request.datasetId);
final int loaderId = generateLoaderId(request.getDatasetId());
getLoaderManager().restartLoader(loaderId, bundle, mLoaderCallbacks);
}
@ -218,12 +218,12 @@ public class DynamicPanel extends HomeFragment {
final String[] selectionArgs;
// Null represents the root filter
if (mRequest.filter == null) {
if (mRequest.getFilter() == null) {
selection = DBUtils.concatenateWhere(HomeItems.DATASET_ID + " = ?", HomeItems.FILTER + " IS NULL");
selectionArgs = new String[] { mRequest.datasetId };
selectionArgs = new String[] { mRequest.getDatasetId() };
} else {
selection = DBUtils.concatenateWhere(HomeItems.DATASET_ID + " = ?", HomeItems.FILTER + " = ?");
selectionArgs = new String[] { mRequest.datasetId, mRequest.filter };
selectionArgs = new String[] { mRequest.getDatasetId(), mRequest.getFilter() };
}
// XXX: You can use CONTENT_FAKE_URI for development to pull items from fake_home_items.json.
@ -256,7 +256,7 @@ public class DynamicPanel extends HomeFragment {
final DatasetRequest request = getRequestFromLoader(loader);
Log.d(LOGTAG, "Resetting loader for request: " + request);
if (mLayout != null) {
mLayout.releaseDataset(request.datasetId);
mLayout.releaseDataset(request.getDatasetId());
}
}

View File

@ -84,8 +84,8 @@ abstract class PanelLayout extends FrameLayout {
* filter for queries on the database.
*/
public static class DatasetRequest implements Parcelable {
public final String datasetId;
public final String filter;
private final String datasetId;
private final String filter;
private DatasetRequest(Parcel in) {
this.datasetId = in.readString();
@ -97,6 +97,14 @@ abstract class PanelLayout extends FrameLayout {
this.filter = filter;
}
public String getDatasetId() {
return datasetId;
}
public String getFilter() {
return filter;
}
@Override
public int describeContents() {
return 0;
@ -168,7 +176,7 @@ abstract class PanelLayout extends FrameLayout {
*/
public final void deliverDataset(DatasetRequest request, Cursor cursor) {
Log.d(LOGTAG, "Delivering request: " + request);
updateViewsWithDataset(request.datasetId, cursor);
updateViewsWithDataset(request.getDatasetId(), cursor);
}
/**