Changeset 1745


Ignore:
Timestamp:
09/15/14 11:02:48 (10 years ago)
Author:
funger
Message:

fixed parentHash Problem in method addComponent

Location:
trunk/autoquest-androidmonitor/src/de/ugoe/cs/autoquest/androidmonitor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-androidmonitor/src/de/ugoe/cs/autoquest/androidmonitor/Androidmonitor.java

    r1728 r1745  
    100100         *  
    101101         * @param view 
     102         *            to be monitored 
    102103         */ 
    103104        public void addLogListenerToView(View view) { 
     105                addLogListenerToView(view, 0); 
     106        } 
     107 
     108        /** 
     109         * replace the listener of each view with a composite listener which 
     110         * collects several listeners for one view. 
     111         *  
     112         * @param view 
     113         *            to be monitored 
     114         * @param parentHash 
     115         *            hash of the parent view element 
     116         */ 
     117        private void addLogListenerToView(View view, int parentHash) { 
     118 
     119                logFile.addComponent(view, parentHash, activityName); 
     120 
     121                // hash code of the actual view element. Problem in using 
     122                // view.getParent().hashCode() is described in 
     123                // de.ugoe.cs.autoquest.androidmonitor addComponent() 
     124                parentHash = view.hashCode(); 
    104125                // traverse all views of the activity 
    105                 logFile.addComponent(view, activityName); 
    106126                if (view instanceof ViewGroup) { 
    107127                        ViewGroup group = (ViewGroup) view; 
    108128                        for (int i = 0; i < group.getChildCount(); i++) { 
    109129                                View child = group.getChildAt(i); 
    110                                 addLogListenerToView(child); 
     130                                addLogListenerToView(child, parentHash); 
    111131                        } 
    112132                } 
  • trunk/autoquest-androidmonitor/src/de/ugoe/cs/autoquest/androidmonitor/AndroidmonitorLogFile.java

    r1728 r1745  
    6060 
    6161                        } else { 
    62                                 // tbd add activity information 
     62                                // TODO add activity information 
    6363                        } 
    6464                } catch (Exception e) { 
     
    133133        } 
    134134 
    135         public void addComponent(View view, String activityName) { 
     135        public void addComponent(View view, int parentHash, String activityName) { 
    136136                XmlSerializer serializer = Xml.newSerializer(); 
    137137                StringWriter writer = new StringWriter(); 
     
    152152                        serializer.attribute("", "name", "path"); 
    153153                        serializer.attribute("", "value", activityName + "/" 
    154                                         + getViewPath(view)); 
     154                                        + getViewPath(view) + view.getClass().getSimpleName()); 
    155155                        serializer.endTag("", "param"); 
    156156 
     
    162162                        serializer.startTag("", "param"); 
    163163                        serializer.attribute("", "name", "parent"); 
    164                         // serializer.attribute("", "value", "" + 
    165                         // view.getParent().hashCode()); 
     164                        // Problem in using view.getParent().hashCode(): 
     165                        // http://developer.android.com/reference/android/view/View.html#getParent() 
     166                        // tells: "... parent is a ViewParent and not necessarily a View." 
     167                        // ViewParent does not have a method hashCode(). Solution is done 
     168                        // add parentHash as parameter to method addComponent() and 
     169                        // Androidmonitor-> addLogListenerToView. 
     170                        serializer.attribute("", "value", "" + parentHash); 
    166171                        serializer.endTag("", "param"); 
    167172 
Note: See TracChangeset for help on using the changeset viewer.