Skip to content

Commit

Permalink
clean up codes
Browse files Browse the repository at this point in the history
  • Loading branch information
yjfnypeu committed Oct 25, 2018
1 parent 29795ba commit af537a8
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 25 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.61'
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
Expand All @@ -18,7 +18,6 @@ buildscript {
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven { url "https://jitpack.io" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ActivityRoute extends BaseRoute<IActivityRoute> implements IActivit
@Override
public Intent createIntent(Context context) {
ActivityLauncher activityLauncher = (ActivityLauncher) launcher;
activityLauncher.set(uri, bundle, callback.getExtras(), (ActivityRouteRule) routeRule, remote);
activityLauncher.set(uri, bundle, callback.getExtras(), routeRule, remote);
return activityLauncher.createIntent(context);
}

Expand Down Expand Up @@ -77,7 +77,7 @@ public void open(Fragment fragment) {
try {
Utils.checkInterceptor(uri, callback.getExtras(), fragment.getActivity(), getInterceptors());
ActivityLauncher activityLauncher = (ActivityLauncher) launcher;
activityLauncher.set(uri, bundle, callback.getExtras(), (ActivityRouteRule) routeRule, remote);
activityLauncher.set(uri, bundle, callback.getExtras(), routeRule, remote);
activityLauncher.open(fragment);
callback.onOpenSuccess(routeRule);
} catch (Throwable e) {
Expand All @@ -92,7 +92,7 @@ public void open(android.support.v4.app.Fragment fragment) {
try {
Utils.checkInterceptor(uri, callback.getExtras(), fragment.getActivity(), getInterceptors());
ActivityLauncher activityLauncher = (ActivityLauncher) launcher;
activityLauncher.set(uri, bundle, callback.getExtras(), (ActivityRouteRule) routeRule, remote);
activityLauncher.set(uri, bundle, callback.getExtras(), routeRule, remote);
activityLauncher.open(fragment);
callback.onOpenSuccess(routeRule);
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ public static boolean checkTypeValid (TypeElement type) {
Set<Modifier> modifiers = type.getModifiers();
if (modifiers.contains(Modifier.PRIVATE)) {
throw new RouterException(String.format("The class %s should not be modified by private",type.getSimpleName()),type);
} else if (modifiers.contains(Modifier.ABSTRACT)) {
// skip it
return false;
}
return true;
} else return !modifiers.contains(Modifier.ABSTRACT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
final class DefaultVerify implements RemoteVerify{

@Override
public boolean verify(Context context) throws Exception {
public boolean verify(Context context) {
String packageName = context.getPackageName();
int uid = Binder.getCallingUid();
String[] packages = context.getPackageManager().getPackagesForUid(uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.net.Uri;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;

import com.lzh.nonview.router.module.RemoteRule;
import com.lzh.nonview.router.protocol.IService;
Expand Down Expand Up @@ -48,39 +47,39 @@ public static void setVerify(RemoteVerify verify) {
List<String> plugins = new ArrayList<>();

@Override
public void register(String pluginName) throws RemoteException {
public void register(String pluginName) {
if (!plugins.contains(pluginName)) {
plugins.add(pluginName);
}
}

@Override
public boolean isRegister(String pluginName) throws RemoteException {
public boolean isRegister(String pluginName) {
return plugins.contains(pluginName);
}

@Override
public void addActivityRules(Map rules) throws RemoteException {
public void addActivityRules(Map rules) {
activities.putAll(rules);
}

@Override
public void addActionRules(Map rules) throws RemoteException {
public void addActionRules(Map rules) {
actions.putAll(rules);
}

@Override
public RemoteRule getActionRule(Uri uri) throws RemoteException {
public RemoteRule getActionRule(Uri uri) {
return findRule(uri, actions);
}

@Override
public RemoteRule getActivityRule(Uri uri) throws RemoteException {
public RemoteRule getActivityRule(Uri uri) {
return findRule(uri, activities);
}

@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
public boolean onTransact(int code, Parcel data, Parcel reply, int flags) {
try {
// check for security verification
if (verify != null && !verify.verify(getApplicationContext())) {
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
}

def parceler_version="1.3.9"
def router_version="2.8.3"
def router_version="29795baa44"
def butterknife_version='8.8.1'
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ArgsActivity:BaseActivity() {
@Arg
var mUrl:String? = null

val mPrinter:TextView by lazy { findViewById(R.id.printer_tv) as TextView }
val mPrinter:TextView by lazy { findViewById<TextView>(R.id.printer_tv) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.lzh.nonview.router.anno.RouterRule
@RouterRule("intent/printer")
class IntentPrinterActivity:BaseActivity() {

val mPrinter:TextView by lazy { findViewById(R.id.printer_tv) as TextView }
val mPrinter:TextView by lazy { findViewById<TextView>(R.id.printer_tv) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -30,6 +30,6 @@ class IntentPrinterActivity:BaseActivity() {
message.append("\n")
}
}
mPrinter.text = message;
mPrinter.text = message
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UserActivity :BaseActivity(){
@Arg("username")
var username = "HaogeStudio"

val userTv:TextView by lazy { findViewById(R.id.username) as TextView }
val userTv:TextView by lazy { findViewById<TextView>(R.id.username) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoginInterceptor : RouteInterceptor {

override fun intercept(uri: Uri?, extras: RouteBundleExtras?, context: Context?): Boolean {
// 判断是否已登录。已登录:不拦截、登录:拦截
return !DataManager.login;
return !DataManager.login
}

}

0 comments on commit af537a8

Please sign in to comment.