Bladeren bron

New look!

Infinite 3 jaren geleden
bovenliggende
commit
4378aef36b
31 gewijzigde bestanden met toevoegingen van 1464 en 199 verwijderingen
  1. BIN
      app/src/main/ic_launcher-playstore.png
  2. 4 2
      app/src/main/java/club/thepenguins/android/api/APIService.java
  3. 1221 179
      app/src/main/java/club/thepenguins/android/data/AuthorPosts.java
  4. 153 0
      app/src/main/java/club/thepenguins/android/fragments/AuthorPostFragment.java
  5. 5 6
      app/src/main/java/club/thepenguins/android/fragments/HomeFragment.java
  6. 14 1
      app/src/main/java/club/thepenguins/android/fragments/PostFragment.java
  7. 5 0
      app/src/main/res/layout/activity_main.xml
  8. 30 0
      app/src/main/res/layout/fragment_author_post.xml
  9. 2 2
      app/src/main/res/layout/nav_header.xml
  10. 5 3
      app/src/main/res/layout/toolbar.xml
  11. 2 2
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  12. 2 2
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  13. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  14. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
  15. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher_round.png
  16. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  17. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
  18. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  19. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  20. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
  21. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  22. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  23. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
  24. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  25. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  26. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
  27. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  28. 2 1
      app/src/main/res/values-night/themes.xml
  29. 4 0
      app/src/main/res/values/ic_launcher_background.xml
  30. 13 0
      app/src/main/res/values/styles.xml
  31. 2 1
      app/src/main/res/values/themes.xml

BIN
app/src/main/ic_launcher-playstore.png


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

@@ -2,7 +2,6 @@ package club.thepenguins.android.api;
 
 import java.util.List;
 
-import club.thepenguins.android.data.AuthorPosts;
 import club.thepenguins.android.data.Image;
 import club.thepenguins.android.data.IndividualPost;
 import club.thepenguins.android.data.Posts;
@@ -15,6 +14,9 @@ public interface APIService {
     @GET("wp-json/wp/v2/posts?_embed")
     Call<List<Posts>> getPosts();
 
+    @GET("wp-json/wp/v2/posts?_embed")
+    Call<List<Posts>> getPostsPerPage(@Query("per_page") String count);
+
     @GET(".")
     Call<Image> getFeaturedImageLink();
 
@@ -25,6 +27,6 @@ public interface APIService {
     Call<IndividualPost> getPostContent();
 
     @GET("wp-json/wp/v2/posts?_embed")
-    Call<AuthorPosts> getAuthorPosts(@Query("author") String id);
+    Call<List<Posts>> getAuthorPosts(@Query("author") String id);
 
 }

File diff suppressed because it is too large
+ 1221 - 179
app/src/main/java/club/thepenguins/android/data/AuthorPosts.java


+ 153 - 0
app/src/main/java/club/thepenguins/android/fragments/AuthorPostFragment.java

@@ -0,0 +1,153 @@
+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 androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import club.thepenguins.android.R;
+import club.thepenguins.android.adapters.PostRecyclerAdapter;
+import club.thepenguins.android.api.APIService;
+import club.thepenguins.android.data.Model;
+import club.thepenguins.android.data.Posts;
+import club.thepenguins.android.utils.Constants;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+
+public class AuthorPostFragment extends Fragment {
+
+
+    private static final String ARG_PARAM1 = "param1";
+    private static final String ARG_PARAM2 = "param2";
+    private String mParam1;
+    private String mParam2;
+    private RecyclerView recyclerView;
+    private LinearLayoutManager LayoutManager;
+    private ArrayList<Model> list;
+    private PostRecyclerAdapter adapter;
+    public static List<Posts> mListPost;
+    private SwipeRefreshLayout swipeContainer;
+
+
+    public static AuthorPostFragment newInstance(String param1, String param2) {
+        AuthorPostFragment fragment = new AuthorPostFragment();
+        Bundle args = new Bundle();
+        args.putString(ARG_PARAM1, param1);
+        args.putString(ARG_PARAM2, param2);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    public AuthorPostFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+            mParam1 = getArguments().getString(ARG_PARAM1);
+            mParam2 = getArguments().getString(ARG_PARAM2);
+        }
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+
+
+        View rootView = inflater.inflate(R.layout.fragment_author_post, container, false);
+
+        getActivity().setTitle("Choose Fragment");
+
+
+        recyclerView = rootView.findViewById(R.id.recycler_view_author);
+
+        LayoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
+        recyclerView.setLayoutManager(LayoutManager);
+
+        swipeContainer = rootView.findViewById(R.id.swiperefreshauthor);
+
+        list = new ArrayList<>();
+
+        getRetrofit(mParam1);
+
+
+        adapter = new PostRecyclerAdapter(list, rootView.getContext());
+
+        recyclerView.setAdapter(adapter);
+
+        swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+
+            @Override
+
+            public void onRefresh() {
+
+                adapter.clear();
+                getRetrofit(mParam1);
+            }
+
+        });
+
+
+        swipeContainer.setColorSchemeResources(android.R.color.holo_blue_bright,
+
+                android.R.color.holo_green_light,
+
+                android.R.color.holo_orange_light,
+
+                android.R.color.holo_red_light);
+
+        return rootView;
+    }
+
+    private void getRetrofit(String authorId) {
+
+        swipeContainer.setRefreshing(true);
+
+        Retrofit retrofit = new Retrofit.Builder()
+                .baseUrl(Constants.BaseUrl)
+                .addConverterFactory(GsonConverterFactory.create())
+                .build();
+
+        APIService service = retrofit.create(APIService.class);
+        Call<List<Posts>> call = service.getAuthorPosts(authorId);
+
+
+        call.enqueue(new Callback<List<Posts>>() {
+            @Override
+            public void onResponse(Call<List<Posts>> call, Response<List<Posts>> response) {
+
+              //  mListPost = response.body();
+                for (int i = 0; i < response.body().size(); i++) {
+
+                    list.add(new Model(response.body().get(i).getTitle().getRendered(), response.body().get(i).getContent().getRendered(), response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl(), response.body().get(i).getLinks().getSelf().get(0).getHref(), response.body().get(i).getEmbedded().getAuthor().get(0).getName()));
+                    //Log.d("Home", "onResponse: " + response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl());
+                }
+                adapter.notifyDataSetChanged();
+                swipeContainer.setRefreshing(false);
+
+            }
+
+            @Override
+            public void onFailure(Call<List<Posts>> call, Throwable t) {
+
+                Log.d("Home", "onFailure: ", t);
+            }
+        });
+    }
+}

+ 5 - 6
app/src/main/java/club/thepenguins/android/fragments/HomeFragment.java

@@ -84,7 +84,7 @@ public class HomeFragment extends Fragment {
 
         list = new ArrayList<>();
 
-        getRetrofit();
+        getRetrofit("100");
 
 
         adapter = new PostRecyclerAdapter(list, rootView.getContext());
@@ -98,7 +98,7 @@ public class HomeFragment extends Fragment {
             public void onRefresh() {
 
                 adapter.clear();
-                getRetrofit();
+                getRetrofit("100");
             }
 
         });
@@ -115,7 +115,7 @@ public class HomeFragment extends Fragment {
         return rootView;
     }
 
-    private void getRetrofit() {
+    private void getRetrofit(String perpage) {
 
         swipeContainer.setRefreshing(true);
 
@@ -125,7 +125,7 @@ public class HomeFragment extends Fragment {
                 .build();
 
         APIService service = retrofit.create(APIService.class);
-        Call<List<Posts>> call = service.getPosts();
+        Call<List<Posts>> call = service.getPostsPerPage(perpage);
 
 
         call.enqueue(new Callback<List<Posts>>() {
@@ -135,9 +135,8 @@ public class HomeFragment extends Fragment {
                 mListPost = response.body();
                 for (int i = 0; i < response.body().size(); i++) {
 
-                    list.add(new Model(response.body().get(i).getTitle().getRendered(), response.body().get(i).getContent().getRendered(), response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl(), response.body().get(i).getLinks().getSelf().get(0).getHref(), response.body().get(i).getEmbedded().getAuthor().get(0).getName()));
+                    list.add(new Model(response.body().get(i).getTitle().getRendered().replace("&#8211;","-"), response.body().get(i).getContent().getRendered(), response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl(), response.body().get(i).getLinks().getSelf().get(0).getHref(), response.body().get(i).getEmbedded().getAuthor().get(0).getName()));
 
-                    Log.d("Home", "onResponse: " + response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl());
                 }
                 adapter.notifyDataSetChanged();
                 swipeContainer.setRefreshing(false);

+ 14 - 1
app/src/main/java/club/thepenguins/android/fragments/PostFragment.java

@@ -2,7 +2,9 @@ package club.thepenguins.android.fragments;
 
 import android.os.Bundle;
 
+import androidx.appcompat.app.AppCompatActivity;
 import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
 
 import android.os.Handler;
 import android.util.Log;
@@ -89,6 +91,17 @@ public class PostFragment extends Fragment {
         textView.setText(mParam4);
         progressBar = rootView.findViewById(R.id.progress);
 
+        textView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+
+                getActivity().getSupportFragmentManager().beginTransaction()
+                        .replace( ((ViewGroup)getView().getParent()).getId(), AuthorPostFragment.newInstance(mParam4, null), "findThisFragment")
+                        .addToBackStack(null)
+                        .commit();
+            }
+        });
+
 
         Picasso.get()
                 .load(mParam2)
@@ -153,7 +166,7 @@ public class PostFragment extends Fragment {
                 myWebView.getSettings().getJavaScriptEnabled();
                 progressBar.setVisibility(View.GONE);
             }
-        }, 2000);
+        }, 3000);
 
 
         return rootView;

+ 5 - 0
app/src/main/res/layout/activity_main.xml

@@ -17,11 +17,16 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical">
+        <androidx.cardview.widget.CardView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            >
 
         <include
             layout="@layout/toolbar"
             android:layout_width="match_parent"
             android:layout_height="wrap_content" />
+        </androidx.cardview.widget.CardView>
 
         <FrameLayout
             android:id="@+id/flContent"

+ 30 - 0
app/src/main/res/layout/fragment_author_post.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".fragments.AuthorPostFragment">
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@color/purple_200">
+
+            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+                android:id="@+id/swiperefreshauthor"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+
+                <androidx.recyclerview.widget.RecyclerView
+                    android:id="@+id/recycler_view_author"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent">
+
+                </androidx.recyclerview.widget.RecyclerView>
+            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
+
+        </RelativeLayout>
+
+
+</FrameLayout>

+ 2 - 2
app/src/main/res/layout/nav_header.xml

@@ -4,7 +4,7 @@
 
     android:layout_height="192dp"
 
-    android:background="?attr/colorPrimaryDark"
+    android:background="@color/white"
 
     android:gravity="bottom"
 
@@ -25,7 +25,7 @@
         android:text="The Penguins Club"
         android:textAppearance="@style/TextAppearance.AppCompat.Body1"
 
-        android:textColor="@android:color/white"
+        android:textColor="@android:color/black"
 
         android:textSize="30sp" />
 

+ 5 - 3
app/src/main/res/layout/toolbar.xml

@@ -10,7 +10,7 @@
 
     android:layout_height="wrap_content"
 
-    android:background="?attr/colorPrimaryDark"
+    android:background="@color/white"
 
     android:fitsSystemWindows="true"
 
@@ -19,6 +19,8 @@
 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
 
+
+
     <TextView
         android:id="@+id/toolbar_title"
         android:layout_width="wrap_content"
@@ -26,7 +28,7 @@
         android:layout_gravity="center"
         android:fontFamily="@font/unifrakturcook"
         android:text="The Penguins Club"
-        android:textSize="20sp" />
-
+        android:textColor="@color/black"
+        android:textSize="25sp" />
 
 </androidx.appcompat.widget.Toolbar>

+ 2 - 2
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
-    <background android:drawable="@drawable/ic_launcher_background" />
-    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+    <background android:drawable="@color/ic_launcher_background"/>
+    <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
 </adaptive-icon>

+ 2 - 2
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
-    <background android:drawable="@drawable/ic_launcher_background" />
-    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+    <background android:drawable="@color/ic_launcher_background"/>
+    <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
 </adaptive-icon>

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png


BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png


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

@@ -10,7 +10,8 @@
         <item name="colorSecondaryVariant">@color/teal_200</item>
         <item name="colorOnSecondary">@color/black</item>
         <!-- Status bar color. -->
-        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
+        <item name="drawerArrowStyle">@style/DrawerIconNight</item>
+        <item name="android:statusBarColor" tools:targetApi="l">@color/black</item>
         <!-- Customize your theme here. -->
     </style>
 </resources>

+ 4 - 0
app/src/main/res/values/ic_launcher_background.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="ic_launcher_background">#FFFFFF</color>
+</resources>

+ 13 - 0
app/src/main/res/values/styles.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
+        <item name="colorControlNormal">@color/black</item>
+    </style>
+
+    <style name="DrawerIconDay" parent="Widget.AppCompat.DrawerArrowToggle">
+        <item name="color">@color/black</item>
+    </style>
+    <style name="DrawerIconNight" parent="Widget.AppCompat.DrawerArrowToggle">
+        <item name="color">@color/white</item>
+    </style>
+</resources>

+ 2 - 1
app/src/main/res/values/themes.xml

@@ -9,8 +9,9 @@
         <item name="colorSecondary">@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="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
+        <item name="android:statusBarColor" tools:targetApi="l">@color/black</item>
         <!-- Customize your theme here. -->
     </style>
 </resources>

Some files were not shown because too many files changed in this diff