Jelajahi Sumber

Dynamically load categories

Infinite 3 tahun lalu
induk
melakukan
5600642c62

+ 80 - 43
app/src/main/java/club/thepenguins/android/activities/MainActivity.java

@@ -5,25 +5,41 @@ import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.Toolbar;
 import androidx.core.view.GravityCompat;
 import androidx.drawerlayout.widget.DrawerLayout;
-import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
 
+import android.content.Context;
 import android.content.res.Configuration;
 import android.os.Bundle;
 import android.util.Log;
+import android.view.Menu;
 import android.view.MenuItem;
+import android.widget.Toast;
 
 
 import com.google.android.material.navigation.NavigationView;
 import com.google.firebase.messaging.FirebaseMessaging;
 
 
+import java.util.ArrayList;
+import java.util.List;
+
 import club.thepenguins.android.R;
 
+import club.thepenguins.android.api.APIService;
+import club.thepenguins.android.data.Category;
+import club.thepenguins.android.data.CategoryModel;
 import club.thepenguins.android.fragments.AboutFragment;
 import club.thepenguins.android.fragments.HomeFragment;
 import club.thepenguins.android.fragments.LinuxFragment;
-import club.thepenguins.android.fragments.NixFragment;
+import club.thepenguins.android.utils.Constants;
+import es.dmoral.toasty.Toasty;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+import static club.thepenguins.android.utils.Constants.noInternet;
 
 public class MainActivity extends AppCompatActivity {
 
@@ -31,9 +47,11 @@ public class MainActivity extends AppCompatActivity {
     private DrawerLayout mDrawer;
     private Toolbar toolbar;
 
-    private NavigationView nvDrawer;
+    private NavigationView nvView;
     private ActionBarDrawerToggle drawerToggle;
     private static String TAG = "MainActivity";
+    private List<Category> categories;
+    private ArrayList<CategoryModel> list;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -42,7 +60,6 @@ public class MainActivity extends AppCompatActivity {
 
 
         toolbar = findViewById(R.id.toolbar);
-
         setSupportActionBar(toolbar);
         getSupportActionBar().setDisplayShowTitleEnabled(false);
 
@@ -51,9 +68,9 @@ public class MainActivity extends AppCompatActivity {
 
         mDrawer = findViewById(R.id.drawer_layout);
 
-        nvDrawer = findViewById(R.id.nvView);
+        nvView = findViewById(R.id.nvView);
 
-        setupDrawerContent(nvDrawer);
+        setupDrawerContent(nvView);
 
 
         mDrawer = findViewById(R.id.drawer_layout);
@@ -66,6 +83,16 @@ public class MainActivity extends AppCompatActivity {
 
         mDrawer.addDrawerListener(drawerToggle);
 
+
+        Menu menu = nvView.getMenu();
+
+        categories = new ArrayList<>();
+        list = new ArrayList<>();
+
+        getCategories(MainActivity.this, menu);
+
+        menu.add(0, 707, 5, "About Us");
+
         FCM();
 
 
@@ -114,6 +141,9 @@ public class MainActivity extends AppCompatActivity {
 
                 return true;
 
+            default:
+                mDrawer.openDrawer(GravityCompat.START);
+
         }
 
         return super.onOptionsItemSelected(item);
@@ -143,72 +173,79 @@ public class MainActivity extends AppCompatActivity {
 
     public void selectDrawerItem(MenuItem menuItem) {
 
-        Fragment fragment = null;
-
-        Class fragmentClass = null;
-
-        switch (menuItem.getItemId()) {
 
-            case R.id.nav_first_fragment:
+        FragmentManager fragmentManager = getSupportFragmentManager();
 
-                fragmentClass = HomeFragment.class;
+        if (menuItem.getItemId() == R.id.home) {
 
-                break;
+            fragmentManager.beginTransaction().replace(R.id.flContent, HomeFragment.newInstance("null", "null")).commit();
 
-            case R.id.aboutfrag:
+        } else if (menuItem.getItemId() == 707) {
 
-                fragmentClass = AboutFragment.class;
+            fragmentManager.beginTransaction().replace(R.id.flContent, AboutFragment.newInstance("null", "null")).commit();
 
-                break;
+        } else {
 
-            case R.id.linuxfrag:
+            fragmentManager.beginTransaction().replace(R.id.flContent, LinuxFragment.newInstance(String.valueOf(menuItem.getItemId()), null)).commit();
 
-                fragmentClass = LinuxFragment.class;
+        }
 
-                break;
-            case R.id.nixfrag:
+        menuItem.setChecked(false);
 
-                fragmentClass = NixFragment.class;
+        mDrawer.closeDrawers();
 
-                break;
+    }
 
-            default:
+    private void FCM() {
 
-                fragmentClass = HomeFragment.class;
+        FirebaseMessaging.getInstance().subscribeToTopic("NewPost").addOnCompleteListener(task -> {
+            if (task.isSuccessful()) {
+                Log.d(TAG, "Successfully Subscribed to Notification Service");
 
-        }
+            } else {
+                Log.d(TAG, "Subscription to Notification Service failed");
+            }
+        });
 
+    }
 
-        try {
+    private void getCategories(Context context, Menu menu1) {
 
-            fragment = (Fragment) fragmentClass.newInstance();
 
-        } catch (Exception e) {
+        Retrofit retrofit = new Retrofit.Builder()
+                .baseUrl(Constants.BaseUrl)
+                .addConverterFactory(GsonConverterFactory.create())
+                .build();
 
-            e.printStackTrace();
+        APIService service = retrofit.create(APIService.class);
+        Call<List<Category>> call = service.getCategories();
 
-        }
 
+        call.enqueue(new Callback<List<Category>>() {
+            @Override
+            public void onResponse(Call<List<Category>> call, Response<List<Category>> response) {
 
-        FragmentManager fragmentManager = getSupportFragmentManager();
+                categories = response.body();
+                for (int i = 0; i < response.body().size(); i++) {
 
-        fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
+                    list.add(new CategoryModel(response.body().get(i).getName(), response.body().get(i).getId()));
+                    System.out.println(response.body().get(i).getName());
 
-        menuItem.setChecked(true);
+                }
 
-        setTitle(menuItem.getTitle());
-        mDrawer.closeDrawers();
+                Menu submenu = menu1.addSubMenu("Categories");
+                for (int i = 0; i < list.size(); i++) {
+                    submenu.add(i, list.get(i).getId(), i, list.get(i).getCatName());
+                    System.out.println(list.get(i));
+                }
 
-    }
 
-    private void FCM() {
+            }
 
-        FirebaseMessaging.getInstance().subscribeToTopic("NewPost").addOnCompleteListener(task -> {
-            if (task.isSuccessful()) {
-                Log.d(TAG, "Successfully Subscribed to Notification Service");
+            @Override
+            public void onFailure(Call<List<Category>> call, Throwable t) {
 
-            } else {
-                Log.d(TAG, "Subscription to Notification Service failed");
+                Toasty.error(context, noInternet, Toast.LENGTH_SHORT, true).show();
             }
         });
 

+ 3 - 1
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.Category;
 import club.thepenguins.android.data.Comments;
 import club.thepenguins.android.data.Image;
 import club.thepenguins.android.data.IndividualPost;
@@ -33,6 +34,7 @@ public interface APIService {
     @GET("wp-json/wp/v2/comments")
     Call<List<Comments>> getPostComments(@Query("post") String id);
 
-    //@GET("wp-json/wp/v2/categories")
+    @GET("wp-json/wp/v2/categories")
+    Call<List<Category>> getCategories();
 
 }

+ 29 - 0
app/src/main/java/club/thepenguins/android/data/CategoryModel.java

@@ -0,0 +1,29 @@
+package club.thepenguins.android.data;
+
+public class CategoryModel {
+
+    private String catName;
+    private int id;
+
+
+    public CategoryModel(String catName, int id) {
+        this.catName = catName;
+        this.id = id;
+    }
+
+    public String getCatName() {
+        return catName;
+    }
+
+    public void setCatName(String catName) {
+        this.catName = catName;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+}

+ 0 - 66
app/src/main/java/club/thepenguins/android/fragments/HardwareFragment.java

@@ -1,66 +0,0 @@
-package club.thepenguins.android.fragments;
-
-import android.os.Bundle;
-
-import androidx.fragment.app.Fragment;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import club.thepenguins.android.R;
-
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link HardwareFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class HardwareFragment extends Fragment {
-
-    // TODO: Rename parameter arguments, choose names that match
-    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
-    private static final String ARG_PARAM1 = "param1";
-    private static final String ARG_PARAM2 = "param2";
-
-    // TODO: Rename and change types of parameters
-    private String mParam1;
-    private String mParam2;
-
-    public HardwareFragment() {
-        // Required empty public constructor
-    }
-
-    /**
-     * Use this factory method to create a new instance of
-     * this fragment using the provided parameters.
-     *
-     * @param param1 Parameter 1.
-     * @param param2 Parameter 2.
-     * @return A new instance of fragment HardwareFragment.
-     */
-    // TODO: Rename and change types and number of parameters
-    public static HardwareFragment newInstance(String param1, String param2) {
-        HardwareFragment fragment = new HardwareFragment();
-        Bundle args = new Bundle();
-        args.putString(ARG_PARAM1, param1);
-        args.putString(ARG_PARAM2, param2);
-        fragment.setArguments(args);
-        return fragment;
-    }
-
-    @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) {
-        // Inflate the layout for this fragment
-        return inflater.inflate(R.layout.fragment_hardware, container, false);
-    }
-}

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

@@ -47,7 +47,7 @@ public class HomeFragment extends Fragment {
     private LinearLayoutManager LayoutManager;
     private ArrayList<Model> list;
     private PostRecyclerAdapter adapter;
-    public static List<Posts> mListPost;
+    public List<Posts> mListPost;
     private SwipeRefreshLayout swipeContainer;
     private ShimmerFrameLayout loader;
 

+ 19 - 5
app/src/main/java/club/thepenguins/android/fragments/LinuxFragment.java

@@ -1,5 +1,6 @@
 package club.thepenguins.android.fragments;
 
+import android.content.Context;
 import android.os.Bundle;
 
 import androidx.fragment.app.Fragment;
@@ -11,6 +12,8 @@ import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.TextView;
+import android.widget.Toast;
 
 import com.facebook.shimmer.ShimmerFrameLayout;
 
@@ -25,12 +28,15 @@ 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 es.dmoral.toasty.Toasty;
 import retrofit2.Call;
 import retrofit2.Callback;
 import retrofit2.Response;
 import retrofit2.Retrofit;
 import retrofit2.converter.gson.GsonConverterFactory;
 
+import static club.thepenguins.android.utils.Constants.noInternet;
+
 
 public class LinuxFragment extends Fragment {
 
@@ -47,6 +53,7 @@ public class LinuxFragment extends Fragment {
     public static List<Posts> mListPost;
     private SwipeRefreshLayout swipeContainer;
     private ShimmerFrameLayout loader;
+    private TextView textView;
 
 
     public LinuxFragment() {
@@ -82,6 +89,8 @@ public class LinuxFragment extends Fragment {
         recyclerView = rootView.findViewById(R.id.recycler_view);
         loader = rootView.findViewById(R.id.shimmer_view_container);
 
+        textView = rootView.findViewById(R.id.noPost);
+
 
         LayoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
         recyclerView.setLayoutManager(LayoutManager);
@@ -90,7 +99,7 @@ public class LinuxFragment extends Fragment {
 
         list = new ArrayList<>();
 
-        getRetrofit();
+        getRetrofit(rootView.getContext(), mParam1);
 
 
         adapter = new PostRecyclerAdapter(list, rootView.getContext());
@@ -104,7 +113,8 @@ public class LinuxFragment extends Fragment {
             public void onRefresh() {
 
                 adapter.clear();
-                getRetrofit();
+                getRetrofit(rootView.getContext(), mParam1);
+                textView.setVisibility(View.GONE);
             }
 
         });
@@ -121,7 +131,7 @@ public class LinuxFragment extends Fragment {
         return rootView;
     }
 
-    private void getRetrofit() {
+    private void getRetrofit(Context context, String id) {
 
         swipeContainer.setRefreshing(true);
         loader.setVisibility(View.VISIBLE);
@@ -133,7 +143,7 @@ public class LinuxFragment extends Fragment {
                 .build();
 
         APIService service = retrofit.create(APIService.class);
-        Call<List<Posts>> call = service.getCategoryPosts("4");
+        Call<List<Posts>> call = service.getCategoryPosts(id);
 
 
         call.enqueue(new Callback<List<Posts>>() {
@@ -150,12 +160,16 @@ public class LinuxFragment extends Fragment {
                 swipeContainer.setRefreshing(false);
                 loader.setVisibility(View.GONE);
 
+                if (list.size() == 0) {
+                    textView.setVisibility(View.VISIBLE);
+                }
+
             }
 
             @Override
             public void onFailure(Call<List<Posts>> call, Throwable t) {
 
-                Log.d("Linux", "onFailure: ", t);
+                Toasty.error(context, noInternet, Toast.LENGTH_LONG, true).show();
             }
         });
     }

+ 0 - 166
app/src/main/java/club/thepenguins/android/fragments/NewsFragment.java

@@ -1,166 +0,0 @@
-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 com.facebook.shimmer.ShimmerFrameLayout;
-
-import org.jsoup.parser.Parser;
-
-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;
-
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link NewsFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class NewsFragment 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;
-    private ShimmerFrameLayout loader;
-
-
-    public NewsFragment() {
-        // Required empty public constructor
-    }
-
-    public static NewsFragment newInstance(String param1, String param2) {
-        NewsFragment fragment = new NewsFragment();
-        Bundle args = new Bundle();
-        args.putString(ARG_PARAM1, param1);
-        args.putString(ARG_PARAM2, param2);
-        fragment.setArguments(args);
-        return fragment;
-    }
-
-    @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_news, container, false);
-
-        getActivity().setTitle("Choose Fragment");
-
-
-        recyclerView = rootView.findViewById(R.id.recycler_view);
-        loader = rootView.findViewById(R.id.shimmer_view_container);
-
-
-        LayoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
-        recyclerView.setLayoutManager(LayoutManager);
-
-        swipeContainer = rootView.findViewById(R.id.swiperefresh);
-
-        list = new ArrayList<>();
-
-        getRetrofit();
-
-
-        adapter = new PostRecyclerAdapter(list, rootView.getContext());
-
-        recyclerView.setAdapter(adapter);
-
-        swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-
-            @Override
-
-            public void onRefresh() {
-
-                adapter.clear();
-                getRetrofit();
-            }
-
-        });
-
-
-        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() {
-
-        swipeContainer.setRefreshing(true);
-        loader.setVisibility(View.VISIBLE);
-        loader.startShimmer();
-
-        Retrofit retrofit = new Retrofit.Builder()
-                .baseUrl(Constants.BaseUrl)
-                .addConverterFactory(GsonConverterFactory.create())
-                .build();
-
-        APIService service = retrofit.create(APIService.class);
-        Call<List<Posts>> call = service.getCategoryPosts("4");
-
-
-        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(Parser.unescapeEntities(response.body().get(i).getTitle().getRendered(), false), 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(), response.body().get(i).getLink()));
-                    //Log.d("Linux", "onResponse: " + response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl());
-                }
-                adapter.notifyDataSetChanged();
-                swipeContainer.setRefreshing(false);
-                loader.setVisibility(View.GONE);
-
-            }
-
-            @Override
-            public void onFailure(Call<List<Posts>> call, Throwable t) {
-
-                Log.d("Linux", "onFailure: ", t);
-            }
-        });
-    }
-}

+ 0 - 169
app/src/main/java/club/thepenguins/android/fragments/NixFragment.java

@@ -1,169 +0,0 @@
-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 org.jsoup.parser.Parser;
-
-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;
-
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link NixFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class NixFragment extends Fragment {
-
-    // TODO: Rename parameter arguments, choose names that match
-    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
-    private static final String ARG_PARAM1 = "param1";
-    private static final String ARG_PARAM2 = "param2";
-
-    // TODO: Rename and change types of parameters
-    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 NixFragment() {
-        // Required empty public constructor
-    }
-
-    /**
-     * Use this factory method to create a new instance of
-     * this fragment using the provided parameters.
-     *
-     * @param param1 Parameter 1.
-     * @param param2 Parameter 2.
-     * @return A new instance of fragment NixFragment.
-     */
-    // TODO: Rename and change types and number of parameters
-    public static NixFragment newInstance(String param1, String param2) {
-        NixFragment fragment = new NixFragment();
-        Bundle args = new Bundle();
-        args.putString(ARG_PARAM1, param1);
-        args.putString(ARG_PARAM2, param2);
-        fragment.setArguments(args);
-        return fragment;
-    }
-
-    @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_linux, container, false);
-
-        getActivity().setTitle("Choose Fragment");
-
-
-        recyclerView = rootView.findViewById(R.id.recycler_view);
-
-        LayoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
-        recyclerView.setLayoutManager(LayoutManager);
-
-        swipeContainer = rootView.findViewById(R.id.swiperefresh);
-
-        list = new ArrayList<>();
-
-        getRetrofit();
-
-
-        adapter = new PostRecyclerAdapter(list, rootView.getContext());
-
-        recyclerView.setAdapter(adapter);
-
-        swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-
-            @Override
-
-            public void onRefresh() {
-
-                adapter.clear();
-                getRetrofit();
-            }
-
-        });
-
-
-        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() {
-
-        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.getCategoryPosts("12");
-
-
-        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(Parser.unescapeEntities(response.body().get(i).getTitle().getRendered(), false), 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(), response.body().get(i).getLink()));
-
-                    //Log.d("Linux", "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("Linux", "onFailure: ", t);
-            }
-        });
-    }
-}

+ 0 - 66
app/src/main/java/club/thepenguins/android/fragments/TechFragment.java

@@ -1,66 +0,0 @@
-package club.thepenguins.android.fragments;
-
-import android.os.Bundle;
-
-import androidx.fragment.app.Fragment;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import club.thepenguins.android.R;
-
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link TechFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class TechFragment extends Fragment {
-
-    // TODO: Rename parameter arguments, choose names that match
-    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
-    private static final String ARG_PARAM1 = "param1";
-    private static final String ARG_PARAM2 = "param2";
-
-    // TODO: Rename and change types of parameters
-    private String mParam1;
-    private String mParam2;
-
-    public TechFragment() {
-        // Required empty public constructor
-    }
-
-    /**
-     * Use this factory method to create a new instance of
-     * this fragment using the provided parameters.
-     *
-     * @param param1 Parameter 1.
-     * @param param2 Parameter 2.
-     * @return A new instance of fragment TechFragment.
-     */
-    // TODO: Rename and change types and number of parameters
-    public static TechFragment newInstance(String param1, String param2) {
-        TechFragment fragment = new TechFragment();
-        Bundle args = new Bundle();
-        args.putString(ARG_PARAM1, param1);
-        args.putString(ARG_PARAM2, param2);
-        fragment.setArguments(args);
-        return fragment;
-    }
-
-    @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) {
-        // Inflate the layout for this fragment
-        return inflater.inflate(R.layout.fragment_tech, container, false);
-    }
-}

+ 4 - 5
app/src/main/res/drawable/ic_baseline_share_24.xml

@@ -2,9 +2,8 @@
     android:width="24dp"
     android:height="24dp"
     android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?attr/colorControlNormal">
-  <path
-      android:fillColor="@color/textColor"
-      android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
+    android:viewportHeight="24">
+    <path
+        android:fillColor="@color/textColor"
+        android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
 </vector>

+ 3 - 1
app/src/main/res/layout/fragment_about.xml

@@ -9,6 +9,8 @@
     <Button
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="About Us" />
+        android:layout_gravity="center"
+        android:text="About Us"
+        />
 
 </FrameLayout>

+ 0 - 14
app/src/main/res/layout/fragment_hardware.xml

@@ -1,14 +0,0 @@
-<?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.HardwareFragment">
-
-    <!-- TODO: Update blank fragment layout -->
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:text="@string/hello_blank_fragment" />
-
-</FrameLayout>

+ 10 - 0
app/src/main/res/layout/fragment_linux.xml

@@ -57,5 +57,15 @@
 
     </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
+    <TextView
+        android:id="@+id/noPost"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:padding="10dp"
+        android:text="@string/noPosts"
+        android:textColor="@color/textColor"
+        android:textSize="25sp"
+        android:visibility="gone" />
+
 
 </FrameLayout>

+ 0 - 14
app/src/main/res/layout/fragment_news.xml

@@ -1,14 +0,0 @@
-<?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.NewsFragment">
-
-    <!-- TODO: Update blank fragment layout -->
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:text="@string/hello_blank_fragment" />
-
-</FrameLayout>

+ 0 - 28
app/src/main/res/layout/fragment_nix.xml

@@ -1,28 +0,0 @@
-<?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.NixFragment">
-
-    <RelativeLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-
-        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
-            android:id="@+id/swiperefresh"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
-
-
-            <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/recycler_view"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent">
-
-            </androidx.recyclerview.widget.RecyclerView>
-        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
-
-    </RelativeLayout>
-
-</FrameLayout>

+ 0 - 14
app/src/main/res/layout/fragment_tech.xml

@@ -1,14 +0,0 @@
-<?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.TechFragment">
-
-    <!-- TODO: Update blank fragment layout -->
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:text="@string/hello_blank_fragment" />
-
-</FrameLayout>

+ 1 - 26
app/src/main/res/menu/drawer_view.xml

@@ -1,32 +1,7 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
     <group>
         <item
-            android:id="@+id/nav_first_fragment"
+            android:id="@+id/home"
             android:title="Home" />
     </group>
-    <item android:title="Categories">
-        <menu>
-            <group>
-                <item
-                    android:id="@+id/linuxfrag"
-                    android:title="Linux" />
-                <item
-                    android:id="@+id/nixfrag"
-                    android:title="Nix" />
-                <item android:title="News" />
-                <item android:title="Hardware" />
-                <item android:title="Technology" />
-            </group>
-        </menu>
-    </item>
-    <item android:title="Sub items">
-        <menu>
-            <group>
-                <item
-                    android:id="@+id/aboutfrag"
-                    android:title="About Us" />
-                <item android:title="Sub item 2" />
-            </group>
-        </menu>
-    </item>
 </menu>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -4,4 +4,5 @@
     <string name="drawer_close">Close navigation drawer</string>
     <string name="name">The Penguins Club</string>
     <string name="hello_blank_fragment">Hello</string>
+    <string name="noPosts">No posts in this category yet!</string>
 </resources>