Java Code Examples for android.widget.TextView#getLayoutParams()

The following examples show how to use android.widget.TextView#getLayoutParams() . 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: SnackbarUtils.java    From SweetTips with Apache License 2.0 6 votes vote down vote up
/**
 * 设置TextView(@+id/snackbar_text)左右两侧的图片
 * @param leftDrawable
 * @param rightDrawable
 * @return
 */
public SnackbarUtils leftAndRightDrawable(@Nullable Drawable leftDrawable, @Nullable Drawable rightDrawable){
    if(getSnackbar()!=null){
        TextView message = (TextView) getSnackbar().getView().findViewById(R.id.snackbar_text);
        LinearLayout.LayoutParams paramsMessage = (LinearLayout.LayoutParams) message.getLayoutParams();
        paramsMessage = new LinearLayout.LayoutParams(paramsMessage.width, paramsMessage.height,0.0f);
        message.setLayoutParams(paramsMessage);
        message.setCompoundDrawablePadding(message.getPaddingLeft());
        int textSize = (int) message.getTextSize();
        Log.e("Jet","textSize:"+textSize);
        if(leftDrawable!=null){
            leftDrawable.setBounds(0,0,textSize,textSize);
        }
        if(rightDrawable!=null){
            rightDrawable.setBounds(0,0,textSize,textSize);
        }
        message.setCompoundDrawables(leftDrawable,null,rightDrawable,null);
        LinearLayout.LayoutParams paramsSpace = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f);
        ((SweetSnackbar.SnackbarLayout)getSnackbar().getView()).addView(new Space(getSnackbar().getView().getContext()),1,paramsSpace);
    }
    return this;
}
 
Example 2
Source File: SweetToast.java    From SweetTips with Apache License 2.0 6 votes vote down vote up
/**
 * 设置当前SweetToast实例的最小宽高
 *  很有用的功能,参考了简书上的文章:http://www.jianshu.com/p/491b17281c0a
 * @param width     SweetToast实例的最小宽度,单位是pix
 * @param height    SweetToast实例的最小高度,单位是pix
 * @return
 */
public SweetToast minSize(int width, int height){
    if(mContentView!=null && mContentView instanceof LinearLayout){
        mContentView.setMinimumWidth(width);
        mContentView.setMinimumHeight(height);
        ((LinearLayout)mContentView).setGravity(Gravity.CENTER);
        try {
            TextView textView = ((TextView) mContentView.findViewById(R.id.message));
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams();
            params.width = LinearLayout.LayoutParams.MATCH_PARENT;
            params.height = LinearLayout.LayoutParams.MATCH_PARENT;
            textView.setLayoutParams(params);
            textView.setGravity(Gravity.CENTER);
        }catch (Exception e){
            Log.e("幻海流心","e:"+e.getLocalizedMessage());
        }
    }
    return this;
}
 
Example 3
Source File: MyFansAdapter.java    From tysq-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 改变关注状态
 *
 * @param isAttention 是否关注
 * @param button      关注按钮
 * @param add         +图片
 * @param layout      父布局
 */
private void changeBtnAttention(boolean isAttention, TextView button, ImageView add, RelativeLayout layout) {
    if (!isAttention) {
        layout.setVisibility(View.VISIBLE);
        layout.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_blue_rect));
        button.setText(R.string.personal_focus_someone);
        add.setVisibility(View.VISIBLE);
        button.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
    } else {
        layout.setVisibility(View.VISIBLE);
        layout.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_dark_gray_fill_4dp));
        button.setText(R.string.personal_focused);
        button.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) button.getLayoutParams();
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        add.setVisibility(View.GONE);
    }
}
 
Example 4
Source File: MLAlertController.java    From NewXmPluginSDK with Apache License 2.0 5 votes vote down vote up
private void centerButton(TextView button) {
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button.getLayoutParams();
    params.gravity = Gravity.CENTER_HORIZONTAL;
    params.weight = 0.5f;
    button.setLayoutParams(params);
    button.setBackgroundResource(R.drawable.common_button);
}
 
Example 5
Source File: RxPopupViewCoordinatesFinder.java    From RxTools-master with Apache License 2.0 5 votes vote down vote up
private static void AdjustHorizotalRightAlignmentOutOfBounds(TextView tipView, ViewGroup root,
                                                             Point point, RxCoordinates anchorViewRxCoordinates,
                                                             RxCoordinates rootLocation) {
    ViewGroup.LayoutParams params = tipView.getLayoutParams();
    int rootLeft = rootLocation.left + root.getPaddingLeft();
    if (point.x < rootLeft){
        int availableSpace = anchorViewRxCoordinates.right - rootLeft;
        point.x = rootLeft;
        params.width = availableSpace;
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        tipView.setLayoutParams(params);
        measureViewWithFixedWidth(tipView, params.width);
    }
}
 
Example 6
Source File: BadgeItem.java    From BottomNavigation with Apache License 2.0 5 votes vote down vote up
/**
 * @param gravity gravity of badge (TOP|LEFT ..etc)
 * @return this, to allow builder pattern
 */
public T setGravity(int gravity) {
    this.mGravity = gravity;
    if (isWeakReferenceValid()) {
        TextView textView = mTextViewRef.get();
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams();
        layoutParams.gravity = gravity;
        textView.setLayoutParams(layoutParams);
    }
    return getSubInstance();
}
 
Example 7
Source File: MainActivity.java    From iTab with Apache License 2.0 5 votes vote down vote up
private View createTabIndicator(String label, Drawable drawable) {
	View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, mTabHost.getTabWidget(), false);

	TextView txtTitle = (TextView) tabIndicator.findViewById(R.id.text_view_tab_title);
	txtTitle.setText(label);
	LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) txtTitle.getLayoutParams();
	txtTitle.setLayoutParams(params);

	ImageView imgIcon = (ImageView) tabIndicator.findViewById(R.id.image_view_tab_icon);
	imgIcon.setImageDrawable(drawable);
	
	return tabIndicator;
}
 
Example 8
Source File: TimeAttackActivity.java    From FixMath with Apache License 2.0 5 votes vote down vote up
private void setCorrectFrameFigure(ImageView correctFrameFigure, int index) {
    TextView correctFrameTextView = (TextView) findViewById(R.id.correctFigure_1);
    int correctFrameFigureWidth = correctFrameTextView.getLayoutParams().width;
    int correctFrameFigureHeight = correctFrameTextView.getLayoutParams().height;

    if (level.GetTimeAttackCorrectFigures(index).equals("k")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.kwadrat_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("o")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.okrag_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("r")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.romb_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("s")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.skat_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("rf")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.romb_f_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("oz")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.okrag_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("ok")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.okat_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    } else if (level.GetTimeAttackCorrectFigures(index).equals("q")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.question_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    }else if (level.GetTimeAttackCorrectFigures(index).equals("kf")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.kwadrat_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    }else if (level.GetTimeAttackCorrectFigures(index).equals("kb")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.kwadrat_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    }else if (level.GetTimeAttackCorrectFigures(index).equals("rg")) {
        correctFrameFigure.setImageBitmap(BitmapManager.decodeSampledBitmapFromResource(getResources(),
                R.drawable.romb_ramka, correctFrameFigureWidth, correctFrameFigureHeight));
    }
}
 
Example 9
Source File: ExpandTextView.java    From youqu_master with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化
 */
private void init() {
    View.inflate(mContext, R.layout.expand_text_view, this);
    mTitleView = (TextView) findViewById(R.id.tv_title);
    mContentView = (TextView) findViewById(R.id.tv_content);
    mHintView = (TextView) findViewById(R.id.tv_more_hint);
    mIndicateImage = (ImageView) findViewById(R.id.iv_arrow_more);
    mShowMore = (RelativeLayout) findViewById(R.id.rl_show_more);

    mTitleView.setText(title);
    mTitleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
    mTitleView.setTextColor(titleTextColor);

    mContentView.setText(content);
    mContentView.setTextSize(TypedValue.COMPLEX_UNIT_PX, contentTextSize);
    mContentView.setTextColor(contentTextColor);

    mHintView.setText(expandHint);
    mHintView.setTextSize(TypedValue.COMPLEX_UNIT_PX, hintTextSize);
    mHintView.setTextColor(hintTextColor);

    if (indicateImage == null) {
        indicateImage = getResources().getDrawable(R.drawable.ic_arrow_down_light_round);
    }
    mIndicateImage.setImageDrawable(indicateImage);
    mShowMore.setOnClickListener(this);
    ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams();
    layoutParams.height = getMinMeasureHeight();
    mContentView.setLayoutParams(layoutParams);
}
 
Example 10
Source File: ActivityMain.java    From XPrivacy with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void publishResults(CharSequence constraint, FilterResults results) {
	if (results != null) {
		clear();
		TextView tvStats = (TextView) findViewById(R.id.tvStats);
		TextView tvState = (TextView) findViewById(R.id.tvState);
		ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter);
		pbFilter.setVisibility(ProgressBar.GONE);
		tvStats.setVisibility(TextView.VISIBLE);

		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				setProgress(getString(R.string.title_restrict), 0, 1);
			}
		});

		// Adjust progress state width
		RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams();
		tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.tvStats);

		if (results.values == null)
			notifyDataSetInvalidated();
		else {
			addAll((ArrayList<ApplicationInfoEx>) results.values);
			notifyDataSetChanged();
		}
		AppListAdapter.this.showStats();
	}
}
 
Example 11
Source File: ChangeClarityDialog.java    From YCVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 设置清晰度等级
 * @param items          清晰度等级items
 * @param defaultChecked 默认选中的清晰度索引
 */
public void setClarityGrade(List<String> items, int defaultChecked) {
    mCurrentCheckedIndex = defaultChecked;
    for (int i = 0; i < items.size(); i++) {
        TextView itemView = (TextView) LayoutInflater.from(getContext())
                .inflate(R.layout.change_video_clarity, mLinearLayout, false);
        itemView.setTag(i);
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mListener != null) {
                    int checkIndex = (int) v.getTag();
                    if (checkIndex != mCurrentCheckedIndex) {
                        for (int j = 0; j < mLinearLayout.getChildCount(); j++) {
                            mLinearLayout.getChildAt(j).setSelected(checkIndex == j);
                        }
                        mListener.onClarityChanged(checkIndex);
                        mCurrentCheckedIndex = checkIndex;
                    } else {
                        mListener.onClarityNotChanged();
                    }
                }
                ChangeClarityDialog.this.dismiss();
            }
        });
        itemView.setText(items.get(i));
        itemView.setSelected(i == defaultChecked);
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)
                itemView.getLayoutParams();
        params.topMargin = (i == 0) ? 0 : VideoPlayerUtils.dp2px(getContext(), 16f);
        mLinearLayout.addView(itemView, params);
    }
}
 
Example 12
Source File: AndroidActivityTest.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void shouldHaveDefaultMargin()  {
    RobolectricActivity activity = rule.getActivity();
    TextView textView = (TextView) activity.findViewById(R.id.hello_textview);

    int bottomMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).bottomMargin;
    assertEquals(dpToPx(activity.getApplicationContext(),5), bottomMargin);
    int topMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).topMargin;
    assertEquals(dpToPx(activity.getApplicationContext(),5), topMargin);
    int rightMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).rightMargin;
    assertEquals(dpToPx(activity.getApplicationContext(),10), rightMargin);
    int leftMargin = ((LinearLayout.LayoutParams) textView.getLayoutParams()).leftMargin;
    assertEquals(dpToPx(activity.getApplicationContext(),10) , leftMargin);
}
 
Example 13
Source File: ElementDescriptorView.java    From px-android with MIT License 5 votes vote down vote up
private void configureTextView(final TextView text, final float textSize, final int textColor,
    final int textMaxLines,
    final int gravity) {
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    text.setTextColor(textColor);
    if (textMaxLines != DEFAULT_MAX_LINES) {
        text.setMaxLines(textMaxLines);
    }
    final LayoutParams titleParams = (LayoutParams) text.getLayoutParams();
    titleParams.gravity = gravity;
    text.setLayoutParams(titleParams);
}
 
Example 14
Source File: UIActionSheetDialog.java    From UIWidget with Apache License 2.0 5 votes vote down vote up
/**
 * 创建取消按钮
 */
private void createCancel() {
    if (TextUtils.isEmpty(mCancelStr)) {
        return;
    }
    mTvCancel = new TextView(mContext);
    mTvCancel.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mTvCancel.setMinimumHeight(mItemsMinHeight);
    mTvCancel.setId(R.id.tv_cancelActionSheetDialog);
    mLLayoutRoot.addView(mTvCancel);

    mTvCancel.setLineSpacing(mLineSpacingExtra, mLineSpacingMultiplier);
    mTvCancel.setGravity(mCancelGravity);
    mTvCancel.setCompoundDrawablePadding(mTextDrawablePadding);
    mTvCancel.setPadding(mItemsTextPaddingLeft, mItemsTextPaddingTop, mItemsTextPaddingRight, mItemsTextPaddingBottom);
    mTvCancel.setText(mCancelStr);
    mTvCancel.setTextSize(mTextSizeUnit, mCancelTextSize);
    mTvCancel.setTextColor(mCancelTextColor);
    if (mCancelMarginTop > 0) {
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mTvCancel.getLayoutParams();
        if (lp != null) {
            lp.topMargin = mCancelMarginTop;
            mTvCancel.setLayoutParams(lp);
        }
    }
    boolean single = mCancelMarginTop > 0 || TextUtils.isEmpty(mTitleStr) && mViewItem == null || mBottomDrawable == null;
    setViewBackground(mTvCancel, DrawableUtil.getNewDrawable(single ? mStateDrawableSingle : mStateDrawableBottom));

    mTvCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDialog.dismiss();
        }
    });
    setTextViewLine(mTvCancel);
}
 
Example 15
Source File: LikeMeFeedAdapter.java    From umeng_community_android with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void updateShareTextViewParams(TextView textView) {
    LayoutParams params = (LayoutParams) textView.getLayoutParams();
    params.width = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    params.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    textView.setLayoutParams(params);
    textView.setBackgroundDrawable(null);
}
 
Example 16
Source File: MenuDialogAdapter.java    From MarketAndroidApp with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.main_menu_item, null);
    }


    //绑定item内的TextView和RadioButton
    TextView nameText = MenuDialogAdapterViewHolder.get(convertView, R.id.menu_item_textview);
    RadioButton clickButton = MenuDialogAdapterViewHolder.get(convertView, R.id.radioButton);
    clickButton.setChecked(selectedPos == position);//改变点击选中状态

    //修改item高度,使其达到甲方要求的每页10个item显示要求
    ViewGroup.LayoutParams lp = nameText.getLayoutParams();
    lp.height = parent.getHeight() / 10;

    //获取选中的item的标题
    CommodityTypeModel menuData = menuDatas.get(position);
    String str = menuData.getName();
    nameText.setText(str);//设置标题

    convertView.setSelected(selectedPos == position);//设置选中时的view
    nameText.setSelected(selectedPos == position);//判断菜单的点击状态

    //选中后的标题字体及RadioButton颜色
    nameText.setTextColor(selectedPos == position ? 0xFF387ef5 : 0xFF222222);
    clickButton.setTextColor(selectedPos == position ? 0xFF787878 : 0xFF387ef5);

    return convertView;
}
 
Example 17
Source File: AlbumVideoController.java    From letv with Apache License 2.0 4 votes vote down vote up
private void initNonCopyrightBtn(TextView textView) {
    textView.setBackgroundResource(R.drawable.noncopyright_album_play_btn);
    textView.getLayoutParams().width = UIsUtils.dipToPx(40.0f);
    textView.getLayoutParams().height = UIsUtils.dipToPx(19.0f);
    textView.setTextColor(Color.parseColor("#ccfcfcfc"));
}
 
Example 18
Source File: ActionBarMenuItem.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text) {
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL) {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    } else {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL) {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view -> {
        if (popupWindow != null && popupWindow.isShowing()) {
            if (processedPopupClick) {
                return;
            }
            processedPopupClick = true;
            if (!allowCloseAnimation) {
                popupWindow.setAnimationStyle(R.style.PopupAnimation);
            }
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null) {
            parentMenu.onItemClick((Integer) view.getTag());
        } else if (delegate != null) {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}
 
Example 19
Source File: DingDingDialog.java    From xposed-rimet with Apache License 2.0 4 votes vote down vote up
@Override
    protected void initView(View view, Bundle args) {
        super.initView(view, args);

        // 创建对象
//        mRimetPresenter = new RimetPresenter(getPluginManager(), this);

        setTitle(Constant.Name.TITLE);

        TextView tvExt = sivSettingsLocation.getExtendView();
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) tvExt.getLayoutParams();
        params.leftMargin = DisplayUtil.dip2px(getContext(), 100);
        tvExt.setMaxLines(2);
        tvExt.setEllipsize(TextUtils.TruncateAt.END);
        tvExt.setTextSize(12);

        SharedPreferences preferences = getDefaultSharedPreferences();
        XPlugin xPlugin = getPluginManager().getXPluginById(Constant.Plugin.DING_DING);

        sivLuckyEnable.bind(getDefaultSharedPreferences(),
                Integer.toString(Constant.XFlag.ENABLE_LUCKY), true,
                (view1, key, value) -> {
                    xPlugin.setEnable(Constant.XFlag.ENABLE_LUCKY, value);
                    return true;
                });

        sivLuckyDelayed.bind(getDefaultSharedPreferences(),
                Integer.toString(Constant.XFlag.LUCKY_DELAYED), "",
                (view12, key, value) -> true);

        sivFastLuckyEnable.bind(getDefaultSharedPreferences(),
                Integer.toString(Constant.XFlag.ENABLE_FAST_LUCKY), true,
                (view1, key, value) -> {
                    xPlugin.setEnable(Constant.XFlag.ENABLE_FAST_LUCKY, value);
                    return true;
                });

        sivRecallEnable.bind(getDefaultSharedPreferences(),
                Integer.toString(Constant.XFlag.ENABLE_RECALL), true,
                (view1, key, value) -> {
                    xPlugin.setEnable(Constant.XFlag.ENABLE_RECALL, value);
                    return true;
                });

        sivLocationEnable.bind(getDefaultSharedPreferences(),
                Integer.toString(Constant.XFlag.ENABLE_LOCATION), false,
                (view1, key, value) -> {
                    xPlugin.setEnable(Constant.XFlag.ENABLE_LOCATION, value);
                    return true;
                });

        // 设置初始信息
        sivSettingsLocation.setExtend(preferences.getString(
                Integer.toString(Constant.XFlag.ADDRESS), ""));
        sivSettingsLocation.setOnClickListener(v -> {
            // 跳转到地图界面
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.setClassName(BuildConfig.APPLICATION_ID, MapActivity.class.getName());
            startActivityForResult(intent, 99);
        });

        sivLove.setOnClickListener(v -> {
            // 打开捐赠界面
            LoveDialog loveDialog = new LoveDialog();
            loveDialog.show(getFragmentManager(), "love");
        });

        sivAbout.setOnClickListener(v -> {
            // 打开关于界面
            DialogUtil.showAboutDialog(getContext());
        });

        // 是否支持版本
        XConfig xConfig = getPluginManager().getVersionManager().getSupportConfig();
        setPromptText(xConfig != null ? "" : "不支持当前版本!");
    }
 
Example 20
Source File: BaseViewHolder.java    From UltimateRecyclerView with Apache License 2.0 4 votes vote down vote up
protected RelativeLayout.LayoutParams getParamsLayoutOffset(TextView layout, T itemData) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
    params.leftMargin = itemMargin * itemData.getTreeDepth() + offsetMargin;
    return params;
}