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

The following examples show how to use android.widget.LinearLayout#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: DefaultDividerAgent.java    From Shield with MIT License 6 votes vote down vote up
private View createShowView() {
    LinearLayout rootView = new LinearLayout(mContext);
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setLayoutParams(new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params.leftMargin = ViewUtils.dip2px(getContext(), 30);

    ItemViewHolder itemViewHolder = new ItemViewHolder();
    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setGravity(Gravity.CENTER_VERTICAL);
    itemViewHolder.textView = textView;

    rootView.addView(textView, params);
    rootView.setTag(itemViewHolder);
    return rootView;
}
 
Example 2
Source File: ItemArenaFragment.java    From MonsterHunter4UDatabase with MIT License 6 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
	// Get the item for the current row
	ArenaReward arenaReward = mArenaRewardCursor.getArenaReward();

	// Set up the text view
	LinearLayout itemLayout = (LinearLayout) view
			.findViewById(R.id.listitem);

	TextView questTextView = (TextView) view.findViewById(R.id.quest);
	TextView amountTextView = (TextView) view.findViewById(R.id.amount);
	TextView percentageTextView = (TextView) view
			.findViewById(R.id.percentage);

	String cellQuestText = arenaReward.getArenaQuest().getName();
	int cellAmountText = arenaReward.getStackSize();
	int cellPercentageText = arenaReward.getPercentage();

	questTextView.setText(cellQuestText);
	amountTextView.setText("" + cellAmountText);

	String percent = "" + cellPercentageText + "%";
	percentageTextView.setText(percent);

	itemLayout.setTag(arenaReward.getArenaQuest().getId());
}
 
Example 3
Source File: BreadCrumbLayout.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    if (Build.VERSION.SDK_INT >= 19 && iv.getDrawable() != null) {
        iv.getDrawable().setAutoMirrored(true);
    }
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 4
Source File: BreadCrumbLayout.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    if (Build.VERSION.SDK_INT >= 19 && iv.getDrawable() != null) {
        iv.getDrawable().setAutoMirrored(true);
    }
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 5
Source File: LinearBreadcrumb.java    From GithubApp with Apache License 2.0 6 votes vote down vote up
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    Drawable arrow = getResources().getDrawable(R.drawable.ic_right_arrow);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (arrow != null) {
            arrow.setAutoMirrored(true);
        }
    }
    iv.setImageDrawable(arrow);
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 6
Source File: SectionDividerAgent.java    From Shield with MIT License 6 votes vote down vote up
private View createShowView() {
    LinearLayout rootView = new LinearLayout(mContext);
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setLayoutParams(new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params.leftMargin = ViewUtils.dip2px(getContext(), 30);

    ItemViewHolder itemViewHolder = new ItemViewHolder();
    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setGravity(Gravity.CENTER_VERTICAL);
    itemViewHolder.textView = textView;

    rootView.addView(textView, params);
    rootView.setTag(itemViewHolder);
    return rootView;
}
 
Example 7
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 8
Source File: AppDialog.java    From Android_framework with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public BaseDialog setPositiveButton(String positive) {
    LinearLayout layout = generateLayout(positive);
    layout.setTag(POSITIVE_LISTENER);
    ll_bottom_button.addView(layout);
    return this;
}
 
Example 9
Source File: ArenaQuestRewardFragment.java    From MonsterHunter4UDatabase with MIT License 5 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
	// Get the item for the current row
	ArenaReward arenaReward = mArenaRewardCursor.getArenaReward();

	// Set up the text view
	LinearLayout itemLayout = (LinearLayout) view
			.findViewById(R.id.listitem);
	ImageView itemImageView = (ImageView) view
			.findViewById(R.id.item_image);

	TextView itemTextView = (TextView) view.findViewById(R.id.item);
	TextView amountTextView = (TextView) view.findViewById(R.id.amount);
	TextView percentageTextView = (TextView) view
			.findViewById(R.id.percentage);

	String cellItemText = arenaReward.getItem().getName();
	int cellAmountText = arenaReward.getStackSize();
	int cellPercentageText = arenaReward.getPercentage();

	itemTextView.setText(cellItemText);
	amountTextView.setText("" + cellAmountText);

	String percent = "" + cellPercentageText + "%";
	percentageTextView.setText(percent);

	Drawable i = null;
	String cellImage = "icons_items/" + arenaReward.getItem().getFileLocation();
	
	try {
		i = Drawable.createFromStream(
				context.getAssets().open(cellImage), null);
	} catch (IOException e) {
		e.printStackTrace();
	}

	itemImageView.setImageDrawable(i);

	itemLayout.setTag(arenaReward.getItem().getId());
}
 
Example 10
Source File: SeriesIntegrals.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
private LinearLayout getLayoutWithTag(final String tag)
{
    LinearLayout retValue = layout.findViewWithTag(tag);
    if (retValue != null)
    {
        retValue.setTag(null);
    }
    return retValue;
}
 
Example 11
Source File: AppDialog.java    From Android_framework with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public BaseDialog addOtherButton(String other, int other_listener) {
    if (!checkIllegalId(other_listener)){
        throw new IllegalArgumentException("按钮id重复");
    }
    LinearLayout layout = generateLayout(other);
    layout.setTag(other_listener);
    mIds.add(other_listener);
    ll_bottom_button.addView(layout);
    return this;
}
 
Example 12
Source File: AddActivity.java    From ClassSchedule with Apache License 2.0 5 votes vote down vote up
private void initNodeInfo(LinearLayout locationItem, CourseV2 courseV2) {
    TextView tvText = locationItem.findViewById(R.id.tv_text);
    String builder = "周" + Constant.WEEK_SINGLE[courseV2.getCouWeek() - 1] +
            " 第" + courseV2.getCouStartNode() + "-" +
            (courseV2.getCouStartNode() + courseV2.getCouNodeCount() - 1) + "节";
    tvText.setText(builder);

    locationItem.setTag(courseV2);
}
 
Example 13
Source File: MonsterQuestFragment.java    From MonsterHunter4UDatabase with MIT License 5 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
	// Get the item for the current row
	MonsterToQuest monsterToQuest = mMonsterToQuestCursor
			.getMonsterToQuest();

	// Set up the text view
	LinearLayout itemLayout = (LinearLayout) view
			.findViewById(R.id.listitem);
	TextView questTextView = (TextView) view
			.findViewById(R.id.quest_name);
	TextView locationTextView = (TextView) view
			.findViewById(R.id.quest_location);
	TextView unstableTextView = (TextView) view
			.findViewById(R.id.quest_unstable);

	String cellQuestText = monsterToQuest.getQuest().getName();
	String cellLocationText = monsterToQuest.getQuest().getHub() + " "
			+ monsterToQuest.getQuest().getStars();
	String cellUnstableText = monsterToQuest.getUnstable();
	
	if (cellUnstableText.equals("no")) {
              unstableTextView.setVisibility(View.GONE);
	}
	else {
		cellUnstableText = "Unstable";
              unstableTextView.setText(cellUnstableText);
	}
	
	questTextView.setText(cellQuestText);
	locationTextView.setText(cellLocationText);

	itemLayout.setTag(monsterToQuest.getQuest().getId());
          itemLayout.setOnClickListener(new QuestClickListener(context,monsterToQuest
                  .getQuest().getId()));
}
 
Example 14
Source File: PlayActivity.java    From AnimeTaste with MIT License 5 votes vote down vote up
@Override
protected Void doInBackground(Void... voids) {
    for (int i = 0; i < mRandomJsonArray.length(); i++) {
        LinearLayout recommend_item = (LinearLayout) mLayoutInflater
                .inflate(R.layout.recommend_item, null);
        ImageView recommendThumb = (ImageView) recommend_item
                .findViewById(R.id.thumb);
        TextView recommendTitle = (TextView) recommend_item
                .findViewById(R.id.recommand_title);
        TextView recommendContent = (TextView) recommend_item
                .findViewById(R.id.recommand_content);
        try {
            JSONObject animationObject = mRandomJsonArray.getJSONObject(i);
            Animation animation = Animation
                    .build(animationObject);
            Picasso.with(mContext).load(animation.HomePic)
                    .placeholder(R.drawable.placeholder_thumb)
                    .error(R.drawable.placeholder_fail)
                    .into(recommendThumb);
            recommendTitle.setText(animation.Name);
            recommendContent.setText(animation.Brief);
            recommend_item.setTag(animation);
            recommend_item.setOnClickListener(PlayActivity.this);
            View line = mRecommendView
                    .findViewById(R.id.divide_line);
            if (i == mRandomJsonArray.length() - 1 && line != null) {
                recommend_item.removeView(line);
            }
            mRandomLayout.addView(recommend_item);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
Example 15
Source File: AttachFragment.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
private View instantiateShareMenuItem(ShareMenuField f) {
    LinearLayout shareItem = new LinearLayout(getActivity());
    shareItem.setOrientation(LinearLayout.VERTICAL);
    shareItem.setGravity(Gravity.CENTER_HORIZONTAL);

    TextView title = new TextView(getActivity());
    title.setGravity(Gravity.CENTER);
    title.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
    title.setText(f.getTitle());
    title.setTextSize(14);

    ImageView icon = new ImageView(getActivity());
    icon.setClickable(true);
    if (f.getSelector() != 0) {
        icon.setBackgroundResource(f.getSelector());
    } else {
        icon.setBackgroundDrawable(ShareMenuButtonFactory.get(f.getColor(), getActivity()));
        icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        icon.setImageResource(f.getIcon());
    }

    shareItem.addView(icon, shareIconSize, shareIconSize);
    shareItem.addView(title);

    View.OnClickListener l = v -> {
        hide();
        onItemClicked(v.getId());
    };
    icon.setId(f.getId());
    icon.setOnClickListener(l);

    shareItem.setTag(R.id.title, title);
    shareItem.setTag(R.id.icon, icon);
    shareItem.setTag(R.id.list, l);

    return shareItem;
}
 
Example 16
Source File: ProjectAdapter.java    From microbit with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Project project = mProjects.get(position);
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
        convertView = inflater.inflate(R.layout.project_items, null);
    }

    Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
    appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());

    ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
    appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());

    LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
    if(actionBarLayout != null) {
        if(project.actionBarExpanded) {
            actionBarLayout.setVisibility(View.VISIBLE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_down), null);
        } else {
            actionBarLayout.setVisibility(View.GONE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_left), null);
        }
    }

    appNameButton.setText(project.name);
    appNameButton.setTag(R.id.positionId, position);
    appNameButton.setTag(R.id.textEdit, appNameEdit);
    appNameButton.setOnClickListener(appNameClickListener);
    appNameButton.setOnLongClickListener(appNameLongClickListener);

    appNameEdit.setTag(R.id.positionId, position);
    appNameEdit.setTag(R.id.editbutton, appNameButton);
    appNameEdit.setOnEditorActionListener(editorOnActionListener);
    appNameEdit.setFilters(new InputFilter[]{renameFilter});

    if(project.inEditMode) {
        appNameEdit.setVisibility(View.VISIBLE);

        appNameEdit.setText(project.name);
        appNameEdit.setSelection(project.name.length());
        appNameEdit.requestFocus();
        appNameButton.setVisibility(View.INVISIBLE);

    } else {
        appNameEdit.setVisibility(View.INVISIBLE);
        appNameButton.setVisibility(View.VISIBLE);
        //dismissKeyBoard(appNameEdit, false);
    }

    //appNameEdit.setOnClickListener(appNameClickListener);

    TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
    flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
    LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
    sendBtnLayout.setTag(position);
    sendBtnLayout.setOnClickListener(sendBtnClickListener);

    ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
    deleteBtn.setTag(position);
    deleteBtn.setOnClickListener(deleteBtnClickListener);
    deleteBtn.setEnabled(true);


    Drawable myIcon;
    if(project.runStatus) {
        flashBtnText.setText("");
        myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
    } else {
        flashBtnText.setText(R.string.flash);
        myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
    }
    sendBtnLayout.setBackground(myIcon);

    sendBtnLayout.setClickable(true);
    return convertView;
}
 
Example 17
Source File: DeviceServicesActivity.java    From EFRConnect-android with Apache License 2.0 4 votes vote down vote up
/**
 * SHOW CHARACTERISTIC PROPERTIES IN UI: READ, WRITE
 ************************************/
private void addPropertiesToCharacteristic(BluetoothGattCharacteristic bluetoothGattCharacteristic,
                                           LinearLayout propsContainer) {
    String propertiesString = Common.getProperties(DeviceServicesActivity.this, bluetoothGattCharacteristic.getProperties());
    String[] propsExploded = propertiesString.split(",");


    if (Arrays.toString(propsExploded).toLowerCase().contains("write no response")) {
        ArrayList<String> temp = new ArrayList<>();
        boolean writeAdded = false;

        for (String s : propsExploded) {
            if (s.toLowerCase().contains("write no response") && !writeAdded) {
                temp.add("Write");
                writeAdded = true;
            } else if (!s.toLowerCase().contains("write")) {
                temp.add(s);
            }
        }

        propsExploded = new String[temp.size()];

        for (int i = 0; i < temp.size(); i++) {
            propsExploded[i] = temp.get(i);
        }
    }

    for (String propertyValue : propsExploded) {
        TextView propertyView = new TextView(this);

        String propertyValueTrimmed = propertyValue.trim();
        propertyValueTrimmed = propertyValue.length() > 13 ? propertyValue.substring(0, 13) : propertyValueTrimmed;
        propertyView.setText(propertyValueTrimmed);
        propertyView.setBackgroundColor(ContextCompat.getColor(DeviceServicesActivity.this, R.color.silabs_white));
        propertyView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_property_text_size));
        propertyView.setTextColor(ContextCompat.getColor(DeviceServicesActivity.this, R.color.silabs_inactive));
        propertyView.setTypeface(Typeface.DEFAULT_BOLD);
        propertyView.setGravity(Gravity.CENTER_VERTICAL);

        LinearLayout propertyContainer = new LinearLayout(DeviceServicesActivity.this);
        propertyContainer.setOrientation(LinearLayout.HORIZONTAL);

        ImageView propertyIcon = new ImageView(DeviceServicesActivity.this);
        int iconId;
        if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_BROADCAST)) {
            iconId = R.drawable.debug_prop_broadcast;
        } else if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_READ)) {
            iconId = R.drawable.ic_icon_read_off;
        } else if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_WRITE)) {
            iconId = R.drawable.ic_icon_edit_off;
        } else if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_NOTIFY)) {
            iconId = R.drawable.ic_icon_notify_off;
        } else if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_INDICATE)) {
            iconId = R.drawable.ic_icon_indicate_off;
        } else if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_SIGNED_WRITE)) {
            iconId = R.drawable.debug_prop_signed_write;
        } else if (propertyValue.trim().toUpperCase().equals(Common.PROPERTY_VALUE_EXTENDED_PROPS)) {
            iconId = R.drawable.debug_prop_ext;
        } else {
            iconId = R.drawable.debug_prop_ext;
        }
        propertyIcon.setBackgroundResource(iconId);
        propertyIcon.setTag(PROPERTY_ICON_TAG);
        propertyView.setTag(PROPERTY_NAME_TAG);

        LinearLayout.LayoutParams paramsText = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        paramsText.gravity = Gravity.CENTER_VERTICAL;

        //int propIconEdgeLength = getResources().getDimensionPixelSize(R.dimen.prop_icon_edge_length);
        LinearLayout.LayoutParams paramsIcon = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        float d = getResources().getDisplayMetrics().density;
        paramsIcon.setMarginEnd((int) (8 * d));
        paramsIcon.gravity = Gravity.CENTER_VERTICAL;

        propertyContainer.addView(propertyIcon, paramsIcon);
        propertyContainer.addView(propertyView, paramsText);

        propertyContainer.setTag(propertyValue);

        LinearLayout.LayoutParams paramsTextAndIconContainer = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
        paramsTextAndIconContainer.setMargins(0, (int) (4 * d), (int) (10 * d), 0);
        propertyContainer.setPadding((int) (2 * d), (int) (8 * d), (int) (6 * d), (int) (6 * d));
        propsContainer.addView(propertyContainer, paramsTextAndIconContainer);
    }
}
 
Example 18
Source File: PbChatActivity.java    From imsdk-android with MIT License 4 votes vote down vote up
/**
 * at消息提示
 */
@SuppressLint("ObjectAnimatorBinding")
public void showAtmsgView() {
    if (isFinishing()) {
        return;
    }
    ImageView tipImage = new ImageView(PbChatActivity.this);
    tipImage.setImageResource(R.drawable.atom_ui_chat_unread_tip);

    final TextView textView = new TextView(PbChatActivity.this);
    int padding = Utils.dipToPixels(PbChatActivity.this, 4);
    int size = Utils.dipToPixels(PbChatActivity.this, 30);
    int topMargin = Utils.dipToPixels(PbChatActivity.this, 70);
    final LinearLayout linearLayout = new LinearLayout(PbChatActivity.this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.setBackgroundResource(R.drawable.atom_ui_float_tab);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            size);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    layoutParams.setMargins(0, topMargin, 0, 0);
    linearLayout.setPadding(padding * 2, padding, padding * 2, padding);
    linearLayout.setLayoutParams(layoutParams);
    textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);

    String msg = MessageFormat.format(getString(R.string.atom_ui_tip_somebody_at_you), atMsgIndexs.size());
    textView.setText(msg);
    textView.setTextColor(Color.parseColor("#EB524A"));
    textView.setPadding(padding * 2, 0, 0, 0);
    textView.setOnClickListener(v -> {
        chat_region.getRefreshableView().smoothScrollToPosition(atMsgIndex);
        clearAtmsgTip();
    });
    linearLayout.addView(tipImage);
    linearLayout.addView(textView);
    linearLayout.setTag(TAG_ATMSG_VIEW);
    final LayoutTransition layoutTransition = new LayoutTransition();
    layoutTransition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(this, "scaleX", 0, 1));
    getHandler().postDelayed(() -> {
        if (!isFinishing()) {
            chating_view.setLayoutTransition(layoutTransition);
            chating_view.addView(linearLayout);
        }
    }, 500);
}
 
Example 19
Source File: FollowList.java    From AndroidLinkup with GNU General Public License v2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	FollowListItem item = null;
	if (convertView == null) {
		LinearLayout llItem = new LinearLayout(parent.getContext());
		item = new FollowListItem();
		llItem.setTag(item);
		convertView = llItem;

		item.aivIcon = new AsyncImageView(getContext());
		int dp_52 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 52);
		int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10);
		int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 5);
		LinearLayout.LayoutParams lpIcon = new LinearLayout.LayoutParams(dp_52, dp_52);
		lpIcon.gravity = Gravity.CENTER_VERTICAL;
		lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
		item.aivIcon.setLayoutParams(lpIcon);
		llItem.addView(item.aivIcon);

		LinearLayout llText = new LinearLayout(parent.getContext());
		llText.setPadding(0, dp_10, dp_10, dp_10);
		llText.setOrientation(LinearLayout.VERTICAL);
		LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpText.gravity = Gravity.CENTER_VERTICAL;
		lpText.weight = 1;
		llText.setLayoutParams(lpText);
		llItem.addView(llText);

		item.tvName = new TextView(parent.getContext());
		item.tvName.setTextColor(0xff000000);
		item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
		item.tvName.setSingleLine();
		llText.addView(item.tvName);

		item.tvSign = new TextView(parent.getContext());
		item.tvSign.setTextColor(0x7f000000);
		item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
		item.tvSign.setSingleLine();
		llText.addView(item.tvSign);

		item.ivCheck = new ImageView(parent.getContext());
		item.ivCheck.setPadding(0, 0, dp_10, 0);
		LinearLayout.LayoutParams lpCheck = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpCheck.gravity = Gravity.CENTER_VERTICAL;
		item.ivCheck.setLayoutParams(lpCheck);
		llItem.addView(item.ivCheck);
	} else {
		item = (FollowListItem) convertView.getTag();
	}

	Following following = getItem(position);
	item.tvName.setText(following.screeName);
	item.tvSign.setText(following.description);
	item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch);
	if (isFling()) {
		Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
		if (bm != null && !bm.isRecycled()) {
			item.aivIcon.setImageBitmap(bm);
		} else {
			item.aivIcon.execute(null, AsyncImageView.DEFAULT_TRANSPARENT);
		}
	} else {
		item.aivIcon.execute(following.icon);
	}

	if (position == getCount() - 1) {
		next();
	}
	return convertView;
}
 
Example 20
Source File: FollowListPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	FollowListItem item = null;
	boolean simpleMode = "FacebookMessenger".equals(platform.getName());
	if (convertView == null) {
		LinearLayout llItem = new LinearLayout(parent.getContext());
		item = new FollowListItem();
		llItem.setTag(item);
		convertView = llItem;

		int dp_52 = com.mob.tools.utils.R.dipToPx(getContext(), 52);
		int dp_10 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 10);
		int dp_5 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 5);

		if(!simpleMode) {
			item.aivIcon = new AsyncImageView(getContext());
			LayoutParams lpIcon = new LayoutParams(dp_52, dp_52);
			lpIcon.gravity = Gravity.CENTER_VERTICAL;
			lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
			item.aivIcon.setLayoutParams(lpIcon);
			llItem.addView(item.aivIcon);
		}

		LinearLayout llText = new LinearLayout(parent.getContext());
		llText.setPadding(0, dp_10, dp_10, dp_10);
		llText.setOrientation(LinearLayout.VERTICAL);
		LayoutParams lpText = new LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpText.gravity = Gravity.CENTER_VERTICAL;
		lpText.weight = 1;
		llText.setLayoutParams(lpText);
		llItem.addView(llText);

		item.tvName = new TextView(parent.getContext());
		item.tvName.setTextColor(0xff000000);
		item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
		item.tvName.setSingleLine();
		if(simpleMode) {
			item.tvName.setPadding(dp_10, 0, 0, 0);
		}
		llText.addView(item.tvName);

		if(!simpleMode) {
			item.tvSign = new TextView(parent.getContext());
			item.tvSign.setTextColor(0x7f000000);
			item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
			item.tvSign.setSingleLine();
			llText.addView(item.tvSign);
		}

		item.ivCheck = new ImageView(parent.getContext());
		item.ivCheck.setPadding(0, 0, dp_10, 0);
		LayoutParams lpCheck = new LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpCheck.gravity = Gravity.CENTER_VERTICAL;
		item.ivCheck.setLayoutParams(lpCheck);
		llItem.addView(item.ivCheck);
	} else {
		item = (FollowListItem) convertView.getTag();
	}

	Following following = getItem(position);
	item.tvName.setText(following.screenName);
	if(!simpleMode) {
		item.tvSign.setText(following.description);
	}
	item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch);
	if(!simpleMode) {
		if (isFling()) {
			Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
			if (bm != null && !bm.isRecycled()) {
				item.aivIcon.setImageBitmap(bm);
			} else {
				item.aivIcon.execute(null, 0);
			}
		} else {
			item.aivIcon.execute(following.icon,0);
		}
	}

	if (position == getCount() - 1) {
		next();
	}
	return convertView;
}