Просмотр исходного кода

Add awesome preloader, comments section, UI improvements

Infinite 3 лет назад
Родитель
Сommit
2fd9cd860b

+ 1 - 0
app/build.gradle

@@ -46,5 +46,6 @@ dependencies {
     implementation 'org.jsoup:jsoup:1.11.1'
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
     implementation "androidx.recyclerview:recyclerview:1.2.1"
+    implementation 'com.facebook.shimmer:shimmer:0.5.0'
 
 }

+ 126 - 0
app/src/main/java/club/thepenguins/android/adapters/CommentAdapter.java

@@ -0,0 +1,126 @@
+package club.thepenguins.android.adapters;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.cardview.widget.CardView;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+
+import com.squareup.picasso.Callback;
+import com.squareup.picasso.NetworkPolicy;
+import com.squareup.picasso.Picasso;
+
+import java.util.ArrayList;
+
+import club.thepenguins.android.R;
+import club.thepenguins.android.data.CommentModel;
+
+public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder> {
+
+
+    private ArrayList<CommentModel> data;
+    private Context ctx;
+
+    public CommentAdapter(ArrayList<CommentModel> list, Context context) {
+        this.data = list;
+        this.ctx = context;
+    }
+
+    @NonNull
+    @Override
+    public CommentAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+
+        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_item, parent, false);
+
+        return new CommentAdapter.ViewHolder(view);
+    }
+
+    @SuppressLint("SetTextI18n")
+    @Override
+    public void onBindViewHolder(@NonNull CommentAdapter.ViewHolder holder, int position) {
+
+        final CommentModel object = data.get(position);
+
+        holder.author.setText(object.getAuthor());
+        holder.comment.setText("\n" + Html.fromHtml(object.getContent()));
+        holder.time.setText(object.getTime());
+        Picasso.get()
+                .load(object.getImage())
+                .placeholder(R.color.shimmer_placeholder)
+                .fit()
+                .centerCrop()
+                .networkPolicy(NetworkPolicy.OFFLINE)
+                .into(holder.imageView, new Callback() {
+                    @Override
+                    public void onSuccess() {
+
+                    }
+
+                    @Override
+                    public void onError(Exception e) {
+                        Picasso.get()
+                                .load(object.getImage())
+                                .placeholder(R.color.shimmer_placeholder)
+                                .fit()
+                                .centerCrop()
+                                .into(holder.imageView);
+                    }
+                });
+
+
+    }
+
+    public void clear() {
+
+        data.clear();
+
+        notifyDataSetChanged();
+
+    }
+
+    public void addAll(ArrayList<CommentModel> list) {
+
+        list.addAll(list);
+
+        notifyDataSetChanged();
+
+    }
+
+    @Override
+    public int getItemCount() {
+        return data.size();
+    }
+
+    public class ViewHolder extends RecyclerView.ViewHolder {
+
+
+        TextView author, comment, time;
+        CardView cardView;
+        ImageView imageView;
+
+
+        public ViewHolder(@NonNull View itemView) {
+            super(itemView);
+
+            cardView = itemView.findViewById(R.id.commentCard);
+            imageView = itemView.findViewById(R.id.commenterImage);
+            author = itemView.findViewById(R.id.author);
+            comment = itemView.findViewById(R.id.comment);
+            time = itemView.findViewById(R.id.commentTime);
+        }
+    }
+
+    public void setData(ArrayList<CommentModel> data) {
+        this.data = data;
+        notifyDataSetChanged();
+    }
+}

+ 3 - 3
app/src/main/java/club/thepenguins/android/adapters/PostRecyclerAdapter.java

@@ -55,7 +55,7 @@ public class PostRecyclerAdapter extends RecyclerView.Adapter<PostRecyclerAdapte
 
         Picasso.get()
                 .load(object.Image)
-                .placeholder(R.color.preloadColor)
+                .placeholder(R.color.shimmer_placeholder)
                 .fit()
                 .centerCrop()
                 .networkPolicy(NetworkPolicy.OFFLINE)
@@ -69,7 +69,7 @@ public class PostRecyclerAdapter extends RecyclerView.Adapter<PostRecyclerAdapte
                     public void onError(Exception e) {
                         Picasso.get()
                                 .load(object.Image)
-                                .placeholder(R.color.preloadColor)
+                                .placeholder(R.color.shimmer_placeholder)
                                 .fit()
                                 .centerCrop()
                                 .into(holder.imageView);
@@ -93,7 +93,7 @@ public class PostRecyclerAdapter extends RecyclerView.Adapter<PostRecyclerAdapte
 
                 FragmentManager fragmentManager = ((AppCompatActivity) ctx).getSupportFragmentManager();
 
-                fragmentManager.beginTransaction().replace(R.id.flContent, PostFragment.newInstance(object.Content, object.Image, object.title, object.author)).addToBackStack("DetailedPizza").commit();
+                fragmentManager.beginTransaction().replace(R.id.flContent, PostFragment.newInstance(object.Content, object.Image, object.title, object.author)).addToBackStack(null).commit();
 
             }
         });

+ 4 - 0
app/src/main/java/club/thepenguins/android/api/APIService.java

@@ -2,6 +2,7 @@ package club.thepenguins.android.api;
 
 import java.util.List;
 
+import club.thepenguins.android.data.Comments;
 import club.thepenguins.android.data.Image;
 import club.thepenguins.android.data.IndividualPost;
 import club.thepenguins.android.data.Posts;
@@ -29,4 +30,7 @@ public interface APIService {
     @GET("wp-json/wp/v2/posts?_embed")
     Call<List<Posts>> getAuthorPosts(@Query("author") String id);
 
+    @GET("wp-json/wp/v2/comments")
+    Call<List<Comments>> getPostComments(@Query("post") String id);
+
 }

+ 52 - 0
app/src/main/java/club/thepenguins/android/data/CommentModel.java

@@ -0,0 +1,52 @@
+package club.thepenguins.android.data;
+
+public class CommentModel {
+
+    private String image, author, time, content;
+
+    public CommentModel(String image, String author, String time, String content) {
+
+        this.image = image;
+        this.author = author;
+        this.time = time;
+        this.content = content;
+    }
+
+    public CommentModel(String author, String time, String content) {
+        this.author = author;
+        this.time = time;
+        this.content = content;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+}

+ 376 - 0
app/src/main/java/club/thepenguins/android/data/Comments.java

@@ -0,0 +1,376 @@
+package club.thepenguins.android.data;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+public class Comments {
+
+    @SerializedName("id")
+    @Expose
+    private Integer id;
+    @SerializedName("post")
+    @Expose
+    private Integer post;
+    @SerializedName("parent")
+    @Expose
+    private Integer parent;
+    @SerializedName("author")
+    @Expose
+    private Integer author;
+    @SerializedName("author_name")
+    @Expose
+    private String authorName;
+    @SerializedName("author_url")
+    @Expose
+    private String authorUrl;
+    @SerializedName("date")
+    @Expose
+    private String date;
+    @SerializedName("date_gmt")
+    @Expose
+    private String dateGmt;
+    @SerializedName("content")
+    @Expose
+    private Content content;
+    @SerializedName("link")
+    @Expose
+    private String link;
+    @SerializedName("status")
+    @Expose
+    private String status;
+    @SerializedName("type")
+    @Expose
+    private String type;
+    @SerializedName("author_avatar_urls")
+    @Expose
+    private AuthorAvatarUrls authorAvatarUrls;
+    @SerializedName("meta")
+    @Expose
+    private List<Object> meta = null;
+    @SerializedName("_links")
+    @Expose
+    private Links links;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getPost() {
+        return post;
+    }
+
+    public void setPost(Integer post) {
+        this.post = post;
+    }
+
+    public Integer getParent() {
+        return parent;
+    }
+
+    public void setParent(Integer parent) {
+        this.parent = parent;
+    }
+
+    public Integer getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(Integer author) {
+        this.author = author;
+    }
+
+    public String getAuthorName() {
+        return authorName;
+    }
+
+    public void setAuthorName(String authorName) {
+        this.authorName = authorName;
+    }
+
+    public String getAuthorUrl() {
+        return authorUrl;
+    }
+
+    public void setAuthorUrl(String authorUrl) {
+        this.authorUrl = authorUrl;
+    }
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getDateGmt() {
+        return dateGmt;
+    }
+
+    public void setDateGmt(String dateGmt) {
+        this.dateGmt = dateGmt;
+    }
+
+    public Content getContent() {
+        return content;
+    }
+
+    public void setContent(Content content) {
+        this.content = content;
+    }
+
+    public String getLink() {
+        return link;
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public AuthorAvatarUrls getAuthorAvatarUrls() {
+        return authorAvatarUrls;
+    }
+
+    public void setAuthorAvatarUrls(AuthorAvatarUrls authorAvatarUrls) {
+        this.authorAvatarUrls = authorAvatarUrls;
+    }
+
+    public List<Object> getMeta() {
+        return meta;
+    }
+
+    public void setMeta(List<Object> meta) {
+        this.meta = meta;
+    }
+
+    public Links getLinks() {
+        return links;
+    }
+
+    public void setLinks(Links links) {
+        this.links = links;
+    }
+
+
+    public class Author {
+
+        @SerializedName("embeddable")
+        @Expose
+        private Boolean embeddable;
+        @SerializedName("href")
+        @Expose
+        private String href;
+
+        public Boolean getEmbeddable() {
+            return embeddable;
+        }
+
+        public void setEmbeddable(Boolean embeddable) {
+            this.embeddable = embeddable;
+        }
+
+        public String getHref() {
+            return href;
+        }
+
+        public void setHref(String href) {
+            this.href = href;
+        }
+
+    }
+
+    public class AuthorAvatarUrls {
+
+        @SerializedName("24")
+        @Expose
+        private String _24;
+        @SerializedName("48")
+        @Expose
+        private String _48;
+        @SerializedName("96")
+        @Expose
+        private String _96;
+
+        public String get24() {
+            return _24;
+        }
+
+        public void set24(String _24) {
+            this._24 = _24;
+        }
+
+        public String get48() {
+            return _48;
+        }
+
+        public void set48(String _48) {
+            this._48 = _48;
+        }
+
+        public String get96() {
+            return _96;
+        }
+
+        public void set96(String _96) {
+            this._96 = _96;
+        }
+
+    }
+
+    public class Collection {
+
+        @SerializedName("href")
+        @Expose
+        private String href;
+
+        public String getHref() {
+            return href;
+        }
+
+        public void setHref(String href) {
+            this.href = href;
+        }
+
+    }
+
+
+    public class Content {
+
+        @SerializedName("rendered")
+        @Expose
+        private String rendered;
+
+        public String getRendered() {
+            return rendered;
+        }
+
+        public void setRendered(String rendered) {
+            this.rendered = rendered;
+        }
+
+    }
+
+    public class Links {
+
+        @SerializedName("self")
+        @Expose
+        private List<Self> self = null;
+        @SerializedName("collection")
+        @Expose
+        private List<Collection> collection = null;
+        @SerializedName("author")
+        @Expose
+        private List<Author> author = null;
+        @SerializedName("up")
+        @Expose
+        private List<Up> up = null;
+
+        public List<Self> getSelf() {
+            return self;
+        }
+
+        public void setSelf(List<Self> self) {
+            this.self = self;
+        }
+
+        public List<Collection> getCollection() {
+            return collection;
+        }
+
+        public void setCollection(List<Collection> collection) {
+            this.collection = collection;
+        }
+
+        public List<Author> getAuthor() {
+            return author;
+        }
+
+        public void setAuthor(List<Author> author) {
+            this.author = author;
+        }
+
+        public List<Up> getUp() {
+            return up;
+        }
+
+        public void setUp(List<Up> up) {
+            this.up = up;
+        }
+
+    }
+
+    public class Self {
+
+        @SerializedName("href")
+        @Expose
+        private String href;
+
+        public String getHref() {
+            return href;
+        }
+
+        public void setHref(String href) {
+            this.href = href;
+        }
+
+    }
+
+    public class Up {
+
+        @SerializedName("embeddable")
+        @Expose
+        private Boolean embeddable;
+        @SerializedName("post_type")
+        @Expose
+        private String postType;
+        @SerializedName("href")
+        @Expose
+        private String href;
+
+        public Boolean getEmbeddable() {
+            return embeddable;
+        }
+
+        public void setEmbeddable(Boolean embeddable) {
+            this.embeddable = embeddable;
+        }
+
+        public String getPostType() {
+            return postType;
+        }
+
+        public void setPostType(String postType) {
+            this.postType = postType;
+        }
+
+        public String getHref() {
+            return href;
+        }
+
+        public void setHref(String href) {
+            this.href = href;
+        }
+    }
+}

+ 22 - 0
app/src/main/java/club/thepenguins/android/fragments/HomeFragment.java

@@ -11,6 +11,7 @@ import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import com.facebook.shimmer.ShimmerFrameLayout;
 
 import org.jsoup.parser.Parser;
 
@@ -43,6 +44,7 @@ public class HomeFragment extends Fragment {
     private PostRecyclerAdapter adapter;
     public static List<Posts> mListPost;
     private SwipeRefreshLayout swipeContainer;
+    private ShimmerFrameLayout loader;
 
 
     public static HomeFragment newInstance(String param1, String param2) {
@@ -82,6 +84,9 @@ public class HomeFragment extends Fragment {
         LayoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
         recyclerView.setLayoutManager(LayoutManager);
 
+
+        loader = (ShimmerFrameLayout) rootView.findViewById(R.id.shimmer_view_container);
+
         swipeContainer = rootView.findViewById(R.id.swiperefresh);
 
         list = new ArrayList<>();
@@ -115,12 +120,27 @@ public class HomeFragment extends Fragment {
 
                 android.R.color.holo_red_light);
 
+
         return rootView;
     }
 
+    @Override
+    public void onResume() {
+        //loader.startShimmer();
+        super.onResume();
+    }
+
+    @Override
+    public void onPause() {
+        //loader.stopShimmer();
+        super.onPause();
+    }
+
     private void getRetrofit(String perpage) {
 
         swipeContainer.setRefreshing(true);
+        loader.setVisibility(View.VISIBLE);
+        loader.startShimmer();
 
         Retrofit retrofit = new Retrofit.Builder()
                 .baseUrl(Constants.BaseUrl)
@@ -143,6 +163,8 @@ public class HomeFragment extends Fragment {
                 }
                 adapter.notifyDataSetChanged();
                 swipeContainer.setRefreshing(false);
+                loader.setVisibility(View.GONE);
+                recyclerView.setVisibility(View.VISIBLE);
 
             }
 

+ 86 - 5
app/src/main/java/club/thepenguins/android/fragments/PostFragment.java

@@ -3,6 +3,8 @@ package club.thepenguins.android.fragments;
 import android.os.Bundle;
 
 import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
 
 import android.os.Handler;
 import android.util.Log;
@@ -11,20 +13,28 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.webkit.WebView;
 import android.widget.ProgressBar;
+import android.widget.TextView;
 import android.widget.Toast;
 
 
+import com.facebook.shimmer.ShimmerFrameLayout;
+
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import club.thepenguins.android.R;
+import club.thepenguins.android.adapters.CommentAdapter;
 import club.thepenguins.android.api.APIService;
+import club.thepenguins.android.data.CommentModel;
+import club.thepenguins.android.data.Comments;
 import club.thepenguins.android.data.IndividualPost;
 import club.thepenguins.android.data.PostContent;
+import club.thepenguins.android.utils.Constants;
 import retrofit2.Call;
 import retrofit2.Response;
 import retrofit2.Retrofit;
@@ -42,7 +52,13 @@ public class PostFragment extends Fragment {
     private String mParam3;
     private String mParam4;
     private ArrayList<PostContent> postData;
-    private ProgressBar progressBar;
+    private ArrayList<CommentModel> comments;
+    private RecyclerView recyclerView;
+    private CommentAdapter commentAdapter;
+    private LinearLayoutManager layoutManager;
+    private TextView textView;
+    private ShimmerFrameLayout loader;
+
 
     public PostFragment() {
         // Required empty public constructor
@@ -77,13 +93,15 @@ public class PostFragment extends Fragment {
 
         View rootView = inflater.inflate(R.layout.fragment_post, container, false);
 
-
-        progressBar = rootView.findViewById(R.id.progress);
+        loader = (ShimmerFrameLayout) rootView.findViewById(R.id.shimmer_view_container);
 
         postData = new ArrayList<>();
+        comments = new ArrayList<>();
+
         postData.clear();
 
         getRetrofit(mParam1);
+
         Log.d("TAG", "onCreateView: " + mParam1);
 
         final Handler handler = new Handler();
@@ -130,7 +148,10 @@ public class PostFragment extends Fragment {
 
                     myWebView.loadDataWithBaseURL(null, newHtmlString, "text/html", "UTF-8", null);
                     myWebView.getSettings().setJavaScriptEnabled(true);
-                    progressBar.setVisibility(View.GONE);
+                    loader.setVisibility(View.GONE);
+                    textView.setVisibility(View.VISIBLE);
+                    recyclerView.setVisibility(View.VISIBLE);
+
                 } catch (Exception e) {
                     Toast.makeText(rootView.getContext(), "Please retry", Toast.LENGTH_SHORT).show();
                     Log.d("PostFragment", "run: " + e);
@@ -140,13 +161,32 @@ public class PostFragment extends Fragment {
             }
         }, 3000);
 
+        textView = rootView.findViewById(R.id.txtview);
+
+        recyclerView = rootView.findViewById(R.id.recyclerComment);
+
+        layoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
+        recyclerView.setLayoutManager(layoutManager);
+
+
+        handler.postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                commentAdapter = new CommentAdapter(comments, rootView.getContext());
+                recyclerView.setAdapter(commentAdapter);
+                String intValue = mParam1.replaceAll("[^0-9]", "").substring(1);
+
+                getComments(intValue);
+            }
+        }, 5000);
+
 
         return rootView;
     }
 
     private void getRetrofit(String postUrl) {
 
-        progressBar.setVisibility(View.VISIBLE);
+        loader.startShimmer();
 
 
         Retrofit retrofit = new Retrofit.Builder()
@@ -181,5 +221,46 @@ public class PostFragment extends Fragment {
         });
     }
 
+    public void getComments(String id) {
+
+
+        Retrofit retrofit = new Retrofit.Builder()
+                .baseUrl(Constants.BaseUrl)
+                .addConverterFactory(GsonConverterFactory.create())
+                .build();
+
+        APIService service = retrofit.create(APIService.class);
+        Call<List<Comments>> call = service.getPostComments(id);
+
+
+        call.enqueue(new retrofit2.Callback<List<Comments>>() {
+            @Override
+            public void onResponse(Call<List<Comments>> call, Response<List<Comments>> response) {
+
+                for (int i = 0; i < response.body().size(); i++) {
+
+                    comments.add(new CommentModel(response.body().get(i).getAuthorAvatarUrls().get96(), response.body().get(i).getAuthorName(), response.body().get(i).getDate(), response.body().get(i).getContent().getRendered()));
+
+                    System.out.println(response.body().get(i).getContent());
+                }
+                commentAdapter.notifyDataSetChanged();
+                if (comments.size() != 0) {
+                    textView.setText("Comments:");
+                } else {
+                    textView.setText("No Comments");
+                }
+
+
+            }
+
+            @Override
+            public void onFailure(Call<List<Comments>> call, Throwable t) {
+
+                Log.d("PostRecyclerAdapter", "onFailure: ", t);
+            }
+        });
+
+    }
+
 
 }

+ 97 - 0
app/src/main/res/layout/comment_item.xml

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/commentCard"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_margin="5dp"
+    android:orientation="horizontal"
+    app:cardElevation="5dp">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal">
+
+        <ImageView
+            android:layout_marginTop="5dp"
+            android:layout_marginStart="5dp"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:id="@+id/commenterImage"
+            android:src="@color/shimmer_placeholder"
+            />
+
+
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        >
+
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center_vertical"
+            android:orientation="vertical"
+            >
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:id="@+id/author"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="5dp"
+                    android:gravity="left"
+                    android:text="Commenter"
+                    android:textColor="@color/black"
+                    android:textSize="16sp"
+                    android:textStyle="bold" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="right"
+                    android:padding="5dp"
+                    android:text="says:"
+                    android:textSize="15sp" />
+
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+
+                <TextView
+                    android:id="@+id/commentTime"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="right"
+                    android:padding="5dp"
+                    android:text="Time"
+                    android:textSize="15sp" />
+
+            </LinearLayout>
+
+            <TextView
+                android:id="@+id/comment"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="10dp"
+                android:layout_marginStart="5dp"/>
+
+        </LinearLayout>
+
+
+    </RelativeLayout>
+    </LinearLayout>
+
+</androidx.cardview.widget.CardView>

+ 39 - 6
app/src/main/res/layout/fragment_home.xml

@@ -1,28 +1,61 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".fragments.HomeFragment">
 
-    <RelativeLayout
+    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+        android:id="@+id/swiperefresh"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
-        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
-            android:id="@+id/swiperefresh"
+
+        <RelativeLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent">
 
 
+            <com.facebook.shimmer.ShimmerFrameLayout
+                android:id="@+id/shimmer_view_container"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:shimmer_auto_start="false">
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical">
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                    <include layout="@layout/shimmer_placeholder_layout" />
+
+                </LinearLayout>
+
+
+            </com.facebook.shimmer.ShimmerFrameLayout>
+
             <androidx.recyclerview.widget.RecyclerView
                 android:id="@+id/recycler_view"
                 android:layout_width="match_parent"
-                android:layout_height="match_parent">
+                android:layout_height="match_parent"
+                android:visibility="gone">
 
             </androidx.recyclerview.widget.RecyclerView>
-        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
-    </RelativeLayout>
+        </RelativeLayout>
+    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
 </FrameLayout>

+ 37 - 8
app/src/main/res/layout/fragment_post.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -9,25 +10,53 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
-       <RelativeLayout
-           android:layout_width="match_parent"
-           android:layout_height="match_parent"
-           >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
 
-            <ProgressBar
-                android:id="@+id/progress"
+            <com.facebook.shimmer.ShimmerFrameLayout
+                android:id="@+id/shimmer_view_container"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:visibility="gone" />
+                app:shimmer_auto_start="false">
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical">
+
+                    <include layout="@layout/shimmer_post_detail" />
+
+                </LinearLayout>
+
+
+            </com.facebook.shimmer.ShimmerFrameLayout>
 
 
             <WebView
                 android:id="@+id/webview"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_below="@+id/progress"
+                android:layout_below="@+id/shimmer_view_container"
                 android:nestedScrollingEnabled="true" />
 
+            <TextView
+                android:id="@+id/txtview"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@+id/webview"
+                android:layout_margin="10dp"
+                android:textColor="@color/black"
+                android:textSize="25sp"
+                android:visibility="gone" />
+
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/recyclerComment"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/txtview"
+                android:visibility="gone" />
+
         </RelativeLayout>
 
 

+ 86 - 0
app/src/main/res/layout/shimmer_placeholder_layout.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/card"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_margin="5dp"
+    android:orientation="horizontal"
+    app:cardElevation="5dp">
+
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <ImageView
+            android:id="@+id/Icon"
+            android:layout_width="match_parent"
+            android:layout_height="200dp"
+            android:layout_margin="5dp"
+            android:background="@color/shimmer_placeholder" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/Icon"
+            android:gravity="center_vertical"
+            android:orientation="vertical"
+            android:paddingTop="10dp">
+
+            <TextView
+                android:id="@+id/title"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:layout_marginBottom="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:textSize="20sp"
+                android:textStyle="bold" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:orientation="horizontal"
+
+                >
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="5dp"
+                    android:gravity="left"
+                    android:textSize="16sp"
+                    android:textStyle="bold" />
+
+                <TextView
+                    android:id="@+id/author"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="right"
+                    android:padding="5dp"
+                    android:textSize="15sp" />
+
+            </LinearLayout>
+
+            <TextView
+                android:id="@+id/subtitle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+        </LinearLayout>
+
+
+    </RelativeLayout>
+
+
+</androidx.cardview.widget.CardView>

+ 176 - 0
app/src/main/res/layout/shimmer_post_detail.xml

@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/card"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_margin="5dp"
+    android:orientation="horizontal"
+    app:cardElevation="5dp">
+
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <ImageView
+            android:id="@+id/Icon"
+            android:layout_width="match_parent"
+            android:layout_height="200dp"
+            android:layout_margin="5dp"
+            android:background="@color/shimmer_placeholder" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/Icon"
+            android:gravity="center_vertical"
+            android:orientation="vertical"
+            android:paddingTop="10dp">
+
+            <TextView
+                android:id="@+id/title"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:layout_marginBottom="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:textSize="20sp"
+                android:textStyle="bold" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:orientation="horizontal"
+
+                >
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="5dp"
+                    android:gravity="left"
+                    android:textSize="16sp"
+                    android:textStyle="bold" />
+
+                <TextView
+                    android:id="@+id/author"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="right"
+                    android:padding="5dp"
+                    android:textSize="15sp" />
+
+            </LinearLayout>
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:background="@color/shimmer_placeholder"
+                android:gravity="left"
+                android:lineSpacingExtra="2dp"
+                android:maxLines="5"
+                android:padding="5dp" />
+
+
+        </LinearLayout>
+
+
+    </RelativeLayout>
+
+
+</androidx.cardview.widget.CardView>

+ 3 - 3
app/src/main/res/values-night/themes.xml

@@ -2,15 +2,15 @@
     <!-- Base application theme. -->
     <style name="Theme.PenguinsRead" parent="Theme.MaterialComponents.DayNight.NoActionBar">
         <!-- Primary brand color. -->
-        <item name="colorPrimary">@color/purple_200</item>
+        <item name="colorPrimary">@color/purple_500</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>
         <item name="colorOnPrimary">@color/black</item>
         <!-- Secondary brand color. -->
         <item name="colorSecondary">@color/teal_200</item>
-        <item name="colorSecondaryVariant">@color/teal_200</item>
+        <item name="colorSecondaryVariant">@color/teal_700</item>
         <item name="colorOnSecondary">@color/black</item>
+        <item name="drawerArrowStyle">@style/DrawerIconDay</item>
         <!-- Status bar color. -->
-        <item name="drawerArrowStyle">@style/DrawerIconNight</item>
         <item name="android:statusBarColor" tools:targetApi="l">@color/black</item>
         <!-- Customize your theme here. -->
     </style>

+ 2 - 0
app/src/main/res/values/colors.xml

@@ -8,4 +8,6 @@
     <color name="black">#FF000000</color>
     <color name="white">#FFFFFFFF</color>
     <color name="preloadColor">#B9B5BD</color>
+    <color name="shimmer_placeholder">#dddddd</color>
+    <color name="colorPrimaryDark">#000000</color>
 </resources>