Skip to content

Commit

Permalink
Merge pull request #147 from intkhabahmed/feature_home_screen_filter_…
Browse files Browse the repository at this point in the history
…handler

Feature home screen filter empty list handler
  • Loading branch information
drulabs authored May 18, 2018
2 parents 2410cc5 + 7959931 commit 0dd50c8
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
Expand Down Expand Up @@ -82,6 +83,10 @@ public class HomeActivity extends AppCompatActivity implements HomeContract.View
private LottieAnimationView progressBar;
// Reference of the quiz filter list layout
private RadioGroup mRGHomeQuizListFilter;
//Empty View elements
private ImageView mIVEmptyFilterResult;
private TextView mTVEmptyFilterResult;
private LinearLayout mLLEmptyFilterResultContainer;
//////////////
boolean mTwiceClicked = false;
Snackbar mSnackbar;
Expand Down Expand Up @@ -134,6 +139,11 @@ private void initializeUI() {
mQuizAdapter = new QuizAdapter(this);
mQuizRecyclerView.setAdapter(mQuizAdapter);

mIVEmptyFilterResult = findViewById(R.id.iv_empty_filter_result);
mTVEmptyFilterResult = findViewById(R.id.tv_empty_filter_result);
mLLEmptyFilterResultContainer = findViewById(R.id.ll_empty_filter_result_container);


initQuizFilter();
mDrawerLayout = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
Expand Down Expand Up @@ -202,6 +212,9 @@ public boolean onOptionsItemSelected(MenuItem item) {

@Override
public void loadQuizzes(List<Quiz> quizzes) {
if(!quizzes.isEmpty()) {
mLLEmptyFilterResultContainer.setVisibility(View.GONE);
}
mQuizRecyclerView.setVisibility(View.VISIBLE);
mEmptyStateTextView.setVisibility(View.GONE);
mQuizAdapter.loadQuizzes(quizzes);
Expand Down Expand Up @@ -287,6 +300,27 @@ public void navigateToEditProfile() {
Toast.makeText(getApplicationContext(), DEMO_TOAST_MSG, Toast.LENGTH_SHORT).show();
}

@Override
public void handleEmptyView(String selectedFilter) {
mLLEmptyFilterResultContainer.setVisibility(View.VISIBLE);
switch (selectedFilter) {
case HomeContract.ATTEMPTED_QUIZZES:
mIVEmptyFilterResult.setImageResource(R.drawable.ic_frown_face);
mTVEmptyFilterResult.setText(R.string.no_attempted_quizzes);
break;
case HomeContract.BOOKMARKED_QUIZZES:
mIVEmptyFilterResult.setImageResource(R.drawable.ic_bookmark_warning);
mTVEmptyFilterResult.setText(R.string.no_bookmarked_quizzes);
break;
case HomeContract.UNATTEMPTED_QUIZZES:
mIVEmptyFilterResult.setImageResource(R.drawable.ic_fireworks);
mTVEmptyFilterResult.setText(R.string.no_un_attempted_quizzes);
break;
default:
throw new UnsupportedOperationException();
}
}

@Override
public void setPresenter(HomeContract.Presenter presenter) {
this.mPresenter = presenter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public interface HomeContract {
int NAVIGATION_SETTINGS = 4;
int NAVIGATION_ABOUT = 5;
int NAVIGATION_EDIT_PROFILE = 6;
String BOOKMARKED_QUIZZES = "bookmarked-quizzes";
String ATTEMPTED_QUIZZES = "attempted-quizzes";
String UNATTEMPTED_QUIZZES = "un-attempted-quizzes";

/**
* Home View
Expand Down Expand Up @@ -50,6 +53,8 @@ interface View extends BaseView<Presenter> {
void navigateToAboutScreen();

void navigateToEditProfile();

void handleEmptyView(String selectedFilter);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public void onAttemptedQuizSelected() {
attemptedQuizzes.add(quiz);
}
}
if(attemptedQuizzes.isEmpty()) {
mView.handleEmptyView(HomeContract.ATTEMPTED_QUIZZES);
}
mView.loadQuizzes(attemptedQuizzes);
}

Expand All @@ -128,6 +131,9 @@ public void onUnAttemptedQuizSelected() {
unAttemptedQuizzes.add(quiz);
}
}
if(unAttemptedQuizzes.isEmpty()) {
mView.handleEmptyView(HomeContract.UNATTEMPTED_QUIZZES);
}
mView.loadQuizzes(unAttemptedQuizzes);
}

Expand All @@ -139,6 +145,9 @@ public void onBookmarkSelected() {
bookmarkedQuizzes.add(quiz);
}
}
if(bookmarkedQuizzes.isEmpty()) {
mView.handleEmptyView(HomeContract.BOOKMARKED_QUIZZES);
}
mView.loadQuizzes(bookmarkedQuizzes);
}

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/ic_bookmark_warning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector android:height="24dp" android:viewportHeight="55"
android:viewportWidth="55" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#D75A4A" android:pathData="M22.5,0h-16v53.444c0,0.495 0.598,0.742 0.948,0.393L22.5,38.784l15.052,15.052c0.35,0.35 0.948,0.102 0.948,-0.393V0H22.5z"/>
<path android:fillColor="#C03B2B" android:pathData="M6.5,0h32v11h-32z"/>
<path android:fillColor="#EFC41A" android:pathData="M47.261,55H23.57c-0.955,0 -1.55,-1.036 -1.069,-1.861l11.845,-20.306c0.478,-0.819 1.66,-0.819 2.138,0L48.33,53.139C48.811,53.964 48.216,55 47.261,55z"/>
<path android:fillColor="#FFFFFF" android:pathData="M35.5,48c-0.552,0 -1,-0.448 -1,-1v-8c0,-0.552 0.448,-1 1,-1s1,0.448 1,1v8C36.5,47.552 36.052,48 35.5,48z"/>
<path android:fillColor="#FFFFFF" android:pathData="M35.5,52c-0.26,0 -0.52,-0.11 -0.71,-0.29c-0.18,-0.19 -0.29,-0.45 -0.29,-0.71c0,-0.26 0.11,-0.52 0.29,-0.71c0.38,-0.37 1.04,-0.37 1.42,0c0.18,0.19 0.29,0.45 0.29,0.71c0,0.26 -0.11,0.52 -0.29,0.71C36.02,51.89 35.77,52 35.5,52z"/>
</vector>
17 changes: 17 additions & 0 deletions app/src/main/res/drawable/ic_fireworks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector android:height="24dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#6EDCF9" android:pathData="M324.06,163.74m-14.723,0a14.723,14.723 0,1 1,29.446 0a14.723,14.723 0,1 1,-29.446 0"/>
<path android:fillColor="#8DD83D" android:pathData="M64.858,330.19m-12.409,0a12.409,12.409 0,1 1,24.818 0a12.409,12.409 0,1 1,-24.818 0"/>
<path android:fillColor="#FFA92C" android:pathData="M283.371,35.882l-31.642,-4.597l-14.15,-28.672c-0.79,-1.6 -2.42,-2.613 -4.203,-2.613s-3.413,1.012 -4.203,2.613l-14.15,28.672l-31.643,4.597c-3.834,0.557 -5.374,5.287 -2.597,7.994l22.896,22.319l-5.406,31.515c-0.654,3.819 3.369,6.748 6.8,4.94l28.302,-14.878c30.83,16.207 28.892,15.418 30.482,15.418c0.972,0 1.939,-0.302 2.756,-0.896c1.442,-1.049 2.166,-2.825 1.865,-4.583l-5.406,-31.515l22.895,-22.319C288.743,41.174 287.211,36.441 283.371,35.882z"/>
<path android:fillColor="#FF8828" android:pathData="M230.989,74.463l-22.896,-22.319c-2.774,-2.704 -1.241,-7.436 2.597,-7.994l31.643,-4.597l6.738,-13.653L237.578,2.613c-0.79,-1.6 -2.42,-2.613 -4.203,-2.613s-3.413,1.012 -4.203,2.613l-14.15,28.672l-31.643,4.597c-3.834,0.557 -5.374,5.287 -2.597,7.994l22.896,22.319l-5.406,31.515c-0.654,3.819 3.369,6.748 6.8,4.94l23.17,-12.18L230.989,74.463z"/>
<path android:fillColor="#FFA92C" android:pathData="M462.783,186.955l-19.044,-18.895l4.769,-26.399c0.577,-3.2 -2.774,-5.684 -5.669,-4.196l-23.854,12.272l-23.633,-12.693c-2.864,-1.536 -6.263,0.882 -5.742,4.095l4.301,26.479l-19.376,18.554c-2.348,2.25 -1.095,6.232 2.121,6.726l26.513,4.093l11.66,24.16c0.281,0.585 0.696,1.079 1.2,1.451c1.959,1.451 4.755,0.784 5.853,-1.389l12.084,-23.949l26.581,-3.624C463.767,193.205 465.092,189.247 462.783,186.955z"/>
<path android:fillColor="#FF8828" android:pathData="M407.823,186.428l-4.301,-26.479c-0.52,-3.209 2.873,-5.633 5.742,-4.095l23.633,12.693l11.855,-6.099l3.755,-20.785c0.577,-3.2 -2.774,-5.684 -5.669,-4.196l-23.854,12.272l-23.633,-12.693c-2.864,-1.536 -6.263,0.882 -5.742,4.095l4.301,26.479l-19.376,18.554c-2.348,2.25 -1.095,6.232 2.121,6.726l21.021,3.246L407.823,186.428z"/>
<path android:fillColor="#E8C018" android:pathData="M190.979,471.648c0,0 -15.56,-129.494 -60.323,-202.221c-6.042,-9.162 -15.583,-13.818 -27.955,-7.26l-0.011,0.006c-13.295,7.054 -6.003,21.193 -6.003,21.193l-0.001,0.001C117.213,308.865 162.831,373.247 190.979,471.648z"/>
<path android:fillColor="#F2D422" android:pathData="M439.159,378.272l0.002,-0.001c1.567,-0.954 3.08,-1.861 4.541,-2.723c5.574,-4.007 13.392,-12.324 5.672,-24.241c-9.052,-13.973 -24.74,-4.34 -27.217,-2.691C340.899,407.026 295.899,512 295.899,512C347.018,441.218 405.167,398.975 439.159,378.272L439.159,378.272z"/>
<path android:fillColor="#E8C018" android:pathData="M75.167,385.301c-2.792,-2.014 -17.195,-11.517 -24.774,0.702c-4.678,7.544 -2.106,14.247 5.599,18.878c0.001,0.001 0.008,0.005 0.008,0.005l0,0C82.829,421.053 129.898,454.809 171.203,512C171.203,511.999 137.028,432.277 75.167,385.301z"/>
<path android:fillColor="#EA473B" android:pathData="M149.305,196.146c0.617,-1.841 0.146,-1.695 -11.912,-13.658c3.052,-16.894 3.476,-16.873 1.928,-18.02c-1.559,-1.154 -1.559,-0.665 -16.671,7.109c-15.117,-8.118 -14.973,-8.521 -16.543,-7.402c-1.579,1.131 -1.113,1.282 1.609,18.051l-11.538,11.05c-1.399,1.338 -0.654,3.71 1.263,4.006l15.789,2.438c7.457,15.453 7.098,15.693 9.031,15.712c1.942,0.015 1.654,-0.379 9.309,-15.55l15.829,-2.157C148.283,197.603 149.022,196.992 149.305,196.146z"/>
<path android:fillColor="#D63322" android:pathData="M128.948,195.338c-16.958,-2.618 -17.087,-2.209 -17.666,-4.048c-0.582,-1.852 -0.121,-1.691 12.152,-13.445l-1.041,-6.408c-14.812,-7.954 -14.716,-8.383 -16.285,-7.264c-1.579,1.131 -1.113,1.282 1.609,18.051c-12.392,11.868 -12.73,11.606 -12.152,13.445c0.583,1.851 0.872,1.455 17.666,4.048c7.229,14.981 6.902,14.693 7.657,15.254c1.17,0.863 2.834,0.464 3.485,-0.827l6.977,-13.827L128.948,195.338z"/>
<path android:fillColor="#F2D422" android:pathData="M253.727,142.301l-0.012,-0.006c-18.085,-9.507 -21.615,-10.021 -40.684,0.003l-0.004,0.002c-16.405,8.624 -16.121,20.788 -15.721,24.028c9.469,58.576 27.319,177.628 36.068,292.235c8.721,-114.223 26.481,-232.861 35.975,-291.643C270.421,160.224 271.61,151.703 253.727,142.301z"/>
<path android:fillColor="#E8C018" android:pathData="M217.507,166.328c-0.401,-3.24 -0.684,-15.404 15.721,-24.028l0.004,-0.002c4.043,-2.125 7.383,-3.772 10.316,-4.964c-10.231,-4.258 -15.656,-2.848 -30.517,4.964l-0.004,0.002c-16.405,8.624 -16.121,20.788 -15.721,24.028c9.469,58.576 27.319,177.628 36.068,292.235c2.68,-35.107 6.215,-70.629 10.101,-104.703C234.676,276.696 224.075,206.96 217.507,166.328z"/>
<path android:fillColor="#F2D422" android:pathData="M386.256,253.408c4.198,-5.61 3.106,-10.191 2.358,-12.042l-4.745,-9.833c-2.244,-4.646 -6.093,-5.941 -7.794,-6.295l-0.854,-0.132h-0.001c0,0 0,0 -8.879,-1.371c-8.39,-1.295 -12.98,5.917 -13.462,6.717c-53.051,93.027 -80.99,244.856 -80.99,244.856c36.366,-108.877 85.054,-183.389 114.357,-221.886C386.25,253.418 386.252,253.413 386.256,253.408z"/>
</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/ic_frown_face.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector android:height="24dp" android:viewportHeight="16"
android:viewportWidth="16" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#fcdf02" android:pathData="M8,1c3.9,0 7,3.1 7,7s-3.1,7 -7,7 -7,-3.1 -7,-7 3.1,-7 7,-7zM8,0c-4.4,0 -8,3.6 -8,8s3.6,8 8,8 8,-3.6 8,-8 -3.6,-8 -8,-8v0z"/>
<path android:fillColor="#fcdf02" android:pathData="M7,6c0,0.552 -0.448,1 -1,1s-1,-0.448 -1,-1c0,-0.552 0.448,-1 1,-1s1,0.448 1,1z"/>
<path android:fillColor="#fcdf02" android:pathData="M11,6c0,0.552 -0.448,1 -1,1s-1,-0.448 -1,-1c0,-0.552 0.448,-1 1,-1s1,0.448 1,1z"/>
<path android:fillColor="#fcdf02" android:pathData="M11.3,12.3c-0.7,-1.1 -2,-1.8 -3.3,-1.8s-2.6,0.7 -3.3,1.8l-0.8,-0.6c0.9,-1.4 2.4,-2.2 4.1,-2.2s3.2,0.8 4.1,2.2l-0.8,0.6z"/>
</vector>
37 changes: 34 additions & 3 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
android:id="@+id/homeactivitycoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:background="@color/black"
android:fitsSystemWindows="true">
android:fitsSystemWindows="true"
android:visibility="visible">

<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout_home"
Expand Down Expand Up @@ -99,7 +99,6 @@
tools:listitem="@layout/list_item_quizzes" />
</android.support.v4.widget.SwipeRefreshLayout>


<!-- Empty view is only visible when the list has no items. -->
<TextView
android:id="@+id/empty_view"
Expand Down Expand Up @@ -144,6 +143,38 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:id="@+id/ll_empty_filter_result_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/refresh_homescreen"
app:layout_constraintVertical_bias="0.38"
tools:ignore="UseCompoundDrawables">

<ImageView
android:id="@+id/iv_empty_filter_result"
android:layout_width="@dimen/empty_view_img_size"
android:layout_height="@dimen/empty_view_img_size"
android:contentDescription="@string/empty_quiz_list"
android:layout_gravity="center_horizontal"
tools:srcCompat="@drawable/ic_fireworks" />

<TextView
android:id="@+id/tv_empty_filter_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Title.Inverse"
tools:text="Empty"
android:textColor="@color/colorAccent"
android:textAlignment="center"
android:layout_marginTop="@dimen/medium_margin"/>
</LinearLayout>


</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>
5 changes: 4 additions & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@
<dimen name="item_discussion_minimum_content_height">60dp</dimen>
<dimen name="item_discussion_minimum_content_width">200dp</dimen>

<!--Handle Filter Layout-->
<dimen name="empty_view_img_size">56dp</dimen>

<!-- Dimensions For Animated Loading Dots -->
<dimen name="loading_dots_width">224dp</dimen>
<dimen name="loading_dots_height">128dp</dimen>

</resources>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,15 @@
<string name="slack_handle_format_missing">Start with \@</string>
<string name="select_your_track">Select Your Track</string>
<string name="user_image_empty">Select a profile photo</string>
<string name="empty_quiz_list">No quiz for the selected Filter</string>

<!--Handle Filter Helper Strings-->
<string name="no_attempted_quizzes">No Attempts Yet!</string>
<string name="no_bookmarked_quizzes">No Bookmarks!</string>
<string name="no_un_attempted_quizzes">All Caught Up!</string>

<string name="type_comment_hint">Type message here</string>



</resources>

0 comments on commit 0dd50c8

Please sign in to comment.