FileDocCategorySizeDatePackage
QSDetailItems.javaAPI DocAndroid 5.1 API9041Thu Mar 12 22:22:42 GMT 2015com.android.systemui.qs

QSDetailItems

public class QSDetailItems extends android.widget.FrameLayout
Quick settings common detail view with line items.

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
private final android.content.Context
mContext
private final H
mHandler
private String
mTag
private Callback
mCallback
private boolean
mItemsVisible
private android.widget.LinearLayout
mItems
private android.view.View
mEmpty
private android.view.View
mMinHeightSpacer
private android.widget.TextView
mEmptyText
private android.widget.ImageView
mEmptyIcon
private int
mMaxItems
Constructors Summary
public QSDetailItems(android.content.Context context, android.util.AttributeSet attrs)


         
        super(context, attrs);
        mContext = context;
        mTag = TAG;
    
Methods Summary
private voidbind(com.android.systemui.qs.QSDetailItems$Item item, android.view.View view)

        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.qs_detail_item, this, false);
            mItems.addView(view);
        }
        view.setVisibility(mItemsVisible ? VISIBLE : INVISIBLE);
        final ImageView iv = (ImageView) view.findViewById(android.R.id.icon);
        iv.setImageResource(item.icon);
        iv.getOverlay().clear();
        if (item.overlay != null) {
            item.overlay.setBounds(0, 0, item.overlay.getIntrinsicWidth(),
                    item.overlay.getIntrinsicHeight());
            iv.getOverlay().add(item.overlay);
        }
        final TextView title = (TextView) view.findViewById(android.R.id.title);
        title.setText(item.line1);
        final TextView summary = (TextView) view.findViewById(android.R.id.summary);
        final boolean twoLines = !TextUtils.isEmpty(item.line2);
        title.setMaxLines(twoLines ? 1 : 2);
        summary.setVisibility(twoLines ? VISIBLE : GONE);
        summary.setText(twoLines ? item.line2 : null);
        view.setMinimumHeight(mContext.getResources() .getDimensionPixelSize(
                twoLines ? R.dimen.qs_detail_item_height_twoline : R.dimen.qs_detail_item_height));
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.onDetailItemClick(item);
                }
            }
        });
        final ImageView disconnect = (ImageView) view.findViewById(android.R.id.icon2);
        disconnect.setVisibility(item.canDisconnect ? VISIBLE : GONE);
        disconnect.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.onDetailItemDisconnect(item);
                }
            }
        });
    
public static com.android.systemui.qs.QSDetailItemsconvertOrInflate(android.content.Context context, android.view.View convert, android.view.ViewGroup parent)

        if (convert instanceof QSDetailItems) {
            return (QSDetailItems) convert;
        }
        return (QSDetailItems) LayoutInflater.from(context).inflate(R.layout.qs_detail_items,
                parent, false);
    
private voidhandleSetCallback(com.android.systemui.qs.QSDetailItems$Callback callback)

        mCallback = callback;
    
private voidhandleSetItems(com.android.systemui.qs.QSDetailItems$Item[] items)

        final int itemCount = items != null ? Math.min(items.length, mMaxItems) : 0;
        mEmpty.setVisibility(itemCount == 0 ? VISIBLE : GONE);
        mItems.setVisibility(itemCount == 0 ? GONE : VISIBLE);
        for (int i = mItems.getChildCount() - 1; i >= itemCount; i--) {
            mItems.removeViewAt(i);
        }
        for (int i = 0; i < itemCount; i++) {
            bind(items[i], mItems.getChildAt(i));
        }
    
private voidhandleSetItemsVisible(boolean visible)

        if (mItemsVisible == visible) return;
        mItemsVisible = visible;
        for (int i = 0; i < mItems.getChildCount(); i++) {
            mItems.getChildAt(i).setVisibility(mItemsVisible ? VISIBLE : INVISIBLE);
        }
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();
        if (DEBUG) Log.d(mTag, "onAttachedToWindow");
    
protected voidonConfigurationChanged(android.content.res.Configuration newConfig)

        super.onConfigurationChanged(newConfig);
        FontSizeUtils.updateFontSize(mEmptyText, R.dimen.qs_detail_empty_text_size);
        int count = mItems.getChildCount();
        for (int i = 0; i < count; i++) {
            View item = mItems.getChildAt(i);
            FontSizeUtils.updateFontSize(item, android.R.id.title,
                    R.dimen.qs_detail_item_primary_text_size);
            FontSizeUtils.updateFontSize(item, android.R.id.summary,
                    R.dimen.qs_detail_item_secondary_text_size);
        }
    
protected voidonDetachedFromWindow()

        super.onDetachedFromWindow();
        if (DEBUG) Log.d(mTag, "onDetachedFromWindow");
        mCallback = null;
    
protected voidonFinishInflate()

        super.onFinishInflate();
        mItems = (LinearLayout) findViewById(android.R.id.list);
        mItems.setVisibility(GONE);
        mEmpty = findViewById(android.R.id.empty);
        mEmpty.setVisibility(GONE);
        mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
        mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
        mMinHeightSpacer = findViewById(R.id.min_height_spacer);

        // By default, a detail item view has fixed size.
        mMaxItems = getResources().getInteger(
                R.integer.quick_settings_detail_max_item_count);
        setMinHeightInItems(mMaxItems);
    
public voidsetCallback(com.android.systemui.qs.QSDetailItems$Callback callback)

        mHandler.removeMessages(H.SET_CALLBACK);
        mHandler.obtainMessage(H.SET_CALLBACK, callback).sendToTarget();
    
public voidsetEmptyState(int icon, int text)

        mEmptyIcon.setImageResource(icon);
        mEmptyText.setText(text);
    
public voidsetItems(com.android.systemui.qs.QSDetailItems$Item[] items)

        mHandler.removeMessages(H.SET_ITEMS);
        mHandler.obtainMessage(H.SET_ITEMS, items).sendToTarget();
    
public voidsetItemsVisible(boolean visible)

        mHandler.removeMessages(H.SET_ITEMS_VISIBLE);
        mHandler.obtainMessage(H.SET_ITEMS_VISIBLE, visible ? 1 : 0, 0).sendToTarget();
    
public voidsetMinHeightInItems(int minHeightInItems)
Set the minimum height of this detail view, in item count.

        ViewGroup.LayoutParams lp = mMinHeightSpacer.getLayoutParams();
        lp.height = minHeightInItems * getResources().getDimensionPixelSize(
                R.dimen.qs_detail_item_height);
        mMinHeightSpacer.setLayoutParams(lp);
    
public voidsetTagSuffix(java.lang.String suffix)

        mTag = TAG + "." + suffix;