diff options
Diffstat (limited to 'app')
7 files changed, 51 insertions, 26 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java index b3c501c0..ac80f670 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java @@ -749,9 +749,9 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie }); if(comment.isSaved()) { - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp); } else { - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp); } ((CommentViewHolder) holder).saveButton.setOnClickListener(view -> { @@ -761,14 +761,14 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie @Override public void success() { comment.setSaved(false); - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp); Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show(); } @Override public void failed() { comment.setSaved(true); - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp); Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show(); } }); @@ -778,14 +778,14 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie @Override public void success() { comment.setSaved(true); - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp); Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show(); } @Override public void failed() { comment.setSaved(false); - ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp); Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show(); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java index 0a2ec243..eac2211b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java @@ -289,9 +289,9 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R }); if(comment.isSaved()) { - ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp); } else { - ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp); } ((DataViewHolder) holder).saveButton.setOnClickListener(view -> { @@ -301,14 +301,14 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R @Override public void success() { comment.setSaved(false); - ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp); Toast.makeText(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show(); } @Override public void failed() { comment.setSaved(true); - ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp); Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show(); } }); @@ -318,14 +318,14 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R @Override public void success() { comment.setSaved(true); - ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp); Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show(); } @Override public void failed() { comment.setSaved(false); - ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp); Toast.makeText(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show(); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java index c1030f3a..4b8deadd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java @@ -229,19 +229,21 @@ class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onParsePostsListingFail() { - initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data")); + initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts")); } }); } } else { - initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, response.message())); + initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, + "code: " + response.code() + " message: " + response.message())); } } @Override public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { String errorMessage = t.getMessage(); - initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, errorMessage)); + initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, + errorMessage + " " + call.request().url().toString())); } }); } @@ -270,7 +272,7 @@ class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onParsePostsListingFail() { - paginationNetworkStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data")); + paginationNetworkStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing more posts")); } }); } else { @@ -342,19 +344,21 @@ class PostDataSource extends PageKeyedDataSource<String, Post> { @Override public void onParsePostsListingFail() { - initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data")); + initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts")); } }); } } else { - initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, response.message())); + initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, + "code: " + response + " message: " + response.message())); } } @Override public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { String errorMessage = t.getMessage(); - initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, errorMessage)); + initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, + errorMessage + " " + call.request().url().toString())); } }); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index 67a0b247..23cb85bc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -411,7 +411,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } else if(networkState.getStatus().equals(NetworkState.Status.FAILED)) { mProgressBar.setVisibility(View.GONE); mFetchPostInfoLinearLayout.setOnClickListener(view -> refresh()); - showErrorView(R.string.load_posts_error); + //showErrorView(R.string.load_posts_error); + showErrorView(networkState.getMsg()); } else { mProgressBar.setVisibility(View.VISIBLE); } @@ -466,6 +467,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } } + private void showErrorView(String message) { + if(activity != null && isAdded()) { + mProgressBar.setVisibility(View.GONE); + mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE); + mFetchPostInfoTextView.setText(message); + mGlide.load(R.drawable.error_image).into(mFetchPostInfoImageView); + } + } + @Override public void changeNSFW(boolean nsfw) { mPostViewModel.changeNSFW(nsfw); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java index 640db3d7..ec336d65 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java @@ -38,8 +38,6 @@ import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.source.ExtractorMediaSource; -import com.google.android.exoplayer2.source.dash.DashChunkSource; -import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; @@ -49,6 +47,7 @@ import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; +import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.util.Util; import java.io.File; @@ -291,17 +290,21 @@ public class ViewVideoActivity extends AppCompatActivity { TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector); videoPlayerView.setPlayer(player); - // Produces DataSource instances through which media data is loaded. - DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, - Util.getUserAgent(this, "Infinity"), bandwidthMeter); + DataSource.Factory dataSourceFactory; // Prepare the player with the source. if(mIsHLSVideo) { - DashChunkSource.Factory dashChunkSourceFactory = new DefaultDashChunkSource.Factory(dataSourceFactory); + // Produces DataSource instances through which media data is loaded. + dataSourceFactory = new DefaultHttpDataSourceFactory( + Util.getUserAgent(this, "Infinity")); player.prepare(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri)); } else { + // Produces DataSource instances through which media data is loaded. + dataSourceFactory = new DefaultDataSourceFactory(this, + Util.getUserAgent(this, "Infinity"), bandwidthMeter); player.prepare(new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(mVideoUri)); } + player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setPlayWhenReady(true); wasPlaying = true; diff --git a/app/src/main/res/drawable/ic_bookmark_20dp.xml b/app/src/main/res/drawable/ic_bookmark_20dp.xml new file mode 100644 index 00000000..6908d298 --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_20dp.xml @@ -0,0 +1,4 @@ +<vector android:height="20dp" android:viewportHeight="24" + android:viewportWidth="24" android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M17,3H7c-1.1,0 -2,0.9 -2,2v16l7,-3 7,3V5c0,-1.1 -0.9,-2 -2,-2z"/> +</vector> diff --git a/app/src/main/res/drawable/ic_bookmark_border_20dp.xml b/app/src/main/res/drawable/ic_bookmark_border_20dp.xml new file mode 100644 index 00000000..d77b4ce5 --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_border_20dp.xml @@ -0,0 +1,4 @@ +<vector android:height="20dp" android:viewportHeight="24" + android:viewportWidth="24" android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M17,3L7,3c-1.1,0 -2,0.9 -2,2v16l7,-3 7,3L19,5c0,-1.1 -0.9,-2 -2,-2zM17,18l-5,-2.18L7,18L7,5h10v13z"/> +</vector> |