Add progress bar to nearby cardview

This commit is contained in:
neslihanturan 2018-09-24 12:37:32 +03:00
parent 7de3ad8b89
commit f4b055607e
2 changed files with 24 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -29,6 +30,7 @@ public class NearbyNoificationCardView extends CardView{
private TextView notificationTitle;
private TextView notificationDistance;
private ImageView notificationIcon;
private ProgressBar progressBar;
public NearbyNoificationCardView(@NonNull Context context) {
super(context);
@ -59,6 +61,8 @@ public class NearbyNoificationCardView extends CardView{
notificationIcon = rootView.findViewById(R.id.nearby_icon);
progressBar = rootView.findViewById(R.id.progressBar);
setActionListeners();
}
@ -116,11 +120,24 @@ public class NearbyNoificationCardView extends CardView{
} else {
Log.d("deneme","called2");
contentLayout.setVisibility(VISIBLE);
// Set visibility of elements in content layout once it become visible
progressBar.setVisibility(VISIBLE);
notificationTitle.setVisibility(GONE);
notificationDistance.setVisibility(GONE);
notificationIcon.setVisibility(GONE);
permissionRequestButton.setVisibility(GONE);
}
}
public void updateContent(boolean isClosestNearbyPlaceFound, Place place) {
// Make progress bar invisible once data is ready
progressBar.setVisibility(GONE);
// And content views visible since they are ready
notificationTitle.setVisibility(VISIBLE);
notificationDistance.setVisibility(VISIBLE);
notificationIcon.setVisibility(VISIBLE);
if (isClosestNearbyPlaceFound) {
notificationTitle.setText(place.name);
notificationDistance.setText(place.distance);

View file

@ -29,6 +29,13 @@
android:id="@+id/content_layout"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerInParent="true"
/>
<ImageView
android:id="@+id/nearby_icon"
android:layout_width="40dp"
@ -36,8 +43,6 @@
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/no_image_found"
android:visibility="gone"
android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_location_white_24dp"/>