MaterialViewPager icon indicating copy to clipboard operation
MaterialViewPager copied to clipboard

Calling notifyDatasetChanged on original Adapter inside RecyclerViewMaterialAdapter

Open Mithrandir21 opened this issue 9 years ago • 7 comments

I have been having an issue when I call the "notifyDataSetChanged()" directly on the original adapter (RecyclerView.Adapter) passed to the RecyclerViewMaterialAdapter. Nothing seems to happen. If I call the function on the wrapper, it works fine, but not on the original adapter given to the wrapper.

What could be the reason for this?

Mithrandir21 avatar Oct 02 '15 08:10 Mithrandir21

I have this issue too :(. I 'm trying to refresh data and it doesn't work. Only the last item in list is refreshed, other are in first state. Is RecyclerViewMaterialAdapter bad ?

tmaxxdd avatar Dec 27 '15 20:12 tmaxxdd

I solved my issue by holding a reference to the original adapter (the one wrapped inside the RecyclerViewMaterialAdapter) and calling the "notifyDataSetChanged()" on that.

BUT the RecyclerViewMaterialAdapter seems to have a some internal functions starting with "mvp_" that call similar functions in the wrapped adapter. I think you should try to call "mvp_notifyDataSetChanged()" in the RecyclerViewMaterialAdapter to see if it works the way you want.

Mithrandir21 avatar Dec 28 '15 09:12 Mithrandir21

Thank you ! I have just solved my problem too, so my problem wasn't about nDSC but I wrong put data to fragments.

tmaxxdd avatar Dec 30 '15 15:12 tmaxxdd

Hi all, can you help to post your code? I am facing the problem too. :(

davidarchi avatar Apr 26 '16 16:04 davidarchi

So it should be simple, when you add any data to the adapter, you have to inform the adapter of changes. This is usually done by calling this function on any adapter:

adapter.notifyDataSetChanged();

But since MaterialViewPager wraps the original adapter inside another adapter, you cannot call notify the original adapter. You have to notify the "wrapping" MaterialViewPager adapter.

You can do this by calling the (this is the call you have to make, instead of the above).

wrapperAdapter.mvp_notifyDataSetChanged()

This call does the following:

public void mvp_notifyDataSetChanged()
{
    mAdapter.notifyDataSetChanged();
    notifyDataSetChanged();
}

Mithrandir21 avatar Apr 26 '16 17:04 Mithrandir21

Hello Braham.

How can i con mvp function inside my adapter. Actually i want to make remove function inside my Adapter On 27 Apr 2016 00:26, "Bahram Malaekeh" [email protected] wrote:

So it should be simple, when you add any data to the adapter, you have to inform the adapter of changes. This is usually done by calling this function on any adapter:

adapter.notifyDataSetChanged();

But since MaterialViewPager wraps the original adapter inside another adapter, you cannot call notify the original adapter. You have to notify the "wrapping" MaterialViewPager adapter.

You can do this by calling the (this is the call you have to make, instead of the above).

wrapperAdapter.mvp_notifyDataSetChanged()

This call does the following:

public void mvp_notifyDataSetChanged() { mAdapter.notifyDataSetChanged(); notifyDataSetChanged(); }

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/florent37/MaterialViewPager/issues/171#issuecomment-214818862

davidarchi avatar Apr 26 '16 17:04 davidarchi

    vlance.vn


    
    
        
            
                
                    
                
            
        
    
     
    
    
            
    
    
        
            
                Bạn vừa nhận được lời mời tham gia vLance, nhận tới 450.000 VNĐ*
            
            Thiên Văn Nguyễn mời bạn tham gia vLance:
            
                
            
            
                "Bạn có thể tìm kiếm việc làm hoặc thuê những chuyên gia để thực hiện công việc với một chi phí hợp lý"
            
            
                *Tham gia vLance và nhận ngay quà tặng lên tới 30 Credit (trị giá 450.000 VNĐ) ngay khi dự án đầu tiên của bạn được hoàn thành.
            
            
                
                    Nhận quà tặng
                
            
        
    

                    
    
    
        
            
                You've just received an invitation to join vLance, receive up to 450.000 VND*
            
            Thiên Văn Nguyễn  is inviting you to vLance: 
            
                
            
            
                "You can find jobs or hire professionals to work for you at a reasonable price"
            
            
                *Join vLance and receive a gift of up to 30 Credit which equal 450.000 VND once your first project is completed. 
            
            
                
                    Accept gift
                
            
        
    

                
    
    
    
    
        
            
                
                    Bạn cần trợ giúp? Liên hệ với chúng tôi
                    Email: [email protected]
                    Tel: 04-6684-1818
                
                
                    
                        
                    
                    
                        
                    
                    
                        
                    
                    
                        
                    
                
            
            
                © 2013 - 2017 vLance.vn 
                Địa chỉ: Tầng 4, số 2, ngõ 68, đường Nam Đồng, phường Nam Đồng, quận Đống Đa, Hà Nội.
            
        
    
        
        
    
    

davidarchi avatar Oct 26 '17 10:10 davidarchi