Skip to content

Commit

Permalink
上传仿闲鱼首页Demo代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ly85206559 committed Apr 21, 2017
0 parents commit f55deec
Show file tree
Hide file tree
Showing 133 changed files with 8,175 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
63 changes: 63 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion setup.compileSdk
buildToolsVersion setup.buildTools
defaultConfig {
applicationId "com.demo.fish"
minSdkVersion setup.minSdk
targetSdkVersion setup.targetSdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

dataBinding {
enabled = true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
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'
})
testCompile 'junit:junit:4.12'

//Support
compile "com.android.support:appcompat-v7:${versions.supportLib}"
compile "com.android.support:recyclerview-v7:${versions.supportLib}"
compile "com.android.support:support-annotations:${versions.supportLib}"
compile "com.android.support:design:${versions.supportLib}"
compile "com.android.support:support-vector-drawable:${versions.supportLib}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'

//NetWork
compile "com.squareup.okio:okio:${versions.okio}"
compile "com.squareup.okhttp3:okhttp:${versions.okhttp3}"

//Retrofit
compile "com.squareup.retrofit2:retrofit:${versions.retrofit2}"
compile "com.squareup.retrofit2:converter-gson:${versions.retrofit2}"
compile "com.squareup.retrofit2:adapter-rxjava2:${versions.retrofit2}"

//ImageLoader
compile "com.facebook.fresco:fresco:${versions.fresco}"
compile "com.facebook.fresco:imagepipeline-okhttp3:${versions.fresco}"

compile('com.mikepenz:materialdrawer:5.8.2@aar') {
transitive = true
}
compile project(':brvah')

compile "io.reactivex.rxjava2:rxjava:${versions.rxjava}"
compile "io.reactivex.rxjava2:rxandroid:${versions.rxandroid}"
}
25 changes: 25 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\IDE\Android\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 *;
#}

# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.demo.fish;

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.prog.socialshare", appContext.getPackageName());
}
}
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.fish">

<application
android:name=".DemoApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity
android:name=".app.main.ui.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
39 changes: 39 additions & 0 deletions app/src/main/java/com/demo/fish/DemoApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.demo.fish;

import android.app.Application;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory;
import com.facebook.imagepipeline.core.ImagePipelineConfig;

import okhttp3.OkHttpClient;

/**
* Created by Ben on 2017/3/31.
*/

public class DemoApplication extends Application {

private static DemoApplication application;

@Override
public void onCreate() {
super.onCreate();
application = this;

init();
}

private void init() {
OkHttpClient mOkHttpClient = new OkHttpClient();
ImagePipelineConfig imagePipelineConfig = OkHttpImagePipelineConfigFactory
.newBuilder(this, mOkHttpClient)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this, imagePipelineConfig);
}

public static DemoApplication getApplication() {
return application;
}
}
18 changes: 18 additions & 0 deletions app/src/main/java/com/demo/fish/app/main/entity/BannerEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.demo.fish.app.main.entity;

/**
* Created by Ben on 2017/4/8.
*/

public class BannerEntity {

private String imageUrl;

public String getImageUrl() {
return imageUrl;
}

public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.demo.fish.app.main.entity;

import android.databinding.BaseObservable;
import android.databinding.Bindable;

import com.demo.fish.BR;

/**
* Created by Ben on 2017/4/9.
*/

public class FunctionItemEntity extends BaseObservable {

private String iconUrl;
private String title;
private String desc;
private Class cls;

@Bindable
public String getIconUrl() {
return iconUrl;
}

public void setIconUrl(String iconUrl) {
this.iconUrl = iconUrl;
notifyPropertyChanged(BR.iconUrl);
}

@Bindable
public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
notifyPropertyChanged(BR.title);
}

@Bindable
public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
notifyPropertyChanged(BR.desc);
}

public Class getCls() {
return cls;
}

public void setCls(Class cls) {
this.cls = cls;
}
}
124 changes: 124 additions & 0 deletions app/src/main/java/com/demo/fish/app/main/entity/HomeEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.demo.fish.app.main.entity;

import android.databinding.BaseObservable;
import android.databinding.Bindable;

import com.demo.fish.BR;

/**
* Created by Ben on 2017/4/9.
*/

public class HomeEntity extends BaseObservable {

//列表类型 0:新鲜的 1:附近的
public static final int LIST_TYPE_FRESH = 0;
public static final int LIST_TYPE_NEAR = 1;

private int bannerCount;
private int listType = LIST_TYPE_FRESH;
private boolean refreshLoading;
private boolean nearLoading;
private boolean refreshing;
private int refreshMoreStatus;
private int nearMoreStatus;
private int loadingMoreStatus;

@Bindable
public int getBannerCount() {
return bannerCount;
}

public void setBannerCount(int bannerCount) {
this.bannerCount = bannerCount;
notifyPropertyChanged(BR.bannerCount);
}

@Bindable
public int getListType() {
return listType;
}

public void setListType(int listType) {
setListType(listType, true);
}

public void setListType(int listType, boolean notify) {
this.listType = listType;
if (notify) {
notifyPropertyChanged(BR.listType);
}
}

@Bindable
public boolean isRefreshLoading() {
return refreshLoading;
}

public void setRefreshLoading(boolean refreshLoading) {
if (this.refreshLoading != refreshLoading) {
this.refreshLoading = refreshLoading;
notifyPropertyChanged(BR.refreshLoading);
}
}

@Bindable
public boolean isNearLoading() {
return nearLoading;
}

public void setNearLoading(boolean nearLoading) {
if (this.nearLoading != nearLoading) {
this.nearLoading = nearLoading;
notifyPropertyChanged(BR.nearLoading);
}
}

@Bindable
public boolean isRefreshing() {
return refreshing;
}

public void setRefreshing(boolean refreshing) {
setRefreshing(refreshing, true);
}

public void setRefreshing(boolean refreshing, boolean notify) {
this.refreshing = refreshing;
if (notify) {
notifyPropertyChanged(BR.refreshing);
}
}

public int getRefreshMoreStatus() {
return refreshMoreStatus;
}

public void setRefreshMoreStatus(int refreshMoreStatus) {
this.refreshMoreStatus = refreshMoreStatus;
}

public int getNearMoreStatus() {
return nearMoreStatus;
}

public void setNearMoreStatus(int nearMoreStatus) {
this.nearMoreStatus = nearMoreStatus;
}

@Bindable
public int getLoadingMoreStatus() {
return loadingMoreStatus;
}

public void setLoadingMoreStatus(int loadingMoreStatus) {
setLoadingMoreStatus(loadingMoreStatus, true);
}

public void setLoadingMoreStatus(int loadingMoreStatus, boolean notify) {
this.loadingMoreStatus = loadingMoreStatus;
if (notify) {
notifyPropertyChanged(BR.loadingMoreStatus);
}
}
}
Loading

0 comments on commit f55deec

Please sign in to comment.