mobile/android/base/home/FramePanelLayout.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/home/FramePanelLayout.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +package org.mozilla.gecko.home;
    1.10 +
    1.11 +import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
    1.12 +import org.mozilla.gecko.home.HomeConfig.PanelConfig;
    1.13 +import org.mozilla.gecko.home.HomeConfig.ViewConfig;
    1.14 +
    1.15 +import android.content.Context;
    1.16 +import android.util.Log;
    1.17 +import android.view.View;
    1.18 +
    1.19 +class FramePanelLayout extends PanelLayout {
    1.20 +    private static final String LOGTAG = "GeckoFramePanelLayout";
    1.21 +
    1.22 +    private final View mChildView;
    1.23 +    private final ViewConfig mChildConfig;
    1.24 +
    1.25 +    public FramePanelLayout(Context context, PanelConfig panelConfig, DatasetHandler datasetHandler,
    1.26 +        OnUrlOpenListener urlOpenListener, ContextMenuRegistry contextMenuRegistry) {
    1.27 +        super(context, panelConfig, datasetHandler, urlOpenListener, contextMenuRegistry);
    1.28 +
    1.29 +        // This layout can only hold one view so we simply
    1.30 +        // take the first defined view from PanelConfig.
    1.31 +        mChildConfig = panelConfig.getViewAt(0);
    1.32 +        if (mChildConfig == null) {
    1.33 +            throw new IllegalStateException("FramePanelLayout requires a view in PanelConfig");
    1.34 +        }
    1.35 +
    1.36 +        mChildView = createPanelView(mChildConfig);
    1.37 +        addView(mChildView);
    1.38 +    }
    1.39 +
    1.40 +    @Override
    1.41 +    public void load() {
    1.42 +        Log.d(LOGTAG, "Loading");
    1.43 +
    1.44 +        if (mChildView instanceof DatasetBacked) {
    1.45 +            final FilterDetail filter = new FilterDetail(mChildConfig.getFilter(), null);
    1.46 +
    1.47 +            final DatasetRequest request = new DatasetRequest(mChildConfig.getIndex(),
    1.48 +                                                              mChildConfig.getDatasetId(),
    1.49 +                                                              filter);
    1.50 +
    1.51 +            Log.d(LOGTAG, "Requesting child request: " + request);
    1.52 +            requestDataset(request);
    1.53 +        }
    1.54 +    }
    1.55 +}

mercurial