Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Commit

Permalink
[tidev#874 state:resolved] Update the title of an Activity during onS…
Browse files Browse the repository at this point in the history
…tart() and when a proxy is set.
  • Loading branch information
donthorp committed Aug 1, 2010
1 parent e3840dc commit 4c74afe
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions android/titanium/src/org/appcelerator/titanium/TiActivity.java
Expand Up @@ -16,6 +16,7 @@
import org.appcelerator.titanium.util.TiActivitySupport;
import org.appcelerator.titanium.util.TiActivitySupportHelper;
import org.appcelerator.titanium.util.TiConfig;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.ITiWindowHandler;
import org.appcelerator.titanium.view.TiCompositeLayout;

Expand Down Expand Up @@ -271,6 +272,8 @@ protected void onResume() {
@Override
protected void onStart() {
super.onStart();
updateTitle();

for (WeakReference<TiContext> contextRef : contexts) {
if (contextRef.get() != null) {
contextRef.get().dispatchOnStart();
Expand Down Expand Up @@ -340,5 +343,31 @@ public void setCreatedContext(TiContext context) {

public void setWindowProxy(TiWindowProxy proxy) {
this.proxy = proxy;
updateTitle();
}

protected void updateTitle() {
if (proxy != null) {
if (proxy.hasDynamicValue("title")) {
String oldTitle = (String) getTitle();
String newTitle = TiConvert.toString(proxy.getDynamicValue("title"));
if (oldTitle == null) {
oldTitle = "";
}
if (newTitle == null) {
newTitle = "";
}
if (!newTitle.equals(oldTitle)) {
final String fnewTitle = newTitle;
runOnUiThread(new Runnable(){

@Override
public void run() {
setTitle(fnewTitle);
}
});
}
}
}
}
}

0 comments on commit 4c74afe

Please sign in to comment.