mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
Trying to solve merge conflicts
disable scrolling functionality first try removed
This commit is contained in:
parent
6502bceb2e
commit
78484a86ac
@ -27,7 +27,8 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.constraintlayout.motion.widget.MotionLayout;
|
||||||
|
import androidx.constraintlayout.motion.widget.MotionScene;
|
||||||
import androidx.core.content.PermissionChecker;
|
import androidx.core.content.PermissionChecker;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
@ -109,7 +110,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||||
|
|
||||||
private MainActivity fragmentActivity;
|
private MainActivity fragmentActivity;
|
||||||
private CoordinatorLayout root;
|
private MotionLayout root;
|
||||||
private FragmentProfileBinding binding;
|
private FragmentProfileBinding binding;
|
||||||
private boolean isLoggedIn;
|
private boolean isLoggedIn;
|
||||||
private String cookie;
|
private String cookie;
|
||||||
@ -251,23 +252,15 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
final View profilePicView,
|
final View profilePicView,
|
||||||
final View mainPostImage,
|
final View mainPostImage,
|
||||||
final int position) {
|
final int position) {
|
||||||
final PostViewV2Fragment.Builder builder = PostViewV2Fragment
|
final NavController navController = NavHostFragment.findNavController(ProfileFragment.this);
|
||||||
.builder(feedModel);
|
final Bundle bundle = new Bundle();
|
||||||
if (position >= 0) {
|
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);
|
||||||
builder.setPosition(position);
|
bundle.putInt(PostViewV2Fragment.ARG_SLIDER_POSITION, position);
|
||||||
|
try {
|
||||||
|
navController.navigate(R.id.action_global_post_view, bundle);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "openPostDialog: ", e);
|
||||||
}
|
}
|
||||||
if (!layoutPreferences.isAnimationDisabled()) {
|
|
||||||
builder.setSharedProfilePicElement(profilePicView)
|
|
||||||
.setSharedMainPostElement(mainPostImage);
|
|
||||||
}
|
|
||||||
final PostViewV2Fragment postViewV2Fragment = builder.build();
|
|
||||||
postViewV2Fragment.setOnDeleteListener(() -> {
|
|
||||||
postViewV2Fragment.dismiss();
|
|
||||||
binding.postsRecyclerView.refresh();
|
|
||||||
});
|
|
||||||
final FragmentManager fragmentManager = getChildFragmentManager();
|
|
||||||
if (fragmentManager.isDestroyed() || fragmentManager.isStateSaved()) return;
|
|
||||||
postViewV2Fragment.show(fragmentManager, "post_view");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final FeedAdapterV2.SelectionModeCallback selectionModeCallback = new FeedAdapterV2.SelectionModeCallback() {
|
private final FeedAdapterV2.SelectionModeCallback selectionModeCallback = new FeedAdapterV2.SelectionModeCallback() {
|
||||||
@ -346,26 +339,22 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
final boolean isSame = ("@" + profileModelUsername).equals(this.username);
|
final boolean isSame = ("@" + profileModelUsername).equals(this.username);
|
||||||
if (isSame) {
|
if (isSame) {
|
||||||
setUsernameDelayed();
|
setUsernameDelayed();
|
||||||
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
|
|
||||||
shouldRefresh = false;
|
shouldRefresh = false;
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (username == null || !username.equals(this.username)) {
|
if (username == null || !username.equals(this.username)) {
|
||||||
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
|
|
||||||
shouldRefresh = true;
|
shouldRefresh = true;
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setUsernameDelayed();
|
setUsernameDelayed();
|
||||||
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
|
|
||||||
shouldRefresh = false;
|
shouldRefresh = false;
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
binding = FragmentProfileBinding.inflate(inflater, container, false);
|
binding = FragmentProfileBinding.inflate(inflater, container, false);
|
||||||
root = binding.getRoot();
|
root = binding.getRoot();
|
||||||
profileDetailsBinding = LayoutProfileDetailsBinding.inflate(inflater, fragmentActivity.getCollapsingToolbarView(), false);
|
profileDetailsBinding = binding.header;
|
||||||
fragmentActivity.setCollapsingView(profileDetailsBinding.getRoot());
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,14 +544,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
super.onDestroyView();
|
|
||||||
if (profileDetailsBinding != null) {
|
|
||||||
fragmentActivity.removeCollapsingView(profileDetailsBinding.getRoot());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
@ -590,7 +571,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
setUsernameDelayed();
|
setUsernameDelayed();
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(username) && !isLoggedIn) {
|
if (TextUtils.isEmpty(username) && !isLoggedIn) {
|
||||||
profileDetailsBinding.infoContainer.setVisibility(View.GONE);
|
binding.header.getRoot().setVisibility(View.GONE);
|
||||||
binding.swipeRefreshLayout.setEnabled(false);
|
binding.swipeRefreshLayout.setEnabled(false);
|
||||||
binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24);
|
binding.privatePage1.setImageResource(R.drawable.ic_outline_info_24);
|
||||||
binding.privatePage2.setText(R.string.no_acc);
|
binding.privatePage2.setText(R.string.no_acc);
|
||||||
@ -688,12 +669,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
binding.postsRecyclerView.refresh();
|
binding.postsRecyclerView.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Disable scrolling when profile has no posts
|
|
||||||
if (profileModel.getMediaCount() == 0){
|
|
||||||
final AppBarLayout.LayoutParams toolbarLayoutParams = (AppBarLayout.LayoutParams) fragmentActivity.getCollapsingToolbarView().getLayoutParams();
|
|
||||||
toolbarLayoutParams.setScrollFlags(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
profileDetailsBinding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
|
profileDetailsBinding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
|
||||||
profileDetailsBinding.isPrivate.setVisibility(profileModel.isPrivate() ? View.VISIBLE : View.GONE);
|
profileDetailsBinding.isPrivate.setVisibility(profileModel.isPrivate() ? View.VISIBLE : View.GONE);
|
||||||
final long profileId = profileModel.getPk();
|
final long profileId = profileModel.getPk();
|
||||||
@ -1217,6 +1192,17 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
.setFeedItemCallback(feedItemCallback)
|
.setFeedItemCallback(feedItemCallback)
|
||||||
.setSelectionModeCallback(selectionModeCallback)
|
.setSelectionModeCallback(selectionModeCallback)
|
||||||
.init();
|
.init();
|
||||||
|
binding.postsRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
|
||||||
|
super.onScrolled(recyclerView, dx, dy);
|
||||||
|
final boolean canScrollVertically = recyclerView.canScrollVertically(-1);
|
||||||
|
final MotionScene.Transition transition = root.getTransition(R.id.transition);
|
||||||
|
if (transition != null) {
|
||||||
|
transition.setEnable(!canScrollVertically);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
binding.swipeRefreshLayout.setRefreshing(true);
|
binding.swipeRefreshLayout.setRefreshing(true);
|
||||||
postsSetupDone = true;
|
postsSetupDone = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user