sampleModels) {
51 | Realm realm = Realm.getDefaultInstance();
52 | realm.beginTransaction();
53 | realm.copyToRealmOrUpdate(sampleModels);
54 | realm.commitTransaction();
55 | }
56 | });
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation;
2 |
3 | public interface BasePresenter {
4 | /**
5 | * Method that control the lifecycle of the view. It should be called in the view's
6 | * (Activity or Fragment) onResume() method.
7 | */
8 | void resume();
9 |
10 | /**
11 | * Method that controls the lifecycle of the view. It should be called in the view's
12 | * (Activity or Fragment) onPause() method.
13 | */
14 | void pause();
15 |
16 | /**
17 | * Method that controls the lifecycle of the view. It should be called in the view's
18 | * (Activity or Fragment) onStop() method.
19 | */
20 | void stop();
21 |
22 | /**
23 | * Method that control the lifecycle of the view. It should be called in the view's
24 | * (Activity or Fragment) onDestroy() method.
25 | */
26 | void destroy();
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation;
2 |
3 | /**
4 | *
5 | * This interface represents a basic view. All views should implement these common methods.
6 | *
7 | */
8 | public interface BaseView {
9 |
10 | /**
11 | * This is a general method used for showing some kind of progress during a background task. For example, this
12 | * method should show a progress bar and/or disable buttons before some background work starts.
13 | */
14 | void showProgress();
15 |
16 | /**
17 | * This is a general method used for hiding progress information after a background task finishes.
18 | */
19 | void hideProgress();
20 |
21 | /**
22 | * This method is used for showing error messages on the UI.
23 | *
24 | * @param message The error message to be displayed.
25 | */
26 | void showError(String message);
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/adapter/SampleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | import com.bumptech.glide.Glide;
11 | import com.tencent.clean.R;
12 | import com.tencent.clean.data.model.SampleModel;
13 |
14 | import java.util.List;
15 |
16 | import butterknife.Bind;
17 | import butterknife.ButterKnife;
18 |
19 | /**
20 | * Created by hoollyzhang on 16/5/30.
21 | * Description :
22 | */
23 | public class SampleAdapter extends RecyclerView.Adapter {
24 |
25 | public void setImages(List images) {
26 | this.images = images;
27 | notifyDataSetChanged();
28 | }
29 |
30 | List images;
31 | @Override
32 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
33 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.sample_item,parent,false);
34 | return new SampleViewHolder(view);
35 | }
36 |
37 | @Override
38 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
39 | SampleViewHolder viewholder = (SampleViewHolder) holder;
40 | SampleModel simpleModel = images.get(position);
41 | Glide.with(viewholder.imagevi.getContext()).load(simpleModel.getUrl()).into(viewholder.imagevi);
42 | viewholder.descriptionTv.setText(simpleModel.getDesc());
43 | }
44 |
45 | @Override
46 | public int getItemCount() {
47 | return images == null ? 0 : images.size();
48 | }
49 |
50 | static class SampleViewHolder extends RecyclerView.ViewHolder{
51 |
52 | @Bind(R.id.imageIv)
53 | ImageView imagevi;
54 | @Bind(R.id.descriptionTv)
55 | TextView descriptionTv;
56 |
57 | public SampleViewHolder(View itemView) {
58 | super(itemView);
59 | ButterKnife.bind(this,itemView);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/event/SampleReloadEvent.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.event;
2 |
3 | /**
4 | * Created by hoollyzhang on 16/6/1.
5 | * Description :
6 | */
7 | public class SampleReloadEvent {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/event/SampleRxEventClearDb.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.event;
2 |
3 | /**
4 | * Created by hoollyzhang on 16/6/1.
5 | * Description :
6 | */
7 | public class SampleRxEventClearDb {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/presenters/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.presenters;
2 |
3 | import com.tencent.clean.data.model.SampleModel;
4 | import com.tencent.clean.presentation.BasePresenter;
5 | import com.tencent.clean.presentation.BaseView;
6 |
7 | import java.util.List;
8 |
9 |
10 | /**
11 | * 放在一起,一个Presenter 对应一个view
12 | */
13 | public interface MainPresenter extends BasePresenter {
14 |
15 | interface View extends BaseView {
16 | // TODO: Add your view methods
17 | void showSampleData(List sampleModels);
18 | }
19 |
20 | // TODO: Add your presenter methods,for example unsubscribe
21 | void unsubscribe();
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/presenters/impl/MainPresenterImpl.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.presenters.impl;
2 |
3 | import android.util.Log;
4 | import android.widget.Toast;
5 |
6 | import com.tencent.clean.data.model.SampleModel;
7 | import com.tencent.clean.domain.usercase.SampleUserCase;
8 | import com.tencent.clean.presentation.presenters.MainPresenter;
9 |
10 | import java.util.List;
11 |
12 | import rx.Observer;
13 | import rx.Subscriber;
14 | import rx.Subscription;
15 | import rx.android.schedulers.AndroidSchedulers;
16 | import rx.schedulers.Schedulers;
17 | import timber.log.Timber;
18 |
19 | /**
20 | * 展现其实例
21 | */
22 | public class MainPresenterImpl implements MainPresenter {
23 |
24 | private MainPresenter.View mView;
25 | private SampleUserCase sampleUserCase;
26 | private Subscription _subscription;
27 |
28 | public MainPresenterImpl(View mView, SampleUserCase sampleUserCase) {
29 | this.mView = mView;
30 | this.sampleUserCase = sampleUserCase;
31 | }
32 |
33 | @Override
34 | public void resume() {
35 | mView.showProgress();
36 | final long startTime = System.currentTimeMillis();
37 | _subscription = sampleUserCase.sample()
38 | .observeOn(AndroidSchedulers.mainThread())
39 | .subscribe(new Subscriber>() {
40 | @Override
41 | public void onCompleted() {
42 | mView.hideProgress();
43 | long ellipseTime = System.currentTimeMillis() - startTime;
44 | mView.showError("执行时间: "+ellipseTime);
45 | }
46 |
47 | @Override
48 | public void onError(Throwable e) {
49 | Log.e("test",e.getMessage());
50 | mView.hideProgress();
51 | }
52 |
53 | @Override
54 | public void onNext(List sampleModels) {
55 | mView.showSampleData(sampleModels);
56 | }
57 | });
58 |
59 | }
60 |
61 | @Override
62 | public void pause() {
63 |
64 | }
65 |
66 | @Override
67 | public void stop() {
68 |
69 | }
70 |
71 | @Override
72 | public void destroy() {
73 | unsubscribe();
74 | }
75 |
76 |
77 | @Override
78 | public void unsubscribe() {
79 | if (_subscription != null && !_subscription.isUnsubscribed()) {
80 | _subscription.unsubscribe();
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/ui/activities/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.ui.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.Menu;
9 | import android.view.MenuInflater;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 |
13 | import com.tencent.clean.R;
14 | import com.tencent.clean.RxBus;
15 | import com.tencent.clean.presentation.event.SampleReloadEvent;
16 | import com.tencent.clean.presentation.event.SampleRxEventClearDb;
17 |
18 | public class MainActivity extends AppCompatActivity {
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
25 | setSupportActionBar(toolbar);
26 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
27 | fab.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View view) {
30 | Snackbar.make(view, "waht do you want", Snackbar.LENGTH_LONG)
31 | .setAction("Action", null).show();
32 | }
33 | });
34 | }
35 |
36 | @Override
37 | public boolean onCreateOptionsMenu(Menu menu) {
38 | MenuInflater inflater = getMenuInflater();
39 | inflater.inflate(R.menu.main_menu, menu);
40 | return true;
41 | }
42 |
43 | @Override
44 | public boolean onOptionsItemSelected(MenuItem item) {
45 | switch (item.getItemId()) {
46 | case R.id.clear_db:
47 | RxBus.getRxBusSingleton().send(new SampleRxEventClearDb());
48 | return true;
49 | case R.id.reload_data:
50 | RxBus.getRxBusSingleton().send(new SampleReloadEvent());
51 | return true;
52 | default:
53 | return super.onOptionsItemSelected(item);
54 | }
55 | }
56 |
57 |
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tencent/clean/presentation/ui/fragment/SampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean.presentation.ui.fragment;
2 |
3 | import android.app.Fragment;
4 | import android.app.ProgressDialog;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.widget.SwipeRefreshLayout;
9 | import android.support.v7.widget.GridLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.Toast;
15 |
16 | import com.tencent.clean.R;
17 | import com.tencent.clean.RxBus;
18 | import com.tencent.clean.data.model.SampleModel;
19 | import com.tencent.clean.domain.usercase.SampleUserCase;
20 | import com.tencent.clean.presentation.adapter.SampleAdapter;
21 | import com.tencent.clean.presentation.event.SampleReloadEvent;
22 | import com.tencent.clean.presentation.event.SampleRxEventClearDb;
23 | import com.tencent.clean.presentation.presenters.MainPresenter;
24 | import com.tencent.clean.presentation.presenters.impl.MainPresenterImpl;
25 |
26 | import java.util.LinkedList;
27 | import java.util.List;
28 |
29 | import butterknife.Bind;
30 | import butterknife.ButterKnife;
31 | import io.realm.Realm;
32 | import rx.subscriptions.CompositeSubscription;
33 |
34 | /**
35 | * Created by hoollyzhang on 16/5/30.
36 | * Description :
37 | */
38 | public class SampleFragment extends Fragment implements MainPresenter.View,RxBus.EventLisener {
39 |
40 | private ProgressDialog sProgressDialog ;
41 | MainPresenter mainPresenter;
42 |
43 | @Bind(R.id.gridRv)
44 | RecyclerView gridRv;
45 | @Bind(R.id.swipeRefreshLayout)
46 | SwipeRefreshLayout swipeRefreshLayout;
47 |
48 | SampleAdapter adapter = new SampleAdapter();
49 |
50 | CompositeSubscription _subscription = new CompositeSubscription();
51 | @Nullable
52 | @Override
53 | public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
54 | View view = inflater.inflate(R.layout.sample_fagment, container, false);
55 | ButterKnife.bind(this, view);
56 | gridRv.setLayoutManager(new GridLayoutManager(getActivity(), 2));
57 | gridRv.setAdapter(adapter);
58 | swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);
59 | swipeRefreshLayout.setEnabled(false);
60 | SampleUserCase sampleUserCase = new SampleUserCase(getActivity());
61 | mainPresenter = new MainPresenterImpl(this,sampleUserCase);
62 | return view;
63 | }
64 |
65 |
66 | @Override
67 | public void onResume() {
68 | super.onResume();
69 | sProgressDialog = ProgressDialog.show(getActivity(),"提示","加载中。。。。。");
70 | mainPresenter.resume();
71 | RxBus.getRxBusSingleton().subscribe(_subscription,this);
72 | }
73 |
74 | @Override
75 | public void onDestroyView() {
76 | if (sProgressDialog != null){
77 | sProgressDialog.dismiss();
78 | sProgressDialog = null;
79 | }
80 | mainPresenter.destroy();
81 | _subscription.clear();
82 | super.onDestroyView();
83 | }
84 |
85 | @Override
86 | public void onDestroy() {
87 | if (sProgressDialog != null){
88 | sProgressDialog.dismiss();
89 | sProgressDialog = null;
90 | }
91 | super.onDestroy();
92 |
93 | }
94 |
95 | @Override
96 | public void showProgress() {
97 | sProgressDialog.show();
98 | }
99 |
100 | @Override
101 | public void hideProgress() {
102 | sProgressDialog.hide();
103 | }
104 |
105 | @Override
106 | public void showError(String message) {
107 | if (getActivity()!=null){
108 | Toast.makeText(getActivity(),message,Toast.LENGTH_LONG).show();
109 | }
110 | }
111 |
112 | @Override
113 | public void showSampleData(List sampleModels) {
114 | adapter.setImages(sampleModels);
115 | }
116 |
117 | @Override
118 | public void dealRxEvent(Object event) {
119 | if (event instanceof SampleRxEventClearDb){
120 | clearDb();
121 | }else if (event instanceof SampleReloadEvent){
122 | reloadData();
123 | }
124 | }
125 |
126 | private void clearDb() {
127 | Realm realm = Realm.getDefaultInstance();
128 | realm.beginTransaction();
129 | realm.delete(SampleModel.class);
130 | realm.commitTransaction();
131 | adapter.setImages(new LinkedList());
132 | Toast.makeText(getActivity(), "缓存清除成功", Toast.LENGTH_LONG).show();
133 | }
134 |
135 | private void reloadData(){
136 | mainPresenter.resume();
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/sample_fagment.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/sample_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
23 |
24 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/celanarch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/app/src/main/res/mipmap-xxhdpi/celanarch.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 | 16dp
8 | 160dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CleanArch
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/tencent/clean/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.tencent.clean;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.1.0'
9 | classpath "io.realm:realm-gradle-plugin:1.0.0"
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
--------------------------------------------------------------------------------
/build/generated/mockable-android-23.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/build/generated/mockable-android-23.jar
--------------------------------------------------------------------------------
/build/intermediates/dex-cache/cache.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Wed May 25 19:58:55 CST 2016
16 | #systemProp.https.proxyPort=8080
17 | #systemProp.http.proxyHost=dev-proxy.oa.com
18 | #systemProp.https.proxyHost=dev-proxy.oa.com
19 | #systemProp.http.proxyPort=8080
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bravekingzhang/CleanArch/aaa1e2da374acb4ebe8aee060da7b851dbbfe4fb/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 25 15:58:49 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Wed May 25 10:58:12 CST 2016
11 | sdk.dir=/Users/hoollyzhang/Library/Android/sdk
12 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------