Java Code Examples for android.widget.FrameLayout#setTag()

The following examples show how to use android.widget.FrameLayout#setTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollSlidingTabStrip.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void addStickerTab(TLRPC.Document sticker) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setTag(sticker);
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    BackupImageView imageView = new BackupImageView(getContext());
    imageView.setAspectFit(true);
    tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
 
Example 2
Source File: ScrollSlidingTabStrip.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void addStickerTab(TLRPC.Document sticker) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setTag(sticker);
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    BackupImageView imageView = new BackupImageView(getContext());
    imageView.setAspectFit(true);
    tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
 
Example 3
Source File: MultiVideoCallActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
void addRemoteVideo(View singleRemoteView, SurfaceView video, String userId) {
        if (singleRemoteView == null)
            return;
        FrameLayout remoteVideoView = (FrameLayout) singleRemoteView.findViewById(R.id.viewlet_remote_video_user);
        remoteVideoView.removeAllViews();
        if (video.getParent() != null) {
            ((ViewGroup) video.getParent()).removeView(video);
        }
        remoteVideoView.addView(video, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
//        TextView remoteNameTextView = new TextView(this);
//        TextView tv = (TextView) singleRemoteView.findViewById(R.id.user_name);
//        ViewGroup.LayoutParams params = tv.getLayoutParams();
//        remoteNameTextView.setLayoutParams(params);
//        remoteNameTextView.setTextAppearance(this, R.style.rc_voip_text_style_style);
//        UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(userId);
//        if (userInfo != null) {
//            remoteNameTextView.setText(userInfo.getName());
//        } else {
//            remoteNameTextView.setText(userId);
//        }
//        remoteVideoView.addView(remoteNameTextView);
        remoteVideoView.setVisibility(View.VISIBLE);
        remoteVideoView.setTag(userId);
    }
 
Example 4
Source File: StatusListView.java    From AppCodeArchitecture with Apache License 2.0 5 votes vote down vote up
private ViewGroup createContainerView() {
    AbsListView.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    FrameLayout container = new FrameLayout(getContext());
    container.setTag(VIEW_TAG);
    container.setLayoutParams(lp);
    return container;
}
 
Example 5
Source File: DialogUnit.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private void display(DialogProvider dialogProvider) {
	Context context = uiManager.getContext();
	FrameLayout content = new FrameLayout(context);
	ListView listView = new ListView(context);
	content.addView(listView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	DialogPostsAdapter adapter = new DialogPostsAdapter(dialogProvider, listView);
	listView.setOnItemClickListener(adapter);
	listView.setOnItemLongClickListener(adapter);
	ScrollListenerComposite.obtain(listView).add(new BusyScrollListener(adapter));
	listView.setAdapter(adapter);
	listView.setId(android.R.id.list);
	listView.setDivider(ResourceUtils.getDrawable(context, R.attr.postsDivider, 0));
	final DialogHolder holder = new DialogHolder(adapter, dialogProvider, content, listView);
	uiManager.observable().register(holder);
	ImageLoader.getInstance().observable().register(holder);
	listView.setTag(holder);
	content.setTag(holder);
	dialogStack.push(content);
	dialogProvider.setStateListener((state) -> {
		switch (state) {
			case STATE_LIST: {
				holder.setShowLoading(false);
				holder.requestUpdate();
				return true;
			}
			case STATE_LOADING: {
				holder.setShowLoading(true);
				return true;
			}
			case STATE_ERROR: {
				if (!holder.cancelled) {
					dialogStack.pop();
					return true;
				}
				return false;
			}
		}
		return false;
	});
}
 
Example 6
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 7
Source File: ColorChooseDialog.java    From AppPlus with MIT License 5 votes vote down vote up
private View getColorItemView(final Context context, int position, boolean isSelect) {
    int color = mColors[position];
    int widthImageCheckView = Utils.convertDensityPix(context, 24);
    int widthColorView = Utils.convertDensityPix(context, 56);
    int widthMargin = Utils.convertDensityPix(context, 4);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.ic_done_white_24dp);

    FrameLayout.LayoutParams ivParams = new FrameLayout.LayoutParams(widthImageCheckView, widthImageCheckView);
    ivParams.gravity = Gravity.CENTER;
    imageView.setLayoutParams(ivParams);
    imageView.setVisibility(isSelect ? View.VISIBLE : View.INVISIBLE);

    FrameLayout frameLayout = new FrameLayout(context);
    GridLayout.LayoutParams params = new GridLayout.LayoutParams(new FrameLayout.LayoutParams(widthColorView, widthColorView));
    params.setGravity(Gravity.CENTER);
    params.setMargins(widthMargin, widthMargin, widthMargin, widthMargin);
    frameLayout.setLayoutParams(params);

    setBackgroundSelector(frameLayout, color);

    frameLayout.addView(imageView);
    frameLayout.setOnClickListener(this);
    frameLayout.setTag(position);
    return frameLayout;
}
 
Example 8
Source File: AbstractTreeViewAdapter.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
public final LinearLayout populateTreeItem(final LinearLayout layout,
        final View childView, final TreeNodeInfo<T> nodeInfo,
        final boolean newChildView) {
    final Drawable individualRowDrawable = getBackgroundDrawable(nodeInfo);
    layout.setBackgroundDrawable(individualRowDrawable == null ? getDrawableOrDefaultBackground(rowBackgroundDrawable)
            : individualRowDrawable);
    final LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(
            calculateIndentation(nodeInfo), LayoutParams.FILL_PARENT);
    final LinearLayout indicatorLayout = (LinearLayout) layout
            .findViewById(R.id.treeview_list_item_image_layout);
    indicatorLayout.setGravity(indicatorGravity);
    indicatorLayout.setLayoutParams(indicatorLayoutParams);
    final ImageView image = (ImageView) layout
            .findViewById(R.id.treeview_list_item_image);
    image.setImageDrawable(getDrawable(nodeInfo));
    image.setScaleType(ScaleType.CENTER);
    image.setTag(nodeInfo.getId());
    image.setOnClickListener(null);
    image.setClickable(false);
    layout.setTag(nodeInfo.getId());
    final FrameLayout frameLayout = (FrameLayout) layout
            .findViewById(R.id.treeview_list_item_frame);
    final FrameLayout.LayoutParams childParams = new FrameLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    if (newChildView) {
        frameLayout.addView(childView, childParams);
    }
    frameLayout.setTag(nodeInfo.getId());
    return layout;
}
 
Example 9
Source File: LazyFragment.java    From XDroidMvp with MIT License 5 votes vote down vote up
private void onCreateView(Bundle savedInstanceState) {
    this.saveInstanceState = savedInstanceState;
    boolean isVisible;
    if (isVisibleToUserState == STATE_NO_SET) {
        isVisible = getUserVisibleHint();
    } else {
        isVisible = isVisibleToUserState == STATE_VISIBLE;
    }
    if (isLazyEnable) {
        if (isVisible && !isInitReady) {
            onCreateViewLazy(savedInstanceState);
            isInitReady = true;
        } else {
            LayoutInflater mInflater = layoutInflater;
            if (mInflater == null && context != null) {
                mInflater = LayoutInflater.from(context);
            }
            layout = new FrameLayout(context);
            layout.setTag(TAG_ROOT_FRAMELAYOUT);

            View view = getPreviewLayout(mInflater, layout);
            if (view != null) {
                layout.addView(view);
            }
            layout.setLayoutParams(
                    new FrameLayout.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.MATCH_PARENT));
            setContentView(layout);
        }
    } else {
        onCreateViewLazy(savedInstanceState);
        isInitReady = true;
    }
}
 
Example 10
Source File: HyperTextEditor.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
/**
 * 生成图片View
 */
private FrameLayout createImageLayout() {
	FrameLayout layout = (FrameLayout) inflater.inflate(R.layout.hte_edit_imageview, null);
	layout.setTag(viewTagIndex++);
	ImageView closeView = layout.findViewById(R.id.image_close);
	FrameLayout.LayoutParams layoutParams = (LayoutParams) closeView.getLayoutParams();
	layoutParams.bottomMargin = HyperLibUtils.dip2px(layout.getContext(),10.0f);
	switch (delIconLocation){
		//左上角
		case 1:
			layoutParams.gravity = Gravity.TOP | Gravity.START;
			closeView.setLayoutParams(layoutParams);
			break;
		//右上角
		case 2:
			layoutParams.gravity = Gravity.TOP | Gravity.END;
			closeView.setLayoutParams(layoutParams);
			break;
		//左下角
		case 3:
			layoutParams.gravity = Gravity.BOTTOM | Gravity.START;
			closeView.setLayoutParams(layoutParams);
			break;
		//右下角
		case 4:
			layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
			closeView.setLayoutParams(layoutParams);
			break;
		//其他右下角
		default:
			layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
			closeView.setLayoutParams(layoutParams);
			break;
	}
	closeView.setTag(layout.getTag());
	closeView.setOnClickListener(btnListener);
	HyperImageView imageView = layout.findViewById(R.id.edit_imageView);
	imageView.setOnClickListener(btnListener);
	return layout;
}
 
Example 11
Source File: PlayPagerAdapter.java    From PlayerBase with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    VideoBean bean = mItems.get(position);
    View itemView = View.inflate(mContext, R.layout.item_pager_play, null);
    FrameLayout playerContainer = itemView.findViewById(R.id.playerContainer);
    playerContainer.setTag(bean.getPath());
    ImageView coverView = itemView.findViewById(R.id.iv_cover);
    GlideApp.with(mContext)
            .load(bean.getPath())
            .centerInside()
            .into(coverView);
    container.addView(itemView);
    return itemView;
}
 
Example 12
Source File: AAH_FilterView.java    From FabulousFilter with Apache License 2.0 5 votes vote down vote up
public void init() {
    fl = new FrameLayout(getContext());
    fl.setTag("aah_fl");
    fab = new FloatingActionButton(getContext());
    fab.setTag("aah_fab");
    fab.setCompatElevation(0);
    fl.addView(fab);
    this.addView(fl);

}
 
Example 13
Source File: FilesListAdapter.java    From secrecy with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);
    name = (TextView) itemView.findViewById(R.id.name);
    type = (TextView) itemView.findViewById(R.id.type);
    size = (TextView) itemView.findViewById(R.id.size);
    date = (TextView) itemView.findViewById(R.id.date);
    thumbnail = (ImageView) itemView.findViewById(R.id.thumbNail);
    frame = (FrameLayout) itemView.findViewById(R.id.frame);
    frame.setTag(this);
    animator = (ViewAnimator) itemView.findViewById(R.id.viewAnimator);
    progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
    frame.setOnClickListener(this);
    frame.setOnLongClickListener(this);
}
 
Example 14
Source File: PerformanceCloseDokitView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
public void addItem(int index, int performanceType) {
    if (mLlCloseWrap == null) {
        return;
    }
    FrameLayout closeViewWrap = (FrameLayout) mLlCloseWrap.getChildAt(index);
    closeViewWrap.setVisibility(View.VISIBLE);
    closeViewWrap.setTag(performanceType);

}
 
Example 15
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 4 votes vote down vote up
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
    mTempWallpaperTiles.add(uri);
    // Add a tile for the image picked from Gallery
    final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater().
            inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
    pickedImageThumbnail.setVisibility(View.GONE);
    setWallpaperItemPaddingToZero(pickedImageThumbnail);
    mWallpapersView.addView(pickedImageThumbnail, 0);

    // Load the thumbnail
    final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
    final Point defaultSize = getDefaultThumbnailSize(this.getResources());
    final Context context = this;
    new AsyncTask<Void, Bitmap, Bitmap>() {
        protected Bitmap doInBackground(Void...args) {
            try {
                int rotation = WallpaperCropActivity.getRotationFromExif(context, uri);
                return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false);
            } catch (SecurityException securityException) {
                if (isDestroyed()) {
                    // Temporarily granted permissions are revoked when the activity
                    // finishes, potentially resulting in a SecurityException here.
                    // Even though {@link #isDestroyed} might also return true in different
                    // situations where the configuration changes, we are fine with
                    // catching these cases here as well.
                    cancel(false);
                } else {
                    // otherwise it had a different cause and we throw it further
                    throw securityException;
                }
                return null;
            }
        }
        protected void onPostExecute(Bitmap thumb) {
            if (!isCancelled() && thumb != null) {
                image.setImageBitmap(thumb);
                Drawable thumbDrawable = image.getDrawable();
                thumbDrawable.setDither(true);
                pickedImageThumbnail.setVisibility(View.VISIBLE);
            } else {
                Log.e(TAG, "Error loading thumbnail for uri=" + uri);
            }
        }
    }.execute();

    UriWallpaperInfo info = new UriWallpaperInfo(uri);
    pickedImageThumbnail.setTag(info);
    info.setView(pickedImageThumbnail);
    addLongPressHandler(pickedImageThumbnail);
    updateTileIndices();
    pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
    if (!fromRestore) {
        mThumbnailOnClickListener.onClick(pickedImageThumbnail);
    }
}
 
Example 16
Source File: MultiVideoCallActivity.java    From sealtalk-android with MIT License 4 votes vote down vote up
public void onSwitchRemoteUsers(View view) {
    String from = (String) view.getTag();
    if (from == null)
        return;
    String to = (String) localView.getTag();
    FrameLayout layout = (FrameLayout) view;
    SurfaceView fromView = (SurfaceView) layout.getChildAt(0);
    SurfaceView toView = localView;

    localViewContainer.removeAllViews();
    layout.removeAllViews();

    View singleRemoteView = remoteViewContainer.findViewWithTag(from + "view");
    UserInfo toUserInfo = RongContext.getInstance().getUserInfoFromCache(to);
    UserInfo fromUserInfo = RongContext.getInstance().getUserInfoFromCache(from);

    AsyncImageView userPortraitView = (AsyncImageView) singleRemoteView.findViewById(R.id.user_portrait);
    TextView backUserNameView = (TextView) singleRemoteView.findViewById(R.id.user_name);

    if (toUserInfo != null) {
        if (toUserInfo.getPortraitUri() != null) {
            userPortraitView.setAvatar(toUserInfo.getPortraitUri().toString(), R.drawable.rc_default_portrait);
        }
        backUserNameView.setText(toUserInfo.getName());
    } else {
        backUserNameView.setText(to);
    }
    singleRemoteView.setTag(to + "view");
    fromView.setZOrderOnTop(false);
    fromView.setZOrderMediaOverlay(false);
    localViewContainer.addView(fromView);
    toView.setZOrderOnTop(true);
    toView.setZOrderMediaOverlay(true);
    layout.addView(toView);

    TextView topUserNameView = (TextView) topContainer.findViewById(R.id.rc_voip_user_name);
    if (fromUserInfo != null) {
        topUserNameView.setText(fromUserInfo.getName());
    } else {
        topUserNameView.setText(from);
    }
    layout.setTag(to);
    localView = fromView;
    localView.setTag(from);
    localViewUserId = from;
}
 
Example 17
Source File: ChartProgressBar.java    From ChartProgressBar-Android with Apache License 2.0 4 votes vote down vote up
private FrameLayout getBar(final String title, final int value, final int index) {

		int maxValue = (int) (mMaxValue * 100);

		LinearLayout linearLayout = new LinearLayout(mContext);
		FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT
		);

		params.gravity = Gravity.CENTER;
		linearLayout.setLayoutParams(params);
		linearLayout.setOrientation(LinearLayout.VERTICAL);
		linearLayout.setGravity(Gravity.CENTER);

		//Adding bar
		Bar bar = new Bar(mContext, null, android.R.attr.progressBarStyleHorizontal);
		bar.setProgress(value);
		bar.setVisibility(View.VISIBLE);
		bar.setIndeterminate(false);

		bar.setMax(maxValue);

		bar.setProgressDrawable(ContextCompat.getDrawable(mContext, R.drawable.progress_bar_shape));

		LayoutParams progressParams = new LayoutParams(
			mBarWidth,
			mBarHeight
		);

		progressParams.gravity = Gravity.CENTER;
		bar.setLayoutParams(progressParams);

		BarAnimation anim = new BarAnimation(bar, 0, value);
		anim.setDuration(250);
		bar.startAnimation(anim);

		LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
		layerDrawable.mutate();

		GradientDrawable emptyLayer = (GradientDrawable) layerDrawable.getDrawable(0);
		ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

		emptyLayer.setColor(ContextCompat.getColor(mContext, mEmptyColor));
		emptyLayer.setCornerRadius(mBarRadius);

		GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

		if (progressLayer != null) {
			progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
			progressLayer.setCornerRadius(mBarRadius);
		}


		linearLayout.addView(bar);

		//Adding txt below bar
		TextView txtBar = new TextView(mContext);
		LayoutParams txtParams = new LayoutParams(
			LayoutParams.WRAP_CONTENT,
			LayoutParams.WRAP_CONTENT
		);

		txtBar.setTextSize(getSP(mBarTitleTxtSize));
		txtBar.setText(title);
		txtBar.setGravity(Gravity.CENTER);
		txtBar.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
		txtBar.setPadding(0, mBarTitleMarginTop, 0, 0);

		txtBar.setLayoutParams(txtParams);

		linearLayout.addView(txtBar);

		FrameLayout rootFrameLayout = new FrameLayout(mContext);
		LinearLayout.LayoutParams rootParams = new LinearLayout.LayoutParams(
			0,
			LayoutParams.MATCH_PARENT,
			1f
		);

		rootParams.gravity = Gravity.CENTER;


		//rootParams.setMargins(0, h, 0, h);
		rootFrameLayout.setLayoutParams(rootParams);


		//Adding bar + title
		rootFrameLayout.addView(linearLayout);

		if (isBarCanBeClick)
			rootFrameLayout.setOnClickListener(barClickListener);

		rootFrameLayout.setTag(index);
		return rootFrameLayout;
	}
 
Example 18
Source File: WallpaperPickerActivity.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
    mTempWallpaperTiles.add(uri);
    // Add a tile for the image picked from Gallery
    final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater().
            inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
    pickedImageThumbnail.setVisibility(View.GONE);
    mWallpapersView.addView(pickedImageThumbnail, 0);

    // Load the thumbnail
    final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
    final Point defaultSize = getDefaultThumbnailSize(this.getResources());
    final Context context = getContext();
    new AsyncTask<Void, Bitmap, Bitmap>() {
        protected Bitmap doInBackground(Void...args) {
            try {
                int rotation = BitmapUtils.getRotationFromExif(context, uri);
                return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false);
            } catch (SecurityException securityException) {
                if (isActivityDestroyed()) {
                    // Temporarily granted permissions are revoked when the activity
                    // finishes, potentially resulting in a SecurityException here.
                    // Even though {@link #isDestroyed} might also return true in different
                    // situations where the configuration changes, we are fine with
                    // catching these cases here as well.
                    cancel(false);
                } else {
                    // otherwise it had a different cause and we throw it further
                    throw securityException;
                }
                return null;
            }
        }
        protected void onPostExecute(Bitmap thumb) {
            if (!isCancelled() && thumb != null) {
                image.setImageBitmap(thumb);
                Drawable thumbDrawable = image.getDrawable();
                thumbDrawable.setDither(true);
                pickedImageThumbnail.setVisibility(View.VISIBLE);
            } else {
                Log.e(TAG, "Error loading thumbnail for uri=" + uri);
            }
        }
    }.execute();

    UriWallpaperInfo info = new UriWallpaperInfo(uri);
    pickedImageThumbnail.setTag(info);
    info.setView(pickedImageThumbnail);
    addLongPressHandler(pickedImageThumbnail);
    updateTileIndices();
    pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
    if (!fromRestore) {
        mThumbnailOnClickListener.onClick(pickedImageThumbnail);
    }
}
 
Example 19
Source File: TrendAdapter.java    From JianshuApp with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder holder, TrendArticle entity) {
    holder.setText(R.id.last_compiled_time, formatTime(entity.getPublishTime()));
    holder.setText(R.id.collection_tag, getSubjectTitle(entity));

    String avatarUrl = getAvatar(entity);
    if (!TextUtils.isEmpty(avatarUrl)) {
        UniversalDraweeView draweeViewAuthorAvatar = holder.getView(R.id.author_avatar);
        draweeViewAuthorAvatar.setImageURI(avatarUrl);
    }

    TextView tvAuthorName = holder.getView(R.id.author_name);
    TextView tvTitle = holder.getView(R.id.title);
    TextView tvExtraInfo = holder.getView(R.id.extra_info);
    UniversalDraweeView draweeViewImage = holder.getView(R.id.image);
    RelativeLayout rlAvatarName = holder.getView(R.id.avatar_name);
    FrameLayout flCollectionTagContainer = holder.getView(R.id.collection_tag_container);

    boolean shouldSetSelected = ArticleDetailDao.isRead(entity.getId());
    String userNickname = getNickname(entity);
    if (!TextUtils.isEmpty(userNickname)) {
        tvAuthorName.setText(userNickname);
        tvAuthorName.setSelected(shouldSetSelected);
    }
    tvTitle.setText(entity.getTitle());
    tvTitle.setSelected(shouldSetSelected);
    tvExtraInfo.setText(getExtraInfo(entity));
    tvExtraInfo.setCompoundDrawablesWithIntrinsicBounds(entity.isHasVideo() ? mDefaultVideoIcon : null, null, null, null);
    if (TextUtils.isEmpty(entity.getImage())) {
        draweeViewImage.setVisibility(View.GONE);
    } else {
        draweeViewImage.setVisibility(View.VISIBLE);
        String thumbUrl = ImageUtils.format(entity.getImage(), DisplayInfo.dp2px(80));
        draweeViewImage.setImageURI(thumbUrl);
    }

    rlAvatarName.setTag(holder.getLayoutPosition());
    rlAvatarName.setOnClickListener(this);

    flCollectionTagContainer.setTag(holder.getLayoutPosition());
    flCollectionTagContainer.setOnClickListener(this);
    if (TextUtils.isEmpty(getSubjectTitle(entity))) {
        flCollectionTagContainer.setVisibility(View.GONE);
    } else {
        flCollectionTagContainer.setVisibility(View.VISIBLE);
    }

    holder.setTag(R.id.root_view, holder.getLayoutPosition());
    holder.setOnClickListener(R.id.root_view, this);
}
 
Example 20
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) {
    mTempWallpaperTiles.add(uri);
    // Add a tile for the image picked from Gallery
    final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater().
            inflate(R.layout.wallpaper_picker_item, mWallpapersView, false);
    pickedImageThumbnail.setVisibility(View.GONE);
    setWallpaperItemPaddingToZero(pickedImageThumbnail);
    mWallpapersView.addView(pickedImageThumbnail, 0);

    // Load the thumbnail
    final ImageView image = (ImageView) pickedImageThumbnail.findViewById(R.id.wallpaper_image);
    final Point defaultSize = getDefaultThumbnailSize(this.getResources());
    final Context context = this;
    new AsyncTask<Void, Bitmap, Bitmap>() {
        protected Bitmap doInBackground(Void...args) {
            int rotation = WallpaperCropActivity.getRotationFromExif(context, uri);
            return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false);

        }
        protected void onPostExecute(Bitmap thumb) {
            if (thumb != null) {
                image.setImageBitmap(thumb);
                Drawable thumbDrawable = image.getDrawable();
                thumbDrawable.setDither(true);
                pickedImageThumbnail.setVisibility(View.VISIBLE);
            } else {
                Log.e(TAG, "Error loading thumbnail for uri=" + uri);
            }
        }
    }.execute();

    UriWallpaperInfo info = new UriWallpaperInfo(uri);
    pickedImageThumbnail.setTag(info);
    info.setView(pickedImageThumbnail);
    addLongPressHandler(pickedImageThumbnail);
    updateTileIndices();
    pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
    if (!fromRestore) {
        mThumbnailOnClickListener.onClick(pickedImageThumbnail);
    }
}