mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 02:38:47 +00:00
Can now display message on List page if there are currently no lists
This commit is contained in:
parent
9d80d6c937
commit
c293fd8877
@ -6,6 +6,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -35,13 +36,14 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
|
|||||||
Requestor requestor;
|
Requestor requestor;
|
||||||
ListView shoppingListsView;
|
ListView shoppingListsView;
|
||||||
ProgressBar loadingLists;
|
ProgressBar loadingLists;
|
||||||
int resultsIndex;
|
TextView emptyMessage;
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.fragment_home, container, false);
|
View root = inflater.inflate(R.layout.fragment_home, container, false);
|
||||||
shoppingListsView = root.findViewById(R.id.shopping_lists);
|
shoppingListsView = root.findViewById(R.id.shopping_lists);
|
||||||
loadingLists = (ProgressBar) root.findViewById(R.id.progress_loading_lists);
|
loadingLists = (ProgressBar) root.findViewById(R.id.progress_loading_lists);
|
||||||
loadingLists.setVisibility(View.VISIBLE);
|
loadingLists.setVisibility(View.VISIBLE);
|
||||||
|
emptyMessage = (TextView) root.findViewById(R.id.textViewEmpty);
|
||||||
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
@ -90,6 +92,7 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
requestor.postObject(newList, idReceiver, idReceiver);
|
requestor.postObject(newList, idReceiver, idReceiver);
|
||||||
|
emptyMessage.setVisibility(View.GONE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Toast.makeText(getContext(), "An error occurred", Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), "An error occurred", Toast.LENGTH_LONG).show();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -177,6 +180,10 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
loadingLists.setVisibility(View.GONE);
|
loadingLists.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if(listIds.length == 0) {
|
||||||
|
emptyMessage.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -36,4 +36,14 @@
|
|||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentEnd="true"/>
|
android:layout_alignParentEnd="true"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textViewEmpty"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="You currently have no shopping lists."
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
Loading…
Reference in New Issue
Block a user