当前位置: 首页>>代码示例>>Java>>正文


Java ViewGroup.setTag方法代码示例

本文整理汇总了Java中android.view.ViewGroup.setTag方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.setTag方法的具体用法?Java ViewGroup.setTag怎么用?Java ViewGroup.setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.setTag方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDataTwoWay

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * (伪)双向 databinding: 同 {@link RecyclerViewAdapter#setDataTwoWay(RecyclerView, ListVM, List)}
 *
 * @param container
 * @param vm
 * @param datas
 * @param <T>
 */
@BindingAdapter({"vm", "data"})
public static <T> void setDataTwoWay(final ViewGroup container, final ListVM<T> vm, List<T> datas){
    if(vm == null){
        return ;
    }
    bind(container, vm, datas);

    if(vm instanceof TwoWayListVM){
        boolean isInited = container.getTag(R.id.db_inited) != null;
        if(!isInited) {
            container.setTag(R.id.db_inited, true);
            loadData(container, (TwoWayListVM<T>)vm, null, null);
        }
    }
}
 
开发者ID:fashare2015,项目名称:MVVM-JueJin,代码行数:24,代码来源:ViewGroupAdapter.java

示例2: displayVoiceMessages

import android.view.ViewGroup; //导入方法依赖的package包/类
private void displayVoiceMessages(final ArrayList<VoiceMessage> voices, ViewGroup container) {
    if(Objects.isNull(container)) return;

    boolean empty = safeIsEmpty(voices);
    container.setVisibility(empty ? View.GONE : View.VISIBLE);
    if (empty) {
        return;
    }

    int i = voices.size() - container.getChildCount();
    for (int j = 0; j < i; j++) {
        container.addView(LayoutInflater.from(mContext).inflate(R.layout.item_voice_message, container, false));
    }

    for (int g = 0; g < container.getChildCount(); g++) {
        ViewGroup root = (ViewGroup) container.getChildAt(g);

        if (g < voices.size()) {
            VoiceHolder holder = (VoiceHolder) root.getTag();
            if(holder == null){
                holder = new VoiceHolder(root);
                root.setTag(holder);
            }

            final VoiceMessage voice = voices.get(g);
            bindVoiceHolder(holder, voice);

            root.setVisibility(View.VISIBLE);
        } else {
            root.setVisibility(View.GONE);
        }
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:34,代码来源:AttachmentsViewBinder.java

示例3: displayAudios

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Отображение аудиозаписей
 *
 * @param audios    аудиозаписи
 * @param container контейнер для аудиозаписей
 */
private void displayAudios(final ArrayList<Audio> audios, ViewGroup container) {
    container.setVisibility(safeIsEmpty(audios) ? View.GONE : View.VISIBLE);
    if (safeIsEmpty(audios)) {
        return;
    }

    int i = audios.size() - container.getChildCount();
    for (int j = 0; j < i; j++) {
        container.addView(LayoutInflater.from(mContext).inflate(R.layout.item_small_audio, container, false));
    }

    for (int g = 0; g < container.getChildCount(); g++) {
        ViewGroup root = (ViewGroup) container.getChildAt(g);
        if (g < audios.size()) {
            final Audio audio = audios.get(g);

            AudioHolder holder = new AudioHolder(mContext, root);

            holder.tvTitle.setText(audio.getArtist());
            holder.tvSubtitle.setText(audio.getTitle());

            int finalG = g;
            holder.ibPlay.setOnClickListener(v -> mAttachmentsActionCallback.onAudioPlay(finalG, audios));

            root.setVisibility(View.VISIBLE);
            root.setTag(audio);
        } else {
            root.setVisibility(View.GONE);
            root.setTag(null);
        }
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:39,代码来源:AttachmentsViewBinder.java

示例4: setRootViewPaddingTop

import android.view.ViewGroup; //导入方法依赖的package包/类
private static void setRootViewPaddingTop(Activity activity, PaddingTop paddingTop) {
    ViewGroup rootView =
            (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
    if (paddingTop == PaddingTop.addPaddingTop) {
        if (!ViewCompat.getFitsSystemWindows(rootView) ||
                (rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_REMOVE_TOP))) {
            if (rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_ADD_TOP)) {
                return;
            }
            rootView.setPadding(
                    rootView.getPaddingLeft(),
                    rootView.getPaddingTop() + getStatusBarHeight(activity),
                    rootView.getPaddingRight(),
                    rootView.getPaddingBottom());
            rootView.setTag(R.id.tag_top, TAG_ADD_TOP);
        }
    }
    else if (paddingTop == PaddingTop.removePaddingTop) {
        if (ViewCompat.getFitsSystemWindows(rootView) ||
                (rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_ADD_TOP))) {
            if (rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_REMOVE_TOP)) {
                return;
            }
            rootView.setPadding(
                    rootView.getPaddingLeft(),
                    rootView.getPaddingTop() - getStatusBarHeight(activity),
                    rootView.getPaddingRight(),
                    rootView.getPaddingBottom());
            rootView.setTag(R.id.tag_top, TAG_REMOVE_TOP);
        }
    }
}
 
开发者ID:ghnor,项目名称:StatusBarFits,代码行数:33,代码来源:StatusBarFits.java

示例5: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ViewGroup view = (ViewGroup) getLayoutInflater().inflate(R.layout.item_mute_app, parent, false);

    ListViewHolder holder = new ListViewHolder(view);
    holder.textView = (TextView) view.findViewById(android.R.id.text1);
    holder.imageView = (ImageView) view.findViewById(R.id.image);

    view.setTag(holder);

    return holder;
}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:13,代码来源:AppMuteActivity.java

示例6: translucentStatusBar

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * change to full screen mode
 * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it
 */
public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
    Window window = activity.getWindow();
    ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);

    //set child View not fill the system window
    View mChildView = mContentView.getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setFitsSystemWindows(mChildView, false);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int statusBarHeight = getStatusBarHeight(activity);

        //First translucent status bar.
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            //After LOLLIPOP just set LayoutParams.
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            if (hideStatusBarBackground) {
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                window.setStatusBarColor(COLOR_TRANSLUCENT);
            } else {
                window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA));
            }
            //must call requestApplyInsets, otherwise it will have space in screen bottom
            if (mChildView != null) {
                ViewCompat.requestApplyInsets(mChildView);
            }
        } else {
            ViewGroup mDecorView = (ViewGroup) window.getDecorView();
            if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) {
                mChildView = mDecorView.getChildAt(0);
                //remove fake status bar view.
                mContentView.removeView(mChildView);
                mChildView = mContentView.getChildAt(0);
                if (mChildView != null) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams();
                    //cancel the margin top
                    if (lp != null && lp.topMargin >= statusBarHeight) {
                        lp.topMargin -= statusBarHeight;
                        mChildView.setLayoutParams(lp);
                    }
                }
                mDecorView.setTag(false);
            }
        }
    }
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:53,代码来源:StatusBarCompat.java

示例7: displayForwards

import android.view.ViewGroup; //导入方法依赖的package包/类
public void displayForwards(List<Message> fwds, final ViewGroup fwdContainer, final Context context, boolean postsAsLinks) {
    fwdContainer.setVisibility(safeIsEmpty(fwds) ? View.GONE : View.VISIBLE);
    if (safeIsEmpty(fwds)) {
        return;
    }

    final int i = fwds.size() - fwdContainer.getChildCount();
    for (int j = 0; j < i; j++) {
        View localView = LayoutInflater.from(context).inflate(R.layout.item_forward_message, fwdContainer, false);
        fwdContainer.addView(localView);
    }

    for (int g = 0; g < fwdContainer.getChildCount(); g++) {
        final ViewGroup itemView = (ViewGroup) fwdContainer.getChildAt(g);
        if (g < fwds.size()) {
            final Message message = fwds.get(g);
            itemView.setVisibility(View.VISIBLE);
            itemView.setTag(message);

            TextView tvBody = itemView.findViewById(R.id.item_fwd_message_text);
            tvBody.setText(message.getBody());
            tvBody.setVisibility(message.getBody() == null || message.getBody().length() == 0 ? View.GONE : View.VISIBLE);

            ((TextView) itemView.findViewById(R.id.item_fwd_message_username)).setText(message.getSender().getFullName());
            ((TextView) itemView.findViewById(R.id.item_fwd_message_time)).setText(AppTextUtils.getDateFromUnixTime(message.getDate()));
            TextView tvFwds = itemView.findViewById(R.id.item_forward_message_fwds);
            tvFwds.setVisibility(message.getForwardMessagesCount() > 0 ? View.VISIBLE : View.GONE);

            tvFwds.setOnClickListener(v -> mAttachmentsActionCallback.onForwardMessagesOpen(message.getFwd()));

            final ImageView ivAvatar = itemView.findViewById(R.id.item_fwd_message_avatar);

            String senderPhotoUrl = message.getSender() == null ? null : message.getSender().getMaxSquareAvatar();
            ViewUtils.displayAvatar(ivAvatar, mAvatarTransformation, senderPhotoUrl, Constants.PICASSO_TAG);

            ivAvatar.setOnClickListener(v -> mAttachmentsActionCallback.onOpenOwner(message.getSenderId()));

            AttachmentsHolder attachmentContainers = new AttachmentsHolder();
            attachmentContainers.setVgAudios(itemView.findViewById(R.id.audio_attachments)).
                    setVgDocs(itemView.findViewById(R.id.docs_attachments)).
                    setVgPhotos(itemView.findViewById(R.id.photo_attachments)).
                    setVgPosts(itemView.findViewById(R.id.posts_attachments)).
                    setVgStickers(itemView.findViewById(R.id.stickers_attachments)).
                    setVoiceMessageRoot(itemView.findViewById(R.id.voice_message_attachments));

            displayAttachments(message.getAttachments(), attachmentContainers, postsAsLinks);
        } else {
            itemView.setVisibility(View.GONE);
            itemView.setTag(null);
        }
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:53,代码来源:AttachmentsViewBinder.java

示例8: translucentStatusBar

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * change to full screen mode
 * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it
 */
public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
    Window    window       = activity.getWindow();
    ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);

    //set child View not fill the system window
    View mChildView = mContentView.getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setFitsSystemWindows(mChildView, false);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int statusBarHeight = getStatusBarHeight(activity);

        //First translucent status bar.
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            //After LOLLIPOP just set LayoutParams.
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            if (hideStatusBarBackground) {
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                window.setStatusBarColor(COLOR_TRANSLUCENT);
            } else {
                window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA));
            }
            //must call requestApplyInsets, otherwise it will have space in screen bottom
            if (mChildView != null) {
                ViewCompat.requestApplyInsets(mChildView);
            }
        } else {
            ViewGroup mDecorView = (ViewGroup) window.getDecorView();
            if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) {
                mChildView = mDecorView.getChildAt(0);
                //remove fake status bar view.
                mContentView.removeView(mChildView);
                mChildView = mContentView.getChildAt(0);
                if (mChildView != null) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams();
                    //cancel the margin top
                    if (lp != null && lp.topMargin >= statusBarHeight) {
                        lp.topMargin -= statusBarHeight;
                        mChildView.setLayoutParams(lp);
                    }
                }
                mDecorView.setTag(false);
            }
        }
    }
}
 
开发者ID:ynztlxdeai,项目名称:MVPtemplate,代码行数:53,代码来源:StatusBarCompat.java

示例9: inflatePhotoView

import android.view.ViewGroup; //导入方法依赖的package包/类
ViewGroup inflatePhotoView(ViewGroup container) {
    ViewGroup v = ItemViewUtil.inflatePhotoView(container);
    v.setTag(albumItem.getPath());
    this.itemView = v;
    return v;
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:7,代码来源:ViewHolder.java

示例10: inflateVideoView

import android.view.ViewGroup; //导入方法依赖的package包/类
ViewGroup inflateVideoView(ViewGroup container) {
    ViewGroup v = ItemViewUtil.inflateVideoView(container);
    v.setTag(albumItem.getPath());
    this.itemView = v;
    return v;
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:7,代码来源:ViewHolder.java


注:本文中的android.view.ViewGroup.setTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。