Fix app crashes on ViewSubredditDetailActivity. Fix some themeing issues.

This commit is contained in:
Alex Ning 2020-04-08 11:41:42 +08:00
parent cd4cf40236
commit 2c36d46cd0
5 changed files with 14 additions and 19 deletions

View File

@ -66,11 +66,11 @@ dependencies {
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.6'
implementation 'androidx.paging:paging-runtime:2.1.2'
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
implementation 'io.noties.markwon:core:4.2.0'
implementation 'io.noties.markwon:linkify:4.2.0'
implementation 'io.noties.markwon:ext-strikethrough:4.2.0'
implementation "io.noties.markwon:simple-ext:4.2.0"
implementation "io.noties.markwon:recycler-table:4.2.0"
implementation 'io.noties.markwon:core:4.3.1'
implementation 'io.noties.markwon:linkify:4.3.1'
implementation 'io.noties.markwon:ext-strikethrough:4.3.1'
implementation "io.noties.markwon:simple-ext:4.3.1"
implementation "io.noties.markwon:recycler-table:4.3.1"
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.4'
implementation 'org.greenrobot:eventbus:3.1.1'

View File

@ -4,9 +4,6 @@ import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
@ -375,12 +372,6 @@ public class ThemePreviewActivity extends AppCompatActivity {
protected void applyFABTheme(FloatingActionButton fab) {
fab.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimaryLightTheme));
fab.setImageTintList(ColorStateList.valueOf(customTheme.fabIconColor));
Drawable myFabSrc = getResources().getDrawable(R.drawable.ic_add_day_night_24dp);
if (myFabSrc.getConstantState() != null) {
Drawable willBeWhite = myFabSrc.getConstantState().newDrawable();
willBeWhite.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
fab.setImageDrawable(willBeWhite);
}
}
public CustomTheme getCustomTheme() {

View File

@ -169,8 +169,10 @@ public class ViewSidebarActivity extends BaseActivity {
.get(SubredditViewModel.class);
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
if (subredditData != null) {
markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
markwonAdapter.notifyDataSetChanged();
if (subredditData.getSidebarDescription() != null && !subredditData.getSidebarDescription().equals("")) {
markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
markwonAdapter.notifyDataSetChanged();
}
} else {
fetchSubredditData();
}

View File

@ -701,7 +701,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
case Post.TEXT_TYPE:
((PostDetailViewHolder) holder).mTypeTextView.setText("TEXT");
if (!mPost.getSelfText().equals("")) {
if (mPost.getSelfText() != null && !mPost.getSelfText().equals("")) {
((PostDetailViewHolder) holder).mContentMarkdownView.setVisibility(View.VISIBLE);
LinearLayoutManager linearLayoutManager = new MarkwonLinearLayoutManager(mActivity, new MarkwonLinearLayoutManager.HorizontalScrollViewScrolledListener() {
@Override

View File

@ -152,8 +152,10 @@ public class SidebarFragment extends Fragment {
.get(SubredditViewModel.class);
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
if (subredditData != null) {
markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
markwonAdapter.notifyDataSetChanged();
if (subredditData.getSidebarDescription() != null && !subredditData.getSidebarDescription().equals("")) {
markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
markwonAdapter.notifyDataSetChanged();
}
} else {
fetchSubredditData();
}