Code Monkey home page Code Monkey logo

Comments (16)

mathew-kurian avatar mathew-kurian commented on July 28, 2024

If you can provide a screenshot of the row item on the mobile device, that would be great.


Sent from Mailbox

On Fri, Jan 23, 2015 at 8:13 PM, DivineCake [email protected]
wrote:

Hi, I'm having some problems when using DocumentView in a row item, it makes the whole row item not clickable. I fixed this by android:descendantFocusability="blocksDescendants" on the RelativeLayout. The problem however is that selecting the DocumentView does not select the Row Item, unlike using a normal TextView does. Clicking outside the DocumentView does indeed trigger the Row Item. What I want to achieve is that clicking the DocumentView, selects the Row Item similar to how it works when I use a normal TextView. Is this an ongoing issue or I'm doing something wrong?
I'll be attaching my layout if that helps.

screen shot 2015-01-24 at 10 12 29 am

Reply to this email directly or view it on GitHub:
#59

from textjustify-android.

polcham avatar polcham commented on July 28, 2024

With DocumentView, tapping on it doesn't select the ListItem
justified
With TextView, tapping on it select the ListItem
nojustify
The red dot indicates tap location.

Thanks! Awesome library btw.

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

I will look at it when I get home. But I think it's because TextView extends View while DocumentView extends Scrollview. So this means that the touch events might not be propagating into the parent views. And I side note, I recommend you use the SqueezeHyphentor to condense the text.


Sent from Mailbox

On Fri, Jan 23, 2015 at 9:30 PM, DivineCake [email protected]
wrote:

With DocumentView, tapping on it doesn't select the ListItem
justified
With TextView, tapping on it select the ListItem
nojustify
The red dot indicates tap location.

Thanks! Awesome library btw.

Reply to this email directly or view it on GitHub:
#59 (comment)

from textjustify-android.

polcham avatar polcham commented on July 28, 2024

Hi Mathew Kurian,
I am able to "hack" fix it, thanks to your suggestion that it extends ScrollView. Solved it by adding an onTouchListener on the DocumentView which calls super() to the parent view, referring to the List. After which calling ListItem.performItemClick does the job.

description.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                        case MotionEvent.ACTION_DOWN:
                            break;
                        case MotionEvent.ACTION_UP:
                            View view = (View) v.getParent().getParent();
                            ListView list = (ListView) view.findViewById(R.id.list);
                            list.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
                            break;
                    }
                    return true;
                }
});

The only problem now, albeit minor, is that using performItemClick doesn't seem to change the state of the ListRow, thereby the row is not getting highlighted.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/list_row_bg" android:state_pressed="false" android:state_selected="false" />
    <item android:drawable="@drawable/list_row_bg_hover" android:state_pressed="true" />
    <item android:drawable="@drawable/list_row_bg_hover" android:state_pressed="false" android:state_selected="true" />
</selector>

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

@divineCake I am glad you found a solution. To make the click work, i would suggest extending document view and following the suggestion at StackOverflow. I have not tried this, but it does look promising.

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

Opening until release

from textjustify-android.

polcham avatar polcham commented on July 28, 2024
description.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                        case MotionEvent.ACTION_DOWN:
                            break;
                        case MotionEvent.ACTION_UP:
                            View view = (View) v.getParent().getParent();
                            ListView list = (ListView) view.findViewById(R.id.list);
                            list.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
                            break;
                    }
                    return true;
                }
});

Would just like to note that this doesn't work as intended, position in this context is limited to the adapter's position index and not to the ListView -> Item's index. Tried your suggestion, though I have no luck with it.

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

Can you give me a sample code I can run on my system to recreate the issue


Sent from Mailbox

On Sun, Jan 25, 2015 at 9:43 PM, DivineCake [email protected]
wrote:

description.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                        case MotionEvent.ACTION_DOWN:
                            break;
                        case MotionEvent.ACTION_UP:
                            View view = (View) v.getParent().getParent();
                            ListView list = (ListView) view.findViewById(R.id.list);
                            list.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
                            break;
                    }
                    return true;
                }
});

Would just like to note that this doesn't work as intended, position in this context is limited to the adapter's position index and not to the ListView -> Item's index. Tried your suggestion, though I have no luck with it.

Reply to this email directly or view it on GitHub:
#59 (comment)

from textjustify-android.

polcham avatar polcham commented on July 28, 2024

The way I structured my list is as follows:

listView.setAdapter(adapter);
listView.setOnItemClickListener(){

}

Now given that the DocumentView is inside the adapter, the onTouchListener for the DocumentView is inside the same adapter class.

Adapter class

@Override
    public View getView(final int position, View convertView, final ViewGroup parent) {
description.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                        case MotionEvent.ACTION_DOWN:
                            break;
                        case MotionEvent.ACTION_UP:
                            ListView list = (ListView) parent;
                            listView.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
                            break;
                    }
                    return true;
                }
            });
}

position in this context however is limited to the index 0-4 (in my case which resets to 0 again when I scroll down the list), and not to the ListView's index. There seems to be no way of accessing the selected index of ListView other than on the ListView itself

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

Can u provide the xml as a file please?


Sent from Mailbox

On Sun, Jan 25, 2015 at 9:57 PM, DivineCake [email protected]
wrote:

The way I structured my list is as follows:

listView.setAdapter(adapter);
listView.setOnItemClickListener(){
}

Now given that the DocumentView is inside the adapter, the onTouchListener for the DocumentView is inside the same adapter class.
Adapter class

@Override
    public View getView(final int position, View convertView, final ViewGroup parent) {
description.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                        case MotionEvent.ACTION_DOWN:
                            break;
                        case MotionEvent.ACTION_UP:
                            ListView list = (ListView) parent;
                            listView.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
                            break;
                    }
                    return true;
                }
            });
}

position in this context however is limited to the index 0-4 (in my case which resets to 0 again when I scroll down the list), and not to the ListView's index. There seems to be no way of accessing the selected index of ListView other than on the ListView itself

Reply to this email directly or view it on GitHub:
#59 (comment)

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

Ok. I have updated the library to support what you want. Use version 2.0.8-SNAPSHOT to get the latest code. This supports features you are looking for. Refer to ListViewTest to see the sample code. The xml files and the PressableDocumentView are all in the sample project.

EDITED: PressableDocumentView introduced into the sample. It is a simple extension of DocumentView.

from textjustify-android.

polcham avatar polcham commented on July 28, 2024

Sorry, I just got home and was planning to make a sample simple program to demonstrate. But I guess you beat me to it! Thanks will look into it! Thank you so much, I appreciate all the work you've done on this awesome library.

from textjustify-android.

polcham avatar polcham commented on July 28, 2024

Hi, how do I update to 2.0.8-SNAPSHOT? I have done a Gradle clean and build but it don't seem to have updated the library to have PressableDocumentView. I tried recreating myself a similar class but I get Error:(44) No resource identifier found for attribute 'documentView_disallowInterceptTouch' in package 'com.sample' following your same code. Sorry, I'm new to GitHub.

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

Use version 2.0.8

from textjustify-android.

polcham avatar polcham commented on July 28, 2024

Thank you very much! Was able to make it work now! I do appreciate all your support.

from textjustify-android.

mathew-kurian avatar mathew-kurian commented on July 28, 2024

Np

from textjustify-android.

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.