Added a blank screen when the favorites list is empty, the color of the icons is changed to black on the ActionBar in the ItemActivity, centered blank screen text in MainActivity.

This commit is contained in:
ChronosX88 2019-02-24 15:32:03 +04:00
parent 7c1d686be6
commit 6d5b0a2b62
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
12 changed files with 104 additions and 24 deletions

View File

@ -20,4 +20,8 @@ public class FavoritesListAdapter extends ArrayAdapter<FavoritesListModel> {
super.clear(); super.clear();
super.addAll(db.selectAll()); super.addAll(db.selectAll());
} }
public int getArraySize() {
return db.selectAll().size();
}
} }

View File

@ -1,6 +1,7 @@
package ru.volgorobot.vrcatalog.view; package ru.volgorobot.vrcatalog.view;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
@ -8,7 +9,9 @@ import android.view.ContextMenu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
@ -22,10 +25,13 @@ import ru.volgorobot.vrcatalog.presenters.FavoritesPresenter;
public class FavoritesActivity extends AppCompatActivity implements MainContract.FavoritesActivityView { public class FavoritesActivity extends AppCompatActivity implements MainContract.FavoritesActivityView {
private FavoritesDBPresenter db; private FavoritesDBPresenter db;
private ListView listView;
private FavoritesListAdapter adapter; private FavoritesListAdapter adapter;
private MainContract.FavoritesPresenter mPresenter; private MainContract.FavoritesPresenter mPresenter;
private ListView listView;
private ImageView favoritesEmptyImage;
private TextView favoritesEmptyText;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -33,10 +39,17 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
mPresenter = new FavoritesPresenter(FavoritesActivity.this, this); mPresenter = new FavoritesPresenter(FavoritesActivity.this, this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); ActionBar actionBar = getSupportActionBar();
getSupportActionBar().setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setTitle("Избранное");
db = new FavoritesDBPresenter(FavoritesActivity.this); db = new FavoritesDBPresenter(FavoritesActivity.this);
initViews();
}
public void initViews() {
listView = findViewById(R.id.favorites_list_view); listView = findViewById(R.id.favorites_list_view);
registerForContextMenu(listView); registerForContextMenu(listView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@ -46,10 +59,24 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
mPresenter.fetchItem(model.getItemID()); mPresenter.fetchItem(model.getItemID());
} }
}); });
favoritesEmptyImage = findViewById(R.id.favorites_empty_image);
favoritesEmptyText = findViewById(R.id.favorites_empty_text);
ArrayList<FavoritesListModel> models = db.selectAll(); ArrayList<FavoritesListModel> models = db.selectAll();
adapter = new FavoritesListAdapter(FavoritesActivity.this, android.R.layout.simple_list_item_1, models); adapter = new FavoritesListAdapter(FavoritesActivity.this, android.R.layout.simple_list_item_1, models);
listView.setAdapter(adapter); listView.setAdapter(adapter);
checkForEmptyContent();
}
public void checkForEmptyContent() {
if(adapter.getArraySize() == 0) {
listView.setVisibility(View.GONE);
favoritesEmptyImage.setVisibility(View.VISIBLE);
favoritesEmptyText.setVisibility(View.VISIBLE);
} else {
listView.setVisibility(View.VISIBLE);
favoritesEmptyImage.setVisibility(View.INVISIBLE);
favoritesEmptyText.setVisibility(View.INVISIBLE);
}
} }
@Override @Override
@ -117,5 +144,6 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
updateListView(); updateListView();
checkForEmptyContent();
} }
} }

View File

@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#FFFFFF" <vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24.0" android:viewportWidth="24.0" android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/> <path android:fillColor="#FF000000" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#D3D3D3"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
</vector>

View File

@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#FFFFFF" <vector android:height="24dp" android:tint="#FF0000"
android:viewportHeight="24.0" android:viewportWidth="24.0" android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/> <path android:fillColor="#FF000000" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>

View File

@ -1,14 +1,47 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".view.FavoritesActivity"> tools:context=".view.FavoritesActivity">
<ListView <ListView
android:id="@+id/favorites_list_view" android:id="@+id/favorites_list_view"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent"/> android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout> <ImageView
android:id="@+id/favorites_empty_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="70dp"
android:layout_marginBottom="52dp"
android:src="@drawable/ic_favorite_border_grey_24dp"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@+id/favorites_empty_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/favorites_empty_text"
android:layout_width="0dp"
android:layout_height="77dp"
android:layout_marginStart="9dp"
android:layout_marginEnd="9dp"
android:layout_marginBottom="68dp"
android:gravity="center"
android:text="@string/favorites_empty"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textSize="24sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/favorites_empty_image" />
</android.support.constraint.ConstraintLayout>

View File

@ -52,6 +52,8 @@
android:text="" android:text=""
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:visibility="invisible" android:visibility="invisible"
android:textSize="18sp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -11,7 +11,7 @@
<item <item
android:id="@+id/nav_favorites" android:id="@+id/nav_favorites"
android:icon="@drawable/ic_favorite_black_24dp" android:icon="@drawable/ic_favorite_black_24dp"
android:title="Избранные" /> android:title="Избранное" />
<item <item
android:id="@+id/nav_settings" android:id="@+id/nav_settings"
android:icon="@drawable/ic_settings_applications" android:icon="@drawable/ic_settings_applications"

View File

@ -3,13 +3,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_favorite" android:id="@+id/action_favorite"
android:icon="@drawable/ic_favorite_border_white_24dp" android:icon="@drawable/ic_favorite_border_black_24dp"
app:showAsAction="always|collapseActionView" app:showAsAction="always|collapseActionView"
android:title="Добавить в избранные" android:title="Добавить в избранные"
android:visible="false"/> android:visible="false"/>
<item <item
android:id="@+id/action_unfavorite" android:id="@+id/action_unfavorite"
android:icon="@drawable/ic_favorite_white_24dp" android:icon="@drawable/ic_favorite_red_24dp"
app:showAsAction="always|collapseActionView" app:showAsAction="always|collapseActionView"
android:title="Удалить из избранного" android:title="Удалить из избранного"
android:visible="false"/> android:visible="false"/>

View File

@ -22,7 +22,7 @@
<item name="background">@android:color/transparent</item> <item name="background">@android:color/transparent</item>
</style> </style>
<style name="ItemActionBar" parent="ItemActivityTheme"> <style name="ItemActionBar" parent="ItemActivityTheme">
<item name="android:textColorPrimary">@android:color/white</item> <item name="android:textColorPrimary">@android:color/black</item>
<item name="android:textColorSecondary">@android:color/white</item> <item name="android:textColorSecondary">@android:color/black</item>
</style> </style>
</resources> </resources>

View File

@ -1,5 +1,6 @@
<resources> <resources>
<string name="app_name">VRCatalog</string> <string name="app_name">uCatalog</string>
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
<string name="favorites_empty">Ваш список избранного пуст</string>
</resources> </resources>

View File

@ -1,8 +1,5 @@
<resources> <resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
@ -16,14 +13,24 @@
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="ItemActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="AppTheme.Fullscreen"> <style name="AppTheme.Fullscreen">
<item name="android:windowFullscreen">true</item> <item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="ItemActivityTheme" parent="AppTheme">
<item name="android:windowTranslucentStatus">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="TransparentActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="android:background">@android:color/transparent</item>
<item name="background">@android:color/transparent</item>
</style>
<style name="ItemActionBar" parent="ItemActivityTheme">
<item name="android:textColorPrimary">@android:color/black</item>
<item name="android:textColorSecondary">@android:color/black</item>
</style> </style>
</resources> </resources>