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

The following examples show how to use android.support.v7.widget.RecyclerView#setVisibility() . 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: BookmarkFragment.java    From IslamicLibraryAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_bookmark_list, container, false);

    // Set the adapter
    RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
    ViewStub zeroView = view.findViewById(R.id.zero_bookmarks);


    if (bookmarks.size() != 0) {
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        recyclerView.setAdapter(bookmarkRecyclerViewAdapter);

    } else {
        recyclerView.setVisibility(View.GONE);
        zeroView.setVisibility(View.VISIBLE);
    }

    return view;
}
 
Example 2
Source File: DisplayListFragment.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void afterViewInflate(View view, BindedDisplayList<T> displayList) {
        collection = (RecyclerView) view.findViewById(R.id.collection);
        if (displayList.getSize() == 0) {
            collection.setVisibility(View.INVISIBLE);
        } else {
            collection.setVisibility(View.VISIBLE);
        }
        setAnimationsEnabled(true);

        this.displayList = displayList;
        configureRecyclerView(collection);

        // emptyCollection = res.findViewById(R.id.emptyCollection);

        adapter = onCreateAdapter(displayList, getActivity());

        collection.setAdapter(adapter);

//        if (emptyCollection != null) {
//            emptyCollection.setVisibility(View.GONE);
//        }
    }
 
Example 3
Source File: MainActivity.java    From bitcoinpos with MIT License 6 votes vote down vote up
@Override
// from ItemActionListFragment
public void onDeleteItemAction(int id) {
    ItemHelper itemHelper = ItemHelper.getInstance(getApplicationContext());
    if(itemHelper.delete(id)) {
        // update UI as well (get ItemFragment's recycler view and adapter
        ItemFragment itemFragment = (ItemFragment) mViewPagerAdapter.instantiateItem(null, 0);
        RecyclerView recyclerView = itemFragment.getRecyclerView();
        ItemRecyclerViewAdapter recyclerViewAdapter = (ItemRecyclerViewAdapter) recyclerView.getAdapter();
        if(recyclerViewAdapter.getItemCount() == 1) {
            // if last item is deleted
            recyclerView.setVisibility(View.GONE);
            itemFragment.getEmptyView().setVisibility(View.VISIBLE);
        }
        recyclerViewAdapter.removeItem(id);
    }
}
 
Example 4
Source File: CommentsFragment.java    From 4pdaClient-plus with Apache License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
//        recLifeCycle(getClass(), CALL_TO_SUPER);
        view = inflater.inflate(LAYOUT, container, false);
//        recLifeCycle(getClass(), RETURN_FROM_SUPER);
        mModelList = new Gson().fromJson(getArguments().getString(LIST_ARG),  new TypeToken<ArrayList<CommentsModel>>() {}.getType());
        if (mModelList.size() != 0) {
            RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.devDbRecyclerView);
            recyclerView.setVisibility(View.VISIBLE);
            mAdapter = new CommentsAdapter(getActivity(), mModelList);
            recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
            recyclerView.setAdapter(mAdapter);
            mAdapter.notifyDataSetChanged();
        } else {
            /*CardView cardView = (CardView) view.findViewById(R.id.dev_db_error_message_con);
            cardView.setVisibility(View.VISIBLE);*/
            TextView textView = ButterKnife.findById(view, R.id.dev_db_error_message);
            textView.setVisibility(View.VISIBLE);
        }
        return view;
    }
 
Example 5
Source File: MainActivity.java    From mirror with GNU General Public License v3.0 6 votes vote down vote up
private void setupArtboardListView() {
    mArtboardList = new LinkedList<>();
    mArtboardListAdapter = new ArtboardListAdapter(this, mArtboardList);
    mArtboardListView = (RecyclerView) getLayoutInflater().inflate(R.layout.layout_artboard_list,
            mRootLayout, false);
    mArtboardListView.setAdapter(mArtboardListAdapter);

    final int gridSpanCount = getResources().getInteger(R.integer.grid_span_count);
    GridLayoutManager layoutManager = new GridLayoutManager(this, gridSpanCount);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position <= 0 || position > mArtboardList.size() ? gridSpanCount : 1;
        }
    });
    mArtboardListView.setLayoutManager(layoutManager);

    mArtboardListView.setVisibility(View.INVISIBLE);
    mRootLayout.addView(mArtboardListView);
}
 
Example 6
Source File: PricesFragment.java    From 4pdaClient-plus with Apache License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
//        recLifeCycle(getClass(), CALL_TO_SUPER);
        view = inflater.inflate(LAYOUT, container, false);
//        recLifeCycle(getClass(), RETURN_FROM_SUPER);
        mModelList = new Gson().fromJson(getArguments().getString(LIST_ARG),  new TypeToken<ArrayList<PricesModel>>() {}.getType());
        if (mModelList.size() != 0) {
            mRecyclerView = (RecyclerView) view.findViewById(R.id.devDbRecyclerView);
            mRecyclerView.setVisibility(View.VISIBLE);
            mAdapter = new PricesAdapter(getActivity(), mModelList);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
            mRecyclerView.setAdapter(mAdapter);
            mAdapter.notifyDataSetChanged();
        } else {
            /*CardView cardView = (CardView) view.findViewById(R.id.dev_db_error_message_con);
            cardView.setVisibility(View.VISIBLE);*/
            TextView textView = ButterKnife.findById(view, R.id.dev_db_error_message);
            textView.setVisibility(View.VISIBLE);
        }
        return view;
    }
 
Example 7
Source File: DiscussionFragment.java    From 4pdaClient-plus with Apache License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
//        recLifeCycle(getClass(), CALL_TO_SUPER);
        view = inflater.inflate(LAYOUT, container, false);
//        recLifeCycle(getClass(), RETURN_FROM_SUPER);
        mModelList = new Gson().fromJson(getArguments().getString(LIST_ARG),  new TypeToken<ArrayList<DiscussionModel>>() {}.getType());
        if (mModelList.size() != 0) {
            mRecyclerView = (RecyclerView) view.findViewById(R.id.devDbRecyclerView);
            mRecyclerView.setVisibility(View.VISIBLE);
            mAdapter = new DiscussionAdapter(getActivity(), mModelList);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
            mRecyclerView.setAdapter(mAdapter);
            mAdapter.notifyDataSetChanged();
        } else {
            /*CardView cardView = (CardView) view.findViewById(R.id.dev_db_error_message_con);
            cardView.setVisibility(View.VISIBLE);*/
            TextView textView = ButterKnife.findById(view, R.id.dev_db_error_message);
            textView.setVisibility(View.VISIBLE);
        }
        return view;
    }
 
Example 8
Source File: ReviewsFragment.java    From 4pdaClient-plus with Apache License 2.0 6 votes vote down vote up
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//        recLifeCycle(getClass(), CALL_TO_SUPER);
        view = inflater.inflate(LAYOUT, container, false);
//        recLifeCycle(getClass(), RETURN_FROM_SUPER);
        mModelList = new Gson().fromJson(getArguments().getString(LIST_ARG),  new TypeToken<ArrayList<ReviewsModel>>() {}.getType());
        if (mModelList.size() != 0) {
            mRecyclerView = (RecyclerView) view.findViewById(R.id.devDbRecyclerView);
            mRecyclerView.setVisibility(View.VISIBLE);
            mAdapter = new ReviewsAdapter(getActivity(), mModelList, ImageLoader.getInstance());
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
            mRecyclerView.setAdapter(mAdapter);
            mAdapter.notifyDataSetChanged();
        } else {
            /*CardView cardView = (CardView) view.findViewById(R.id.dev_db_error_message_con);
            cardView.setVisibility(View.VISIBLE);*/
            TextView textView = ButterKnife.findById(view, R.id.dev_db_error_message);
            textView.setVisibility(View.VISIBLE);
        }
        return view;
    }
 
Example 9
Source File: GlobalUserNotesFragment.java    From IslamicLibraryAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_global_user_list, container, false);
    RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
    ViewStub zeroView = view.findViewById(R.id.zero_global_user_notes);

    if ((bookmarkItems.isEmpty() && highlightItems.isEmpty())) {
        recyclerView.setVisibility(View.GONE);
        zeroView.setVisibility(View.VISIBLE);
    } else {
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
Example 10
Source File: FirmwareFragment.java    From 4pdaClient-plus with Apache License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
//        recLifeCycle(getClass(), CALL_TO_SUPER);
        view = inflater.inflate(LAYOUT, container, false);
//        recLifeCycle(getClass(), RETURN_FROM_SUPER);
        mModelList = new Gson().fromJson(getArguments().getString(LIST_ARG),  new TypeToken<ArrayList<FirmwareModel>>() {}.getType());
        if (mModelList.size() != 0) {
            mRecyclerView = (RecyclerView) view.findViewById(R.id.devDbRecyclerView);
            mRecyclerView.setVisibility(View.VISIBLE);
            mAdapter = new FirmwareAdapter(getActivity(), mModelList);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
            mRecyclerView.setAdapter(mAdapter);
            mAdapter.notifyDataSetChanged();
        } else {
            /*CardView cardView = (CardView) view.findViewById(R.id.dev_db_error_message_con);
            cardView.setVisibility(View.VISIBLE);*/
            TextView textView = ButterKnife.findById(view, R.id.dev_db_error_message);
            textView.setVisibility(View.VISIBLE);
        }
        return view;
    }
 
Example 11
Source File: AboutAdapter.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
HeaderViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    RecyclerView recyclerView = itemView.findViewById(R.id.recyclerview);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, true));
    recyclerView.setHasFixedSize(true);

    String[] urls = mContext.getResources().getStringArray(R.array.about_social_links);
    if (urls.length == 0) {
        recyclerView.setVisibility(View.GONE);

        subtitle.setPadding(
                subtitle.getPaddingLeft(),
                subtitle.getPaddingTop(),
                subtitle.getPaddingRight(),
                subtitle.getPaddingBottom() + mContext.getResources().getDimensionPixelSize(R.dimen.content_margin));
    } else {
        if (recyclerView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
            if (urls.length < 7) {
                params.width = LinearLayout.LayoutParams.WRAP_CONTENT;
                params.gravity = Gravity.CENTER_HORIZONTAL;
                recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
            }
        }
        recyclerView.setAdapter(new AboutSocialAdapter(mContext, urls));
    }

    subtitle.setHtml(mContext.getResources().getString(R.string.about_desc));

    CardView card = itemView.findViewById(R.id.card);
    if (!Preferences.get(mContext).isShadowEnabled()) {
        if (card != null) card.setCardElevation(0);

        profile.setShadowRadius(0f);
        profile.setShadowColor(Color.TRANSPARENT);
    }
}
 
Example 12
Source File: MainActivity.java    From mirror with GNU General Public License v3.0 5 votes vote down vote up
private void setupMirrorListView() {
    mMirrorInfoList = new LinkedList<>();
    mMirrorListAdapter = new MirrorListAdapter(this, mMirrorInfoList);
    mMirrorListView = (RecyclerView) getLayoutInflater().inflate(R.layout.layout_artboard_list,
            mRootLayout, false);
    mMirrorListView.setAdapter(mMirrorListAdapter);
    mMirrorListView.setLayoutManager(new LinearLayoutManager(this));

    mMirrorListView.setVisibility(View.VISIBLE);
    mRootLayout.addView(mMirrorListView);
}
 
Example 13
Source File: SearchBar.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
protected void initRecyclerView() {
    _searchRecycler = new RecyclerView(getContext());
    _searchRecycler.setItemAnimator(null);
    _searchRecycler.setVisibility(View.GONE);
    _searchRecycler.setAdapter(_adapter);
    _searchRecycler.setClipToPadding(false);
    _searchRecycler.setHasFixedSize(true);
    updateRecyclerViewLayoutManager();
}
 
Example 14
Source File: SearchActivity.java    From TestChat with Apache License 2.0 5 votes vote down vote up
@Override
public void initView() {
        ToolBarOption toolBarOption = new ToolBarOption();
        toolBarOption.setNeedNavigation(false);
        setToolBar(toolBarOption);
        display = (RecyclerView) findViewById(R.id.rcv_search_display);
        display.setVisibility(GONE);
        findViewById(R.id.ll_search_container).setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                        finish();
                        return true;
                }
        });
}
 
Example 15
Source File: AppChoicesActivity.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_selector);

    LAUNCH_ACTIVITY_ANIM_BUNDLE = ActivityOptions.
            makeCustomAnimation(AppChoicesActivity.this,
                    R.transition.left_in,
                    R.transition.left_out).toBundle();

    mPackageManager = getPackageManager();
    mAppSelectionsStore = AppSelectionsStore.get(this);
    mRecyclerView = (RecyclerView) findViewById(R.id.app_selections_recycler_view);
    mLoadingView = (TextView) findViewById(R.id.app_list_loading_text_view);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    PreferenceManager.setDefaultValues(this, R.xml.main_settings, false);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mShowOnlyEnabledApps = mPreferences.getBoolean(getString(R.string.show_enabled_apps_key), false);

    if (savedInstanceState != null && getSetupStatus(savedInstanceState)) {
        mAppSelections = savedInstanceState.getParcelableArrayList(STATE_APP_SELECTIONS);
        Parcelable listState = savedInstanceState.getParcelable(STATE_RECYCLER_VIEW);

        if (mShowOnlyEnabledApps) {
            List<AppSelection> appSelectionsSubList = new ArrayList<>();

            for (AppSelection appSelection : mAppSelections) {
                if (appSelection.isSelected()) {
                    appSelectionsSubList.add(appSelection);
                }
            }
            mAdapter = new ActivityAdapter(appSelectionsSubList);
        } else {
            mAdapter = new ActivityAdapter(mAppSelections);
        }
        mRecyclerView.setAdapter(mAdapter);
        mRecyclerView.getLayoutManager().onRestoreInstanceState(listState);
        mSetupComplete = getSetupStatus(savedInstanceState);

        DebugLog log = DebugLog.get(getApplicationContext());
        if (log.isEnabled()) {
            log.writeLog("Restoring state may cause problems for some users");
            log.writeLog("Number of applications: " + mAppSelections.size());
            log.writeLog("Loading Text View text: " + mLoadingView.getText());
            log.writeLog("Loading Text View status: " + mLoadingView.getVisibility());
            log.writeLog("Setup status: " + (mSetupComplete ? "true" : "false"));
        }
    } else {
        mLoadingView.setText(getString(R.string.app_list_loading_text));
        mRecyclerView.setVisibility(View.GONE);
        mLoadingView.setVisibility(View.VISIBLE);
        mProgressBar.setVisibility(View.VISIBLE);
        new AppListSetup().execute();
    }
}
 
Example 16
Source File: ChatsListsFragment.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
private void notExpanded(RecyclerView recyclerView, ImageView imageView) {
    recyclerView.setVisibility(View.GONE);
    imageView.setImageResource(R.mipmap.ic_expand_less);
}
 
Example 17
Source File: MainActivity.java    From bitcoinpos with MIT License 4 votes vote down vote up
@Override
// from AddItemDialogFragment
public void onAddOrUpdateItemFragmentInteraction(int itemId, String itemName, double itemPrice) {
    // TODO: for now order is not implemented (always 0)
    // TODO: currently only name and price/amount can be set!

    // itemId is -1 when adding new item
    boolean isEditMode = itemId >= 0;

    // get ItemFragment's recycler view and adapter to add and display the item
    // this is a quick way of getting the fragment at position 0 (ItemFragment)
    ItemFragment itemFragment = (ItemFragment) mViewPagerAdapter.instantiateItem(null, 0);
    RecyclerView recyclerView = itemFragment.getRecyclerView();
    ItemRecyclerViewAdapter recyclerViewAdapter = (ItemRecyclerViewAdapter) recyclerView.getAdapter();

    // get DB helper for items
    ItemHelper itemHelper = ItemHelper.getInstance(getApplicationContext());

    Item item;
    if(isEditMode) {
        // get item and modify
        item = itemHelper.get(itemId);
        if(item != null) {
            item.setName(itemName);
            item.setAmount(itemPrice);

            // update in db
            itemHelper.update(item);

            // update UI
            recyclerViewAdapter.updateItem(item);
        }
    } else {
        // create new item
        item = new Item(null, itemName, "", itemPrice, 0, "", true, new Date());

        // add the item to the DB
        int newItemId = itemHelper.insert(item);

        // update the memory object with the id generated from the DB
        item.setItemId(newItemId);

        if(recyclerViewAdapter.getItemCount() == 0) {
            // first item added ever
            recyclerView.setVisibility(View.VISIBLE);
            itemFragment.getEmptyView().setVisibility(View.GONE);
        }
        recyclerViewAdapter.addItem(item);

    }

}
 
Example 18
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);
    }
 
Example 19
Source File: ProfileTab1.java    From Nimbus with GNU General Public License v3.0 2 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){

    View view = inflater.inflate(R.layout.fragment_profiletab1, container, false);


    ProfileEventDataModel profileEventDataModel;
    sharedPref = new SharedPref(getContext());

    recyclerView = (RecyclerView) view.findViewById(R.id.list1);
    progress = (ProgressBar) view.findViewById(R.id.progress);
    textView = (TextView) view.findViewById(R.id.text);


    profileEventAdapter = new ProfileEventAdapter(list,getContext());

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(profileEventAdapter);


    profileEventDataModel = new ProfileEventDataModel("","","");

    if(savedInstanceState==null){

        progress.setVisibility(view.VISIBLE);
        profileEventDataModel.profileEventList(sharedPref.getUserId());

    }
    else {
        list = savedInstanceState.getParcelableArrayList(EVENT_LIST);
        if(list!=null){
            recyclerView.setVisibility(View.VISIBLE);
            progress.setVisibility(View.GONE);

        }

    }



    return view;
}
 
Example 20
Source File: ProfileTab1.java    From Hillffair17 with GNU General Public License v3.0 2 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){

    View view = inflater.inflate(R.layout.fragment_profiletab1, container, false);


    ProfileEventDataModel profileEventDataModel;
    sharedPref = new SharedPref(getContext());

    recyclerView = (RecyclerView) view.findViewById(R.id.list);
    progress = (ProgressBar) view.findViewById(R.id.progress);
    textView = (TextView) view.findViewById(R.id.text);


    profileEventAdapter = new ProfileEventAdapter(list,getContext());

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(profileEventAdapter);


    profileEventDataModel = new ProfileEventDataModel("","","");

    if(savedInstanceState==null){

        progress.setVisibility(view.VISIBLE);
        profileEventDataModel.profileEventList(sharedPref.getUserId());

    }
    else {
        list = savedInstanceState.getParcelableArrayList(EVENT_LIST);
        if(list!=null){
            recyclerView.setVisibility(View.VISIBLE);
            progress.setVisibility(View.GONE);

        }

    }



    return view;
}