Java Code Examples for android.support.v7.widget.RecyclerView#setLayoutParams()

The following examples show how to use android.support.v7.widget.RecyclerView#setLayoutParams() . 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: ViewHelper.java    From FABRevealMenu-master with Apache License 2.0 7 votes vote down vote up
public RecyclerView generateMenuView(boolean enableNestedScrolling) {
    //Create menu view
    RecyclerView mMenuView = new RecyclerView(mContext);
    mMenuView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
    mMenuView.setBackgroundColor(Color.TRANSPARENT);
    mMenuView.setLayoutParams(matchParams);
    final int padding = dpToPx(mContext, 10);
    mMenuView.setPadding(padding, padding, padding, padding);
    mMenuView.setNestedScrollingEnabled(enableNestedScrolling);
    return mMenuView;
}
 
Example 2
Source File: ClassifyView.java    From ClassifyView with Apache License 2.0 7 votes vote down vote up
@NonNull
protected RecyclerView getSub(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new GridLayoutManager(context, mSubSpanCount));
    RecyclerView.ItemAnimator itemAnimator = new ClassifyItemAnimator();
    itemAnimator.setChangeDuration(CHANGE_DURATION);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 3
Source File: RecyclerViewHeader.java    From Android-Application-ZJB with Apache License 2.0 7 votes vote down vote up
private void setupAlignment(RecyclerView recycler) {
    if (!mAlreadyAligned) {
        //setting alignment of header
        ViewGroup.LayoutParams currentParams = getLayoutParams();
        FrameLayout.LayoutParams newHeaderParams;
        int width = ViewGroup.LayoutParams.WRAP_CONTENT;
        int height = ViewGroup.LayoutParams.WRAP_CONTENT;
        int gravity = (mReversed ? Gravity.BOTTOM : Gravity.TOP) | Gravity.CENTER_HORIZONTAL;
        if (currentParams != null) {
            newHeaderParams = new FrameLayout.LayoutParams(getLayoutParams()); //to copy all the margins
            newHeaderParams.width = width;
            newHeaderParams.height = height;
            newHeaderParams.gravity = gravity;
        } else {
            newHeaderParams = new FrameLayout.LayoutParams(width, height, gravity);
        }
        RecyclerViewHeader.this.setLayoutParams(newHeaderParams);

        //setting alignment of recycler
        FrameLayout newRootParent = new FrameLayout(recycler.getContext());
        newRootParent.setLayoutParams(recycler.getLayoutParams());
        ViewParent currentParent = recycler.getParent();
        if (currentParent instanceof ViewGroup) {
            int indexWithinParent = ((ViewGroup) currentParent).indexOfChild(recycler);

            ((ViewGroup) currentParent).removeViewAt(indexWithinParent);
            recycler.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            newRootParent.addView(recycler);
            newRootParent.addView(RecyclerViewHeader.this);
            ((ViewGroup) currentParent).addView(newRootParent, indexWithinParent);
        }
    }
}
 
Example 4
Source File: QuickReplyListView.java    From imsdk-android with MIT License 6 votes vote down vote up
private RecyclerView getListView(final List<String> quickReplies, final OnQuickRepliesClickListener listener) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setVerticalScrollBarEnabled(false);
    recyclerView.setHorizontalScrollBarEnabled(false);
    recyclerView.setBackgroundColor(Color.TRANSPARENT);

    QuickReplyAdapter quickReplyAdapter = new QuickReplyAdapter(R.layout.atom_ui_quickreply_item, quickReplies);
    quickReplyAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            listener.onQuickReplyClick(quickReplies.get(position));
        }

    });
    recyclerView.setAdapter(quickReplyAdapter);
    return recyclerView;
}
 
Example 5
Source File: ThumbLineView.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
private void initView() {
    mIndicatorMargin = Utils.dip2px(getContext(), 6);
    mThumbRecyclerView = new RecyclerView(getContext());
    LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lp.setMargins(0, mIndicatorMargin, 0, mIndicatorMargin);
    mThumbRecyclerView.setLayoutParams(lp);
    mThumbRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));

    // 初始化指示器
    View indicator = new View(getContext());
    int indicatorWidth = Utils.dip2px(getContext(), 2);
    LayoutParams params = new LayoutParams(indicatorWidth, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
    indicator.setLayoutParams(params);
    indicator.setBackgroundColor(getResources().getColor(R.color.colorWhite));

    addView(mThumbRecyclerView);
    addView(indicator);
}
 
Example 6
Source File: PageMenuLayout.java    From PageMenuLayout with Apache License 2.0 6 votes vote down vote up
public void setPageDatas(int rowCount, int spanCount, @NonNull List<T> datas, @NonNull PageMenuViewHolderCreator creator) {
    if (datas == null) {
        datas = new ArrayList<>();
    }
    mRowCount = rowCount;
    mSpanCount = spanCount;
    if (mRowCount == 0 || mSpanCount == 0) {
        return;
    }
    int pageSize = mRowCount * mSpanCount;
    int pageCount = (int) Math.ceil(datas.size() * 1.0 / pageSize);
    List<View> viewList = new ArrayList<>();
    for (int index = 0; index < pageCount; index++) {
        RecyclerView recyclerView = new RecyclerView(this.getContext());
        recyclerView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        recyclerView.setLayoutManager(new GridLayoutManager(this.getContext(), mSpanCount));
        EntranceAdapter<T> entranceAdapter = new EntranceAdapter<>(creator, datas, index, pageSize);
        recyclerView.setAdapter(entranceAdapter);
        viewList.add(recyclerView);
    }
    PageViewPagerAdapter adapter = new PageViewPagerAdapter(viewList);
    mViewPager.setAdapter(adapter);
}
 
Example 7
Source File: SearchFragment.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("JavascriptInterface")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    initFabBehavior();

    baseInflateFragment(inflater, R.layout.fragment_search);
    refreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_list);
    searchSettingsView = (ViewGroup) View.inflate(getContext(), R.layout.search_settings, null);

    nickBlock = (ViewGroup) searchSettingsView.findViewById(R.id.search_nick_block);
    resourceBlock = (ViewGroup) searchSettingsView.findViewById(R.id.search_resource_block);
    resultBlock = (ViewGroup) searchSettingsView.findViewById(R.id.search_result_block);
    sortBlock = (ViewGroup) searchSettingsView.findViewById(R.id.search_sort_block);
    sourceBlock = (ViewGroup) searchSettingsView.findViewById(R.id.search_source_block);

    resourceSpinner = (Spinner) searchSettingsView.findViewById(R.id.search_resource_spinner);
    resultSpinner = (Spinner) searchSettingsView.findViewById(R.id.search_result_spinner);
    sortSpinner = (Spinner) searchSettingsView.findViewById(R.id.search_sort_spinner);
    sourceSpinner = (Spinner) searchSettingsView.findViewById(R.id.search_source_spinner);

    nickField = (TextView) searchSettingsView.findViewById(R.id.search_nick_field);

    submitButton = (Button) searchSettingsView.findViewById(R.id.search_submit);
    saveSettingsButton = (Button) searchSettingsView.findViewById(R.id.search_save_settings);

    webView = getMainActivity().getWebViewsProvider().pull(getContext());
    attachWebView(webView);
    recyclerView = new RecyclerView(getContext());
    recyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    refreshLayout.addView(recyclerView);

    paginationHelper = new PaginationHelper(getActivity());
    paginationHelper.addInToolbar(inflater, toolbarLayout, configuration.isFitSystemWindow());

    contentController.setMainRefresh(refreshLayout);
    return view;
}
 
Example 8
Source File: LinearHHClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getSub(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 9
Source File: LinearHHClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getMain(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 10
Source File: WhiteBoardDebugView.java    From Shield with MIT License 5 votes vote down vote up
protected void init() {
    defaultPadding = ViewUtils.dip2px(getContext(), 10);

    recyclerView = new RecyclerView(getContext());
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    adapter = new CustomRecyclerAdapter();
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    addView(recyclerView);
}
 
Example 11
Source File: LinearHVClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getMain(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 12
Source File: LinearVVClassifyView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected RecyclerView getSub(Context context, AttributeSet parentAttrs) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setChangeDuration(10);
    recyclerView.setItemAnimator(itemAnimator);
    return recyclerView;
}
 
Example 13
Source File: SelectActivity.java    From gcm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getIntent().getCategories() == null) {
        setResult(RESULT_CANCELED);
        finish();
    }
    setTitle(getIntent().getStringExtra(INTENT_EXTRA_TITLE));
    setContentView(R.layout.dialog_select_element);

    mRecyclerView = (RecyclerView) findViewById(R.id.select_dialog_list);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int minScreenHeight = 600;
    float activityHeightPercentage = 0.5f;
    if (metrics.heightPixels > minScreenHeight) {
        ViewGroup.LayoutParams layoutParams = mRecyclerView.getLayoutParams();
        layoutParams.height = (int) (metrics.heightPixels * activityHeightPercentage);
        mRecyclerView.setLayoutParams(layoutParams);
    }

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mRecyclerView.setHasFixedSize(true);

    // use a linear layout manager
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);

    // specify an adapter (see also next example)
    mAdapter = new SenderAdapter(this);
    mRecyclerView.setAdapter(mAdapter);

    Button addSenderButton = (Button) findViewById(R.id.select_dialog_add);
    addSenderButton.setOnClickListener(mAdapter);
}
 
Example 14
Source File: LiteIconActivity.java    From NanoIconPackLite with Apache License 2.0 5 votes vote down vote up
private void init() {
    setTheme(android.R.style.Theme_DeviceDefault_Wallpaper);

    displayMetrics = getResources().getDisplayMetrics();

    adapter = new IconAdapter();

    layoutManager = new GridLayoutManager(this, calculateGridNum());
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.isCate(position) ? layoutManager.getSpanCount() : 1;
        }
    });

    RecyclerView recyclerView = new RecyclerView(this);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);

    ViewGroup.LayoutParams lpRv = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    recyclerView.setLayoutParams(lpRv);
    recyclerView.setBackgroundColor(0x80808080); // 保证图标视觉

    setContentView(recyclerView);
}
 
Example 15
Source File: LiteIconActivityV2.java    From NanoIconPackLite with Apache License 2.0 5 votes vote down vote up
private void init() {
    setTheme(android.R.style.Theme_DeviceDefault_Wallpaper);

    displayMetrics = getResources().getDisplayMetrics();

    adapter = new IconAdapter();

    layoutManager = new GridLayoutManager(this, calculateGridNum());
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.isCate(position) ? layoutManager.getSpanCount() : 1;
        }
    });

    RecyclerView recyclerView = new RecyclerView(this);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);

    ViewGroup.LayoutParams lpRv = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    recyclerView.setLayoutParams(lpRv);
    recyclerView.setBackgroundColor(0x80808080); // 保证图标视觉

    setContentView(recyclerView);
}
 
Example 16
Source File: HomeFragment.java    From KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo with Apache License 2.0 5 votes vote down vote up
@Override
protected View addContentView(LayoutInflater inflater) {
    mSwipeRefreshLayout = new SwipeRefreshLayout(getContext());
    mRecyclerView = new RecyclerView(getContext());
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mSwipeRefreshLayout.setLayoutParams(layoutParams);
    ViewGroup.LayoutParams swipeRefreshLayoutParams = new SwipeRefreshLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mRecyclerView.setLayoutParams(swipeRefreshLayoutParams);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    return mSwipeRefreshLayout;
}
 
Example 17
Source File: PBaseLoaderFragment.java    From YImagePicker with Apache License 2.0 5 votes vote down vote up
/**
 * 设置文件夹列表的高度
 *
 * @param mFolderListRecyclerView 文件夹列表
 * @param mImageSetMask           文件夹列表的灰色透明蒙层
 * @param isCrop                  是否是小红书样式
 */
protected void setFolderListHeight(RecyclerView mFolderListRecyclerView, View mImageSetMask, boolean isCrop) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mFolderListRecyclerView.getLayoutParams();
    RelativeLayout.LayoutParams maskParams = (RelativeLayout.LayoutParams) mImageSetMask.getLayoutParams();
    PickerUiConfig uiConfig = getUiConfig();
    int height = uiConfig.getFolderListOpenMaxMargin();
    if (uiConfig.getFolderListOpenDirection() == PickerUiConfig.DIRECTION_BOTTOM) {
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        if (isCrop) {
            params.bottomMargin = bottomBar != null ? bottomBar.getViewHeight() : 0;
            params.topMargin = (titleBar != null ? titleBar.getViewHeight() : 0) + height;
            maskParams.topMargin = (titleBar != null ? titleBar.getViewHeight() : 0);
            maskParams.bottomMargin = bottomBar != null ? bottomBar.getViewHeight() : 0;
        } else {
            params.bottomMargin = 0;
            params.topMargin = height;
        }
    } else {
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
        if (isCrop) {
            params.bottomMargin = height + (bottomBar != null ? bottomBar.getViewHeight() : 0);
            params.topMargin = titleBar != null ? titleBar.getViewHeight() : 0;
            maskParams.topMargin = (titleBar != null ? titleBar.getViewHeight() : 0);
            maskParams.bottomMargin = bottomBar != null ? bottomBar.getViewHeight() : 0;
        } else {
            params.bottomMargin = height;
            params.topMargin = 0;
        }
    }
    mFolderListRecyclerView.setLayoutParams(params);
    mImageSetMask.setLayoutParams(maskParams);
}
 
Example 18
Source File: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    Defaults.setupInitialValues(getApplicationContext(), getIntent());

    if (!Defaults.ACTIVITY_THEME.isEmpty()) {
    		setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME));
    }

    setupIds();
    setContentView(main_layout_id);

    isMultipleSelection = (1 != Defaults.MAX_IMAGE_SELECTION);
    isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE;

    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        if (!Defaults.STATUS_BAR_COLOR.isEmpty()) {
        	window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR));
        }

        window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR));
    }

    ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
    		if (!Defaults.BAR_COLOR.isEmpty()) {
    			actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR));
        }

        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(Defaults.TITLE);

    } else {
    		Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG);
    }


    mRecyclerView = new RecyclerView(TiApplication.getInstance());
    mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mRecyclerView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, Defaults.GRID_SIZE));

    FrameLayout frame_container = (FrameLayout) findViewById(container);
    frame_container.addView(mRecyclerView);
    frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR));

    adapterSet = new PhotoAdapter(adapter);
    mRecyclerView.setAdapter(adapterSet);

    if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) {
    		mRecyclerView.addItemDecoration(new DividerDecoration());
    }

    setupGlideOptions(); // set glide-options to apply on image

    // Get gallery photos in a new UI thread like AsyncTask to update UI changes properly
    new FetchImages().execute();
}
 
Example 19
Source File: ImageViewerActivity.java    From titanium-imagepicker with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    imagesAdapter = intent.getExtras().getParcelableArrayList(Defaults.Params.IMAGES);

    Defaults.setupInitialValues(getApplicationContext(), intent);

    if (!Defaults.ACTIVITY_THEME.isEmpty()) {
 		setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME));
 }

    setupIds();
    setContentView(frame_layout);

    isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE;

    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        if (!Defaults.STATUS_BAR_COLOR.isEmpty()) {
        	window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR));
        }

        window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR));
    }

    ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
    		if (!Defaults.BAR_COLOR.isEmpty()) {
    			actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR));
        }

        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(Defaults.TITLE);
    } else {
 		Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG);
 }

    mRecyclerView = new RecyclerView(TiApplication.getInstance());
    mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mRecyclerView.setLayoutManager(new GridLayoutManager(ImageViewerActivity.this, Defaults.GRID_SIZE));

    FrameLayout frame_container = (FrameLayout) findViewById(frame_layout_id);
    frame_container.addView(mRecyclerView);
    frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR));

    adapterSet = new PhotoAdapter(imagesAdapter);
    mRecyclerView.setAdapter(adapterSet);

    if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) {
    	mRecyclerView.addItemDecoration(new DividerDecoration());
    }

    setupGlideOptions(); // set glide-options to apply on image
}
 
Example 20
Source File: ImageScannerDialogLayout.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
private void initListView() {


        mListView = new RecyclerView(mContext);
        LinearLayoutManager layoutmanager = new LinearLayoutManager(mContext);
        layoutmanager.setOrientation(LinearLayoutManager.VERTICAL);
        mListView.setLayoutManager(layoutmanager);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.topMargin = mTopLayoutHeight;
        mListView.setLayoutParams(params);
        mListView.setBackgroundColor(Color.WHITE);

        imageFloderAdapter = new ImageFloderAdapter(mContext);
        imageFloderAdapter.mOnItemClickListener = new IWidgetClickListener<ImageFolderBean>() {
            @Override
            public void onClick(ImageFolderBean imageFolderBean) {
                initGridView();

                imageModel = new ImageModel();
                imageModel.onCreate(mContext, ImageScannerDialogLayout.this);
                imageModel.load(imageFolderBean);

                mListView.setVisibility(GONE);
                mTitleView.setText("选择图片");
                mCancelView.setVisibility(VISIBLE);
            }
        };
        mListView.setAdapter(imageFloderAdapter);

        imageFolderModel = new ImageFolderModel();
        imageFolderModel.onCreate(mContext, new IImageMediaCallback() {
            @Override
            public void onImageLoad(Cursor cursor) {
                imageFloderAdapter.swapCursor(cursor);
            }

            @Override
            public void onImageReset() {
                imageFloderAdapter.swapCursor(null);
            }
        });
        imageFolderModel.loadImageFolders();

        addView(mListView);
    }