Skip to content

Commit

Permalink
Merge pull request #15 from HamidrezaAmz/developer
Browse files Browse the repository at this point in the history
update code - added smooth scroll for horizonal lists - fix conflict …
  • Loading branch information
HamidrezaAmz authored Jul 13, 2019
2 parents d5b50b6 + bd5b3e3 commit 3f70e86
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 27 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 23
versionName "1.2.3"
versionCode 24
versionName "1.2.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
11 changes: 3 additions & 8 deletions library/src/main/java/com/vasl/recyclerlibrary/MyCustomView.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,19 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.tuyenmonkey.mkloader.MKLoader;
import com.vasl.recyclerlibrary.customViews.CustomSwipeRefreshLayout;
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.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

public class MyCustomView extends RelativeLayout implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {

private Context context;
Expand Down Expand Up @@ -68,7 +63,7 @@ public class MyCustomView extends RelativeLayout implements View.OnClickListener
private AppCompatImageView errorImageView;

// swipe
private SwipeRefreshLayout swipeRefreshLayout;
private CustomSwipeRefreshLayout swipeRefreshLayout;

// interface
private MyCustomViewCallBack myCustomViewCallBack;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.vasl.recyclerlibrary.customViews;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;

import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

public class CustomSwipeRefreshLayout extends SwipeRefreshLayout {

private int mTouchSlop;

private float mPrevX;

public CustomSwipeRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mPrevX = MotionEvent.obtain(event).getX();
break;

case MotionEvent.ACTION_MOVE:
final float eventX = event.getX();
float xDiff = Math.abs(eventX - mPrevX);

if (xDiff > mTouchSlop) {
return false;
}
}

return super.onInterceptTouchEvent(event);
}
}
4 changes: 2 additions & 2 deletions library/src/main/res/layout/layout_my_custom_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
<com.vasl.recyclerlibrary.customViews.CustomSwipeRefreshLayout
android:id="@+id/swipeHolder"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!--recycler-view-->
<include layout="@layout/layout_recycler_view" />

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</com.vasl.recyclerlibrary.customViews.CustomSwipeRefreshLayout>

<RelativeLayout
android:layout_width="match_parent"
Expand Down
3 changes: 1 addition & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<activity
android:name="com.vasl.Library.Android.MainActivity">
<activity android:name="com.vasl.Library.Android.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
22 changes: 16 additions & 6 deletions sample/src/main/java/com/vasl/Library/Android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

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;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class MainActivity extends AppCompatActivity implements MyCustomViewCallBack, MyCustomViewScrollCallBack {
public class MainActivity extends AppCompatActivity implements MyCustomViewCallBack, MyCustomViewScrollCallBack, MyCustomAdapterCallBack {

private static final String TAG = "MainActivity";

Expand Down Expand Up @@ -52,13 +54,16 @@ protected void onCreate(Bundle savedInstanceState) {

adapter = new RecyclerVerticalAdapter(MainActivity.this, rowModels);

adapter.setMyCustomAdapterCallBack(this);

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

myCustomView.setMyCustomViewScrollCallBack(this);

recyclerView.setAdapter(adapter);

getList(start_page);

}

@Override
Expand Down Expand Up @@ -92,7 +97,7 @@ public void run() {

adapter.notifyDataSetChanged();
myCustomView.setStatus(ListStatus.SUCCESS);
myCustomView.setSwipeRefreshStatus(false);
myCustomView.setSwipeRefreshStatus(true);
}
}, 1000);
}
Expand Down Expand Up @@ -138,4 +143,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onScrollChange(ScrollDirection scrollDirection) {

}

@Override
public void richToEnd() {
Toast.makeText(this, "richToEnd()", Toast.LENGTH_SHORT).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.vasl.recyclerlibrary.baseClasses.BaseRecyclerAdapter;
import com.vasl.recyclerlibrary.globalObjects.RowModel;

import java.util.ArrayList;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class RecyclerVerticalAdapter extends BaseRecyclerAdapter {

private Context context;
Expand Down Expand Up @@ -44,7 +44,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int po
.with(context)
.load(rowModel.getImageUrl())
.into(holder.imageView);

}

@Override
Expand Down

0 comments on commit 3f70e86

Please sign in to comment.