add: about page, settings, notification switch

This commit is contained in:
hyb1996
2017-02-03 10:41:23 +08:00
parent 636ce6d889
commit 5640b47663
47 changed files with 1392 additions and 307 deletions

View File

@@ -1,6 +1,7 @@
package com.stardust.view;
import android.view.View;
import android.widget.CompoundButton;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -21,7 +22,31 @@ public class ViewBinder {
}
Method[] methods = o.getClass().getDeclaredMethods();
for (Method method : methods) {
method.setAccessible(true);
bindClick(o, method, findViewById);
bindCheck(o, method, findViewById);
}
}
private static void bindCheck(final Object o, final Method method, Method findViewById) {
ViewBinding.Check annotation = method.getAnnotation(ViewBinding.Check.class);
if (annotation == null || annotation.value() == 0)
return;
int id = annotation.value();
try {
CompoundButton button = (CompoundButton) findViewById.invoke(o, id);
button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
try {
method.invoke(o, isChecked);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
});
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
@@ -45,7 +70,6 @@ public class ViewBinder {
private static void invokeMethod(Object o, Method method) {
try {
method.setAccessible(true);
method.invoke(o);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);