Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23117] Hyperloop: Android: Support calls to super-class

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-05-10T23:04:28.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsAndroid, Hyperloop
Labelsn/a
ReporterAndrey Tkachenko
AssigneeChristopher Williams
Created2016-03-28T19:05:24.000+0000
Updated2018-08-06T17:49:28.000+0000

Description

Hyperloop Android (not sure if it works in iOS) currently cannot call the superclass inside a Hyperloop-based subclass. We should support that in order to match a common OOP-pattern.

Comments

  1. Christopher Williams 2016-04-21

    [~hansknoechel] Do you have some sample code for the usage you're expecting? I assume this is when you override a method in a JS subclass and want to be able to call the super implementation in it?
  2. Hans Knöchel 2016-04-22

    The initial request contained a constructor method:
       MyView = android.view.View.extend({
           MyView: function() {
               // Constructor called?
           }
       });
       
    and a super-class call:
       var MyView = View.extend({
           onMeasure: function(widthMeasureSpec, heightMeasureSpec) {
               View.prototype.onMeasure.call(this, widthMeasureSpec, heightMeasureSpec);
               // or
               this.super.onMeasure.call(this, widthMeasureSpec, heightMeasureSpec);
           }
       }
       
    If you can think of a better structure, please go ahead! :-)
  3. Christopher Williams 2016-05-10

    https://github.com/appcelerator/hyperloop.next/pull/29
  4. Christopher Williams 2016-05-10

    This PR is for an implementation that uses a this.super property. So it'd look more like this:
       var MyView = View.extend({
           onMeasure: function (widthMeasureSpec, heightMeasureSpec) {
               this.super.onMeasure(widthMeasureSpec, heightMeasureSpec);
               // do your own custom work now.
           }
       });
       
  5. Christopher Williams 2016-05-10

    Another note, the PR I posted does not attempt to address overriding constructors as mentioned above. Quite honestly how to achieve that has me a bit stumped right now...
  6. Hans Knöchel 2016-05-10

    Alright. Should we file an own ticket for the constructor call?
  7. Rodolfo Perottoni 2016-11-02

    @Chris Williams @Hans Knoechel how can I get the current application context using this same approach? By getting a reference to the current *Activity* on native code I can just call *getApplicationContext()* and that's it. On the other hand, with Hyperloop I'd need to go past the first super class (Activity -> ContextThemeWrapper -> ContextWrapper -> Context.getApplicationContext()). How do you see that happening?
  8. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source