Search in sources :

Example 61 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project focus-android by mozilla-mobile.

the class SearchEngineListPreference method refreshSearchEngineViews.

private void refreshSearchEngineViews(Context context, SearchEngineManager sem) {
    if (searchEngineGroup == null) {
        // so searchEngineGroup is not set yet.
        return;
    }
    final String defaultSearchEngine = sem.getDefaultSearchEngine(context).getIdentifier();
    searchEngineGroup.removeAllViews();
    final LayoutInflater layoutInflater = LayoutInflater.from(context);
    final RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    for (int i = 0; i < searchEngines.size(); i++) {
        final SearchEngine engine = searchEngines.get(i);
        final String engineId = engine.getIdentifier();
        final CompoundButton engineItem = makeButtonFromSearchEngine(engine, layoutInflater, context.getResources());
        engineItem.setId(i);
        engineItem.setTag(engineId);
        if (engineId.equals(defaultSearchEngine)) {
            updateDefaultItem(engineItem);
        }
        searchEngineGroup.addView(engineItem, layoutParams);
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) CompoundButton(android.widget.CompoundButton)

Example 62 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project 91Pop by DanteAndroid.

the class MeiZiTuAdapter method convert.

@Override
protected void convert(BaseViewHolder helper, MeiZiTu item) {
    ImageView imageView = helper.getView(R.id.iv_item_mei_zi_tu);
    GlideApp.with(helper.itemView.getContext()).load(buildGlideUrl(item.getThumbUrl())).transition(new DrawableTransitionOptions().crossFade(300)).into(imageView);
    int height;
    if (!heightMap.containsKey(item.getThumbUrl())) {
        height = item.getHeight() * width / item.getWidth();
        heightMap.put(item.getThumbUrl(), height);
    } else {
        height = heightMap.get(item.getThumbUrl());
    }
    StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) helper.itemView.getLayoutParams();
    layoutParams.height = height;
    helper.itemView.setLayoutParams(layoutParams);
}
Also used : DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ImageView(android.widget.ImageView)

Example 63 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project 91Pop by DanteAndroid.

the class Mm99Adapter method convert.

@Override
protected void convert(final BaseViewHolder helper, final Mm99 item) {
    final ImageView imageView = helper.getView(R.id.iv_item_99_mm);
    GlideApp.with(helper.itemView.getContext()).asBitmap().load(item.getImgUrl()).transition(new BitmapTransitionOptions().crossFade(300)).into(new SimpleTarget<Bitmap>() {

        @Override
        public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
            imageView.setImageBitmap(resource);
            int height;
            if (!heightMap.containsKey(item.getImgUrl())) {
                height = resource.getHeight() * width / item.getImgWidth();
                heightMap.put(item.getImgUrl(), height);
            } else {
                height = heightMap.get(item.getImgUrl());
            }
            StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) helper.itemView.getLayoutParams();
            layoutParams.height = height;
            helper.itemView.setLayoutParams(layoutParams);
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) BitmapTransitionOptions(com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ImageView(android.widget.ImageView)

Example 64 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project 91Pop by DanteAndroid.

the class PigAvAdapter method convert.

@Override
protected void convert(BaseViewHolder helper, PigAv item) {
    helper.setText(R.id.tv_item_pig_av_title, item.getTitle());
    int height;
    if (!heightMap.containsKey(item.getImgUrl())) {
        height = item.getImgHeight() * width / item.getImgWidth() + 15;
        heightMap.put(item.getImgUrl(), height);
    } else {
        height = heightMap.get(item.getImgUrl());
    }
    AppCompatImageView imageView = helper.getView(R.id.iv_item_pig_av_img);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) imageView.getLayoutParams();
    layoutParams.height = height;
    imageView.setLayoutParams(layoutParams);
    GlideApp.with(helper.itemView).load(item.getImgUrl()).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(imageView);
}
Also used : DrawableTransitionOptions(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions) AppCompatImageView(android.support.v7.widget.AppCompatImageView) LinearLayout(android.widget.LinearLayout)

Example 65 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project AgentWebX5 by Justson.

the class ScrollingUtil method isRecyclerViewToTop.

public static boolean isRecyclerViewToTop(RecyclerView recyclerView) {
    if (recyclerView != null) {
        RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
        if (manager == null) {
            return true;
        }
        if (manager.getItemCount() == 0) {
            return true;
        }
        int firstChildTop = 0;
        if (recyclerView.getChildCount() > 0) {
            // 处理item高度超过一屏幕时的情况
            View firstVisibleChild = recyclerView.getChildAt(0);
            if (firstVisibleChild != null && firstVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) {
                if (android.os.Build.VERSION.SDK_INT < 14) {
                    return !(ViewCompat.canScrollVertically(recyclerView, -1) || recyclerView.getScrollY() > 0);
                } else {
                    return !ViewCompat.canScrollVertically(recyclerView, -1);
                }
            }
            // 如果RecyclerView的子控件数量不为0,获取第一个子控件的top
            // 解决item的topMargin不为0时不能触发下拉刷新
            View firstChild = recyclerView.getChildAt(0);
            RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) firstChild.getLayoutParams();
            firstChildTop = firstChild.getTop() - layoutParams.topMargin - getRecyclerViewItemTopInset(layoutParams) - recyclerView.getPaddingTop();
        }
        if (manager instanceof LinearLayoutManager) {
            LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
            if (layoutManager.findFirstCompletelyVisibleItemPosition() < 1 && firstChildTop == 0) {
                return true;
            }
        } else if (manager instanceof StaggeredGridLayoutManager) {
            StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager;
            int[] out = layoutManager.findFirstCompletelyVisibleItemPositions(null);
            if (out[0] < 1 && firstChildTop == 0) {
                return true;
            }
        }
    }
    return false;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) View(android.view.View) WebView(android.webkit.WebView)

Aggregations

View (android.view.View)140 RecyclerView (android.support.v7.widget.RecyclerView)127 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)38 ViewGroup (android.view.ViewGroup)33 LinearLayout (android.widget.LinearLayout)27 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)17 Paint (android.graphics.Paint)15 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 BindView (butterknife.BindView)12 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)11 Toolbar (android.support.v7.widget.Toolbar)11 Rect (android.graphics.Rect)9 EditText (android.widget.EditText)9 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)9 AdapterView (android.widget.AdapterView)8 RelativeLayout (android.widget.RelativeLayout)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7