Skip to content
Permalink
Browse files

优化demo代码,demo添加代码使用示例

  • Loading branch information...
AriaLyy committed May 28, 2019
1 parent ce43e48 commit 7b15d4c0522c1efb7111c7fcfaa4b1a13fb5e279
Showing with 4,338 additions and 843 deletions.
  1. +24 −15 AppFrame/build.gradle
  2. +8 −0 AppFrame/proguard-rules.pro
  3. +13 −0 AppFrame/src/androidTest/java/com/lyy/frame/ApplicationTest.java
  4. +5 −7 AppFrame/src/main/AndroidManifest.xml
  5. +13 −0 AppFrame/src/main/java/com/arialyy/frame/base/BaseApp.java
  6. +108 −0 AppFrame/src/main/java/com/arialyy/frame/base/BaseDialog.java
  7. +19 −0 AppFrame/src/main/java/com/arialyy/frame/base/BaseFragment.java
  8. +20 −0 AppFrame/src/main/java/com/arialyy/frame/base/BaseViewModule.java
  9. +52 −0 AppFrame/src/main/java/com/arialyy/frame/base/StatusBarCompat.java
  10. +28 −0 AppFrame/src/main/java/com/arialyy/frame/base/net/BasicDeserializer.java
  11. +39 −0 AppFrame/src/main/java/com/arialyy/frame/base/net/HttpCallback.java
  12. +20 −0 AppFrame/src/main/java/com/arialyy/frame/base/net/INetResponse.java
  13. +23 −0 AppFrame/src/main/java/com/arialyy/frame/base/net/JsonCodeAnalysisUtil.java
  14. +112 −0 AppFrame/src/main/java/com/arialyy/frame/base/net/NetManager.java
  15. +65 −0 AppFrame/src/main/java/com/arialyy/frame/base/net/OkHttpLogger.java
  16. +100 −119 AppFrame/src/main/java/com/arialyy/frame/cache/AbsCache.java
  17. +3 −3 AppFrame/src/main/java/com/arialyy/frame/cache/CacheParam.java
  18. +16 −80 AppFrame/src/main/java/com/arialyy/frame/cache/CacheUtil.java
  19. +968 −0 AppFrame/src/main/java/com/arialyy/frame/cache/DiskLruCache.java
  20. +21 −0 AppFrame/src/main/java/com/arialyy/frame/cache/PathConstaant.java
  21. +9 −0 AppFrame/src/main/java/com/arialyy/frame/config/CommonConstant.java
  22. +9 −0 AppFrame/src/main/java/com/arialyy/frame/config/NetConstant.java
  23. +20 −18 AppFrame/src/main/java/com/arialyy/frame/core/AbsActivity.java
  24. +10 −5 AppFrame/src/main/java/com/arialyy/frame/core/AbsAlertDialog.java
  25. +0 −3 AppFrame/src/main/java/com/arialyy/frame/core/AbsDialog.java
  26. +5 −4 AppFrame/src/main/java/com/arialyy/frame/core/AbsDialogFragment.java
  27. +0 −1 AppFrame/src/main/java/com/arialyy/frame/core/AbsFragment.java
  28. +20 −35 AppFrame/src/main/java/com/arialyy/frame/core/AbsFrame.java
  29. +4 −6 AppFrame/src/main/java/com/arialyy/frame/core/AbsPopupWindow.java
  30. +3 −3 AppFrame/src/main/java/com/arialyy/frame/core/BindingFactory.java
  31. +8 −4 AppFrame/src/main/java/com/arialyy/frame/core/CrashHandler.java
  32. +4 −2 AppFrame/src/main/java/com/arialyy/frame/core/DialogSimpleModule.java
  33. +1 −3 AppFrame/src/main/java/com/arialyy/frame/core/ModuleFactory.java
  34. +38 −24 AppFrame/src/main/java/com/arialyy/frame/http/HttpUtil.java
  35. +17 −4 AppFrame/src/main/java/com/arialyy/frame/module/AbsModule.java
  36. +8 −3 AppFrame/src/main/java/com/arialyy/frame/module/IOCProxy.java
  37. +1 −2 AppFrame/src/main/java/com/arialyy/frame/module/ModuleFactory.java
  38. +6 −4 AppFrame/src/main/java/com/arialyy/frame/permission/PermissionManager.java
  39. +4 −4 AppFrame/src/main/java/com/arialyy/frame/permission/PermissionUtil.java
  40. +2 −2 AppFrame/src/main/java/com/arialyy/frame/temp/AbsTempView.java
  41. +12 −6 AppFrame/src/main/java/com/arialyy/frame/temp/TempView.java
  42. +3 −1 AppFrame/src/main/java/com/arialyy/frame/util/AESEncryption.java
  43. +32 −54 AppFrame/src/main/java/com/arialyy/frame/util/AndroidUtils.java
  44. +4 −2 AppFrame/src/main/java/com/arialyy/frame/util/AppUtils.java
  45. +5 −5 AppFrame/src/main/java/com/arialyy/frame/util/DensityUtils.java
  46. +5 −4 AppFrame/src/main/java/com/arialyy/frame/util/DrawableUtil.java
  47. +22 −7 AppFrame/src/main/java/com/arialyy/frame/util/FileUtil.java
  48. +6 −5 AppFrame/src/main/java/com/arialyy/frame/util/KeyBoardUtils.java
  49. +83 −0 AppFrame/src/main/java/com/arialyy/frame/util/MediaUtil.java
  50. +4 −3 AppFrame/src/main/java/com/arialyy/frame/util/NetUtils.java
  51. +3 −2 AppFrame/src/main/java/com/arialyy/frame/util/RegularExpression.java
  52. +23 −13 AppFrame/src/main/java/com/arialyy/frame/util/ScreenUtil.java
  53. +2 −1 AppFrame/src/main/java/com/arialyy/frame/util/ShellUtils.java
  54. +1 −1 AppFrame/src/main/java/com/arialyy/frame/util/StringUtil.java
  55. +15 −11 AppFrame/src/main/java/com/arialyy/frame/util/show/FL.java
  56. +47 −21 AppFrame/src/main/java/com/arialyy/frame/util/show/L.java
  57. +18 −6 AppFrame/src/main/java/com/arialyy/frame/util/show/T.java
  58. +12 −12 AppFrame/src/main/res/drawable/selector_green_bt.xml
  59. +2 −2 AppFrame/src/main/res/layout/layout_error_temp.xml
  60. +3 −3 AppFrame/src/main/res/values/color.xml
  61. +1 −1 AppFrame/src/main/res/values/strings.xml
  62. +11 −11 AppFrame/src/main/res/values/style.xml
  63. +8 −0 Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java
  64. +5 −3 AriaAnnotations/src/main/java/com/arialyy/annotations/Download.java
  65. +1 −1 README.md
  66. +3 −2 app/build.gradle
  67. +5 −0 app/src/main/AndroidManifest.xml
  68. +90 −0 app/src/main/assets/help_code/FtpDownload.java
  69. +127 −0 app/src/main/assets/help_code/FtpUpload.java
  70. +119 −0 app/src/main/assets/help_code/HttpDownload.java
  71. +170 −0 app/src/main/assets/help_code/KotlinHttpDownload.kt
  72. +5 −3 app/src/main/java/com/arialyy/simple/base/BaseActivity.java
  73. +6 −7 app/src/main/java/com/arialyy/simple/base/BaseApplication.java
  74. +58 −0 app/src/main/java/com/arialyy/simple/common/DialogModule.java
  75. +177 −0 app/src/main/java/com/arialyy/simple/common/DirChooseDialog.java
  76. +93 −0 app/src/main/java/com/arialyy/simple/common/ModifyPathDialog.java
  77. +3 −1 app/src/main/java/com/arialyy/simple/common/ModifyUrlDialog.java
  78. +68 −0 app/src/main/java/com/arialyy/simple/core/FullScreenCodeActivity.java
  79. +95 −0 app/src/main/java/com/arialyy/simple/core/download/DownloadModule1.java
  80. +231 −80 app/src/main/java/com/arialyy/simple/core/download/KotlinDownloadActivity.kt
  81. +97 −123 app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
  82. +25 −30 app/src/main/java/com/arialyy/simple/core/test/TestFTPActivity.java
  83. +47 −33 app/src/main/java/com/arialyy/simple/core/upload/FtpUploadActivity.java
  84. +74 −0 app/src/main/java/com/arialyy/simple/core/upload/UploadModule.java
  85. +106 −0 app/src/main/java/com/arialyy/simple/util/AppUtil.java
  86. +76 −0 app/src/main/java/com/arialyy/simple/widget/CodeView.java
  87. +3 −2 app/src/main/java/com/arialyy/simple/widget/SvgTextView.java
  88. +14 −5 app/src/main/res/drawable/ic_choose_file.xml
  89. +6 −0 app/src/main/res/drawable/ic_dir.xml
  90. +4 −0 app/src/main/res/drawable/ic_full_screen.xml
  91. +1 −1 app/src/main/res/drawable/ic_modify.xml
  92. +8 −0 app/src/main/res/layout/activity_ftp_upload.xml
  93. +17 −0 app/src/main/res/layout/activity_full_screen_code.xml
  94. +46 −15 app/src/main/res/layout/activity_single.xml
  95. +86 −0 app/src/main/res/layout/activity_single_kotlin.xml
  96. +81 −0 app/src/main/res/layout/dialog_choose_dir.xml
  97. +120 −0 app/src/main/res/layout/dialog_modify_path.xml
  98. +2 −1 app/src/main/res/layout/dialog_modify_url.xml
  99. +31 −0 app/src/main/res/layout/item_choose_dir.xml
  100. +44 −0 app/src/main/res/layout/layout_code_demo.xml
  101. +0 −7 app/src/main/res/layout/layout_content_single.xml
  102. +1 −0 app/src/main/res/values/colors.xml
  103. +1 −0 app/src/main/res/values/dimens.xml
  104. +12 −0 app/src/main/res/values/help_code_string.xml
  105. +18 −3 app/src/main/res/values/strings.xml
  106. +7 −2 app/src/main/res/values/styles.xml
  107. +7 −2 build.gradle
@@ -1,14 +1,16 @@
apply plugin: 'com.android.library'
//apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 61
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
@@ -22,18 +24,25 @@ android {
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.google.code.gson:gson:2.7'
// compile 'com.squareup.retrofit2:retrofit:2.1.0'
// compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
// compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
api "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
api 'com.google.code.gson:gson:2.8.2'
api 'io.reactivex:rxandroid:1.2.0'
api 'io.reactivex:rxjava:1.1.5'
implementation 'com.squareup.okhttp3:okhttp:3.2.0'
// compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
// compile 'com.google.dagger:dagger:2.5'
// apt 'com.google.dagger:dagger-compiler:2.5'
// provided 'javax.annotation:jsr250-api:1.0'
}
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.2.0'
implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
implementation 'com.android.support:multidex:1.0.3'

//apply from: 'jcenter.gradle'
api "android.arch.lifecycle:runtime:${rootProject.ext.lifecycleVersion}"
api "android.arch.lifecycle:extensions:${rootProject.ext.lifecycleVersion}"
annotationProcessor "android.arch.lifecycle:compiler:${rootProject.ext.lifecycleVersion}"

}
@@ -15,3 +15,11 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,13 @@
package com.lyy.frame;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
@@ -1,14 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lyy.frame">
package="com.lyy.frame">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS"/>

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">

</application>
</application>

</manifest>
@@ -0,0 +1,13 @@
package com.arialyy.frame.base;

import android.app.Application;
import android.content.Context;

/**
* Created by AriaL on 2017/11/26.
*/

public class BaseApp {
public static Context context;
public static Application app;
}
@@ -0,0 +1,108 @@
package com.arialyy.frame.base;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.IntEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Dialog;
import android.databinding.ViewDataBinding;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.BounceInterpolator;
import com.arialyy.frame.core.AbsDialogFragment;
import com.arialyy.frame.util.AndroidUtils;

/**
* Created by Aria.Lao on 2017/12/4.
*/

public abstract class BaseDialog<VB extends ViewDataBinding> extends AbsDialogFragment<VB> {
private WindowManager.LayoutParams mWpm;
private Window mWindow;
protected boolean useDefaultAnim = true;

@Override protected void init(Bundle savedInstanceState) {
mWindow = getDialog().getWindow();
if (mWindow != null) {
mWpm = mWindow.getAttributes();
}
if (mWpm != null && mWindow != null) {
//mView = mWindow.getDecorView();
mRootView.setBackgroundColor(Color.WHITE);
mWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//in();
if (useDefaultAnim) {
in1();
}
}
}

@Override public void dismiss() {
if (mWpm != null && mWindow != null) {
if (useDefaultAnim) {
out();
}
} else {
super.dismiss();
}
}

@Override protected void dataCallback(int result, Object data) {

}

/**
* 进场动画
*/
private void in() {
int height = AndroidUtils.getScreenParams(getContext())[1];
ValueAnimator animator = ValueAnimator.ofObject(new IntEvaluator(), -height / 2, 0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
mWpm.y = (int) animation.getAnimatedValue();
mWindow.setAttributes(mWpm);
}
});
animator.setInterpolator(new BounceInterpolator()); //弹跳
Animator alpha = ObjectAnimator.ofFloat(mRootView, "alpha", 0f, 1f);
AnimatorSet set = new AnimatorSet();
set.play(animator).with(alpha);
set.setDuration(2000).start();
}

private void in1() {
Animator alpha = ObjectAnimator.ofFloat(mRootView, "alpha", 0f, 1f);
alpha.setDuration(800);
alpha.start();
}

/**
* 重力动画
*/
private void out() {
int height = AndroidUtils.getScreenParams(getContext())[1];
ValueAnimator animator = ValueAnimator.ofObject(new IntEvaluator(), 0, height / 3);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
mWpm.y = (int) animation.getAnimatedValue();
mWindow.setAttributes(mWpm);
}
});
Animator alpha = ObjectAnimator.ofFloat(mRootView, "alpha", 1f, 0f);
AnimatorSet set = new AnimatorSet();
set.play(animator).with(alpha);
set.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationEnd(Animator animation) {
BaseDialog.super.dismiss();
}
});
set.setDuration(600).start();
}
}
@@ -0,0 +1,19 @@
package com.arialyy.frame.base;

import android.databinding.ViewDataBinding;
import com.arialyy.frame.core.AbsFragment;

/**
* Created by Aria.Lao on 2017/12/1.
*/
public abstract class BaseFragment<VB extends ViewDataBinding> extends AbsFragment<VB> {
public int color;

@Override protected void dataCallback(int result, Object obj) {

}

@Override protected void onDelayLoad() {

}
}
@@ -0,0 +1,20 @@
package com.arialyy.frame.base;

import android.arch.lifecycle.ViewModel;
import com.arialyy.frame.base.net.NetManager;
import com.arialyy.frame.util.StringUtil;

/**
* Created by AriaL on 2017/11/26.
* ViewModule只能是public
*/

public class BaseViewModule extends ViewModel {
protected NetManager mNetManager;
protected String TAG = "";

public BaseViewModule() {
mNetManager = NetManager.getInstance();
TAG = StringUtil.getClassName(this);
}
}
@@ -0,0 +1,52 @@
package com.arialyy.frame.base;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;

public class StatusBarCompat {
private static final int INVALID_VAL = -1;
private static final int COLOR_DEFAULT = Color.parseColor("#20000000");

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void compat(Activity activity, int statusColor) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (statusColor != INVALID_VAL) {
activity.getWindow().setStatusBarColor(statusColor);
}
return;
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
int color = COLOR_DEFAULT;
ViewGroup contentView = activity.findViewById(android.R.id.content);
if (statusColor != INVALID_VAL) {
color = statusColor;
}
View statusBarView = new View(activity);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
getStatusBarHeight(activity));
statusBarView.setBackgroundColor(color);
contentView.addView(statusBarView, lp);
}
}

public static void compat(Activity activity) {
compat(activity, INVALID_VAL);
}

public static int getStatusBarHeight(Context context) {
int result = 0;
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
}
@@ -0,0 +1,28 @@
package com.arialyy.frame.base.net;

import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;

/**
* 自定义Gson描述
* Created by “Aria.Lao” on 2016/10/26.
*
* @param <T> 服务器数据实体
*/
public class BasicDeserializer<T> implements JsonDeserializer<T> {
@Override
public T deserialize(JsonElement element, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
JsonObject root = element.getAsJsonObject();
if (JsonCodeAnalysisUtil.isSuccess(root)) {
return new Gson().fromJson(root.get("object"), typeOfT);
} else {
throw new IllegalStateException(root.get("rltmsg").getAsString());
}
}
}
@@ -0,0 +1,39 @@
package com.arialyy.frame.base.net;

import com.arialyy.frame.util.show.FL;
import com.arialyy.frame.util.show.L;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
* Created by “Aria.Lao” on 2016/10/26.
* HTTP数据回调
*/
public abstract class HttpCallback<T> implements INetResponse<T>, Observable.Transformer<T, T> {

@Override public void onFailure(Throwable e) {
L.e("HttpCallback", FL.getExceptionString(e));
}

@Override public Observable<T> call(Observable<T> observable) {
Observable<T> tObservable = observable.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(new Func1<T, T>() {
@Override public T call(T t) {
onResponse(t);
return t;
}
})
.onErrorReturn(new Func1<Throwable, T>() {
@Override public T call(Throwable throwable) {
onFailure(throwable);
return null;
}
});
tObservable.subscribe();
return tObservable;
}
}

0 comments on commit 7b15d4c

Please sign in to comment.
You can’t perform that action at this time.