32 lines
756 B
Java
32 lines
756 B
Java
package com.gh.common.util;
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
public class ClassUtils {
|
|
|
|
@Nullable
|
|
public static Class<?> forName(String name) {
|
|
if (TextUtils.isEmpty(name)) return null;
|
|
|
|
if ("NewsActivity".equals(name)) {
|
|
name = "NewsDetailActivity";
|
|
} else if ("GameDetailsActivity".equals(name)) {
|
|
name = "GameDetailActivity";
|
|
}
|
|
try {
|
|
if (!name.contains("com.gh")) {
|
|
return Class.forName("com.gh.gamecenter." + name);
|
|
} else {
|
|
return Class.forName(name);
|
|
}
|
|
} catch (ClassNotFoundException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|