|
|
@ -2,28 +2,19 @@ package gr.thmmy.mthmmy.activities.topic; |
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.app.NotificationManager; |
|
|
|
import android.arch.lifecycle.ViewModelProvider; |
|
|
|
import android.arch.lifecycle.ViewModelProviders; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.SharedPreferences; |
|
|
|
import android.graphics.Rect; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.AsyncTask; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Handler; |
|
|
|
import android.support.design.widget.FloatingActionButton; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.preference.PreferenceManager; |
|
|
|
import android.support.v7.widget.RecyclerView; |
|
|
|
import android.text.Html; |
|
|
|
import android.text.SpannableStringBuilder; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.text.method.LinkMovementMethod; |
|
|
|
import android.text.style.ClickableSpan; |
|
|
|
import android.text.style.URLSpan; |
|
|
|
import android.util.SparseArray; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.MenuItem; |
|
|
@ -36,42 +27,20 @@ import android.widget.ProgressBar; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import org.jsoup.Jsoup; |
|
|
|
import org.jsoup.nodes.Document; |
|
|
|
import org.jsoup.nodes.Element; |
|
|
|
import org.jsoup.select.Selector; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
import gr.thmmy.mthmmy.R; |
|
|
|
import gr.thmmy.mthmmy.activities.board.BoardActivity; |
|
|
|
import gr.thmmy.mthmmy.activities.profile.ProfileActivity; |
|
|
|
import gr.thmmy.mthmmy.activities.settings.SettingsActivity; |
|
|
|
import gr.thmmy.mthmmy.base.BaseActivity; |
|
|
|
import gr.thmmy.mthmmy.model.Bookmark; |
|
|
|
import gr.thmmy.mthmmy.model.Post; |
|
|
|
import gr.thmmy.mthmmy.model.ThmmyPage; |
|
|
|
import gr.thmmy.mthmmy.utils.CustomLinearLayoutManager; |
|
|
|
import gr.thmmy.mthmmy.utils.HTMLUtils; |
|
|
|
import gr.thmmy.mthmmy.utils.parsing.ParseException; |
|
|
|
import gr.thmmy.mthmmy.utils.parsing.ParseHelpers; |
|
|
|
import gr.thmmy.mthmmy.viewmodel.TopicViewModel; |
|
|
|
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; |
|
|
|
import okhttp3.MultipartBody; |
|
|
|
import okhttp3.Request; |
|
|
|
import okhttp3.RequestBody; |
|
|
|
import okhttp3.Response; |
|
|
|
import timber.log.Timber; |
|
|
|
|
|
|
|
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; |
|
|
|
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; |
|
|
|
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; |
|
|
|
import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; |
|
|
|
import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; |
|
|
|
import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; |
|
|
|
import static gr.thmmy.mthmmy.activities.topic.Posting.replyStatus; |
|
|
|
import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG; |
|
|
|
|
|
|
|
/** |
|
|
@ -81,7 +50,9 @@ import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG; |
|
|
|
* key {@link #BUNDLE_TOPIC_TITLE} for faster title rendering. |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
public class TopicActivity extends BaseActivity { |
|
|
|
public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskObserver, |
|
|
|
DeleteTask.DeleteTaskCallbacks, ReplyTask.OnReplyTaskFinished, PrepareForEditTask.PrepareForEditCallbacks, |
|
|
|
EditTask.EditTaskCallbacks, PrepareForReply.PrepareForReplyCallbacks { |
|
|
|
//Activity's variables
|
|
|
|
/** |
|
|
|
* The key to use when putting topic's url String to {@link TopicActivity}'s Bundle. |
|
|
@ -91,76 +62,18 @@ public class TopicActivity extends BaseActivity { |
|
|
|
* The key to use when putting topic's title String to {@link TopicActivity}'s Bundle. |
|
|
|
*/ |
|
|
|
public static final String BUNDLE_TOPIC_TITLE = "TOPIC_TITLE"; |
|
|
|
private static TopicTask topicTask; |
|
|
|
private MaterialProgressBar progressBar; |
|
|
|
private TextView toolbarTitle; |
|
|
|
/** |
|
|
|
* Holds this topic's base url. For example a topic with url similar to |
|
|
|
* "https://www.thmmy.gr/smf/index.php?topic=1.15;topicseen" or |
|
|
|
* "https://www.thmmy.gr/smf/index.php?topic=1.msg1#msg1" |
|
|
|
* has the base url "https://www.thmmy.gr/smf/index.php?topic=1" |
|
|
|
*/ |
|
|
|
private static String base_url = ""; |
|
|
|
/** |
|
|
|
* Holds this topic's title. At first this gets the value of the topic title that came with |
|
|
|
* bundle and is rendered in the toolbar while parsing this topic. Later, after topic's parsing |
|
|
|
* is done, it gets the value of {@link #parsedTitle} if bundle title and parsed title differ. |
|
|
|
*/ |
|
|
|
private String topicTitle; |
|
|
|
/** |
|
|
|
* Holds this topic's title as parsed from the html source. If this (parsed) title is different |
|
|
|
* than the one that came with activity's bundle then the parsed title is preferred over the |
|
|
|
* bundle one and gets rendered in the toolbar. |
|
|
|
*/ |
|
|
|
private String parsedTitle; |
|
|
|
private String topicPageUrl; |
|
|
|
private RecyclerView recyclerView; |
|
|
|
/** |
|
|
|
* Holds the url of this page |
|
|
|
*/ |
|
|
|
private String loadedPageUrl = ""; |
|
|
|
/** |
|
|
|
* Holds the topicId of this page |
|
|
|
*/ |
|
|
|
private int loadedPageTopicId = -1; |
|
|
|
/** |
|
|
|
* Becomes true after user has posted in this topic and the page is being reloaded and false |
|
|
|
* when topic's reloading is done |
|
|
|
*/ |
|
|
|
private boolean reloadingPage = false; |
|
|
|
//Posts related
|
|
|
|
private TopicAdapter topicAdapter; |
|
|
|
/** |
|
|
|
* Holds a list of this topic's posts |
|
|
|
*/ |
|
|
|
private ArrayList<Post> postsList; |
|
|
|
/** |
|
|
|
* Holds the index of the post that has focus |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* Holds the position in the {@link #postsList} of the post with focus |
|
|
|
*/ |
|
|
|
private static int postFocusPosition = 0; |
|
|
|
//Reply related
|
|
|
|
private FloatingActionButton replyFAB; |
|
|
|
/** |
|
|
|
* Holds this topic's reply url |
|
|
|
*/ |
|
|
|
private String replyPageUrl = null; |
|
|
|
//Topic's pages related
|
|
|
|
/** |
|
|
|
* Holds current page's index (starting from 1, not 0) |
|
|
|
*/ |
|
|
|
private int thisPage = 1; |
|
|
|
/** |
|
|
|
* Holds this topic's number of pages |
|
|
|
*/ |
|
|
|
private int numberOfPages = 1; |
|
|
|
/** |
|
|
|
* Holds a list of this topic's pages urls |
|
|
|
*/ |
|
|
|
private final SparseArray<String> pagesUrls = new SparseArray<>(); |
|
|
|
//Page select related
|
|
|
|
/** |
|
|
|
* Used for handling bottom navigation bar's buttons long click user interactions |
|
|
@ -197,21 +110,22 @@ public class TopicActivity extends BaseActivity { |
|
|
|
private ImageButton lastPage; |
|
|
|
private TopicViewModel viewModel; |
|
|
|
|
|
|
|
//Topic's info related
|
|
|
|
private SpannableStringBuilder topicTreeAndMods = new SpannableStringBuilder("Loading..."), |
|
|
|
topicViewers = new SpannableStringBuilder("Loading..."); |
|
|
|
|
|
|
|
boolean includeAppSignaturePreference = true; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
setContentView(R.layout.activity_topic); |
|
|
|
|
|
|
|
viewModel = ViewModelProviders.of(this).get(TopicViewModel.class); |
|
|
|
viewModel.setTopicTaskObserver(this); |
|
|
|
viewModel.setDeleteTaskCallbacks(this); |
|
|
|
viewModel.setReplyFinishListener(this); |
|
|
|
viewModel.setPrepareForEditCallbacks(this); |
|
|
|
viewModel.setEditTaskCallbacks(this); |
|
|
|
viewModel.setPrepareForReplyCallbacks(this); |
|
|
|
|
|
|
|
Bundle extras = getIntent().getExtras(); |
|
|
|
topicTitle = extras.getString(BUNDLE_TOPIC_TITLE); |
|
|
|
String maybeTopicTitle = topicTitle; |
|
|
|
topicPageUrl = extras.getString(BUNDLE_TOPIC_URL); |
|
|
|
String topicTitle = extras.getString(BUNDLE_TOPIC_TITLE); |
|
|
|
String topicPageUrl = extras.getString(BUNDLE_TOPIC_URL); |
|
|
|
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory( |
|
|
|
Uri.parse(topicPageUrl)); |
|
|
|
if (!target.is(ThmmyPage.PageCategory.TOPIC)) { |
|
|
@ -222,10 +136,6 @@ public class TopicActivity extends BaseActivity { |
|
|
|
|
|
|
|
topicPageUrl = ThmmyPage.sanitizeTopicUrl(topicPageUrl); |
|
|
|
|
|
|
|
if (sessionManager.isLoggedIn()) { |
|
|
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); |
|
|
|
includeAppSignaturePreference = sharedPrefs.getBoolean(SettingsActivity.APP_SIGNATURE_ENABLE_KEY, true); |
|
|
|
} |
|
|
|
|
|
|
|
thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl), true); |
|
|
|
|
|
|
@ -251,20 +161,11 @@ public class TopicActivity extends BaseActivity { |
|
|
|
|
|
|
|
recyclerView = findViewById(R.id.topic_recycler_view); |
|
|
|
recyclerView.setHasFixedSize(true); |
|
|
|
recyclerView.setOnTouchListener( |
|
|
|
new View.OnTouchListener() { |
|
|
|
@Override |
|
|
|
public boolean onTouch(View v, MotionEvent event) { |
|
|
|
v.performClick(); |
|
|
|
return topicTask != null && topicTask.getStatus() == AsyncTask.Status.RUNNING; |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
//LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
|
|
|
|
CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager( |
|
|
|
getApplicationContext(), loadedPageUrl); |
|
|
|
getApplicationContext(), topicPageUrl); |
|
|
|
recyclerView.setLayoutManager(layoutManager); |
|
|
|
topicAdapter = new TopicAdapter(this, postsList, viewModel.getTopicTaskResultMutableLiveData().getValue().getBaseUrl(), topicTask); |
|
|
|
topicAdapter = new TopicAdapter(this, postsList); |
|
|
|
recyclerView.setAdapter(topicAdapter); |
|
|
|
|
|
|
|
replyFAB = findViewById(R.id.topic_fab); |
|
|
@ -272,13 +173,9 @@ public class TopicActivity extends BaseActivity { |
|
|
|
bottomNavBar = findViewById(R.id.bottom_navigation_bar); |
|
|
|
if (!sessionManager.isLoggedIn()) replyFAB.hide(); |
|
|
|
else { |
|
|
|
replyFAB.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
if (sessionManager.isLoggedIn()) { |
|
|
|
PrepareForReply prepareForReply = new PrepareForReply(); |
|
|
|
prepareForReply.execute(topicAdapter.getToQuoteList()); |
|
|
|
} |
|
|
|
replyFAB.setOnClickListener(view -> { |
|
|
|
if (sessionManager.isLoggedIn()) { |
|
|
|
viewModel.prepareForReply(postsList, topicAdapter.getToQuoteList()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
@ -294,14 +191,8 @@ public class TopicActivity extends BaseActivity { |
|
|
|
initDecrementButton(previousPage, SMALL_STEP); |
|
|
|
initIncrementButton(nextPage, SMALL_STEP); |
|
|
|
initIncrementButton(lastPage, LARGE_STEP); |
|
|
|
paginationEnabled(false); |
|
|
|
|
|
|
|
//Gets posts
|
|
|
|
//topicTask = new TopicTask();
|
|
|
|
//topicTask.execute(topicPageUrl); //Attempt data parsing
|
|
|
|
|
|
|
|
viewModel = ViewModelProviders.of(this).get(TopicViewModel.class); |
|
|
|
viewModel.getTopicTaskResultMutableLiveData().observe(this, topicTaskResult -> { |
|
|
|
viewModel.getTopicTaskResult().observe(this, topicTaskResult -> { |
|
|
|
if (topicTaskResult == null) { |
|
|
|
hideControls(); |
|
|
|
} else { |
|
|
@ -320,19 +211,19 @@ public class TopicActivity extends BaseActivity { |
|
|
|
} |
|
|
|
postsList.addAll(topicTaskResult.getNewPostsList()); |
|
|
|
topicAdapter.notifyItemRangeInserted(0, postsList.size()); |
|
|
|
topicAdapter.prepareForDelete(new TopicActivity.DeleteTask()); |
|
|
|
topicAdapter.prepareForPrepareForEdit(new TopicActivity.PrepareForEdit()); |
|
|
|
|
|
|
|
pageIndicator.setText(String.valueOf(thisPage) + "/" + String.valueOf(numberOfPages)); |
|
|
|
pageIndicator.setText(String.valueOf(topicTaskResult.getCurrentPageIndex()) + "/" + |
|
|
|
String.valueOf(topicTaskResult.getPageCount())); |
|
|
|
pageRequestValue = topicTaskResult.getCurrentPageIndex(); |
|
|
|
|
|
|
|
if (topicTaskResult.getCurrentPageIndex() == topicTaskResult.getPageCount()) { |
|
|
|
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
|
|
|
if (notificationManager != null) |
|
|
|
notificationManager.cancel(NEW_POST_TAG, loadedPageTopicId); |
|
|
|
notificationManager.cancel(NEW_POST_TAG, topicTaskResult.getLoadedPageTopicId()); |
|
|
|
} |
|
|
|
|
|
|
|
showControls(); |
|
|
|
break; |
|
|
|
case NETWORK_ERROR: |
|
|
|
Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show(); |
|
|
|
break; |
|
|
@ -355,23 +246,41 @@ public class TopicActivity extends BaseActivity { |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
viewModel.initialLoad(topicPageUrl); |
|
|
|
viewModel.getPrepareForReplyResult().observe(this, prepareForReplyResult -> { |
|
|
|
if (prepareForReplyResult != null) { |
|
|
|
//prepare for a reply
|
|
|
|
viewModel.setWritingReply(true); |
|
|
|
postsList.add(Post.newQuickReply()); |
|
|
|
topicAdapter.notifyItemInserted(postsList.size()); |
|
|
|
recyclerView.scrollToPosition(postsList.size() - 1); |
|
|
|
showControls(); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
viewModel.getPrepareForEditResult().observe(this, result -> { |
|
|
|
if (result != null && result.isSuccessful()) { |
|
|
|
viewModel.setEditingPost(true); |
|
|
|
postsList.get(result.getPosition()).setPostType(Post.TYPE_EDIT); |
|
|
|
topicAdapter.notifyItemChanged(result.getPosition()); |
|
|
|
recyclerView.scrollToPosition(result.getPosition()); |
|
|
|
showControls(); |
|
|
|
} |
|
|
|
}); |
|
|
|
viewModel.initialLoad(topicPageUrl); |
|
|
|
} |
|
|
|
|
|
|
|
public void hideControls() { |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
paginationEnabled(false); |
|
|
|
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(false); |
|
|
|
} |
|
|
|
|
|
|
|
public void showControls() { |
|
|
|
progressBar.setVisibility(ProgressBar.INVISIBLE); |
|
|
|
if (replyPageUrl == null) { |
|
|
|
progressBar.setVisibility(ProgressBar.GONE); |
|
|
|
if (viewModel.getTopicTaskResult().getValue().getReplyPageUrl() == null) { |
|
|
|
replyFAB.hide(); |
|
|
|
topicAdapter.resetTopic(viewModel.getTopicTaskResultMutableLiveData().getValue().getBaseUrl(), new TopicTask(), false); |
|
|
|
} else topicAdapter.resetTopic(viewModel.getTopicTaskResultMutableLiveData().getValue().getBaseUrl(), new TopicTask(), true); |
|
|
|
paginationEnabled(true); |
|
|
|
topicAdapter.resetTopic(false); |
|
|
|
} else |
|
|
|
topicAdapter.resetTopic(true); |
|
|
|
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true); |
|
|
|
} |
|
|
|
|
|
|
@ -397,12 +306,12 @@ public class TopicActivity extends BaseActivity { |
|
|
|
LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info |
|
|
|
, null); |
|
|
|
TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); |
|
|
|
//treeAndMods.setText(new SpannableStringBuilder("Loading..."));
|
|
|
|
treeAndMods.setText(new SpannableStringBuilder("Loading...")); |
|
|
|
treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); |
|
|
|
TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); |
|
|
|
//usersViewing.setText(new SpannableStringBuilder("Loading..."));
|
|
|
|
usersViewing.setText(new SpannableStringBuilder("Loading...")); |
|
|
|
usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); |
|
|
|
viewModel.getTopicTaskResultMutableLiveData().observe(this, topicTaskResult -> { |
|
|
|
viewModel.getTopicTaskResult().observe(this, topicTaskResult -> { |
|
|
|
if (topicTaskResult == null) { |
|
|
|
usersViewing.setText(new SpannableStringBuilder("Loading...")); |
|
|
|
treeAndMods.setText(new SpannableStringBuilder("Loading...")); |
|
|
@ -421,7 +330,7 @@ public class TopicActivity extends BaseActivity { |
|
|
|
case R.id.menu_share: |
|
|
|
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); |
|
|
|
sendIntent.setType("text/plain"); |
|
|
|
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, topicPageUrl); |
|
|
|
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, viewModel.getTopicUrl()); |
|
|
|
startActivity(Intent.createChooser(sendIntent, "Share via")); |
|
|
|
return true; //invalidateOptionsMenu();
|
|
|
|
default: |
|
|
@ -452,19 +361,13 @@ public class TopicActivity extends BaseActivity { |
|
|
|
super.onResume(); |
|
|
|
refreshTopicBookmark(); |
|
|
|
drawer.setSelection(-1); |
|
|
|
|
|
|
|
if (sessionManager.isLoggedIn()) { |
|
|
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); |
|
|
|
includeAppSignaturePreference = sharedPrefs.getBoolean(SettingsActivity.APP_SIGNATURE_ENABLE_KEY, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
recyclerView.setAdapter(null); |
|
|
|
if (topicTask != null && topicTask.getStatus() != AsyncTask.Status.RUNNING) |
|
|
|
topicTask.cancel(true); |
|
|
|
viewModel.stopLoading(); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------BOTTOM NAV BAR METHODS----------------------------------
|
|
|
@ -527,26 +430,22 @@ public class TopicActivity extends BaseActivity { |
|
|
|
@SuppressLint("ClickableViewAccessibility") |
|
|
|
private void initIncrementButton(ImageButton increment, final int step) { |
|
|
|
// Increment once for a click
|
|
|
|
increment.setOnClickListener(new View.OnClickListener() { |
|
|
|
public void onClick(View v) { |
|
|
|
if (!autoIncrement && step == LARGE_STEP) { |
|
|
|
changePage(numberOfPages - 1); |
|
|
|
} else if (!autoIncrement) { |
|
|
|
incrementPageRequestValue(step); |
|
|
|
changePage(pageRequestValue - 1); |
|
|
|
} |
|
|
|
increment.setOnClickListener(v -> { |
|
|
|
if (!autoIncrement && step == LARGE_STEP) { |
|
|
|
viewModel.changePage(viewModel.getTopicTaskResult().getValue().getPageCount() - 1); |
|
|
|
} else if (!autoIncrement) { |
|
|
|
incrementPageRequestValue(step); |
|
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// Auto increment for a long click
|
|
|
|
increment.setOnLongClickListener( |
|
|
|
new View.OnLongClickListener() { |
|
|
|
public boolean onLongClick(View arg0) { |
|
|
|
paginationDisable(arg0); |
|
|
|
autoIncrement = true; |
|
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); |
|
|
|
return false; |
|
|
|
} |
|
|
|
arg0 -> { |
|
|
|
paginationDisable(arg0); |
|
|
|
autoIncrement = true; |
|
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); |
|
|
|
return false; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
@ -560,11 +459,11 @@ public class TopicActivity extends BaseActivity { |
|
|
|
} else if (rect != null && event.getAction() == MotionEvent.ACTION_UP && autoIncrement) { |
|
|
|
autoIncrement = false; |
|
|
|
paginationEnabled(true); |
|
|
|
changePage(pageRequestValue - 1); |
|
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
|
} else if (rect != null && event.getAction() == MotionEvent.ACTION_MOVE) { |
|
|
|
if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { |
|
|
|
autoIncrement = false; |
|
|
|
decrementPageRequestValue(pageRequestValue - thisPage); |
|
|
|
decrementPageRequestValue(pageRequestValue - viewModel.getTopicTaskResult().getValue().getCurrentPageIndex()); |
|
|
|
paginationEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
@ -576,26 +475,22 @@ public class TopicActivity extends BaseActivity { |
|
|
|
@SuppressLint("ClickableViewAccessibility") |
|
|
|
private void initDecrementButton(ImageButton decrement, final int step) { |
|
|
|
// Decrement once for a click
|
|
|
|
decrement.setOnClickListener(new View.OnClickListener() { |
|
|
|
public void onClick(View v) { |
|
|
|
if (!autoDecrement && step == LARGE_STEP) { |
|
|
|
changePage(0); |
|
|
|
} else if (!autoDecrement) { |
|
|
|
decrementPageRequestValue(step); |
|
|
|
changePage(pageRequestValue - 1); |
|
|
|
} |
|
|
|
decrement.setOnClickListener(v -> { |
|
|
|
if (!autoDecrement && step == LARGE_STEP) { |
|
|
|
viewModel.changePage(0); |
|
|
|
} else if (!autoDecrement) { |
|
|
|
decrementPageRequestValue(step); |
|
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// Auto decrement for a long click
|
|
|
|
decrement.setOnLongClickListener( |
|
|
|
new View.OnLongClickListener() { |
|
|
|
public boolean onLongClick(View arg0) { |
|
|
|
paginationDisable(arg0); |
|
|
|
autoDecrement = true; |
|
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); |
|
|
|
return false; |
|
|
|
} |
|
|
|
arg0 -> { |
|
|
|
paginationDisable(arg0); |
|
|
|
autoDecrement = true; |
|
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); |
|
|
|
return false; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
@ -609,12 +504,12 @@ public class TopicActivity extends BaseActivity { |
|
|
|
} else if (event.getAction() == MotionEvent.ACTION_UP && autoDecrement) { |
|
|
|
autoDecrement = false; |
|
|
|
paginationEnabled(true); |
|
|
|
changePage(pageRequestValue - 1); |
|
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) { |
|
|
|
if (rect != null && |
|
|
|
!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { |
|
|
|
autoIncrement = false; |
|
|
|
incrementPageRequestValue(thisPage - pageRequestValue); |
|
|
|
incrementPageRequestValue(viewModel.getTopicTaskResult().getValue().getCurrentPageIndex() - pageRequestValue); |
|
|
|
paginationEnabled(true); |
|
|
|
} |
|
|
|
} |
|
|
@ -624,11 +519,11 @@ public class TopicActivity extends BaseActivity { |
|
|
|
} |
|
|
|
|
|
|
|
private void incrementPageRequestValue(int step) { |
|
|
|
if (pageRequestValue < numberOfPages - step) { |
|
|
|
if (pageRequestValue < viewModel.getTopicTaskResult().getValue().getPageCount() - step) { |
|
|
|
pageRequestValue = pageRequestValue + step; |
|
|
|
} else |
|
|
|
pageRequestValue = numberOfPages; |
|
|
|
pageIndicator.setText(pageRequestValue + "/" + String.valueOf(numberOfPages)); |
|
|
|
pageRequestValue = viewModel.getTopicTaskResult().getValue().getPageCount(); |
|
|
|
pageIndicator.setText(pageRequestValue + "/" + String.valueOf(viewModel.getTopicTaskResult().getValue().getPageCount())); |
|
|
|
} |
|
|
|
|
|
|
|
private void decrementPageRequestValue(int step) { |
|
|
@ -636,346 +531,107 @@ public class TopicActivity extends BaseActivity { |
|
|
|
pageRequestValue = pageRequestValue - step; |
|
|
|
else |
|
|
|
pageRequestValue = 1; |
|
|
|
pageIndicator.setText(pageRequestValue + "/" + String.valueOf(numberOfPages)); |
|
|
|
} |
|
|
|
|
|
|
|
private void changePage(int pageRequested) { |
|
|
|
if (pageRequested != thisPage - 1) { |
|
|
|
if (topicTask != null && topicTask.getStatus() != AsyncTask.Status.RUNNING) |
|
|
|
topicTask.cancel(true); |
|
|
|
|
|
|
|
topicTask = new TopicTask(); |
|
|
|
topicTask.execute(pagesUrls.get(pageRequested)); //Attempt data parsing
|
|
|
|
|
|
|
|
} |
|
|
|
pageIndicator.setText(pageRequestValue + "/" + String.valueOf(viewModel.getTopicTaskResult().getValue().getPageCount())); |
|
|
|
} |
|
|
|
|
|
|
|
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
|
|
|
|
|
|
|
|
class PrepareForReply extends AsyncTask<ArrayList<Integer>, Void, Boolean> { |
|
|
|
String numReplies, seqnum, sc, topic, buildedQuotes = ""; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPreExecute() { |
|
|
|
changePage(numberOfPages - 1); |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
paginationEnabled(false); |
|
|
|
replyFAB.setEnabled(false); |
|
|
|
replyFAB.hide(); |
|
|
|
bottomNavBar.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Boolean doInBackground(ArrayList<Integer>... quoteList) { |
|
|
|
Document document; |
|
|
|
Request request = new Request.Builder() |
|
|
|
.url(replyPageUrl + ";wap2") |
|
|
|
.build(); |
|
|
|
|
|
|
|
try { |
|
|
|
Response response = client.newCall(request).execute(); |
|
|
|
document = Jsoup.parse(response.body().string()); |
|
|
|
|
|
|
|
numReplies = replyPageUrl.substring(replyPageUrl.indexOf("num_replies=") + 12); |
|
|
|
seqnum = document.select("input[name=seqnum]").first().attr("value"); |
|
|
|
sc = document.select("input[name=sc]").first().attr("value"); |
|
|
|
topic = document.select("input[name=topic]").first().attr("value"); |
|
|
|
} catch (IOException | Selector.SelectorParseException e) { |
|
|
|
Timber.e(e, "Prepare failed."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
for (Integer quotePosition : quoteList[0]) { |
|
|
|
request = new Request.Builder() |
|
|
|
.url("https://www.thmmy.gr/smf/index.php?action=quotefast;quote=" + |
|
|
|
postsList.get(quotePosition).getPostIndex() + |
|
|
|
";" + "sesc=" + sc + ";xml") |
|
|
|
.build(); |
|
|
|
|
|
|
|
try { |
|
|
|
Response response = client.newCall(request).execute(); |
|
|
|
String body = response.body().string(); |
|
|
|
buildedQuotes += body.substring(body.indexOf("<quote>") + 7, body.indexOf("</quote>")); |
|
|
|
buildedQuotes += "\n\n"; |
|
|
|
} catch (IOException | Selector.SelectorParseException e) { |
|
|
|
Timber.e(e, "Quote building failed."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPostExecute(Boolean result) { |
|
|
|
postsList.add(Post.newQuickReply()); |
|
|
|
topicAdapter.notifyItemInserted(postsList.size()); |
|
|
|
topicAdapter.prepareForReply(new ReplyTask(), topicTitle, numReplies, seqnum, sc, |
|
|
|
topic, buildedQuotes); |
|
|
|
recyclerView.scrollToPosition(postsList.size() - 1); |
|
|
|
progressBar.setVisibility(ProgressBar.GONE); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onTopicTaskStarted() { |
|
|
|
hideControls(); |
|
|
|
} |
|
|
|
|
|
|
|
class ReplyTask extends AsyncTask<String, Void, Boolean> { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPreExecute() { |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
paginationEnabled(false); |
|
|
|
replyFAB.setEnabled(false); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Boolean doInBackground(String... args) { |
|
|
|
final String sentFrommTHMMY = includeAppSignaturePreference |
|
|
|
? "\n[right][size=7pt][i]sent from [url=https://play.google.com/store/apps/details?id=gr.thmmy.mthmmy]mTHMMY [/url][/i][/size][/right]" |
|
|
|
: ""; |
|
|
|
RequestBody postBody = new MultipartBody.Builder() |
|
|
|
.setType(MultipartBody.FORM) |
|
|
|
.addFormDataPart("message", args[1] + sentFrommTHMMY) |
|
|
|
.addFormDataPart("num_replies", args[2]) |
|
|
|
.addFormDataPart("seqnum", args[3]) |
|
|
|
.addFormDataPart("sc", args[4]) |
|
|
|
.addFormDataPart("subject", args[0]) |
|
|
|
.addFormDataPart("topic", args[5]) |
|
|
|
.build(); |
|
|
|
Request post = new Request.Builder() |
|
|
|
.url("https://www.thmmy.gr/smf/index.php?action=post2") |
|
|
|
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") |
|
|
|
.post(postBody) |
|
|
|
.build(); |
|
|
|
|
|
|
|
try { |
|
|
|
client.newCall(post).execute(); |
|
|
|
Response response = client.newCall(post).execute(); |
|
|
|
switch (replyStatus(response)) { |
|
|
|
case SUCCESSFUL: |
|
|
|
return true; |
|
|
|
case NEW_REPLY_WHILE_POSTING: |
|
|
|
//TODO this...
|
|
|
|
return true; |
|
|
|
default: |
|
|
|
Timber.e("Malformed post. Request string: %s", post.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
Timber.e(e, "Post failed."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPostExecute(Boolean result) { |
|
|
|
View view = getCurrentFocus(); |
|
|
|
if (view != null) { |
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
|
} |
|
|
|
|
|
|
|
postsList.remove(postsList.size() - 1); |
|
|
|
topicAdapter.notifyItemRemoved(postsList.size()); |
|
|
|
|
|
|
|
progressBar.setVisibility(ProgressBar.GONE); |
|
|
|
replyFAB.setVisibility(View.VISIBLE); |
|
|
|
bottomNavBar.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
if (!result) |
|
|
|
Toast.makeText(TopicActivity.this, "Post failed!", Toast.LENGTH_SHORT).show(); |
|
|
|
paginationEnabled(true); |
|
|
|
replyFAB.setEnabled(true); |
|
|
|
|
|
|
|
if (result) { |
|
|
|
topicTask = new TopicTask(); |
|
|
|
if ((postsList.get(postsList.size() - 1).getPostNumber() + 1) % 15 == 0) |
|
|
|
topicTask.execute(viewModel.getTopicTaskResultMutableLiveData().getValue().getBaseUrl() + "." + 2147483647); |
|
|
|
else { |
|
|
|
reloadingPage = true; |
|
|
|
topicTask.execute(loadedPageUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onTopicTaskCancelled() { |
|
|
|
showControls(); |
|
|
|
} |
|
|
|
|
|
|
|
class DeleteTask extends AsyncTask<String, Void, Boolean> { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPreExecute() { |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
paginationEnabled(false); |
|
|
|
replyFAB.setEnabled(false); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Boolean doInBackground(String... args) { |
|
|
|
Request delete = new Request.Builder() |
|
|
|
.url(args[0]) |
|
|
|
.header("User-Agent", |
|
|
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") |
|
|
|
.build(); |
|
|
|
|
|
|
|
try { |
|
|
|
client.newCall(delete).execute(); |
|
|
|
Response response = client.newCall(delete).execute(); |
|
|
|
//Response response = client.newCall(delete).execute();
|
|
|
|
switch (replyStatus(response)) { |
|
|
|
case SUCCESSFUL: |
|
|
|
return true; |
|
|
|
default: |
|
|
|
Timber.e("Something went wrong. Request string: %s", delete.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
Timber.e(e, "Delete failed."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onReplyTaskFinished(boolean success) { |
|
|
|
View view = getCurrentFocus(); |
|
|
|
if (view != null) { |
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPostExecute(Boolean result) { |
|
|
|
progressBar.setVisibility(ProgressBar.GONE); |
|
|
|
replyFAB.setVisibility(View.VISIBLE); |
|
|
|
bottomNavBar.setVisibility(View.VISIBLE); |
|
|
|
postsList.remove(postsList.size() - 1); |
|
|
|
topicAdapter.notifyItemRemoved(postsList.size()); |
|
|
|
|
|
|
|
if (!result) |
|
|
|
Toast.makeText(TopicActivity.this, "Post deleted!", Toast.LENGTH_SHORT).show(); |
|
|
|
paginationEnabled(true); |
|
|
|
replyFAB.setEnabled(true); |
|
|
|
showControls(); |
|
|
|
viewModel.setWritingReply(false); |
|
|
|
|
|
|
|
if (result) { |
|
|
|
topicTask = new TopicTask(); |
|
|
|
reloadingPage = true; |
|
|
|
topicTask.execute(loadedPageUrl); |
|
|
|
if (success) { |
|
|
|
if ((postsList.get(postsList.size() - 1).getPostNumber() + 1) % 15 == 0) { |
|
|
|
viewModel.loadUrl(viewModel.getBaseUrl() + "." + 2147483647); |
|
|
|
} else { |
|
|
|
viewModel.reloadPage(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
Toast.makeText(TopicActivity.this, "Post failed!", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class PrepareForEdit extends AsyncTask<Integer, Void, Boolean> { |
|
|
|
int position; |
|
|
|
String commitEditURL, numReplies, seqnum, sc, topic, postText = ""; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPreExecute() { |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
paginationEnabled(false); |
|
|
|
replyFAB.setEnabled(false); |
|
|
|
replyFAB.hide(); |
|
|
|
bottomNavBar.setVisibility(View.GONE); |
|
|
|
topicAdapter.disablePostEditing(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Boolean doInBackground(Integer... positions) { |
|
|
|
Document document; |
|
|
|
position = positions[0]; |
|
|
|
String url = postsList.get(position).getPostEditURL(); |
|
|
|
Request request = new Request.Builder() |
|
|
|
.url(url + ";wap2") |
|
|
|
.build(); |
|
|
|
@Override |
|
|
|
public void onPrepareForReplyStarted() { |
|
|
|
hideControls(); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
Response response = client.newCall(request).execute(); |
|
|
|
document = Jsoup.parse(response.body().string()); |
|
|
|
@Override |
|
|
|
public void onPrepareForReplyCancelled() { |
|
|
|
showControls(); |
|
|
|
} |
|
|
|
|
|
|
|
Element message = document.select("textarea").first(); |
|
|
|
postText = message.text(); |
|
|
|
@Override |
|
|
|
public void onDeleteTaskStarted() { |
|
|
|
hideControls(); |
|
|
|
} |
|
|
|
|
|
|
|
commitEditURL = document.select("form").first().attr("action"); |
|
|
|
numReplies = replyPageUrl.substring(replyPageUrl.indexOf("num_replies=") + 12); |
|
|
|
seqnum = document.select("input[name=seqnum]").first().attr("value"); |
|
|
|
sc = document.select("input[name=sc]").first().attr("value"); |
|
|
|
topic = document.select("input[name=topic]").first().attr("value"); |
|
|
|
@Override |
|
|
|
public void onDeleteTaskFinished(boolean result) { |
|
|
|
showControls(); |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (IOException | Selector.SelectorParseException e) { |
|
|
|
Timber.e(e, "Prepare failed."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (result) { |
|
|
|
viewModel.reloadPage(); |
|
|
|
} else { |
|
|
|
Toast.makeText(TopicActivity.this, "Post deleted!", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPostExecute(Boolean result) { |
|
|
|
postsList.get(position).setPostType(Post.TYPE_EDIT); |
|
|
|
topicAdapter.notifyItemChanged(position); |
|
|
|
topicAdapter.prepareForEdit(new EditTask(), commitEditURL, numReplies, seqnum, sc, topic, postText); |
|
|
|
recyclerView.scrollToPosition(position); |
|
|
|
progressBar.setVisibility(ProgressBar.GONE); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onPrepareEditStarted() { |
|
|
|
hideControls(); |
|
|
|
} |
|
|
|
|
|
|
|
public class EditTask extends AsyncTask<EditTaskDTO, Void, Boolean> { |
|
|
|
EditTaskDTO dto; |
|
|
|
@Override |
|
|
|
public void onPrepareEditCancelled() { |
|
|
|
showControls(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPreExecute() { |
|
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
|
paginationEnabled(false); |
|
|
|
replyFAB.setEnabled(false); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onEditTaskStarted() { |
|
|
|
hideControls(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Boolean doInBackground(EditTaskDTO... editTaskDTOS) { |
|
|
|
dto = editTaskDTOS[0]; |
|
|
|
RequestBody postBody = new MultipartBody.Builder() |
|
|
|
.setType(MultipartBody.FORM) |
|
|
|
.addFormDataPart("message", dto.getMessage()) |
|
|
|
.addFormDataPart("num_replies", dto.getNumReplies()) |
|
|
|
.addFormDataPart("seqnum", dto.getSeqnum()) |
|
|
|
.addFormDataPart("sc", dto.getSc()) |
|
|
|
.addFormDataPart("subject", dto.getSubject()) |
|
|
|
.addFormDataPart("topic", dto.getTopic()) |
|
|
|
.build(); |
|
|
|
Request post = new Request.Builder() |
|
|
|
.url(dto.getUrl()) |
|
|
|
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") |
|
|
|
.post(postBody) |
|
|
|
.build(); |
|
|
|
|
|
|
|
try { |
|
|
|
client.newCall(post).execute(); |
|
|
|
Response response = client.newCall(post).execute(); |
|
|
|
switch (replyStatus(response)) { |
|
|
|
case SUCCESSFUL: |
|
|
|
return true; |
|
|
|
case NEW_REPLY_WHILE_POSTING: |
|
|
|
//TODO this...
|
|
|
|
return true; |
|
|
|
default: |
|
|
|
Timber.e("Malformed post. Request string: %s", post.toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
Timber.e(e, "Edit failed."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onEditTaskFinished(boolean result, int position) { |
|
|
|
View view = getCurrentFocus(); |
|
|
|
if (view != null) { |
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPostExecute(Boolean result) { |
|
|
|
View view = getCurrentFocus(); |
|
|
|
if (view != null) { |
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
|
} |
|
|
|
postsList.get(position).setPostType(Post.TYPE_POST); |
|
|
|
topicAdapter.notifyItemChanged(position); |
|
|
|
viewModel.setEditingPost(false); |
|
|
|
|
|
|
|
postsList.get(dto.getPosition()).setPostType(Post.TYPE_POST); |
|
|
|
topicAdapter.notifyItemChanged(dto.getPosition()); |
|
|
|
showControls(); |
|
|
|
|
|
|
|
progressBar.setVisibility(ProgressBar.GONE); |
|
|
|
replyFAB.setVisibility(View.VISIBLE); |
|
|
|
bottomNavBar.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
if (!result) |
|
|
|
Toast.makeText(TopicActivity.this, "Edit failed!", Toast.LENGTH_SHORT).show(); |
|
|
|
paginationEnabled(true); |
|
|
|
replyFAB.setEnabled(true); |
|
|
|
topicAdapter.enablePostEditing(); |
|
|
|
|
|
|
|
if (result) { |
|
|
|
topicTask = new TopicTask(); |
|
|
|
reloadingPage = true; |
|
|
|
topicTask.execute(loadedPageUrl); |
|
|
|
} |
|
|
|
if (result) { |
|
|
|
viewModel.setEditingPost(false); |
|
|
|
viewModel.reloadPage(); |
|
|
|
} else { |
|
|
|
Toast.makeText(TopicActivity.this, "Edit failed!", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |