本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}