Bug 968573 - Use ViewConfig's item handler to define url opener flags (r=margaret)

This commit is contained in:
Lucas Rocha 2014-02-13 18:42:34 +00:00
parent 76119bb860
commit 45023ec9cb
2 changed files with 16 additions and 2 deletions

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko.home;
import org.mozilla.gecko.R;
import org.mozilla.gecko.db.BrowserContract.HomeItems;
import org.mozilla.gecko.home.HomeConfig.ItemHandler;
import org.mozilla.gecko.home.HomeConfig.ViewConfig;
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
import org.mozilla.gecko.home.PanelLayout.DatasetBacked;
@ -27,11 +28,13 @@ public class PanelGridView extends GridView
implements DatasetBacked, PanelView {
private static final String LOGTAG = "GeckoPanelGridView";
private final ViewConfig mViewConfig;
private final PanelGridViewAdapter mAdapter;
protected OnUrlOpenListener mUrlOpenListener;
public PanelGridView(Context context, ViewConfig viewConfig) {
super(context, null, R.attr.panelGridViewStyle);
mViewConfig = viewConfig;
mAdapter = new PanelGridViewAdapter(context);
setAdapter(mAdapter);
setOnItemClickListener(new PanelGridItemClickListener());
@ -82,7 +85,12 @@ public class PanelGridView extends GridView
int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL);
final String url = cursor.getString(urlIndex);
mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.OPEN_WITH_INTENT));
EnumSet<OnUrlOpenListener.Flags> flags = EnumSet.noneOf(OnUrlOpenListener.Flags.class);
if (mViewConfig.getItemHandler() == ItemHandler.INTENT) {
flags.add(OnUrlOpenListener.Flags.OPEN_WITH_INTENT);
}
mUrlOpenListener.onUrlOpen(url, flags);
}
}
}

View File

@ -6,6 +6,7 @@
package org.mozilla.gecko.home;
import org.mozilla.gecko.R;
import org.mozilla.gecko.home.HomeConfig.ItemHandler;
import org.mozilla.gecko.home.HomeConfig.ViewConfig;
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
import org.mozilla.gecko.home.PanelLayout.DatasetBacked;
@ -73,7 +74,12 @@ public class PanelListView extends HomeListView
int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL);
final String url = cursor.getString(urlIndex);
mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.OPEN_WITH_INTENT));
EnumSet<OnUrlOpenListener.Flags> flags = EnumSet.noneOf(OnUrlOpenListener.Flags.class);
if (mViewConfig.getItemHandler() == ItemHandler.INTENT) {
flags.add(OnUrlOpenListener.Flags.OPEN_WITH_INTENT);
}
mUrlOpenListener.onUrlOpen(url, flags);
}
}
}