Skip to content

Commit 52c0fad

Browse files
author
rjmatthews62
committed
fullShow now without flicker.
1 parent 0521dcf commit 52c0fad

File tree

6 files changed

+60
-8
lines changed

6 files changed

+60
-8
lines changed

android/Common/src/com/googlecode/android_scripting/facade/ui/FullScreenTask.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,24 @@ public void onClick(View view) {
168168
mEventFacade.postEvent("click", mInflater.getViewInfo(view));
169169
}
170170

171+
public void loadLayout(String layout) {
172+
ViewInflater inflater = new ViewInflater();
173+
View view;
174+
StringReader sr = new StringReader(layout);
175+
try {
176+
XmlPullParser xml = ViewInflater.getXml(sr);
177+
view = inflater.inflate(getActivity(), xml);
178+
mView = view;
179+
mInflater = inflater;
180+
getActivity().setContentView(mView);
181+
mInflater.setClickListener(mView, this, this);
182+
mLayout = layout;
183+
mView.invalidate();
184+
} catch (Exception e) {
185+
mInflater.getErrors().add(e.toString());
186+
}
187+
}
188+
171189
private class SetProperty implements Runnable {
172190
View mView;
173191
String mProperty;
@@ -207,6 +225,21 @@ public void run() {
207225
}
208226
}
209227

228+
private class SetLayout implements Runnable {
229+
String mLayout;
230+
CountDownLatch mLatch = new CountDownLatch(1);
231+
232+
SetLayout(String layout) {
233+
mLayout = layout;
234+
}
235+
236+
@Override
237+
public void run() {
238+
loadLayout(mLayout);
239+
mLatch.countDown();
240+
}
241+
}
242+
210243
@Override
211244
public boolean onKeyDown(int keyCode, KeyEvent event) {
212245
Map<String, String> data = new HashMap<String, String>();
@@ -235,4 +268,15 @@ public void setOverrideKeys(List<Integer> overrideKeys) {
235268
mOverrideKeys = overrideKeys;
236269
}
237270

271+
// Used to hot-switch screens.
272+
public void setLayout(String layout) {
273+
SetLayout p = new SetLayout(layout);
274+
mHandler.post(p);
275+
try {
276+
p.mLatch.await();
277+
} catch (InterruptedException e) {
278+
mInflater.getErrors().add(e.toString());
279+
}
280+
}
281+
238282
}

android/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,16 @@ public List<String> fullShow(
552552
@RpcParameter(name = "layout", description = "String containing View layout") String layout)
553553
throws InterruptedException {
554554
if (mFullScreenTask != null) {
555-
fullDismiss();
555+
// fullDismiss();
556+
mFullScreenTask.setLayout(layout);
557+
} else {
558+
mFullScreenTask = new FullScreenTask(layout);
559+
mFullScreenTask.setEventFacade(mEventFacade);
560+
mFullScreenTask.setUiFacade(this);
561+
mFullScreenTask.setOverrideKeys(mOverrideKeys);
562+
mTaskQueue.execute(mFullScreenTask);
563+
mFullScreenTask.getShowLatch().await();
556564
}
557-
mFullScreenTask = new FullScreenTask(layout);
558-
mFullScreenTask.setEventFacade(mEventFacade);
559-
mFullScreenTask.setUiFacade(this);
560-
mFullScreenTask.setOverrideKeys(mOverrideKeys);
561-
mTaskQueue.execute(mFullScreenTask);
562-
mFullScreenTask.getShowLatch().await();
563565
return mFullScreenTask.mInflater.getErrors();
564566
}
565567

android/Common/src/com/googlecode/android_scripting/facade/ui/ViewInflater.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,4 +997,10 @@ public void setListAdapter(View view, JSONArray items) {
997997
mErrors.add("failed to load list " + e.getMessage());
998998
}
999999
}
1000+
1001+
public void clearAll() {
1002+
getErrors().clear();
1003+
mIdList.clear();
1004+
mNextSeq = BASESEQ;
1005+
}
10001006
}
1.16 KB
Binary file not shown.

android/ScriptingLayerForAndroid/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.googlecode.android_scripting" android:installLocation="auto"
4-
android:versionCode="518" android:versionName="5x18">
4+
android:versionCode="519" android:versionName="5x19">
55
<uses-permission android:name="android.permission.RECEIVE_SMS" />
66
<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS" />
77
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
902 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)