Skip to content

Commit 4cb4fd1

Browse files
committed
解决5.0以下版本复制兼容问题;
1 parent 2ddf7b8 commit 4cb4fd1

12 files changed

+69
-70
lines changed

Diff for: app/build.gradle

+1-4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ android {
6868
ndk {
6969
// fix bug #504 64位系统webView问题
7070
abiFilters "armeabi"
71+
abiFilters "x86"
7172
abiFilters "armeabi-v7a"
7273
}
7374
}
@@ -135,15 +136,12 @@ dependencies {
135136
compile 'com.github.bumptech.glide:glide:4.0.0'
136137
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
137138
compile 'com.umeng.analytics:analytics:6.1.2'
138-
// 事件通知
139139
compile 'org.greenrobot:eventbus:3.0.0'
140-
// 滑动返回
141140
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
142141
compile 'com.github.chrisbanes:PhotoView:2.1.2'
143142
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
144143
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
145144
compile 'com.tencent.bugly:crashreport_upgrade:1.3.1'
146-
// 非常强悍的RecyclerView
147145
compile 'eu.davidea:flexible-adapter:5.0.0-rc2'
148146
// LeanCloud 基础包
149147
compile 'cn.leancloud.android:avoscloud-sdk:v4.4.3'
@@ -153,7 +151,6 @@ dependencies {
153151
// 主题切换
154152
compile 'skin.support:skin-support:2.1.2'
155153
compile 'skin.support:skin-support-design:1.2.5'
156-
157154
compile 'com.kyleduo.switchbutton:library:1.4.6'
158155
compile 'com.google.code.gson:gson:2.8.0'
159156
}

Diff for: app/src/main/java/android/support/design/widget/DesignTabLayout.java

+23-25
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package android.support.design.widget;
1818

19+
import android.animation.Animator;
20+
import android.animation.AnimatorListenerAdapter;
21+
import android.animation.ValueAnimator;
1922
import android.annotation.TargetApi;
2023
import android.content.Context;
2124
import android.content.res.ColorStateList;
@@ -273,7 +276,7 @@ public interface OnTabSelectedListener {
273276
private final ArrayList<OnTabSelectedListener> mSelectedListeners = new ArrayList<>();
274277
private OnTabSelectedListener mCurrentVpSelectedListener;
275278

276-
private ValueAnimatorCompat mScrollAnimator;
279+
private ValueAnimator mScrollAnimator;
277280

278281
ViewPager mViewPager;
279282
private PagerAdapter mPagerAdapter;
@@ -1094,14 +1097,13 @@ private void animateToTab(int newPosition) {
10941097
final int targetScrollX = calculateScrollXForTab(newPosition, 0);
10951098

10961099
if (startScrollX != targetScrollX) {
1097-
if (mScrollAnimator == null) {
1098-
mScrollAnimator = ViewUtils.createAnimator();
1099-
mScrollAnimator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
1100-
mScrollAnimator.setDuration(ANIMATION_DURATION);
1101-
mScrollAnimator.addUpdateListener(new ValueAnimatorCompat.AnimatorUpdateListener() {
1102-
@Override
1103-
public void onAnimationUpdate(ValueAnimatorCompat animator) {
1104-
scrollTo(animator.getAnimatedIntValue(), 0);
1100+
if(this.mScrollAnimator == null) {
1101+
this.mScrollAnimator = new ValueAnimator();
1102+
this.mScrollAnimator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
1103+
this.mScrollAnimator.setDuration(300L);
1104+
this.mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
1105+
public void onAnimationUpdate(ValueAnimator animator) {
1106+
scrollTo(((Integer)animator.getAnimatedValue()).intValue(), 0);
11051107
}
11061108
});
11071109
}
@@ -1840,7 +1842,7 @@ private class SlidingTabStrip extends LinearLayout {
18401842
private int mIndicatorLeft = -1;
18411843
private int mIndicatorRight = -1;
18421844

1843-
private ValueAnimatorCompat mIndicatorAnimator;
1845+
private ValueAnimator mIndicatorAnimator;
18441846
private int mIndicatorWidth;
18451847
private boolean mEnableIndicatorAnimate = true;
18461848

@@ -2049,24 +2051,20 @@ void animateIndicatorToPosition(final int position, int duration) {
20492051
}
20502052

20512053
if (startLeft != targetLeft || startRight != targetRight) {
2052-
ValueAnimatorCompat animator = mIndicatorAnimator = ViewUtils.createAnimator();
2054+
ValueAnimator animator = this.mIndicatorAnimator = new ValueAnimator();
20532055
animator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
2054-
animator.setDuration(duration);
2055-
animator.setFloatValues(0, 1);
2056-
animator.addUpdateListener(new ValueAnimatorCompat.AnimatorUpdateListener() {
2057-
@Override
2058-
public void onAnimationUpdate(ValueAnimatorCompat animator) {
2059-
final float fraction = animator.getAnimatedFraction();
2060-
setIndicatorPosition(
2061-
AnimationUtils.lerp(startLeft, targetLeft, fraction),
2062-
AnimationUtils.lerp(startRight, targetRight, fraction));
2056+
animator.setDuration((long)duration);
2057+
animator.setFloatValues(new float[]{0.0F, 1.0F});
2058+
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
2059+
public void onAnimationUpdate(ValueAnimator animator) {
2060+
float fraction = animator.getAnimatedFraction();
2061+
SlidingTabStrip.this.setIndicatorPosition(AnimationUtils.lerp(startLeft, targetLeft, fraction), AnimationUtils.lerp(startRight, targetRight, fraction));
20632062
}
20642063
});
2065-
animator.addListener(new ValueAnimatorCompat.AnimatorListenerAdapter() {
2066-
@Override
2067-
public void onAnimationEnd(ValueAnimatorCompat animator) {
2068-
mSelectedPosition = position;
2069-
mSelectionOffset = 0f;
2064+
animator.addListener(new AnimatorListenerAdapter() {
2065+
public void onAnimationEnd(Animator animator) {
2066+
SlidingTabStrip.this.mSelectedPosition = position;
2067+
SlidingTabStrip.this.mSelectionOffset = 0.0F;
20702068
}
20712069
});
20722070
animator.start();

Diff for: app/src/main/java/com/rae/cnblogs/ThemeCompat.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ public static class CnblogsThemeHookInflater implements SkinLayoutInflater {
3636
public View createView(@NonNull Context context, String name, @NonNull AttributeSet attributeSet) {
3737
if (TextUtils.equals("ImageView", name)) {
3838
try {
39+
// 解决compat包使用了vector,导致5.0以下低版本文章复制产生崩溃。
40+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH) {
41+
return new RaeSkinImageViewV4(context, attributeSet);
42+
}
3943
return new RaeSkinImageView(context, attributeSet);
4044
} catch (Throwable e) {
4145
e.printStackTrace();
4246
}
43-
44-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
45-
return new RaeSkinImageViewV4(context, attributeSet);
46-
}
47+
return null;
4748
}
4849
return null;
4950
}

Diff for: app/src/main/java/com/rae/cnblogs/adapter/MomentDetailAdapter.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ private void onBindCommentViewHolder(MomentCommentHolder holder, MomentCommentBe
181181
holder.dateView.setOnClickListener(onClickListener);
182182

183183
int index = mDataList.indexOf(m);
184+
holder.commentTextView.setText(holder.itemView.getContext().getString(R.string.title_comment, mMomentBean.getCommentCount()));
184185
holder.titleLayout.setVisibility(index == 0 ? View.VISIBLE : View.GONE);
185186
holder.dividerView.setVisibility(index == mDataList.size() - 1 ? View.GONE : View.VISIBLE);
186187
holder.authorView.setText(m.getAuthorName());
@@ -229,7 +230,7 @@ private void onBindDetailInfoViewHolder(MomentHolder holder, MomentBean m) {
229230
holder.authorView.setText(m.getAuthorName());
230231
holder.dateView.setText(m.getPostTime());
231232
holder.summaryView.setText(m.getContent());
232-
holder.commentView.setText(m.getCommentCount());
233+
// holder.commentView.setText(m.getCommentCount());
233234
holder.androidTagView.setVisibility(m.isAndroidClient() ? View.VISIBLE : View.GONE);
234235
}
235236

Diff for: app/src/main/java/com/rae/cnblogs/model/MomentCommentHolder.java

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class MomentCommentHolder extends SimpleViewHolder {
3232
@BindView(R.id.view_divider)
3333
public View dividerView;
3434

35+
@BindView(R.id.tv_title)
36+
public TextView commentTextView;
37+
3538
public MomentCommentHolder(View itemView) {
3639
super(itemView);
3740
ButterKnife.bind(this, itemView);

Diff for: app/src/main/java/com/rae/cnblogs/model/MomentHolder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class MomentHolder extends SimpleViewHolder {
3232
@BindView(R.id.tv_blog_date)
3333
public TextView dateView;
3434

35-
@BindView(R.id.tv_blog_comment)
35+
3636
public TextView commentView;
3737

3838
@BindView(R.id.recycler_view)
@@ -65,6 +65,7 @@ public MomentHolder(View itemView) {
6565
thumbView = itemView.findViewById(R.id.img_thumb);
6666
followView = itemView.findViewById(R.id.btn_blogger_follow);
6767
androidTagView = itemView.findViewById(R.id.tv_android_tag);
68+
commentView = itemView.findViewById(R.id.tv_blog_comment);
6869
ButterKnife.bind(this, itemView);
6970
}
7071
}

Diff for: app/src/main/java/com/rae/cnblogs/widget/RaeSkinImageViewV4.java

+27-13
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ public RaeSkinImageViewV4(Context context, AttributeSet attrs, int defStyleAttr)
3535
super(context, attrs, defStyleAttr);
3636
this.mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
3737
this.mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
38-
this.mImageHelper = new SkinCompatImageHelper(this);
39-
this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
38+
try {
39+
this.mImageHelper = new SkinCompatImageHelper(this);
40+
this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
41+
} catch (Throwable e) {
42+
e.printStackTrace();
43+
}
4044
init();
4145
}
4246

@@ -48,12 +52,15 @@ private void init() {
4852
@Override
4953
public void applySkin() {
5054
setAlpha(isNight() ? getResources().getInteger(R.integer.imageAlpha_night) / 100.0f : 1f);
51-
if (this.mBackgroundTintHelper != null) {
52-
this.mBackgroundTintHelper.applySkin();
53-
}
54-
55-
if (this.mImageHelper != null) {
56-
this.mImageHelper.applySkin();
55+
try {
56+
if (this.mBackgroundTintHelper != null) {
57+
this.mBackgroundTintHelper.applySkin();
58+
}
59+
if (this.mImageHelper != null) {
60+
this.mImageHelper.applySkin();
61+
}
62+
} catch (Throwable e) {
63+
e.printStackTrace();
5764
}
5865
}
5966

@@ -65,17 +72,24 @@ public boolean isNight() {
6572

6673
public void setBackgroundResource(@DrawableRes int resId) {
6774
super.setBackgroundResource(resId);
68-
if (this.mBackgroundTintHelper != null) {
69-
this.mBackgroundTintHelper.onSetBackgroundResource(resId);
75+
try {
76+
if (this.mBackgroundTintHelper != null) {
77+
this.mBackgroundTintHelper.onSetBackgroundResource(resId);
78+
}
79+
} catch (Throwable e) {
80+
e.printStackTrace();
7081
}
7182

7283
}
7384

7485
public void setImageResource(@DrawableRes int resId) {
75-
if (this.mImageHelper != null) {
76-
this.mImageHelper.setImageResource(resId);
86+
try {
87+
if (this.mImageHelper != null) {
88+
this.mImageHelper.setImageResource(resId);
89+
}
90+
} catch (Throwable e) {
91+
e.printStackTrace();
7792
}
78-
7993
}
8094

8195
}

Diff for: app/src/main/res/layout/item_moment_comment.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
android:layout_alignTop="@+id/img_blog_avatar"
3535
android:layout_marginLeft="12dp"
3636
android:layout_toRightOf="@+id/img_blog_avatar"
37-
android:text="全部评论"
37+
android:text="@string/title_comment"
3838
android:textColor="@color/ph1"
3939
android:textSize="@dimen/h2"/>
4040
</LinearLayout>

Diff for: app/src/main/res/layout/item_moment_detail_info.xml

+1-19
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
android:lineSpacingExtra="6sp"
7171
android:text="描述"
7272
android:textColor="@color/ph1"
73+
android:textIsSelectable="true"
7374
android:textSize="@dimen/summary"/>
7475

7576
<RelativeLayout
@@ -117,25 +118,6 @@
117118
android:textSize="@dimen/h3"/>
118119

119120

120-
<TextView
121-
android:id="@+id/tv_blog_comment"
122-
android:layout_width="wrap_content"
123-
android:layout_height="wrap_content"
124-
android:layout_marginLeft="24dp"
125-
android:gravity="center"
126-
android:text="0"
127-
android:textColor="@color/ph3"
128-
android:textSize="@dimen/h3"/>
129-
130-
<TextView
131-
android:id="@+id/tv_comment_title"
132-
android:layout_width="wrap_content"
133-
android:layout_height="wrap_content"
134-
android:text="条回复"
135-
android:textColor="@color/ph3"
136-
android:textSize="@dimen/h3"/>
137-
138-
139121
<TextView
140122
android:id="@+id/tv_android_tag"
141123
android:layout_width="wrap_content"

Diff for: app/src/main/res/layout/view_placeholder.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@
104104

105105
<ProgressBar
106106
android:id="@+id/pb_loading"
107+
style="@style/ProgressBar"
107108
android:layout_width="32dp"
108109
android:layout_height="32dp"
109-
android:indeterminateDuration="500"/>
110+
android:indeterminateDuration="1500"/>
110111

111112
<TextView
112113
android:id="@+id/tv_loading"

Diff for: app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@
150150
<string name="tips_post_moment_apply">开通博客后才能发图片,您似乎还没有开通,如果已经开通请继续。</string>
151151
<string name="blog_apply">立即申请</string>
152152
<string name="moment_unlogin_hint">登录后,更多评论等你来发现。</string>
153+
<string name="title_comment">全部评论(%s)</string>
153154
</resources>

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ ext {
5858
buildToolsVersion = '26.0.1'
5959
targetSdkVersion = 26
6060
minSdkVersion = 16
61-
supportVersion = '25.4.0'
61+
supportVersion = '26.+'
6262
}

0 commit comments

Comments
 (0)