Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Omiknight committed Jan 16, 2017
0 parents commit 36e802a
Show file tree
Hide file tree
Showing 76 changed files with 1,541 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .gitignore
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/
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
40 changes: 40 additions & 0 deletions app/build.gradle
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'


}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
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 *;
#}
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());
}
}
23 changes: 23 additions & 0 deletions app/src/main/AndroidManifest.xml
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>
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);
}
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 app/src/main/java/com/cins/daily/mvp/presenter/NewsPresenter.java
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);
}
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();
}
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();
}
}
}
Loading

0 comments on commit 36e802a

Please sign in to comment.