aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-09-19 09:16:31 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-09-19 09:16:31 +0000
commit0b2e358584add4c70550dea654acfc79994c3490 (patch)
tree4b2688462f2aed6d8d0525f3ac36f326d38e64f1 /app
parent50da29ad8c507898b337b0ebcb84b34ef1680978 (diff)
downloadinfinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.tar
infinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.tar.gz
infinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.tar.bz2
infinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.tar.lz
infinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.tar.xz
infinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.tar.zst
infinity-for-reddit-0b2e358584add4c70550dea654acfc79994c3490.zip
Fixed frames dropping when playing videos. Use smaller icons for saving and unsaving comments. Temporarily show precise error message when loading posts failed.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java15
-rw-r--r--app/src/main/res/drawable/ic_bookmark_20dp.xml4
-rw-r--r--app/src/main/res/drawable/ic_bookmark_border_20dp.xml4
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>