Skip to content

Commit

Permalink
Merge pull request #11 from HamidrezaAmz/developer
Browse files Browse the repository at this point in the history
update code - revert Scroll Direction
  • Loading branch information
HamidrezaAmz authored Mar 14, 2019
2 parents 2328e1e + d8a9882 commit c4ad160
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 18
versionName "1.1.8"
versionCode 19
versionName "1.1.9"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
20 changes: 20 additions & 0 deletions library/src/main/java/com/vasl/recyclerlibrary/MyCustomView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

import com.tuyenmonkey.mkloader.MKLoader;
import com.vasl.recyclerlibrary.globalEnums.ListStatus;
import com.vasl.recyclerlibrary.globalEnums.ScrollDirection;
import com.vasl.recyclerlibrary.globalInterfaces.MyCustomViewCallBack;
import com.vasl.recyclerlibrary.globalInterfaces.MyCustomViewScrollCallBack;
import com.vasl.recyclerlibrary.utils.PublicFunction;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;
Expand Down Expand Up @@ -102,6 +104,24 @@ private void init(AttributeSet attrs) {

// recycler-view
recyclerView = view.findViewById(R.id.recyclerView);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {

}

@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0) {
if (myCustomViewScrollCallBack != null)
myCustomViewScrollCallBack.onScrollChange(ScrollDirection.UP);
} else {
if (myCustomViewScrollCallBack != null)
myCustomViewScrollCallBack.onScrollChange(ScrollDirection.DOWN);
}
}
});

// swipe-view
swipeRefreshLayout = view.findViewById(R.id.swipeHolder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.vasl.recyclerlibrary.globalInterfaces;

import com.vasl.recyclerlibrary.globalEnums.ScrollDirection;

public interface MyCustomViewScrollCallBack {

void endOfList();
void onScrollChange(ScrollDirection scrollDirection);

}
15 changes: 13 additions & 2 deletions sample/src/main/java/com/vasl/Library/Android/BlankFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

import com.vasl.recyclerlibrary.MyCustomView;
import com.vasl.recyclerlibrary.globalEnums.ListStatus;
import com.vasl.recyclerlibrary.globalEnums.ScrollDirection;
import com.vasl.recyclerlibrary.globalInterfaces.MyCustomAdapterCallBack;
import com.vasl.recyclerlibrary.globalInterfaces.MyCustomViewCallBack;
import com.vasl.recyclerlibrary.globalInterfaces.MyCustomViewScrollCallBack;
import com.vasl.recyclerlibrary.globalObjects.RowModel;

import java.util.ArrayList;
Expand All @@ -22,7 +24,7 @@
/**
* A simple {@link Fragment} subclass.
*/
public class BlankFragment extends Fragment implements MyCustomViewCallBack, MyCustomAdapterCallBack {
public class BlankFragment extends Fragment implements MyCustomViewCallBack, MyCustomAdapterCallBack, MyCustomViewScrollCallBack {

private int index = 1;

Expand Down Expand Up @@ -55,11 +57,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

myCustomView.setMyCustomViewCallBack(this);

myCustomView.setMyCustomViewScrollCallBack(this);

adapter.setMyCustomAdapterCallBack(this);


myCustomView.setStatus(ListStatus.LOADING);

adapter = new RecyclerVerticalAdapter(getActivity(), rowModels);

adapter.setMyCustomAdapterCallBack(this);

recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false));

Expand Down Expand Up @@ -118,4 +124,9 @@ public void richToEnd() {
curr_page = curr_page + 1;
getList(curr_page);
}

@Override
public void onScrollChange(ScrollDirection scrollDirection) {

}
}

0 comments on commit c4ad160

Please sign in to comment.