Skip to content

Commit

Permalink
添加各种依赖
Browse files Browse the repository at this point in the history
添加混淆规则
添加基础类
添加引导页
  • Loading branch information
Mr-zhao-dy committed Aug 16, 2017
1 parent 34997e8 commit f2be7db
Show file tree
Hide file tree
Showing 55 changed files with 4,679 additions and 15 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Expand Down Expand Up @@ -42,6 +43,13 @@ android {
}

buildTypes {
debug {
signingConfig signingConfigs.release
// buildConfigField "String", "BASE_URL", "\"http://api.hengchuangyun.com/\""
// buildConfigField "String", "BASE_URL", "\"http://192.168.1.188:8080/cfzxi_v2/control/\""
// buildConfigField "String", "BASE_URL", "\"http://www.cfzxzz.com/cfzxi_v2/control/\""
}

release {
signingConfig signingConfigs.release
minifyEnabled true
Expand All @@ -60,12 +68,16 @@ android {

productFlavors {

"360" {
xiaomi {
applicationId "com.hcy.tomeetu"
buildConfigField "boolean", "API_Log", "true"
buildConfigField "String", "channel", "\"xiaomi\""
}

huawei {
applicationId "com.hcy.tomeetu"
buildConfigField "boolean", "API_Log", "true"
buildConfigField "String", "channel", "\"huawei\""
}

}
Expand Down Expand Up @@ -142,13 +154,14 @@ def getGitCommitDescription() {


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.+'
compile project(':mylibrary')
}
repositories {
mavenCentral()
Expand Down
14 changes: 13 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-optimizations !code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-ignorewarnings


##################below is for common android
-keep public class **.R$* { public static final int *; }
-keep public class * extends android.app.Activity
Expand Down Expand Up @@ -103,4 +111,8 @@
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
##---------------End: proguard configuration for RxJava ----------
##---------------End: proguard configuration for RxJava ----------


-keep class com.hcy.tomeetu.Utils.** {*;}
-keep class com.hcy.tomeetu.common.** {*;}
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

<application
android:allowBackup="true"
android:name=".common.AppContext"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".activity.MainActivity"></activity>
<activity android:name=".activity.TestActivity" />
<activity android:name=".activity.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TestActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.hcy.tomeetu
package com.hcy.tomeetu.activity

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.hcy.tomeetu.R
import com.hcy.tomeetu.common.BaseActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
class MainActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/com/hcy/tomeetu/activity/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.hcy.tomeetu.activity

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Message

import com.hcy.tomeetu.R
import com.hcy.tomeetu.common.BaseActivity
import com.hcy.tomeetu.utils.UIHelper

class SplashActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
val handler = object : Handler() {
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
}
}
handler.postDelayed({
UIHelper.startActivity(MainActivity::class.java)
}, 3000)

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.hcy.tomeetu
package com.hcy.tomeetu.activity

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.hcy.tomeetu.R
import com.hcy.tomeetu.common.BaseActivity

class TestActivity : AppCompatActivity() {
class TestActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
155 changes: 155 additions & 0 deletions app/src/main/java/com/hcy/tomeetu/common/AppBaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package com.hcy.tomeetu.common;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import android.view.View;
import android.widget.FrameLayout;


import com.cfzx.mvp.presenter.BasePresenter;
import com.cfzx.mvp.presenter.loader.PresenterFactory;
import com.cfzx.mvp.presenter.loader.PresenterLoader;
import com.cfzx.mvp.view.BaseView;
import com.hcy.mylibrary.KLog;
import com.hcy.tomeetu.R;
import com.hcy.tomeetu.utils.C;


import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* Created by Administrator on 2016/7/21 0021.
*/
public abstract class AppBaseActivity<P extends BasePresenter<V>, V extends BaseView> extends BaseActivity implements LoaderManager.LoaderCallbacks<P>, PresenterFactory<P> {

static final AtomicInteger sViewCounter = new AtomicInteger(Integer.MIN_VALUE);
/**
* Do we need to call {@link #doStart()} from the {@link #onLoadFinished(Loader, BasePresenter)} method.
* Will be true if presenter wasn't loaded when {@link #onStart()} is reached
*/
private final AtomicBoolean mNeedToCallStart = new AtomicBoolean(false);
protected boolean mFirstStart;//Is this the first start of the activity (after onCreate)
protected P mBasePresenter;

@Nullable
@BindView(R.id.toolbar_layout)
protected CollapsingToolbarLayout toolbarLayout;
@Nullable
@BindView(R.id.fl_head_container)
protected FrameLayout headContainer;
protected View mRootView;
private int mUniqueLoaderIdentifier;//Unique identifier for the loader, persisted across re-creation

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// UIHelper.$optimizeBackgroundOverdraw(this);
KLog.d(TAG, TAG + "=> onCreate_save:" + savedInstanceState);
mFirstStart = savedInstanceState == null || savedInstanceState.getBoolean(C.SavedInstanceState.RECREATION_SAVED_STATE);
mUniqueLoaderIdentifier = savedInstanceState == null ? AppBaseActivity.sViewCounter.incrementAndGet() : savedInstanceState.getInt(C.SavedInstanceState.LOADER_ID_SAVED_STATE);
mRootView = getLayoutInflater().inflate(getLayoutId(), null);
setContentView(mRootView);
ButterKnife.bind(this);
getSupportLoaderManager().initLoader(mUniqueLoaderIdentifier, null, AppBaseActivity.this);

}

@Override
protected void onStart() {
super.onStart();
if (mBasePresenter == null) {
mNeedToCallStart.set(true);
} else {
doStart();
}
}

protected void doStart() {
KLog.d(TAG, TAG + "doStart", mFirstStart, mUniqueLoaderIdentifier);
assert mBasePresenter != null;
mBasePresenter.onViewAttached((V) this);
mBasePresenter.onStart(mFirstStart);
mFirstStart = false;
}

@Override
protected void onResume() {
super.onResume();
if (mBasePresenter != null) mBasePresenter.onResume();
}

@Override
protected void onPause() {
super.onPause();
if (mBasePresenter != null) mBasePresenter.onPause();
}

@Override
protected void onStop() {
super.onStop();
if (mBasePresenter != null) {
mBasePresenter.onStop();
}
}

@Override
protected void onDestroy() {
if (mBasePresenter != null) {
mBasePresenter.onViewDetached();
}
super.onDestroy();

}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(C.SavedInstanceState.RECREATION_SAVED_STATE, true);
outState.putInt(C.SavedInstanceState.LOADER_ID_SAVED_STATE, mUniqueLoaderIdentifier);
}


protected abstract int getLayoutId();

/**
* 不需要权限就忽略
* 触发时机自己处理
*/
@TargetApi(Build.VERSION_CODES.M)
protected abstract void requestPermission();


@Override
public Loader<P> onCreateLoader(int id, Bundle args) {
return new PresenterLoader<>(this, this);
}

@Override
public void onLoadFinished(Loader<P> loader, P data) {
mBasePresenter = data;
if (mNeedToCallStart.compareAndSet(true, false)) {
doStart();
}
}

@Override
public void onLoaderReset(Loader<P> loader) {
mBasePresenter = null;
}

@Nullable
public CollapsingToolbarLayout getToolbarLayout() {
return toolbarLayout;
}


}
Loading

0 comments on commit f2be7db

Please sign in to comment.