Skip to content

Commit

Permalink
0.0.4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzue committed May 29, 2022
1 parent e5eaef4 commit 5554bb6
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions runner/src/main/java/com/kongzue/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.widget.BaseAdapter;
Expand Down Expand Up @@ -535,7 +537,7 @@ public static void changeData(String key, Object data) {
try {
field.setAccessible(true);
View view = (View) field.get(activity);
setValue(view, data);
preSetValue(view, data);
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -550,7 +552,7 @@ public static void changeData(String key, Object data) {
try {
field.setAccessible(true);
View view = (View) field.get(activity);
setValue(view, data);
preSetValue(view, data);
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -569,16 +571,29 @@ public static void changeDataByTag(String key, Object data) {
for (Activity activity : activityList) {
View view = activity.getWindow().getDecorView().findViewWithTag(key);
if (view != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
setValue(view, data);
}
});
preSetValue(view, data);
}
}
}

private static void preSetValue(View view, Object data) {
if (view.getContext() instanceof Activity){
((Activity)view.getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
setValue(view, data);
}
});
}else{
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
setValue(view, data);
}
});
}
}

private static void setValue(View view, Object data) {
if (view != null) {
if (customDataSetter == null || !customDataSetter.setData(view, data)) {
Expand Down

0 comments on commit 5554bb6

Please sign in to comment.