forked from Omiknight/Daily
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 36e802a
Showing
76 changed files
with
1,541 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
#built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# files for the dex VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# generated files | ||
bin/ | ||
gen/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Windows thumbnail db | ||
Thumbs.db | ||
|
||
# OSX files | ||
.DS_Store | ||
|
||
# Eclipse project files | ||
.classpath | ||
.project | ||
|
||
# Android Studio | ||
.idea/ | ||
*.iml | ||
|
||
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs. | ||
.gradle | ||
build/ | ||
|
||
*build/ | ||
.gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
defaultConfig { | ||
applicationId "com.cins.daily" | ||
minSdkVersion 15 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
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.1.0' | ||
compile 'com.android.support:design:25.1.0' | ||
//apt 'com.jakewharton:butterknife-compiler:8.0.1' | ||
|
||
compile 'com.jakewharton:butterknife:8.0.1' | ||
compile 'com.android.support:support-v4:25.1.0' | ||
compile 'com.android.support:recyclerview-v7:25.1.0' | ||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2' | ||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' | ||
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\sdk\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/cins/daily/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.cins.daily; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.cins.daily", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.cins.daily"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".mvp.ui.activities.NewsActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/cins/daily/mvp/interactor/NewsInteractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.cins.daily.mvp.interactor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Eric on 2017/1/15. | ||
*/ | ||
|
||
public interface NewsInteractor { | ||
|
||
interface OnFinishedListener { | ||
void onFinished(List<String> items); | ||
} | ||
|
||
void loadNews(OnFinishedListener listener); | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/cins/daily/mvp/interactor/impl/NewsInteractorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.cins.daily.mvp.interactor.impl; | ||
|
||
import android.os.Handler; | ||
|
||
import com.cins.daily.mvp.interactor.NewsInteractor; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Eric on 2017/1/15. | ||
*/ | ||
|
||
public class NewsInteractorImpl implements NewsInteractor { | ||
@Override | ||
public void loadNews(final OnFinishedListener listener) { | ||
new Handler().postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
listener.onFinished(createArrayList()); | ||
} | ||
}, 2000); | ||
} | ||
|
||
private List<String> createArrayList() { | ||
return Arrays.asList( | ||
"Item 12", | ||
"Item 12", | ||
"Item 12", | ||
"Item 12", | ||
"Item 12" | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/cins/daily/mvp/presenter/NewsPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.cins.daily.mvp.presenter; | ||
|
||
import com.cins.daily.mvp.presenter.base.BasePresenter; | ||
|
||
/** | ||
* Created by Eric on 2017/1/16. | ||
*/ | ||
|
||
public interface NewsPresenter extends BasePresenter { | ||
|
||
void onFabClicked(); | ||
|
||
void onItemClicked(int position); | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/cins/daily/mvp/presenter/base/BasePresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.cins.daily.mvp.presenter.base; | ||
|
||
/** | ||
* Created by Eric on 2017/1/16. | ||
*/ | ||
|
||
public interface BasePresenter { | ||
void onResume(); | ||
|
||
void onCreateView(); | ||
|
||
void onDestroy(); | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/cins/daily/mvp/presenter/impl/NewsPresenterImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.cins.daily.mvp.presenter.impl; | ||
|
||
import com.cins.daily.mvp.interactor.NewsInteractor; | ||
import com.cins.daily.mvp.interactor.impl.NewsInteractorImpl; | ||
import com.cins.daily.mvp.presenter.NewsPresenter; | ||
import com.cins.daily.mvp.view.NewsView; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Eric on 2017/1/16. | ||
*/ | ||
|
||
public class NewsPresenterImpl implements NewsPresenter, NewsInteractor.OnFinishedListener{ | ||
|
||
private NewsView mNewsView; | ||
private NewsInteractor mNewsInteractor; | ||
|
||
public NewsPresenterImpl(NewsView newsView) { | ||
mNewsView = newsView; | ||
mNewsInteractor = new NewsInteractorImpl(); | ||
} | ||
|
||
@Override | ||
public void onCreateView() { | ||
if (mNewsView != null) { | ||
mNewsView.showProgress(); | ||
} | ||
mNewsInteractor.loadNews(this); | ||
} | ||
|
||
@Override | ||
public void onFabClicked() { | ||
|
||
} | ||
|
||
@Override | ||
public void onItemClicked(int position) { | ||
|
||
} | ||
|
||
@Override | ||
public void onResume() { | ||
|
||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
mNewsView = null; | ||
} | ||
|
||
@Override | ||
public void onFinished(List<String> items) { | ||
if (mNewsView != null) { | ||
mNewsView.setItems(items); | ||
mNewsView.hideProgress(); | ||
} | ||
} | ||
} |
Oops, something went wrong.