Giter Site home page Giter Site logo

Comments (21)

janishar avatar janishar commented on May 16, 2024 1

I am closing this thread and moving the discussion to #13

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk can you provide a little more detail?
If by late update you mean the the view being updated from the network call after being rendered. Then yes.
In the class use
@position
private int position

Then notify
placeHolderView.getAdapter().notifyItemChanged(position);

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk To streamline the solution I have added few methods to the PlaceHolderView 0.2.7

  1. <T>int getViewResolverPosition(T resolver): This will give the position of the class object which is added as the item view, even before the item view is binded to the window.
  2. <T>void refreshView(T resolver): This will refresh the item view after new data is added based on the class object reference added as item view.
  3. public void refreshView(int position): This will refresh the item view after new data is added based on the position of item view.
  4. void refresh(): It will re draw the entire PlaceHolderView with new data.

Hope this solves your problem

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

im at 0.2.6 @janishar when the new child are added on later event to the placeholder i have got a crash. the reason was that the xml wasnt able to inflate.

E/AndroidRuntime: FATAL EXCEPTION: main
Process:XXXXXXX, PID: 1773
android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.mikhaellopez.circularimageview.CircularImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.mindorks.placeholderview.ViewAdapter.onCreateViewHolder(ViewAdapter.java:39)
at com.mindorks.placeholderview.ViewAdapter.onCreateViewHolder(ViewAdapter.java:17)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5836)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5060)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:541)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2843)
at android.view.View.measure(View.java:18796)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1458)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:746)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:18796)
at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:7874)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1440)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2843)
at android.view.View.measure(View.java:18796)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:706)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1364)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:771)
at android.view.View.measure(View.java:18796)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18796)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:18796)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18796)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:706)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:773)
at android.view.View.measure(View.java:18796)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:18796)

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk you should not refer to the view elements other than in method annotated with @resolve. Because the view may have be removed from the window or not have been bind to the PlaceHolderView. What you should do is, place the view data in a list, use list item based on position to populate the view and update the list and refresh the view . Its the same procedure you would take when using recyclerView.

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk Also you can do is that, update the variables of the class and call refresh. When the view will be bind then it will automatically update the view. Please use 0.2.7

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk This is what I understood the use case. If there is something else that you have implemented please explain a bit in more detail. Thanks

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

i found out eventually. it is not the case. The view from 'com.mikhaellopez:circularimageview:3.0.2' with using com.mikhaellopez.circularimageview.CircularImageView . The view was inflated normally not in the placeholderview but it has problem to inflate within placeholderview. Instead I tried to use ImageView, it inflated normally.
As it is implemented as a child view xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="50dp"
    android:layout_height="50dp">

    <com.mikhaellopez.circularimageview.CircularImageView
        android:id="@+id/circle_image_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="center" />

</RelativeLayout>

with the class for sub placeviewholder. As you can see in this pattern. The late event comes from
public void success(List<UserGallerio> response) { and the child view started added into the this subplaceviewholder.

@Animate(Animation.FADE_IN_ASC)
@NonReusable
@Layout(R.layout.item_placeholder)
public class itemProfiles implements RepoResponseBase<List<UserGallerio>> {
    @View(R.id.placeholderview)
    private PlaceHolderView mProfileList;
    private Context mContext;
    private MetaWordRespository mMeta;
    private UserGX mUserX;

    @Override
    public void success(List<UserGallerio> response) {
        for (UserGallerio user_item : response) {
            mProfileList.addView(new itemProfileCircle(mContext, user_item));
        }
    }

    @Override
    public void endOfPagination() {

    }

    @Override
    public void endNotFoundFailure() {

    }

    @Override
    public void failure() {

    }

    public itemProfiles(Context context, MetaWordRespository mMeta, UserGX mUserRepo) {
        this.mContext = context;
        this.mMeta = mMeta;
        this.mUserX = mUserRepo;
        this.mUserX.setListListener(this);
    }

    @Resolve
    private void onResolved() {
        this.mUserX.initUserListMostRecent();
        mProfileList.getBuilder()
                .setHasFixedSize(false)
                .setItemViewCacheSize(5)
                .setLayoutManager(new GridLayoutManager(mContext, 4, LinearLayoutManager.VERTICAL, false));
    }
}

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

according to your suggestion, should i add mProfileList.refresh(); the loaded list is added to the child placeholderview?

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk Do few changes...

  1. Make a
List<itemProfileCircle> itemProfileCircleList = new ArrayList<>();
  1. Add new itemProfileCircle(mContext, user_item) in that list.
  2. mProfileList.addView don't use outside @resolve
  3. In onResolved() use
for(itemProfileCircle item : itemProfileCircleList){
      mProfileList.addView(item);
}
  1. Also in onResolved(), do call mProfileList.removeAllViews() before adding views. Because this will safeguard against repetitive view addition when view is rebinded.

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

@janishar at which point should i initiate the item request to fill in the subplaceholder?

  1. onResolved or 2. class start itemProfiles .
    From the second point of view that you mention not to use addView outside @resolve and what to do from the late update event call upon? if the first call on the resolve is count zero on the list item then addView will not be called. Do I able to make update from the late event?

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk you can initiate the item request as soon as the class is constructed. Don't call the item request in onResolved otherwise it will call item request whenever the view is re binded to the window.
The fetched data will be stored in itemProfileCircleList. When the view is binded to the window it will automatically pick up the fetched data and add the view into the sub placeholdeview in the @resolve annotated method. Also do call mainPlaceHoldeView.refresh() (mainPlaceHoldeView is the parent placeholderview containing mProfileList) when the data has been fetched.

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk Is this issue solved? if yes then please close this issue. Thanks

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

its interesting that i encountered the issue on #13 relates to this issue. Now I have defined 2 different managers on the constructor and there is a logic decision to allow which layoutmanager to use during resolve process.

  1. GridLayoutManager - practiculer vertical with 2 column
  2. LinearLayoutManager - horizontal

There are few times i got crashed from calling one of them and it is not consistent.

java.lang.IllegalStateException: View with id 2131886663: com.mindorks.placeholderview.PlaceHolderView#onMeasure() did not set the measured dimension by calling setMeasuredDimension()
This crash is during the animation to reveal the items to the mainplaceholderview.

do you have some suggestion or sample code to show how to make delay events calls upon to using the provided methods to refresh the new items?

let me know if i am missing anything to remove the view. From using this pattern with 0.2.7. When the itemCateStrWestern is using. The items kept inserting on the top and it result alot of repeating items and crashed at scrolled up all the way and scroll down that hits the end of these repeating list.

When should we putout the @NonReusable? any examples?

@Animate(Animation.FADE_IN_ASC)
@NonReusable
@Layout(R.layout.item_placeholder)
public class itemCateCollection {
    @View(R.id.placeholderview)
    private PlaceHolderView mCateListingReference;
    private LinearLayoutManager eastern;
    private GridLayoutManager western;
    private Context mContext;
    private List<catItem> mImageList;
    private List<itemCateStrAsian> mAsianShowList = new ArrayList<>();
    private List<itemCateStrWestern> mWesternShowList = new ArrayList<>();
    private boolean culture_asian;

    public itemCateCollection(Context context, List<catItem> imageList) {
        mContext = context;
        mImageList = imageList;
        this.culture_asian = MetaWordRespository.isVertical();
        this.western = new GridLayoutManager(mContext, 2, LinearLayoutManager.VERTICAL, false);
        this.eastern = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
        mAsianShowList.clear();
        mWesternShowList.clear();
        for (catItem mItem : imageList) {
            mAsianShowList.add(new itemCateStrAsian(mContext, mCateListingReference, mItem));
            mWesternShowList.add(new itemCateStrWestern(mContext, mCateListingReference, mItem));
        }
    }

    @Resolve
    private void onResolved() {

        mCateListingReference.getBuilder()
                .setHasFixedSize(true)
                .setItemViewCacheSize(10)
                .setLayoutManager(this.culture_asian ? eastern : western);

        if (this.culture_asian) {
            for (itemCateStrAsian str : mAsianShowList) {
                mCateListingReference.addView(str);
            }
        } else {
            for (itemCateStrWestern str : mWesternShowList) {
                mCateListingReference.addView(str);
            }
        }

    }

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

ok. I got this resolved. These items needs to be check,

   if (mCateListingReference.getAllViewResolvers().size() == 0) {
            if (this.culture_asian) {
                for (itemCateStrAsian str : mAsianShowList) {
                    mCateListingReference.addView(str);
                }
            } else {
                for (itemCateStrWestern str : mWesternShowList) {
                    mCateListingReference.addView(str);
                }
            }
        }

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk @NonReusable should be used in view which once removed from the placeholderview is not to be added or modified again.
Do you still need some reference example or you got it solved?

from placeholderview.

jjhesk avatar jjhesk commented on May 16, 2024

yes. I need reference for implementation of late events call upon updating the new list. would u do handler post delay to stimulate the call events?

from placeholderview.

janishar avatar janishar commented on May 16, 2024

@jjhesk I will create a repository with the example and post it here in sometime

from placeholderview.

rakesh1001 avatar rakesh1001 commented on May 16, 2024

how to perform the action on adapterItem from fragment??

from placeholderview.

shiprasinghal1 avatar shiprasinghal1 commented on May 16, 2024

Hello,
I want to update a child in particular parent in different fragment than the fragment where Place Holder view is initialized/populated. I am unable to find any particular method in PlaceHolderView class for same.
Can you please suggest something. Thanks

from placeholderview.

aakashbhusal7 avatar aakashbhusal7 commented on May 16, 2024

how to get the position of child view. I need to increment the symbol number for list of data from child view.

from placeholderview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.