Skip to content

Commit

Permalink
Split project&&Supprt horizontal refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dkzwm committed Oct 23, 2017
1 parent ff72c1c commit 9c8e3ae
Show file tree
Hide file tree
Showing 111 changed files with 1,810 additions and 550 deletions.
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/dictionaries/dkzwm1.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apply plugin: 'com.android.application'

android {
Expand All @@ -8,8 +7,8 @@ android {
applicationId "me.dkzwm.smoothrefreshlayout.sample"
minSdkVersion 16
targetSdkVersion 26
versionCode 28
versionName "1.4.8"
versionCode 29
versionName "1.5.0"
}
buildTypes {
release {
Expand All @@ -19,9 +18,12 @@ android {
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile project(':core')
compile project(':ext-two-level')
compile project(':ext-horizontal')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
Expand All @@ -32,10 +34,8 @@ dependencies {
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.github.bumptech.glide:glide:4.2.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
}



3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<activity
android:name="me.dkzwm.widget.srl.sample.ui.TestBaseRecyclerViewAdapterActivity"
android:screenOrientation="portrait"/>
<activity
android:name="me.dkzwm.widget.srl.sample.ui.TestHorizontalRefreshActivity"
android:screenOrientation="portrait"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CustomQQActivityHeader(@NonNull Context context, @Nullable AttributeSet a
public CustomQQActivityHeader(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
View header = LayoutInflater.from(context).inflate(R.layout.layout_custom_qq_activity_header, this);
mTextViewTitle = (TextView) header.findViewById(R.id.textView_QQ_activity_header_title);
mTextViewTitle = (TextView) header.findViewById(R.id.textView_qq_activity_header_title);
}


Expand Down Expand Up @@ -64,7 +64,7 @@ public View getView() {
@Override
public void onFingerUp(SmoothRefreshLayout layout, IIndicator indicator) {
final int mOffsetToRefresh = indicator.getOffsetToRefresh();
final int currentPos = indicator.getCurrentPosY();
final int currentPos = indicator.getCurrentPos();

if (currentPos > mOffsetToRefresh) {
mCount++;
Expand Down Expand Up @@ -97,7 +97,7 @@ public void onRefreshComplete(SmoothRefreshLayout layout,boolean isSuccessful) {
@Override
public void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, IIndicator indicator) {
final int mOffsetToRefresh = indicator.getOffsetToRefresh();
final int currentPos = indicator.getCurrentPosY();
final int currentPos = indicator.getCurrentPos();

if (currentPos > mOffsetToRefresh && !mStartedCounter) {
if (indicator.hasTouched() && status == SmoothRefreshLayout.SR_STATUS_PREPARE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onRefreshComplete(SmoothRefreshLayout frame, boolean isSuccessful) {

@Override
public void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, ITwoLevelIndicator indicator) {
final int currentPos = indicator.getCurrentPosY();
final int currentPos = indicator.getCurrentPos();
if (layout instanceof TwoLevelSmoothRefreshLayout) {
TwoLevelSmoothRefreshLayout refreshLayout = (TwoLevelSmoothRefreshLayout) layout;
if (!refreshLayout.isDisabledTwoLevelRefresh()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void onRefreshComplete(SmoothRefreshLayout layout, boolean isSuccessful)

@Override
public void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, IIndicator indicator) {
mCurrentPosY = indicator.getCurrentPosY();
mCurrentPosY = indicator.getCurrentPos();
mHasLeftHeaderHeight = mCurrentPosY > indicator.getHeaderHeight();
if (status == SmoothRefreshLayout.SR_STATUS_PREPARE
|| status == SmoothRefreshLayout.SR_STATUS_COMPLETE) {
Expand All @@ -344,7 +344,7 @@ public void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, II

@Override
public void onPureScrollPositionChanged(SmoothRefreshLayout layout, byte status, IIndicator indicator) {
mCurrentPosY = indicator.getCurrentPosY();
mCurrentPosY = indicator.getCurrentPos();
mHasLeftHeaderHeight = mCurrentPosY > indicator.getHeaderHeight();
float currentPercent = Math.min(1f, indicator.getCurrentPercentOfRefreshOffset());
setProgress(currentPercent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public View getView() {

@Override
public void onFingerUp(SmoothRefreshLayout layout, IIndicator indicator) {
mFingerUpY = indicator.getCurrentPosY();
mFingerUpY = indicator.getCurrentPos();
if (layout.isEnabledKeepRefreshView() && mStatus != SmoothRefreshLayout.SR_STATUS_COMPLETE) {
final int offsetToKeepHeader = indicator.getOffsetToKeepHeaderWhileLoading();
if (mFingerUpY > offsetToKeepHeader && !layout.isDisabledPerformRefresh()) {
Expand Down Expand Up @@ -283,7 +283,7 @@ public void onRefreshComplete(SmoothRefreshLayout layout, boolean isSuccessful)

@Override
public void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, IIndicator indicator) {
mCurrentPosY = indicator.getCurrentPosY();
mCurrentPosY = indicator.getCurrentPos();
final int width = getWidth();
final float[] lastMovePoint = indicator.getLastMovePoint();
final int offsetToKeepHeader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void onChanged(byte status, IIndicator indicator) {
findViewById(R.id.button_main_test_nested_view_pager).setOnClickListener(this);
findViewById(R.id.button_main_test_base_recyclerView_adapter).setOnClickListener(this);
findViewById(R.id.button_main_test_nested_horizontal_views).setOnClickListener(this);
findViewById(R.id.button_main_test_horizontal_refresh).setOnClickListener(this);
mButtonDebug = (Button) findViewById(R.id.button_main_debug);
mButtonDebug.setOnClickListener(this);
}
Expand Down Expand Up @@ -161,6 +162,9 @@ public void onClick(View v) {
Toast.makeText(this, getString(R.string.current_version) + BuildConfig.VERSION_NAME,
Toast.LENGTH_SHORT).show();
break;
case R.id.button_main_test_horizontal_refresh:
startActivity(new Intent(MainActivity.this, TestHorizontalRefreshActivity.class));
break;
case R.id.button_main_debug:
SmoothRefreshLayout.debug(!SmoothRefreshLayout.isDebug());
if (SmoothRefreshLayout.isDebug()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public void run() {
}, 2000);
}
}, mRecyclerView);
mRefreshLayout.setOnChildScrollUpCallback(new SmoothRefreshLayout.OnChildScrollUpCallback() {
mRefreshLayout.setOnChildAlreadyInEdgeCanMoveHeaderCallBack(new SmoothRefreshLayout.OnChildAlreadyInEdgeCanMoveHeaderCallBack() {
@Override
public boolean canChildScrollUp(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView header) {
public boolean isChildAlreadyInEdgeCanMoveHeader(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView header) {
return ScrollCompat.canChildScrollUp(mRecyclerView);
}
});
mRefreshLayout.setOnChildScrollDownCallback(new SmoothRefreshLayout.OnChildScrollDownCallback() {
mRefreshLayout.setOnChildAlreadyInEdgeCanMoveFooterCallBack(new SmoothRefreshLayout.OnChildAlreadyInEdgeCanMoveFooterCallBack() {
@Override
public boolean canChildScrollDown(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView footer) {
public boolean isChildAlreadyInEdgeCanMoveFooter(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView footer) {
return ScrollCompat.canChildScrollDown(mRecyclerView);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package me.dkzwm.widget.srl.sample.ui;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import me.dkzwm.widget.srl.RefreshingListenerAdapter;
import me.dkzwm.widget.srl.SmoothRefreshLayout;
import me.dkzwm.widget.srl.extra.footer.HorizontalMaterialFooter;
import me.dkzwm.widget.srl.extra.header.HorizontalMaterialHeader;
import me.dkzwm.widget.srl.sample.R;
import me.dkzwm.widget.srl.utils.PixelUtl;

/**
* Created by dkzwm on 2017/9/13.
*
* @author dkzwm
*/

public class TestHorizontalRefreshActivity extends AppCompatActivity {
private SmoothRefreshLayout mRefreshLayout;
private Handler mHandler = new Handler();

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_horizontal_refresh);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.test_nested_horizontal_views);
mRefreshLayout = (SmoothRefreshLayout) findViewById(R.id
.smoothRefreshLayout_test_horizontal_refresh);
HorizontalMaterialHeader header = new HorizontalMaterialHeader(this);
header.setColorSchemeColors(new int[]{Color.RED, Color.BLUE, Color
.GREEN, Color.BLACK});
header.setPadding(PixelUtl.dp2px(this, 25), 0, PixelUtl.dp2px(this, 25), 0);
mRefreshLayout.setHeaderView(header);
HorizontalMaterialFooter footer = new HorizontalMaterialFooter(this);
footer.setProgressBarColors(new int[]{Color.RED, Color.BLUE, Color
.GREEN, Color.BLACK});
mRefreshLayout.setFooterView(footer);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.setDisablePerformLoadMore(false);
mRefreshLayout.setEnableKeepRefreshView(true);
mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(boolean isRefresh) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mRefreshLayout.refreshComplete();
Toast.makeText(TestHorizontalRefreshActivity.this,
R.string.sr_refresh_complete, Toast.LENGTH_SHORT).show();
}
}, 4000);
}
});
mRefreshLayout.setOffsetRatioToKeepRefreshViewWhileLoading(1);
mRefreshLayout.setRatioOfRefreshViewHeightToRefresh(1);
mRefreshLayout.autoRefresh(false);
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}


@Override
public void onBackPressed() {
startActivity(new Intent(TestHorizontalRefreshActivity.this, MainActivity.class));
finish();
}

@Override
protected void onDestroy() {
super.onDestroy();
mHandler.removeCallbacksAndMessages(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.test_material_style);
mTextView = (TextView) findViewById(R.id.textView_test_refresh_activity_desc);
mRefreshLayout = (MaterialSmoothRefreshLayout) findViewById(R.id.smoothRefreshLayout_test_refresh_activity);
mTextView = (TextView) findViewById(R.id.textView_test_refresh_desc);
mRefreshLayout = (MaterialSmoothRefreshLayout) findViewById(R.id.smoothRefreshLayout_test_refresh);
mRefreshLayout.materialStyle();
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
Expand Down
Loading

0 comments on commit 9c8e3ae

Please sign in to comment.