Skip to content

Commit

Permalink
完成 1.0.2 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
wsc committed Jul 22, 2017
1 parent 8c3667f commit c5f5351
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 2 deletions refresh-footer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
// provided 'com.android.support:support-annotations:25.3.1'
// provided 'com.android.support:support-v4:25.3.1'
provided 'com.android.support:support-compat:25.3.1'
provided project(':refresh-layout')
}

Expand Down
1 change: 0 additions & 1 deletion refresh-header/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
// provided 'com.android.support:support-annotations:25.3.1'
provided 'com.android.support:support-compat:25.3.1'
provided project(':refresh-layout')
}
Expand Down
4 changes: 0 additions & 4 deletions refresh-layout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
// provided 'com.android.support:support-annotations:25.3.1'
// provided 'com.android.support:support-v4:25.3.1'
// provided 'com.android.support:support-compat:25.3.1'
// provided 'com.android.support:recyclerview-v7:25.3.1'
provided 'com.android.support:design:25.3.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
Expand Down Expand Up @@ -72,7 +71,7 @@ private void initView(Context context, AttributeSet attrs, int defStyleAttr) {
lpPathView.rightMargin = density.dip2px(10);
addView(mProgressView, lpPathView);

mBottomText = new AppCompatTextView(context, attrs, defStyleAttr);
mBottomText = new TextView(context, attrs, defStyleAttr);
mBottomText.setTextColor(0xff666666);
mBottomText.setTextSize(16);
mBottomText.setText(REFRESH_FOOTER_PULLUP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,21 @@ private void initView(Context context, AttributeSet attrs, int defStyleAttr) {

ta.recycle();

if (context instanceof FragmentActivity) {
FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager();
if (manager != null) {
List<Fragment> fragments = manager.getFragments();
if (fragments != null && fragments.size() > 0) {
setLastUpdateTime(new Date());
return;
try {//try 不能删除-否则会出现兼容性问题
if (context instanceof FragmentActivity) {
FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager();
if (manager != null) {
List<Fragment> fragments = manager.getFragments();
if (fragments != null && fragments.size() > 0) {
setLastUpdateTime(new Date());
return;
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}

KEY_LAST_UPDATE_TIME += context.getClass().getName();
mShared = context.getSharedPreferences("ClassicsHeader", Context.MODE_PRIVATE);
setLastUpdateTime(new Date(mShared.getLong(KEY_LAST_UPDATE_TIME, System.currentTimeMillis())));
Expand Down Expand Up @@ -282,7 +287,7 @@ public void run() {
public ClassicsHeader setLastUpdateTime(Date time) {
mLastTime = time;
mLastUpdateText.setText(mFormat.format(time));
if (mShared != null) {
if (mShared != null && !isInEditMode()) {
mShared.edit().putLong(KEY_LAST_UPDATE_TIME, time.getTime()).apply();
}
return this;
Expand Down

0 comments on commit c5f5351

Please sign in to comment.