Bladeren bron

合并代码

liujiangyao 7 jaren geleden
bovenliggende
commit
ce6e09e8bf

+ 8 - 1
app/src/main/java/com/sheep/gamegroup/view/fragment/BaseListFragment2.java

@@ -72,6 +72,8 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
     protected SmartRefreshLayout refreshLayout;
     @BindView(R.id.view_list)
     protected RecyclerView view_list;
+    @BindView(R.id.tag_view)
+    View tag_view;
 
     protected BaseMessage lastMessage;//最后一个网络获取的结果
     protected int page = 1;//页数
@@ -92,6 +94,8 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
 //        refreshLayout.setFooterTriggerRate(1);
     }
     protected View bottomLine;
+    /* 记录滑动坐标的数组 */
+    int[] locate = new int[2];
     public void initListener() {
         refreshLayout.setOnRefreshListener(new OnRefreshListener() {
             @Override
@@ -136,8 +140,9 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
                     int lastVisibleItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();
                     int totalCount = linearLayoutManager.getItemCount();
                     Log.e("lastvisi_item_-----", lastVisibleItem+","+totalCount);
+                    Log.e("lastvisi_item_-----", locate[1]+"");
 
-                    if(newState == RecyclerView.SCROLL_STATE_IDLE && isSlidingToLast){//滑动到了底部
+                    if(newState == RecyclerView.SCROLL_STATE_IDLE && isSlidingToLast && locate[1] > 0){//滑动到了底部
                         if(ListUtil.size(list) >= per_page*page){
 
                             refreshLayout.autoLoadMore();
@@ -150,6 +155,8 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
             @Override
             public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                 super.onScrolled(recyclerView, dx, dy);
+                tag_view.getLocationInWindow(locate);
+                Log.e("locate-----", locate[0]+","+locate[1]);
                 Log.e("dx-----", dx+","+dy);
                 if (dy > 0) {
                     //大于0表示正在向下滚动

+ 7 - 6
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSmallSheep.java

@@ -198,6 +198,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     TextView test_change_user;
     @BindView(R.id.list_title)
     LinearLayout listTitle;
+    @BindView(R.id.title_car)
     LinearLayout titleCardLayout;
     /* 记录滑动坐标的数组 */
     int[] locate = new int[2];
@@ -546,7 +547,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
      */
     @SuppressLint("InflateParams")
     private void initTitleCardLayout(final Context context) {
-        titleCardLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.view_float_title_card, null);
+//        titleCardLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.view_float_title_card, null);
         doIt = titleCardLayout.findViewById(R.id.do_it_text);
         willStart = titleCardLayout.findViewById(R.id.will_start_text);
         doItLine = titleCardLayout.findViewById(R.id.do_it_every_day_line);
@@ -573,7 +574,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
                 willStartClick();
             }
         });
-        ((ViewGroup) activity.getWindow().getDecorView()).addView(titleCardLayout);
+//        ((ViewGroup) activity.getWindow().getDecorView()).addView(titleCardLayout);
         titleCardLayout.setVisibility(View.GONE);
     }
 
@@ -758,7 +759,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
             public void onScrollChange(NestedScrollView nestedScrollView, int i, int i1, int i2, int i3) {
                 listTitle.getLocationInWindow(locate);
                 if (locate[1] < 0 && titleCardLayout.getVisibility() == View.GONE) {
-//                    titleCardLayout.setVisibility(View.VISIBLE);
+                    titleCardLayout.setVisibility(View.VISIBLE);
                 } else if (locate[1] > 20 && titleCardLayout.getVisibility() == View.VISIBLE) {
                     titleCardLayout.setVisibility(View.GONE);
                 }
@@ -1323,6 +1324,9 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
 
     @Override
     public void onPause() {
+        if(titleCardLayout != null){
+            titleCardLayout.setVisibility(View.GONE);
+        }
         super.onPause();
         if (upview1 != null) {
             //停止滚动
@@ -1332,9 +1336,6 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
             //停止滚动
             homepageItemNoticeMv.stopFlipping();
         }
-        if(titleCardLayout != null){
-            titleCardLayout.setVisibility(View.GONE);
-        }
     }
 
     private void invite(final List<MoreDataEntity> moreDataEntityList) {

+ 4 - 1
app/src/main/res/layout/homepage_act_layout.xml

@@ -5,7 +5,6 @@
     android:layout_height="match_parent"
     android:background="@color/white"
     android:clipChildren="true">
-
     <com.sheep.gamegroup.util.SheepSwipeRefreshLayout
         android:id="@+id/refresh"
         android:layout_width="match_parent"
@@ -175,4 +174,8 @@
         android:paddingEnd="@dimen/content_padding_10"
         android:text="切换服务器"
         android:visibility="gone" />
+
+    <include
+        layout="@layout/view_float_title_card"
+        android:visibility="visible" />
 </RelativeLayout>

+ 3 - 1
app/src/main/res/layout/view_float_title_card.xml

@@ -3,7 +3,9 @@
     android:id="@+id/title_car"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:background="@color/white"
+    android:visibility="visible">
 
     <LinearLayout
         android:layout_width="match_parent"