|
|
@ -228,42 +228,43 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo |
|
|
|
@Override |
|
|
|
public boolean onOptionsItemSelected(MenuItem item) { |
|
|
|
// Handle presses on the action bar items
|
|
|
|
switch (item.getItemId()) { |
|
|
|
case R.id.menu_bookmark: |
|
|
|
topicMenuBookmarkClick(); |
|
|
|
return true; |
|
|
|
case R.id.menu_info: |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); |
|
|
|
LayoutInflater inflater = this.getLayoutInflater(); |
|
|
|
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.setMovementMethod(LinkMovementMethod.getInstance()); |
|
|
|
TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); |
|
|
|
usersViewing.setText(new SpannableStringBuilder("Loading...")); |
|
|
|
usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); |
|
|
|
viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { |
|
|
|
if (topicTreeAndMods == null) return; |
|
|
|
treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); |
|
|
|
}); |
|
|
|
viewModel.getTopicViewers().observe(this, topicViewers -> { |
|
|
|
if (topicViewers == null) return; |
|
|
|
usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); |
|
|
|
}); |
|
|
|
builder.setView(infoDialog); |
|
|
|
topicInfoDialog = builder.create(); |
|
|
|
topicInfoDialog.show(); |
|
|
|
return true; |
|
|
|
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, viewModel.getTopicUrl()); |
|
|
|
startActivity(Intent.createChooser(sendIntent, "Share via")); |
|
|
|
return true; //invalidateOptionsMenu();
|
|
|
|
default: |
|
|
|
return super.onOptionsItemSelected(item); |
|
|
|
int itemId = item.getItemId(); |
|
|
|
if (itemId == R.id.menu_bookmark) { |
|
|
|
topicMenuBookmarkClick(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
else if (itemId == R.id.menu_info) { |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyleAccent); |
|
|
|
LayoutInflater inflater = this.getLayoutInflater(); |
|
|
|
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.setMovementMethod(LinkMovementMethod.getInstance()); |
|
|
|
TextView usersViewing = infoDialog.findViewById(R.id.users_viewing); |
|
|
|
usersViewing.setText(new SpannableStringBuilder("Loading...")); |
|
|
|
usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); |
|
|
|
viewModel.getTopicTreeAndMods().observe(this, topicTreeAndMods -> { |
|
|
|
if (topicTreeAndMods == null) return; |
|
|
|
treeAndMods.setText(HTMLUtils.getSpannableFromHtml(this, topicTreeAndMods)); |
|
|
|
}); |
|
|
|
viewModel.getTopicViewers().observe(this, topicViewers -> { |
|
|
|
if (topicViewers == null) return; |
|
|
|
usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); |
|
|
|
}); |
|
|
|
builder.setView(infoDialog); |
|
|
|
topicInfoDialog = builder.create(); |
|
|
|
topicInfoDialog.show(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
else if (itemId == R.id.menu_share) { |
|
|
|
Intent sendIntent = new Intent(Intent.ACTION_SEND); |
|
|
|
sendIntent.setType("text/plain"); |
|
|
|
sendIntent.putExtra(Intent.EXTRA_TEXT, viewModel.getTopicUrl()); |
|
|
|
startActivity(Intent.createChooser(sendIntent, "Share via")); |
|
|
|
return true; //invalidateOptionsMenu();
|
|
|
|
} |
|
|
|
return super.onOptionsItemSelected(item); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|