aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2018-07-30 15:27:52 +0000
committerAlex Ning <chineseperson5@gmail.com>2018-07-30 15:27:52 +0000
commit7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad (patch)
tree4c7e2b89cb2c37ac2febede0d151e60bc536e054 /app/src/main/java
parentc752b66953ad0beca25e87ecf98db346ddabf55a (diff)
downloadinfinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.tar
infinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.tar.gz
infinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.tar.bz2
infinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.tar.lz
infinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.tar.xz
infinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.tar.zst
infinity-for-reddit-7f8ca49190fdb4c2ac0acbf1f6cbcd235fe6d3ad.zip
Add the ViewSubredditActivity. Add a OnClickListener in the subscribed subreddits RecyclerView to lauch the ViewSubredditActivity.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java51
3 files changed, 59 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java
index 5fefa9e6..c235d653 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditUtils.java
@@ -34,7 +34,6 @@ class RedditUtils {
static final String SCOPE_KEY = "scope";
static final String SCOPE = "identity edit flair history modconfig modflair modlog modposts modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread";
static final String ACCESS_TOKEN_KEY = "access_token";
- static final String EXPIRES_IN_KEY = "expires_in";
static final String AUTHORIZATION_KEY = "Authorization";
static final String AUTHORIZATION_BASE = "bearer ";
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
index 88d194d7..67a569cd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit;
import android.content.Context;
+import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -33,6 +34,13 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
+ mContext.startActivity(intent);
+ }
+ });
if(!mSubscribedSubredditData.get(i).getIconUrl().equals("")) {
glide.load(mSubscribedSubredditData.get(i).getIconUrl()).into(((SubredditViewHolder) viewHolder).iconCircleImageView);
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
new file mode 100644
index 00000000..3346aaea
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -0,0 +1,51 @@
+package ml.docilealligator.infinityforreddit;
+
+import android.os.Bundle;
+import android.support.design.widget.AppBarLayout;
+import android.support.design.widget.CollapsingToolbarLayout;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+
+public class ViewSubredditDetailActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_view_subreddit_detail);
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout_view_subreddit_detail_activity);
+ AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout_view_subreddit_detail_activity);
+ appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
+ boolean isShow = true;
+ int scrollRange = -1;
+
+ @Override
+ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
+ if (scrollRange == -1) {
+ scrollRange = appBarLayout.getTotalScrollRange();
+ }
+ if (scrollRange + verticalOffset == 0) {
+ collapsingToolbarLayout.setTitle(getString(R.string.title_activity_view_subreddit_detail));
+ isShow = true;
+ } else if(isShow) {
+ collapsingToolbarLayout.setTitle(" ");//carefull there should a space between double quote otherwise it wont work
+ isShow = false;
+ }
+ }
+ });
+
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
+ .setAction("Action", null).show();
+ }
+ });
+ }
+}