// Path: app/src/main/java/party/minge/reddit/client/Manager.java
// @EBean(scope = EBean.Scope.Singleton)
// public class Manager {
//     @Bean(ResFactory.class)
//     protected UserAgentFactory userAgentFactory;
// 
//     @Bean(ResFactory.class)
//     protected CredentialFactory credentialFactory;
// 
//     @Bean(UserlessCredentialFactory.class)
//     protected CredentialFactory anonymousCredentialFactory;
// 
//     protected RedditClient redditClient;
// 
//     protected AuthenticationManager authenticationManager;
// 
//     protected AccountManager accountManager;
// 
//     @Bean(PreferenceTokenStore.class)
//     protected TokenStore tokenStore;
// 
//     @AfterInject
//     public void afterInject() {
//         this.redditClient = new RedditClient(this.userAgentFactory.getUserAgent());
//         this.authenticationManager = AuthenticationManager.get();
//         this.authenticationManager.init(this.redditClient, new RefreshTokenHandler(this.tokenStore, this.redditClient));
//         this.accountManager = new AccountManager(this.redditClient);
//     }
// 
//     /**
//      * Anonymously authenticates if required.
//      * If already authenticated, does not re-authenticate.
//      *
//      * @param authenticationCallback Methods to call on success or failure.
//      */
//     public void authenticateIfRequired(AuthenticationCallback authenticationCallback) {
//         AuthenticationState state = AuthenticationManager.get().checkAuthState();
// 
//         if (state == AuthenticationState.READY) {
//             authenticationCallback.onSuccessfulAuthentication();
//             return;
//         }
// 
//         if (state == AuthenticationState.NEED_REFRESH) {
//             try {
//                 this.authenticationManager.refreshAccessToken(this.getCredentials());
//                 authenticationCallback.onSuccessfulAuthentication();
//             } catch (Exception ex) {
//                 authenticationCallback.onFailedAuthentication(ex);
//             }
// 
//             return;
//         }
// 
//         try {
//             OAuthData authData = this.getClient().getOAuthHelper().easyAuth(this.getAnonymousCredentials());
//             this.getClient().authenticate(authData);
// 
//             authenticationCallback.onSuccessfulAuthentication();
//         } catch (Exception ex) {
//             authenticationCallback.onFailedAuthentication(ex);
//         }
//     }
// 
//     public RedditClient getClient() {
//         return this.redditClient;
//     }
// 
//     public AccountManager getAccountManager() {
//         return this.accountManager;
//     }
// 
//     public AuthenticationManager getAuthenticationManager() {
//         return this.authenticationManager;
//     }
// 
//     public Credentials getCredentials() {
//         return this.credentialFactory.getCredentials();
//     }
// 
//     public Credentials getAnonymousCredentials() {
//         return this.anonymousCredentialFactory.getCredentials();
//     }
// }
// 
// Path: app/src/main/java/party/minge/reddit/treeview/SubmissionTreeNodeAdapter.java
// @EBean
// public class SubmissionTreeNodeAdapter {
//     @RootContext
//     protected Context context;
// 
//     @Bean
//     protected CommentTreeNodeAdapter commentTreeNodeAdapter;
// 
//     public TreeNode fromSubmission(Submission submission)
//     {
//         TreeNode rootNode = new TreeNode(null);
// 
//         TreeNode postNode = new TreeNode(submission);
// 
//         postNode.setViewHolder(new SubmissionNodeViewHolder(this.context));
// 
//         rootNode.addChild(postNode);
// 
//         List<CommentNode> comments = submission.getComments().getChildren();
// 
//         for (CommentNode comment : comments) {
//             rootNode.addChild(this.commentTreeNodeAdapter.fromCommentNode(comment));
//         }
// 
//         return rootNode;
//     }
// }


import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import com.unnamed.b.atv.model.TreeNode;
import com.unnamed.b.atv.view.AndroidTreeView;
import net.dean.jraw.models.CommentNode;
import net.dean.jraw.models.Submission;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
import party.minge.reddit.client.Manager;
import party.minge.reddit.treeview.SubmissionTreeNodeAdapter;
package party.minge.reddit;






@EActivity(R.layout.activity_submission_detail)
public class SubmissionDetailActivity extends Activity {
    @Extra
    protected String submissionId;

    protected Submission submission;

    @Bean
    protected Manager manager;

    @Bean
    protected SubmissionTreeNodeAdapter adapter;

    @ViewById
    protected LinearLayout grpMain;

    @ViewById
    protected ProgressBar loader;

    protected TreeNode treeNode;

    @ViewById
    protected SwipeRefreshLayout grpSwipeRefresh;

    @AfterViews
    protected void setupRefresh() {
        this.grpSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                SubmissionDetailActivity_.intent(SubmissionDetailActivity.this)
                        .submissionId(SubmissionDetailActivity.this.submissionId)
                        .start();

                SubmissionDetailActivity.this.finish();
            }
        });
    }

    @AfterViews
// Path: app/src/main/java/party/minge/reddit/client/Manager.java
// @EBean(scope = EBean.Scope.Singleton)
// public class Manager {
//     @Bean(ResFactory.class)
//     protected UserAgentFactory userAgentFactory;
// 
//     @Bean(ResFactory.class)
//     protected CredentialFactory credentialFactory;
// 
//     @Bean(UserlessCredentialFactory.class)
//     protected CredentialFactory anonymousCredentialFactory;
// 
//     protected RedditClient redditClient;
// 
//     protected AuthenticationManager authenticationManager;
// 
//     protected AccountManager accountManager;
// 
//     @Bean(PreferenceTokenStore.class)
//     protected TokenStore tokenStore;
// 
//     @AfterInject
//     public void afterInject() {
//         this.redditClient = new RedditClient(this.userAgentFactory.getUserAgent());
//         this.authenticationManager = AuthenticationManager.get();
//         this.authenticationManager.init(this.redditClient, new RefreshTokenHandler(this.tokenStore, this.redditClient));
//         this.accountManager = new AccountManager(this.redditClient);
//     }
// 
//     /**
//      * Anonymously authenticates if required.
//      * If already authenticated, does not re-authenticate.
//      *
//      * @param authenticationCallback Methods to call on success or failure.
//      */
//     public void authenticateIfRequired(AuthenticationCallback authenticationCallback) {
//         AuthenticationState state = AuthenticationManager.get().checkAuthState();
// 
//         if (state == AuthenticationState.READY) {
//             authenticationCallback.onSuccessfulAuthentication();
//             return;
//         }
// 
//         if (state == AuthenticationState.NEED_REFRESH) {
//             try {
//                 this.authenticationManager.refreshAccessToken(this.getCredentials());
//                 authenticationCallback.onSuccessfulAuthentication();
//             } catch (Exception ex) {
//                 authenticationCallback.onFailedAuthentication(ex);
//             }
// 
//             return;
//         }
// 
//         try {
//             OAuthData authData = this.getClient().getOAuthHelper().easyAuth(this.getAnonymousCredentials());
//             this.getClient().authenticate(authData);
// 
//             authenticationCallback.onSuccessfulAuthentication();
//         } catch (Exception ex) {
//             authenticationCallback.onFailedAuthentication(ex);
//         }
//     }
// 
//     public RedditClient getClient() {
//         return this.redditClient;
//     }
// 
//     public AccountManager getAccountManager() {
//         return this.accountManager;
//     }
// 
//     public AuthenticationManager getAuthenticationManager() {
//         return this.authenticationManager;
//     }
// 
//     public Credentials getCredentials() {
//         return this.credentialFactory.getCredentials();
//     }
// 
//     public Credentials getAnonymousCredentials() {
//         return this.anonymousCredentialFactory.getCredentials();
//     }
// }
// 
// Path: app/src/main/java/party/minge/reddit/treeview/SubmissionTreeNodeAdapter.java
// @EBean
// public class SubmissionTreeNodeAdapter {
//     @RootContext
//     protected Context context;
// 
//     @Bean
//     protected CommentTreeNodeAdapter commentTreeNodeAdapter;
// 
//     public TreeNode fromSubmission(Submission submission)
//     {
//         TreeNode rootNode = new TreeNode(null);
// 
//         TreeNode postNode = new TreeNode(submission);
// 
//         postNode.setViewHolder(new SubmissionNodeViewHolder(this.context));
// 
//         rootNode.addChild(postNode);
// 
//         List<CommentNode> comments = submission.getComments().getChildren();
// 
//         for (CommentNode comment : comments) {
//             rootNode.addChild(this.commentTreeNodeAdapter.fromCommentNode(comment));
//         }
// 
//         return rootNode;
//     }
// }


// Path: app/src/main/java/party/minge/reddit/SubmissionDetailActivity.java
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import com.unnamed.b.atv.model.TreeNode;
import com.unnamed.b.atv.view.AndroidTreeView;
import net.dean.jraw.models.CommentNode;
import net.dean.jraw.models.Submission;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
import party.minge.reddit.client.Manager;
import party.minge.reddit.treeview.SubmissionTreeNodeAdapter;

package party.minge.reddit;






@EActivity(R.layout.activity_submission_detail)
public class SubmissionDetailActivity extends Activity {
    @Extra
    protected String submissionId;

    protected Submission submission;

    @Bean
    protected Manager manager;

    @Bean
    protected SubmissionTreeNodeAdapter adapter;

    @ViewById
    protected LinearLayout grpMain;

    @ViewById
    protected ProgressBar loader;

    protected TreeNode treeNode;

    @ViewById
    protected SwipeRefreshLayout grpSwipeRefresh;

    @AfterViews
    protected void setupRefresh() {
        this.grpSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                SubmissionDetailActivity_.intent(SubmissionDetailActivity.this)
                        .submissionId(SubmissionDetailActivity.this.submissionId)
                        .start();

                SubmissionDetailActivity.this.finish();
            }
        });
    }

    @AfterViews
    protected void hideActionBar() {