Skip to content

Commit

Permalink
fix demo
Browse files Browse the repository at this point in the history
  • Loading branch information
limedroid committed Dec 12, 2016
1 parent 1ed4427 commit 7ce64dd
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 87 deletions.
16 changes: 14 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

> Demo详细使用可参看Demo

## 特性

**XDroid**主要有这些特性:
Expand Down Expand Up @@ -50,12 +51,22 @@ git clone https://github.com/limedroid/XDroid.git
compile project(':library')
```


### step3

修改`XDroidConf`配置类,主要针对log、cache、router、imageloader。若采用默认配置,此步骤可略过.


## Demo效果

<p align="center">
<img src="art/snapshot_2.png"/>
</p>

<p align="center">
<img src="art/snapshot_1.png"/>
</p>


## 重要说明

* [ButterKnife](https://github.com/JakeWharton/butterknife)使用的是8.4.0版本,重点是 `@BindView`,可以去项目官网查看。
Expand All @@ -70,8 +81,9 @@ compile project(':library')

## 感谢

* 感谢各位江湖前辈大拿的帮助
* 特别感谢基友石浩提供的建议和完美logo
* 感谢干货提供的api


## 关于我

Expand Down
54 changes: 20 additions & 34 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
Expand All @@ -81,53 +73,47 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/cn.droidlover/XRecyclerView/1.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/cn.droidlover/qtcontentlayout/1.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.jakewharton/butterknife/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.wang.avi/library/1.0.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.zhy/okhttputils/2.6.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="okio-1.8.0" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.6.2" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.1.0" level="project" />
<orderEntry type="library" exported="" name="butterknife-annotations-8.4.0" level="project" />
<orderEntry type="library" exported="" name="okio-1.8.0" level="project" />
<orderEntry type="library" exported="" name="eventbus-3.0.0" level="project" />
<orderEntry type="library" exported="" name="design-23.3.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.3.0" level="project" />
<orderEntry type="library" exported="" name="XRecyclerView-1.0.0" level="project" />
<orderEntry type="library" exported="" name="qtcontentlayout-1.0.3" level="project" />
<orderEntry type="library" exported="" name="okhttp-3.3.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.3.0" level="project" />
<orderEntry type="library" exported="" name="library-1.0.2" level="project" />
<orderEntry type="library" exported="" name="butterknife-annotations-8.4.0" level="project" />
<orderEntry type="library" exported="" name="butterknife-8.4.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.7.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="okhttputils-2.6.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.1.0" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
</module>
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/xdroid_logo_128"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".ui.MainActivity">
<activity
android:name=".ui.MainActivity"
android:icon="@mipmap/xdroid_logo_128">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import cn.droidlover.xdroid.demo.R;
import cn.droidlover.xdroid.demo.model.GankResults;
import cn.droidlover.xdroid.imageloader.ILFactory;
import cn.droidlover.xdroid.kit.Kits;
import cn.droidlover.xdroid.kit.KnifeKit;

/**
Expand Down Expand Up @@ -114,11 +113,8 @@ public void onClick(View v) {
holder.tvAuthor.setText("");
}

if (item.getCreatedAt() > 0) {
holder.tvTime.setText(Kits.Date.getMd(item.getCreatedAt()));
} else {
holder.tvTime.setText("");
}
holder.tvTime.setText(item.getCreatedAt());

holder.tvType.setText(type);

holder.itemView.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

public class GankResults extends BaseModel {

private List<Item> items;
private List<Item> results;

public List<Item> getItems() {
return items;
public List<Item> getResults() {
return results;
}

public void setItems(List<Item> items) {
this.items = items;
public void setResults(List<Item> results) {
this.results = results;
}

public static class Item {
private String _id;
private String _ns;
private long createdAt;
private String createdAt;
private String desc;
private String publishedAt;
private String source;
Expand All @@ -46,11 +46,11 @@ public void set_ns(String _ns) {
this._ns = _ns;
}

public long getCreatedAt() {
public String getCreatedAt() {
return createdAt;
}

public void setCreatedAt(long createdAt) {
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

public abstract class BasePagerFragment extends XFragment {


@BindView(R.id.contentLayout)
XRecyclerContentLayout contentLayout;

Expand Down Expand Up @@ -71,9 +70,9 @@ public void onFail(Call call, Exception e, int id) {
public void onResponse(GankResults response, int id) {
if (!response.isError()) {
if (page > 1) {
getAdapter().addData(response.getItems());
getAdapter().addData(response.getResults());
} else {
getAdapter().setData(response.getItems());
getAdapter().setData(response.getResults());
}

contentLayout.getRecyclerView().setPage(page, MAX_PAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onItemClick(int position, GankResults.Item model, int tag, GirlAdapt

@Override
public void setLayoutManager(XRecyclerView recyclerView) {
recyclerView.verticalStaggeredLayoutManager(2);
recyclerView.gridLayoutManager(context, 2);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package cn.droidlover.xdroid.demo.ui;

import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.bumptech.glide.GifRequestBuilder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.droidlover.xdroid.base.XActivity;
import cn.droidlover.xdroid.base.XFragmentAdapter;
import cn.droidlover.xdroid.demo.R;
Expand Down Expand Up @@ -80,6 +75,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}


@Override
public int getLayoutId() {
return R.layout.activity_main;
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/cn/droidlover/xdroid/demo/ui/WebActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ private void initWebView() {
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (newProgress == 100) {
contentLayout.showContent();
url = webView.getUrl();
if (contentLayout != null)
contentLayout.showContent();
if (webView != null)
url = webView.getUrl();
} else {
contentLayout.showLoading();
if (contentLayout != null)
contentLayout.showLoading();
}
}
});
Expand Down Expand Up @@ -124,7 +127,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
break;
case R.id.action_share:
AppKit.shareText(this, webView.getTitle() + " " + webView.getUrl() + " 来自「趣刻」APP");
AppKit.shareText(this, webView.getTitle() + " " + webView.getUrl() + " 来自「XDroid」");
break;
case R.id.action_refresh:
webView.reload();
Expand Down
69 changes: 67 additions & 2 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">

<include layout="@layout/view_toolbar" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">


<TextView
android:id="@+id/tv_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="16dp"
android:text="XDroid是一个轻量级的Android快速开发框架,由UI、Cache、Event、ImageLoader、Kit、Log、Router、Net等几个部分组成。其设计思想是使用接口对各模块解耦规范化,不强依赖某些明确的三方类库,使得三方类库可自由搭配组装,方便替换。可快速、自由的进行App开发。"
android:textSize="14sp" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/tv_info"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
android:src="@mipmap/xdroid_logo_128" />

<TextView
android:id="@+id/tv_github"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_info"
android:layout_marginTop="20dp"
android:paddingLeft="18dp"
android:text="https://github.com/limedroid/XDroid"
android:textColor="@color/colorPrimaryDark"
android:textSize="16sp"
android:textStyle="bold" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_github"
android:layout_marginTop="25dp"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="关于我"
android:textColor="@color/text_primary"
android:textSize="20sp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Email : [email protected]"
android:textColor="@color/text_secondary"
android:textSize="16sp" />

</LinearLayout>

</RelativeLayout>


</LinearLayout>
7 changes: 3 additions & 4 deletions app/src/main/res/layout/adapter_girl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:background="#ffffff"
android:paddingTop="4dp">

<ImageView
android:id="@+id/iv_girl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="200dp"
android:layout_height="200dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
android:scaleType="fitXY" />

</LinearLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7ce64dd

Please sign in to comment.