日常备份,接入广点通开屏、Banner
数据改成掉落日志和战斗日志(战斗日志咕了)
186
.idea/assetWizardSettings.xml
Normal file
@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WizardSettings">
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="imageWizard">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="imageAssetPanel">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="actionbar">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipArt">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="theme" value="HOLO_DARK" />
|
||||
<entry key="themeColor" value="ffffff" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="launcher">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="backgroundImage">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="scalingPercent" value="0" />
|
||||
<entry key="trimmed" value="true" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="foregroundClipArt">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="foregroundImage">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
<entry key="scalingPercent" value="61" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="foregroundText">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="backgroundAssetType" value="COLOR" />
|
||||
<entry key="backgroundColor" value="ffffff" />
|
||||
<entry key="backgroundImage" value="D:\Android Studios\plugins\android\lib\templates\gradle-projects\NewAndroidModule\root\res\drawable-v24\ic_launcher_foreground.xml" />
|
||||
<entry key="backgroundLayerName" value="ic_launcher_background" />
|
||||
<entry key="foregroundImage" value="C:\Users\58381\Pictures\newlogo\icon_logo.png" />
|
||||
<entry key="legacyIconShape" value="NONE" />
|
||||
<entry key="outputName" value="icon_logo" />
|
||||
<entry key="webIconShape" value="NONE" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="launcherLegacy">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipArt">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="image">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
<entry key="paddingPercent" value="5" />
|
||||
<entry key="trimmed" value="true" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="assetType" value="IMAGE" />
|
||||
<entry key="iconShape" value="NONE" />
|
||||
<entry key="imageAsset" value="C:\Users\58381\Pictures\newlogo\icon_logo.png" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="notification">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipArt">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="000000" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -1,29 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<Objective-C-extensions>
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
</code_scheme>
|
||||
</component>
|
4
.idea/encodings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
@ -3,6 +3,9 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<compositeConfiguration>
|
||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||
</compositeConfiguration>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
|
4
.idea/json2java.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Json2JavaSettings" style="NONE" classNamePrefix="" classNameSuffix="" annotationGenerated="true" annotationSuppressWarnings="true" />
|
||||
</project>
|
@ -25,7 +25,7 @@
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -5,6 +5,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/RefreshRecyclerView/RefreshRecyclerView.iml" filepath="$PROJECT_DIR$/RefreshRecyclerView/RefreshRecyclerView.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/jianrmg_v2.iml" filepath="$PROJECT_DIR$/jianrmg_v2.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/mylibrary/mylibrary.iml" filepath="$PROJECT_DIR$/mylibrary/mylibrary.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '27.0.3'
|
||||
buildToolsVersion '28.0.3'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 15
|
||||
|
@ -0,0 +1,138 @@
|
||||
package cn.lemon.view.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 对应 ViewTypeManager
|
||||
* <p>
|
||||
* Created by linlongxin on 2017/9/20.
|
||||
*/
|
||||
|
||||
public class CustomMultiTypeAdapter extends RecyclerAdapter {
|
||||
|
||||
private final String TAG = "CustomMultiTypeAdapter";
|
||||
private List<Object> mViewsData;
|
||||
private ViewTypeManager mViewHolderManager;
|
||||
|
||||
|
||||
public CustomMultiTypeAdapter(Context context) {
|
||||
super(context);
|
||||
mViewsData = new ArrayList<>();
|
||||
mViewHolderManager = new ViewTypeManager();
|
||||
}
|
||||
|
||||
public void setViewHolderFactory(IViewHolderFactory factory) {
|
||||
if (factory == null) {
|
||||
return;
|
||||
}
|
||||
mViewHolderManager.setViewHolderFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == STATUS_TYPE) {
|
||||
return new BaseViewHolder<>(mStatusView);
|
||||
} else {
|
||||
return mViewHolderManager.getViewHolder(parent, viewType);
|
||||
}
|
||||
}
|
||||
|
||||
// 弃用
|
||||
@Override
|
||||
public BaseViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(BaseViewHolder holder, int position) {
|
||||
// 显示加载更多
|
||||
if (!mIsNoMoring && mLoadMoreEnable && !mIsLoadMoring && isValidLoadMore(position)) {
|
||||
mIsLoadMoring = true;
|
||||
setViewVisible(mLoadMoreLayout, true);
|
||||
setViewVisible(mLoadMoreView, true);
|
||||
setViewVisible(mLoadMoreError, false);
|
||||
setViewVisible(mNoMoreView, false);
|
||||
if (mLoadMoreAction != null) {
|
||||
log("load more");
|
||||
mLoadMoreAction.onAction();
|
||||
}
|
||||
} else {
|
||||
if (position < mViewsData.size()) {
|
||||
holder.setData(mViewsData.get(position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (hasEndStatusView() && position == mViewCount - 1) {
|
||||
return STATUS_TYPE;
|
||||
}
|
||||
return mViewHolderManager.getViewType(position);
|
||||
}
|
||||
|
||||
public void add(int viewType) {
|
||||
add(new Object(), viewType);
|
||||
}
|
||||
|
||||
public <T> void add(T data, int viewType) {
|
||||
if (mIsNoMoring || data == null) {
|
||||
return;
|
||||
}
|
||||
mIsLoadMoring = false;
|
||||
mViewsData.add(data);
|
||||
int positionStart;
|
||||
if (hasEndStatusView()) {
|
||||
positionStart = mViewCount - 1;
|
||||
} else {
|
||||
positionStart = mViewCount;
|
||||
}
|
||||
mViewHolderManager.putViewType(positionStart, viewType);
|
||||
mViewCount++;
|
||||
notifyItemRangeInserted(positionStart, 1);
|
||||
}
|
||||
|
||||
public <T> void addAll(T[] data, int viewType) {
|
||||
addAll(Arrays.asList(data), viewType);
|
||||
}
|
||||
|
||||
public <T> void addAll(List<T> data, int viewType) {
|
||||
|
||||
if (mIsNoMoring || data == null || data.size() == 0) {
|
||||
return;
|
||||
}
|
||||
mIsLoadMoring = false;
|
||||
int size = data.size();
|
||||
mViewsData.addAll(data);
|
||||
int positionStart;
|
||||
if (hasEndStatusView()) {
|
||||
positionStart = mViewCount - 1;
|
||||
} else {
|
||||
positionStart = mViewCount;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
mViewHolderManager.putViewType(positionStart + i, viewType);
|
||||
}
|
||||
mViewCount += size;
|
||||
notifyItemRangeInserted(positionStart, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if (mViewsData == null) {
|
||||
return;
|
||||
}
|
||||
mViewsData.clear();
|
||||
mViewCount = hasEndStatusView() ? 1 : 0;
|
||||
mIsNoMoring = false;
|
||||
mIsLoadMoring = false;
|
||||
setViewVisible(mLoadMoreLayout, false);
|
||||
setViewVisible(mNoMoreView, false);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package cn.lemon.view.adapter;
|
||||
|
||||
import android.os.Message;
|
||||
|
||||
/**
|
||||
* Created by linlongxin on 2018/3/29
|
||||
*/
|
||||
public interface IHandler {
|
||||
|
||||
void handMsg(Message message);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.lemon.view.adapter;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* 为避免反射,ViewType 交给开发者自己管理
|
||||
*
|
||||
* Created by linlongxin on 2017/9/20.
|
||||
*/
|
||||
|
||||
public interface IViewHolderFactory {
|
||||
|
||||
<V extends BaseViewHolder> V getViewHolder(ViewGroup parent, int viewType);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.lemon.view.adapter;
|
||||
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* 为避免反射,ViewType 交给开发者自己管理(IViewTypeFactory)
|
||||
*
|
||||
* Created by linlongxin on 2017/9/20.
|
||||
*/
|
||||
|
||||
public class ViewTypeManager {
|
||||
|
||||
private final String TAG = "ViewTypeManager";
|
||||
// position to Type
|
||||
private SparseIntArray mPositionToTypeMap;
|
||||
|
||||
private IViewHolderFactory mViewHolderFactory;
|
||||
|
||||
public ViewTypeManager() {
|
||||
mPositionToTypeMap = new SparseIntArray();
|
||||
}
|
||||
|
||||
protected int getViewType(int position) {
|
||||
return mPositionToTypeMap.get(position);
|
||||
}
|
||||
|
||||
protected void putViewType(int position, int viewType) {
|
||||
mPositionToTypeMap.put(position, viewType);
|
||||
}
|
||||
|
||||
public void setViewHolderFactory(IViewHolderFactory factory){
|
||||
mViewHolderFactory = factory;
|
||||
}
|
||||
|
||||
protected <T extends BaseViewHolder> T getViewHolder(ViewGroup parent, int viewType){
|
||||
if (mViewHolderFactory != null) {
|
||||
return mViewHolderFactory.getViewHolder(parent, viewType);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.lemon.view.adapter;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* Created by linlongxin on 2018/3/29
|
||||
*/
|
||||
public class WeakHandler extends Handler {
|
||||
|
||||
private WeakReference<IHandler> mHandler;
|
||||
|
||||
public WeakHandler(IHandler handler) {
|
||||
this.mHandler = new WeakReference<>(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
IHandler handler = mHandler.get();
|
||||
if (handler != null) {
|
||||
handler.handMsg(msg);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<solid android:color="#BBBBBB"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
@ -1,72 +1,143 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "com.yutou.jianrmg_v2"
|
||||
//applicationId "com.yutou.jianr_mg"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 27
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionName "0.4α"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('D:\\AndroidKeys\\yutou.jks')
|
||||
storePassword '34864394'
|
||||
keyAlias 'yutou'
|
||||
keyPassword '34864394'
|
||||
}
|
||||
debug {
|
||||
storeFile file('D:\\AndroidKeys\\yutou.jks')
|
||||
storePassword '34864394'
|
||||
keyAlias 'yutou'
|
||||
keyPassword '34864394'
|
||||
}
|
||||
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debug {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility 1.8
|
||||
}
|
||||
|
||||
}
|
||||
configurations.all {
|
||||
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
|
||||
def requested = details.requested
|
||||
if (requested.group == 'com.android.support') {
|
||||
if (!requested.name.startsWith("multidex")) {
|
||||
details.useVersion '27.1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
|
||||
//noinspection GradleCompatible
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
|
||||
//implementation 'com.android.support:design:26.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
|
||||
//okhttp
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
|
||||
|
||||
//FastJson
|
||||
implementation 'com.alibaba:fastjson:1.2.41'
|
||||
|
||||
//轮播图
|
||||
implementation 'com.bigkoo:convenientbanner:2.0.5'
|
||||
|
||||
//图片流缓存
|
||||
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
//圆形图片
|
||||
implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
|
||||
//滑动Tabs
|
||||
implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
|
||||
implementation 'com.ogaclejapan.smarttablayout:utils-v13:1.6.1@aar'
|
||||
|
||||
//MD 对话框
|
||||
implementation 'me.drakeet.materialdialog:library:1.3.1'
|
||||
|
||||
//载入界面
|
||||
implementation 'com.kaopiz:kprogresshud:1.1.0'
|
||||
|
||||
//文本编辑器
|
||||
implementation 'com.github.louisgeek:ClassicLinesEditView:1.0.2'
|
||||
|
||||
//文件选择器
|
||||
implementation 'com.leon:lfilepickerlibrary:1.8.0'
|
||||
|
||||
//富文本展示 #关注更新
|
||||
implementation 'com.zzhoujay.richtext:richtext:3.0.7'
|
||||
|
||||
//底端对话框
|
||||
implementation 'com.orhanobut:dialogplus:1.11@aar'
|
||||
|
||||
//二维码扫描
|
||||
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
|
||||
|
||||
//底端菜单
|
||||
implementation 'me.majiajie:pager-bottom-tab-strip:2.2.5'
|
||||
implementation 'me.majiajie:pager-bottom-tab-strip:2.3.0'
|
||||
|
||||
//刷新载入
|
||||
implementation project(path: ':RefreshRecyclerView')
|
||||
|
||||
//图片形状
|
||||
implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
|
||||
|
||||
//毛玻璃
|
||||
implementation 'jp.wasabeef:glide-transformations:3.0.0'
|
||||
|
||||
//图表
|
||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||
//
|
||||
|
||||
//Spinner
|
||||
implementation 'com.github.arcadefire:nice-spinner:1.3.4'
|
||||
//glide
|
||||
implementation 'com.github.bumptech.glide:glide:4.9.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||
|
||||
//友盟
|
||||
implementation 'com.umeng.umsdk:analytics:7.5.4'
|
||||
implementation 'com.umeng.umsdk:common:1.5.4'
|
||||
|
||||
//友盟推动
|
||||
implementation 'com.umeng.umsdk:utdid:1.1.5.3'
|
||||
implementation 'com.umeng.umsdk:push:5.0.2'
|
||||
|
||||
/* api project(path: ':BaseModel')
|
||||
api project(path: ':GameDataModel')
|
||||
api project(path: ':AppHome')
|
||||
api project(path: ':MgListModel')
|
||||
api project(path: ':ResModl')
|
||||
api project(path: ':UserModel')*/
|
||||
|
||||
implementation files('libs/tbs_sdk_thirdapp_v3.6.0.1371_43624_sharewithdownload_withoutGame_obfs_20181106_121046.jar')
|
||||
}
|
||||
|
BIN
app/libs/GDTUnionSDK.4.28.902.min.jar
Normal file
@ -1,37 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.yutou.jianrmg_v2">
|
||||
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 如果需要精确定位的话请加上此权限 -->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- targetSdkVersion >= 26 时需要配置此权限,否则无法进行安装app的动作 -->
|
||||
|
||||
|
||||
<application
|
||||
android:name=".Application"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:icon="@mipmap/icon_logo"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:roundIcon="@mipmap/icon_logo_round"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<!--<activity
|
||||
android:name=".basemodel.views.LoadingActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
android:theme="@style/AppTheme"
|
||||
android:fullBackupContent="@xml/backup_descriptor"
|
||||
android:allowBackup="true"
|
||||
tools:targetApi="n">
|
||||
|
||||
<meta-data
|
||||
android:name="UMENG_APPKEY"
|
||||
android:value="5c4f0bfcf1f556353e000016" />
|
||||
<meta-data
|
||||
android:name="UMENG_CHANNEL"
|
||||
android:value="QQ" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>-->
|
||||
<activity
|
||||
android:name=".LoadingActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@ -43,15 +53,52 @@
|
||||
android:name=".services.DownloadService"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
<service android:name=".services.WindowsService" />
|
||||
|
||||
<activity
|
||||
android:name=".views.BaseActivity"/>
|
||||
android:name=".views.BaseActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".views.WebActivity" />
|
||||
<activity android:name=".views.ModListActivity" />
|
||||
<activity android:name=".views.ModActivity" />
|
||||
<activity android:name=".views.DownloadListActivity" />
|
||||
<activity android:name=".views.FavoritesActivity" />
|
||||
<activity android:name=".views.UpFeedBack" />
|
||||
<activity android:name=".views.ConfigActivity" />
|
||||
<activity android:name=".views.UserDefinedActivity" />
|
||||
<activity android:name=".views.LicenseActivity" />
|
||||
<activity android:name=".views.RegisterActivity" />
|
||||
<activity android:name=".views.ExcelActivity" />
|
||||
<activity android:name=".views.TestActivity" />
|
||||
<activity android:name=".views.WindowsStartActivity" />
|
||||
|
||||
<!--广点通-->
|
||||
<service
|
||||
android:name="com.qq.e.comm.DownloadService"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".views.WebActivity"/>
|
||||
<activity android:name=".views.ModListActivity"/>
|
||||
<activity android:name=".views.ModActivity"/>
|
||||
<activity android:name=".views.DownloadListActivity"/>
|
||||
<activity android:name=".views.FavoritesActivity"/>
|
||||
android:name="com.qq.e.ads.ADActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name="com.qq.e.ads.PortraitADActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.qq.e.ads.LandscapeADActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="landscape" />
|
||||
|
||||
<provider
|
||||
android:name=".Tools.MyFileProvider"
|
||||
android:authorities="com.yutou.jianrmg_v2.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/gdt_file_path" />
|
||||
</provider>
|
||||
<uses-library android:name="org.apache.http.legacy" android:required="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
94805
app/src/main/assets/shipCardId
Normal file
BIN
app/src/main/icon_logo-web.png
Normal file
After Width: | Height: | Size: 105 KiB |
5
app/src/main/java/Interfaces/MagicBoxInterface.java
Normal file
@ -0,0 +1,5 @@
|
||||
package Interfaces;
|
||||
|
||||
public interface MagicBoxInterface {
|
||||
void getData(String data);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.bigzhao.jianrmagicbox;
|
||||
|
||||
public interface IMagicBoxBinder {
|
||||
String ACTION_SERVICE="com.bigzhao.jianrmagicbox.action.SERVICE";
|
||||
String ACTION_RECEIVER="com.bigzhao.jianrmagicbox.action.RECEIVER";
|
||||
int getVersion();
|
||||
Object action(String action, String... args) throws Exception;
|
||||
}
|
@ -2,7 +2,6 @@ package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -15,7 +14,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Interfaces.ModInterface;
|
||||
import com.yutou.jianrmg_v2.Databases.ModDatabase;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ModUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
@ -65,32 +64,25 @@ public class DownloadItemAdapter extends BaseAdapter {
|
||||
}else{
|
||||
items= (Items) view.getTag();
|
||||
}
|
||||
if(list.get(i)==null)
|
||||
return view;
|
||||
items.title.setText(list.get(i).getTitle());
|
||||
imageLoader.displayImage(AppData.appConfig.getDownloadhome()+list.get(i).getIcon(),items.icon);
|
||||
items.delete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
items.delete.setOnClickListener(v -> {
|
||||
final MaterialDialog dialog=new MaterialDialog(context);
|
||||
dialog.setTitle("提示");
|
||||
dialog.setMessage("删除这个内容?");
|
||||
dialog.setNegativeButton("我手滑了", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.setPositiveButton("是的", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.setNegativeButton("我手滑了", v12 -> dialog.dismiss());
|
||||
dialog.setPositiveButton("是的", v1 -> {
|
||||
Utils.deleteFiles(Utils.getAppPath()+"/"+list.get(i).getId());
|
||||
ModDatabase database=ModDatabase.init();
|
||||
database.deleteMod(list.get(i));
|
||||
Utils.toast(context,"删除完成");
|
||||
list.remove(i);
|
||||
notifyDataSetChanged();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
items.install.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -0,0 +1,64 @@
|
||||
package com.yutou.jianrmg_v2.Adapters.GameDataAdapters;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
|
||||
public class DropAdapter extends RecyclerAdapter<Map<String,String>> {
|
||||
ImageLoader loader;
|
||||
public DropAdapter(Context context) {
|
||||
super(context);
|
||||
loader= Utils.initImageLoader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder<Map<String, String>> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new MyHolder(parent, R.layout.item_team);
|
||||
}
|
||||
class MyHolder extends BaseViewHolder<Map<String,String>>{
|
||||
private ImageView icon;
|
||||
private LinearLayout layout,hpLayout;
|
||||
private TextView name,time;
|
||||
private ProgressBar itemHp;
|
||||
MyHolder(ViewGroup parent, int layoutId) {
|
||||
super(parent, layoutId);
|
||||
icon=findViewById(R.id.icon);
|
||||
layout=findViewById(R.id.items);
|
||||
hpLayout=findViewById(R.id.hpLayout);
|
||||
name=findViewById(R.id.title);
|
||||
itemHp=findViewById(R.id.itemHp);
|
||||
layout.setVisibility(View.GONE);
|
||||
itemHp.setVisibility(View.GONE);
|
||||
hpLayout.removeAllViews();
|
||||
time=new TextView(getContext());
|
||||
hpLayout.addView(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Map<String, String> data) {
|
||||
super.setData(data);
|
||||
name.setText(data.get("name"));
|
||||
time.setText(data.get("time"));
|
||||
if(data.containsKey("icon")){
|
||||
loader.displayImage(data.get("icon"),icon);
|
||||
}else{
|
||||
icon.setImageResource(R.mipmap.icon_logo);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.yutou.jianrmg_v2.Adapters.GameDataAdapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
|
||||
public class WarAdapter extends RecyclerAdapter<Map<String,String>> {
|
||||
public WarAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder<Map<String, String>> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new MyHolder(parent, R.layout.item_team);
|
||||
}
|
||||
class MyHolder extends BaseViewHolder<Map<String,String>>{
|
||||
|
||||
public MyHolder(ViewGroup parent, int layoutId) {
|
||||
super(parent, layoutId);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,24 @@
|
||||
package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.Data.MAppHome;
|
||||
import com.yutou.jianrmg_v2.Model.HomeCard;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.HomeHeader;
|
||||
import com.yutou.jianrmg_v2.views.ModActivity;
|
||||
import com.yutou.jianrmg_v2.views.WebActivity;
|
||||
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
|
||||
@ -25,53 +28,66 @@ import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
* Created by 58381 on 2018/1/23.
|
||||
*/
|
||||
|
||||
public class HomeRecyclerAdapter extends RecyclerAdapter<MAppHome> {
|
||||
public class HomeRecyclerAdapter extends RecyclerAdapter<HomeCard> {
|
||||
private ImageLoader imageLoader;
|
||||
private Activity activity;
|
||||
|
||||
public HomeRecyclerAdapter(Context context) {
|
||||
super(context);
|
||||
this.activity= (Activity) context;
|
||||
this.activity = (Activity) context;
|
||||
imageLoader = Utils.initImageLoader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder<MAppHome> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new CardRecordHolder(parent, R.layout.item_home);
|
||||
public BaseViewHolder<HomeCard> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new CardRecordHolder(parent, R.layout.item_home_card);
|
||||
}
|
||||
|
||||
private class CardRecordHolder extends BaseViewHolder<MAppHome> {
|
||||
private ImageView icon;
|
||||
private TextView name;
|
||||
private class CardRecordHolder extends BaseViewHolder<HomeCard> {
|
||||
private HomeHeader header;
|
||||
private ImageView imageView;
|
||||
private TextView textView;
|
||||
|
||||
|
||||
public CardRecordHolder(ViewGroup parent, int layoutId) {
|
||||
CardRecordHolder(ViewGroup parent, int layoutId) {
|
||||
super(parent, layoutId);
|
||||
icon = findViewById(R.id.image);
|
||||
name = findViewById(R.id.title);
|
||||
|
||||
|
||||
header=HomeHeader.getHome(getContext());
|
||||
imageView=findViewById(R.id.card);
|
||||
textView=findViewById(R.id.text);
|
||||
imageLoader=Utils.initImageLoader(getContext());
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void setData(MAppHome data) {
|
||||
public void setData(HomeCard data) {
|
||||
super.setData(data);
|
||||
Log.i("首页收据", JSON.toJSONString(data));
|
||||
if (data.getIcon() != null && "null".equals(data.getIcon()))
|
||||
imageLoader.displayImage(data.getIcon(), icon);
|
||||
name.setText(data.getName() + "");
|
||||
header.flashHome();
|
||||
imageLoader.displayImage(data.getImageUrl(),imageView);
|
||||
textView.setText(" "+data.getText()+">> ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemViewClick(MAppHome data) {
|
||||
public void onItemViewClick(HomeCard data) {
|
||||
super.onItemViewClick(data);
|
||||
if (data.getUrl() != null && data.getUrl().contains("webhttp")) {
|
||||
Intent intent = new Intent(getContext(), WebActivity.class);
|
||||
// intent.setAction(Intent.ACTION_VIEW);
|
||||
// intent.setData(Uri.parse(data.getUrl()));
|
||||
intent.putExtra("url", data.getUrl().replace("webhttp", "http"));
|
||||
Intent intent = null;
|
||||
switch (data.getType()){
|
||||
case 0:
|
||||
intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(data.getClick().toString()));
|
||||
|
||||
break;
|
||||
case 1:
|
||||
intent=new Intent(getContext(), ModActivity.class);
|
||||
intent.putExtra("modId",data.getClick());
|
||||
break;
|
||||
case 2:
|
||||
intent=new Intent(getContext(), WebActivity.class);
|
||||
intent.putExtra("url",data.getClick());
|
||||
break;
|
||||
}
|
||||
if(intent!=null)
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,169 @@
|
||||
package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
||||
import com.yutou.jianrmg_v2.Data.TeamData;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MagicTeamDataAdapter extends BaseAdapter {
|
||||
List<TeamData> list;
|
||||
Context context;
|
||||
ImageLoader loader;
|
||||
boolean spoiler=false;
|
||||
|
||||
|
||||
public MagicTeamDataAdapter(List<TeamData> list, Context context) {
|
||||
this.list = list;
|
||||
this.context = context;
|
||||
loader = Utils.initImageLoader(context);
|
||||
}
|
||||
|
||||
public void setSpoiler(boolean spoiler) {
|
||||
this.spoiler = spoiler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeamData getItem(int i) {
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
ItemViews item = null;
|
||||
if (view == null) {
|
||||
item = new ItemViews();
|
||||
view = LayoutInflater.from(context).inflate(R.layout.item_team, viewGroup,false);
|
||||
item.hp = view.findViewById(R.id.hp);
|
||||
item.hpMax = view.findViewById(R.id.hpMax);
|
||||
item.hpBar = view.findViewById(R.id.itemHp);
|
||||
item.title = view.findViewById(R.id.title);
|
||||
item.icon = view.findViewById(R.id.icon);
|
||||
item.icon_ = view.findViewById(R.id.icon_);
|
||||
item.item1 = view.findViewById(R.id.item1);
|
||||
item.item2 = view.findViewById(R.id.item2);
|
||||
item.item3 = view.findViewById(R.id.item3);
|
||||
item.item4 = view.findViewById(R.id.item4);
|
||||
item.hpLayout=view.findViewById(R.id.hpLayout);
|
||||
view.setTag(item);
|
||||
} else {
|
||||
item = (ItemViews) view.getTag();
|
||||
}
|
||||
TeamData data = list.get(i);
|
||||
item.hp.setText(data.getHp());
|
||||
if(!spoiler){
|
||||
item.hp.setText("???");
|
||||
}
|
||||
item.hpMax.setText(data.getHpMax());
|
||||
item.hpBar.setMax(Integer.valueOf(data.getHpMax()));
|
||||
item.hpBar.setProgress(Integer.valueOf(data.getHp()));
|
||||
if(!spoiler){
|
||||
item.hpBar.setProgress(0);
|
||||
}
|
||||
item.title.setText(data.getTitle());
|
||||
if(!data.isUser()){
|
||||
((LinearLayout.LayoutParams)item.hpLayout.getLayoutParams()).gravity=Gravity.END;
|
||||
item.title.setGravity(Gravity.END);
|
||||
item.icon.setVisibility(View.GONE);
|
||||
item.icon_.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
((LinearLayout.LayoutParams)item.hpLayout.getLayoutParams()).gravity=Gravity.LEFT;
|
||||
item.title.setGravity(Gravity.LEFT);
|
||||
item.icon.setVisibility(View.VISIBLE);
|
||||
item.icon_.setVisibility(View.GONE);
|
||||
}
|
||||
if (data.getImageUrl() != null) {
|
||||
if (data.isUser()) {
|
||||
loader.displayImage(data.getImageUrl(), item.icon);
|
||||
} else {
|
||||
loader.displayImage(data.getImageUrl(), item.icon_);
|
||||
}
|
||||
}
|
||||
if (data.getItem1Url() != null) {
|
||||
loader.displayImage(data.getItem1Url(), item.item1,new imageListener() );
|
||||
item.item1.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
item.item1.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
item.item1.setVisibility(View.GONE);
|
||||
}
|
||||
if (data.getItem2Url() != null) {
|
||||
loader.displayImage(data.getItem2Url(), item.item2,new imageListener());
|
||||
item.item2.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
item.item2.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
item.item2.setVisibility(View.GONE);
|
||||
}
|
||||
if (data.getItem3Url() != null) {
|
||||
loader.displayImage(data.getItem3Url(), item.item3,new imageListener());
|
||||
item.item3.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
item.item3.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
item.item3.setVisibility(View.GONE);
|
||||
}
|
||||
if (data.getItem4Url() != null) {
|
||||
loader.displayImage(data.getItem4Url(), item.item4,new imageListener());
|
||||
item.item4.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
item.item4.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
item.item4.setVisibility(View.GONE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setData(List<TeamData> enemyTeam) {
|
||||
this.list=enemyTeam;
|
||||
}
|
||||
|
||||
class ItemViews {
|
||||
TextView title, hp, hpMax;
|
||||
ImageView icon, icon_, item1, item2, item3, item4;
|
||||
ProgressBar hpBar;
|
||||
LinearLayout hpLayout;
|
||||
}
|
||||
class imageListener implements ImageLoadingListener {
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
ImageView imageView= (ImageView) view;
|
||||
imageView.setImageResource(R.mipmap.icon_logo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingCancelled(String imageUri, View view) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MAppTools;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.BaseActivity;
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
|
||||
public class MainUtilsAdapter extends RecyclerAdapter<MAppTools> {
|
||||
private ImageLoader imageLoader;
|
||||
|
||||
public MainUtilsAdapter(Context context) {
|
||||
super(context);
|
||||
imageLoader = Utils.initImageLoader(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder<MAppTools> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new MyViewHolder(parent, R.layout.item_mg_home);
|
||||
}
|
||||
|
||||
private class MyViewHolder extends BaseViewHolder<MAppTools> {
|
||||
private ImageView icon;
|
||||
private TextView name;
|
||||
|
||||
MyViewHolder(ViewGroup parent, int layoutId) {
|
||||
super(parent, layoutId);
|
||||
icon = findViewById(R.id.image);
|
||||
name = findViewById(R.id.title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(MAppTools data) {
|
||||
super.setData(data);
|
||||
imageLoader.displayImage(data.getImage(), icon);
|
||||
name.setText(data.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemViewClick(MAppTools data) {
|
||||
super.onItemViewClick(data);
|
||||
if (data.getMainFunction().equals("#")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String type = data.getMainFunction().split("#")[1];
|
||||
String main = data.getMainFunction().split("#")[0];
|
||||
|
||||
try {
|
||||
Intent intent=null;
|
||||
if(!type.equals("localActivity")){
|
||||
intent = new Intent(getContext(), Application.application.getClassLoader().loadClass(main));
|
||||
if(data.getParameter()!=null){
|
||||
intent.putExtra("parameter",data.getParameter());
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case "activity":
|
||||
getContext().startActivity(intent);
|
||||
break;
|
||||
case "service":
|
||||
getContext().startService(intent);
|
||||
break;
|
||||
case "localActivity":
|
||||
intent=new Intent(getContext(), BaseActivity.class);
|
||||
intent.putExtra("activityName",main);
|
||||
intent.putExtra("jar",data.getPluginName()+".jar");
|
||||
intent.putExtra("name",data.getName());
|
||||
intent.putExtra("url",data.getUrl());
|
||||
if(data.getParameter()!=null){
|
||||
intent.putExtra("parameter",data.getParameter());
|
||||
}
|
||||
getContext().startActivity(intent);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.ViewGroup;
|
||||
@ -34,14 +35,14 @@ public class ModListRecyclerAdapter extends RecyclerAdapter<MAppMg> {
|
||||
|
||||
@Override
|
||||
public BaseViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new CardRecordHolder(parent, R.layout.item_home);
|
||||
return new CardRecordHolder(parent, R.layout.item_mg_home);
|
||||
}
|
||||
|
||||
private class CardRecordHolder extends BaseViewHolder<MAppMg> {
|
||||
private ImageView icon;
|
||||
private TextView name;
|
||||
|
||||
public CardRecordHolder(ViewGroup parent, int layoutId) {
|
||||
CardRecordHolder(ViewGroup parent, int layoutId) {
|
||||
super(parent, layoutId);
|
||||
icon = findViewById(R.id.image);
|
||||
name = findViewById(R.id.title);
|
||||
@ -50,8 +51,17 @@ public class ModListRecyclerAdapter extends RecyclerAdapter<MAppMg> {
|
||||
@Override
|
||||
public void setData(MAppMg data) {
|
||||
super.setData(data);
|
||||
if (data.getIcon() != null && "null".equals(data.getIcon()))
|
||||
imageLoader.displayImage(AppData.appConfig.getDownloadhome() + data.getIcon(), icon);
|
||||
if (data.getIcon() != null && !"null".equals(data.getIcon())) {
|
||||
String url=data.getIcon();
|
||||
if(!url.contains("http://")&&!url.contains("https://")){
|
||||
url=AppData.appConfig.getDownloadhome() + data.getIcon();
|
||||
}
|
||||
imageLoader.displayImage(url, icon);
|
||||
}else{
|
||||
icon.setImageResource(R.mipmap.icon_logo);
|
||||
icon.getLayoutParams().width=Utils.getPixelsFromDp((Activity) getContext(),84);
|
||||
icon.getLayoutParams().height=Utils.getPixelsFromDp((Activity) getContext(),84);
|
||||
}
|
||||
name.setText(data.getName());
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.yutou.jianrmg_v2.Adapters;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@ -13,13 +13,26 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Data.TModtype;
|
||||
import com.yutou.jianrmg_v2.Data.ZsShipType;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Interfaces.ModInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.ModUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.ModActivity;
|
||||
|
||||
import org.angmarch.views.NiceSpinner;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
|
||||
/**
|
||||
@ -28,6 +41,7 @@ import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
|
||||
public class ModRecyclerAdapter extends RecyclerAdapter<TMod> {
|
||||
private ImageLoader imageLoader;
|
||||
private CardRecordHolder holder;
|
||||
|
||||
public ModRecyclerAdapter(Context context) {
|
||||
super(context);
|
||||
@ -36,51 +50,183 @@ public class ModRecyclerAdapter extends RecyclerAdapter<TMod> {
|
||||
|
||||
@Override
|
||||
public BaseViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
return new CardRecordHolder(parent, R.layout.item_mod_item);
|
||||
holder = new CardRecordHolder(parent, R.layout.item_mod_item);
|
||||
return holder;
|
||||
}
|
||||
|
||||
private class CardRecordHolder extends BaseViewHolder<TMod> {
|
||||
private ImageView icon,select;
|
||||
private ImageView icon, select;
|
||||
private TextView title;
|
||||
private PopupMenu menu;
|
||||
|
||||
public CardRecordHolder(ViewGroup parent, int layoutId) {
|
||||
private List<TModtype> modtypes;
|
||||
private List<ZsShipType> shipTypes;
|
||||
CardRecordHolder(ViewGroup parent, int layoutId) {
|
||||
super(parent, layoutId);
|
||||
icon = findViewById(R.id.icon);
|
||||
title = findViewById(R.id.title);
|
||||
select=findViewById(R.id.select);
|
||||
menu=new PopupMenu(getContext(),select);
|
||||
select = findViewById(R.id.select);
|
||||
menu = new PopupMenu(getContext(), select);
|
||||
if (AppData.user.getPower() == 0)
|
||||
menu.inflate(R.menu.mod_menu_notadmin);
|
||||
else
|
||||
menu.inflate(R.menu.mod_menu);
|
||||
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if(item.getSubMenu()!=null){
|
||||
menu.show();
|
||||
if (getContext().getClass().getName().contains("FavoritesActivity"))
|
||||
for (int i = 0; i < menu.getMenu().size(); i++) {
|
||||
if (menu.getMenu().getItem(i).getItemId() == R.id.collection) {
|
||||
menu.getMenu().getItem(i).setTitle("取消收藏");
|
||||
break;
|
||||
}
|
||||
}
|
||||
menu.setOnMenuItemClickListener(item -> {
|
||||
if (item.getSubMenu() != null) {
|
||||
menu.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
select.setOnClickListener(new View.OnClickListener() {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.audit_ok:
|
||||
setMod("1");
|
||||
break;
|
||||
case R.id.audit_no:
|
||||
setMod("0");
|
||||
break;
|
||||
case R.id.move:
|
||||
setMod("move");
|
||||
break;
|
||||
case R.id.collection:
|
||||
try {
|
||||
String url=HttpApi.MOD_COLLCETION;
|
||||
if (getContext().getClass().getName().contains("FavoritesActivity")){
|
||||
url=HttpApi.MOD_REMOE_COLLCET;
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("uid", AppData.user.getId());
|
||||
json.put("mid", getData().getId() + "");
|
||||
HttpUtils.post(HttpApi.HOME_URL + url, json, new HttpInterface() {
|
||||
private String state = "取消收藏失败,未知错误";
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
menu.show();
|
||||
public void httpGetData(String string, int code) {
|
||||
|
||||
try {
|
||||
JSONObject json = new JSONObject(string);
|
||||
state = json.getString("msg");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(e, ModRecyclerAdapter.this);
|
||||
}
|
||||
AppData.handler.post(() -> Utils.toast(getContext(), state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(e, ModRecyclerAdapter.this);
|
||||
}
|
||||
break;
|
||||
case R.id.download:
|
||||
ModUtils.init(getContext()).installMod(getData(), (flag, type) -> AppData.handler.post(() -> Utils.toast(getContext(), "flag:" + flag + " type:" + type)));
|
||||
break;
|
||||
case R.id.admin:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
select.setOnClickListener(view -> menu.show());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(TMod data) {
|
||||
super.setData(data);
|
||||
imageLoader.displayImage( AppData.appConfig.getDownloadhome()+data.getIcon(),icon);
|
||||
imageLoader.displayImage(AppData.appConfig.getDownloadhome() + data.getIcon(), icon);
|
||||
title.setText(data.getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemViewClick(TMod data) {
|
||||
super.onItemViewClick(data);
|
||||
Intent intent=new Intent(getContext(), ModActivity.class);
|
||||
Intent intent = new Intent(getContext(), ModActivity.class);
|
||||
intent.putExtra("mod", JSON.toJSONString(data));
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
private void setMod(String type){
|
||||
if(!type.equals("move")){
|
||||
setMod(type,-1,-1);
|
||||
return;
|
||||
}
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.MOD_GET_TYPEINFO, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
JSONObject data=json.getJSONObject("data");
|
||||
modtypes=JSON.parseArray(data.get("mType").toString(),TModtype.class);
|
||||
shipTypes=JSON.parseArray(data.get("jType").toString(),ZsShipType.class);
|
||||
AppData.handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final MaterialDialog dialog=new MaterialDialog(getContext());
|
||||
dialog.setTitle("移动分区");
|
||||
View view= LayoutInflater.from(getContext()).inflate(R.layout.item_mod_move,null);
|
||||
final NiceSpinner modSpinner=view.findViewById(R.id.mod_spinner);
|
||||
final NiceSpinner jianSprinner=view.findViewById(R.id.jian_spinner);
|
||||
modSpinner.attachDataSource(TModtype.toStringList(modtypes));
|
||||
jianSprinner.attachDataSource(ZsShipType.toStringList(shipTypes));
|
||||
dialog.setContentView(view);
|
||||
dialog.setPositiveButton("确定", v -> {
|
||||
setMod("move",modSpinner.getSelectedIndex(),jianSprinner.getSelectedIndex());
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.setNegativeButton("取消", v -> dialog.dismiss());
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
private void setMod(String type,int mType,int jType){
|
||||
try{
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("mid",getData().getId());
|
||||
json.put("type",type);
|
||||
json.put("mType",mType==-1?"":modtypes.get(mType).getId());
|
||||
json.put("jType",jType==-1?"":shipTypes.get(jType).getId());
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_MOVE, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
final String data=json.getString("msg");
|
||||
AppData.handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.toast(getContext(),data);
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
@ -7,20 +8,25 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.ConfigActivity;
|
||||
import com.yutou.jianrmg_v2.views.DownloadListActivity;
|
||||
import com.yutou.jianrmg_v2.views.FavoritesActivity;
|
||||
import com.yutou.jianrmg_v2.views.UpFeedBack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MyItemGridViewAdapter extends BaseAdapter {
|
||||
public static class ItemData{
|
||||
public static class ItemData {
|
||||
private String title;
|
||||
private int imageUrl=-1;
|
||||
private int imageUrl = -1;
|
||||
|
||||
public ItemData(int imageUrl, String title) {
|
||||
this.imageUrl = imageUrl;
|
||||
@ -35,13 +41,13 @@ public class MyItemGridViewAdapter extends BaseAdapter {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
private List<ItemData> list;
|
||||
private Context context;
|
||||
|
||||
public MyItemGridViewAdapter(List<ItemData> list, Context context) {
|
||||
this.list = list;
|
||||
this.context = context;
|
||||
Log.i("List Size",""+list.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,38 +67,49 @@ public class MyItemGridViewAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public View getView(final int i, View view, ViewGroup viewGroup) {
|
||||
Item item=null;
|
||||
if(view==null){
|
||||
item=new Item();
|
||||
view= LayoutInflater.from(context).inflate(R.layout.item_my_gridview,null);
|
||||
item.imageView=view.findViewById(R.id.image);
|
||||
item.title=view.findViewById(R.id.title);
|
||||
Item item = null;
|
||||
if (view == null) {
|
||||
item = new Item();
|
||||
view = LayoutInflater.from(context).inflate(R.layout.item_my_gridview, null);
|
||||
item.imageView = view.findViewById(R.id.image);
|
||||
item.title = view.findViewById(R.id.title);
|
||||
view.setTag(item);
|
||||
}else{
|
||||
item= (Item) view.getTag();
|
||||
} else {
|
||||
item = (Item) view.getTag();
|
||||
}
|
||||
if(list.get(i).imageUrl!=-1){
|
||||
if (list.get(i).imageUrl != -1) {
|
||||
item.imageView.setImageResource(list.get(i).getImageUrl());
|
||||
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(Utils.getPixelsFromDp((Activity) context,32),Utils.getPixelsFromDp((Activity) context,32));
|
||||
params.topMargin=Utils.getPixelsFromDp((Activity) context,8);
|
||||
params.leftMargin=Utils.getPixelsFromDp((Activity) context,24);
|
||||
params.bottomMargin=Utils.getPixelsFromDp((Activity) context,8);
|
||||
item.imageView.setLayoutParams(params);
|
||||
}
|
||||
item.title.setText(list.get(i).title);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.i("点击"+list.get(i).getTitle());
|
||||
Intent intent=null;
|
||||
switch (i){
|
||||
view.setOnClickListener(view1 -> {
|
||||
Log.i("点击" + list.get(i).getTitle());
|
||||
Intent intent = null;
|
||||
switch (i) {
|
||||
case 0:
|
||||
intent=new Intent(context, DownloadListActivity.class);
|
||||
intent = new Intent(context, DownloadListActivity.class);
|
||||
break;
|
||||
case 1:
|
||||
intent = new Intent(context, FavoritesActivity.class);
|
||||
break;
|
||||
case 2:
|
||||
intent = new Intent(context, UpFeedBack.class);
|
||||
break;
|
||||
case 3:
|
||||
intent=new Intent(context, ConfigActivity.class);
|
||||
break;
|
||||
}
|
||||
if(intent!=null)
|
||||
if (intent != null)
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
private class Item{
|
||||
private class Item {
|
||||
private ImageView imageView;
|
||||
private TextView title;
|
||||
}
|
||||
|
@ -3,16 +3,32 @@ package com.yutou.jianrmg_v2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.tencent.smtt.sdk.QbSdk;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
import com.umeng.message.IUmengRegisterCallback;
|
||||
import com.umeng.message.PushAgent;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.User;
|
||||
import com.yutou.jianrmg_v2.Databases.UserDatabase;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.ActivitysManager;
|
||||
import com.yutou.jianrmg_v2.Tools.ConfigUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.JianRUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.zzhoujay.richtext.ext.MD5;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
@ -22,40 +38,146 @@ import dalvik.system.DexClassLoader;
|
||||
*/
|
||||
|
||||
public class Application extends android.app.Application {
|
||||
public static Application application;
|
||||
private static final String TAG = "Application";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Application.application = this;
|
||||
// DoraemonKit.install(application);
|
||||
UMConfigure.setLogEnabled(true);
|
||||
System.out.println("开始初始化");
|
||||
|
||||
init();
|
||||
// initPlugsin();
|
||||
initPlugs();
|
||||
regActivity();
|
||||
}
|
||||
private void initPlugsin(){
|
||||
Map<String,DexClassLoader> plugsin=new HashMap<>();
|
||||
File path=new File(Utils.getAppPath()+"/plugin/");
|
||||
for (File file : path.listFiles()) {
|
||||
if(file.getName().contains(".jar")){
|
||||
DexClassLoader dexClassLoader=new DexClassLoader(file.getAbsolutePath(),"/data/data/"+getPackageName()+"/",null,getClassLoader());
|
||||
plugsin.put(file.getName(),dexClassLoader);
|
||||
}
|
||||
}
|
||||
AppData.plugsin=plugsin;
|
||||
}
|
||||
private void init(){
|
||||
AppData.Token= (String) ConfigUtils.init().load("token");
|
||||
AppData.user=new User();
|
||||
try {
|
||||
AppData.user.setId((Integer) ConfigUtils.init().load("uid"));
|
||||
}catch (Exception e){
|
||||
AppData.user.setId(-1);
|
||||
JianRUtils.initShipCardId();
|
||||
|
||||
|
||||
QbSdk.initX5Environment(this, new QbSdk.PreInitCallback() {
|
||||
@Override
|
||||
public void onCoreInitFinished() {
|
||||
System.out.println("QDSDK初始化失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewInitFinished(boolean b) {
|
||||
Log.e("QDSDK","加载内核是否成功:"+b);
|
||||
}
|
||||
private void regActivity(){
|
||||
});
|
||||
UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, "c5ec76e4a6ebb1516359792ffee09eb5");
|
||||
MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
|
||||
PushAgent.getInstance(this).register(new IUmengRegisterCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
System.out.println("友盟推送注册成功:"+s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String s, String s1) {
|
||||
System.out.println("友盟推送注册失败:"+s+"("+s1+")");
|
||||
}
|
||||
});
|
||||
System.out.println("初始化结束");
|
||||
}
|
||||
|
||||
private void initPlugs() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
||||
Map<String, DexClassLoader> plugsin = new HashMap<>();
|
||||
File path = new File(Utils.getAppPath() + "/plugin/");
|
||||
if (path.exists()) {
|
||||
for (File file : path.listFiles()) {
|
||||
if (file.getName().contains(".jar")) {
|
||||
DexClassLoader dexClassLoader = new DexClassLoader(file.getAbsolutePath(), Application.application.getFilesDir() + "/plugs/", null, getClassLoader());
|
||||
plugsin.put(file.getName(), dexClassLoader);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
path.mkdirs();
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
List<String> fileName = new ArrayList<>();
|
||||
for (File file : path.listFiles()) {
|
||||
try {
|
||||
if (!file.getName().contains(".jar")) {
|
||||
continue;
|
||||
}
|
||||
String appid = (String) plugsin.get(file.getName()).loadClass("com.yutou.jianrmg_v2.plugins.Data").getField("appId").get(null);
|
||||
String md5 = Utils.getFileMD5(file);
|
||||
System.out.println("MD5:" + md5);
|
||||
JSONObject plugs = new JSONObject();
|
||||
plugs.put("appid", appid);
|
||||
plugs.put("md5", md5);
|
||||
plugs.put("name", file.getName());
|
||||
fileName.add(file.getName());
|
||||
array.put(plugs);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
json.put("array", array.toString());
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.SYSTEM_PLUGINS, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(string);
|
||||
JSONArray plugs = json.getJSONArray("data");
|
||||
for (int i = 0; i < plugs.length(); i++) {
|
||||
if (fileName.contains(plugs.getString(i))) {
|
||||
AppData.plugsin.put(plugs.getString(i), plugsin.get(plugs.getString(i)));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
User user = UserDatabase.init().getUser();
|
||||
if (user == null) {
|
||||
AppData.Token = "0000";
|
||||
AppData.user = new User();
|
||||
AppData.user.setId(-1);
|
||||
} else {
|
||||
AppData.Token = user.getToken();
|
||||
AppData.user = user;
|
||||
}
|
||||
File file = new File(Utils.getAppPath());
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
private void regActivity() {
|
||||
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
Log.i("Appliction","创建:"+activity.getClass().getName());
|
||||
Log.i(TAG, "创建:" + activity.getClass().getName());
|
||||
AppData.activity = activity;
|
||||
AppData.handler = new Handler();
|
||||
ActivitysManager.addActivity(activity);
|
||||
PushAgent.getInstance(activity).onAppStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,7 +207,7 @@ public class Application extends android.app.Application {
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
Log.i("Appliction","销毁:"+activity.getClass().getName());
|
||||
Log.i(TAG, "销毁:" + activity.getClass().getName());
|
||||
ActivitysManager.finishActivity(activity);
|
||||
}
|
||||
});
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -11,11 +15,16 @@ import dalvik.system.DexClassLoader;
|
||||
|
||||
public class AppData {
|
||||
public static List<MGamePackname> packnames;
|
||||
public static Map<String,DexClassLoader> plugsin;
|
||||
public static List<TModfilePath> installPath;
|
||||
public static Map<String,DexClassLoader> plugsin=new HashMap<>();
|
||||
public static SConfig appConfig;
|
||||
public static User user;
|
||||
public static UUserdata userdata;
|
||||
public static String Token="";
|
||||
|
||||
public static boolean RxDeBug=true;
|
||||
public static Activity activity;
|
||||
public static Handler handler;
|
||||
public static String version="1.0";
|
||||
public static String magicPackageName ="com.bigzhao.jianrmagicbox";
|
||||
}
|
||||
|
@ -1,120 +1,6 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
public class MAppHome {
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.id
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.name
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.icon
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.url
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.isshow
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
private Integer isshow;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.id
|
||||
* @return the value of m_app_home.id
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.id
|
||||
* @param id the value for m_app_home.id
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.name
|
||||
* @return the value of m_app_home.name
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.name
|
||||
* @param name the value for m_app_home.name
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.icon
|
||||
* @return the value of m_app_home.icon
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.icon
|
||||
* @param icon the value for m_app_home.icon
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.url
|
||||
* @return the value of m_app_home.url
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.url
|
||||
* @param url the value for m_app_home.url
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.isshow
|
||||
* @return the value of m_app_home.isshow
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public Integer getIsshow() {
|
||||
return isshow;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.isshow
|
||||
* @param isshow the value for m_app_home.isshow
|
||||
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
|
||||
*/
|
||||
public void setIsshow(Integer isshow) {
|
||||
this.isshow = isshow;
|
||||
}
|
||||
private int id;
|
||||
private long action_time;
|
||||
}
|
145
app/src/main/java/com/yutou/jianrmg_v2/Data/MAppHomeConfig.java
Normal file
@ -0,0 +1,145 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class MAppHomeConfig {
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home_config.id
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home_config.name
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home_config.url
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home_config.startdate
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private Date startdate;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home_config.enddate
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private Date enddate;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home_config.state
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home_config.id
|
||||
* @return the value of m_app_home_config.id
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home_config.id
|
||||
* @param id the value for m_app_home_config.id
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home_config.name
|
||||
* @return the value of m_app_home_config.name
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home_config.name
|
||||
* @param name the value for m_app_home_config.name
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home_config.url
|
||||
* @return the value of m_app_home_config.url
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home_config.url
|
||||
* @param url the value for m_app_home_config.url
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home_config.startdate
|
||||
* @return the value of m_app_home_config.startdate
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public Date getStartdate() {
|
||||
return startdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home_config.startdate
|
||||
* @param startdate the value for m_app_home_config.startdate
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setStartdate(Date startdate) {
|
||||
this.startdate = startdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home_config.enddate
|
||||
* @return the value of m_app_home_config.enddate
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public Date getEnddate() {
|
||||
return enddate;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home_config.enddate
|
||||
* @param enddate the value for m_app_home_config.enddate
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setEnddate(Date enddate) {
|
||||
this.enddate = enddate;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home_config.state
|
||||
* @return the value of m_app_home_config.state
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home_config.state
|
||||
* @param state the value for m_app_home_config.state
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setState(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
97
app/src/main/java/com/yutou/jianrmg_v2/Data/MAppLicense.java
Normal file
@ -0,0 +1,97 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
public class MAppLicense {
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_license.id
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_license.name
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_license.license
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
private String license;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_license.url
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_license.id
|
||||
* @return the value of m_app_license.id
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_license.id
|
||||
* @param id the value for m_app_license.id
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_license.name
|
||||
* @return the value of m_app_license.name
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_license.name
|
||||
* @param name the value for m_app_license.name
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_license.license
|
||||
* @return the value of m_app_license.license
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_license.license
|
||||
* @param license the value for m_app_license.license
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_license.url
|
||||
* @return the value of m_app_license.url
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_license.url
|
||||
* @param url the value for m_app_license.url
|
||||
* @mbg.generated Mon Jan 28 11:04:09 CST 2019
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
204
app/src/main/java/com/yutou/jianrmg_v2/Data/MAppTools.java
Normal file
@ -0,0 +1,204 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
public class MAppTools {
|
||||
private String pluginName;
|
||||
private String parameter;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.id
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.name
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.image
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private String image;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.url
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.main_function
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private String mainFunction;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.permission
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private Integer permission;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_tools.isshow
|
||||
*
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
private Integer isshow;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.id
|
||||
*
|
||||
* @return the value of m_app_tools.id
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.id
|
||||
*
|
||||
* @param id the value for m_app_tools.id
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.name
|
||||
*
|
||||
* @return the value of m_app_tools.name
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.name
|
||||
*
|
||||
* @param name the value for m_app_tools.name
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.image
|
||||
*
|
||||
* @return the value of m_app_tools.image
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.image
|
||||
*
|
||||
* @param image the value for m_app_tools.image
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.url
|
||||
*
|
||||
* @return the value of m_app_tools.url
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.url
|
||||
*
|
||||
* @param url the value for m_app_tools.url
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.main_function
|
||||
*
|
||||
* @return the value of m_app_tools.main_function
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public String getMainFunction() {
|
||||
return mainFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.main_function
|
||||
*
|
||||
* @param mainFunction the value for m_app_tools.main_function
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setMainFunction(String mainFunction) {
|
||||
this.mainFunction = mainFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.permission
|
||||
*
|
||||
* @return the value of m_app_tools.permission
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public Integer getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.permission
|
||||
*
|
||||
* @param permission the value for m_app_tools.permission
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setPermission(Integer permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_tools.isshow
|
||||
*
|
||||
* @return the value of m_app_tools.isshow
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public Integer getIsshow() {
|
||||
return isshow;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_tools.isshow
|
||||
*
|
||||
* @param isshow the value for m_app_tools.isshow
|
||||
* @mbg.generated Fri Jan 04 11:28:23 CST 2019
|
||||
*/
|
||||
public void setIsshow(Integer isshow) {
|
||||
this.isshow = isshow;
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public void setPluginName(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
public String getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
public void setParameter(String parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
}
|
107
app/src/main/java/com/yutou/jianrmg_v2/Data/SystemData.java
Normal file
@ -0,0 +1,107 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Tools.RootUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SystemData {
|
||||
private int osVersionCode;
|
||||
private String osName;
|
||||
private String appVersion;
|
||||
private boolean isRoot;
|
||||
private boolean isInstallClient;
|
||||
private String cpuType;
|
||||
private String phoneDisplay;
|
||||
private String imei;
|
||||
|
||||
public SystemData() {
|
||||
if (Utils.getApplicationPackName(Application.application, AppData.magicPackageName)
|
||||
|| new File(Utils.getSDCardPath() + "Android/data/com.huanmeng.zhanjian2/files/MagicBox/").exists()) {
|
||||
isInstallClient = true;
|
||||
} else {
|
||||
isInstallClient = false;
|
||||
}
|
||||
osVersionCode = Build.VERSION.SDK_INT;
|
||||
osName = Build.VERSION.RELEASE;
|
||||
try {
|
||||
appVersion = Application.application.getPackageManager().getPackageInfo(Application.application.getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
appVersion = AppData.version;
|
||||
}
|
||||
RootUtils.init(AppData.activity);
|
||||
isRoot = RootUtils.su();
|
||||
cpuType = Build.CPU_ABI;
|
||||
phoneDisplay = Build.BRAND;
|
||||
|
||||
TelephonyManager telephonyManager = (TelephonyManager) Application.application.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (telephonyManager != null && ActivityCompat.checkSelfPermission(Application.application, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
|
||||
imei = telephonyManager.getDeviceId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getOsVersionCode() {
|
||||
return osVersionCode;
|
||||
}
|
||||
|
||||
public String getOsName() {
|
||||
return osName;
|
||||
}
|
||||
|
||||
public String getAppVersion() {
|
||||
return appVersion;
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return isRoot;
|
||||
}
|
||||
|
||||
public boolean isInstallClient() {
|
||||
return isInstallClient;
|
||||
}
|
||||
|
||||
public String getCpuType() {
|
||||
return cpuType;
|
||||
}
|
||||
|
||||
public String getPhoneDisplay() {
|
||||
return phoneDisplay;
|
||||
}
|
||||
|
||||
public String getImei() {
|
||||
return imei;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"osVersionCode\":")
|
||||
.append(osVersionCode);
|
||||
sb.append(",\"osName\":\"")
|
||||
.append(osName).append('\"');
|
||||
sb.append(",\"appVersion\":\"")
|
||||
.append(appVersion).append('\"');
|
||||
sb.append(",\"isRoot\":")
|
||||
.append(isRoot);
|
||||
sb.append(",\"isInstallClient\":")
|
||||
.append(isInstallClient);
|
||||
sb.append(",\"cpuType\":\"")
|
||||
.append(cpuType).append('\"');
|
||||
sb.append(",\"phoneDisplay\":\"")
|
||||
.append(phoneDisplay).append('\"');
|
||||
sb.append(",\"imei\":\"")
|
||||
.append(imei).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -163,4 +163,14 @@ public class TModfile {
|
||||
public void setUpdatetime(Long updatetime) {
|
||||
this.updatetime = updatetime;
|
||||
}
|
||||
|
||||
private TMod mod;
|
||||
|
||||
public TMod getMod() {
|
||||
return mod;
|
||||
}
|
||||
|
||||
public void setMod(TMod mod) {
|
||||
this.mod = mod;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
public class TModfilePath {
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column t_modfile_path.id
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column t_modfile_path.name
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column t_modfile_path.path
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column t_modfile_path.id
|
||||
* @return the value of t_modfile_path.id
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column t_modfile_path.id
|
||||
* @param id the value for t_modfile_path.id
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column t_modfile_path.name
|
||||
* @return the value of t_modfile_path.name
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column t_modfile_path.name
|
||||
* @param name the value for t_modfile_path.name
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column t_modfile_path.path
|
||||
* @return the value of t_modfile_path.path
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column t_modfile_path.path
|
||||
* @param path the value for t_modfile_path.path
|
||||
* @mbg.generated Fri Jan 25 11:07:59 CST 2019
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
62
app/src/main/java/com/yutou/jianrmg_v2/Data/TModtype.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TModtype {
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column t_modtype.id
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column t_modtype.name
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column t_modtype.id
|
||||
* @return the value of t_modtype.id
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column t_modtype.id
|
||||
* @param id the value for t_modtype.id
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column t_modtype.name
|
||||
* @return the value of t_modtype.name
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column t_modtype.name
|
||||
* @param name the value for t_modtype.name
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static List<String> toStringList(List<TModtype> array){
|
||||
List<String> list=new ArrayList<>();
|
||||
for (TModtype tModtype : array) {
|
||||
list.add(tModtype.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
152
app/src/main/java/com/yutou/jianrmg_v2/Data/TeamData.java
Normal file
@ -0,0 +1,152 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class TeamData {
|
||||
private int id;
|
||||
private String title;
|
||||
private String hp;
|
||||
private String hpMax;
|
||||
private String imageUrl;
|
||||
private String item1Url;
|
||||
private String item2Url;
|
||||
private String item3Url;
|
||||
private String item4Url;
|
||||
private boolean user;
|
||||
private JSONObject src;
|
||||
private long createTime;
|
||||
|
||||
public TeamData() {
|
||||
createTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public void setHp(String hp) {
|
||||
this.hp = hp;
|
||||
}
|
||||
|
||||
public String getHpMax() {
|
||||
return hpMax;
|
||||
}
|
||||
|
||||
public void setHpMax(String hpMax) {
|
||||
this.hpMax = hpMax;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getItem1Url() {
|
||||
return item1Url;
|
||||
}
|
||||
|
||||
public void setItem1Url(String item1Url) {
|
||||
this.item1Url = item1Url;
|
||||
}
|
||||
|
||||
public String getItem2Url() {
|
||||
return item2Url;
|
||||
}
|
||||
|
||||
public void setItem2Url(String item2Url) {
|
||||
this.item2Url = item2Url;
|
||||
}
|
||||
|
||||
public String getItem3Url() {
|
||||
return item3Url;
|
||||
}
|
||||
|
||||
public void setItem3Url(String item3Url) {
|
||||
this.item3Url = item3Url;
|
||||
}
|
||||
|
||||
public String getItem4Url() {
|
||||
return item4Url;
|
||||
}
|
||||
|
||||
public void setItem4Url(String item4Url) {
|
||||
this.item4Url = item4Url;
|
||||
}
|
||||
|
||||
public boolean isUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(boolean user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public JSONObject getSrc() {
|
||||
try {
|
||||
if (src != null)
|
||||
src.put("createTime", createTime);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
public void setSrc(JSONObject src) {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"id\":")
|
||||
.append(id);
|
||||
sb.append(",\"title\":\"")
|
||||
.append(title).append('\"');
|
||||
sb.append(",\"hp\":\"")
|
||||
.append(hp).append('\"');
|
||||
sb.append(",\"hpMax\":\"")
|
||||
.append(hpMax).append('\"');
|
||||
sb.append(",\"imageUrl\":\"")
|
||||
.append(imageUrl).append('\"');
|
||||
sb.append(",\"item1Url\":\"")
|
||||
.append(item1Url).append('\"');
|
||||
sb.append(",\"item2Url\":\"")
|
||||
.append(item2Url).append('\"');
|
||||
sb.append(",\"item3Url\":\"")
|
||||
.append(item3Url).append('\"');
|
||||
sb.append(",\"item4Url\":\"")
|
||||
.append(item4Url).append('\"');
|
||||
sb.append(",\"user\":")
|
||||
.append(user);
|
||||
sb.append(",\"src\":")
|
||||
.append(src);
|
||||
sb.append(",\"createTime\":")
|
||||
.append(createTime);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
public class User {
|
||||
|
||||
private String uname;
|
||||
private String token;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column user.id
|
||||
* @mbg.generated Sun Jan 21 18:14:28 CST 2018
|
||||
@ -117,4 +118,32 @@ public class User {
|
||||
public void setPower(Integer power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getUname() {
|
||||
return uname;
|
||||
}
|
||||
|
||||
public void setUname(String uname) {
|
||||
this.uname = uname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"token='" + token + '\'' +
|
||||
", id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", pass='" + pass + '\'' +
|
||||
", imei='" + imei + '\'' +
|
||||
", power=" + power +
|
||||
'}';
|
||||
}
|
||||
}
|
108
app/src/main/java/com/yutou/jianrmg_v2/Data/ZsShipType.java
Normal file
@ -0,0 +1,108 @@
|
||||
package com.yutou.jianrmg_v2.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ZsShipType {
|
||||
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column zs_ship_type.id
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column zs_ship_type.name
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column zs_ship_type.shortname
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
private String shortname;
|
||||
/**
|
||||
* This field was generated by MyBatis Generator. This field corresponds to the database column zs_ship_type.mark
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column zs_ship_type.id
|
||||
* @return the value of zs_ship_type.id
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column zs_ship_type.id
|
||||
* @param id the value for zs_ship_type.id
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column zs_ship_type.name
|
||||
* @return the value of zs_ship_type.name
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column zs_ship_type.name
|
||||
* @param name the value for zs_ship_type.name
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column zs_ship_type.shortname
|
||||
* @return the value of zs_ship_type.shortname
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public String getShortname() {
|
||||
return shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column zs_ship_type.shortname
|
||||
* @param shortname the value for zs_ship_type.shortname
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public void setShortname(String shortname) {
|
||||
this.shortname = shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method returns the value of the database column zs_ship_type.mark
|
||||
* @return the value of zs_ship_type.mark
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public String getMark() {
|
||||
return mark;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator. This method sets the value of the database column zs_ship_type.mark
|
||||
* @param mark the value for zs_ship_type.mark
|
||||
* @mbg.generated Sun May 06 16:48:05 CST 2018
|
||||
*/
|
||||
public void setMark(String mark) {
|
||||
this.mark = mark;
|
||||
}
|
||||
|
||||
public static List<String> toStringList(List<ZsShipType> array){
|
||||
List<String> list=new ArrayList<>();
|
||||
for (ZsShipType zsShipType : array) {
|
||||
list.add(zsShipType.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,367 @@
|
||||
package com.yutou.jianrmg_v2.Databases;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JianRDataDataBase extends SQLiteOpenHelper {
|
||||
private static JianRDataDataBase database;
|
||||
private SQLiteDatabase writeDatabase, readDatabase;
|
||||
private final static String TAB_DATA_TYPE = "t_data_type";
|
||||
private final static String TAB_DATA_NAME = "t_data_name";
|
||||
private final static String TAB_DATA_GAME = "t_data_GAME";
|
||||
private final static String TAB_DATA_DROP = "t_data_DROP";
|
||||
|
||||
public static JianRDataDataBase init() {
|
||||
if (database == null) {
|
||||
database = new JianRDataDataBase();
|
||||
database.readDatabase = database.getReadableDatabase();
|
||||
database.writeDatabase = database.getWritableDatabase();
|
||||
}
|
||||
return database;
|
||||
}
|
||||
|
||||
private JianRDataDataBase() {
|
||||
super(Application.application, "game_data_db", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||
/*
|
||||
* ---------------------------------------------------
|
||||
* | 标题 | 类型 | 说明 |
|
||||
* ---------------------------------------------------
|
||||
* | _id | int | id自增 |
|
||||
* ---------------------------------------------------
|
||||
* | typeName | varchar(255) | 分类名字 |
|
||||
* ---------------------------------------------------
|
||||
*/
|
||||
String sql = "create table " + TAB_DATA_TYPE + " (_id integer primary key,typeName varchar(255))";
|
||||
/*
|
||||
* ---------------------------------------------------
|
||||
* | 标题 | 类型 | 说明 |
|
||||
* ---------------------------------------------------
|
||||
* | _id | int | id自增 |
|
||||
* ---------------------------------------------------
|
||||
* | typeId | int | 分类id |
|
||||
* ---------------------------------------------------
|
||||
* | title | varchar(255) | 数据库名 |
|
||||
* ---------------------------------------------------
|
||||
*/
|
||||
String sql_2 = "create table " + TAB_DATA_NAME + " (_id integer primary key,typeId integer,title varchar(255))";
|
||||
/*
|
||||
* ---------------------------------------------------
|
||||
* | 标题 | 类型 | 说明 |
|
||||
* ---------------------------------------------------
|
||||
* | _id | int | id自增 |
|
||||
* ---------------------------------------------------
|
||||
* | nameId | int | 数据id |
|
||||
* ---------------------------------------------------
|
||||
* | mapId | varchar(255) | 地图编号 |
|
||||
* ---------------------------------------------------
|
||||
* | nodeType | varchar(255) | 节点类型 |
|
||||
* ---------------------------------------------------
|
||||
* | litter | varchar(20) | 凋落物cid |
|
||||
* ---------------------------------------------------
|
||||
* | src | text | 原始数据 |
|
||||
* ---------------------------------------------------
|
||||
* | m,a | varchar(50) | 用于关联战斗信息 |
|
||||
* ---------------------------------------------------
|
||||
* | createTime | varchar(255) | 创建时间 |
|
||||
* ---------------------------------------------------
|
||||
* | md5 | varchar(255) | md5校验唯一性 |
|
||||
* ---------------------------------------------------
|
||||
*/
|
||||
String sql_3 = "create table " + TAB_DATA_GAME + " (_id integer primary key,nameId integer,mapId varchar(255),nodeType varchar(20),litter varchar(255),src text,m varchar(50),a vharchar(50),createTime varchar(255),md5 varchar(255))";
|
||||
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------
|
||||
* | 标题 | 类型 | 说明 |
|
||||
* ---------------------------------------------------
|
||||
* | _id | int | id自增 |
|
||||
* ---------------------------------------------------
|
||||
* | dataId | int | 数据id |
|
||||
* ---------------------------------------------------
|
||||
* | cid | varchar(255) | 舰娘CID |
|
||||
* ---------------------------------------------------
|
||||
* | title | varchar(255) | 舰娘名字 |
|
||||
* ---------------------------------------------------
|
||||
* | md5 | varchar(255) | 防止重复 |
|
||||
* ---------------------------------------------------
|
||||
*/
|
||||
String sql_4="create table " + TAB_DATA_DROP + " (_id integer primary key,dataId integer,cid varchar(255), title varchar(255),md5 varchar(255))";
|
||||
sqLiteDatabase.execSQL(sql);
|
||||
sqLiteDatabase.execSQL(sql_2);
|
||||
sqLiteDatabase.execSQL(sql_3);
|
||||
sqLiteDatabase.execSQL(sql_4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
||||
|
||||
}
|
||||
public void addDrop(JSONObject json){
|
||||
if(!queryGameDrop(Utils.getMD5(json.toString()+"Drop"))){
|
||||
try{
|
||||
JSONArray newShipVO=new JSONObject(json.getString("message")).getJSONArray("newShipVO");
|
||||
if(newShipVO!=null&&newShipVO.length()>0){
|
||||
String cid=newShipVO.getJSONObject(0).get("shipCid").toString();
|
||||
String title=newShipVO.getJSONObject(0).getString("title");
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("dataId",json.getInt("dataId"));
|
||||
values.put("cid",cid);
|
||||
values.put("title",title);
|
||||
values.put("md5",Utils.getMD5(json.toString()+"Drop"));
|
||||
readDatabase.insert(TAB_DATA_DROP,null,values);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<JSONObject> getDrops(){
|
||||
List<JSONObject> list=new ArrayList<>();
|
||||
try{
|
||||
Cursor cursor=readDatabase.query(TAB_DATA_DROP,new String[]{"*"},null,null,null,null,null);
|
||||
while (cursor.moveToNext()){
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("dataId",cursor.getInt(cursor.getColumnIndex("dataId")));
|
||||
json.put("cid",cursor.getString(cursor.getColumnIndex("cid")));
|
||||
json.put("title",cursor.getString(cursor.getColumnIndex("title")));
|
||||
json.put("id",cursor.getInt(cursor.getColumnIndex("_id")));
|
||||
list.add(json);
|
||||
}
|
||||
cursor.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public List<JSONObject> getDrops(String name){
|
||||
List<JSONObject> list=new ArrayList<>();
|
||||
int nameId=getNameId(name);
|
||||
if(nameId<=0){
|
||||
return list;
|
||||
}
|
||||
|
||||
try{
|
||||
List<JSONObject> data=getDrops();
|
||||
for (JSONObject datum : data) {
|
||||
int dataId=datum.getInt("dataId");
|
||||
JSONObject tmp=getData(dataId).get("data");
|
||||
int dId=tmp.getInt("id");
|
||||
if(datum.getInt("dataId")==dId&&nameId==tmp.getInt("nameId")){
|
||||
datum.put("data",tmp);
|
||||
list.add(datum);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
private boolean queryDataType(String title) {
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_TYPE, new String[]{"*"}, "typeName=?", new String[]{title}, null, null, null);
|
||||
int count = cursor.getCount();
|
||||
cursor.close();
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
private boolean queryDataName(String title) {
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_NAME, new String[]{"*"}, "title=?", new String[]{title}, null, null, null);
|
||||
int count = cursor.getCount();
|
||||
cursor.close();
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
public void addType(String title) {
|
||||
if (!queryDataType(title)) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("typeName", title);
|
||||
writeDatabase.insert(TAB_DATA_TYPE, null, values);
|
||||
}
|
||||
}
|
||||
|
||||
public void addName(String title, String context) {
|
||||
if (queryDataType(title) && getTypeId(title) != -1) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("title", context);
|
||||
values.put("typeId", getTypeId(title));
|
||||
writeDatabase.insert(TAB_DATA_NAME, null, values);
|
||||
}
|
||||
}
|
||||
|
||||
public long addData(String title, JSONObject data) {
|
||||
if (queryDataName(title) && !queryGameData(Utils.getMD5(data.toString()))) {
|
||||
try {
|
||||
JSONObject ext=new JSONObject(data.getString("ext"));
|
||||
JSONObject message=new JSONObject(data.getString("message"));
|
||||
String type=data.getString("type");
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("nameId", getNameId(title));
|
||||
values.put("mapId", ext.getString("n"));
|
||||
values.put("nodeType", type);
|
||||
String cid="";
|
||||
try{
|
||||
cid=message.getJSONArray("newShipVO").getJSONObject(0).getString("shipCid");
|
||||
}catch (Exception ignored){
|
||||
|
||||
}
|
||||
values.put("litter",cid);
|
||||
values.put("m",ext.getString("m"));
|
||||
values.put("a",ext.getString("a"));
|
||||
values.put("src", data.toString());
|
||||
values.put("createTime", System.currentTimeMillis() + "");
|
||||
values.put("md5", Utils.getMD5(data.toString()));
|
||||
return writeDatabase.insert(TAB_DATA_GAME, null, values);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public List<Map<String,JSONObject>> getData(){
|
||||
List<Map<String,JSONObject>> list=new ArrayList<>();
|
||||
try{
|
||||
Cursor cursor=readDatabase.query(TAB_DATA_GAME,new String[]{"*"},"nodeType=?",new String[]{"DealNode"},null,null,"_id desc");
|
||||
while (cursor.moveToNext()){
|
||||
Map<String,JSONObject> map=new HashMap<>();
|
||||
String m=cursor.getString(cursor.getColumnIndex("m"));
|
||||
String a=cursor.getString(cursor.getColumnIndex("a"));
|
||||
String n=cursor.getString(cursor.getColumnIndex("mapId"));
|
||||
map.put("DealNode",new JSONObject(cursor.getString(cursor.getColumnIndex("src"))));
|
||||
map.put("GetWarResult",getWarResult(m,n,a));
|
||||
list.add(map);
|
||||
}
|
||||
cursor.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public Map<String,JSONObject> getData(int id){
|
||||
Map<String,JSONObject> map=new HashMap<>();
|
||||
try{
|
||||
Cursor cursor=readDatabase.query(TAB_DATA_GAME,new String[]{"*"},"_id=?",new String[]{id+""},null,null,null);
|
||||
if(cursor.moveToNext()){
|
||||
String m=cursor.getString(cursor.getColumnIndex("m"));
|
||||
String a=cursor.getString(cursor.getColumnIndex("a"));
|
||||
String n=cursor.getString(cursor.getColumnIndex("mapId"));
|
||||
map.put("DealNode",new JSONObject(cursor.getString(cursor.getColumnIndex("src"))));
|
||||
map.put("GetWarResult",getWarResult(m,n,a));
|
||||
JSONObject data=new JSONObject();
|
||||
data.put("id",cursor.getInt(cursor.getColumnIndex("_id")));
|
||||
data.put("nameId",cursor.getInt(cursor.getColumnIndex("nameId")));
|
||||
data.put("mapId",cursor.getString(cursor.getColumnIndex("mapId")));
|
||||
data.put("nodeType",cursor.getString(cursor.getColumnIndex("nodeType")));
|
||||
data.put("litter",cursor.getString(cursor.getColumnIndex("litter")));
|
||||
data.put("createTime",cursor.getString(cursor.getColumnIndex("createTime")));
|
||||
data.put("md5",cursor.getString(cursor.getColumnIndex("md5")));
|
||||
map.put("data",data);
|
||||
}
|
||||
cursor.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
private JSONObject getWarResult(String m,String n,String a){
|
||||
JSONObject json=null;
|
||||
try{
|
||||
Cursor cursor=readDatabase.query(TAB_DATA_GAME,new String[]{"*"},"mapId=? and m=? and a=?",new String[]{n,m,a},null,null,null);
|
||||
if(cursor.moveToNext()){
|
||||
json=new JSONObject(cursor.getString(cursor.getColumnIndex("src")));
|
||||
}
|
||||
cursor.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return json;
|
||||
}
|
||||
private boolean queryGameData(String md5) {
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_GAME, new String[]{"*"}, "md5=?", new String[]{md5}, null, null, null);
|
||||
int count = cursor.getCount();
|
||||
cursor.close();
|
||||
return count > 0;
|
||||
}
|
||||
private boolean queryGameDrop(String md5) {
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_DROP, new String[]{"*"}, "md5=?", new String[]{md5}, null, null, null);
|
||||
int count = cursor.getCount();
|
||||
cursor.close();
|
||||
return count > 0;
|
||||
}
|
||||
public List<String> getTypes() {
|
||||
List<String> list = new ArrayList<>();
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_TYPE, new String[]{"*"}, null, null, null, null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
list.add(cursor.getString(cursor.getColumnIndex("typeName")));
|
||||
}
|
||||
cursor.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> getNames(String name) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (name == null) {
|
||||
return list;
|
||||
}
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_NAME, new String[]{"*"}, "typeId=?", new String[]{getTypeId(name) + ""}, null, null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
list.add(cursor.getString(cursor.getColumnIndex("title")));
|
||||
}
|
||||
cursor.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
private int getNameId(String title) {
|
||||
int list = -1;
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_NAME, new String[]{"*"}, "title=?", new String[]{title}, null, null, null);
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToNext();
|
||||
list = cursor.getInt(cursor.getColumnIndex("_id"));
|
||||
}
|
||||
cursor.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
private int getTypeId(String title) {
|
||||
int list = -1;
|
||||
Cursor cursor = readDatabase.query(TAB_DATA_TYPE, new String[]{"*"}, "typeName=?", new String[]{title}, null, null, null);
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToNext();
|
||||
list = cursor.getInt(cursor.getColumnIndex("_id"));
|
||||
}
|
||||
cursor.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
private void removeData(String name) {
|
||||
writeDatabase.delete(TAB_DATA_GAME, "nameId=?", new String[]{getNameId(name) + ""});
|
||||
}
|
||||
|
||||
public void removeName(String name) {
|
||||
removeData(name);
|
||||
writeDatabase.delete(TAB_DATA_NAME, "title", new String[]{name});
|
||||
}
|
||||
|
||||
public void removeType(String name) {
|
||||
removeName(name);
|
||||
writeDatabase.delete(TAB_DATA_TYPE, "typeName", new String[]{name});
|
||||
}
|
||||
public void clearTable(String tabName){
|
||||
writeDatabase.execSQL("delete from "+tabName);
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.yutou.jianrmg_v2.Databases;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModDatabase extends SQLiteOpenHelper {
|
||||
private static ModDatabase database;
|
||||
private SQLiteDatabase writeDatabase, readDatabase;
|
||||
private static String TAB_MOD_INSTALL = "t_mod_install";
|
||||
private static String TAB_MOD_LIST="t_mod_list";
|
||||
public static ModDatabase init(){
|
||||
if(database==null){
|
||||
database=new ModDatabase();
|
||||
database.writeDatabase=database.getWritableDatabase();
|
||||
database.readDatabase=database.getReadableDatabase();
|
||||
}
|
||||
return database;
|
||||
}
|
||||
private ModDatabase() {
|
||||
super(Application.application, "mg_mod_db", null, 1);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
String sql = "create table " + TAB_MOD_INSTALL + " (_id integer primary key,id integer,modName verchar(50),isInstall integer,installClient verchar(255),clientName verchar(255),isRoot integer,modVersion integer)";
|
||||
String t_2="create table "+TAB_MOD_LIST+" (_id integer primary key,id integer, modName verchar(50),info verchar(255),icon verchar(255),modVersion integer)";
|
||||
|
||||
db.execSQL(sql);
|
||||
db.execSQL(t_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addInstallMod(TMod mod, MGamePackname packname){
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("id",mod.getId());
|
||||
values.put("modName",mod.getTitle());
|
||||
values.put("isInstall",1);
|
||||
values.put("installClient",packname.getPackname());
|
||||
values.put("modVersion",mod.getModversion());
|
||||
values.put("clientName",packname.getZhname());
|
||||
values.put("isRoot",packname.isRoot()?1:0);
|
||||
if(isInstallMod(mod,packname.getPackname(),false)){
|
||||
writeDatabase.update(TAB_MOD_INSTALL,values,"id=? and installClient=?",new String[]{mod.getId()+"",packname.getPackname()});
|
||||
}else {
|
||||
writeDatabase.insert(TAB_MOD_INSTALL, null, values);
|
||||
}
|
||||
}
|
||||
public boolean isInstallMod(TMod mod){
|
||||
return isInstallMod(mod,null,true);
|
||||
}
|
||||
private boolean isInstallMod(TMod mod,String packName, boolean isInstall){
|
||||
Cursor cursor;
|
||||
String sql;
|
||||
String[] tmp;
|
||||
if(packName==null) {
|
||||
sql = "id=? and modVersion=? and isInstall=?";
|
||||
tmp=new String[]{mod.getId()+"",mod.getModversion()+"","1"};
|
||||
}else{
|
||||
sql="id=? and modVersion=? and installClient=? and isInstall=?";
|
||||
tmp=new String[]{mod.getId()+"",packName,mod.getModversion()+"","1"};
|
||||
}
|
||||
if(isInstall){
|
||||
cursor=readDatabase.query(TAB_MOD_INSTALL,new String[]{"*"},sql,tmp,null,null,null);
|
||||
}else{
|
||||
cursor=readDatabase.query(TAB_MOD_INSTALL,new String[]{"*"},"id=? and modVersion=? and installClient=?",new String[]{mod.getId()+"",mod.getModversion()+"",packName},null,null,null);
|
||||
}
|
||||
|
||||
boolean flag=cursor.getCount() != 0;
|
||||
cursor.close();
|
||||
return flag;
|
||||
}
|
||||
public void backInstaMod(TMod mod,String packName){
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("isInstall",0);
|
||||
writeDatabase.update(TAB_MOD_INSTALL,values,"id=? and modVersion=? and installClient=?",new String[]{mod.getId()+"",mod.getModversion()+"",packName});
|
||||
}
|
||||
public List<MGamePackname> getInstallClients(TMod mod){
|
||||
List<MGamePackname> installClients = new ArrayList<>();
|
||||
try {
|
||||
Cursor cursor = readDatabase.query(TAB_MOD_INSTALL, new String[]{"*"}, "id=? and modVersion=?", new String[]{mod.getId() + "", mod.getModversion() + ""}, null, null, null);
|
||||
cursor.moveToFirst();
|
||||
do {
|
||||
MGamePackname packname = new MGamePackname();
|
||||
packname.setPackname(cursor.getString(cursor.getColumnIndex("installClient")));
|
||||
packname.setZhname(cursor.getString(cursor.getColumnIndex("clientName")));
|
||||
packname.setRoot(cursor.getInt(cursor.getColumnIndex("isRoot")) == 1);
|
||||
installClients.add(packname);
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return installClients;
|
||||
}
|
||||
public void downloadMod(TMod mod){
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("id",mod.getId());
|
||||
values.put("modName",mod.getTitle());
|
||||
values.put("info",mod.getInfo());
|
||||
values.put("modVersion",mod.getModversion());
|
||||
values.put("icon",mod.getIcon());
|
||||
if(!isDownloadMod(mod)){
|
||||
writeDatabase.insert(TAB_MOD_LIST,null,values);
|
||||
}else{
|
||||
deleteMod(mod);
|
||||
downloadMod(mod);
|
||||
}
|
||||
}
|
||||
public void deleteMod(TMod mod){
|
||||
writeDatabase.delete(TAB_MOD_LIST,"id=?",new String[]{mod.getId()+""});
|
||||
}
|
||||
public boolean isDownloadMod(TMod mod){
|
||||
Cursor cursor=readDatabase.query(TAB_MOD_LIST,new String[]{"*"},"id=?",new String[]{mod.getId()+""},null,null,null);
|
||||
boolean flag=cursor.getCount()>0;
|
||||
cursor.close();
|
||||
return flag;
|
||||
}
|
||||
public List<TMod> getDownloadModIds(){
|
||||
List<TMod> list=new ArrayList<>();
|
||||
Cursor cursor=readDatabase.query(TAB_MOD_LIST,new String[]{"*"},null,null,null,null,null);
|
||||
if(cursor!=null){
|
||||
while (cursor.moveToNext()) {
|
||||
TMod mod=new TMod();
|
||||
mod.setId(cursor.getInt(cursor.getColumnIndex("id")));
|
||||
mod.setTitle(cursor.getString(cursor.getColumnIndex("modName")));
|
||||
mod.setInfo(cursor.getString(cursor.getColumnIndex("info")));
|
||||
mod.setModversion(cursor.getInt(cursor.getColumnIndex("modVersion")));
|
||||
mod.setIcon(cursor.getString(cursor.getColumnIndex("icon")));
|
||||
list.add(mod);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
System.out.println(list.size());
|
||||
return list;
|
||||
}
|
||||
public int getModVersion(TMod mod){
|
||||
Cursor cursor=readDatabase.query(TAB_MOD_LIST,new String[]{"*"},"id=?",new String[]{mod.getId()+""},null,null,null);
|
||||
int version=-1;
|
||||
try {
|
||||
cursor.moveToFirst();
|
||||
version=cursor.getInt(cursor.getColumnIndex("modVersion"));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
cursor.close();
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.yutou.jianrmg_v2.Databases;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
|
||||
public class PlugDatabase extends SQLiteOpenHelper {
|
||||
private static PlugDatabase database;
|
||||
private SQLiteDatabase writeDatabase,readDatabase;
|
||||
private static String TAB_PLUGS="s_plugs";
|
||||
public static PlugDatabase init(){
|
||||
if(database==null){
|
||||
database=new PlugDatabase();
|
||||
database.writeDatabase=database.getWritableDatabase();
|
||||
database.readDatabase=database.getReadableDatabase();
|
||||
}
|
||||
return database;
|
||||
}
|
||||
private PlugDatabase() {
|
||||
super(Application.application, "plug_db", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
String sql="create table "+TAB_PLUGS+" (_id integer primary key,id integer,pname verchar(50), fileName verchar(150),md5 verchar(255), version integer)";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
public void addPlug(){
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.yutou.jianrmg_v2.Databases;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.User;
|
||||
|
||||
public class UserDatabase extends SQLiteOpenHelper {
|
||||
private static UserDatabase database;
|
||||
private SQLiteDatabase writeDatabase,readDatabase;
|
||||
private static String TAB_USER="u_user";
|
||||
public static UserDatabase init(){
|
||||
if(database==null){
|
||||
database=new UserDatabase();
|
||||
database.writeDatabase=database.getWritableDatabase();
|
||||
database.readDatabase=database.getReadableDatabase();
|
||||
}
|
||||
return database;
|
||||
}
|
||||
|
||||
private UserDatabase() {
|
||||
super(Application.application,"userData_db",null,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
String sql="create table "+TAB_USER+"(_id integer primary key,id integer,uname verchar(50),token verchar(50))";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
public void login(int id,String uname,String token){
|
||||
deleteTable(TAB_USER);
|
||||
Cursor cursor=readDatabase.query(TAB_USER,new String[]{"id","uname"},"id=? and uname=?",new String[]{id+"",uname},null,null,null);
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("id",id);
|
||||
values.put("uname",uname);
|
||||
values.put("token",token);
|
||||
cursor.moveToFirst();
|
||||
if(cursor.getCount() > 0){
|
||||
writeDatabase.update(TAB_USER,values,"_id=?",new String[]{1+""});
|
||||
}else{
|
||||
writeDatabase.insert(TAB_USER,null,values);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
public User getUser(){
|
||||
Cursor cursor=readDatabase.query(TAB_USER,new String[]{"id,uname,token"},"_id=?",new String[]{"1"},null,null,null);
|
||||
User user=null;
|
||||
cursor.moveToFirst();
|
||||
if(cursor.getCount() > 0){
|
||||
user=new User();
|
||||
user.setId(cursor.getInt(cursor.getColumnIndex("id")));
|
||||
user.setName(cursor.getString(cursor.getColumnIndex("uname")));
|
||||
user.setImei("-----");
|
||||
user.setPass("-----");
|
||||
user.setToken(cursor.getString(cursor.getColumnIndex("token")));
|
||||
user.setPower(0);
|
||||
}
|
||||
cursor.close();
|
||||
return user;
|
||||
}
|
||||
private void deleteTable(String tableName){
|
||||
writeDatabase.execSQL("delete from "+tableName);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -14,17 +15,29 @@ import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
import com.yutou.jianrmg_v2.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianrmg_v2.Fragments.GameDataFragments.DropFragment;
|
||||
import com.yutou.jianrmg_v2.Fragments.GameDataFragments.WarFragment;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Interfaces.BaseFragmeneInerface;
|
||||
import me.majiajie.pagerbottomtabstrip.NavigationController;
|
||||
import me.majiajie.pagerbottomtabstrip.PageNavigationView;
|
||||
import me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener;
|
||||
|
||||
|
||||
public class GameData extends Fragment {
|
||||
private Context context;
|
||||
private static GameData gameData;
|
||||
|
||||
private PageNavigationView tab;
|
||||
private ViewPager viewPager;
|
||||
private NavigationController navigationController;
|
||||
private List<Fragment> list;
|
||||
|
||||
public static GameData init(){
|
||||
if(gameData==null){
|
||||
gameData=new GameData();
|
||||
@ -37,17 +50,37 @@ public class GameData extends Fragment {
|
||||
if(view!=null)
|
||||
return view;
|
||||
view=inflater.inflate(R.layout.fragment_game_data,null);
|
||||
PieChart pieChart=view.findViewById(R.id.pieChart);
|
||||
List<PieEntry> entries = new ArrayList<>();
|
||||
entries.add(new PieEntry(120000, "弹"));
|
||||
entries.add(new PieEntry(230000, "钢"));
|
||||
entries.add(new PieEntry(50000, "铝"));
|
||||
entries.add(new PieEntry(80000, "油"));
|
||||
tab = view.findViewById(R.id.tab);
|
||||
viewPager = view.findViewById(R.id.pager);
|
||||
|
||||
PieDataSet set = new PieDataSet(entries, "当前资源");
|
||||
PieData data = new PieData(set);
|
||||
pieChart.setData(data);
|
||||
pieChart.invalidate();
|
||||
|
||||
list=new ArrayList<>();
|
||||
list.add(DropFragment.init());
|
||||
list.add(WarFragment.init());
|
||||
|
||||
ViewPagerAdapter adapter=new ViewPagerAdapter(getChildFragmentManager(),list);
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setCurrentItem(0);
|
||||
|
||||
navigationController = tab.material()
|
||||
.addItem(R.drawable.icon_drop, R.drawable.icon_drop_select, "掉落日志")
|
||||
.addItem(R.drawable.icon_war,R.drawable.icon_war_select,"战斗日志")
|
||||
.build();
|
||||
navigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() {
|
||||
@Override
|
||||
public void onSelected(int index, int old) {
|
||||
switch (index) {
|
||||
}
|
||||
viewPager.setCurrentItem(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat(int index) {
|
||||
|
||||
}
|
||||
});
|
||||
navigationController.setupWithViewPager(viewPager);
|
||||
navigationController.setSelect(0);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,160 @@
|
||||
package com.yutou.jianrmg_v2.Fragments.GameDataFragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.yutou.jianrmg_v2.Adapters.GameDataAdapters.DropAdapter;
|
||||
import com.yutou.jianrmg_v2.Databases.JianRDataDataBase;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.JianRUtils;
|
||||
|
||||
import org.angmarch.views.NiceSpinner;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
|
||||
import cn.lemon.view.RefreshRecyclerView;
|
||||
import cn.lemon.view.adapter.Action;
|
||||
|
||||
public class DropFragment extends Fragment {
|
||||
private static DropFragment fragment;
|
||||
private View view;
|
||||
private NiceSpinner src, type;
|
||||
private JianRDataDataBase database;
|
||||
private RefreshRecyclerView recyclerView;
|
||||
private DropAdapter adapter;
|
||||
|
||||
public static DropFragment init() {
|
||||
if (fragment == null) {
|
||||
fragment = new DropFragment();
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public DropFragment() {
|
||||
database = JianRDataDataBase.init();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
view = inflater.inflate(R.layout.fragment_drop, null);
|
||||
initView();
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
src = view.findViewById(R.id.src);
|
||||
type = view.findViewById(R.id.type);
|
||||
recyclerView = view.findViewById(R.id.recyclerView);
|
||||
recyclerView.setSwipeRefreshColors(0xFF437845, 0xFFE44F98, 0xFF2FAC21);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new DropAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
recyclerView.addRefreshAction(() -> {
|
||||
try {
|
||||
src.setSelectedIndex(0);
|
||||
type.setSelectedIndex(0);
|
||||
getData(0);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
new Handler().postAtTime(() -> {
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
recyclerView.showNoMore();
|
||||
}, 0, 100);
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> srcTypes;
|
||||
|
||||
private void initData() {
|
||||
try {
|
||||
srcTypes = database.getTypes();
|
||||
if(srcTypes.size()==0){
|
||||
srcTypes.add("无参数");
|
||||
|
||||
}
|
||||
src.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, srcTypes));
|
||||
src.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
type.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, database.getNames(srcTypes.get(i))));
|
||||
getData(type.getSelectedIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
});
|
||||
src.setSelectedIndex(0);
|
||||
List<String> types=database.getNames(srcTypes.get(0));
|
||||
if(types.size()==0){
|
||||
types.add("无参数");
|
||||
}
|
||||
type.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item,types));
|
||||
type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
getData(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
});
|
||||
getData(0);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void getData(int i) {
|
||||
try {
|
||||
String name = database.getNames(srcTypes.get(src.getSelectedIndex())).get(i);
|
||||
List<JSONObject> list = database.getDrops(name);
|
||||
List<Map<String, String>> ldata = new ArrayList<>();
|
||||
for (JSONObject json : list) {
|
||||
Map<String, String> map = new ArrayMap<>();
|
||||
String cid = json.get("cid").toString();
|
||||
String title = json.getString("title");
|
||||
map.put("icon", "http://jianr.jianrmod.cn/jianr/ship/S_NORMAL_" + JianRUtils.jianCidToid(cid) + ".png");
|
||||
map.put("name", title);
|
||||
map.put("time", new SimpleDateFormat("yyyy年MM月dd hh:mm:ss")
|
||||
.format(new Date(Long.valueOf(json.getJSONObject("data").getString("createTime")))));
|
||||
ldata.add(map);
|
||||
}
|
||||
Collections.reverse(ldata);
|
||||
adapter.clear();
|
||||
adapter.addAll(ldata);
|
||||
adapter.notifyDataSetChanged();
|
||||
recyclerView.showNoMore();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.yutou.jianrmg_v2.Fragments.GameDataFragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yutou.jianrmg_v2.Adapters.GameDataAdapters.DropAdapter;
|
||||
import com.yutou.jianrmg_v2.Adapters.GameDataAdapters.WarAdapter;
|
||||
import com.yutou.jianrmg_v2.Databases.JianRDataDataBase;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.angmarch.views.NiceSpinner;
|
||||
|
||||
import cn.lemon.view.RefreshRecyclerView;
|
||||
|
||||
public class WarFragment extends Fragment {
|
||||
private static WarFragment fragment;
|
||||
private View view;
|
||||
private NiceSpinner src, type;
|
||||
private JianRDataDataBase database;
|
||||
private RefreshRecyclerView recyclerView;
|
||||
private WarAdapter adapter;
|
||||
|
||||
public static WarFragment init(){
|
||||
if(fragment==null){
|
||||
fragment=new WarFragment();
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if(view!=null){
|
||||
return view;
|
||||
}
|
||||
view=inflater.inflate(R.layout.fragment_drop,null);
|
||||
initView();
|
||||
|
||||
return view;
|
||||
}
|
||||
public void initView() {
|
||||
src = view.findViewById(R.id.src);
|
||||
type = view.findViewById(R.id.type);
|
||||
recyclerView = view.findViewById(R.id.recyclerView);
|
||||
recyclerView.setSwipeRefreshColors(0xFF437845, 0xFFE44F98, 0xFF2FAC21);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new WarAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
recyclerView.addRefreshAction(() -> {
|
||||
try {
|
||||
src.setSelectedIndex(0);
|
||||
type.setSelectedIndex(0);
|
||||
new Handler().postAtTime(() -> {
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
recyclerView.showNoMore();
|
||||
Utils.toast(getContext(),"还在摸,咕了");
|
||||
}, 0, 100);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,45 +1,35 @@
|
||||
package com.yutou.jianrmg_v2.Fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bigkoo.convenientbanner.ConvenientBanner;
|
||||
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
|
||||
import com.bigkoo.convenientbanner.holder.Holder;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.Adapters.HomeRecyclerAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.MAppHome;
|
||||
import com.yutou.jianrmg_v2.Data.MBanner;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Model.HomeCard;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.HomeHeader;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import cn.lemon.view.RefreshRecyclerView;
|
||||
import cn.lemon.view.adapter.Action;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/20.
|
||||
@ -47,16 +37,16 @@ import cn.lemon.view.adapter.Action;
|
||||
|
||||
public class Home extends Fragment {
|
||||
private static Home home;
|
||||
private ConvenientBanner banner;
|
||||
|
||||
private RefreshRecyclerView recyclerView;
|
||||
private HomeRecyclerAdapter adapter;
|
||||
private View view;
|
||||
private List<MAppHome> datas;
|
||||
private List<HomeCard> datas;
|
||||
private int min=0, max=10;
|
||||
private boolean isInit=true;
|
||||
private Handler handler;
|
||||
public Handler handler;
|
||||
private ImageLoader imageLoader;
|
||||
private Context context;
|
||||
private HomeHeader header;
|
||||
|
||||
public static Home init(){
|
||||
if(home==null){
|
||||
@ -75,66 +65,19 @@ public class Home extends Fragment {
|
||||
view= inflater.inflate(R.layout.fragment_home,null);
|
||||
imageLoader= Utils.initImageLoader(getContext());
|
||||
handler=new Handler();
|
||||
initBanner();
|
||||
initView(view);
|
||||
TextView textView=new TextView(getContext());
|
||||
textView.setText("a");
|
||||
return view;
|
||||
}
|
||||
private void initBanner(){
|
||||
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.BANNER, new HttpInterface() {
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
final List<MBanner> array;
|
||||
try {
|
||||
Log.i("banner",string);
|
||||
JSONObject json=new JSONObject(string);
|
||||
|
||||
if(json.getInt("code")==100){
|
||||
array= JSON.parseArray(json.getString("data"),MBanner.class);
|
||||
}else{
|
||||
array=new ArrayList<>();
|
||||
}
|
||||
Log.i(""+(handler==null));
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setBanner(array);
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void setBanner( List<MBanner> list){
|
||||
banner.setCanLoop(true);
|
||||
banner.startTurning(2000);
|
||||
banner.setPages(new CBViewHolderCreator(){
|
||||
|
||||
@Override
|
||||
public Object createHolder() {
|
||||
return new Banner();
|
||||
}
|
||||
},list).setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT);
|
||||
}
|
||||
private void initView(View view){
|
||||
Log.i("初始化主页");
|
||||
banner=new ConvenientBanner(getContext());
|
||||
ViewGroup.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,400);
|
||||
banner.setLayoutParams(params);
|
||||
|
||||
recyclerView=view.findViewById(R.id.recyclerView);
|
||||
recyclerView.setSwipeRefreshColors(0xFF437845,0xFFE44F98,0xFF2FAC21);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getContext(),3));
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false));
|
||||
adapter=new HomeRecyclerAdapter(getContext());
|
||||
adapter.setHeader(banner);
|
||||
adapter.setHeader(HomeHeader.getHome(getActivity()).getView());
|
||||
TextView endText=new TextView(getContext());
|
||||
endText.setLayoutParams(new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.getPixelsFromDp(getActivity(),48)));
|
||||
endText.setTextSize(16);
|
||||
@ -142,18 +85,13 @@ public class Home extends Fragment {
|
||||
endText.setText(" --已经没有了--");
|
||||
adapter.setFooter(endText);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addRefreshAction(new Action() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
recyclerView.addRefreshAction(() -> {
|
||||
min=0;
|
||||
max=10;
|
||||
isInit=true;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
recyclerView.setLoadMoreAction(new Action() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
recyclerView.setLoadMoreAction(() -> {
|
||||
if(isInit){
|
||||
recyclerView.showNoMore();
|
||||
}else {
|
||||
@ -161,7 +99,6 @@ public class Home extends Fragment {
|
||||
max += 10;
|
||||
initData();
|
||||
}
|
||||
}
|
||||
});
|
||||
recyclerView.showSwipeRefresh();
|
||||
initData();
|
||||
@ -183,14 +120,9 @@ public class Home extends Fragment {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json.getInt("code")==100){
|
||||
datas= JSON.parseArray(json.getString("data"),MAppHome.class);
|
||||
datas= JSON.parseArray(json.getString("data"),HomeCard.class);
|
||||
}
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setData();
|
||||
}
|
||||
});
|
||||
handler.post(() -> setData());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -199,8 +131,8 @@ public class Home extends Fragment {
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void setData(){
|
||||
if(datas.size()>0){
|
||||
adapter.clear();
|
||||
@ -211,27 +143,5 @@ public class Home extends Fragment {
|
||||
adapter.addAll(datas);
|
||||
}
|
||||
}
|
||||
private class Banner implements Holder<MBanner>{
|
||||
private ImageView imageView;
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
imageView = new ImageView(context);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
return imageView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateUI(Context context, int position,final MBanner data) {
|
||||
imageLoader.displayImage(data.getUrl(),imageView);
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent=new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(data.getClick()));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.lemon.view.RefreshRecyclerView;
|
||||
import cn.lemon.view.adapter.Action;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/23.
|
||||
@ -71,18 +70,13 @@ public class MGList extends Fragment {
|
||||
endText.setText(" --已经没有了--");
|
||||
adapter.setFooter(endText);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addRefreshAction(new Action() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
recyclerView.addRefreshAction(() -> {
|
||||
min=0;
|
||||
max=10;
|
||||
isInit=true;
|
||||
initData();
|
||||
}
|
||||
});
|
||||
recyclerView.setLoadMoreAction(new Action() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
recyclerView.setLoadMoreAction(() -> {
|
||||
if(isInit){
|
||||
recyclerView.showNoMore();
|
||||
}else {
|
||||
@ -90,7 +84,6 @@ public class MGList extends Fragment {
|
||||
max += 10;
|
||||
initData();
|
||||
}
|
||||
}
|
||||
});
|
||||
recyclerView.showSwipeRefresh();
|
||||
initData();
|
||||
@ -116,12 +109,7 @@ public class MGList extends Fragment {
|
||||
if(json.getInt("code")==100){
|
||||
datas= JSON.parseArray(json.getString("data"), MAppMg.class);
|
||||
}
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setData();
|
||||
}
|
||||
});
|
||||
handler.post(() -> setData());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
@ -20,7 +21,9 @@ import com.yutou.jianrmg_v2.Adapters.MyItemGridViewAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.UUserdata;
|
||||
import com.yutou.jianrmg_v2.Data.User;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
|
||||
@ -66,6 +69,10 @@ public class My extends Fragment {
|
||||
// items=view.findViewById(R.id.items);
|
||||
myItems=view.findViewById(R.id._my_items);
|
||||
}
|
||||
icon.setOnClickListener(view->{
|
||||
Utils.toast(getContext(),"个人资料...咕了!诶嘿(<ゝω·)~☆kira");
|
||||
});
|
||||
image_top.setOnClickListener(view->Utils.toast(getContext(),"点这里不会有什么奇怪的东西啦"));
|
||||
imageLoader= Utils.initImageLoader(getContext());
|
||||
initData();
|
||||
return view;
|
||||
@ -73,18 +80,27 @@ public class My extends Fragment {
|
||||
private void initData(){
|
||||
user= AppData.user;
|
||||
udata=AppData.userdata;
|
||||
if(udata==null)
|
||||
udata=new UUserdata();
|
||||
udata.setImage("https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1209476926,1108056910&fm=58");
|
||||
boolean isImage=true;
|
||||
if(udata==null) {
|
||||
udata = new UUserdata();
|
||||
}
|
||||
if(user==null||user.getId()<1){
|
||||
uname.setText("未登录");
|
||||
icon.setImageResource(R.mipmap.ic_launcher);
|
||||
icon.setImageResource(R.mipmap.icon_logo);
|
||||
return;
|
||||
}
|
||||
if(udata.getImage()==null||udata.getImage().equals("#")){
|
||||
icon.setImageResource(R.mipmap.icon_logo);
|
||||
isImage=false;
|
||||
}
|
||||
try {
|
||||
uname.setText(user.getName());
|
||||
imageLoader.displayImage(udata.getImage(),icon);
|
||||
uname.setText(user.getUname());
|
||||
if(isImage) {
|
||||
imageLoader.displayImage(udata.getImage(), icon);
|
||||
Glide.with(getContext()).load(udata.getImage()).apply(bitmapTransform(new BlurTransformation(25))).into(image_top);
|
||||
}else{
|
||||
Glide.with(getContext()).load(R.mipmap.icon_logo).apply(bitmapTransform(new BlurTransformation(25))).into(image_top);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -92,10 +108,10 @@ public class My extends Fragment {
|
||||
}
|
||||
private List<MyItemGridViewAdapter.ItemData> getItemData(){
|
||||
List<MyItemGridViewAdapter.ItemData> list=new ArrayList<>();
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"下载中心"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"收藏夹"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"问题/建议"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"设置"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(R.drawable.ic_download,"下载中心"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(R.drawable.ic_collection,"收藏夹"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(R.drawable.ic_feedback,"问题/建议"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(R.drawable.ic_config,"设置"));
|
||||
/* list.add(new MyItemGridViewAdapter.ItemData(-1,""));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,""));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,""));
|
||||
|
@ -0,0 +1,150 @@
|
||||
package com.yutou.jianrmg_v2.Fragments;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yutou.jianrmg_v2.Adapters.MainUtilsAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MAppTools;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.lemon.view.RefreshRecyclerView;
|
||||
import dalvik.system.DexClassLoader;
|
||||
|
||||
public class UtilsFragments extends Fragment {
|
||||
private static UtilsFragments utilsFragments=null;
|
||||
private View view;
|
||||
private RefreshRecyclerView recyclerView;
|
||||
private int min=0,max=0;
|
||||
private boolean isStart=true;
|
||||
private List<MAppTools> datas;
|
||||
private Handler handler;
|
||||
private MainUtilsAdapter adapter;
|
||||
|
||||
public static UtilsFragments init(){
|
||||
if(utilsFragments==null){
|
||||
utilsFragments=new UtilsFragments();
|
||||
}
|
||||
return utilsFragments;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if(view==null){
|
||||
view=inflater.inflate(R.layout.fragment_mg,null);
|
||||
}
|
||||
initView();
|
||||
return view;
|
||||
}
|
||||
private void initView(){
|
||||
handler=new Handler();
|
||||
adapter=new MainUtilsAdapter(getActivity());
|
||||
recyclerView=view.findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getContext(),3));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addRefreshAction(() -> {
|
||||
min=0;
|
||||
max=0;
|
||||
isStart=true;
|
||||
adapter.clear();
|
||||
initData();
|
||||
});
|
||||
recyclerView.setLoadMoreAction(()->{
|
||||
recyclerView.showNoMore();
|
||||
});
|
||||
initData();
|
||||
recyclerView.showSwipeRefresh();
|
||||
}
|
||||
private void initData(){
|
||||
try{
|
||||
datas=new ArrayList<>();
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("min",min);
|
||||
json.put("max",max);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MG_TOOLS, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
datas= JSON.parseArray(json.getJSONArray("data").toString(),MAppTools.class);
|
||||
setLocalData();
|
||||
handler.post(()->setData());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private Map<String, DexClassLoader> map;
|
||||
private void setLocalData(){
|
||||
try{
|
||||
map=AppData.plugsin;
|
||||
if(map==null||map.isEmpty()){
|
||||
return;
|
||||
}
|
||||
Iterator iterator=map.keySet().iterator();
|
||||
while (iterator.hasNext()){
|
||||
String key= (String) iterator.next();
|
||||
if(map.containsKey(key)){
|
||||
Class plugins=map.get(key).loadClass("com.yutou.jianrmg_v2.plugins.Data");
|
||||
MAppTools tools=new MAppTools();
|
||||
tools.setName((String) plugins.getField("title").get(null));
|
||||
tools.setPluginName((String) plugins.getField("name").get(null));
|
||||
tools.setImage((String) plugins.getField("image").get(null));
|
||||
tools.setMainFunction((String) plugins.getField("mainFunction").get(null));
|
||||
tools.setUrl((String) plugins.getField("url").get(null));
|
||||
tools.setPermission((Integer) plugins.getField("permission").get(null));
|
||||
tools.setIsshow(1);
|
||||
|
||||
List<MAppTools> tmpTools=new ArrayList<>();
|
||||
for (MAppTools data : datas) {
|
||||
if (data.getMainFunction().equals(tools.getMainFunction())) {
|
||||
tmpTools.add(data);
|
||||
}
|
||||
}
|
||||
datas.removeAll(tmpTools);
|
||||
datas.add(tools);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void setData() {
|
||||
System.out.println(datas.size());
|
||||
if(datas.size()>0){
|
||||
adapter.addAll(datas);
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
}else{
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
recyclerView.showNoMore();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +1,84 @@
|
||||
package com.yutou.jianrmg_v2;
|
||||
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.AssetManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.constraint.ConstraintLayout;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.qq.e.ads.splash.SplashAD;
|
||||
import com.qq.e.ads.splash.SplashADListener;
|
||||
import com.qq.e.comm.util.AdError;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.Data.SConfig;
|
||||
import com.yutou.jianrmg_v2.Data.UUserdata;
|
||||
import com.yutou.jianrmg_v2.Data.User;
|
||||
import com.yutou.jianrmg_v2.Databases.UserDatabase;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ActivitysManager;
|
||||
import com.yutou.jianrmg_v2.Tools.AppPermissions;
|
||||
import com.yutou.jianrmg_v2.Tools.ConfigUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import com.yutou.jianrmg_v2.views.RegisterActivity;
|
||||
import com.yutou.jianrmg_v2.views.WebActivity;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/18.
|
||||
*/
|
||||
|
||||
public class LoadingActivity extends AppCompatActivity {
|
||||
private LinearLayout loginLayout;
|
||||
private static final String APPID = "1105364182";
|
||||
private static final String POSID = "4070960054673794";
|
||||
|
||||
private LinearLayout loginLayout,adLayout;
|
||||
private Button login, reg;
|
||||
private TextView notlogin, uname, password;
|
||||
private ImageView icon;
|
||||
private Handler handler;
|
||||
private boolean isLogin=false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
|
||||
WindowManager.LayoutParams. FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_loading);
|
||||
Utils.setImmersion(this);
|
||||
handler = new Handler();
|
||||
initViews();
|
||||
initData();
|
||||
startOpenAd();
|
||||
}
|
||||
|
||||
private void login(String name, String pass) {
|
||||
@ -74,13 +91,18 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(string);
|
||||
final String msg=json.getString("msg");
|
||||
if (json.getInt("code") == 100) {
|
||||
AppData.user = JSON.parseObject(json.getJSONObject("data").toString(), User.class);
|
||||
AppData.Token = json.getString("token");
|
||||
ConfigUtils.init().save(ConfigUtils.token, AppData.Token);
|
||||
ConfigUtils.init().save(ConfigUtils.uid, AppData.user.getId());
|
||||
start();
|
||||
AppData.user.setToken(AppData.Token);
|
||||
UserDatabase.init().login(AppData.user.getId(),AppData.user.getName(),AppData.Token);
|
||||
isLogin=true;
|
||||
handler.post(()-> start());
|
||||
}else{
|
||||
handler.post(() -> Utils.toast(LoadingActivity.this,msg));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -90,6 +112,7 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
e.printStackTrace();
|
||||
Utils.toast(LoadingActivity.this,"登录失败:"+e.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
@ -98,20 +121,8 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
/* if(RootUtils.su()) {
|
||||
RootUtils root = RootUtils.init(this);
|
||||
root.exec("cp /sdcard/jianRMG/1/aaa.txt /data/data/com.huanmeng.zhanjian2/");
|
||||
root.exec("cp /sdcard/jianRMG/1/aaa.txt /data/data/com.huanmeng.zhanjian2/files/");
|
||||
root.exec("mkdir /data/data/com.huanmeng.zhanjian2/files/bbb/");
|
||||
}else{
|
||||
Log.i("获取ROOT失败");
|
||||
}*/
|
||||
AssetManager manager = getResources().getAssets();
|
||||
try {
|
||||
String[] strs = manager.list("");
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
System.out.println(strs[i]);
|
||||
}
|
||||
String fileName;
|
||||
switch (Build.CPU_ABI) {
|
||||
case "armeabi-v7a":
|
||||
@ -121,20 +132,23 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
}
|
||||
InputStream inputStream = manager.open(fileName);
|
||||
//jar.createNewFile();
|
||||
FileOutputStream outputStream = new FileOutputStream("/data/data/" + this.getPackageName() + "/files/busybox");
|
||||
FileOutputStream outputStream = new FileOutputStream(getFilesDir()+"/busybox");
|
||||
int len = 0;
|
||||
byte[] bytes = new byte[inputStream.available()];
|
||||
while ((len = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, len);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Utils.toast(this, Build.CPU_ABI);
|
||||
// Utils.toast(this, Build.CPU_ABI);
|
||||
initGamePackName();
|
||||
initConfig();
|
||||
initUser();
|
||||
|
||||
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.O){
|
||||
ready(1);
|
||||
}else
|
||||
ActivityCompat.requestPermissions(this,AppPermissions.permissions,AppPermissions.REQUEST_CODE);
|
||||
}
|
||||
|
||||
private void initConfig() {
|
||||
@ -156,6 +170,7 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
e.printStackTrace();
|
||||
Utils.toast(LoadingActivity.this,"初始化失败:"+e.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
@ -192,7 +207,6 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("token", AppData.Token);
|
||||
json.put("uid", AppData.user.getId());
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.USER_TEST, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
@ -201,10 +215,14 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
if (json.getInt("code") == 100) {
|
||||
JSONObject data = json.getJSONObject("data").getJSONObject("data");
|
||||
AppData.user = JSON.parseObject(data.getJSONObject("user").toString(), User.class);
|
||||
AppData.userdata=JSON.parseObject(data.getJSONObject("userdata").toString(), UUserdata.class);
|
||||
ConfigUtils.init().save(ConfigUtils.collection, data.getJSONArray("collection"));
|
||||
isLogin=true;
|
||||
}else{
|
||||
isLogin=false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
ready(1);
|
||||
}
|
||||
@ -227,16 +245,23 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
icon = findViewById(R.id.icon);
|
||||
uname = findViewById(R.id.uname);
|
||||
password = findViewById(R.id.password);
|
||||
adLayout = findViewById(R.id.adLayout);
|
||||
reg=findViewById(R.id.reg);
|
||||
|
||||
notlogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
start();
|
||||
|
||||
Intent regIntent=getIntent();
|
||||
if(regIntent!=null){
|
||||
String name=regIntent.getStringExtra("name");
|
||||
String pass=regIntent.getStringExtra("password");
|
||||
if(!Utils.testStringIsNull(name,pass)){
|
||||
uname.setText(name);
|
||||
password.setText(pass);
|
||||
login.callOnClick();
|
||||
}
|
||||
});
|
||||
login.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
}
|
||||
|
||||
notlogin.setOnClickListener(view -> start());
|
||||
login.setOnClickListener(view -> {
|
||||
String name = uname.getText().toString();
|
||||
String pass = password.getText().toString();
|
||||
if (Utils.testStringIsNull(name, pass)) {
|
||||
@ -244,13 +269,68 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
login(name, pass);
|
||||
}
|
||||
});
|
||||
reg.setOnClickListener(view -> {
|
||||
Intent intent=new Intent(LoadingActivity.this, RegisterActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
public void start() {
|
||||
adLayout.removeAllViews();
|
||||
adLayout.setVisibility(View.GONE);
|
||||
ConstraintLayout.LayoutParams params=new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.topMargin=Utils.getPixelsFromDp(this,512);
|
||||
params.startToStart=Utils.getPixelsFromDp(this,8);
|
||||
params.startToEnd=Utils.getPixelsFromDp(this,8);
|
||||
// icon.setLayoutParams(params);
|
||||
if(true){
|
||||
// return;
|
||||
}
|
||||
|
||||
PackageManager manager = getPackageManager();
|
||||
String code = "";
|
||||
try {
|
||||
PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
|
||||
code = info.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(AppData.appConfig!=null&&!AppData.appConfig.getApkVersion().equals(code)){
|
||||
MaterialDialog dialog=new MaterialDialog(this);
|
||||
dialog.setTitle("检测到更新");
|
||||
dialog.setMessage(AppData.appConfig.getMessage());
|
||||
dialog.setNegativeButton("放弃",v -> {
|
||||
dialog.dismiss();
|
||||
if(isLogin) {
|
||||
Intent intent = new Intent(LoadingActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}else{
|
||||
Utils.toast(this,"未登录/登录信息失效");
|
||||
showLogin();
|
||||
}
|
||||
});
|
||||
dialog.setPositiveButton("升级",v -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(AppData.appConfig.getApkUrl()));
|
||||
startActivity(intent);
|
||||
ActivitysManager.AppExit(this);
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
}else{
|
||||
if(isLogin) {
|
||||
Intent intent = new Intent(LoadingActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}else{
|
||||
Utils.toast(this,"未登录/登录信息失效");
|
||||
showLogin();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showLogin() {
|
||||
@ -288,18 +368,91 @@ public class LoadingActivity extends AppCompatActivity {
|
||||
private synchronized void ready(int i) {
|
||||
readys += i;
|
||||
Log.i(readys + "");
|
||||
if (readys == 3) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Utils.testStringIsNull(AppData.Token)) {
|
||||
if (readys == 4) {
|
||||
handler.postDelayed(() -> {
|
||||
/*if (Utils.testStringIsNull(AppData.Token)) {
|
||||
showLogin();
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
boolean flag=true;
|
||||
if(requestCode==AppPermissions.REQUEST_CODE){
|
||||
for (String permission : AppPermissions.permissions) {
|
||||
if(ActivityCompat.checkSelfPermission(this,permission)!=PackageManager.PERMISSION_GRANTED){
|
||||
System.out.println(permission);
|
||||
flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flag){
|
||||
MaterialDialog dialog=new MaterialDialog(this);
|
||||
dialog.setTitle(">__<");
|
||||
dialog.setMessage("缺少起床的必要权限哦!");
|
||||
dialog.setNegativeButton("不给", view -> {
|
||||
Utils.toast(LoadingActivity.this,"哼,小气");
|
||||
handler.postDelayed(()-> {ActivitysManager.AppExit(LoadingActivity.this);dialog.dismiss();},300);
|
||||
});
|
||||
dialog.setPositiveButton("拿去吧",view->{
|
||||
ActivityCompat.requestPermissions(LoadingActivity.this,AppPermissions.permissions,AppPermissions.REQUEST_CODE);
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}else{
|
||||
ready(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void startOpenAd(){
|
||||
new SplashAD(this, adLayout, APPID, POSID, new SplashADListener() {
|
||||
@Override
|
||||
public void onADDismissed() {
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoAD(AdError adError) {
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADPresent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADClicked() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADTick(long l) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADExposure() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
package com.yutou.jianrmg_v2;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Fragments.GameData;
|
||||
import com.yutou.jianrmg_v2.Fragments.Home;
|
||||
import com.yutou.jianrmg_v2.Fragments.MGList;
|
||||
import com.yutou.jianrmg_v2.Fragments.My;
|
||||
import com.yutou.jianrmg_v2.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Fragments.UtilsFragments;
|
||||
import com.yutou.jianrmg_v2.Tools.ActivitysManager;
|
||||
import com.yutou.jianrmg_v2.LoadingActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -31,8 +35,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
AppData.activity=this;
|
||||
AppData.handler=new Handler();
|
||||
ActivitysManager.finishActivity(LoadingActivity.class);
|
||||
initViews();
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
@ -40,6 +47,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
viewPager = findViewById(R.id.pager);
|
||||
list=new ArrayList<>();
|
||||
list.add(Home.init());
|
||||
list.add(UtilsFragments.init());
|
||||
list.add(GameData.init());
|
||||
list.add(MGList.init());
|
||||
list.add(My.init());
|
||||
@ -49,6 +57,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
viewPager.setCurrentItem(0);
|
||||
navigationController = tab.material()
|
||||
.addItem(R.drawable.icon_home, R.drawable.icon_home_select, "主页")
|
||||
.addItem(R.drawable.icon_tools,R.drawable.icon_tools_select,"工具")
|
||||
.addItem(R.drawable.icon_data, R.drawable.icon_data_select, "数据")
|
||||
.addItem(R.drawable.icon_mg, R.drawable.icon_mg_select, "魔改")
|
||||
.addItem(R.drawable.icon_my, R.drawable.icon_my_select, "个人中心")
|
||||
@ -68,6 +77,31 @@ public class MainActivity extends AppCompatActivity {
|
||||
});
|
||||
navigationController.setupWithViewPager(viewPager);
|
||||
navigationController.setSelect(0);
|
||||
}
|
||||
long oldTime=0;
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if(keyCode==KeyEvent.KEYCODE_BACK){
|
||||
if(System.currentTimeMillis()-oldTime<1000){
|
||||
ActivitysManager.AppExit(this);
|
||||
}else{
|
||||
Toast.makeText(this,"再按一次退出程序",Toast.LENGTH_LONG).show();
|
||||
oldTime=System.currentTimeMillis();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
||||
|
66
app/src/main/java/com/yutou/jianrmg_v2/Model/HomeCard.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.yutou.jianrmg_v2.Model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeCard {
|
||||
private String imageUrl;
|
||||
private String text;
|
||||
private String click;
|
||||
private int type=0;
|
||||
public HomeCard(){
|
||||
}
|
||||
public static List<HomeCard> testCard(){
|
||||
List<HomeCard> list=new ArrayList<>();
|
||||
|
||||
HomeCard card_1=new HomeCard();
|
||||
HomeCard card_2=new HomeCard();
|
||||
HomeCard card_3=new HomeCard();
|
||||
|
||||
card_1.setImageUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1535525627&di=b94e73818984f09b8798568b60756a21&imgtype=jpg&er=1&src=http%3A%2F%2Fpic.90sjimg.com%2Fback_pic%2Fu%2F00%2F02%2F82%2F06%2F561c95213aaa4.jpg");
|
||||
card_2.setImageUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534930909822&di=84e2ca01ea55aa50fbc82ee8b1e821d6&imgtype=0&src=http%3A%2F%2Fpic.90sjimg.com%2Fback_pic%2Fqk%2Fback_origin_pic%2F00%2F02%2F07%2F2dedc747d6ad3a06885b129630ef6850.jpg");
|
||||
card_3.setImageUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534930909819&di=57e7349b86054380b04257eb13d30005&imgtype=0&src=http%3A%2F%2Fpic.90sjimg.com%2Fback_pic%2F00%2F00%2F69%2F40%2F517f2945e9d3085411c263a88b236281.jpg");
|
||||
|
||||
card_1.setClick("http://www.baidu.com/");
|
||||
card_2.setClick("http://www.qq.com");
|
||||
card_3.setClick("2");
|
||||
card_3.setType(1);
|
||||
|
||||
list.add(card_1);
|
||||
list.add(card_2);
|
||||
list.add(card_3);
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getClick() {
|
||||
return click;
|
||||
}
|
||||
|
||||
public void setClick(String click) {
|
||||
this.click = click;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -5,29 +5,45 @@ package com.yutou.jianrmg_v2.Network;
|
||||
*/
|
||||
|
||||
public class HttpApi {
|
||||
// public static final String HOME_URL="http://192.168.31.240:8088/android/"; //zzz_gz wifi
|
||||
public static final String HOME_URL="http://192.168.137.1:8088/android/"; //笔记本本身WIFI
|
||||
// public static final String HOME_URL="http://game.yutou233.cn/android/"; //服务器
|
||||
public static final String HOME="http://jianr.jianrmod.cn/";
|
||||
//public static final String HOME = "http://192.168.31.241:8088/"; //zzz_gz wifi
|
||||
//public static final String HOME = "http://192.168.137.1:8088/"; //笔记本本身WIFI
|
||||
public static final String HOME_URL=HOME+"android/"; //服务器
|
||||
|
||||
public static final String MOD_ALL="mod/all.do";
|
||||
public static final String MOD_MODS="mod/getMods.do";
|
||||
public static final String MOD_TYPE="mod/getType.do";
|
||||
public static final String MOD_REMOD="mod/remod.do";
|
||||
public static final String MOD_USER_LIST="mod/user.do";
|
||||
public static final String MOD_TAG="mod/tags.do";
|
||||
public static final String MOD_DOWNLOAD="mod/download.do";
|
||||
public static final String MOD_GAME_PACKNAME="mod/packnames.do";
|
||||
public static final String MOD_COLLCETION="mod/collection.do";
|
||||
public static final String MOD_ALL = "mod/all.do";
|
||||
public static final String MOD_MODS = "mod/getMods.do";
|
||||
public static final String MOD_TYPE = "mod/getType.do";
|
||||
public static final String MOD_REMOD = "mod/remod.do";
|
||||
public static final String MOD_USER_LIST = "mod/user.do";
|
||||
public static final String MOD_TAG = "mod/tags.do";
|
||||
public static final String MOD_DOWNLOAD = "mod/download.do";
|
||||
public static final String MOD_GAME_PACKNAME = "mod/packnames.do";
|
||||
public static final String MOD_COLLCETION = "mod/collection.do";
|
||||
public static final String MOD_LIST_COLLCET = "mod/getCollect.do";
|
||||
public static final String MOD_REMOE_COLLCET = "mod/removeCollect.do";
|
||||
public static final String MOD_MOVE = "mod/move.do";
|
||||
public static final String MOD_GET_TYPEINFO = "mod/typeInfo.do";
|
||||
|
||||
public static final String BANNER="banner/get.do";
|
||||
public static final String BANNER = "banner/get.do";
|
||||
|
||||
public static final String MG_HOME_LIST="config/home.do";
|
||||
public static final String MG_MG_LIST="config/mg.do";
|
||||
public static final String MG_CONFIG="config/update.do";
|
||||
public static final String MG_HOME_LIST = "config/home.do";
|
||||
public static final String MG_MG_LIST = "config/mg.do";
|
||||
public static final String MG_CONFIG = "config/update.do";
|
||||
public static final String MG_TOOLS = "config/utils.do";
|
||||
public static final String MG_GAME_ACTIVITY = "config/gameActivity.do";
|
||||
|
||||
public static final String USER_LOGIN="user/login.do";
|
||||
public static final String USER_REG="user/reg.do";
|
||||
public static final String USER_RELOAD="user/reload.do";
|
||||
public static final String USER_LOGOUT="user/logout.do";
|
||||
public static final String USER_TEST="user/test.do";
|
||||
public static final String USER_LOGIN = "user/login.do";
|
||||
public static final String USER_REG = "user/reg.do";
|
||||
public static final String USER_RELOAD = "user/reload.do";
|
||||
public static final String USER_LOGOUT = "user/logout.do";
|
||||
public static final String USER_TEST = "user/test.do";
|
||||
|
||||
public static final String SYSTEM_UP_INFO = "system/addFeedBack.do";
|
||||
public static final String SYSTEM_LICENSE = "system/license.do";
|
||||
public static final String SYSTEM_PLUGINS = "system/plugins.do";
|
||||
|
||||
public static final String INSTALL_PATH = "config/installPath.do";
|
||||
|
||||
|
||||
public static final String HITOKOTO_API = "https://v1.hitokoto.cn/";
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ public class HttpUtils {
|
||||
if(client==null){
|
||||
client=getClient();
|
||||
}
|
||||
Log.i("GET",url);
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@ -55,7 +54,7 @@ public class HttpUtils {
|
||||
String http=response.body().string();
|
||||
if(httpInterface!=null)
|
||||
httpInterface.httpGetData(http, response.code());
|
||||
Log.i(url,"接收:"+http);
|
||||
Log.i(url,"传参:"+url.replace(HttpApi.HOME_URL,"")+" 接收:"+http);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -67,7 +66,6 @@ public class HttpUtils {
|
||||
if(client==null){
|
||||
client=getClient();
|
||||
}
|
||||
Log.i("POST",url);
|
||||
Request request = new Request.Builder().url(url).post(mapToBody(json)).removeHeader("User-Agent").build();
|
||||
Call call = client.newCall(request);
|
||||
try {
|
||||
@ -108,13 +106,13 @@ public class HttpUtils {
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
downloadFileInerface.over(false);
|
||||
AppData.handler.post(()->downloadFileInerface.over(false));
|
||||
}
|
||||
|
||||
boolean isflag=true;
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
public void onResponse(Call call, Response response) {
|
||||
InputStream is = null;
|
||||
byte[] buf = new byte[2048];
|
||||
byte[] buf = new byte[1024];
|
||||
int len = 0;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
@ -123,22 +121,34 @@ public class HttpUtils {
|
||||
File file = new File(srcPath, getNameFromUrl(url));
|
||||
fos = new FileOutputStream(file);
|
||||
long sum = 0;
|
||||
int pr=-1;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
sum += len;
|
||||
int progress = (int) (sum * 1.0f / total * 100);
|
||||
// 下载中
|
||||
/* while (!downloadFileInerface.downloading(getNameFromUrl(url),progress,total)){
|
||||
if(progress==pr){
|
||||
isflag=false;
|
||||
}else{
|
||||
isflag=true;
|
||||
pr=progress;
|
||||
}
|
||||
if(progress==100){
|
||||
isflag=true;
|
||||
pr=progress;
|
||||
}
|
||||
if(isflag)
|
||||
while (!downloadFileInerface.downloading(getNameFromUrl(url),progress,total)){
|
||||
Thread.sleep(10);
|
||||
}*/
|
||||
|
||||
}
|
||||
System.out.println("下载:"+progress);
|
||||
}
|
||||
fos.flush();
|
||||
// 下载完成
|
||||
downloadFileInerface.over(true);
|
||||
AppData.handler.post(()->downloadFileInerface.over(true));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
downloadFileInerface.over(false);
|
||||
AppData.handler.post(()->downloadFileInerface.over(false));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -176,7 +186,10 @@ public class HttpUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(json.isNull("token"))
|
||||
builder.add("token", AppData.Token);
|
||||
if(json.isNull("uid"))
|
||||
builder.add("uid",AppData.user.getId()+"");
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
public class AppPermissions {
|
||||
public static final int REQUEST_CODE = 2333;
|
||||
public static String[] permissions=new String[]{
|
||||
Manifest.permission.READ_PHONE_STATE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
};
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -20,7 +22,7 @@ public class ConfigUtils {
|
||||
public static final String user="user";
|
||||
|
||||
private static ConfigUtils config;
|
||||
private static final String configPath="/data/data/com.yutou.jianrmg_v2/files/";
|
||||
private static final String configPath=Application.application.getFilesDir().getAbsolutePath();
|
||||
private JSONObject json;
|
||||
public static ConfigUtils init(){
|
||||
if(config==null){
|
||||
@ -33,7 +35,7 @@ public class ConfigUtils {
|
||||
json=read();
|
||||
}
|
||||
private JSONObject read(){
|
||||
File file=new File(configPath+"appConfig.json");
|
||||
File file=new File(configPath+"/appConfig.json");
|
||||
if(file.exists()){
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(file)));
|
||||
@ -70,7 +72,7 @@ public class ConfigUtils {
|
||||
}
|
||||
public boolean save(String key, Object value){
|
||||
try {
|
||||
File file=new File(configPath+"appConfig.json");
|
||||
File file=new File(configPath+"/appConfig.json");
|
||||
if(!file.exists()){
|
||||
file.createNewFile();
|
||||
}
|
||||
|
41
app/src/main/java/com/yutou/jianrmg_v2/Tools/ExcelUtils.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tencent.smtt.sdk.TbsReaderView;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ExcelUtils {
|
||||
private TbsReaderView tbs;
|
||||
private Context context;
|
||||
|
||||
public ExcelUtils(Context context) {
|
||||
this.context = context;
|
||||
tbs = new TbsReaderView(context, null);
|
||||
}
|
||||
|
||||
public TbsReaderView getReader() {
|
||||
return tbs;
|
||||
}
|
||||
|
||||
public void start(File file) {
|
||||
if(tbs==null){
|
||||
Log.e("TBS服务已关闭");
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("filePath", file.getAbsolutePath());
|
||||
bundle.putString("tempPath", Utils.getAppPath()+ "/" + "TbsReaderTemp");
|
||||
boolean flag= tbs.preOpen("xlsx", false);
|
||||
System.out.println("打开文件:"+flag);
|
||||
tbs.openFile(bundle);
|
||||
}
|
||||
public void close(){
|
||||
tbs.onStop();
|
||||
}
|
||||
public void stop() {
|
||||
tbs.onStop();
|
||||
tbs=null;
|
||||
}
|
||||
}
|
62
app/src/main/java/com/yutou/jianrmg_v2/Tools/JianRUtils.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class JianRUtils {
|
||||
private static JSONArray shipCardId;
|
||||
public static int jianCidToid(String cid){
|
||||
if(cid.substring(1,2).equals("1")){
|
||||
int con=Integer.valueOf(cid.substring(2,cid.length()-2));
|
||||
return 1000+con;
|
||||
}else{
|
||||
return Integer.valueOf(cid.substring(2,cid.length()-2));
|
||||
}
|
||||
}
|
||||
public static int equipCidToid(String cid){
|
||||
return Integer.valueOf(cid.substring(2))/100;
|
||||
}
|
||||
public static int EnemyShipCardId(String cid){
|
||||
try {
|
||||
for (int i = 0; i < shipCardId.length(); i++) {
|
||||
JSONObject json=shipCardId.getJSONObject(i);
|
||||
if(json.getString("cid").equals(cid)){
|
||||
return json.getInt("picId");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static void initShipCardId(){
|
||||
try{
|
||||
File file=new File(Application.application.getFilesDir()+"/shipCardid");
|
||||
InputStream inputStream;
|
||||
if(!file.exists()){
|
||||
inputStream=Application.application.getAssets().open("shipCardId");
|
||||
}else{
|
||||
inputStream=new FileInputStream(file);
|
||||
}
|
||||
BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder str= new StringBuilder();
|
||||
String tmp;
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
str.append(tmp);
|
||||
}
|
||||
reader.close();
|
||||
inputStream.close();
|
||||
shipCardId=new JSONArray(str.toString());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,12 +6,8 @@ import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@ -20,23 +16,23 @@ import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Data.TModfile;
|
||||
import com.yutou.jianrmg_v2.Databases.ModDatabase;
|
||||
import com.yutou.jianrmg_v2.Interfaces.DownloadInterface;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Interfaces.ModInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.services.DownloadService;
|
||||
import com.yutou.jianrmg_v2.services.MagicBoxService;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import Interfaces.MagicBoxInterface;
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
|
||||
@ -45,12 +41,13 @@ import me.drakeet.materialdialog.MaterialDialog;
|
||||
*/
|
||||
|
||||
public class ModUtils {
|
||||
public static final int MOD_INSTALL = 1;
|
||||
private static final int MOD_INSTALL = 1;
|
||||
public static final int MOD_BACKUP = 2;
|
||||
public static final int MOD_UNINSTALL = 3;
|
||||
private static final int MOD_UNINSTALL = 3;
|
||||
|
||||
private static final String TAG = "ModUtils";
|
||||
private static ModUtils modUtils;
|
||||
private ModDatabase database;
|
||||
private Context context;
|
||||
private Handler handler;
|
||||
private List<TModfile> modfiles;
|
||||
@ -60,6 +57,7 @@ public class ModUtils {
|
||||
public static ModUtils init(Context context) {
|
||||
if (modUtils == null) {
|
||||
modUtils = new ModUtils();
|
||||
modUtils.database = ModDatabase.init();
|
||||
}
|
||||
modUtils.setContext(context);
|
||||
return modUtils;
|
||||
@ -83,18 +81,19 @@ public class ModUtils {
|
||||
return modfiles;
|
||||
}
|
||||
|
||||
private void setModfiles(List<TModfile> modfiles) {
|
||||
this.modfiles = modfiles;
|
||||
}
|
||||
|
||||
public void installMod(TMod mod, ModInterface modInterface) {
|
||||
this.mod = mod;
|
||||
if(modfiles!=null&&modfiles.size()>0&&!mod.getId().equals(modfiles.get(0).getMid())){
|
||||
if (modfiles != null && modfiles.size() > 0 && !mod.getId().equals(modfiles.get(0).getMid())) {
|
||||
modfiles.clear();
|
||||
getModDownloadInfo();
|
||||
}
|
||||
if (modInterface == null) {
|
||||
modInterface = new ModInterface() {
|
||||
@Override
|
||||
public void onAction(boolean flag, int type) {
|
||||
modInterface = (flag, type) -> {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
install(modInterface);
|
||||
@ -102,40 +101,53 @@ public class ModUtils {
|
||||
|
||||
private void install(ModInterface modInterface) {
|
||||
if (modfiles == null) {
|
||||
Toast.makeText(context, "正在加载数据,请稍后再试", Toast.LENGTH_LONG).show();
|
||||
KProgressHUD hud = Utils.showLoading(context, "加载中", "请稍后");
|
||||
hud.show();
|
||||
getModDownloadInfo();
|
||||
handler.postDelayed(() -> {
|
||||
hud.dismiss();
|
||||
install(modInterface);
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
if(database.getModVersion(mod)<mod.getModversion()){
|
||||
downloadMod();
|
||||
return;
|
||||
}
|
||||
Log.i("安装mod", isInstallMod(mod) + " " + changeMod(mod, modfiles));
|
||||
if (changeMod(mod, modfiles) && !isInstallMod(mod)) {
|
||||
install(mod, modInterface);
|
||||
} else if (isInstallMod(mod)) {
|
||||
MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("安装?还原?");
|
||||
dialog.setMessage("检测到已经安装了本mod,是继续安装到其他客户端还是还原呢?");
|
||||
dialog.setNegativeButton("还原", view -> {
|
||||
reBackMod(mod, modInterface);
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.setPositiveButton("安装", view -> {
|
||||
install(mod, modInterface);
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
} else {
|
||||
if (getModPath(mod).listFiles().length > 0 && !changeMod(mod, modfiles)) {
|
||||
boolean flag_a=getModPath(mod,"",true).listFiles().length > 0;
|
||||
boolean flag_b=!changeMod(mod, modfiles);
|
||||
if (flag_a && flag_b) {
|
||||
final MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("mod已损失");
|
||||
dialog.setMessage("当前mod文件有缺失,是否重新下载?");
|
||||
dialog.setPositiveButton("确定", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.setPositiveButton("确定", view -> {
|
||||
downloadMod();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.setNegativeButton("算了", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.setNegativeButton("算了", view -> dialog.dismiss());
|
||||
dialog.show();
|
||||
} else {
|
||||
downloadMod();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MGamePackname packname;
|
||||
private void install(final TMod mod, final ModInterface modInterface) {
|
||||
List<String> clientList = new ArrayList<>();
|
||||
for (MGamePackname packname : AppData.packnames) {
|
||||
@ -144,34 +156,25 @@ public class ModUtils {
|
||||
final MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("选择安装客户端");
|
||||
ListView listView = new ListView(context);
|
||||
listView.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, clientList));
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
MGamePackname packname = AppData.packnames.get(i);
|
||||
listView.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, clientList));
|
||||
listView.setOnItemClickListener((adapterView, view, i, l) -> {
|
||||
packname = AppData.packnames.get(i);
|
||||
hud.show();
|
||||
boolean isRoot = false;
|
||||
ModUtils.this.i=0;
|
||||
srcs.clear();
|
||||
paths.clear();
|
||||
for (TModfile modfile : modfiles) {
|
||||
File file = getModPath(mod, modfile.getFilename());
|
||||
File file = getModPath(mod, modfile.getFilename(), false);
|
||||
if (packname.getZhname().contains("[ROOT]")) {
|
||||
if (!RootUtils.su()) {
|
||||
hud.dismiss();
|
||||
final MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("错误");
|
||||
dialog.setMessage("未获取到ROOT权限\n提示:魔改专用端可免ROOT使用魔改,以及更多功能");
|
||||
dialog.setPositiveButton("确定", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.setNegativeButton("下载魔改专用客户端", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
final MaterialDialog dialog1 = new MaterialDialog(context);
|
||||
dialog1.setTitle("错误");
|
||||
dialog1.setMessage("未获取到ROOT权限\n提示:魔改专用端可免ROOT使用魔改,以及更多功能\t提示2:如果您确实有ROOT权限,请前往安全中心手动赋予盒子权限");
|
||||
dialog1.setPositiveButton("确定", view1 -> dialog1.dismiss());
|
||||
dialog1.setNegativeButton("下载魔改专用客户端", view12 -> dialog1.dismiss());
|
||||
dialog1.show();
|
||||
modInterface.onAction(false, MOD_INSTALL);
|
||||
return;
|
||||
}
|
||||
@ -180,49 +183,104 @@ public class ModUtils {
|
||||
rootInstall(file, "/data/data/" + packname.getPackname() + modfile.getInstallpathid());
|
||||
} else {
|
||||
isRoot = false;
|
||||
Log.i(TAG, "免ROOT安装");
|
||||
notRootInstall(file, Utils.getSDCardPath() + "Android/data/" + packname.getPackname() + modfile.getInstallpathid());
|
||||
notRootInstall(file, modfile.getInstallpathid());
|
||||
}
|
||||
}
|
||||
try {
|
||||
new File(getModInstallPath(mod) + packname.getPackname() + ".lock").createNewFile();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("root", isRoot);
|
||||
json.put("packname", packname.getPackname());
|
||||
json.put("zhname", packname.getZhname());
|
||||
Utils.writerFile(getModInstallPath(mod) + packname.getPackname() + ".lock", json.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if(srcs.size()>0) {
|
||||
boolean finalIsRoot = isRoot;
|
||||
File file=new File(Utils.getAppPath()+"/"+modfiles.get(0).getMid()+"/backup/"+packname.getPackname());
|
||||
if(!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
notRootInstallStart(new ModInterface() {
|
||||
@Override
|
||||
public void onAction(boolean flag, int type) {
|
||||
hud.dismiss();
|
||||
dialog.dismiss();
|
||||
Utils.toast(context, "安装成功,重启游戏生效");
|
||||
modInterface.onAction(true, MOD_INSTALL);
|
||||
packname.setRoot(finalIsRoot);
|
||||
database.addInstallMod(mod, packname);
|
||||
}
|
||||
},file.listFiles().length==0);
|
||||
}else {
|
||||
hud.dismiss();
|
||||
dialog.dismiss();
|
||||
Utils.toast(context, "安装成功,重启游戏生效");
|
||||
modInterface.onAction(true, MOD_INSTALL);
|
||||
packname.setRoot(isRoot);
|
||||
database.addInstallMod(mod, packname);
|
||||
}
|
||||
});
|
||||
dialog.setContentView(listView);
|
||||
dialog.setPositiveButton("放弃", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
modInterface.onAction(false,MOD_INSTALL);
|
||||
dialog.setPositiveButton("放弃", view -> {
|
||||
modInterface.onAction(false, MOD_INSTALL);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
private boolean notRootInstall(File src, String path) {
|
||||
private List<File> srcs=new ArrayList<>();
|
||||
private List<String> paths=new ArrayList<>();
|
||||
private int i=0;
|
||||
public void notRootInstall(File src, String path) {
|
||||
if (src.exists()) {
|
||||
boolean flag = Utils.copyFile(src.getAbsolutePath(), path, true);
|
||||
return flag;
|
||||
try{
|
||||
srcs.add(src);
|
||||
paths.add(path);
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Utils.copyFile(src.getAbsolutePath(), path, true);
|
||||
} else {
|
||||
Log.i(TAG, "找不到文件:" + src.getAbsolutePath());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void notRootInstallStart(ModInterface modInterface,boolean isBackup){
|
||||
try{
|
||||
if(i==srcs.size()){
|
||||
MagicBoxService.init().clearOrder();
|
||||
modInterface.onAction(true,0);
|
||||
return;
|
||||
}
|
||||
JSONObject order=new JSONObject();
|
||||
order.put("action","copy");
|
||||
if(isBackup) {
|
||||
order.put("args", new String[]{"files:" + paths.get(i).replace("/files/","")+srcs.get(i).getName(),
|
||||
srcs.get(i).getAbsolutePath().replace(srcs.get(i).getName(), "backup/" + packname.getPackname() + "/" + srcs.get(i).getName())});
|
||||
}else{
|
||||
order.put("args",new String[]{srcs.get(i).getAbsolutePath(),"files:" + paths.get(i).replace("/files/","")+srcs.get(i).getName()});
|
||||
}
|
||||
MagicBoxService.init().setOrder(order, data -> { //先备份
|
||||
try {
|
||||
if(!isBackup){//如果不需要备份则按照安装逻辑进行
|
||||
i++;
|
||||
MagicBoxService.init().clearOrder();
|
||||
notRootInstallStart(modInterface,false);
|
||||
return;
|
||||
}
|
||||
order.put("action","copy");
|
||||
order.put("args",new String[]{srcs.get(i).getAbsolutePath(),"files:" + paths.get(i).replace("/files/","")+srcs.get(i).getName()});
|
||||
i++;
|
||||
MagicBoxService.init().setOrder(order, data2 -> {//再安装
|
||||
MagicBoxService.init().clearOrder();
|
||||
notRootInstallStart(modInterface,true);
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
modInterface.onAction(false,0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
modInterface.onAction(false,0);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean rootInstall(File src, String path) {
|
||||
private void rootInstall(File src, String path) {
|
||||
|
||||
RootUtils root = RootUtils.init(context);
|
||||
if (RootUtils.su()) {
|
||||
File tmpFile = new File("/data/data/" + context.getPackageName() + "/mods/");
|
||||
@ -235,57 +293,60 @@ public class ModUtils {
|
||||
root.exec("cp -f " + tmpFile.getAbsolutePath() + "/" + src.getName() + " " + path);
|
||||
root.exec("chmod 777 " + path + src.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reBackMod(TMod tMod, final ModInterface modInterface) {
|
||||
final MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("将还原 " + tMod.getTitle());
|
||||
final List<MGamePackname> clientList = getInstallClens();
|
||||
final List<MGamePackname> clientList = database.getInstallClients(tMod);
|
||||
List<String> titles = new ArrayList<>();
|
||||
for (MGamePackname packname : clientList) {
|
||||
titles.add("[" + (packname.isRoot() ? "ROOT" : "免ROOT") + "]" + packname.getZhname());
|
||||
}
|
||||
ListView listView = new ListView(context);
|
||||
listView.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, titles));
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
if (clientList.get(i).isRoot()) {
|
||||
listView.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, titles));
|
||||
listView.setOnItemClickListener((adapterView, view, i, l) -> {
|
||||
MGamePackname packageName=clientList.get(i);
|
||||
if (packageName.isRoot()) {
|
||||
RootUtils root = RootUtils.init(context);
|
||||
for (TModfile modfile : modfiles) {
|
||||
if (getModPath(mod, "backup/" + clientList.get(i).getPackname() + "/" + modfile.getFilename()).exists()) {
|
||||
root.exec("cp -f " + getModInstallPath(mod) + "backup/" + clientList.get(i).getPackname() + "/" + modfile.getFilename() + " " + "/data/data/" + clientList.get(i).getPackname() + modfile.getInstallpathid());
|
||||
if (getModPath(mod, "backup/" + packageName.getPackname() + "/" + modfile.getFilename(), false).exists()) {
|
||||
root.exec("cp -f " + getModInstallPath(mod) + "backup/" +packageName.getPackname() + "/" + modfile.getFilename() + " " + "/data/data/" + packageName.getPackname() + modfile.getInstallpathid());
|
||||
root.exec("chmod 777 " + "/data/data/" + packageName.getPackname() + modfile.getInstallpathid());
|
||||
} else {
|
||||
root.exec("rm -f " + "/data/data/" + clientList.get(i).getPackname() + modfile.getInstallpathid() + modfile.getFilename());
|
||||
root.exec("rm -f " + "/data/data/" + packageName.getPackname() + modfile.getInstallpathid() + modfile.getFilename());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (TModfile modfile : modfiles) {
|
||||
String filePath = Utils.getSDCardPath() + "Android/data/" + clientList.get(i).getPackname() + modfile.getInstallpathid() + modfile.getFilename();
|
||||
Log.i(TAG, "删除:" + filePath);
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
new File(getModPath(mod).getAbsolutePath() + "/" + clientList.get(i).getPackname() + ".lock").delete();
|
||||
if (modInterface != null)
|
||||
modInterface.onAction(true, MOD_UNINSTALL);
|
||||
dialog.dismiss();
|
||||
Utils.toast(context,"还原成功,重启游戏生效");
|
||||
Utils.toast(context, "还原成功,重启游戏生效");
|
||||
database.backInstaMod(tMod, clientList.get(i).getPackname());
|
||||
} else {
|
||||
ModUtils.this.i=0;
|
||||
srcs.clear();
|
||||
paths.clear();
|
||||
for (TModfile modfile : modfiles) {
|
||||
File file=new File(Utils.getAppPath()+"/"+modfile.getMid()+"/backup/"+packageName.getPackname()+"/"+modfile.getFilename());
|
||||
String path=modfile.getInstallpathid();
|
||||
notRootInstall(file,path);
|
||||
}
|
||||
notRootInstallStart((flag, type) -> {
|
||||
if (modInterface != null)
|
||||
modInterface.onAction(true, MOD_UNINSTALL);
|
||||
dialog.dismiss();
|
||||
Utils.toast(context, "还原成功,重启游戏生效");
|
||||
database.backInstaMod(tMod, clientList.get(i).getPackname());
|
||||
},false);
|
||||
}
|
||||
|
||||
});
|
||||
dialog.setContentView(listView);
|
||||
dialog.setNegativeButton("放弃", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.setNegativeButton("放弃", view -> {
|
||||
if (modInterface != null)
|
||||
modInterface.onAction(false, MOD_UNINSTALL);
|
||||
dialog.dismiss();
|
||||
;
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
@ -294,28 +355,27 @@ public class ModUtils {
|
||||
private void backupOrRoot(File srcFile, String srcPath, String backupClient, TMod mod) {
|
||||
RootUtils root = RootUtils.init(context);
|
||||
if (RootUtils.su()) {
|
||||
File backup = getModPath(mod, "backup/" + backupClient);
|
||||
File backup = getModPath(mod, "backup/" + backupClient, true);
|
||||
File file = new File(backup.getAbsolutePath() + "/" + srcFile.getName());
|
||||
if (file.exists()) {
|
||||
return;
|
||||
}
|
||||
if (!backup.exists()) {
|
||||
Log.i("获取ROOT", "2");
|
||||
backup.mkdirs();
|
||||
}
|
||||
Utils.toast(null, file.getAbsolutePath());
|
||||
File tmpFile = new File("/data/data/" + context.getPackageName() + "/mods/" + srcFile.getName());
|
||||
if (tmpFile.exists())
|
||||
tmpFile.delete();
|
||||
tmpFile.getParentFile().mkdirs();
|
||||
root.exec("mkdir -p " + srcPath);
|
||||
root.exec("chmod 7777 " + srcPath + srcFile.getName());
|
||||
root.exec("cp -f " + srcPath + srcFile.getName() + " " + tmpFile);
|
||||
root.println("cp -f " + tmpFile.getAbsolutePath() + " " + backup.getAbsolutePath());
|
||||
} else {
|
||||
root.exec("chmod 777 " + srcPath + srcFile.getName());
|
||||
root.exec("cp -f " + srcPath + srcFile.getName() + " " + file.getAbsolutePath());
|
||||
root.println("cp -f " + tmpFile.getAbsolutePath() + " " + file.getAbsolutePath());
|
||||
}else{
|
||||
handler.post(() -> Utils.toast(context,"没有ROOT权限,无法进行操作"));
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadMod() {
|
||||
database.downloadMod(mod);
|
||||
Toast.makeText(context, "开始下载", Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(context.getApplicationContext(), DownloadService.class);
|
||||
intent.setPackage(context.getPackageName());
|
||||
@ -379,9 +439,12 @@ public class ModUtils {
|
||||
JSONObject json = new JSONObject(string);
|
||||
if (json.getInt("code") == 100) {
|
||||
modfiles = JSON.parseArray(json.getJSONArray("data").toString(), TModfile.class);
|
||||
for (int i = 0; i < modfiles.size(); i++) {
|
||||
modfiles.get(i).setMod(mod);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,7 +454,7 @@ public class ModUtils {
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,15 +463,8 @@ public class ModUtils {
|
||||
}
|
||||
|
||||
public static boolean isInstallMod(TMod mod) {
|
||||
File modPath = new File(Utils.getAppPath() + "/" + mod.getId() + "/");
|
||||
for (int i = 0; i < modPath.listFiles().length; i++) {
|
||||
Log.i("检测mod是否安装", "位置:" + modPath.listFiles()[i].getAbsolutePath() + " exists:" + modPath.listFiles()[i].exists() + " .lock=" + (modPath.listFiles()[i].getName().contains(".lock")));
|
||||
if (modPath.listFiles()[i].getName().contains(".lock")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
ModDatabase database = ModDatabase.init();
|
||||
return database.isInstallMod(mod);
|
||||
}
|
||||
|
||||
public static boolean changeMod(TMod mod, List<TModfile> modfiles) {
|
||||
@ -423,29 +479,14 @@ public class ModUtils {
|
||||
}
|
||||
|
||||
public static File getModPath(TMod mod) {
|
||||
return getModPath(mod, "");
|
||||
return getModPath(mod, "", false);
|
||||
}
|
||||
|
||||
public static File getModPath(TMod mod, String name) {
|
||||
public static File getModPath(TMod mod, String name, boolean isCreate) {
|
||||
File path = new File(Utils.getAppPath() + "/" + mod.getId() + "/" + name);
|
||||
if (!path.exists()) {
|
||||
if (isCreate && !path.exists()) {
|
||||
path.mkdirs();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
public List<MGamePackname> getInstallClens() {
|
||||
List<MGamePackname> installClens = new ArrayList<>();
|
||||
File modPath = getModPath(mod);
|
||||
if (modPath.exists()) {
|
||||
for (int i = 0; i < modPath.listFiles().length; i++) {
|
||||
if (modPath.listFiles()[i].getName().contains(".lock")) {
|
||||
Log.i(TAG, modPath.listFiles()[i].getName().split("\\.lock")[0]);
|
||||
installClens.add(JSON.parseObject(Utils.readFile(modPath.listFiles()[i].getAbsolutePath()), MGamePackname.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return installClens;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import android.support.v4.content.FileProvider;
|
||||
|
||||
public class MyFileProvider extends FileProvider {
|
||||
}
|
@ -1,18 +1,24 @@
|
||||
package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/2/6.
|
||||
@ -25,88 +31,160 @@ public class RootUtils {
|
||||
private Process process;
|
||||
private DataOutputStream stream;
|
||||
private int exitValue;
|
||||
public static RootUtils init(Context context){
|
||||
if(rootUtils==null){
|
||||
rootUtils=new RootUtils(context);
|
||||
|
||||
public static RootUtils init(Context context) {
|
||||
if (rootUtils == null) {
|
||||
rootUtils = new RootUtils(context);
|
||||
rootUtils.init();
|
||||
rootUtils.println("chmod 7777 /data/data/com.yutou.jianrmg_v2/files/busybox");
|
||||
}
|
||||
return rootUtils;
|
||||
}
|
||||
private void init(){
|
||||
|
||||
public static void setRootInstallModel(Context context) {
|
||||
RadioButton rawRoot, busyBox;
|
||||
RadioGroup group;
|
||||
rawRoot = new RadioButton(context);
|
||||
busyBox = new RadioButton(context);
|
||||
group = new RadioGroup(context);
|
||||
rawRoot.setText("安卓自带指令");
|
||||
busyBox.setText("busyBox(有问题,在完善)");
|
||||
group.addView(rawRoot);
|
||||
group.addView(busyBox);
|
||||
if (RootUtils.init(context).isBusyBox()) {
|
||||
group.check(busyBox.getId());
|
||||
} else {
|
||||
group.check(rawRoot.getId());
|
||||
}
|
||||
busyBox.setEnabled(false);
|
||||
MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("设置ROOT安装模式");
|
||||
dialog.setContentView(group);
|
||||
dialog.setPositiveButton("确定", view -> {
|
||||
SharedPreferences preferences=context.getSharedPreferences("config",Context.MODE_PRIVATE);
|
||||
if(busyBox.isChecked()){
|
||||
preferences.edit().putInt("rootInstallModel",0).apply();
|
||||
}else{
|
||||
preferences.edit().putInt("rootInstallModel",1).apply();
|
||||
}
|
||||
dialog.dismiss();
|
||||
Utils.toast(context,"设置完成");
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
try {
|
||||
|
||||
localProcess = Runtime.getRuntime();
|
||||
process= localProcess.exec("su\n");
|
||||
stream=new DataOutputStream(process.getOutputStream());
|
||||
}catch (Exception e){
|
||||
process = localProcess.exec("ls"+"\n");
|
||||
stream = new DataOutputStream(process.getOutputStream());
|
||||
if(su()){
|
||||
boolean tmp=isBusyBox();
|
||||
isBusyBox=false;
|
||||
println("chmod 777" + Application.application.getFilesDir() + "/files/busybox");
|
||||
println("chmod +x" + Application.application.getFilesDir() + "/files/busybox");
|
||||
isBusyBox=tmp;
|
||||
}
|
||||
System.out.println("尝试获取ROOT权限");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RootUtils(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
private static int isRoot=0;
|
||||
public static boolean su(){
|
||||
if(isRoot!=0){
|
||||
if(isRoot==1){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int isRoot = -1;
|
||||
|
||||
public static boolean su() {
|
||||
if (isRoot != -1) {
|
||||
return isRoot == 1;
|
||||
}
|
||||
try {
|
||||
Process localProcess = Runtime.getRuntime().exec("su\n");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));
|
||||
Object localObject = localProcess.getOutputStream();
|
||||
DataOutputStream localDataOutputStream = new DataOutputStream(
|
||||
(OutputStream) localObject);
|
||||
localDataOutputStream.writeBytes("echo test\n");
|
||||
localDataOutputStream.writeBytes("ls -l /data/data\n");
|
||||
localDataOutputStream.flush();
|
||||
localDataOutputStream.writeBytes("exit\n");
|
||||
localDataOutputStream.flush();
|
||||
int result =localProcess.waitFor();
|
||||
localDataOutputStream.close();
|
||||
localProcess.exitValue();
|
||||
if (result == 0) {
|
||||
isRoot=1;
|
||||
return true;
|
||||
boolean result = false;
|
||||
int resultCode=-1;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
result = localProcess.waitFor(500, TimeUnit.MILLISECONDS);
|
||||
}else{
|
||||
System.out.println("b");
|
||||
resultCode=localProcess.waitFor();
|
||||
}
|
||||
else {
|
||||
isRoot=-1;
|
||||
localDataOutputStream.close();
|
||||
reader.close();
|
||||
localProcess.exitValue();
|
||||
if (result||resultCode == 0 || resultCode == 128) {
|
||||
isRoot = 1;
|
||||
return true;
|
||||
} else {
|
||||
isRoot = -1;
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
isRoot=-1;
|
||||
isRoot = -1;
|
||||
return false;
|
||||
}
|
||||
public boolean exec(String exec){
|
||||
|
||||
public boolean exec(String exec) {
|
||||
try {
|
||||
exec="./data/data/"+context.getPackageName()+"/files/busybox "+exec;
|
||||
Log.i("ROOT",exec);
|
||||
stream.writeBytes(exec+"\n");
|
||||
if (!isBusyBox()) {
|
||||
return println(exec);
|
||||
}
|
||||
String newExec = "./data/data/" + context.getPackageName() + "/files/busybox " + exec;
|
||||
Log.i("ROOT", newExec);
|
||||
stream.writeBytes(newExec + "\n");
|
||||
stream.flush();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();;
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
e.printStackTrace();
|
||||
init();
|
||||
Utils.toast(context,"busyBox失效,转为系统指令尝试");
|
||||
isBusyBox=false;
|
||||
return println(exec);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean isBusyBox=false;
|
||||
public boolean println(String exec) {
|
||||
try {
|
||||
if (isBusyBox) {
|
||||
return exec(exec);
|
||||
}
|
||||
String[] execs=new String[]{
|
||||
"su",
|
||||
"-c",
|
||||
exec
|
||||
};
|
||||
// exec="./data/data/"+context.getPackageName()+"/files/busybox-armv6l "+exec;
|
||||
Log.i("ROOT",exec);
|
||||
Process process=localProcess.exec(exec+"\n");
|
||||
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String str="",tmp;
|
||||
List<String> list=new ArrayList<>();
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
Log.i("SystemROOT", exec);
|
||||
Process process = localProcess.exec(execs);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String str = "", tmp;
|
||||
List<String> list = new ArrayList<>();
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
//str+=tmp;
|
||||
list.add(tmp);
|
||||
}
|
||||
reader.close();
|
||||
for (String string : list) {
|
||||
Log.i("ROOT get",string);
|
||||
Log.i("ROOT get", string);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -114,4 +192,16 @@ public class RootUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBusyBox() {
|
||||
SharedPreferences preferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
|
||||
switch (preferences.getInt("rootInstallModel", 0)) {
|
||||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,32 @@ package com.yutou.jianrmg_v2.Tools;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.Data.TModfilePath;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.views.WebActivity;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -24,7 +39,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,8 +57,18 @@ public class Utils {
|
||||
return (size * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
|
||||
}
|
||||
|
||||
public static DisplayMetrics getMetrics(Activity activity) {
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public static void toast(Context context, String str) {
|
||||
Toast.makeText(context, str, Toast.LENGTH_LONG).show();
|
||||
if (context == null)
|
||||
context = Application.application;
|
||||
Context finalContext = context;
|
||||
AppData.handler.post(() -> Toast.makeText(finalContext, str, Toast.LENGTH_LONG).show());
|
||||
|
||||
}
|
||||
|
||||
public static void setImmersion(Activity activity) {
|
||||
@ -231,4 +256,130 @@ public class Utils {
|
||||
files.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getApplicationPackName(Context context, String packName) {
|
||||
List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
|
||||
for (PackageInfo info : packages) {
|
||||
if (info.packageName.equals(packName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void initGamePackName() {
|
||||
try {
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.MOD_GAME_PACKNAME, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
Log.i(HttpApi.MOD_GAME_PACKNAME, string);
|
||||
JSONObject json = new JSONObject(string);
|
||||
AppData.packnames = JSON.parseArray(json.getJSONArray("data").toString(), MGamePackname.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void initInstallPath() {
|
||||
try {
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.INSTALL_PATH, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
Log.i(HttpApi.INSTALL_PATH, string);
|
||||
JSONObject json = new JSONObject(string);
|
||||
AppData.installPath = JSON.parseArray(json.getJSONArray("data").toString(), TModfilePath.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFileMD5(File file) {
|
||||
if (!file.isFile()) {
|
||||
return null;
|
||||
}
|
||||
MessageDigest digest = null;
|
||||
FileInputStream in = null;
|
||||
byte buffer[] = new byte[1024];
|
||||
int len;
|
||||
try {
|
||||
digest = MessageDigest.getInstance("MD5");
|
||||
in = new FileInputStream(file);
|
||||
while ((len = in.read(buffer, 0, 1024)) != -1) {
|
||||
digest.update(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return bytesToHexString(digest.digest());
|
||||
}
|
||||
public static String getMD5(String data){
|
||||
try{
|
||||
MessageDigest digest=MessageDigest.getInstance("MD5");
|
||||
digest.update(data.getBytes());
|
||||
return bytesToHexString(digest.digest());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String bytesToHexString(byte[] src) {
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (byte aSrc : src) {
|
||||
int v = aSrc & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static void openWebView(String url) {
|
||||
if(url.equals("#")){
|
||||
Utils.toast(Application.application,"暂无连接");
|
||||
return;
|
||||
}
|
||||
Intent intent;
|
||||
try {
|
||||
Uri uri = Uri.parse(url);
|
||||
intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
intent = new Intent(Application.application, WebActivity.class);
|
||||
intent.putExtra("url", url);
|
||||
|
||||
}
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
Application.application.startActivity(intent);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,8 @@ import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.TModfile;
|
||||
import com.yutou.jianrmg_v2.Interfaces.DownloadFileInerface;
|
||||
import com.yutou.jianrmg_v2.Interfaces.DownloadInterface;
|
||||
@ -32,64 +31,75 @@ public class DownloadService extends Service {
|
||||
private List<TModfile> list;
|
||||
private DownloadInterface downloadInterface;
|
||||
private NotificationManager notificationManager;
|
||||
private String BUTTON_CLICK="com.yutou.jianrmg.download.notification.button";
|
||||
private String BUTTON_CLICK = "com.yutou.jianrmg.download.notification.button";
|
||||
private Download download;
|
||||
private RemoteViews views;
|
||||
private Notification notification;
|
||||
private boolean puase=false;
|
||||
public class ServiceBinder extends Binder{
|
||||
public DownloadService getService(DownloadInterface downloadInterface){
|
||||
DownloadService.this.downloadInterface=downloadInterface;
|
||||
private boolean puase = false;
|
||||
private static boolean isInit = false;
|
||||
|
||||
public class ServiceBinder extends Binder {
|
||||
public DownloadService getService(DownloadInterface downloadInterface) {
|
||||
DownloadService.this.downloadInterface = downloadInterface;
|
||||
return DownloadService.this;
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadService() {
|
||||
list=new ArrayList<>();
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
private ServiceBinder binder=new ServiceBinder();
|
||||
private ServiceBinder binder = new ServiceBinder();
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// TODO: Return the communication channel to the service.
|
||||
return binder;
|
||||
}
|
||||
public void setFiles(List<TModfile> list){
|
||||
this.list=list;
|
||||
}
|
||||
public void setInterface(DownloadInterface downloadInterface){
|
||||
this.downloadInterface=downloadInterface;
|
||||
|
||||
public void setFiles(List<TModfile> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public int getDownloadList(){
|
||||
public void setInterface(DownloadInterface downloadInterface) {
|
||||
this.downloadInterface = downloadInterface;
|
||||
}
|
||||
|
||||
public int getDownloadList() {
|
||||
return list.size();
|
||||
}
|
||||
public void start(List<TModfile> addList){
|
||||
|
||||
public void start(List<TModfile> addList) {
|
||||
Log.i("启动下载服务");
|
||||
puase=false;
|
||||
list.addAll(addList);
|
||||
if (!isInit) {
|
||||
puase = false;
|
||||
downloadInterface.start();
|
||||
startNotification();
|
||||
download= new Download(this);
|
||||
download = new Download(this);
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
}
|
||||
public void pause(){
|
||||
puase=!puase;
|
||||
|
||||
public void pause() {
|
||||
puase = !puase;
|
||||
}
|
||||
private void startNotification(){
|
||||
IntentFilter filter=new IntentFilter();
|
||||
|
||||
private void startNotification() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(BUTTON_CLICK);
|
||||
registerReceiver(receiver,filter);
|
||||
Intent intent=new Intent(BUTTON_CLICK);
|
||||
PendingIntent buttonIntent=PendingIntent.getBroadcast(this,1,intent,PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
registerReceiver(receiver, filter);
|
||||
Intent intent = new Intent(BUTTON_CLICK);
|
||||
PendingIntent buttonIntent = PendingIntent.getBroadcast(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
views=new RemoteViews(getPackageName(),R.layout.notification_download_layout);
|
||||
views.setTextViewText(R.id.title,"开始下载");
|
||||
views.setOnClickPendingIntent(R.id.button,buttonIntent);
|
||||
views = new RemoteViews(getPackageName(), R.layout.notification_download_layout);
|
||||
views.setTextViewText(R.id.title, "开始下载");
|
||||
views.setOnClickPendingIntent(R.id.button, buttonIntent);
|
||||
views.setImageViewResource(R.id.imageView, R.mipmap.ic_launcher);
|
||||
|
||||
notificationManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
Notification.Builder builder=new Notification.Builder(getApplicationContext());
|
||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
Notification.Builder builder = new Notification.Builder(getApplicationContext());
|
||||
builder.setTicker("开始下载");
|
||||
builder.setContentTitle("正在下载");
|
||||
builder.setContent(views);
|
||||
@ -100,87 +110,100 @@ public class DownloadService extends Service {
|
||||
builder.setSmallIcon(R.drawable.icon_download);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel=new NotificationChannel("channel_1","Message",NotificationManager.IMPORTANCE_HIGH);
|
||||
NotificationChannel channel = new NotificationChannel("channel_1", "Message", NotificationManager.IMPORTANCE_HIGH);
|
||||
builder.setChannelId(channel.getId());
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
notification = builder.build();
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
notificationManager.notify(1,notification);
|
||||
Utils.toast(getApplicationContext(),"展示通知栏");
|
||||
notificationManager.notify(1, notification);
|
||||
Utils.toast(getApplicationContext(), "展示通知栏");
|
||||
}
|
||||
private BroadcastReceiver receiver=new BroadcastReceiver() {
|
||||
|
||||
private boolean isClickButton = false;
|
||||
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i("点击按钮");
|
||||
puase=!puase;
|
||||
puase = !puase;
|
||||
isClickButton = true;
|
||||
}
|
||||
};
|
||||
private class Download extends Thread{
|
||||
|
||||
private class Download extends Thread {
|
||||
private Download download;
|
||||
private DownloadService service;
|
||||
private boolean isAlive=false,downloading=false;
|
||||
public Download(DownloadService service){
|
||||
download=this;
|
||||
private boolean isAlive = false, downloading = false;
|
||||
|
||||
public Download(DownloadService service) {
|
||||
download = this;
|
||||
download.init(service);
|
||||
}
|
||||
|
||||
private void init(DownloadService service){
|
||||
if(!download.isAlive||!download.isAlive()||!download.isInterrupted())
|
||||
{
|
||||
this.service=service;
|
||||
private void init(DownloadService service) {
|
||||
if (!download.isAlive || !download.isAlive() || !download.isInterrupted()) {
|
||||
this.service = service;
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
isAlive=true;
|
||||
isAlive = true;
|
||||
Log.i("准备下载");
|
||||
while (service.list.size()>0){
|
||||
if(downloading){
|
||||
while (service.list.size() > 0) {
|
||||
if (downloading) {
|
||||
continue;
|
||||
}
|
||||
Log.i("开始下载:"+(downloading));
|
||||
downloading=true;
|
||||
final TModfile modfile=service.list.get(service.list.size()-1);
|
||||
Log.i("开始下载:" + (downloading));
|
||||
downloading = true;
|
||||
final TModfile modfile = service.list.get(service.list.size() - 1);
|
||||
service.downloadInterface.getDownloadList(service.list.size());
|
||||
Log.i("下载地址",modfile.getServiceurl());
|
||||
Log.i("下载地址", modfile.getServiceurl());
|
||||
HttpUtils.downloadFile(modfile.getServiceurl(), Utils.getAppPath() + "/" + modfile.getMid() + "/", new DownloadFileInerface() {
|
||||
|
||||
@Override
|
||||
public boolean downloading(String fileName, int current, long length) {
|
||||
service.views.setTextViewText(R.id.title,"正在下载:"+modfile.getFilename()+"("+length/1024+"kb)");
|
||||
service.views.setProgressBar(R.id.progressBar, 100,current,false);
|
||||
if(service.puase){
|
||||
service.views.setTextViewText(R.id.button,"下载");
|
||||
}else{
|
||||
service.views.setTextViewText(R.id.button,"暂停");
|
||||
service.views.setTextViewText(R.id.title, "正在下载:" + modfile.getFilename() + "(" + length / 1024 + "kb)");
|
||||
service.views.setProgressBar(R.id.progressBar, 100, current, false);
|
||||
if (isClickButton) {
|
||||
if (service.puase) {
|
||||
service.views.setTextViewText(R.id.button, "下载");
|
||||
} else {
|
||||
service.views.setTextViewText(R.id.button, "暂停");
|
||||
}
|
||||
isClickButton = false;
|
||||
}
|
||||
try {
|
||||
service.notificationManager.notify(1, service.notification);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
service.notificationManager.notify(1,service.notification);
|
||||
if(service.puase){
|
||||
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
return !service.puase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void over(boolean isOver) {
|
||||
if(isOver){
|
||||
if (isOver) {
|
||||
service.list.remove(modfile);
|
||||
}
|
||||
downloading=false;
|
||||
downloading = false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
service.views.setTextViewText(R.id.title,"全部下载完成");
|
||||
service.views.setProgressBar(R.id.progressBar,10,10,false);
|
||||
service.notificationManager.notify(1,service.notification);
|
||||
AppData.handler.postDelayed(() -> {
|
||||
service.views.setTextViewText(R.id.button, "0v0");
|
||||
service.views.setTextViewText(R.id.title, "全部下载完成");
|
||||
service.views.setProgressBar(R.id.progressBar, 10, 10, false);
|
||||
service.notificationManager.notify(1, service.notification);
|
||||
service.downloadInterface.over();
|
||||
isAlive=false;
|
||||
isAlive = false;
|
||||
}, 100);
|
||||
isInit=false;
|
||||
Log.i("下载结束");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,212 @@
|
||||
package com.yutou.jianrmg_v2.services;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bigzhao.jianrmagicbox.aidl.IMagicBoxBinder;
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Databases.JianRDataDataBase;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.WarView;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import Interfaces.MagicBoxInterface;
|
||||
|
||||
import static android.content.Context.BIND_AUTO_CREATE;
|
||||
|
||||
public class MagicBoxService {
|
||||
private JSONObject order = null;
|
||||
private static MagicBoxService magicBoxService = null;
|
||||
private MagicBoxInterface magicBoxInterface;
|
||||
private JSONObject dealNode, getWarResult;
|
||||
private boolean isClose = true, saveData = false;
|
||||
private String dataType, dataName;
|
||||
|
||||
|
||||
private MagicBoxService() {
|
||||
initMagicBox();
|
||||
}
|
||||
|
||||
public void setSaveData(boolean saveData, String dataName, String dataType) {
|
||||
this.saveData = saveData;
|
||||
this.dataName = dataName;
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public static MagicBoxService init() {
|
||||
if (!Utils.getApplicationPackName(Application.application, AppData.magicPackageName)) {
|
||||
System.out.println("没有安装客户端");
|
||||
return null;
|
||||
}
|
||||
if (magicBoxService == null) {
|
||||
magicBoxService = new MagicBoxService();
|
||||
}
|
||||
return magicBoxService;
|
||||
}
|
||||
|
||||
private ServiceConnection connection;
|
||||
|
||||
private void initMagicBox() {
|
||||
System.out.println("绑定大钊客户端");
|
||||
isClose = false;
|
||||
connection = new ServiceConnection() {
|
||||
JianRDataDataBase dataBase;
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
System.out.println("链接大钊客户端");
|
||||
if (!Utils.testStringIsNull(dataName, dataType)) {
|
||||
dataBase = JianRDataDataBase.init();
|
||||
}
|
||||
dataBase = JianRDataDataBase.init();
|
||||
IMagicBoxBinder boxBinder = IMagicBoxBinder.Stub.asInterface(iBinder);
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isClose) {
|
||||
System.out.println("关闭连接");
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (order != null && !order.isNull("action")) {
|
||||
try {
|
||||
System.out.println("提交参数 action:" + order.getString("action") + " args:" + JSON.toJSONString(order.get("args")));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
if (order.getString("action").equals("getVersion")) {
|
||||
magicBoxInterface.getData(boxBinder.getVersion() + "");
|
||||
} else {
|
||||
magicBoxInterface.getData(boxBinder.action_remote(order.getString("action"), (String[]) order.get("args")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Application.application.unbindService(connection);
|
||||
isClose = true;
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
try {
|
||||
String str = boxBinder.action_remote("getLastLog", new String[]{"DealNode"});
|
||||
if (str != null) {
|
||||
try {
|
||||
dealNode = new JSONObject(str);
|
||||
if (dataBase != null && saveData) {
|
||||
dataBase.addData(dataName, dealNode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String str2 = boxBinder.action_remote("getLastLog", new String[]{"GetWarResult"});
|
||||
if (str2 != null) {
|
||||
try {
|
||||
getWarResult = new JSONObject(str2);
|
||||
if (dataBase != null && saveData) {
|
||||
long id = dataBase.addData(dataName, getWarResult);
|
||||
getWarResult.put("dataId", id);
|
||||
if (id != -1)
|
||||
dataBase.addDrop(getWarResult);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(listener!=null){
|
||||
JSONObject json;
|
||||
if(str!=null){
|
||||
json=new JSONObject(str);
|
||||
json.put("type","DealNode");
|
||||
listener.getData(json.toString());
|
||||
}
|
||||
if(str2!=null){
|
||||
json=new JSONObject(str2);
|
||||
json.put("type","GetWarResult");
|
||||
listener.getData(json.toString());
|
||||
}
|
||||
}
|
||||
// System.out.println("str = "+str);
|
||||
// System.out.println("str2 = "+str2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
order = null;
|
||||
}
|
||||
}, 0, 500);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName componentName) {
|
||||
System.out.println("大钊客户端连接失败:" + componentName.flattenToString());
|
||||
isClose = true;
|
||||
}
|
||||
};
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(com.bigzhao.jianrmagicbox.IMagicBoxBinder.ACTION_SERVICE);
|
||||
intent.setPackage(AppData.magicPackageName);
|
||||
Application.application.bindService(intent, connection, BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
public void startService() {
|
||||
try {
|
||||
Application.application.unbindService(connection);
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(com.bigzhao.jianrmagicbox.IMagicBoxBinder.ACTION_SERVICE);
|
||||
intent.setPackage(AppData.magicPackageName);
|
||||
boolean tmp = Application.application.bindService(intent, connection, BIND_AUTO_CREATE);
|
||||
System.out.println("重新绑定结果:" + tmp);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setOrder(JSONObject order, MagicBoxInterface boxInterface) {
|
||||
if (isClose) {
|
||||
initMagicBox();
|
||||
}
|
||||
this.order = order;
|
||||
this.magicBoxInterface = boxInterface;
|
||||
}
|
||||
|
||||
public void clearOrder() {
|
||||
order = null;
|
||||
}
|
||||
|
||||
public JSONObject getDealNode() {
|
||||
return dealNode;
|
||||
}
|
||||
|
||||
public JSONObject getGetWarResult() {
|
||||
return getWarResult;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
isClose = true;
|
||||
}
|
||||
|
||||
private void saveData(JSONObject json, String fileName) {
|
||||
try {
|
||||
File file = new File(Utils.getSDCardPath() + "/" + fileName + ".txt");
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
writer.write(json.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private MagicBoxInterface listener=null;
|
||||
void setOnListener(MagicBoxInterface boxInterface) {
|
||||
this.listener=boxInterface;
|
||||
}
|
||||
}
|
@ -0,0 +1,641 @@
|
||||
package com.yutou.jianrmg_v2.services;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.constraint.ConstraintLayout;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.tencent.smtt.sdk.TbsReaderView;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ExcelUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.RootUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.views.ExcelActivity;
|
||||
import com.yutou.jianrmg_v2.views.WarView;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import Interfaces.MagicBoxInterface;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
|
||||
public class WindowsService extends Service {
|
||||
private MyBinder binder = new MyBinder();
|
||||
private Handler handler;
|
||||
private LinearLayout buttons, contextLayout;
|
||||
private FrameLayout side;
|
||||
private ImageView push, state;
|
||||
private WindowManager windowManager;
|
||||
private WindowManager.LayoutParams params;
|
||||
private ConstraintLayout mainLayout;
|
||||
private WebView webView;
|
||||
private ExcelUtils excel;
|
||||
private File excelFile;
|
||||
private Context context;
|
||||
private boolean input_flag = false,saveData=false;
|
||||
private String dataType,dataName;
|
||||
private WarView warView;
|
||||
|
||||
private class MyBinder extends Binder {
|
||||
public WindowsService getService() {
|
||||
return WindowsService.this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return binder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (intent != null) {
|
||||
saveData = intent.getBooleanExtra("saveData", false);
|
||||
dataName=intent.getStringExtra("dataName");
|
||||
dataType=intent.getStringExtra("dataType");
|
||||
System.out.println("接收到配置,开关 = "+saveData+" name = "+dataName+" type = "+dataType);
|
||||
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
System.out.println("触发悬浮窗");
|
||||
context = WindowsService.this;
|
||||
handler = new Handler();
|
||||
warView=new WarView(context,null,webW,handler);
|
||||
try {
|
||||
SharedPreferences sp = getSharedPreferences(ExcelActivity.excelName, MODE_PRIVATE);
|
||||
excelFile = new File(sp.getString("default", "null.xlsx"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
initWindows();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
stopSelf();
|
||||
Utils.toast(getApplicationContext(), "需要开启悬浮窗权限");
|
||||
Intent windowIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
||||
windowIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(windowIntent);
|
||||
return;
|
||||
}
|
||||
initViews();
|
||||
serviceTimer();
|
||||
reloadUi();
|
||||
}
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private void serviceTimer() {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
boolean isRuntime = false;
|
||||
boolean listener=true;
|
||||
@Override
|
||||
public void run() {
|
||||
MagicBoxService boxService = MagicBoxService.init();
|
||||
if (boxService == null) {
|
||||
Utils.toast(context, "未安装专用客户端,部分功能将无法使用");
|
||||
cancel();
|
||||
return;
|
||||
}else{
|
||||
boxService.setSaveData(saveData,dataName,dataType);
|
||||
}
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("action", "getVersion");
|
||||
boxService.setOrder(json, data -> {
|
||||
boxService.clearOrder();
|
||||
isRuntime = true;
|
||||
});
|
||||
if(listener) {
|
||||
listener=false;
|
||||
boxService.setOnListener(data -> {
|
||||
try{
|
||||
JSONObject jdata=new JSONObject(data);
|
||||
//保留,还不知道干啥用
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
handler.post(() -> {
|
||||
if (isRuntime) {
|
||||
state.setImageResource(R.drawable.item_suspend_yuan_green);
|
||||
state.setTag(true);
|
||||
} else {
|
||||
state.setImageResource(R.drawable.item_suspend_yuan_rad);
|
||||
state.setTag(false);
|
||||
}
|
||||
isRuntime = false;
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
private void initWindows() {
|
||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
params = new WindowManager.LayoutParams();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
} else {
|
||||
params.type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
params.format = PixelFormat.RGBA_8888;
|
||||
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
params.gravity = Gravity.START | Gravity.TOP;
|
||||
params.alpha = 50;
|
||||
mainLayout = (ConstraintLayout) LayoutInflater.from(context).inflate(R.layout.activity_suspend, null);
|
||||
windowManager.addView(mainLayout, params);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
buttons = mainLayout.findViewById(R.id.buttons);
|
||||
state = mainLayout.findViewById(R.id.state);
|
||||
push = mainLayout.findViewById(R.id.push);
|
||||
side = mainLayout.findViewById(R.id.side);
|
||||
contextLayout = mainLayout.findViewById(R.id.contextLayout);
|
||||
webView = new WebView(context);
|
||||
contextLayout.addView(webView);
|
||||
initWebView();
|
||||
initWebUi();
|
||||
|
||||
setWebUrl("http://www.baidu.com");
|
||||
state.setOnClickListener(view -> {
|
||||
if ((boolean) state.getTag()) {
|
||||
Utils.toast(context, "专用客户端已连接");
|
||||
} else {
|
||||
if (MagicBoxService.init() == null) {
|
||||
Utils.toast(context, "专用客户端未安装(仅限共存版)");
|
||||
} else {
|
||||
Utils.toast(context, "专用客户端未启动");
|
||||
MagicBoxService service= MagicBoxService.init();
|
||||
if(service!=null){
|
||||
service.startService();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
state.setTag(false);
|
||||
push.setTag(false);
|
||||
push.setOnClickListener(view -> {
|
||||
if ((boolean) push.getTag()) {
|
||||
push.setTag(false);
|
||||
side.setVisibility(View.VISIBLE);
|
||||
|
||||
} else {
|
||||
push.setTag(true);
|
||||
side.setVisibility(View.GONE);
|
||||
webView.setVisibility(View.GONE);
|
||||
}
|
||||
reloadUi();
|
||||
});
|
||||
|
||||
List<Button> buts = new ArrayList<>();
|
||||
buts.addAll(getMagicButtons());
|
||||
buts.addAll(getWebButtons());
|
||||
buts.addAll(getConfigButtons());
|
||||
|
||||
for (Button button : buts) {
|
||||
buttons.addView(button);
|
||||
}
|
||||
|
||||
}
|
||||
private int webW=0,webH=0;
|
||||
private void reloadUi() {
|
||||
if(webView.getLayoutParams().width>0) {
|
||||
webW = webView.getLayoutParams().width;
|
||||
webH = webView.getLayoutParams().height;
|
||||
contextLayout.getLayoutParams().width=webW;
|
||||
}
|
||||
int pushSize = Utils.getPixelsFromDp(AppData.activity, 10);
|
||||
int sideSize = Utils.getPixelsFromDp(AppData.activity, 45);
|
||||
int webSize =contextLayout.getLayoutParams().width;
|
||||
if (side.getVisibility() == View.GONE) {
|
||||
sideSize = 0;
|
||||
}
|
||||
if (contextLayout.getVisibility() == View.GONE) {
|
||||
webSize = 0;
|
||||
}
|
||||
if(webSize<0){
|
||||
|
||||
}
|
||||
|
||||
System.out.println("push size:" + pushSize);
|
||||
System.out.println("side size:" + sideSize);
|
||||
System.out.println("webs size:" + webSize);
|
||||
params.width =pushSize + sideSize +webSize;
|
||||
System.out.println("悬浮窗大小:" + params.width+" push="+pushSize+" side="+sideSize+" wr="+webSize+" wit="+Utils.getMetrics(AppData.activity).widthPixels);
|
||||
windowManager.updateViewLayout(mainLayout, params);
|
||||
initWebUi();
|
||||
}
|
||||
|
||||
private void initWebUi() {
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
windowManager.getDefaultDisplay().getMetrics(metrics);
|
||||
int width = -1;
|
||||
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// 横屏
|
||||
width = metrics.widthPixels;
|
||||
width = (int) (width - (width * 0.1));
|
||||
System.out.println("横屏");
|
||||
} else {
|
||||
// 竖屏
|
||||
width = metrics.widthPixels;
|
||||
width = (int) (width - (width * 0.2));
|
||||
System.out.println("竖屏");
|
||||
}
|
||||
webView.getLayoutParams().width = width;
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
private void initWebView() {
|
||||
WebSettings settings = webView.getSettings();
|
||||
settings.setJavaScriptEnabled(true);
|
||||
settings.setUseWideViewPort(true);
|
||||
settings.setAppCacheEnabled(true);
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
System.out.println("加载网页:" + url);
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
webView.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
webView.goBack();
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<Button> getWebButtons() {
|
||||
List<Button> list = new ArrayList<>();
|
||||
Button bbs = new Button(context);
|
||||
bbs.setText("论");
|
||||
bbs.setTag(200);
|
||||
bbs.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
Button address = new Button(context);
|
||||
address.setText("浏");
|
||||
address.setTag(201);
|
||||
address.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
Button bookmark = new Button(context);
|
||||
bookmark.setText("签");
|
||||
bookmark.setTag(202);
|
||||
bookmark.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
Button input = new Button(context);
|
||||
input.setText("输");
|
||||
input.setTag(203);
|
||||
input.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
Button strategy = new Button(context);
|
||||
strategy.setText("攻");
|
||||
strategy.setTag(204);
|
||||
strategy.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
list.add(bbs);
|
||||
list.add(strategy);
|
||||
list.add(address);
|
||||
list.add(input);
|
||||
// list.add(bookmark);
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<Button> getMagicButtons() {
|
||||
List<Button> list = new ArrayList<>();
|
||||
if (MagicBoxService.init() != null) {
|
||||
Button map = new Button(context);
|
||||
Button user = new Button(context);
|
||||
Button pool = new Button(context);
|
||||
Button build = new Button(context);
|
||||
Button develop = new Button(context);
|
||||
Button expedition = new Button(context);
|
||||
Button fix = new Button(context);
|
||||
|
||||
map.setText("图");
|
||||
user.setText("捞");
|
||||
pool.setText("战");
|
||||
build.setText("掉");
|
||||
develop.setText("开");
|
||||
expedition.setText("征");
|
||||
fix.setText("修");
|
||||
|
||||
map.setTag(100);
|
||||
user.setTag(101);
|
||||
pool.setTag(102);
|
||||
build.setTag(103);
|
||||
develop.setTag(104);
|
||||
expedition.setTag(105);
|
||||
fix.setTag(106);
|
||||
|
||||
map.setOnClickListener(new ButtonOnClick());
|
||||
user.setOnClickListener(new ButtonOnClick());
|
||||
pool.setOnClickListener(new ButtonOnClick());
|
||||
build.setOnClickListener(new ButtonOnClick());
|
||||
develop.setOnClickListener(new ButtonOnClick());
|
||||
expedition.setOnClickListener(new ButtonOnClick());
|
||||
fix.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
list.add(map);
|
||||
list.add(user);
|
||||
list.add(pool);
|
||||
list.add(build);
|
||||
//list.add(develop);
|
||||
//list.add(expedition);
|
||||
list.add(fix);
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<Button> getConfigButtons() {
|
||||
List<Button> list = new ArrayList<>();
|
||||
Button alpha = new Button(context);
|
||||
alpha.setText("透");
|
||||
alpha.setTag(300);
|
||||
alpha.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
Button exit = new Button(context);
|
||||
exit.setText("退");
|
||||
exit.setTag(301);
|
||||
exit.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
Button win = new Button(context);
|
||||
win.setText("拉");
|
||||
win.setTag(302);
|
||||
win.setOnClickListener(new ButtonOnClick());
|
||||
|
||||
list.add(win);
|
||||
list.add(alpha);
|
||||
list.add(exit);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
reloadUi();
|
||||
}
|
||||
private void setWebUrl(String url){
|
||||
handler.post(()->{
|
||||
if (contextLayout.getVisibility() == View.GONE) {
|
||||
contextLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if(excel!=null) {
|
||||
excel.close();
|
||||
excel = null;
|
||||
}
|
||||
if (webView.getVisibility() == View.GONE) {
|
||||
webView.setVisibility(View.VISIBLE);
|
||||
reloadUi();
|
||||
}
|
||||
setView(webView);
|
||||
reloadUi();
|
||||
webView.loadUrl(url);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
class ButtonOnClick implements View.OnClickListener {
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog dialog;
|
||||
MagicBoxService service = MagicBoxService.init();
|
||||
JSONObject json;
|
||||
LinearLayout layout;
|
||||
try {
|
||||
|
||||
switch ((int) view.getTag()) {
|
||||
case 300:
|
||||
SeekBar bar = new SeekBar(context);
|
||||
bar.setMin(1);
|
||||
bar.setMax(230);
|
||||
bar.setProgress((int) params.alpha);
|
||||
bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
System.out.println("参数:" + i);
|
||||
params.alpha = i;
|
||||
windowManager.updateViewLayout(mainLayout, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
});
|
||||
dialog = new AlertDialog.Builder(context)
|
||||
.setTitle("设置透明度")
|
||||
.setView(bar)
|
||||
.setPositiveButton("确定", (dialogInterface, i) -> dialogInterface.dismiss()).create();
|
||||
dialog.getWindow().setType(params.type);
|
||||
dialog.show();
|
||||
break;
|
||||
case 301:
|
||||
timer.cancel();
|
||||
webView.destroy();
|
||||
contextLayout.removeAllViews();
|
||||
mainLayout.removeAllViews();
|
||||
windowManager.removeView(mainLayout);
|
||||
if (excel != null) {
|
||||
excel.stop();
|
||||
}
|
||||
if(warView!=null){
|
||||
warView.close();
|
||||
}
|
||||
stopSelf();
|
||||
break;
|
||||
case 302:
|
||||
Button button = (Button) view;
|
||||
if (button.getText().toString().equals("拉")) {
|
||||
button.setText("缩");
|
||||
contextLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
button.setText("拉");
|
||||
contextLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
reloadUi();
|
||||
break;
|
||||
case 200:
|
||||
if (contextLayout.getVisibility() == View.GONE) {
|
||||
contextLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
reloadUi();
|
||||
setWebUrl("http://bbs.jianrmod.cn");
|
||||
break;
|
||||
case 201:
|
||||
layout = new LinearLayout(context);
|
||||
layout.setHorizontalGravity(LinearLayout.VERTICAL);
|
||||
EditText webEdit = new EditText(context);
|
||||
LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
webEdit.setLayoutParams(editParams);
|
||||
webEdit.setText("http://");
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
layout.addView(webEdit);
|
||||
layout.setLayoutParams(layoutParams);
|
||||
dialog = new AlertDialog.Builder(context)
|
||||
.setTitle("输入地址")
|
||||
.setView(layout)
|
||||
.setPositiveButton("跳转", (dialogInterface, i) -> {
|
||||
|
||||
setWebUrl(webEdit.getText().toString());
|
||||
dialogInterface.dismiss();
|
||||
})
|
||||
.setNegativeButton("取消", (dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.create();
|
||||
dialog.getWindow().setType(params.type);
|
||||
dialog.show();
|
||||
case 202:
|
||||
break;
|
||||
case 203:
|
||||
if (input_flag) {
|
||||
input_flag = false;
|
||||
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
windowManager.updateViewLayout(mainLayout, params);
|
||||
Utils.toast(context, "取消监听,网页不可输入内容,实体按键恢复");
|
||||
} else {
|
||||
input_flag = true;
|
||||
params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
|
||||
windowManager.updateViewLayout(mainLayout, params);
|
||||
Utils.toast(context, "监听浏览器,网页可输入内容,实体按键失效");
|
||||
}
|
||||
break;
|
||||
case 204:
|
||||
if (!excelFile.exists()) {
|
||||
Utils.toast(context, "离线资料不存在,请先下载离线资料");
|
||||
return;
|
||||
}
|
||||
|
||||
if(excel==null){
|
||||
excel=new ExcelUtils(AppData.activity);
|
||||
setView(excel.getReader());
|
||||
excel.getReader().getLayoutParams().height=contextLayout.getLayoutParams().height;
|
||||
excel.start(excelFile);
|
||||
}
|
||||
reloadUi();
|
||||
break;
|
||||
|
||||
case 100:
|
||||
if(service!=null){
|
||||
json=service.getDealNode();
|
||||
service.getGetWarResult();
|
||||
if(json==null)
|
||||
return;
|
||||
JSONObject ext=new JSONObject(json.getString("ext"));
|
||||
if(ext.getString("s").equals("pve")){
|
||||
System.out.println("原参数:"+ext.toString());
|
||||
String url="http://js.ntwikis.com/jsp/apps/cancollezh/maps/detailnew.jsp?detailid="+((ext.getInt("n")/100)+"").replace("0","-");
|
||||
System.out.println("url:"+url);
|
||||
setWebUrl(url);
|
||||
}
|
||||
reloadUi();
|
||||
}
|
||||
break;
|
||||
case 101:
|
||||
if (service != null) {
|
||||
json = service.getDealNode();
|
||||
if(json==null)
|
||||
return;
|
||||
JSONObject ext=new JSONObject(json.getString("ext"));
|
||||
System.out.println("EXT源:"+ext.toString());
|
||||
String url="http://www.jianrmod.cn/data/nodeDropInfo.html?node="+ext.getInt("n");
|
||||
System.out.println("url:"+url);
|
||||
setWebUrl(url);
|
||||
reloadUi();
|
||||
}
|
||||
break;
|
||||
case 102:
|
||||
if(service!=null) {
|
||||
setView(warView.initView());
|
||||
warView.update(service,webW);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setView(View view) {
|
||||
contextLayout.removeAllViews();
|
||||
contextLayout.addView(view);
|
||||
}
|
||||
private View getUserTeam(JSONObject json){
|
||||
try {
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,36 +1,73 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
import com.yutou.jianrmg_v2.Application;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Interfaces.DownloadFileInerface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import Interfaces.BaseActivityInterface;
|
||||
import dalvik.system.DexClassLoader;
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class BaseActivity extends AppCompatActivity {
|
||||
private BaseActivityInterface activityInterface;
|
||||
private LinearLayout main_layut;
|
||||
private KProgressHUD hud;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_base);
|
||||
setTitle(R.string.app_name);
|
||||
hud=Utils.showLoading(this,"请稍后","正在下载");
|
||||
main_layut=findViewById(R.id.main_layut);
|
||||
String baseActivityName=getIntent().getStringExtra("activityName");
|
||||
String jar=getIntent().getStringExtra("jar");
|
||||
String name=getIntent().getStringExtra("name");
|
||||
String url=getIntent().getStringExtra("url");
|
||||
DexClassLoader dexClassLoader= AppData.plugsin.get(jar);
|
||||
|
||||
try {
|
||||
activityInterface= (BaseActivityInterface) dexClassLoader.loadClass(baseActivityName).newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
activityInterface.onCreate(savedInstanceState,main_layut,this,getIntent());
|
||||
} catch (Exception e) {
|
||||
activityInterface=new NotInter();
|
||||
MaterialDialog dialog=new MaterialDialog(this);
|
||||
dialog.setTitle("下载插件:"+name);
|
||||
dialog.setMessage("这可能是一个插件,但您未安装该插件,请问是否进行下载安装操作?");
|
||||
dialog.setNegativeButton("取消",view ->{dialog.dismiss();finish();});
|
||||
dialog.setPositiveButton("确定",view -> {
|
||||
HttpUtils.downloadFile(url, Utils.getAppPath() + "/plugin/", new DownloadFileInerface() {
|
||||
@Override
|
||||
public boolean downloading(String fileName, int current, long length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void over(boolean isOver) {
|
||||
Toast.makeText(Application.application,"下载完成,重启应用生效",Toast.LENGTH_LONG).show();
|
||||
hud.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
dialog.dismiss();
|
||||
hud.show();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,4 +120,56 @@ public class BaseActivity extends AppCompatActivity {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private class NotInter implements BaseActivityInterface{
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIntent(Intent intent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data getData() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.RootUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigActivity extends AppCompatActivity {
|
||||
private ListView listView;
|
||||
private List<String> config;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_config);
|
||||
initCofig();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
listView = findViewById(R.id.listView);
|
||||
listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, config));
|
||||
listView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
Intent intent=null;
|
||||
switch (position){
|
||||
case 0:
|
||||
RootUtils.setRootInstallModel(ConfigActivity.this);
|
||||
break;
|
||||
case 1:
|
||||
Utils.initImageLoader(ConfigActivity.this).clearDiskCache();
|
||||
Toast.makeText(ConfigActivity.this,"咕",Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case 2:
|
||||
intent=new Intent(this,WebActivity.class);
|
||||
intent.putExtra("url", HttpApi.HOME_URL+"../html/join.jsp");
|
||||
break;
|
||||
case 3:
|
||||
intent=new Intent(this,WebActivity.class);
|
||||
intent.putExtra("url", HttpApi.HOME_URL+"../html/about.jsp");
|
||||
break;
|
||||
case 4:
|
||||
intent=new Intent(this,LicenseActivity.class);
|
||||
break;
|
||||
}
|
||||
if(intent!=null){
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void initCofig(){
|
||||
config=new ArrayList<>();
|
||||
config.add("设置ROOT安装模式");
|
||||
config.add("清空图片缓存");
|
||||
config.add("加群");
|
||||
config.add("关于我们");
|
||||
config.add("开源项目协议");
|
||||
}
|
||||
}
|
@ -1,80 +1,83 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Adapters.DownloadItemAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Databases.ModDatabase;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ModUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Interfaces.BaseActivityInterface;
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class DownloadListActivity extends AppCompatActivity {
|
||||
private Context context;
|
||||
private ListView listView;
|
||||
private List<TMod> mods;
|
||||
private List<TMod> mods, mods_;
|
||||
private Handler handler;
|
||||
private ModDatabase database;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_download_list);
|
||||
this.context = this;
|
||||
handler=new Handler();
|
||||
handler = new Handler();
|
||||
this.database = ModDatabase.init();
|
||||
getDownloadFileList();
|
||||
initViews();
|
||||
}
|
||||
private void getDownloadFileList(){
|
||||
JSONObject json=new JSONObject();
|
||||
File rootPath=new File(Utils.getAppPath());
|
||||
try{
|
||||
JSONArray array=new JSONArray();
|
||||
for (File path : rootPath.listFiles()) {
|
||||
if (path.isDirectory()){
|
||||
|
||||
private void getDownloadFileList() {
|
||||
JSONObject json = new JSONObject();
|
||||
mods_ = database.getDownloadModIds();
|
||||
try {
|
||||
array.put(Integer.valueOf(path.getName())+"");
|
||||
}catch (Exception e){ }
|
||||
JSONArray array = new JSONArray();
|
||||
for (TMod mod : mods_) {
|
||||
array.put(mod.getId());
|
||||
}
|
||||
}
|
||||
json.put("ids",array);
|
||||
json.put("ids", array);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_MODS, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json.getInt("code")!=100){
|
||||
JSONObject json = new JSONObject(string);
|
||||
if (json.getInt("code") != 100) {
|
||||
return;
|
||||
}
|
||||
mods= JSON.parseArray(json.getJSONArray("data").toString(),TMod.class);
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listView.setAdapter(new DownloadItemAdapter(context,mods));
|
||||
mods = JSON.parseArray(json.getJSONArray("data").toString(), TMod.class);
|
||||
handler.post(() -> {
|
||||
listView.setAdapter(new DownloadItemAdapter(context, mods));
|
||||
String title = "";
|
||||
List<TMod> ids = new ArrayList<>(mods_.size());
|
||||
for (TMod mod : mods) {
|
||||
for (TMod tMod : mods_) {
|
||||
if (tMod.getTitle().equals(mod.getTitle()) && tMod.getModversion() < mod.getModversion()) {
|
||||
System.out.println(tMod.getTitle() + " " + tMod.getModversion() + " " + mod.getTitle() + " " + mod.getModversion());
|
||||
title += "\n" + tMod.getTitle();
|
||||
ids.add(mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ids.isEmpty())
|
||||
showUploadModDialog(title, ids);
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
@ -86,12 +89,41 @@ public class DownloadListActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){}
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
private void initViews(){
|
||||
listView=findViewById(R.id.listView);
|
||||
|
||||
}
|
||||
|
||||
private void showUploadModDialog(String title, List<TMod> mods) {
|
||||
MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("Mod升级");
|
||||
dialog.setMessage("你有以下mod可以进行升级:" + title + "\n是否进行升级?");
|
||||
dialog.setNegativeButton("不用了", view -> dialog.dismiss());
|
||||
dialog.setPositiveButton("好的", view -> {
|
||||
ModUtils utils = ModUtils.init(context);
|
||||
for (TMod mod : mods) {
|
||||
utils.installMod(mod, null);
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
listView = findViewById(R.id.listView);
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
164
app/src/main/java/com/yutou/jianrmg_v2/views/ExcelActivity.java
Normal file
@ -0,0 +1,164 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.constraint.ConstraintLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
import com.tencent.smtt.sdk.TbsReaderView;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Interfaces.DownloadFileInerface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ExcelUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class ExcelActivity extends AppCompatActivity {
|
||||
|
||||
private ExcelUtils excel;
|
||||
private JSONObject parame;
|
||||
private KProgressHUD hud;
|
||||
public static String excelName="excelData";
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_excel);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
hud = Utils.showLoading(this, "请稍后", "文件正在下载中");
|
||||
if (intent != null) {
|
||||
String parameter = intent.getStringExtra("parameter");
|
||||
if (parameter != null) {
|
||||
try {
|
||||
parame = new JSONObject(parameter);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
excel = new ExcelUtils(this);
|
||||
ConstraintLayout layout = findViewById(R.id.layout);
|
||||
layout.addView(excel.getReader(), ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT);
|
||||
initData();
|
||||
}
|
||||
SharedPreferences sp;
|
||||
private void initData() {
|
||||
try {
|
||||
sp=getSharedPreferences(excelName,MODE_PRIVATE);
|
||||
File path = new File(Utils.getAppPath() + "/data/");
|
||||
if (!path.exists()) {
|
||||
path.mkdirs();
|
||||
downlaodFile();
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(Utils.getAppPath() + "/data/" + parame.getString("fileName"));
|
||||
if (!file.exists()) {
|
||||
downlaodFile();
|
||||
|
||||
return;
|
||||
}
|
||||
if(!sp.getString(parame.getString("name"),"").equals(parame.getString("fileVersion"))){
|
||||
downlaodFile();
|
||||
return;
|
||||
}
|
||||
initView();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void downlaodFile() {
|
||||
MaterialDialog dialog = new MaterialDialog(this);
|
||||
dialog.setTitle("资料缺失/过期");
|
||||
dialog.setMessage("检测到当前资料并不存在或需要更新,是否进行更新(建议在WIFI网络下进行)");
|
||||
dialog.setNegativeButton("取消", view -> {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
});
|
||||
dialog.setPositiveButton("确定", view -> {
|
||||
dialog.dismiss();
|
||||
hud.show();
|
||||
try {
|
||||
HttpUtils.downloadFile(parame.getString("url"), Utils.getAppPath() + "/data/", new DownloadFileInerface() {
|
||||
String fileName;
|
||||
@Override
|
||||
public boolean downloading(String fileName, int current, long length) {
|
||||
this.fileName=fileName;
|
||||
AppData.handler.post(()->hud.setDetailsLabel("下载中 "+current+"/100"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void over(boolean isOver) {
|
||||
if(!isOver){
|
||||
hud.dismiss();
|
||||
Utils.toast(ExcelActivity.this,"下载失败");
|
||||
return;
|
||||
}
|
||||
if(sp==null){
|
||||
sp=getSharedPreferences(excelName,MODE_PRIVATE);
|
||||
}
|
||||
try {
|
||||
File file= new File(Utils.getAppPath()+"/data/"+fileName);
|
||||
File newFile=new File(Utils.getAppPath()+"/data/"+parame.getString("fileName"));
|
||||
file.renameTo(newFile);
|
||||
sp.edit().putString(parame.getString("name"),parame.getString("fileVersion")).apply();
|
||||
if(parame.getBoolean("default"))
|
||||
sp.edit().putString("default",newFile.getAbsolutePath()).apply();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
hud.dismiss();
|
||||
Utils.toast(ExcelActivity.this,"下载完成");
|
||||
initView();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
hud.dismiss();
|
||||
Utils.toast(ExcelActivity.this,"下载失败");
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
try {
|
||||
File file = new File(Utils.getAppPath() + "/data/" + parame.getString("fileName"));
|
||||
// file = new File("/storage/emulated/0/jianRMG/data/jianrData.xlsx");
|
||||
System.out.println(file.getAbsolutePath()+" "+file.exists());
|
||||
excel.start(file);
|
||||
setTitle(parame.getString("name")+" by-"+parame.getString("by"));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
excel.stop();
|
||||
}
|
||||
}
|
@ -1,14 +1,136 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Adapters.ModRecyclerAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.lemon.view.RefreshRecyclerView;
|
||||
import cn.lemon.view.adapter.Action;
|
||||
|
||||
public class FavoritesActivity extends AppCompatActivity {
|
||||
private static final String TAG = "收藏夹";
|
||||
private RefreshRecyclerView recyclerView;
|
||||
private ModRecyclerAdapter adapter;
|
||||
private List<TMod> modList;
|
||||
private Handler handler;
|
||||
private boolean isReload = false, isNext = true;
|
||||
private int con = 0, max = 10;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favorite);
|
||||
handler = new Handler();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
recyclerView.setSwipeRefreshColors(0xFF437845, 0xFFE44F98, 0xFF2FAC21);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
adapter = new ModRecyclerAdapter(this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addRefreshAction(new Action() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
con = 0;
|
||||
max = 10;
|
||||
isReload = true;
|
||||
getData();
|
||||
}
|
||||
});
|
||||
recyclerView.setLoadMoreAction(new Action() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
con = max;
|
||||
max += 10;
|
||||
isReload = false;
|
||||
getData();
|
||||
}
|
||||
});
|
||||
recyclerView.showSwipeRefresh();
|
||||
getData();
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
try {
|
||||
modList = new ArrayList<>();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("min", con);
|
||||
json.put("max", max);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_LIST_COLLCET, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(string);
|
||||
final String msg = json.getString("msg");
|
||||
if (json.getInt("code") != 100) {
|
||||
Log.i(TAG, string);
|
||||
handler.post(() -> {
|
||||
Utils.toast(FavoritesActivity.this, msg);
|
||||
recyclerView.destroyDrawingCache();
|
||||
});
|
||||
return;
|
||||
}
|
||||
modList = Utils.ListRemoveNull(JSON.parseArray(json.getString("data"), TMod.class));
|
||||
isNext = json.getBoolean("next");
|
||||
handler.post(() -> setData());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setData() {
|
||||
System.out.println("列表数量");
|
||||
System.out.println(modList.size());
|
||||
recyclerView.dismissSwipeRefresh();
|
||||
if (isReload) {
|
||||
adapter.clear();
|
||||
adapter.addAll(modList);
|
||||
// recyclerView.getRecyclerView().scrollToPosition(0);
|
||||
} else {
|
||||
adapter.addAll(modList);
|
||||
}
|
||||
if (!isNext)
|
||||
recyclerView.showNoMore();
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
||||
|
316
app/src/main/java/com/yutou/jianrmg_v2/views/HomeHeader.java
Normal file
@ -0,0 +1,316 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bigkoo.convenientbanner.ConvenientBanner;
|
||||
import com.bigkoo.convenientbanner.holder.Holder;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.qq.e.ads.banner2.UnifiedBannerADListener;
|
||||
import com.qq.e.ads.banner2.UnifiedBannerView;
|
||||
import com.qq.e.comm.util.AdError;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MAppHomeConfig;
|
||||
import com.yutou.jianrmg_v2.Data.MBanner;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class HomeHeader {
|
||||
private static final String APPID = "1105364182";
|
||||
private static final String POSID = "7040360034176735";
|
||||
private static HomeHeader header;
|
||||
private MAppHomeConfig homeConfig;
|
||||
private ConvenientBanner banner;
|
||||
private Context context;
|
||||
private ImageLoader imageLoader;
|
||||
private LinearLayout layout;
|
||||
private LinearLayout home, action;
|
||||
|
||||
private TextView hitokoto, from, time;
|
||||
private Timer timer;
|
||||
private boolean isFlash = false;
|
||||
private Handler handler;
|
||||
|
||||
public static HomeHeader getHome(Context context) {
|
||||
if (header == null) {
|
||||
System.out.println("初始化头部");
|
||||
header = new HomeHeader(context);
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
private HomeHeader(Context context) {
|
||||
this.context = context;
|
||||
handler = new Handler();
|
||||
initBanner();
|
||||
initGameActivity();
|
||||
isFlash = true;
|
||||
imageLoader = Utils.initImageLoader(context);
|
||||
layout = new LinearLayout(context);
|
||||
home = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.item_home, null, true);
|
||||
hitokoto = home.findViewById(R.id.hitokoto);
|
||||
from = home.findViewById(R.id.from);
|
||||
time = home.findViewById(R.id.action_time);
|
||||
action = home.findViewById(R.id.action);
|
||||
timer = new Timer();
|
||||
|
||||
action.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (homeConfig != null) {
|
||||
Utils.openWebView(homeConfig.getUrl());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void startGameActivity() {
|
||||
timer.schedule(new TimerTask() {
|
||||
private String text;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
isFlash = true;
|
||||
long nowDate = System.currentTimeMillis();
|
||||
Date action_time = null;
|
||||
if (nowDate < homeConfig.getStartdate().getTime()) {
|
||||
text = homeConfig.getName() + "\n距离活动开始:";
|
||||
action_time = homeConfig.getStartdate();
|
||||
}
|
||||
if (nowDate > homeConfig.getStartdate().getTime() && nowDate < homeConfig.getEnddate().getTime()) {
|
||||
text = homeConfig.getName() + "\n距离活动结束:";
|
||||
action_time = homeConfig.getEnddate();
|
||||
}
|
||||
if(nowDate > homeConfig.getEnddate().getTime()){
|
||||
text ="\n活动已结束~";
|
||||
action_time=null;
|
||||
}
|
||||
if (action_time != null) {
|
||||
long now_time = System.currentTimeMillis() / 1000;
|
||||
long activityTime = action_time.getTime() / 1000;
|
||||
long s = (activityTime - now_time) % 60;
|
||||
long m = (activityTime - now_time) / 60 % 60;
|
||||
long h = (activityTime - now_time) / 60 / 60;
|
||||
text += h + ":" + m + ":" + s;
|
||||
}
|
||||
handler.post(() -> time.setText(text));
|
||||
|
||||
}
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
//flashHome();
|
||||
layout.removeAllViews();
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
banner = new ConvenientBanner(getContext());
|
||||
ViewGroup.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 400);
|
||||
banner.setLayoutParams(params);
|
||||
layout.addView(banner);
|
||||
layout.addView(home);
|
||||
showAdBanner();
|
||||
return layout;
|
||||
}
|
||||
private void showAdBanner(){
|
||||
UnifiedBannerView bannerView=new UnifiedBannerView((Activity) context, APPID, POSID, new UnifiedBannerADListener() {
|
||||
@Override
|
||||
public void onNoAD(AdError adError) {
|
||||
Utils.toast(getContext(),adError.getErrorMsg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADReceive() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADExposure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADClosed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADClicked() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADLeftApplication() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADOpenOverlay() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onADCloseOverlay() {
|
||||
|
||||
}
|
||||
});
|
||||
bannerView.loadAD();
|
||||
layout.addView(bannerView);
|
||||
}
|
||||
|
||||
public void setBanner(List<MBanner> list) {
|
||||
banner.setCanLoop(true);
|
||||
banner.startTurning(2000);
|
||||
banner.setPages(() -> new Banner(), list).setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT);
|
||||
}
|
||||
|
||||
public void flashHome() {
|
||||
if (!isFlash) {
|
||||
return;
|
||||
}
|
||||
isFlash = false;
|
||||
System.out.println("刷新一言");
|
||||
HttpUtils.get(HttpApi.HITOKOTO_API, new HttpInterface() {
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
json = new JSONObject(string);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
AppData.handler.post(() -> {
|
||||
try {
|
||||
hitokoto.setText(json.getString("hitokoto"));
|
||||
from.setText("---" + json.getString("from"));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initBanner() {
|
||||
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.BANNER, new HttpInterface() {
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
final List<MBanner> array;
|
||||
try {
|
||||
Log.i("banner", string);
|
||||
JSONObject json = new JSONObject(string);
|
||||
|
||||
if (json.getInt("code") == 100) {
|
||||
array = JSON.parseArray(json.getString("data"), MBanner.class);
|
||||
} else {
|
||||
array = new ArrayList<>();
|
||||
}
|
||||
AppData.handler.post(() -> setBanner(array));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initGameActivity() {
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.MG_GAME_ACTIVITY, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json = new JSONObject(string);
|
||||
if (json.getInt("code") == 100) {
|
||||
JSONObject data = new JSONObject(json.getString("data"));
|
||||
homeConfig = new MAppHomeConfig();
|
||||
homeConfig.setName(data.getString("name"));
|
||||
homeConfig.setUrl(data.getString("url"));
|
||||
homeConfig.setStartdate(new Date(data.getLong("startdate")));
|
||||
homeConfig.setEnddate(new Date(data.getLong("enddate")));
|
||||
homeConfig.setState(data.getInt("state"));
|
||||
if (homeConfig.getState() == 1 || homeConfig.getState() == -1) {
|
||||
handler.postDelayed(() -> startGameActivity(), 300);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
handler.post(() -> time.setText("咕咕咕?"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class Banner implements Holder<MBanner> {
|
||||
private ImageView imageView;
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
imageView = new ImageView(context);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
return imageView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateUI(Context context, int position, final MBanner data) {
|
||||
imageLoader.displayImage(data.getUrl(), imageView);
|
||||
imageView.setOnClickListener(view -> {
|
||||
Intent intent;
|
||||
if(data.getClick().startsWith("appWeb")){
|
||||
intent = new Intent(getContext(),WebActivity.class);
|
||||
intent.putExtra("url",data.getClick().substring(6));
|
||||
}else {
|
||||
intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(data.getClick()));
|
||||
}
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Data.MAppLicense;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class LicenseActivity extends AppCompatActivity {
|
||||
ListView listView;
|
||||
List<String> licenseListName;
|
||||
private Handler handler;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
listView=new ListView(this);
|
||||
initLicenseName();
|
||||
handler=new Handler();
|
||||
ArrayAdapter adapter= new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, licenseListName);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setOnItemClickListener((adapterView, view, i, l) -> getLicense(licenseListName.get(i)));
|
||||
setContentView(listView);
|
||||
}
|
||||
private MAppLicense license;
|
||||
private void getLicense(String name){
|
||||
try{
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("name",name);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.SYSTEM_LICENSE,json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
license= JSON.parseObject(new JSONObject(string).getJSONObject("data").toString(),MAppLicense.class);
|
||||
handler.post(this::showDialog);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void showDialog(){
|
||||
MaterialDialog dialog=new MaterialDialog(LicenseActivity.this);
|
||||
dialog.setTitle(license.getName());
|
||||
dialog.setMessage(license.getLicense());
|
||||
dialog.setNegativeButton("前往Git", view -> {
|
||||
Intent intent=new Intent(LicenseActivity.this,WebActivity.class);
|
||||
intent.putExtra("url",license.getUrl());
|
||||
startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.setPositiveButton("关闭",view -> dialog.dismiss());
|
||||
dialog.show();
|
||||
}
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void initLicenseName(){
|
||||
licenseListName=new ArrayList<>();
|
||||
licenseListName.add("okhttp");
|
||||
licenseListName.add("FastJson");
|
||||
licenseListName.add("Android-ConvenientBanner");
|
||||
licenseListName.add("Android-Universal-Image-Loader");
|
||||
licenseListName.add("SmartTabLayout");
|
||||
licenseListName.add("KProgressHUD");
|
||||
licenseListName.add("ClassicLinesEditView");
|
||||
licenseListName.add("LFilePicker");
|
||||
licenseListName.add("RichText");
|
||||
licenseListName.add("dialogplus");
|
||||
licenseListName.add("QRCodeReaderView");
|
||||
licenseListName.add("PagerBottomTabStrip-master");
|
||||
licenseListName.add("RecyclerView");
|
||||
licenseListName.add("android-shape-imageview");
|
||||
licenseListName.add("glide-transformations");
|
||||
licenseListName.add("MPAndroidChart");
|
||||
licenseListName.add("Nice Spinner");
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
@ -16,14 +15,14 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Adapters.ReModListAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Data.TModtag;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Interfaces.ModInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
@ -31,24 +30,23 @@ import com.yutou.jianrmg_v2.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.Tools.ModUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.zzhoujay.richtext.RichText;
|
||||
import com.zzhoujay.richtext.RichType;
|
||||
import com.zzhoujay.richtext.ig.DefaultImageGetter;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/26.
|
||||
*/
|
||||
|
||||
public class ModActivity extends AppCompatActivity{
|
||||
public class ModActivity extends AppCompatActivity {
|
||||
private TMod tMod;
|
||||
private ImageView modImage, icon, collection_img;
|
||||
private TextView title, by, downloadText,richText;
|
||||
private TextView title, by, downloadText, richText;
|
||||
private LinearLayout tagsLayout;
|
||||
private FrameLayout collection, share, download;
|
||||
private ListView quote;
|
||||
@ -56,44 +54,85 @@ public class ModActivity extends AppCompatActivity{
|
||||
private ImageLoader imageLoader;
|
||||
private Handler handler;
|
||||
private ModUtils modUtils;
|
||||
private KProgressHUD hud;
|
||||
|
||||
private List<TMod> remods;
|
||||
private Context context;
|
||||
private Intent intent;
|
||||
private static final String TAG="ModActivity";
|
||||
private static final String TAG = "ModActivity";
|
||||
|
||||
public ModActivity(){
|
||||
public ModActivity() {
|
||||
Log.i("初始化mod列表");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_mod);
|
||||
intent=getIntent();
|
||||
tMod = JSON.parseObject(intent.getStringExtra("mod"), TMod.class);
|
||||
context=this;
|
||||
imageLoader = Utils.initImageLoader(context);
|
||||
intent = getIntent();
|
||||
handler = new Handler();
|
||||
tMod = JSON.parseObject(intent.getStringExtra("mod"), TMod.class);
|
||||
String modId=intent.getStringExtra("modId");
|
||||
if(modId!=null){
|
||||
hud=Utils.showLoading(this,null,null);
|
||||
hud.show();
|
||||
initMod(modId);
|
||||
}else {
|
||||
init();
|
||||
}
|
||||
}
|
||||
private void init(){
|
||||
context = this;
|
||||
imageLoader = Utils.initImageLoader(context);
|
||||
modUtils = ModUtils.init(context);
|
||||
modUtils.setMod(tMod);
|
||||
initViews();
|
||||
initData(tMod);
|
||||
initTags(tMod.getId());
|
||||
getRemod();
|
||||
if(hud!=null&&hud.isShowing()){
|
||||
hud.dismiss();
|
||||
}
|
||||
}
|
||||
private void initMod(String modId){
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
array.put(modId);
|
||||
json.put("ids",array);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_MODS, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
List<TMod> list=JSON.parseArray(json.getJSONArray("data").toString(), TMod.class);
|
||||
if(list.size()>0){
|
||||
tMod=list.get(0);
|
||||
handler.post(() -> init());
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
private void initViews() {
|
||||
modImage = findViewById(R.id.ModImage);
|
||||
icon = findViewById(R.id.icon);
|
||||
collection_img = findViewById(R.id.collection_img);
|
||||
title = findViewById(R.id.title);
|
||||
by = findViewById(R.id.by);
|
||||
richText =findViewById(R.id.richText);
|
||||
richText = findViewById(R.id.richText);
|
||||
tagsLayout = findViewById(R.id.tags);
|
||||
collection = findViewById(R.id.collection);
|
||||
share = findViewById(R.id.share);
|
||||
@ -103,9 +142,8 @@ public class ModActivity extends AppCompatActivity{
|
||||
}
|
||||
|
||||
private void initData(final TMod tMod) {
|
||||
List<MGamePackname> installClick=modUtils.getInstallClens();
|
||||
System.out.println("---------->"+AppData.appConfig.getDownloadhome() + tMod.getImage());
|
||||
System.out.println("---------->"+AppData.appConfig.getDownloadhome() + tMod.getIcon());
|
||||
Log.i(TAG,"---------->" + AppData.appConfig.getDownloadhome() + tMod.getImage());
|
||||
Log.i(TAG,"---------->" + AppData.appConfig.getDownloadhome() + tMod.getIcon());
|
||||
imageLoader.displayImage(AppData.appConfig.getDownloadhome() + tMod.getImage(), modImage);
|
||||
imageLoader.displayImage(AppData.appConfig.getDownloadhome() + tMod.getIcon(), icon);
|
||||
title.setText(tMod.getTitle());
|
||||
@ -115,19 +153,12 @@ public class ModActivity extends AppCompatActivity{
|
||||
//.type(RichType.html)
|
||||
.into(richText);
|
||||
downloadText.setTag(0);
|
||||
if (ModUtils.getModPath(tMod).listFiles().length > 0) {
|
||||
if (ModUtils.getModPath(tMod,"",true).listFiles().length > 0) {
|
||||
downloadText.setText("安装");
|
||||
downloadText.setTag(2);
|
||||
}
|
||||
download.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
downloadButtonClick();
|
||||
}
|
||||
});
|
||||
collection.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
download.setOnClickListener(view -> downloadButtonClick());
|
||||
collection.setOnClickListener(view -> {
|
||||
if (Utils.testStringIsNull(AppData.Token)) {
|
||||
Utils.toast(context, "登录状态未知,请登录哦");
|
||||
return;
|
||||
@ -138,6 +169,7 @@ public class ModActivity extends AppCompatActivity{
|
||||
json.put("mid", tMod.getId() + "");
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_COLLCETION, json, new HttpInterface() {
|
||||
private String state = "收藏失败,未知错误";
|
||||
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
|
||||
@ -157,7 +189,8 @@ public class ModActivity extends AppCompatActivity{
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
Log.e(e,ModActivity.this);
|
||||
}
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
@ -176,8 +209,8 @@ public class ModActivity extends AppCompatActivity{
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
e.printStackTrace();
|
||||
Log.e(e, ModActivity.class);
|
||||
}
|
||||
});
|
||||
|
||||
@ -205,7 +238,8 @@ public class ModActivity extends AppCompatActivity{
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
Log.e(e,ModActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +249,8 @@ public class ModActivity extends AppCompatActivity{
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
Log.e(e,ModActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,23 +260,12 @@ public class ModActivity extends AppCompatActivity{
|
||||
|
||||
break;
|
||||
case 1:
|
||||
modUtils.reBackMod(tMod,new ModInterface(){
|
||||
@Override
|
||||
public void onAction(boolean flag, int type) {
|
||||
Log.i(TAG,"还原mod:"+flag);
|
||||
}
|
||||
});
|
||||
modUtils.reBackMod(tMod, (flag, type) -> Log.i(TAG, "还原mod:" + flag));
|
||||
|
||||
break;
|
||||
case 0:
|
||||
case 2:
|
||||
modUtils.installMod(tMod,new ModInterface(){
|
||||
|
||||
@Override
|
||||
public void onAction(boolean flag, int type) {
|
||||
Log.i(TAG,"安装mod:"+flag);
|
||||
}
|
||||
});
|
||||
modUtils.installMod(tMod, (flag, type) -> Log.i(TAG, "安装mod:" + flag));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -264,8 +288,8 @@ public class ModActivity extends AppCompatActivity{
|
||||
@Override
|
||||
public void run() {
|
||||
for (TModtag tag : tags) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Utils.getPixelsFromDp(((Activity)context), 50), Utils.getPixelsFromDp(((Activity)context), 15));
|
||||
params.setMargins(Utils.getPixelsFromDp(((Activity)context), 10), 0, 0, 0);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Utils.getPixelsFromDp(((Activity) context), 50), Utils.getPixelsFromDp(((Activity) context), 15));
|
||||
params.setMargins(Utils.getPixelsFromDp(((Activity) context), 10), 0, 0, 0);
|
||||
Button button = new Button(context);
|
||||
button.setText(tag.getTag());
|
||||
button.setTextSize(8);
|
||||
@ -288,7 +312,18 @@ public class ModActivity extends AppCompatActivity{
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.MAppMg;
|
||||
import com.yutou.jianrmg_v2.Fragments.ModListFragment_0;
|
||||
@ -82,5 +83,15 @@ public class ModListActivity extends AppCompatActivity{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,152 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.LoadingActivity;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ActivitysManager;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
private TextView textView2;
|
||||
private EditText userName;
|
||||
private EditText editText2;
|
||||
private EditText password;
|
||||
private EditText rePassword;
|
||||
private Button login;
|
||||
private Button register;
|
||||
private ImageView ovo;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
textView2 = findViewById(R.id.textView2);
|
||||
userName = findViewById(R.id.userName);
|
||||
editText2 = findViewById(R.id.editText2);
|
||||
password = findViewById(R.id.password);
|
||||
rePassword = findViewById(R.id.rePassword);
|
||||
login = findViewById(R.id.login);
|
||||
register = findViewById(R.id.register);
|
||||
ovo = findViewById(R.id.ovo);
|
||||
|
||||
|
||||
login.setOnClickListener(this);
|
||||
register.setOnClickListener(this);
|
||||
ovo.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.login:
|
||||
finish();
|
||||
break;
|
||||
case R.id.register:
|
||||
if(submit()){
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("uname",userName.getText().toString());
|
||||
json.put("name",editText2.getText().toString());
|
||||
json.put("pass",password.getText().toString());
|
||||
HttpUtils.post(HttpApi.HOME_URL+HttpApi.USER_REG, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json.getInt("code")==200){
|
||||
ActivitysManager.finishActivity(LoadingActivity.class);
|
||||
Intent intent=new Intent(RegisterActivity.this, LoadingActivity.class);
|
||||
intent.putExtra("name",userName.getText().toString());
|
||||
intent.putExtra("password",password.getText().toString());
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}else{
|
||||
Utils.toast(RegisterActivity.this,json.getString("msg"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
Utils.toast(RegisterActivity.this,e.getMessage());
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R.id.ovo:
|
||||
Utils.toast(getApplicationContext(),"OvO?");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean submit() {
|
||||
// validate
|
||||
String userNameString = userName.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(userNameString)) {
|
||||
Toast.makeText(this, "登录账号(字母+数字)", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
String editText2String = editText2.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(editText2String)) {
|
||||
Toast.makeText(this, "用户名(可中文)", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
String passwordString = password.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(passwordString)) {
|
||||
Toast.makeText(this, "密码", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
String rePasswordString = rePassword.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(rePasswordString)) {
|
||||
Toast.makeText(this, "再输入一次密码", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if(!passwordString.equals(rePasswordString)){
|
||||
Toast.makeText(this, "密码不一致", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
// TODO validate success, do something
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TestActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
TextView textView=new TextView(this);
|
||||
textView.setText("没有数据");
|
||||
setContentView(textView);
|
||||
}
|
||||
|
||||
}
|
112
app/src/main/java/com/yutou/jianrmg_v2/views/UpFeedBack.java
Normal file
@ -0,0 +1,112 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.classichu.lineseditview.LinesEditView;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.SystemData;
|
||||
import com.yutou.jianrmg_v2.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ActivitysManager;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class UpFeedBack extends AppCompatActivity {
|
||||
private LinesEditView editView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_feedback);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
editView = findViewById(R.id.linesEditView);
|
||||
TextView info = findViewById(R.id.info);
|
||||
Button button = findViewById(R.id.button);
|
||||
Switch aSwitch = findViewById(R.id.switch1);
|
||||
info.setText(new SystemData().toString());
|
||||
aSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (!isChecked) {
|
||||
MaterialDialog dialog = new MaterialDialog(UpFeedBack.this);
|
||||
dialog.setTitle("提示");
|
||||
dialog.setMessage("关闭采集可能让我们无法查明原因哦~\n采集内容并不包含隐私问题请放心");
|
||||
dialog.setNegativeButton("允许采集", view -> {aSwitch.setChecked(true);dialog.dismiss();});
|
||||
dialog.setPositiveButton("我拒绝", view -> {aSwitch.setChecked(false);dialog.dismiss();});
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
button.setOnClickListener(v -> {
|
||||
String context = editView.getContentText();
|
||||
if (context.trim().length() == 0) {
|
||||
Utils.toast(UpFeedBack.this, "请不要提交空内容");
|
||||
return;
|
||||
}
|
||||
editView.setEnabled(false);
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("context", editView.getContentText().trim());
|
||||
if (aSwitch.isChecked())
|
||||
json.put("sysinfo", new SystemData().toString());
|
||||
else {
|
||||
json.put("sysinfo","User say:NO!");
|
||||
}
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.SYSTEM_UP_INFO, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
String msg = "error";
|
||||
try {
|
||||
JSONObject json = new JSONObject(string);
|
||||
msg = json.getString("msg");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String finalMsg = msg;
|
||||
AppData.handler.post(() -> {
|
||||
Utils.toast(UpFeedBack.this, finalMsg);
|
||||
if (finalMsg.equals("提交成功")) {
|
||||
ActivitysManager.finishActivity(UpFeedBack.class);
|
||||
} else {
|
||||
editView.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
AppData.handler.post(() -> Utils.toast(UpFeedBack.this, "网络错误"));
|
||||
editView.setEnabled(true);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.leon.lfilepickerlibrary.LFilePicker;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.Data.TMod;
|
||||
import com.yutou.jianrmg_v2.Data.TModfile;
|
||||
import com.yutou.jianrmg_v2.Data.TModfilePath;
|
||||
import com.yutou.jianrmg_v2.Interfaces.ModInterface;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.ModUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.RootUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class UserDefinedActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
private Button srcFile;
|
||||
private Spinner outPath;
|
||||
private Spinner packageName;
|
||||
private Button execute;
|
||||
private TextView logcat;
|
||||
private Handler handler;
|
||||
private List<String> pName;
|
||||
private List<File> files;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_user_defined);
|
||||
handler = new Handler();
|
||||
files = new ArrayList<>();
|
||||
pName = new ArrayList<>();
|
||||
initView();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initView() {
|
||||
srcFile = findViewById(R.id.srcFile);
|
||||
outPath = findViewById(R.id.outPath);
|
||||
packageName = findViewById(R.id.packageName);
|
||||
execute = findViewById(R.id.execute);
|
||||
logcat = findViewById(R.id.logcat);
|
||||
|
||||
srcFile.setOnClickListener(this);
|
||||
execute.setOnClickListener(this);
|
||||
|
||||
Utils.initGamePackName();
|
||||
Utils.initInstallPath();
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (AppData.packnames == null || AppData.packnames.size() == 0) {
|
||||
Utils.initGamePackName();
|
||||
} else if (AppData.installPath == null || AppData.installPath.size() == 0) {
|
||||
Utils.initGamePackName();
|
||||
} else {
|
||||
handler.post(() -> {
|
||||
List<String> title, out;
|
||||
title = new ArrayList<>();
|
||||
out = new ArrayList<>();
|
||||
for (MGamePackname packname : AppData.packnames) {
|
||||
pName.add(packname.getPackname());
|
||||
title.add(packname.getZhname());
|
||||
}
|
||||
for (TModfilePath modfilePath : AppData.installPath) {
|
||||
out.add(modfilePath.getPath());
|
||||
}
|
||||
outPath.setAdapter(new ArrayAdapter<>(UserDefinedActivity.this, android.R.layout.simple_spinner_dropdown_item, out));
|
||||
packageName.setAdapter(new ArrayAdapter<>(UserDefinedActivity.this, android.R.layout.simple_spinner_dropdown_item, title));
|
||||
cancel();
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 0, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.srcFile:
|
||||
new LFilePicker()
|
||||
.withActivity(this)
|
||||
.withRequestCode(100)
|
||||
.withStartPath(Environment.getExternalStorageDirectory().getPath()+"/jianRMG")//指定初始显示路径
|
||||
.withIsGreater(false)//过滤文件大小 小于指定大小的文件
|
||||
.withMutilyMode(true)
|
||||
.withFileSize(5*1024*1024)//指定文件大小为500K
|
||||
.start();
|
||||
break;
|
||||
case R.id.execute:
|
||||
if(!AppData.packnames.get(packageName.getSelectedItemPosition()).getZhname().contains("[ROOT]")){
|
||||
ModUtils modUtils=ModUtils.init(UserDefinedActivity.this);
|
||||
for (File file : files) {
|
||||
modUtils.notRootInstall(file, outPath.getSelectedItem().toString());
|
||||
}
|
||||
modUtils.notRootInstallStart(new ModInterface() {
|
||||
@Override
|
||||
public void onAction(boolean flag, int type) {
|
||||
if(flag){
|
||||
handler.post(()->logcat.append("\n复制成功"));
|
||||
}else{
|
||||
handler.post(()->logcat.append("\n复制失败"));
|
||||
}
|
||||
}
|
||||
},false);
|
||||
return;
|
||||
}
|
||||
boolean flag = false, flag2 = false;
|
||||
if (files.size() == 0) {
|
||||
logcat.append("\n未选择任何文件");
|
||||
return;
|
||||
}
|
||||
for (File file : files) {
|
||||
logcat.append("\n执行复制:" + file.getAbsolutePath() + " 到" + outPath.getSelectedItem().toString());
|
||||
flag = RootUtils.init(this).exec("cp -r -f " + file.getAbsolutePath() + " /data/data/" + pName.get(packageName.getSelectedItemPosition()) + outPath.getSelectedItem().toString());
|
||||
flag2 = RootUtils.init(this).exec("chmod 777" + " /data/data/" + pName.get(packageName.getSelectedItemPosition()) + outPath.getSelectedItem().toString() + file.getName());
|
||||
RootUtils.init(this).exec("chmod +x" + " /data/data/" + pName.get(packageName.getSelectedItemPosition()) + outPath.getSelectedItem().toString() + file.getName());
|
||||
if(!flag){
|
||||
logcat.append("\n复制失败:"+file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
if (flag && flag2) {
|
||||
logcat.append("\n操作成功");
|
||||
} else {
|
||||
logcat.append("\n操作失败");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == 100) {
|
||||
//如果是文件选择模式,需要获取选择的所有文件的路径集合
|
||||
files.clear();
|
||||
List<String> list = data.getStringArrayListExtra("paths");
|
||||
Toast.makeText(getApplicationContext(), "选中了" + list.size() + "个文件", Toast.LENGTH_SHORT).show();
|
||||
logcat.append("\n已选择 " + list.size() + "个文件");
|
||||
for (String s : list) {
|
||||
logcat.append("\n" + s);
|
||||
files.add(new File(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
219
app/src/main/java/com/yutou/jianrmg_v2/views/WarView.java
Normal file
@ -0,0 +1,219 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.yutou.jianrmg_v2.Adapters.MagicTeamDataAdapter;
|
||||
import com.yutou.jianrmg_v2.Data.TeamData;
|
||||
import com.yutou.jianrmg_v2.Databases.JianRDataDataBase;
|
||||
import com.yutou.jianrmg_v2.Tools.JianRUtils;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.services.MagicBoxService;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class WarView {
|
||||
private JSONObject data,message;
|
||||
private MagicTeamDataAdapter adapter;
|
||||
private JianRDataDataBase dataBase;
|
||||
private Context context;
|
||||
private int width=-1;
|
||||
private Handler handler;
|
||||
|
||||
public WarView(Context context, JSONObject warData, int width, Handler handler){
|
||||
this.data=warData;
|
||||
this.context=context;
|
||||
this.width=width;
|
||||
this.handler=handler;
|
||||
try {
|
||||
message=new JSONObject(data.getString("message"));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
private Timer timer;
|
||||
private String md5="";
|
||||
public void update(MagicBoxService service, int width){
|
||||
try{
|
||||
this.width=width;
|
||||
params.weight=width;
|
||||
linearLayout.setLayoutParams(params);
|
||||
if(timer==null){
|
||||
timer=new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
WarView.this.data=service.getDealNode();
|
||||
WarView.this.message=new JSONObject(data.getString("message"));
|
||||
if(!Utils.getMD5(WarView.this.message.toString()).equals(md5)){
|
||||
md5=Utils.getMD5(WarView.this.message.toString());
|
||||
|
||||
if((int)listView.getTag()==1){
|
||||
adapter.setData(getEnemyTeam(message));
|
||||
listView.setTag(0);
|
||||
}else {
|
||||
adapter.setData(getUserTeam(message));
|
||||
listView.setTag(1);
|
||||
}
|
||||
System.out.println("更新数据:"+adapter.getCount()+" "+listView.getTag());
|
||||
System.out.println(adapter.getItem(0).toString());
|
||||
handler.post(() -> adapter.notifyDataSetChanged());
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},0,500);
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private LinearLayout linearLayout;
|
||||
private Switch userTeam;
|
||||
private Button button;
|
||||
private ListView listView;
|
||||
private LinearLayout.LayoutParams params;
|
||||
public View initView() {
|
||||
if(linearLayout!=null){
|
||||
return linearLayout;
|
||||
}
|
||||
dataBase=JianRDataDataBase.init();
|
||||
linearLayout = new LinearLayout(context);
|
||||
params= new LinearLayout.LayoutParams(width, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
linearLayout.setLayoutParams(params);
|
||||
linearLayout.setBackgroundColor(Color.WHITE);
|
||||
|
||||
listView = new ListView(context);
|
||||
button = new Button(context);
|
||||
userTeam = new Switch(context);
|
||||
button.setText("切换队伍");
|
||||
button.setOnClickListener(view -> {
|
||||
if ((int) listView.getTag() == 1) {
|
||||
adapter.setData(getEnemyTeam(message));
|
||||
listView.setTag(0);
|
||||
} else {
|
||||
adapter.setData(getUserTeam(message));
|
||||
listView.setTag(1);
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
linearLayout.addView(button);
|
||||
|
||||
userTeam.setText("剧透");
|
||||
userTeam.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
adapter.setSpoiler(b);
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
linearLayout.addView(userTeam);
|
||||
|
||||
adapter = new MagicTeamDataAdapter(getUserTeam(message), context);
|
||||
ViewGroup.LayoutParams listParams=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setLayoutParams(listParams);
|
||||
listView.setTag(1);
|
||||
linearLayout.addView(listView);
|
||||
|
||||
return linearLayout;
|
||||
}
|
||||
|
||||
private JSONObject loadData(File file) {
|
||||
try {
|
||||
JSONObject json;
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String str = "", tmp;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str += tmp;
|
||||
}
|
||||
reader.close();
|
||||
json = new JSONObject(str);
|
||||
return json;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<TeamData> getUserTeam(JSONObject json) {
|
||||
List<TeamData> data = new ArrayList<>();
|
||||
try {
|
||||
JSONObject warRepoot = message.getJSONObject("warReport");
|
||||
JSONArray selfShips = warRepoot.getJSONArray("selfShips");
|
||||
for (int i = 0; i < selfShips.length(); i++) {
|
||||
TeamData team = new TeamData();
|
||||
JSONObject js = selfShips.getJSONObject(i);
|
||||
team.setId(i);
|
||||
team.setHpMax(js.get("hpMax").toString());
|
||||
team.setTitle(js.getString("title"));
|
||||
team.setHp(warRepoot.getJSONArray("hpBeforeNightWarSelf").get(i).toString());
|
||||
team.setImageUrl("http://jianr.jianrmod.cn/jianr/ship/S_NORMAL_" + JianRUtils.jianCidToid(js.get("shipCid").toString()) + ".png");
|
||||
try {
|
||||
team.setItem1Url("http://jianr.jianrmod.cn/jianr/equipment/equip_L_" + JianRUtils.equipCidToid(js.getJSONArray("equipment").get(0).toString()) + ".png");
|
||||
team.setItem2Url("http://jianr.jianrmod.cn/jianr/equipment/equip_L_" + JianRUtils.equipCidToid(js.getJSONArray("equipment").get(1).toString()) + ".png");
|
||||
team.setItem3Url("http://jianr.jianrmod.cn/jianr/equipment/equip_L_" + JianRUtils.equipCidToid(js.getJSONArray("equipment").get(2).toString()) + ".png");
|
||||
team.setItem4Url("http://jianr.jianrmod.cn/jianr/equipment/equip_L_" + JianRUtils.equipCidToid(js.getJSONArray("equipment").get(3).toString()) + ".png");
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
team.setUser(true);
|
||||
team.setSrc(json);
|
||||
data.add(team);
|
||||
}
|
||||
return data;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private List<TeamData> getEnemyTeam(JSONObject json) {
|
||||
List<TeamData> data = new ArrayList<>();
|
||||
try {
|
||||
JSONObject warRepoot = message.getJSONObject("warReport");
|
||||
JSONArray selfShips = warRepoot.getJSONArray("enemyShips");
|
||||
for (int i = 0; i < selfShips.length(); i++) {
|
||||
TeamData team = new TeamData();
|
||||
JSONObject js = selfShips.getJSONObject(i);
|
||||
team.setId(i);
|
||||
team.setHpMax(js.get("hpMax").toString());
|
||||
team.setTitle(js.getString("title"));
|
||||
team.setHp(warRepoot.getJSONArray("hpBeforeNightWarEnemy").get(i).toString());
|
||||
team.setImageUrl("http://jianr.jianrmod.cn/jianr/ship/S_NORMAL_" + JianRUtils.EnemyShipCardId(js.get("shipCid").toString()) + ".png");
|
||||
team.setUser(false);
|
||||
team.setSrc(json);
|
||||
data.add(team);
|
||||
}
|
||||
return data;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
public void close(){
|
||||
timer.cancel();
|
||||
linearLayout.removeAllViews();
|
||||
linearLayout=null;
|
||||
timer=null;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Log;
|
||||
|
||||
@ -68,4 +69,15 @@ public class WebActivity extends AppCompatActivity{
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,252 @@
|
||||
package com.yutou.jianrmg_v2.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.yutou.jianrmg_v2.Databases.JianRDataDataBase;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.services.WindowsService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.drakeet.materialdialog.MaterialDialog;
|
||||
|
||||
public class WindowsStartActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
private Switch saveData;
|
||||
private Spinner dataType;
|
||||
private Button typeAdd;
|
||||
private Button typeRemove;
|
||||
private Spinner dataName;
|
||||
private Button nameAdd;
|
||||
private Button nameRemove;
|
||||
private LinearLayout dataConfig;
|
||||
private Button start;
|
||||
ArrayAdapter typeAdapter;
|
||||
ArrayAdapter nameAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_windows_start);
|
||||
JianRDataDataBase.init();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
saveData = findViewById(R.id.saveData);
|
||||
dataType = findViewById(R.id.dataType);
|
||||
typeAdd = findViewById(R.id.typeAdd);
|
||||
typeRemove = findViewById(R.id.typeRemove);
|
||||
dataName = findViewById(R.id.dataName);
|
||||
nameAdd = findViewById(R.id.nameAdd);
|
||||
nameRemove = findViewById(R.id.nameRemove);
|
||||
dataConfig = findViewById(R.id.dataConfig);
|
||||
start = findViewById(R.id.start);
|
||||
|
||||
typeAdd.setOnClickListener(this);
|
||||
typeRemove.setOnClickListener(this);
|
||||
nameAdd.setOnClickListener(this);
|
||||
nameRemove.setOnClickListener(this);
|
||||
start.setOnClickListener(this);
|
||||
|
||||
saveData.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
if (b) {
|
||||
dataConfig.setVisibility(View.VISIBLE);
|
||||
saveData.setTag(true);
|
||||
} else {
|
||||
dataConfig.setVisibility(View.GONE);
|
||||
saveData.setTag(false);
|
||||
}
|
||||
});
|
||||
saveData.setTag(true);
|
||||
typeAdapter=new ArrayAdapter<>(this,android.R.layout.simple_spinner_dropdown_item,getType());
|
||||
nameAdapter=new ArrayAdapter<>(this,android.R.layout.simple_spinner_dropdown_item,getName(null));
|
||||
dataName.setAdapter(nameAdapter);
|
||||
dataType.setAdapter(typeAdapter);
|
||||
dataType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
reloadSpinner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
});
|
||||
reloadSpinner();
|
||||
}
|
||||
private void reloadSpinner(){
|
||||
nameAdapter.clear();
|
||||
typeAdapter.clear();
|
||||
typeAdapter.addAll(getType());
|
||||
try {
|
||||
nameAdapter.addAll(getName(dataType.getSelectedItem().toString()));
|
||||
}catch (Exception e){
|
||||
nameAdapter.addAll(getName(null));
|
||||
}
|
||||
|
||||
nameAdapter.notifyDataSetChanged();
|
||||
typeAdapter.notifyDataSetChanged();
|
||||
}
|
||||
public List<String> getType() {
|
||||
List<String> list = new ArrayList<>();
|
||||
try {
|
||||
list.addAll(JianRDataDataBase.init().getTypes());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
list.add("-请从右侧按钮添加-");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> getName(String type) {
|
||||
List<String> list = new ArrayList<>();
|
||||
try {
|
||||
list.addAll(JianRDataDataBase.init().getNames(type));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
list.add("-请从右侧按钮添加-");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.typeAdd:
|
||||
saveType();
|
||||
break;
|
||||
case R.id.typeRemove:
|
||||
removeType();
|
||||
break;
|
||||
case R.id.nameAdd:
|
||||
saveName();
|
||||
break;
|
||||
case R.id.nameRemove:
|
||||
removeName();
|
||||
break;
|
||||
case R.id.start:
|
||||
Intent intent = new Intent(this, WindowsService.class);
|
||||
intent.putExtra("saveData", ((boolean) saveData.getTag()));
|
||||
if((boolean)saveData.getTag()) {
|
||||
intent.putExtra("dataType", dataType.getSelectedItem().toString());
|
||||
intent.putExtra("dataName", dataName.getSelectedItem().toString());
|
||||
}
|
||||
startService(intent);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeType() {
|
||||
MaterialDialog dialog = new MaterialDialog(this);
|
||||
dialog.setTitle("删除分类");
|
||||
dialog.setMessage("确定删除 " + dataType.getSelectedItem().toString() + " 分类?" +
|
||||
"\n删除后,该分类下的数据库将无法访问");
|
||||
dialog.setNegativeButton("取消", view -> dialog.dismiss());
|
||||
dialog.setPositiveButton("确定", view -> {
|
||||
try {
|
||||
JianRDataDataBase.init().removeType(dataType.getSelectedItem().toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reloadSpinner();
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
public void removeName() {
|
||||
MaterialDialog dialog = new MaterialDialog(this);
|
||||
dialog.setTitle("删除数据库");
|
||||
dialog.setMessage("确定删除 " + dataName.getSelectedItem().toString() + " 数据库?" +
|
||||
"\n删除后,该数据库将无法访问");
|
||||
dialog.setNegativeButton("取消", view -> dialog.dismiss());
|
||||
dialog.setPositiveButton("确定", view -> {
|
||||
try {
|
||||
if(dataType.getSelectedItem().toString().equals("-请从右侧按钮添加-")){
|
||||
Utils.toast(this, "请先选择分类");
|
||||
return;
|
||||
}
|
||||
JianRDataDataBase.init().removeName(dataName.getSelectedItem().toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reloadSpinner();
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public void saveType() {
|
||||
MaterialDialog dialog = new MaterialDialog(this);
|
||||
dialog.setTitle("添加分类");
|
||||
EditText editText = new EditText(this);
|
||||
editText.setHint("分类名称(如活动、日常、默认等自定义)");
|
||||
dialog.setContentView(editText);
|
||||
dialog.setNegativeButton("取消", view -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.setPositiveButton("保存", view -> {
|
||||
if (Utils.testStringIsNull(editText.getText().toString())) {
|
||||
Utils.toast(this, "请输入分类名称");
|
||||
editText.setText("默认");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JianRDataDataBase.init().addType(editText.getText().toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reloadSpinner();
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public void saveName() {
|
||||
MaterialDialog dialog = new MaterialDialog(this);
|
||||
dialog.setTitle("添加数据库");
|
||||
EditText editText = new EditText(this);
|
||||
editText.setHint("数据库名称(如活动、日常、默认等自定义)");
|
||||
dialog.setContentView(editText);
|
||||
dialog.setNegativeButton("取消", view -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.setPositiveButton("保存", view -> {
|
||||
if (Utils.testStringIsNull(editText.getText().toString())) {
|
||||
Utils.toast(this, "请输入数据库名称");
|
||||
editText.setText("默认");
|
||||
return;
|
||||
}
|
||||
if(dataType.getSelectedItem().toString().equals("-请从右侧按钮添加-")){
|
||||
Utils.toast(this, "请先选择分类");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JianRDataDataBase.init().addName(dataType.getSelectedItem().toString(),editText.getText().toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reloadSpinner();
|
||||
dialog.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
}
|
BIN
app/src/main/jniLibs/armeabi/liblbs.so
Normal file
@ -4,7 +4,7 @@
|
||||
android:fillBefore="false"
|
||||
android:duration="2000">
|
||||
<translate
|
||||
android:toYDelta="-10%p"
|
||||
android:toYDelta="-50%p"
|
||||
/>
|
||||
|
||||
</set>
|
BIN
app/src/main/res/drawable/gugugu.png
Normal file
After Width: | Height: | Size: 107 KiB |
BIN
app/src/main/res/drawable/ic_collection.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
app/src/main/res/drawable/ic_config.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
app/src/main/res/drawable/ic_download.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
app/src/main/res/drawable/ic_feedback.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
@ -2,169 +2,75 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillColor="#26A69A"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
android:viewportWidth="1800"
|
||||
android:viewportHeight="1800">
|
||||
<group android:translateX="846"
|
||||
android:translateY="846">
|
||||
<path android:fillColor="#008577"
|
||||
android:pathData="M0,0h108v108h-108z"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
BIN
app/src/main/res/drawable/icon_drop.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
app/src/main/res/drawable/icon_drop_select.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
app/src/main/res/drawable/icon_tools.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
app/src/main/res/drawable/icon_tools_select.png
Normal file
After Width: | Height: | Size: 3.5 KiB |