Last active
July 26, 2017 18:28
-
-
Save vestrel00/4071d2a0325ce5bd79c9efbf1f3a2503 to your computer and use it in GitHub Desktop.
A: 6 - ui/example_1/fragment/Example1Fragment.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Example1Fragment extends BaseFragment implements View.OnClickListener { | |
@Inject | |
SingletonUtil singletonUtil; | |
@Inject | |
PerActivityUtil perActivityUtil; | |
@Inject | |
PerFragmentUtil perFragmentUtil; | |
private TextView someText; | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
return inflater.inflate(R.layout.example_1_fragment, container, false); | |
} | |
@Override | |
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
super.onViewCreated(view, savedInstanceState); | |
// TODO (Butterknife) replace with butterknife view binding | |
someText = (TextView) view.findViewById(R.id.some_text); | |
view.findViewById(R.id.do_something).setOnClickListener(this); | |
} | |
@Override | |
public void onClick(View v) { | |
switch (v.getId()) { | |
case R.id.do_something: | |
onDoSomethingClicked(); | |
break; | |
default: | |
throw new IllegalArgumentException("Unhandled view " + v.getId()); | |
} | |
} | |
private void onDoSomethingClicked() { | |
String something = singletonUtil.doSomething(); | |
something += "\n" + perActivityUtil.doSomething(); | |
something += "\n" + perFragmentUtil.doSomething(); | |
showSomething(something); | |
} | |
private void showSomething(String something) { | |
someText.setText(something); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment