|
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 package org.mozilla.gecko.home; |
|
7 |
|
8 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; |
|
9 import org.mozilla.gecko.home.HomeConfig.PanelConfig; |
|
10 import org.mozilla.gecko.home.HomeConfig.ViewConfig; |
|
11 |
|
12 import android.content.Context; |
|
13 import android.util.Log; |
|
14 import android.view.View; |
|
15 |
|
16 class FramePanelLayout extends PanelLayout { |
|
17 private static final String LOGTAG = "GeckoFramePanelLayout"; |
|
18 |
|
19 private final View mChildView; |
|
20 private final ViewConfig mChildConfig; |
|
21 |
|
22 public FramePanelLayout(Context context, PanelConfig panelConfig, DatasetHandler datasetHandler, |
|
23 OnUrlOpenListener urlOpenListener, ContextMenuRegistry contextMenuRegistry) { |
|
24 super(context, panelConfig, datasetHandler, urlOpenListener, contextMenuRegistry); |
|
25 |
|
26 // This layout can only hold one view so we simply |
|
27 // take the first defined view from PanelConfig. |
|
28 mChildConfig = panelConfig.getViewAt(0); |
|
29 if (mChildConfig == null) { |
|
30 throw new IllegalStateException("FramePanelLayout requires a view in PanelConfig"); |
|
31 } |
|
32 |
|
33 mChildView = createPanelView(mChildConfig); |
|
34 addView(mChildView); |
|
35 } |
|
36 |
|
37 @Override |
|
38 public void load() { |
|
39 Log.d(LOGTAG, "Loading"); |
|
40 |
|
41 if (mChildView instanceof DatasetBacked) { |
|
42 final FilterDetail filter = new FilterDetail(mChildConfig.getFilter(), null); |
|
43 |
|
44 final DatasetRequest request = new DatasetRequest(mChildConfig.getIndex(), |
|
45 mChildConfig.getDatasetId(), |
|
46 filter); |
|
47 |
|
48 Log.d(LOGTAG, "Requesting child request: " + request); |
|
49 requestDataset(request); |
|
50 } |
|
51 } |
|
52 } |