Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit fa2df1b

Browse files
committed
修复一些BUG
1 parent b7552f6 commit fa2df1b

File tree

18 files changed

+137
-74
lines changed

18 files changed

+137
-74
lines changed

‎.idea/modules.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎module-blog/src/main/java/com/rae/cnblogs/blog/BloggerActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import org.greenrobot.eventbus.EventBus;
4343

44+
import java.net.URLDecoder;
4445
import java.util.ArrayList;
4546
import java.util.List;
4647

@@ -275,7 +276,7 @@ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable>
275276

276277
// @Override
277278
public String getBlogApp() {
278-
return mBlogApp;
279+
return URLDecoder.decode(mBlogApp);
279280
}
280281

281282
@Override

‎module-discover/src/main/java/com/rae/cnblogs/discover/column/detail/AntColumnDetailAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ private void bindRootLevel1View(BaseViewHolder helper, ColumnDetailCatalogEntity
119119
AntIntroArticlesInfo info = item.getIntroArticlesInfo();
120120
TextView textView = helper.getView(R.id.tv_title);
121121
Context context = helper.itemView.getContext();
122+
helper.addOnClickListener(R.id.tv_title);
122123

123124
// 说明
124125
if (item.isDesc()) {

‎module-discover/src/main/java/com/rae/cnblogs/discover/ui/AntColumnDetailActivity.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,24 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
125125
mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
126126
@Override
127127
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
128+
AntColumnInfo columnInfo = mAdapter.getColumnInfo();
129+
if (columnInfo == null) return;
130+
128131
// 查看目录大纲图片
129-
if (view.getId() == R.id.btn_catalog && mAdapter.getColumnInfo() != null) {
130-
AppRoute.routeToImagePreview(getContext(), mAdapter.getColumnInfo().getOutlineImgOriginal());
132+
if (view.getId() == R.id.btn_catalog && columnInfo != null) {
133+
AppRoute.routeToImagePreview(getContext(), columnInfo.getOutlineImgOriginal());
134+
}
135+
136+
// 点击目录标题
137+
if (view.getId() == R.id.tv_title) {
138+
if (columnInfo.isSubscribe()) {
139+
// 已订阅的话跳掉详情
140+
AppRoute.routeToAntUserColumnDetail(getContext(), columnInfo.getId());
141+
} else {
142+
UICompat.toastInCenter(getContext(), "请先订阅专栏");
143+
}
131144
}
145+
132146
}
133147
});
134148

@@ -256,6 +270,10 @@ public void onSubscribeError(String message) {
256270

257271
@Override
258272
public void onSubscribeSuccess() {
273+
AntColumnInfo columnInfo = mAdapter.getColumnInfo();
274+
if (columnInfo != null) {
275+
columnInfo.setSubscribe(true);
276+
}
259277
UICompat.toast(this, getString(R.string.subscribe_success));
260278
UICompat.scaleIn(mStudyButton);
261279
}

‎module-discover/src/main/res/layout/item_column_category_level0.xml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,37 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="wrap_content"
5-
android:background="@drawable/public_divider_while_primary"
5+
android:background="@color/white"
66
android:gravity="center"
77
android:paddingStart="24dp"
88
android:paddingEnd="24dp">
99

10-
<TextView
11-
android:id="@+id/tv_title"
12-
android:layout_width="0dp"
10+
<LinearLayout
11+
android:layout_width="match_parent"
1312
android:layout_height="wrap_content"
14-
android:layout_weight="1"
15-
android:ellipsize="end"
16-
android:singleLine="true"
17-
android:text="订阅须知"
18-
android:textColor="@color/black"
19-
android:textSize="16sp"
20-
android:textStyle="bold" />
13+
android:background="@drawable/public_divider_while_primary"
14+
android:gravity="center">
2115

22-
<ImageView
23-
android:id="@+id/img_arrow"
24-
android:layout_width="wrap_content"
25-
android:layout_height="wrap_content"
26-
android:padding="12dp"
27-
android:rotation="180"
28-
android:src="@drawable/icon_arrow_up" />
16+
<TextView
17+
android:id="@+id/tv_title"
18+
android:layout_width="0dp"
19+
android:layout_height="wrap_content"
20+
android:layout_weight="1"
21+
android:ellipsize="end"
22+
android:singleLine="true"
23+
android:text="订阅须知"
24+
android:textColor="@color/black"
25+
android:textSize="16sp"
26+
android:textStyle="bold" />
27+
28+
<ImageView
29+
android:id="@+id/img_arrow"
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:padding="12dp"
33+
android:rotation="180"
34+
android:src="@drawable/icon_arrow_up" />
35+
36+
</LinearLayout>
2937

3038
</LinearLayout>

‎module-middleware/src/main/java/com/rae/cnblogs/ContentEntityConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static BlogBean convertToBlog(ContentEntity b) {
2727
m.setViews(b.getViewCount());
2828
m.setComment(b.getCommentCount());
2929
m.setLikes(b.getLikeCount());
30-
m.setBlogApp(b.getAuthor());
30+
m.setBlogApp(b.getAuthorId());
3131
m.setUrl(b.getUrl());
3232
m.setThumbUrls(AppGson.toJson(b.getThumbs()));
3333
return m;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:angle="90"
5+
android:endColor="#00000000"
6+
android:startColor="@color/black" />
7+
</shape>

‎module-middleware/src/main/res/layout/activity_image_preview.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@
6262
android:layout_height="wrap_content"
6363
android:layout_alignParentBottom="true"
6464
android:layout_centerHorizontal="true"
65-
android:layout_marginBottom="@dimen/default_margin"
66-
android:layout_marginLeft="@dimen/default_margin"
67-
android:layout_marginRight="@dimen/default_margin">
65+
android:background="@drawable/bg_default_mask"
66+
android:padding="20dp">
6867

6968
<TextView
7069
android:id="@+id/tv_image_preview_count"

‎module-moment/src/main/java/com/rae/cnblogs/moment/fragment/MomentFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,15 @@ private void showToast(int type, String msg) {
223223
*/
224224
@Override
225225
public void scrollToTop() {
226-
UICompat.scrollToTop(mRecyclerView);
227226
if (mRecyclerView != null && mRecyclerView.isOnTop()) {
228227
mAppLayout.post(new Runnable() {
229228
@Override
230229
public void run() {
231230
mAppLayout.autoRefresh();
232231
}
233232
});
233+
} else {
234+
UICompat.scrollToTop(mRecyclerView);
234235
}
235236
}
236237

‎module-moment/src/main/java/com/rae/cnblogs/moment/service/MomentIntentService.java

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.greenrobot.eventbus.EventBus;
3434

3535
import java.io.File;
36+
import java.io.FileInputStream;
3637
import java.io.FileNotFoundException;
3738
import java.io.FileOutputStream;
3839
import java.io.IOException;
@@ -103,26 +104,53 @@ protected void onHandleIntent(@Nullable final Intent intent) {
103104
.observeOn(AndroidSchedulers.mainThread())
104105
// 压缩图片
105106
.map(new Function<ImageMetaData, ImageMetaData>() {
107+
106108
@Override
107109
public ImageMetaData apply(ImageMetaData imageMetaData) throws Exception {
108-
imageMetaData.localPath = composeImage(imageMetaData.localPath);
110+
// 压缩图片
111+
imageMetaData.setLocalPath(composeImage(imageMetaData.localPath));
109112
return imageMetaData;
110113
}
111114

112115
/**
113116
* 压缩图片小于2M
114117
*/
115-
private String composeImage(String output) throws IOException {
118+
private String composeImage(String filePath) throws IOException {
119+
// 复制图片
120+
String output = new File(getExternalCacheDir(), "temp" + System.currentTimeMillis() + ".jpg").getAbsolutePath();
121+
FileOutputStream fileOutputStream = new FileOutputStream(output);
122+
FileInputStream fileInputStream = new FileInputStream(filePath);
123+
int len;
124+
byte[] buffer = new byte[128];
125+
while ((len = fileInputStream.read(buffer)) != -1) {
126+
fileOutputStream.write(buffer, 0, len);
127+
}
128+
fileOutputStream.flush();
129+
fileInputStream.close();
130+
fileOutputStream.close();
131+
132+
Log.d(TAG, "复制图片:" + filePath + " 到 " + output);
133+
116134
BitmapFactory.Options opt = new BitmapFactory.Options();
117135
opt.inJustDecodeBounds = true;
118136
BitmapFactory.decodeFile(output, opt);
119137

120-
if (opt.outWidth > opt.outHeight) {
121-
opt.inSampleSize = opt.outWidth / 320;
122-
} else {
123-
opt.inSampleSize = opt.outHeight / 680;
138+
// if (opt.outWidth > opt.outHeight) {
139+
// opt.inSampleSize = opt.outWidth / 320;
140+
// } else {
141+
// opt.inSampleSize = opt.outHeight / 680;
142+
// }
143+
144+
final int reqWidth = 720;
145+
final int reqHeight = 1280;
146+
147+
if (opt.outHeight > reqHeight || opt.outWidth > reqWidth) {
148+
final int heightRatio = Math.round((float) opt.outHeight / (float) reqHeight);
149+
final int widthRatio = Math.round((float) opt.outWidth / (float) reqHeight);
150+
opt.inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio;//用最大
124151
}
125152

153+
126154
//避免出现内存溢出的情况,进行相应的属性设置。
127155
opt.inPreferredConfig = Bitmap.Config.RGB_565;
128156
opt.inJustDecodeBounds = false;
@@ -134,13 +162,10 @@ private String composeImage(String output) throws IOException {
134162
throw new IOException("图片加载失败,可能由于图片太大了");
135163
}
136164
Log.d(TAG, "图片压缩前大小:" + output + "--> " + bmp.getByteCount());
137-
Bitmap result = BitmapCompressor.compressBitmap(bmp, 2048);
165+
Bitmap result = BitmapCompressor.compressBitmap(bmp, 4096);
138166
File file = new File(output);
139-
if (file.exists()) {
140-
file.delete();
141-
}
142167
FileOutputStream stream = new FileOutputStream(file);
143-
result.compress(Bitmap.CompressFormat.JPEG, 90, stream);
168+
result.compress(Bitmap.CompressFormat.JPEG, 100, stream);
144169
stream.close();
145170
stream.flush();
146171

@@ -175,6 +200,11 @@ public ImageMetaData apply(String url) {
175200
@Override
176201
public ObservableSource<String> apply(final ImageMetaData data) {
177202
Log.d(TAG, "正在转换短连接:" + data.remoteUrl);
203+
204+
// 到这里图片上传成功,删除临时图片
205+
boolean delete = new File(data.localPath).delete();
206+
Log.d(TAG, "删除图片:[" + delete + "] " + data.localPath);
207+
178208
return mPostApi.shotUrl(BuildConfig.WEIBO_APP_ID, data.remoteUrl)
179209
.map(new Function<String, String>() {
180210
@Override

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /