Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
codeestX committed Sep 4, 2016
1 parent 5afe175 commit a431452
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 18 deletions.
7 changes: 1 addition & 6 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 105 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,106 @@
News App with MVP + Material Design + RxJava + Retrofit + Dagger2 + Realm + Glide
#GeekNews
-

<b>Updating
A pure reading App based on Material Design + MVP + RxJava + Retrofit + Dagger2 + Realm + Glide

极客日报,一款纯粹的阅读App,基于Material Design + MVP + RxJava + Retrofit + Dagger2 + Realm + Glide

#Points
-
* 使用RxJava配合Retrofit2做网络请求
* 使用RxUtil对线程操作和网络请求结果处理做了封装
* 使用RxPresenter对订阅的生命周期做管理
* 使用RxBus来方便组件间的通信
* 使用RxJava其他操作符来做延时、轮询、转化等操作
* 使用okhttp3对网络返回内容做缓存,还有日志、超时重连、头部消息的配置
* 使用Material Design控件和动画
* 使用MVP架构整个项目,对应于model、ui、presenter三个包
* 使用Dagger2将M层注入P层,将P层注入V层,无需new,直接调用对象
* 使用Realm做阅读记录和收藏记录的存储和查询
* 使用Glide做图片的处理和加载
* 使用Fragmentation简化Fragment的操作,还有Activity滑动返回
* 使用RecyclerView实现下拉刷新、上拉加载、侧滑删除、长按拖曳
* 使用WebView做阅览页,通过修改其配置达成各种需要的功能
* 使用原生的夜间模式、分享、反馈
* 包含搜索、收藏、自动更新(尚未实现)等功能

#Version
-
###V1.0.0
`1.提交第一版`

#Thanks
-
###API:
[知乎日报API](https://github.com/izzyleung/ZhihuDailyPurify/wiki/%E7%9F%A5%E4%B9%8E%E6%97%A5%E6%8A%A5-API-%E5%88%86%E6%9E%90)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[微信精选API](http://apistore.baidu.com/apiworks/servicedetail/632.html)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[干货集中营API](http://gank.io/api)

###APP:
[Hot](https://github.com/zj-wukewei/Hot) 提供了Dagger2配合MVP的架构思路

[知了日报](https://github.com/HotBitmapGG/RxZhiHu) 提供了部分设计思路

还有其他很多大神的类似作品

###RES:
[iconfont](http://www.iconfont.cn/) 提供icon素材

[material UP](http://www.material.uplabs.com/) 提供Material Design风格的素材

###LIB:
//ui
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'

//rx
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'

//network
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'

//di
compile 'com.google.dagger:dagger:2.0.2'
compile 'com.google.dagger:dagger-compiler:2.0.2'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
provided 'org.glassfish:javax.annotation:10.0-b28'

//other
compile 'com.umeng.analytics:analytics:latest.integration'
compile 'com.orhanobut:logger:1.15'
compile 'me.yokeyword:fragmentation:0.7.9'
compile 'me.yokeyword:fragmentation-swipeback:0.7.9'
compile 'com.victor:lib:1.0.4'
compile 'com.prolificinteractive:material-calendarview:1.4.0'
compile 'net.opacapp:multiline-collapsingtoolbar:1.2.2'
compile 'com.github.chrisbanes:PhotoView:1.3.0'
compile 'com.miguelcatalan:materialsearchview:1.4.0'

//canary
debugCompile 'com.github.moduth:blockcanary-android:1.2.1'
releaseCompile 'com.github.moduth:blockcanary-no-op:1.2.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'`


#License
-
Copyright (c) 2016 codeestX

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.codeest.geeknews.app.App;
import com.codeest.geeknews.util.LogUtil;
import com.codeest.geeknews.util.ToastUtil;

import java.io.PrintWriter;
import java.io.StringWriter;
Expand Down Expand Up @@ -39,9 +41,10 @@ public void uncaughtException(Thread thread, Throwable ex) {
LogUtil.e(TAG, ex.toString());
LogUtil.e(TAG, collectCrashDeviceInfo());
LogUtil.e(TAG, getCrashInfo(ex));

// 调用系统错误机制
defaultHandler.uncaughtException(thread, ex);
ToastUtil.shortShow("抱歉,程序发生异常即将退出");
App.getInstance().exitApp();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static void initOkHttp() {
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
builder.addInterceptor(loggingInterceptor);
}
// 缓存 http://www.jianshu.com/p/93153b34310e
// http://www.jianshu.com/p/93153b34310e
File cacheFile = new File(Constants.PATH_CACHE);
Cache cache = new Cache(cacheFile, 1024 * 1024 * 50);
Interceptor cacheInterceptor = new Interceptor() {
Expand All @@ -79,7 +79,7 @@ public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(request);
if (SystemUtil.isNetworkConnected()) {
int maxAge = 0;
// 有网络时, 不缓存
// 有网络时, 不缓存, 最大保存时长为0
response.newBuilder()
.header("Cache-Control", "public, max-age=" + maxAge)
.removeHeader("Pragma")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.codeest.geeknews.ui.main.fragment.SettingFragment;
import com.codeest.geeknews.ui.wechat.fragment.WechatMainFragment;
import com.codeest.geeknews.ui.zhihu.fragment.ZhihuMainFragment;
import com.codeest.geeknews.util.LogUtil;
import com.codeest.geeknews.util.SharedPreferenceUtil;
import com.miguelcatalan.materialsearchview.MaterialSearchView;

Expand Down Expand Up @@ -79,12 +80,16 @@ protected int getLayout() {
*/
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
SharedPreferenceUtil.setNightModeState(false);
} else {
mNavigationView.getMenu().findItem(R.id.drawer_setting).setChecked(false);
showFragment = ITEM_SETTING;
hideFragment = ITEM_ZHIHU;
showHideFragment(getTargetFragment(showFragment), getTargetFragment(hideFragment));
mNavigationView.getMenu().findItem(R.id.drawer_zhihu).setChecked(false);
hideFragment = ITEM_SETTING;
}
super.onCreate(savedInstanceState);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;

import com.codeest.geeknews.R;
import com.codeest.geeknews.base.BaseFragment;
Expand Down Expand Up @@ -54,9 +55,9 @@ protected void initEventAndData() {
public void onSwiped(int adapterPosition) {
// 滑动删除的时候,从数据源移除,并刷新这个Item。
if (mList != null) {
mPresenter.deleteLikeData(mList.get(adapterPosition).getId());
mList.remove(adapterPosition);
mAdapter.notifyItemRemoved(adapterPosition);
mPresenter.deleteLikeData(mList.get(adapterPosition).getId());
}
}

Expand Down Expand Up @@ -92,6 +93,7 @@ public void showError(String msg) {

@Override
public void showContent(List<RealmLikeBean> list) {
LogUtil.d(mList.size()+"Content");
mList.clear();
mList.addAll(list);
mAdapter.notifyDataSetChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.codeest.geeknews.model.bean.NightModeEvent;
import com.codeest.geeknews.util.ShareUtil;
import com.codeest.geeknews.util.SharedPreferenceUtil;
import com.codeest.geeknews.util.SnackbarUtil;

import java.io.File;

Expand Down Expand Up @@ -46,7 +47,6 @@ public class SettingFragment extends SimpleFragment implements CompoundButton.On

File cacheFile;
boolean isNull = true;
boolean test = true;

@Override
protected int getLayoutId() {
Expand Down Expand Up @@ -84,7 +84,7 @@ void doClear() {

@OnClick(R.id.ll_setting_update)
void doUpdate() {

SnackbarUtil.showShort(getActivity().getWindow().getDecorView(),"这个功能还没有实现哦~(>_<)~");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.codeest.geeknews.R;
import com.codeest.geeknews.component.ImageLoader;
import com.codeest.geeknews.model.bean.WXItemBean;
import com.codeest.geeknews.presenter.WechatPresenter;
import com.codeest.geeknews.ui.gank.activity.TechDetailActivity;
import com.codeest.geeknews.widget.SquareImageView;

Expand Down Expand Up @@ -54,6 +55,7 @@ public void onClick(View view) {
intent.putExtra("id",mList.get(holder.getAdapterPosition()).getPicUrl()); //wechat API 没有id,用图片来做唯一数据库索引
intent.putExtra("title",mList.get(holder.getAdapterPosition()).getTitle());
intent.putExtra("url",mList.get(holder.getAdapterPosition()).getUrl());
intent.putExtra("tech", WechatPresenter.TECH_WECHAT);
mContext.startActivity(intent);
}
});
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/codeest/geeknews/util/SnackbarUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.codeest.geeknews.util;

import android.support.design.widget.Snackbar;
import android.view.View;

/**
* Created by codeest on 16/9/3.
*/

public class SnackbarUtil {

public static void show(View view, String msg) {
Snackbar.make(view, msg, Snackbar.LENGTH_LONG);
}

public static void showShort(View view, String msg) {
Snackbar.make(view, msg, Snackbar.LENGTH_SHORT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

/**
* Created by codeest on 2016/8/24.
* http://blog.csdn.net/yanzhenjie1003/article/details/51935982
*/

public class DefaultItemTouchHelpCallback extends ItemTouchHelper.Callback {

/**
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/fragment_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
android:text="@string/setting_cache"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cb_setting_cache"
android:button="@drawable/abc_btn_check_material"
android:buttonTint="@color/colorAccent"
android:checked="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Expand All @@ -66,6 +68,8 @@
android:text="@string/setting_image"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cb_setting_image"
android:button="@drawable/abc_btn_check_material"
android:buttonTint="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Expand All @@ -88,6 +92,8 @@
android:text="@string/setting_night"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cb_setting_night"
android:button="@drawable/abc_btn_check_material"
android:buttonTint="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_like_girl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginTop="6dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="2dp"
app:cardBackgroundColor="@android:color/white"
app:cardElevation="2dp"
app:cardCornerRadius="3dp">
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/view_drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:layout_gravity="bottom|end"
android:layout_marginBottom="40dp"
android:layout_marginEnd="30dp"
android:textColor="@color/drawer_header_text"
android:textSize="28sp"
android:text="@string/app_name"/>
<TextView
Expand All @@ -22,6 +23,7 @@
android:layout_gravity="bottom|end"
android:layout_marginBottom="12dp"
android:layout_marginEnd="24dp"
android:textColor="@color/drawer_header_text"
android:textSize="16sp"
android:text="@string/app_intro"/>
</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/menu/drawer_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
android:title="@string/drawer_collection"/>
<item
android:id="@+id/drawer_setting"
android:checked="false"
android:icon="@mipmap/ic_drawer_setting"
android:checkable="true"
android:title="@string/drawer_setting"/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<color name="bottom_shadow">#6e000000</color>
<color name="drawer_item_bg_p">#e8e8e8</color>
<color name="drawer_item_bg_n">#fffff9</color>
<color name="drawer_header_text">#2c2c2c</color>
<color name="toast_bg">#dddfe0</color>
<color name="black_bg">#d0000000</color>
<color name="bottom_text">#a9a9a9</color>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash_bg</item>
</style>

</resources>

0 comments on commit a431452

Please sign in to comment.