|
@ -7,8 +7,6 @@ import android.os.AsyncTask; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
import android.os.Handler; |
|
|
import android.os.Handler; |
|
|
import android.support.design.widget.FloatingActionButton; |
|
|
import android.support.design.widget.FloatingActionButton; |
|
|
import android.support.v4.app.ActivityOptionsCompat; |
|
|
|
|
|
import android.support.v4.util.Pair; |
|
|
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
import android.support.v7.app.AlertDialog; |
|
|
import android.support.v7.widget.LinearLayoutManager; |
|
|
import android.support.v7.widget.LinearLayoutManager; |
|
|
import android.support.v7.widget.RecyclerView; |
|
|
import android.support.v7.widget.RecyclerView; |
|
@ -79,6 +77,8 @@ public class TopicActivity extends BaseActivity { |
|
|
private String topicTitle; |
|
|
private String topicTitle; |
|
|
private FloatingActionButton replyFAB; |
|
|
private FloatingActionButton replyFAB; |
|
|
private String parsedTitle; |
|
|
private String parsedTitle; |
|
|
|
|
|
private RecyclerView recyclerView; |
|
|
|
|
|
private RecyclerView.LayoutManager layoutManager; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
@ -101,7 +101,6 @@ public class TopicActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
postsList = new ArrayList<>(); |
|
|
postsList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
firstPage = (ImageButton) findViewById(R.id.page_first_button); |
|
|
firstPage = (ImageButton) findViewById(R.id.page_first_button); |
|
|
previousPage = (ImageButton) findViewById(R.id.page_previous_button); |
|
|
previousPage = (ImageButton) findViewById(R.id.page_previous_button); |
|
|
pageIndicator = (TextView) findViewById(R.id.page_indicator); |
|
|
pageIndicator = (TextView) findViewById(R.id.page_indicator); |
|
@ -166,6 +165,12 @@ public class TopicActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
recyclerView = (RecyclerView)findViewById(R.id.topic_recycler_view); |
|
|
|
|
|
recyclerView.setHasFixedSize(true); |
|
|
|
|
|
layoutManager = new LinearLayoutManager(getApplicationContext()); |
|
|
|
|
|
recyclerView.setLayoutManager(layoutManager); |
|
|
|
|
|
recyclerView.setAdapter(new TopicAdapter(getApplicationContext(), postsList)); |
|
|
|
|
|
|
|
|
new TopicTask().execute(extras.getString("TOPIC_URL")); //Attempt data parsing
|
|
|
new TopicTask().execute(extras.getString("TOPIC_URL")); //Attempt data parsing
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -292,17 +297,7 @@ public class TopicActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
private void changePage(int pageRequested) { |
|
|
private void changePage(int pageRequested) { |
|
|
if (pageRequested != thisPage - 1) { |
|
|
if (pageRequested != thisPage - 1) { |
|
|
//Restart activity with new page
|
|
|
new TopicTask().execute(pagesUrls.get(pageRequested)); //Attempt data parsing
|
|
|
Pair<View, String> p1 = Pair.create((View) replyFAB, "fab"); |
|
|
|
|
|
Pair<View, String> p2 = Pair.create((View) toolbar, "toolbar"); |
|
|
|
|
|
ActivityOptionsCompat options = ActivityOptionsCompat. |
|
|
|
|
|
makeSceneTransitionAnimation(this, p1, p2); |
|
|
|
|
|
|
|
|
|
|
|
Intent intent = getIntent(); |
|
|
|
|
|
intent.putExtra("TOPIC_URL", pagesUrls.get(pageRequested)); |
|
|
|
|
|
intent.putExtra("TOPIC_TITLE", topicTitle); |
|
|
|
|
|
startActivity(intent, options.toBundle()); |
|
|
|
|
|
finish(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
|
|
|
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
|
|
@ -315,6 +310,7 @@ public class TopicActivity extends BaseActivity { |
|
|
//Show a progress bar until done
|
|
|
//Show a progress bar until done
|
|
|
protected void onPreExecute() { |
|
|
protected void onPreExecute() { |
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
|
|
replyFAB.setEnabled(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected Boolean doInBackground(String... strings) { |
|
|
protected Boolean doInBackground(String... strings) { |
|
@ -324,6 +320,7 @@ public class TopicActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
//Find message focus if present
|
|
|
//Find message focus if present
|
|
|
{ |
|
|
{ |
|
|
|
|
|
postFocus = NO_POST_FOCUS; |
|
|
if (pageUrl.contains("msg")) { |
|
|
if (pageUrl.contains("msg")) { |
|
|
String tmp = pageUrl.substring(pageUrl.indexOf("msg") + 3); |
|
|
String tmp = pageUrl.substring(pageUrl.indexOf("msg") + 3); |
|
|
if (tmp.contains(";")) |
|
|
if (tmp.contains(";")) |
|
@ -414,13 +411,7 @@ public class TopicActivity extends BaseActivity { |
|
|
* adds a card for each post to the ScrollView. |
|
|
* adds a card for each post to the ScrollView. |
|
|
*/ |
|
|
*/ |
|
|
private void populateLayout() { |
|
|
private void populateLayout() { |
|
|
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.topic_recycler_view); |
|
|
recyclerView.swapAdapter(new TopicAdapter(getApplicationContext(), postsList), false); |
|
|
recyclerView.setHasFixedSize(true); |
|
|
|
|
|
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); |
|
|
|
|
|
recyclerView.setLayoutManager(layoutManager); |
|
|
|
|
|
|
|
|
|
|
|
TopicAdapter adapter = new TopicAdapter(getApplicationContext(), postsList); |
|
|
|
|
|
recyclerView.setAdapter(adapter); |
|
|
|
|
|
|
|
|
|
|
|
//Set post focus
|
|
|
//Set post focus
|
|
|
if (postFocus != NO_POST_FOCUS) { |
|
|
if (postFocus != NO_POST_FOCUS) { |
|
|