| 
						
						
							
								
							
						
						
					 | 
					@ -60,12 +60,12 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * The key to use when putting topic's title String to {@link TopicActivity}'s Bundle. | 
					 | 
					 | 
					     * The key to use when putting topic's title String to {@link TopicActivity}'s Bundle. | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public static final String EXTRAS_TOPIC_TITLE = "TOPIC_TITLE"; | 
					 | 
					 | 
					    public static final String EXTRAS_TOPIC_TITLE = "TOPIC_TITLE"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    static String PACKAGE_NAME; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private static TopicTask topicTask; | 
					 | 
					 | 
					    private static TopicTask topicTask; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    //About posts
 | 
					 | 
					 | 
					    //About posts
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private List<Post> postsList; | 
					 | 
					 | 
					    private List<Post> postsList; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    static final int NO_POST_FOCUS = -1; | 
					 | 
					 | 
					    private static final int NO_POST_FOCUS = -1; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    static int postFocus = NO_POST_FOCUS; | 
					 | 
					 | 
					    private static int postFocus = NO_POST_FOCUS; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private static int postFocusPosition = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    //Quotes
 | 
					 | 
					 | 
					    //Quotes
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public static final ArrayList<Integer> toQuoteList = new ArrayList<>(); | 
					 | 
					 | 
					    public static final ArrayList<Integer> toQuoteList = new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    //Topic's pages
 | 
					 | 
					 | 
					    //Topic's pages
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -93,7 +93,7 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private FloatingActionButton replyFAB; | 
					 | 
					 | 
					    private FloatingActionButton replyFAB; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private String parsedTitle; | 
					 | 
					 | 
					    private String parsedTitle; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private RecyclerView recyclerView; | 
					 | 
					 | 
					    private RecyclerView recyclerView; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    private RecyclerView.LayoutManager layoutManager; | 
					 | 
					 | 
					    private String loadedPageUrl = ""; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -101,7 +101,6 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        super.onCreate(savedInstanceState); | 
					 | 
					 | 
					        super.onCreate(savedInstanceState); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        setContentView(R.layout.activity_topic); | 
					 | 
					 | 
					        setContentView(R.layout.activity_topic); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        PACKAGE_NAME = getApplicationContext().getPackageName(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        Bundle extras = getIntent().getExtras(); | 
					 | 
					 | 
					        Bundle extras = getIntent().getExtras(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        topicTitle = extras.getString("TOPIC_TITLE"); | 
					 | 
					 | 
					        topicTitle = extras.getString("TOPIC_TITLE"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -122,9 +121,10 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        recyclerView = (RecyclerView) findViewById(R.id.topic_recycler_view); | 
					 | 
					 | 
					        recyclerView = (RecyclerView) findViewById(R.id.topic_recycler_view); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        recyclerView.setHasFixedSize(true); | 
					 | 
					 | 
					        recyclerView.setHasFixedSize(true); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        layoutManager = new LinearLayoutManager(getApplicationContext()); | 
					 | 
					 | 
					        LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        recyclerView.setLayoutManager(layoutManager); | 
					 | 
					 | 
					        recyclerView.setLayoutManager(layoutManager); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        recyclerView.setAdapter(new TopicAdapter(getApplicationContext(), progressBar, postsList)); | 
					 | 
					 | 
					        recyclerView.setAdapter(new TopicAdapter(getApplicationContext(), progressBar, postsList, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                new TopicTask())); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); | 
					 | 
					 | 
					        replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        replyFAB.setEnabled(false); | 
					 | 
					 | 
					        replyFAB.setEnabled(false); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -336,6 +336,7 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        private static final int SUCCESS = 0; | 
					 | 
					 | 
					        private static final int SUCCESS = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        private static final int NETWORK_ERROR = 1; | 
					 | 
					 | 
					        private static final int NETWORK_ERROR = 1; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        private static final int OTHER_ERROR = 2; | 
					 | 
					 | 
					        private static final int OTHER_ERROR = 2; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        private static final int SAME_PAGE = 3; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        protected void onPreExecute() { | 
					 | 
					 | 
					        protected void onPreExecute() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            progressBar.setVisibility(ProgressBar.VISIBLE); | 
					 | 
					 | 
					            progressBar.setVisibility(ProgressBar.VISIBLE); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -345,13 +346,13 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        protected Integer doInBackground(String... strings) { | 
					 | 
					 | 
					        protected Integer doInBackground(String... strings) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Document document; | 
					 | 
					 | 
					            Document document; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            base_url = strings[0].substring(0, strings[0].lastIndexOf(".")); //This topic's base url
 | 
					 | 
					 | 
					            base_url = strings[0].substring(0, strings[0].lastIndexOf(".")); //This topic's base url
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            String pageUrl = strings[0]; | 
					 | 
					 | 
					            String newPageUrl = strings[0]; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            //Finds message focus if present
 | 
					 | 
					 | 
					            //Finds message focus if present
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            { | 
					 | 
					 | 
					            { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                postFocus = NO_POST_FOCUS; | 
					 | 
					 | 
					                postFocus = NO_POST_FOCUS; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                if (pageUrl.contains("msg")) { | 
					 | 
					 | 
					                if (newPageUrl.contains("msg")) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    String tmp = pageUrl.substring(pageUrl.indexOf("msg") + 3); | 
					 | 
					 | 
					                    String tmp = newPageUrl.substring(newPageUrl.indexOf("msg") + 3); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    if (tmp.contains(";")) | 
					 | 
					 | 
					                    if (tmp.contains(";")) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf(";"))); | 
					 | 
					 | 
					                        postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf(";"))); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    else | 
					 | 
					 | 
					                    else | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -359,13 +360,20 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (!loadedPageUrl.contains(base_url)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                Request request = new Request.Builder() | 
					 | 
					 | 
					                Request request = new Request.Builder() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    .url(pageUrl) | 
					 | 
					 | 
					                        .url(newPageUrl) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                        .build(); | 
					 | 
					 | 
					                        .build(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                try { | 
					 | 
					 | 
					                try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    Response response = client.newCall(request).execute(); | 
					 | 
					 | 
					                    Response response = client.newCall(request).execute(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    document = Jsoup.parse(response.body().string()); | 
					 | 
					 | 
					                    document = Jsoup.parse(response.body().string()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    parse(document); | 
					 | 
					 | 
					                    parse(document); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    for (int i = 0; i < postsList.size(); ++i) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        if (postsList.get(i).getPostIndex() == postFocus) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            postFocusPosition = i; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    return SUCCESS; | 
					 | 
					 | 
					                    return SUCCESS; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } catch (IOException e) { | 
					 | 
					 | 
					                } catch (IOException e) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    Report.i(TAG, "IO Exception", e); | 
					 | 
					 | 
					                    Report.i(TAG, "IO Exception", e); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -374,6 +382,7 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    Report.e(TAG, "Exception", e); | 
					 | 
					 | 
					                    Report.e(TAG, "Exception", e); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    return OTHER_ERROR; | 
					 | 
					 | 
					                    return OTHER_ERROR; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else return SAME_PAGE; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        protected void onPostExecute(Integer parseResult) { | 
					 | 
					 | 
					        protected void onPostExecute(Integer parseResult) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -381,16 +390,9 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case SUCCESS: | 
					 | 
					 | 
					                case SUCCESS: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    progressBar.setVisibility(ProgressBar.INVISIBLE); | 
					 | 
					 | 
					                    progressBar.setVisibility(ProgressBar.INVISIBLE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    recyclerView.swapAdapter(new TopicAdapter(getApplicationContext(), progressBar, postsList), false); | 
					 | 
					 | 
					                    recyclerView.swapAdapter(new TopicAdapter(getApplicationContext(), progressBar, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    //Set post focus
 | 
					 | 
					 | 
					                            postsList, new TopicTask()), false); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    if (postFocus != NO_POST_FOCUS) { | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                        for (int i = postsList.size() - 1; i >= 0; --i) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            int currentPostIndex = postsList.get(i).getPostIndex(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            if (currentPostIndex == postFocus) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                layoutManager.scrollToPosition(i); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                            } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    replyFAB.setEnabled(true); | 
					 | 
					 | 
					                    replyFAB.setEnabled(true); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    //Set current page
 | 
					 | 
					 | 
					                    //Set current page
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -408,6 +410,8 @@ public class TopicActivity extends BaseActivity { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case NETWORK_ERROR: | 
					 | 
					 | 
					                case NETWORK_ERROR: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show(); | 
					 | 
					 | 
					                    Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    break; | 
					 | 
					 | 
					                    break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                case SAME_PAGE: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                default: | 
					 | 
					 | 
					                default: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    //Parse failed - should never happen
 | 
					 | 
					 | 
					                    //Parse failed - should never happen
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    Toast.makeText(getBaseContext(), "Fatal Error", Toast.LENGTH_SHORT).show(); | 
					 | 
					 | 
					                    Toast.makeText(getBaseContext(), "Fatal Error", Toast.LENGTH_SHORT).show(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |