Skip to content

Commit 2a8d283

Browse files
committed
opt ui and ads
1 parent bb38a7f commit 2a8d283

23 files changed

+124
-65
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ android {
1616
applicationId "com.brian.csdnblog"
1717
minSdkVersion 15
1818
targetSdkVersion 24
19-
versionCode 80
20-
versionName "1.3.80"
19+
versionCode 81
20+
versionName "1.3.81"
2121
multiDexEnabled true
2222
vectorDrawables.useSupportLibrary = true
2323

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
<activity
3939
android:name="com.brian.codeblog.activity.SplashActivity"
40-
android:theme="@style/AppBaseTheme"
40+
android:theme="@style/AppTheme.Launcher"
4141
android:screenOrientation="portrait">
4242
<intent-filter>
4343
<action android:name="android.intent.action.MAIN" />

app/src/main/java/com/brian/codeblog/activity/BlogContentActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private void initBlogInfo() {
208208
try {
209209
mBlogInfo = (BlogInfo) getIntent().getExtras().getSerializable(BUNDLE_EXTRAS_BLOGINFO);
210210
} catch (Exception e) {
211-
ToastUtil.showMsgS("oops,打开出错。。。");
211+
ToastUtil.showMsg("oops,打开出错。。。");
212212
return;
213213
}
214214
if (mBlogInfo == null || TextUtils.isEmpty(mBlogInfo.link)) {

app/src/main/java/com/brian/codeblog/activity/MainTabActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ protected void onStop() {
240240
protected void onDestroy() {
241241
int count = CommonPreference.getInstance().getBlogReadCount();
242242
String time = TimeUtil.convCountTime(CommonPreference.getInstance().getBlogReadTime());
243-
ToastUtil.showMsgS(String.format(Locale.CHINA, "累计学习 %d篇博文,用时 %s", count, time));
243+
ToastUtil.showMsg(String.format(Locale.CHINA, "累计学习 %d篇博文,用时 %s", count, time));
244244
super.onDestroy();
245245
OnlineConfigAgent.getInstance().removeOnlineConfigListener();
246246
SpotManager.getInstance(this).onDestroy();

app/src/main/java/com/brian/codeblog/activity/SearchActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private void onSendMsg() {
186186
loadListData(url);
187187
UsageStatsManager.sendUsageData(UsageStatsManager.USAGE_SEARCH, mInputText);
188188
} else {
189-
ToastUtil.showMsgS("请输入适当关键字");
189+
ToastUtil.showMsg("请输入适当关键字");
190190
}
191191
}
192192

app/src/main/java/com/brian/codeblog/activity/SettingActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void onClick(View v) {
153153
@Override
154154
public void onClick(View v) {
155155
UsageStatsManager.sendUsageData(UsageStatsManager.SETTING_LIST, "cache");
156-
ToastUtil.showMsgS("清除了缓存:" + FileUtil.fileSizeToString(DataManager.getInstance().getRemovableDataSize()));
156+
ToastUtil.showMsg("清除了缓存:" + FileUtil.fileSizeToString(DataManager.getInstance().getRemovableDataSize()));
157157
DataManager.getInstance().clearAllCacheData();
158158
}
159159
});

app/src/main/java/com/brian/codeblog/activity/SidePageFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void initUI() {
9090
mBlogerNameView.setText(bloger.nickName + "的博客");
9191
LogUtil.log("headUrl=" + bloger.headUrl);
9292
if (TextUtils.isEmpty(bloger.headUrl)) {
93-
mBlogerHeadView.setImageResource(R.drawable.icon_default_user);
93+
mBlogerHeadView.setImageResource(R.drawable.ic_default_user);
9494
} else {
9595
Picasso.with(Env.getContext()).load(bloger.headUrl).into(mBlogerHeadView);
9696
}
@@ -183,7 +183,7 @@ public void onEventMainThread(CurrBlogerEvent event) {
183183
mBlogerNameView.setText(event.bloger.nickName + "的博客");
184184
LogUtil.log("headUrl=" + event.bloger.headUrl);
185185
if (TextUtils.isEmpty(event.bloger.headUrl)) {
186-
mBlogerHeadView.setImageResource(R.drawable.icon_default_user);
186+
mBlogerHeadView.setImageResource(R.drawable.ic_default_user);
187187
} else {
188188
Picasso.with(Env.getContext()).load(event.bloger.headUrl).into(mBlogerHeadView);
189189
}

app/src/main/java/com/brian/codeblog/activity/SplashActivity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.brian.codeblog.activity;
22

3+
import android.content.Context;
34
import android.content.Intent;
45
import android.os.Bundle;
56
import android.os.Parcelable;
@@ -16,6 +17,7 @@
1617
import com.brian.codeblog.manager.DataManager;
1718
import com.brian.codeblog.manager.PushManager;
1819
import com.brian.codeblog.util.LogUtil;
20+
import com.brian.codeblog.util.NetStatusUtil;
1921
import com.brian.codeblog.util.PermissionUtil;
2022
import com.brian.codeblog.util.UIUtil;
2123
import com.brian.csdnblog.R;
@@ -63,7 +65,7 @@ public void run() {
6365
jumpMainActivityDeLay(2000); // 防止卡在广告页
6466
}
6567
}
66-
}, 50);
68+
}, 200);
6769
}
6870
}
6971

@@ -79,8 +81,9 @@ private void delayInitTask() {
7981
}
8082

8183
private void initAD() {
82-
AdHelper.initAd(this.getApplicationContext());
83-
if (!AdHelper.isAdCanShow) {
84+
Context context = this.getApplicationContext();
85+
AdHelper.initAd(context);
86+
if (!AdHelper.isAdCanShow || !NetStatusUtil.isWifiNet(context)) {
8487
jumpMainActivityDeLay(1000);
8588
return;
8689
}

app/src/main/java/com/brian/codeblog/parser/OsChinaHtmlParser.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,20 @@ private String doGetBlogContent(String contentSrc) {
186186
// 获取文档内容
187187
Document doc = Jsoup.parse(contentSrc);
188188
LogUtil.d("doc1=" + doc);
189-
Element detail = doc.getElementsByClass("blog-content").get(0);
189+
Element detail = null;
190+
try {
191+
detail = doc.getElementsByClass("blog-content").get(0);
192+
} catch (Exception e) {
193+
}
194+
if (detail == null) {
195+
try {
196+
detail = doc.getElementsByClass("BlogContent").get(0);
197+
} catch (Exception e) {
198+
}
199+
}
200+
if (detail == null) {
201+
return contentSrc;
202+
}
190203

191204

192205
detail.getElementsByClass("title").get(0).tagName("h1");
@@ -237,7 +250,8 @@ public String getBlogContentUrl(String... urls) {
237250
} else {
238251
blogUrl = url;
239252
}
240-
return blogUrl + "?fromerr=3WWGWBvP";
253+
return blogUrl;
254+
// return blogUrl + "?fromerr=3WWGWBvP";
241255
}
242256

243257
@Override

app/src/main/java/com/brian/codeblog/proctocol/HttpGetBlogContentRequest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
import android.text.TextUtils;
44

5+
import com.brian.codeblog.Config;
56
import com.brian.codeblog.model.BaseType;
67
import com.brian.codeblog.parser.BlogHtmlParserFactory;
78
import com.brian.codeblog.parser.IBlogHtmlParser;
89
import com.brian.codeblog.proctocol.base.AbstractHttpClient;
910
import com.brian.codeblog.proctocol.base.BaseRequestParam;
1011
import com.brian.codeblog.proctocol.base.HttpClientParam;
12+
import com.brian.codeblog.util.FileUtil;
13+
import com.brian.codeblog.util.LogUtil;
14+
import com.brian.codeblog.util.PathUtil;
15+
import com.brian.codeblog.util.ToastUtil;
1116

1217
/**
1318
* 请求博客正文
@@ -41,6 +46,12 @@ public ResultData convResponseResult(String responseContent) {
4146
if (type == -1) {
4247
throw new RuntimeException("set RequestParam.type!");
4348
}
49+
if (Config.isDebug) {
50+
String filePath = PathUtil.getCacheDirPath() + "/blog_" + System.currentTimeMillis() + ".html";
51+
FileUtil.writeFile(filePath, responseContent);
52+
LogUtil.log("filePath=" + filePath);
53+
ToastUtil.showMsg("filePath=" + filePath);
54+
}
4455
IBlogHtmlParser parser = BlogHtmlParserFactory.getBlogParser(type);
4556
ResultData resultData = new ResultData();
4657
resultData.blogContent = parser.getBlogContent(type, responseContent);

0 commit comments

Comments
 (0)