Java 类android.support.v7.widget.ViewStubCompat 实例源码

项目:eazycore    文件:BaseMainWithDataFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    rootLayout = (LinearLayout) rootView.findViewById(R.id.root_layout);
    replaceLayout = (ViewStubCompat) rootView.findViewById(R.id.replace_layout);
    multiStateView = (MultiStateView) rootView.findViewById(R.id.multiStateView);
    if (inflateExtraView() != -1) {
        replaceLayout.setLayoutResource(inflateExtraView());
        replaceLayout.inflate();
    }
    swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
    swipeRefresh.setOnRefreshListener(onRefreshListener());

    multiStateView.setStateListener(onStateListener());
    return view;
}
项目:EazyBaseMVP    文件:BaseMainWithDataFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    rootLayout = (LinearLayout) rootView.findViewById(R.id.root_layout);
    replaceLayout = (ViewStubCompat) rootView.findViewById(R.id.replace_layout);
    multiStateView = (MultiStateView) rootView.findViewById(R.id.multiStateView);
    if (inflateExtraView() != -1) {
        replaceLayout.setLayoutResource(inflateExtraView());
        replaceLayout.inflate();
    }
    swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
    swipeRefresh.setOnRefreshListener(onRefreshListener());

    multiStateView.setStateListener(onStateListener());
    return view;
}
项目:mimi-reader    文件:GalleryImageBase.java   
public void inflateLayout(@LayoutRes int res, ViewStubCompat.OnInflateListener listener) {
    if (viewStub != null) {
        if (listener != null) {
            viewStub.setOnInflateListener(listener);
        }

        viewStub.setLayoutResource(res);
        viewStub.inflate();
    }
}
项目:EasyIntro    文件:EasyIntroCarouselFragment.java   
private void addIndicator() {
    if (mIndicatorRes != -1) {
        ViewStubCompat viewStub = (ViewStubCompat) mIndicatorsContainer.findViewById(R.id.pageIndicator);
        viewStub.setLayoutResource(mIndicatorRes);
        viewStub.setOnInflateListener(new ViewStubCompat.OnInflateListener() {
            @Override
            public void onInflate(ViewStubCompat stub, View inflated) {
                setViewPagerToPageIndicator();
            }
        });
        View view = viewStub.inflate();
        view.setVisibility(mPageIndicatorVisibility ? View.VISIBLE : View.GONE);
    }
}
项目:eazycore    文件:BaseMainWithDataFragment.java   
public ViewStubCompat getReplaceLayout() {
    return replaceLayout;
}
项目:EazyBaseMVP    文件:BaseMainWithDataFragment.java   
public ViewStubCompat getReplaceLayout() {
    return replaceLayout;
}
项目:mimi-reader    文件:GalleryImageBase.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (view == null || !defaultLayout || getArguments() == null) {
        return;
    }

    viewStub = (ViewStubCompat) view.findViewById(R.id.view_stub);
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);

    final String protocol = MimiUtil.httpOrHttps(getActivity());
    final String baseUrl = getString(R.string.image_link);
    final String basePath = getString(R.string.full_image_path, boardName, tim, fileExt);
    imageUrl = protocol + baseUrl + basePath;

    downloadTask = new DownloadThread(getImageFileLocation(), imageUrl);
    downloadTask.setProgressListener(new DownloadThread.ProgressListener() {
        @Override
        public void onProgressUpdate(int progress) {
            progressBar.setProgress(progress);
        }

        @Override
        public void onComplete(final String filePath) {
            Log.i(LOG_TAG, "Finished downloading image: location=" + filePath);
            if (!TextUtils.isEmpty(filePath) && getActivity() != null) {

                if (progressBar != null) {
                    progressBar.setVisibility(View.GONE);
                }

                imageFile = new File(filePath);
                displayImage(imageFile, getUserVisibleHint());


            }
        }
    });
    downloadTask.setErrorListener(new DownloadThread.ErrorListener() {
        @Override
        public void onError() {
            Log.e(LOG_TAG, "Error downloading file");
        }
    });

    downloadTask.start();
}
项目:EasyIntro    文件:EasyIntroCarouselFragment.java   
private void inflateIndicatorContainer(final View view) {
    final ViewStubCompat indicatorContainerStub = (ViewStubCompat) view.findViewById(R.id.indicatorContainer);

    // set gravity
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) indicatorContainerStub.getLayoutParams();
    params.gravity = mIndicatorContainerGravity;
    indicatorContainerStub.setLayoutParams(params);

    indicatorContainerStub.setLayoutResource(mIndicatorContainer);
    indicatorContainerStub.setOnInflateListener(new ViewStubCompat.OnInflateListener() {
        @Override
        public void onInflate(ViewStubCompat stub, View inflated) {
            // there must be predefined ids
            if (inflated.findViewById(R.id.leftIndicator) == null) {
                throw new RuntimeException(getString(R.string.exception_left_indicator_id));
            } else if (inflated.findViewById(R.id.rightIndicator) == null) {
                throw new RuntimeException(getString(R.string.exception_right_indicator_id));
            } else if (inflated.findViewById(R.id.pageIndicator) == null) {
                throw new RuntimeException(getString(R.string.exception_page_indicator_id));
            }
            // check indicators instanceof
            else if (!(inflated.findViewById(R.id.leftIndicator) instanceof LeftToggleIndicator)) {
                throw new RuntimeException(getString(R.string.exception_previous_indicator_instanceof));
            } else if (!(inflated.findViewById(R.id.rightIndicator) instanceof RightToggleIndicator)) {
                throw new RuntimeException(getString(R.string.exception_next_indicator_instanceof));
            }

            mIndicatorsContainer = inflated;

            // must be initialized after inflating indicator container
            mRightIndicator = (RightToggleIndicator) mIndicatorsContainer.findViewById(R.id.rightIndicator);
            mLeftIndicator = (LeftToggleIndicator) mIndicatorsContainer.findViewById(R.id.leftIndicator);
            mRightIndicator.setListener(EasyIntroCarouselFragment.this);
            mRightIndicator.withDisabled(mRightIndicatorEnabled);
            mLeftIndicator.setListener(EasyIntroCarouselFragment.this);
            mLeftIndicator.withDisabled(mLeftIndicatorEnabled);

            addIndicator();
            updateToggleIndicators();
        }
    });
    indicatorContainerStub.inflate();
}