Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable top and bottom quickreturn #12

Open
misrakli opened this issue Jul 16, 2014 · 7 comments
Open

Enable top and bottom quickreturn #12

misrakli opened this issue Jul 16, 2014 · 7 comments

Comments

@misrakli
Copy link

Hi,
is it possible to enable top and bottom quickreturnviews at same time for same listview?

Thank you.

@felipecsl
Copy link
Owner

Yeah, check the sample app here. You can call addTargetView twice, one for top and one for bottom.
If you run the sample app, open the actionbar overflow menu and tap "Toggle bottom QuickReturn", then you'll have both active at the same time.

@misrakli
Copy link
Author

Thank you for your quick response.
I asked you because i tried this already out and didnt get it work.
The "bottom view" is placed over the "top view" but is scrolled down when the list is scrolled, so the place is wrong but the scrolling is right, both views are hidden. By the way using only topView works fine.

The differences to youre example are:

  1. I am adding the framelayout in onCreate to an other layout (relativelayout)
  2. I have separeted the Activity from the View (two different classes), the activity is acting as the presenter
  3. The "top" and "bottom" views are included in my activity_layout.xml per "include"
  4. I have to call adddTargetView in onGlobalLayout in my view, otherwise getWidth of the topView always returns 0 and topView (without bottomView) doesnt work, too

Do you have any ideas?
Thank you.

@misrakli misrakli mentioned this issue Jul 18, 2014
@felipecsl felipecsl reopened this Jul 18, 2014
@felipecsl
Copy link
Owner

I will check this and get back to you. If you can provide some code snippets or a test app demonstrating the bug, it would be super helpful.
Thanks!

@misrakli
Copy link
Author

Hi Felipe,
thank you for reopening...Here are some snippets, hope they will help you..
Can't figure out how it works in your test app.. Thank you for your help.

base_layout.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/base_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/base_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </RelativeLayout>

    <ListView
        android:id="@+id/base_drawer_list"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#FFFFFF"
        android:choiceMode="none"
        android:divider="#E6E6E6"
        android:dividerHeight="1dp" />

</android.support.v4.widget.DrawerLayout>

testlayout.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#E6E6E6" >

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="#FFFFFF"
        android:dividerHeight="1dp"
        android:padding="0dp" >
    </ListView>

    <LinearLayout
        android:id="@+id/topView_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white" >

        <include
            android:id="@+id/topView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            layout="@layout/topView_layout />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottomView_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#33b5e5" >

        <include
            android:id="@+id/bottomView"
            layout="@layout/bottomView_layout"
            android:visibility="gone" />
    </LinearLayout>

</FrameLayout>
public class MyBaseActivity extends Activity {
    @override 
    public  onCreate(Bundle b){
        super.onCreate(b);
        setContentView(R.layout.my_base_layout);
        IMyViewInterface viewInterface = createView();
        ..
        this.baseContainer = (RelativeLayout)findViewById(R.id.base_view_container);

        View view = ViewCreator.createView(getLayoutInflater(), this.baseContainer, this.view.getResource());
        viewInterface.setView(view);
        viewInterface.setup();
        baseContainer.addView(view);
    }

    protected abstract IMyViewInterface createView();
}

public class MyTestActivity extends MyBaseActivity {
    @override 
    protected IMyViewInterface  createView() {
    return new MyTestView();
}

public class MyTestView implements IMyViewInterface {

    private View view;

    @override 
    public void setView(View view) {
        this.view = view;
    }

    @override
    public void setup() {
        this.bottomView = this.view.findViewById(R.id.bottomView);
        this.bottomView.setVisibility(View.GONE);
       this.TopView = this.view.findViewById(R.id.topView);
       this.list = this.view.findViewById(R.id.list);
        this.listOrders.setAdapter(new QuickReturnAdapter(this.adapter));
        final QuickReturnAttacher quickReturnAttacher = QuickReturnAttacher.forView(list);

        quickReturnAttacher.addTargetView(this.scanInfo, QuickReturnTargetView.POSITION_BOTTOM);

        this.listOrders.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener()
        {

            @Override
            public void onGlobalLayout()
            {
                   //I have to do it this way because otherwise topView is never shown, because height is always 0 if called getHeight() directly in setup()
                    quickReturnAttacher.addTargetView(stopDescriptionContainer,
                        QuickReturnTargetView.POSITION_TOP, topView.getHeight())
                        .setAnimatedTransition(false);
            }
        });

    }

@misrakli
Copy link
Author

Hi Felipe, any progress on this issue?
did my code snippets help you?

@felipecsl
Copy link
Owner

@misrakli sorry didn't have time to check yet. Will keep you posted

@misrakli
Copy link
Author

Ok..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants