Fix snackbar position

This commit is contained in:
d8ahazard 2016-09-26 12:51:40 -05:00 committed by topjohnwu
parent 441e603bc0
commit 3adc7ca22a

View File

@ -40,11 +40,12 @@ public class ModulesFragment extends Fragment {
private SharedPreferences prefs; private SharedPreferences prefs;
public static List<Module> listModules = new ArrayList<>(); public static List<Module> listModules = new ArrayList<>();
private View viewMain;
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View viewMain = inflater.inflate(R.layout.modules_fragment, container, false); viewMain = inflater.inflate(R.layout.modules_fragment, container, false);
ButterKnife.bind(this, viewMain); ButterKnife.bind(this, viewMain);
mSwipeRefreshLayout.setRefreshing(true); mSwipeRefreshLayout.setRefreshing(true);
@ -96,6 +97,7 @@ public class ModulesFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
viewMain = this.getView();
getActivity().setTitle("Modules"); getActivity().setTitle("Modules");
} }
@ -123,19 +125,19 @@ public class ModulesFragment extends Fragment {
if (!chbox.isChecked()) { if (!chbox.isChecked()) {
listModules.get(position).createDisableFile(); listModules.get(position).createDisableFile();
Snackbar.make(chk, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show(); Snackbar.make(viewMain, R.string.disable_file_created, Snackbar.LENGTH_SHORT).show();
} else { } else {
listModules.get(position).removeDisableFile(); listModules.get(position).removeDisableFile();
Snackbar.make(chk, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show(); Snackbar.make(viewMain, R.string.disable_file_removed, Snackbar.LENGTH_SHORT).show();
} }
}, (deleteBtn, position) -> { }, (deleteBtn, position) -> {
// On delete button click listener // On delete button click listener
listModules.get(position).createRemoveFile(); listModules.get(position).createRemoveFile();
Snackbar.make(deleteBtn, R.string.remove_file_created, Snackbar.LENGTH_SHORT).show(); Snackbar.make(viewMain, R.string.remove_file_created, Snackbar.LENGTH_SHORT).show();
}, (undeleteBtn, position) -> { }, (undeleteBtn, position) -> {
// On undelete button click listener // On undelete button click listener
listModules.get(position).deleteRemoveFile(); listModules.get(position).deleteRemoveFile();
Snackbar.make(undeleteBtn, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show(); Snackbar.make(viewMain, R.string.remove_file_deleted, Snackbar.LENGTH_SHORT).show();
})); }));
mSwipeRefreshLayout.setRefreshing(false); mSwipeRefreshLayout.setRefreshing(false);