Skip to content

Commit

Permalink
Prevent adding Scenario, Condition, Profile when no related plugin en…
Browse files Browse the repository at this point in the history
…abled

Fix #98
  • Loading branch information
renyuneyun committed May 20, 2018
1 parent 5da3a16 commit 0d1f192
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ListFragment;
import android.view.ContextMenu;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -76,18 +76,17 @@ public void onResume() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getActivity().setTitle(title());
return inflater.inflate(R.layout.fragment_fab_list, container, false);
}
View view = inflater.inflate(R.layout.fragment_fab_list, container, false);

@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
FloatingActionButton fab = view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
beginNewData();
}
});

return view;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@
package ryey.easer.core.ui.edit;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.view.View;

import ryey.easer.R;
import ryey.easer.core.EHService;
import ryey.easer.core.data.storage.ConditionDataStorage;
import ryey.easer.plugins.PluginRegistry;

public class ConditionListFragment extends AbstractDataListFragment<ConditionDataStorage> {

Expand Down Expand Up @@ -51,4 +57,13 @@ protected void onDataChangedFromEditDataActivity() {
protected Intent intentForEditDataActivity() {
return new Intent(getContext(), EditConditionActivity.class);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
//noinspection ConstantConditions
if (PluginRegistry.getInstance().condition().getEnabledPlugins(getContext()).size() == 0) {
FloatingActionButton fab = view.findViewById(R.id.fab);
fab.hide();
}
}
}
15 changes: 15 additions & 0 deletions app/src/main/java/ryey/easer/core/ui/edit/ProfileListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
package ryey.easer.core.ui.edit;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.view.View;

import ryey.easer.R;
import ryey.easer.core.data.storage.ProfileDataStorage;
import ryey.easer.plugins.PluginRegistry;

public class ProfileListFragment extends AbstractDataListFragment<ProfileDataStorage> {

Expand All @@ -44,4 +50,13 @@ protected ProfileDataStorage retmStorage() {
protected Intent intentForEditDataActivity() {
return new Intent(getActivity(), EditProfileActivity.class);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
//noinspection ConstantConditions
if (PluginRegistry.getInstance().operation().getEnabledPlugins(getContext()).size() == 0) {
FloatingActionButton fab = view.findViewById(R.id.fab);
fab.hide();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@
package ryey.easer.core.ui.edit;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.view.View;

import ryey.easer.R;
import ryey.easer.core.EHService;
import ryey.easer.core.data.storage.ScenarioDataStorage;
import ryey.easer.plugins.PluginRegistry;

public class ScenarioListFragment extends AbstractDataListFragment<ScenarioDataStorage> {

Expand Down Expand Up @@ -51,4 +57,13 @@ protected void onDataChangedFromEditDataActivity() {
protected Intent intentForEditDataActivity() {
return new Intent(getContext(), EditScenarioActivity.class);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
//noinspection ConstantConditions
if (PluginRegistry.getInstance().event().getEnabledPlugins(getContext()).size() == 0) {
FloatingActionButton fab = view.findViewById(R.id.fab);
fab.hide();
}
}
}

0 comments on commit 0d1f192

Please sign in to comment.