Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
codeestX committed Sep 6, 2016
1 parent f70bb63 commit 49e9f6e
Show file tree
Hide file tree
Showing 30 changed files with 295 additions and 181 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ GeekNews, A pure reading App based on Material Design + MVP + RxJava + Retrofit

###Preview

![](https://github.com/codeestX/GeekNews/raw/master/screenshots/part1.gif)      
![](https://github.com/codeestX/GeekNews/raw/master/screenshots/part2.gif)      
![](https://github.com/codeestX/GeekNews/raw/master/screenshots/part3.gif)
![](https://github.com/codeestX/GeekNews/raw/master/screenshots/GIF1.gif)    
![](https://github.com/codeestX/GeekNews/raw/master/screenshots/GIF2.gif)    
![](https://github.com/codeestX/GeekNews/raw/master/screenshots/GIF3.gif)

###Download APK

Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ dependencies {
compile 'com.umeng.analytics:analytics:latest.integration'
compile 'com.orhanobut:logger:1.15'
compile 'me.yokeyword:fragmentation:0.7.9'

//widget
compile 'com.victor:lib:1.0.4'
compile 'com.prolificinteractive:material-calendarview:1.4.0'
compile 'net.opacapp:multiline-collapsingtoolbar:1.2.2'
Expand Down
30 changes: 19 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:hardwareAccelerated="true"
android:theme="@style/AppTheme"
android:screenOrientation="portrait">
android:theme="@style/AppTheme">

//主类
<activity android:name=".ui.main.activity.WelcomeActivity"
android:theme="@style/SplashTheme">
android:theme="@style/SplashTheme"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -28,26 +28,34 @@
</activity>
<activity android:name="com.codeest.geeknews.ui.main.activity.MainActivity"
android:launchMode="singleTop"
android:theme="@style/SplashTheme">
android:theme="@style/SplashTheme"
android:screenOrientation="portrait">
</activity>

//知乎
<activity android:name=".ui.zhihu.activity.CalendarActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>
<activity android:name=".ui.zhihu.activity.ZhihuDetailActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>
<activity android:name=".ui.zhihu.activity.CommentActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>
<activity android:name=".ui.zhihu.activity.ThemeActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>
<activity android:name=".ui.zhihu.activity.SectionActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>

//Gank
<activity android:name=".ui.gank.activity.TechDetailActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>
<activity android:name=".ui.gank.activity.GirlDetailActivity"
android:launchMode="singleTop" />
android:launchMode="singleTop"
android:screenOrientation="portrait"/>

<meta-data
android:value="YOUR_APP_KEY"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/codeest/geeknews/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import com.codeest.geeknews.di.component.AppComponent;
import com.codeest.geeknews.di.component.DaggerAppComponent;
import com.codeest.geeknews.di.module.AppModule;
import com.codeest.geeknews.widget.AppBlockCanaryContext;
import com.github.moduth.blockcanary.BlockCanary;
import com.orhanobut.logger.Logger;
import com.squareup.leakcanary.LeakCanary;

import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -52,6 +55,12 @@ public void onCreate() {

//初始化错误收集
CrashHandler.init(new CrashHandler(getApplicationContext()));

//初始化内存泄漏检测
LeakCanary.install(this);

//初始化过度绘制检测
BlockCanary.install(this, new AppBlockCanaryContext()).start();
}

public void addActivity(Activity act) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.codeest.geeknews.model.db.RealmHelper;
import com.codeest.geeknews.model.http.RetrofitHelper;
import com.codeest.geeknews.presenter.contract.DailyContract;
import com.codeest.geeknews.util.DateUtil;
import com.codeest.geeknews.util.LogUtil;
import com.codeest.geeknews.util.RxUtil;
import com.prolificinteractive.materialcalendarview.CalendarDay;
Expand Down Expand Up @@ -66,6 +67,16 @@ public String call(CalendarDay calendarDay) {
return date.append(year).append(month).append(day).toString();
}
})
.filter(new Func1<String, Boolean>() {
@Override
public Boolean call(String s) {
if(s.equals(DateUtil.getCurrentDate())) {
getDailyData();
return false;
}
return true;
}
})
.observeOn(Schedulers.io()) //为了网络请求切到io线程
.flatMap(new Func1<String, Observable<DailyBeforeListBean>>() {
@Override
Expand Down Expand Up @@ -126,7 +137,6 @@ public void call(DailyListBean dailyListBean) {
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
LogUtil.d(throwable.toString());
mView.showError("数据加载失败ヽ(≧Д≦)ノ");
}
});
Expand All @@ -137,6 +147,16 @@ public void call(Throwable throwable) {
public void getBeforeData(String date) {
Subscription rxSubscription = mRetrofitHelper.fetchDailyBeforeListInfo(date)
.compose(RxUtil.<DailyBeforeListBean>rxSchedulerHelper())
.map(new Func1<DailyBeforeListBean, DailyBeforeListBean>() {
@Override
public DailyBeforeListBean call(DailyBeforeListBean dailyBeforeListBean) {
List<DailyListBean.StoriesBean> list = dailyBeforeListBean.getStories();
for(DailyListBean.StoriesBean item : list) {
item.setReadState(mRealmHelper.queryNewsId(item.getId()));
}
return dailyBeforeListBean;
}
})
.subscribe(new Action1<DailyBeforeListBean>() {
@Override
public void call(DailyBeforeListBean dailyBeforeListBean) {
Expand Down Expand Up @@ -171,7 +191,9 @@ public void call(Long aLong) {

@Override
public void stopInterval() {
intervalSubscription.unsubscribe();
if (intervalSubscription != null) {
intervalSubscription.unsubscribe();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void call(List<GankItemBean> gankItemBeen) {
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
mView.showError("加载数据失败");
mView.showError("数据加载失败ヽ(≧Д≦)ノ");
}
});
addSubscrebe(rxSubscription);
Expand All @@ -64,7 +64,7 @@ public void call(List<GankItemBean> gankItemBeen) {
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
mView.showError("加载更多数据失败");
mView.showError("加载更多数据失败ヽ(≧Д≦)ノ");
}
});
addSubscrebe(rxSubscription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void call(List<GankItemBean> gankItemBeen) {
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
mView.showError("加载数据失败");
mView.showError("数据加载失败ヽ(≧Д≦)ノ");
}
});
addSubscrebe(rxSubscription);
Expand All @@ -147,7 +147,7 @@ public void call(List<GankItemBean> gankItemBeen) {
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
mView.showError("加载更多数据失败");
mView.showError("加载更多数据失败ヽ(≧Д≦)ノ");
}
});
addSubscrebe(rxSubscription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
break;
case R.id.action_save:
SystemUtil.saveBitmapToFile(mContext,url,bitmap);
SystemUtil.saveBitmapToFile(mContext,url,bitmap,ivGirlDetail,false);
break;
case R.id.action_share:
ShareUtil.shareImage(mContext,SystemUtil.saveBitmapToFile(mContext,url,bitmap),"分享一只妹纸");
ShareUtil.shareImage(mContext,SystemUtil.saveBitmapToFile(mContext,url,bitmap,ivGirlDetail,true),"分享一只妹纸");
break;
}
return super.onOptionsItemSelected(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
SystemUtil.copyToClipBoard(mContext,url);
return true;
case R.id.action_share:
ShareUtil.shareText(mContext,url,"分享一篇文章");
ShareUtil.shareText(mContext,title + " " + url,"分享一篇文章");
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.graphics.Bitmap;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -15,14 +14,10 @@
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.codeest.geeknews.R;
import com.codeest.geeknews.component.ImageLoader;
import com.codeest.geeknews.model.bean.GankItemBean;
import com.codeest.geeknews.presenter.TechPresenter;
import com.codeest.geeknews.presenter.contract.MainContract;
import com.codeest.geeknews.util.DateUtil;
import com.codeest.geeknews.util.ImageUtil;
import com.codeest.geeknews.util.LogUtil;
import com.codeest.geeknews.util.SystemUtil;

import java.util.List;

Expand Down Expand Up @@ -102,12 +97,12 @@ public void onClick(View view) {
});
} else if(holder instanceof TopViewHolder) {
if (url != null) {
ImageLoader.load(mContext, url, ((TopViewHolder)holder).ivOrigin);
ivOrigin = ((TopViewHolder)holder).ivOrigin;
Glide.with(mContext).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
((TopViewHolder)holder).ivBlur.setImageBitmap(ImageUtil.doBlur(resource, 50 , true));
((TopViewHolder)holder).ivOrigin.setImageBitmap(resource);
((TopViewHolder)holder).ivBlur.setImageBitmap(ImageUtil.doBlur(resource, 50 , false));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.codeest.geeknews.ui.main.activity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.NavigationView;
Expand All @@ -10,6 +11,7 @@
import android.view.MenuItem;

import com.codeest.geeknews.R;
import com.codeest.geeknews.app.App;
import com.codeest.geeknews.app.Constants;
import com.codeest.geeknews.base.BaseActivity;
import com.codeest.geeknews.component.RxBus;
Expand Down Expand Up @@ -185,10 +187,24 @@ public void onBackPressedSupport() {
if (mSearchView.isSearchOpen()) {
mSearchView.closeSearch();
} else {
super.onBackPressedSupport();
showExitDialog();
}
}

private void showExitDialog() {
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(this);
builder.setTitle("提示");
builder.setMessage("确定退出GeekNews吗");
builder.setNegativeButton("取消", null);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
App.getInstance().exitApp();
}
});
builder.show();
}

private SupportFragment getTargetFragment(String item) {
switch (item) {
case ITEM_ZHIHU:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ protected void onDestroy() {

@Override
public void showError(String msg) {
//使用默认图片

}
}
Loading

0 comments on commit 49e9f6e

Please sign in to comment.