// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Interactor.java
// public interface Interactor {
//     void fetchNewsfeed(int userId);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/InteractorOut.java
// public interface InteractorOut {
//     void onSuccessNewsfeed(String[] newsfeed);
//     void onFailureNewsfeed(String message);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
// 
//     void getNewsfeed(int userId);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
//     void setData(String[] newsfeed);
//     void showError(String message);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/interactor/NewsfeedInteractor.java
// public class NewsfeedInteractor implements Interactor {
// 
//     private InteractorOut newsfeedPresenter;
//     public NewsfeedInteractor(InteractorOut newsfeedPresenter) {
//         this.newsfeedPresenter=newsfeedPresenter;
//     }
// 
//     @Override
//     public void fetchNewsfeed(int userId) {
//         // fetch newsfeed
//         double random=  Math.random()*3+1; // some dummy operation
// 
//        if(random%2==0)
//        {
//            newsfeedPresenter.onFailureNewsfeed("Failed to fetch data.");
//        }
//        else
//        {
//            String[] newsfeed={"Sample post happy", "Sample post sad", "Sample status update", "Sample share"};
//            newsfeedPresenter.onSuccessNewsfeed(newsfeed);
//        }
//     }
// }


import com.example.mvp_practice02.newsfeed.contracts.Interactor;
import com.example.mvp_practice02.newsfeed.contracts.InteractorOut;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.interactor.NewsfeedInteractor;
package com.example.mvp_practice02.newsfeed.presenter;


/**
 * Created by Talha Hasan Zia on 30-Apr-18.
 * <p></p><b>Description:</b><p></p> Why class was created?
 * <p></p>
 * <b>Public Methods:</b><p></p> Only listing to public methods usage.
 */
public class NewsfeedPresenter implements Presenter, InteractorOut {

    private View view;
    private Interactor interactor;

    public NewsfeedPresenter(View view) {
        this.view = view;
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Interactor.java
// public interface Interactor {
//     void fetchNewsfeed(int userId);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/InteractorOut.java
// public interface InteractorOut {
//     void onSuccessNewsfeed(String[] newsfeed);
//     void onFailureNewsfeed(String message);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/Presenter.java
// public interface Presenter {
// 
//     void getNewsfeed(int userId);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/contracts/View.java
// public interface View {
//     void setData(String[] newsfeed);
//     void showError(String message);
// }
// 
// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/interactor/NewsfeedInteractor.java
// public class NewsfeedInteractor implements Interactor {
// 
//     private InteractorOut newsfeedPresenter;
//     public NewsfeedInteractor(InteractorOut newsfeedPresenter) {
//         this.newsfeedPresenter=newsfeedPresenter;
//     }
// 
//     @Override
//     public void fetchNewsfeed(int userId) {
//         // fetch newsfeed
//         double random=  Math.random()*3+1; // some dummy operation
// 
//        if(random%2==0)
//        {
//            newsfeedPresenter.onFailureNewsfeed("Failed to fetch data.");
//        }
//        else
//        {
//            String[] newsfeed={"Sample post happy", "Sample post sad", "Sample status update", "Sample share"};
//            newsfeedPresenter.onSuccessNewsfeed(newsfeed);
//        }
//     }
// }


// Path: Testing/app/src/main/java/com/example/mvp_practice02/newsfeed/presenter/NewsfeedPresenter.java
import com.example.mvp_practice02.newsfeed.contracts.Interactor;
import com.example.mvp_practice02.newsfeed.contracts.InteractorOut;
import com.example.mvp_practice02.newsfeed.contracts.Presenter;
import com.example.mvp_practice02.newsfeed.contracts.View;
import com.example.mvp_practice02.newsfeed.interactor.NewsfeedInteractor;

package com.example.mvp_practice02.newsfeed.presenter;


/**
 * Created by Talha Hasan Zia on 30-Apr-18.
 * <p></p><b>Description:</b><p></p> Why class was created?
 * <p></p>
 * <b>Public Methods:</b><p></p> Only listing to public methods usage.
 */
public class NewsfeedPresenter implements Presenter, InteractorOut {

    private View view;
    private Interactor interactor;

    public NewsfeedPresenter(View view) {
        this.view = view;
        interactor=new NewsfeedInteractor(this);