Language: Java

public class SongLauncher extends Fragment implements ISongLauncher{

    SongAdapter mSongAdapter;
    Fragment mSongStateFragment;
    IActivityFragmentInteractor mInteracter;

    public SongLauncher() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    public void setInteracter(IActivityFragmentInteractor interacter) {
        mInteracter = interacter;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_song_launcher, container, false);
        Inventory.getInstance().songLauncherController(this);
        init(view);
        return view;
    }

    private void init(View view){
        final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.song_list_recycler_view);
        LinearLayoutManager linearLayoutManager= new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(linearLayoutManager);
        mSongAdapter = new SongAdapter(Inventory.getInstance().getSongsList());
        mSongStateFragment = getFragmentManager().findFragmentByTag("102");
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
                linearLayoutManager.getOrientation());
        recyclerView.addItemDecoration(dividerItemDecoration);
        recyclerView.setAdapter(mSongAdapter);
        recyclerView.addOnItemTouchListener(
                new RecyclerItemClickListener(getContext(), new RecyclerItemClickListener.OnItemClickListener() {
                    @Override
                    public void onItemClick(View view, int position) {
                        Log.d("Clicked", ":" + position);
                        Inventory.getInstance().updateLastPlayed(position);
                        if (mInteracter != null){
                            mInteracter.nowPlaying();
                        }

                    }
                })
        );
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onListUpdated() {
        mSongAdapter.setSongLists(Inventory.getInstance().getSongsList());
    }
}
public class MainActivity extends AppCompatActivity implements IActivityFragmentInteractor{

    private TextView mTextMessage;
    private Retrofit retrofit;
    Fragment mActiveFragment;
    volatile int dataPresent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        dataPresent = 0;
    }

    @Override
    protected void onStart() {
        super.onStart();

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

        Gson gson = new GsonBuilder()
                .setLenient()
                .create();

        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .client(client)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();

        callEndpoints();

        final SongState songStateFragment = new SongState();
        final SongLauncher songLauncherFragment = new SongLauncher();
        songLauncherFragment.setInteracter(this);
        final FragmentManager fm = getSupportFragmentManager();
        mActiveFragment = songLauncherFragment;
        fm.beginTransaction().add(R.id.main_container, songLauncherFragment, "101").commit();
        fm.beginTransaction().add(R.id.main_container, songStateFragment, "102").hide(songStateFragment).commit();

        mTextMessage = (TextView) findViewById(R.id.message);
        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.navigation_home:
                        fm.beginTransaction().hide(mActiveFragment).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).show(songLauncherFragment).commit();
                        mActiveFragment = songLauncherFragment;
                        return true;
                    case R.id.navigation_dashboard:
                        fm.beginTransaction().hide(mActiveFragment).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).show(songStateFragment).commit();
                        mActiveFragment = songStateFragment;
                        return true;
                }
                return false;
            }
        });

    }

    private void callEndpoints() {
        InventoryController inventoryController = retrofit.create(InventoryController.class);

        inventoryController.listSongs()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(new DisposableSingleObserver<List<SongList>>() {
                    @Override
                    public void onSuccess(List<SongList> songLists) {
                        //Log.d("New Song", "Size: " + songLists.size() + songLists.get(1).getArtist() + " " + songLists.get(2).getArtist());
                        Inventory.getInstance().setSongsList(songLists);
                        dataPresent = 1;
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e("SongList", "Error" + e);
                    }
                });
    }

    @Override
    public void nowPlaying() {
        if (mActiveFragment == getSupportFragmentManager().findFragmentByTag("101")){
            getSupportFragmentManager().beginTransaction().hide(mActiveFragment)
                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                    .show(getSupportFragmentManager().findFragmentByTag("102")).commit();
            mActiveFragment = getSupportFragmentManager().findFragmentByTag("102");
        }
    }
}

public interface IActivityFragmentInteractor {
    void nowPlaying();
}


Compiler output:
Main.java:1: error: class SongLauncher is public, should be declared in a file named SongLauncher.java
public class SongLauncher extends Fragment implements ISongLauncher{
       ^
Main.java:73: error: class MainActivity is public, should be declared in a file named MainActivity.java
public class MainActivity extends AppCompatActivity implements IActivityFragmentInteractor{
       ^
Main.java:170: error: interface IActivityFragmentInteractor is public, should be declared in a file named IActivityFragmentInteractor.java
public interface IActivityFragmentInteractor {
       ^
Main.java:1: error: cannot find symbol
public class SongLauncher extends Fragment implements ISongLauncher{
                                  ^
  symbol: class Fragment
Main.java:1: error: cannot find symbol
public class SongLauncher extends Fragment implements ISongLauncher{
                                                      ^
  symbol: class ISongLauncher
Main.java:3: error: cannot find symbol
    SongAdapter mSongAdapter;
    ^
  symbol:   class SongAdapter
  location: class SongLauncher
Main.java:4: error: cannot find symbol
    Fragment mSongStateFragment;
    ^
  symbol:   class Fragment
  location: class SongLauncher
Main.java:12: error: cannot find symbol
    public void onCreate(Bundle savedInstanceState) {
                         ^
  symbol:   class Bundle
  location: class SongLauncher
Main.java:23: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             ^
  symbol:   class LayoutInflater
  location: class SongLauncher
Main.java:23: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                                      ^
  symbol:   class ViewGroup
  location: class SongLauncher
Main.java:24: error: cannot find symbol
                             Bundle savedInstanceState) {
                             ^
  symbol:   class Bundle
  location: class SongLauncher
Main.java:23: error: cannot find symbol
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
           ^
  symbol:   class View
  location: class SongLauncher
Main.java:32: error: cannot find symbol
    private void init(View view){
                      ^
  symbol:   class View
  location: class SongLauncher
Main.java:58: error: cannot find symbol
    public void onAttach(Context context) {
                         ^
  symbol:   class Context
  location: class SongLauncher
Main.java:73: error: cannot find symbol
public class MainActivity extends AppCompatActivity implements IActivityFragmentInteractor{
                                  ^
  symbol: class AppCompatActivity
Main.java:75: error: cannot find symbol
    private TextView mTextMessage;
            ^
  symbol:   class TextView
  location: class MainActivity
Main.java:76: error: cannot find symbol
    private Retrofit retrofit;
            ^
  symbol:   class Retrofit
  location: class MainActivity
Main.java:77: error: cannot find symbol
    Fragment mActiveFragment;
    ^
  symbol:   class Fragment
  location: class MainActivity
Main.java:81: error: cannot find symbol
    protected void onCreate(Bundle savedInstanceState) {
                            ^
  symbol:   class Bundle
  location: class MainActivity
Main.java:11: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:13: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class SongLauncher
Main.java:22: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:26: error: cannot find symbol
        View view = inflater.inflate(R.layout.fragment_song_launcher, container, false);
        ^
  symbol:   class View
  location: class SongLauncher
Main.java:26: error: package R does not exist
        View view = inflater.inflate(R.layout.fragment_song_launcher, container, false);
                                      ^
Main.java:27: error: cannot find symbol
        Inventory.getInstance().songLauncherController(this);
        ^
  symbol:   variable Inventory
  location: class SongLauncher
Main.java:33: error: cannot find symbol
        final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.song_list_recycler_view);
              ^
  symbol:   class RecyclerView
  location: class SongLauncher
Main.java:33: error: cannot find symbol
        final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.song_list_recycler_view);
                                           ^
  symbol:   class RecyclerView
  location: class SongLauncher
Main.java:33: error: package R does not exist
        final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.song_list_recycler_view);
                                                                            ^
Main.java:34: error: cannot find symbol
        LinearLayoutManager linearLayoutManager= new LinearLayoutManager(getContext());
        ^
  symbol:   class LinearLayoutManager
  location: class SongLauncher
Main.java:34: error: cannot find symbol
        LinearLayoutManager linearLayoutManager= new LinearLayoutManager(getContext());
                                                     ^
  symbol:   class LinearLayoutManager
  location: class SongLauncher
Main.java:34: error: cannot find symbol
        LinearLayoutManager linearLayoutManager= new LinearLayoutManager(getContext());
                                                                         ^
  symbol:   method getContext()
  location: class SongLauncher
Main.java:36: error: cannot find symbol
        mSongAdapter = new SongAdapter(Inventory.getInstance().getSongsList());
                           ^
  symbol:   class SongAdapter
  location: class SongLauncher
Main.java:36: error: cannot find symbol
        mSongAdapter = new SongAdapter(Inventory.getInstance().getSongsList());
                                       ^
  symbol:   variable Inventory
  location: class SongLauncher
Main.java:37: error: cannot find symbol
        mSongStateFragment = getFragmentManager().findFragmentByTag("102");
                             ^
  symbol:   method getFragmentManager()
  location: class SongLauncher
Main.java:38: error: cannot find symbol
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
        ^
  symbol:   class DividerItemDecoration
  location: class SongLauncher
Main.java:38: error: cannot find symbol
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
                                                          ^
  symbol:   class DividerItemDecoration
  location: class SongLauncher
Main.java:43: error: cannot find symbol
                new RecyclerItemClickListener(getContext(), new RecyclerItemClickListener.OnItemClickListener() {
                    ^
  symbol:   class RecyclerItemClickListener
  location: class SongLauncher
Main.java:43: error: package RecyclerItemClickListener does not exist
                new RecyclerItemClickListener(getContext(), new RecyclerItemClickListener.OnItemClickListener() {
                                                                                         ^
Main.java:45: error: cannot find symbol
                    public void onItemClick(View view, int position) {
                                            ^
  symbol: class View
Main.java:44: error: method does not override or implement a method from a supertype
                    @Override
                    ^
Main.java:46: error: cannot find symbol
                        Log.d("Clicked", ":" + position);
                        ^
  symbol: variable Log
Main.java:47: error: cannot find symbol
                        Inventory.getInstance().updateLastPlayed(position);
                        ^
  symbol: variable Inventory
Main.java:43: error: cannot find symbol
                new RecyclerItemClickListener(getContext(), new RecyclerItemClickListener.OnItemClickListener() {
                                              ^
  symbol:   method getContext()
  location: class SongLauncher
Main.java:57: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:59: error: cannot find symbol
        super.onAttach(context);
        ^
  symbol:   variable super
  location: class SongLauncher
Main.java:63: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:65: error: cannot find symbol
        super.onDetach();
        ^
  symbol:   variable super
  location: class SongLauncher
Main.java:68: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:70: error: cannot find symbol
        mSongAdapter.setSongLists(Inventory.getInstance().getSongsList());
                                  ^
  symbol:   variable Inventory
  location: class SongLauncher
Main.java:80: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:82: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class MainActivity
Main.java:83: error: package R does not exist
        setContentView(R.layout.activity_main);
                        ^
Main.java:87: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:89: error: cannot find symbol
        super.onStart();
        ^
  symbol:   variable super
  location: class MainActivity
Main.java:91: error: cannot find symbol
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        ^
  symbol:   class HttpLoggingInterceptor
  location: class MainActivity
Main.java:91: error: cannot find symbol
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
                                                 ^
  symbol:   class HttpLoggingInterceptor
  location: class MainActivity
Main.java:92: error: package HttpLoggingInterceptor does not exist
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);