Methods Summary |
---|
public void | add(TabControl.Tab t)Add a new window web page to the grid
if (mMaxedOut) {
return;
}
mItems.add(t);
notifyObservers();
if (mItems.size() == TabControl.MAX_TABS) {
mMaxedOut = true;
}
|
public boolean | areAllItemsEnabled()
return true;
|
public void | clear()Clear the internal WebViews and remove their picture listeners.
for (TabControl.Tab t : mItems) {
clearPictureListeners(t);
}
mItems.clear();
notifyObservers();
|
private void | clearPictureListeners(TabControl.Tab t)
if (t.getWebView() != null) {
t.getWebView().setPictureListener(null);
if (t.getSubWebView() != null) {
t.getSubWebView().setPictureListener(null);
}
}
|
private void | confirmClose(int position)
final ImageGrid.Listener l = mImageGrid.getListener();
if (l == null) {
return;
}
l.remove(position);
|
public int | getCount()
// Include the New Window button if we have not reached the tab limit
if (!mMaxedOut) {
return mItems.size()+1;
}
return mItems.size();
|
public java.lang.Object | getItem(int position)
if (!mMaxedOut) {
if (0 == position) {
return null;
}
return mItems.get(position);
}
return mItems.get(position);
|
public long | getItemId(int position)
return position;
|
public int | getItemViewType(int position)
return 0;
|
public android.view.View | getView(int position, android.view.View convertView, android.view.ViewGroup parent)
View v = null;
if (convertView != null) {
v = convertView;
} else {
LayoutInflater factory = LayoutInflater.from(mContext);
v = factory.inflate(R.layout.tabitem, null);
}
FakeWebView img = (FakeWebView) v.findViewById(R.id.icon);
ImageView close = (ImageView) v.findViewById(R.id.close);
TextView tv = (TextView) v.findViewById(R.id.label);
// position needs to be in the range of Tab indices.
if (!mMaxedOut) {
position--;
}
// Create the View for actual tabs
if (position != ImageGrid.NEW_TAB) {
TabControl.Tab t = mItems.get(position);
img.setTab(t);
tv.setText(t.getTitle());
// Do not put the 'X' if the tab picker isn't "live" (meaning the
// user cannot click on a tab)
if (!mIsLive) {
close.setVisibility(View.GONE);
} else {
close.setVisibility(View.VISIBLE);
final int pos = position;
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ImageAdapter.this.confirmClose(pos);
}
});
}
} else {
img.setBackgroundColor(Color.BLACK);
img.setImageResource(R.drawable.ic_new_window);
img.setScaleType(ImageView.ScaleType.CENTER);
img.setPadding(0, 0, 0, 34);
tv.setText(R.string.new_window);
close.setVisibility(View.GONE);
}
ViewGroup.LayoutParams lp = img.getLayoutParams();
if (lp.height != mTabHeight) {
lp.height = mTabHeight;
img.requestLayout();
}
return v;
|
public int | getViewTypeCount()
return 1;
|
public boolean | hasStableIds()
return true;
|
void | heightChanged(int newHeight)
mTabHeight = newHeight;
|
public boolean | isEmpty()
return getCount() == 0;
|
public boolean | isEnabled(int position)
if (position >= 0 && position <= mItems.size()) {
return true;
}
return false;
|
public boolean | maxedOut()Whether the adapter is at its limit, determined by TabControl.MAX_TABS
return mMaxedOut;
|
void | notifyObservers()Notify all the observers that a change has happened.
for (DataSetObserver observer : mDataObservers) {
observer.onChanged();
}
|
public void | registerDataSetObserver(android.database.DataSetObserver observer)
mDataObservers.add(observer);
|
public void | remove(int index)Remove a window from the list. At this point, the window
has already gone. It just needs to be removed from the screen
if (index >= 0 && index < mItems.size()) {
clearPictureListeners(mItems.remove(index));
notifyObservers();
mMaxedOut = false;
}
|
public void | unregisterDataSetObserver(android.database.DataSetObserver observer)
mDataObservers.remove(observer);
|