aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-09-26 02:10:51 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-09-26 02:10:51 +0000
commitb47422fd758896c7e3371bcf59ec6fe9a262e980 (patch)
tree2793408ea1d452d336bf78436c86221716b706b9 /app/src/main/java
parent428734bddeb7eea9b63d6d8e965d27beb9e7bc93 (diff)
downloadinfinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.tar
infinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.tar.gz
infinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.tar.bz2
infinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.tar.lz
infinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.tar.xz
infinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.tar.zst
infinity-for-reddit-b47422fd758896c7e3371bcf59ec6fe9a262e980.zip
Animate layout changes in item_post_compact.xml.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java27
2 files changed, 47 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 772040b6..32f3eb84 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -16,6 +16,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -782,9 +783,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (mCompactLayoutToolbarHiddenByDefault) {
- ((PostCompactBaseViewHolder) holder).bottomConstraintLayout.setVisibility(View.GONE);
+ mCallback.delayTransition();
+ ViewGroup.LayoutParams params = (LinearLayout.LayoutParams) ((PostCompactBaseViewHolder) holder).bottomConstraintLayout.getLayoutParams();
+ params.height = 0;
+ ((PostCompactBaseViewHolder) holder).bottomConstraintLayout.setLayoutParams(params);
} else {
- ((PostCompactBaseViewHolder) holder).bottomConstraintLayout.setVisibility(View.VISIBLE);
+ ViewGroup.LayoutParams params = (LinearLayout.LayoutParams) ((PostCompactBaseViewHolder) holder).bottomConstraintLayout.getLayoutParams();
+ params.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ ((PostCompactBaseViewHolder) holder).bottomConstraintLayout.setLayoutParams(params);
+ mCallback.delayTransition();
}
if (mShowDividerInCompactLayout) {
@@ -1319,6 +1326,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
void typeChipClicked(int filter);
void currentlyBindItem(int position);
+
+ void delayTransition();
}
public class PostBaseViewHolder extends RecyclerView.ViewHolder {
@@ -2819,10 +2828,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
itemView.setOnLongClickListener(view -> {
if (mLongPressToHideToolbarInCompactLayout) {
- if (bottomConstraintLayout.getVisibility() == View.VISIBLE) {
- bottomConstraintLayout.setVisibility(View.GONE);
+ if (bottomConstraintLayout.getLayoutParams().height == 0) {
+ ViewGroup.LayoutParams params = (LinearLayout.LayoutParams) bottomConstraintLayout.getLayoutParams();
+ params.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ bottomConstraintLayout.setLayoutParams(params);
+ mCallback.delayTransition();
} else {
- bottomConstraintLayout.setVisibility(View.VISIBLE);
+ mCallback.delayTransition();
+ ViewGroup.LayoutParams params = (LinearLayout.LayoutParams) bottomConstraintLayout.getLayoutParams();
+ params.height = 0;
+ bottomConstraintLayout.setLayoutParams(params);
}
}
return true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index fcf7db71..d5b638b3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -42,6 +42,8 @@ import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import androidx.transition.AutoTransition;
+import androidx.transition.TransitionManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
@@ -441,6 +443,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
maxPosition = position;
}
}
+
+ @Override
+ public void delayTransition() {
+ TransitionManager.beginDelayedTransition(mPostRecyclerView, new AutoTransition());
+ }
});
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
@@ -488,6 +495,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
maxPosition = position;
}
}
+
+ @Override
+ public void delayTransition() {
+ TransitionManager.beginDelayedTransition(mPostRecyclerView, new AutoTransition());
+ }
});
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
@@ -537,6 +549,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
maxPosition = position;
}
}
+
+ @Override
+ public void delayTransition() {
+ TransitionManager.beginDelayedTransition(mPostRecyclerView, new AutoTransition());
+ }
});
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
@@ -585,6 +602,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
maxPosition = position;
}
}
+
+ @Override
+ public void delayTransition() {
+ TransitionManager.beginDelayedTransition(mPostRecyclerView, new AutoTransition());
+ }
});
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
@@ -624,6 +646,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
maxPosition = position;
}
}
+
+ @Override
+ public void delayTransition() {
+ TransitionManager.beginDelayedTransition(mPostRecyclerView, new AutoTransition());
+ }
});
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mOauthRetrofit, accessToken,