Skip to content

Commit

Permalink
🐛 fix site modify button disappear
Browse files Browse the repository at this point in the history
  • Loading branch information
ourfor committed Dec 4, 2024
1 parent 9004833 commit a2c22f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;

import lombok.extern.slf4j.Slf4j;
import lombok.val;
import top.ourfor.app.iplayx.R;
import top.ourfor.app.iplayx.action.DispatchAction;
Expand All @@ -21,6 +22,7 @@
import top.ourfor.app.iplayx.model.SiteModel;
import top.ourfor.app.iplayx.store.GlobalStore;

@Slf4j
public class SiteViewCell extends ConstraintLayout implements UpdateModelAction {
private SiteModel model;
SiteCellBinding binding = null;
Expand Down Expand Up @@ -75,13 +77,13 @@ void setupUI(Context context) {

void bind() {
binding.content.setOnClickListener(v -> callOnClick());

binding.delete.setOnClickListener(v -> XGET(GlobalStore.class).removeSite(model));
boolean allowModify = XGET(Navigator.class).getCurrentPageId() == R.id.sitePage;
val currentPageId = XGET(Navigator.class).getCurrentPageId();
boolean allowModify = currentPageId == R.id.sitePage || currentPageId == R.id.settingPage;
binding.modify.setVisibility(allowModify ? VISIBLE : GONE);
binding.modify.setOnClickListener(v -> {
val dst = XGET(Navigator.class).getCurrentPageId();
if (dst == R.id.sitePage) {
val pageId = XGET(Navigator.class).getCurrentPageId();
if (pageId == R.id.sitePage || pageId == R.id.settingPage) {
val action = XGET(SiteUpdateAction.class);
if (action == null) return;
XGET(DispatchAction.class).runOnUiThread(() -> action.onSiteModify(model));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ public void create(Context context, Map<String, Object> params) {
public View view() {
return binding.getRoot();
}

@Override
public int id() {
return R.id.settingPage;
}
}

0 comments on commit a2c22f2

Please sign in to comment.