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
[TIMOB-25656] Android: getOrCreateView() should always return a View #9721
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass
FR Passed. Will do another FR pass with suggestions below.
Studio Ver: 5.0.0.201712081732 |
@@ -557,6 +556,12 @@ protected TiUIView handleGetView() | |||
} | |||
|
|||
Activity activity = getActivity(); | |||
if (activity.isDestroyed()) { | |||
activity = activity.getParent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold on. I see a problem here. The parent activity can be in a destroyed state too.
Instead of falling-back to the parent activity, I think you should set the activity to null here and let the below code grab the top-most activity. Odds are the top-most activity is the one the proxy's view is going to be used on. Or alternatively, walk up the parent activity tree until you find a non-destroyed activity, such as the LauncherActivity.
The below code should exercise this issue...
var rootWindow = Ti.UI.createWindow();
var button = Ti.UI.createButton({ title: "Start Test" });
button.addEventListener("click", function(e) {
var imageView;
var childWindow1 = Ti.UI.createWindow();
childWindow1.addEventListener("open", function(e) {
var childWindow2 = Ti.UI.createWindow();
childWindow2.addEventListener("open", function(e) {
// Create the image view under the 2nd child window.
imageView = Ti.UI.createImageView();
childWindow2.close();
});
childWindow2.addEventListener("close", function(e) {
childWindow1.close();
});
childWindow2.open();
});
childWindow1.addEventListener("close", function(e) {
// Attempt to access after both child windows have been destroyed.
imageView.tintColor;
// With this PR's code, the proxy would theoretically create a view a 2nd
// time here because above line switched to using destroyed parent activity.
imageView.tintColor;
});
childWindow1.open();
});
rootWindow.add(button);
rootWindow.open();
@lokeshchdhry, we should also test using the customer's |
Thanks @jquick-axway for the suggestion. I am seeing some issues with the user code.
The latest code above by @jquick-axway , does not throw any error on android 7.1.1, 6.0.1 & 4.4.2. |
9267551
to
17d9b4a
Compare
@jquick-axway @lokeshchdhry Updated PR |
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass
FR Passed.
Studio Ver: 5.0.0.201712081732 |
@jquick-axway , Danger is not passing because its needs tests. Can you please provide some or if not possible to provide a test then remove |
eda7e3a
to
02ff5c8
Compare
0cb48e6
to
1be991d
Compare
5507439
to
e68ee3f
Compare
getOrCreateView()
to always return aView
TEST CASE
JIRA Ticket