ArrayList<News> news = new ArrayList<>();
news.add(new News(t, Double.parseDouble(p));
return news;
newsList.add(new News(t, Double.parseDouble(p));
return newsList;
/* Complex parts */
public class Input
{
public String test() {
return "sdas";
}
}
public class Input2
{
public String test2() {
return "sdas1";
}
}
/* Facade */
class InputFacade {
private Input input;
private Input2 input2;
public InputFacade() {
this.input = new Input();
this.input2 = new Input2();
}
public void startInput() {
input.test();
input2.test2();
System.out.println(input.test() + input2.test2());
}
}
/* Client */
class MyClass {
public static void main(String[] args) {
InputFacade input = new InputFacade();
input.startInput();
}
}
> sdassdas1
Желательно предоставить не сам метод, а набор знаний и источников для реализации данного метода.
MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.sound_file_1);
mediaPlayer.start();
if (mediaPlayer != null) {
mediaPlayer.release();
mediaPlayer = null;
}
FirebaseAuth.AuthStateListener mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
updateUI(user);
}
};
public class MainActivity implements AdapterView.OnItemSelectedListener {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
....
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.planets_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
}
...
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
parent.getItemAtPosition(position);
switch (position) {
case 0:
return;
//этот будет срабатывать сразу при отображении спиннера
case 1:
Intent intent = new Intent(this, Main2Activity.class);
startActivity(intent);
return;
case 2:
Intent intent = new Intent(this, Main3Activity.class);
startActivity(intent);
return;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
<string-array name="planets_array">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
</string-array>
public class MainActivity {
...
public String BEST_TEXT;
public String SCORE_TEXT;
public String BEST_TEXT_GAME;
...
@Override
protected void onCreate ... {
...
BEST_TEXT = getString(R.string.BEST_TEXT);
SCORE_TEXT = getString(R.string.SCORE_TEXT);
...
<string name="BEST_TEXT">High Score:" "</string>
<string name="BEST_TEXT">Рекорд:" "</string>