From c1eb6237172332a0a4bdef87f02c8966211aec26 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Thu, 29 Dec 2016 17:21:06 +0200 Subject: [PATCH] Progressbar & some layout changes --- app/build.gradle | 2 +- .../activities/main/forum/ForumFragment.java | 5 +++-- .../activities/main/recent/RecentFragment.java | 12 +++++++++--- .../mthmmy/activities/topic/TopicActivity.java | 5 +++-- app/src/main/res/layout/activity_topic.xml | 14 ++++++++------ app/src/main/res/layout/fragment_forum.xml | 13 ++++++++----- app/src/main/res/layout/fragment_recent.xml | 16 ++++++++-------- app/src/main/res/layout/fragment_recent_row.xml | 12 +++++------- 8 files changed, 45 insertions(+), 34 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 95cc0dd5..ee2e5129 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,8 +43,8 @@ dependencies { } compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3' - compile 'com.google.code.gson:gson:2.8.0' compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1' + compile 'me.zhanghai.android.materialprogressbar:library:1.3.0' } apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java index 382d9a2d..9b69b700 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java @@ -29,6 +29,7 @@ import gr.thmmy.mthmmy.data.Board; import gr.thmmy.mthmmy.data.Category; import gr.thmmy.mthmmy.data.TopicSummary; import gr.thmmy.mthmmy.session.SessionManager; +import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; import okhttp3.HttpUrl; import okhttp3.Request; @@ -49,7 +50,7 @@ public class ForumFragment extends BaseFragment private static final String TAG = "ForumFragment"; // Fragment initialization parameters, e.g. ARG_SECTION_NUMBER - private ProgressBar progressBar; + private MaterialProgressBar progressBar; private ForumAdapter forumAdapter; private List categories; @@ -99,7 +100,7 @@ public class ForumFragment extends BaseFragment // Set the adapter if (rootView instanceof RelativeLayout) { - progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar); + progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); forumAdapter = new ForumAdapter(getContext(), categories, fragmentInteractionListener); forumAdapter.setExpandCollapseListener(new ExpandableRecyclerAdapter.ExpandCollapseListener() { @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index bb3c6180..d0330849 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -3,6 +3,7 @@ package gr.thmmy.mthmmy.activities.main.recent; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; @@ -26,6 +27,7 @@ import gr.thmmy.mthmmy.activities.base.BaseFragment; import gr.thmmy.mthmmy.data.TopicSummary; import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.utils.CustomRecyclerView; +import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; import okhttp3.HttpUrl; import okhttp3.Request; @@ -43,7 +45,7 @@ public class RecentFragment extends BaseFragment { private static final String TAG = "RecentFragment"; // Fragment initialization parameters, e.g. ARG_SECTION_NUMBER - private ProgressBar progressBar; + private MaterialProgressBar progressBar; private SwipeRefreshLayout swipeRefreshLayout; private RecentAdapter recentAdapter; @@ -95,11 +97,15 @@ public class RecentFragment extends BaseFragment { // Set the adapter if (rootView instanceof RelativeLayout) { - progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar); + progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); recentAdapter = new RecentAdapter(getActivity(), topicSummaries, fragmentInteractionListener); CustomRecyclerView recyclerView = (CustomRecyclerView) rootView.findViewById(R.id.list); - recyclerView.setLayoutManager(new LinearLayoutManager(rootView.findViewById(R.id.list).getContext())); + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext()); + recyclerView.setLayoutManager(linearLayoutManager); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), + linearLayoutManager.getOrientation()); + recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.setAdapter(recentAdapter); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 9d7f8544..3fd701b2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -31,6 +31,7 @@ import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.activities.base.BaseActivity; import gr.thmmy.mthmmy.data.Post; +import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; import okhttp3.Request; import okhttp3.Response; @@ -87,7 +88,7 @@ public class TopicActivity extends BaseActivity { private ImageButton nextPage; private ImageButton lastPage; //Other variables - private ProgressBar progressBar; + private MaterialProgressBar progressBar; private String topicTitle; private FloatingActionButton replyFAB; private String parsedTitle; @@ -115,7 +116,7 @@ public class TopicActivity extends BaseActivity { createDrawer(); - progressBar = (ProgressBar) findViewById(R.id.progressBar); + progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); postsList = new ArrayList<>(); diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index 49c45d92..0ebb4ddb 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -89,17 +89,19 @@ android:contentDescription="@string/text_last" app:srcCompat="@drawable/page_last"/> + - + app:layout_anchorGravity="bottom|center" + app:mpb_indeterminateTint="@color/accent" + android:visibility="invisible" + android:indeterminate="true" + app:mpb_progressStyle="horizontal" + style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" /> - + android:layout_alignParentTop="true" + app:mpb_indeterminateTint="@color/accent" + android:visibility="invisible" + android:indeterminate="true" + app:mpb_progressStyle="horizontal" + style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_recent.xml b/app/src/main/res/layout/fragment_recent.xml index 911412c2..4ebe43bb 100644 --- a/app/src/main/res/layout/fragment_recent.xml +++ b/app/src/main/res/layout/fragment_recent.xml @@ -17,20 +17,20 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background" - android:clipToPadding="false" - android:paddingBottom="4dp" - android:paddingTop="4dp" app:layoutManager="LinearLayoutManager" tools:context=".activities.main.recent.RecentFragment" tools:listitem="@layout/fragment_recent_row"/> - + android:layout_alignParentTop="true" + app:mpb_indeterminateTint="@color/accent" + android:visibility="invisible" + android:indeterminate="true" + app:mpb_progressStyle="horizontal" + style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_recent_row.xml b/app/src/main/res/layout/fragment_recent_row.xml index e350e94d..cb4d23ca 100644 --- a/app/src/main/res/layout/fragment_recent_row.xml +++ b/app/src/main/res/layout/fragment_recent_row.xml @@ -1,10 +1,9 @@ + >