Android-SpinKit
Android-SpinKit copied to clipboard
Full of Bug
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/white" android:layout_margin="@dimen/dp_10" app:cardBackgroundColor="@color/white" app:cardCornerRadius="@dimen/dp_10" app:cardElevation="@dimen/dp_5" app:cardUseCompatPadding="true" app:contentPadding="@dimen/dp_5" android:layout_height="wrap_content">
<com.github.ybq.android.spinkit.SpinKitView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/spin_kit"
style="@style/SpinKitView.FadingCircle"
android:layout_width="@dimen/dp_35"
android:indeterminate="false"
android:layout_height="@dimen/dp_35"
android:layout_centerInParent="true"
android:layout_gravity="center"
app:SpinKit_Color="@color/sky_lue"
android:padding="10dp"/>
</androidx.cardview.widget.CardView>
public void dialogShow (Context context, String msg) { progressDialog = new Dialog(context); progressDialog.setCancelable(false); progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Display display = ((Activity) context).getWindowManager().getDefaultDisplay(); int screenWidth = display.getWidth(); progressDialog.setContentView(R.layout.dialog_custom_progress); SpinkKitView progressBar = (SpinKitView) findViewById(R.id.spin_kit); progressDialog.show(); progressDialog.getWindow().setLayout((int) (screenWidth / 1.1), LinearLayout.LayoutParams.WRAP_CONTENT); }
public void dialogHide(){
progressDialog.dismiss();
// if (progressDialog!=null){ // progressDialog.dismiss(); // } }
The spin kit never stops spinning it rotates infinitely. Is there any way to stop this
You have to hide spinkit right after your data has loaded call this if you want to hide it: progressBar.visibility = View.INVISIBLE
call this to show it again: progressBar.visibility = View.VISIBLE
@Bobby-Anggunawan not working i have already tried your code this library is causing memory leak and the same issue is happening again, this time null Pointer exception is thrown
public void dialogShow (Context context, String msg) { progressDialog = new Dialog(context); progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Display display = ((AppCompatActivity) context).getWindowManager().getDefaultDisplay(); int screenWidth = display.getWidth(); progressDialog.setContentView(R.layout.dialog_custom_progress); progressBar = (SpinKitView) findViewById(R.id.spin_kit); progressBar.setVisibility(View.VISIBLE); progressDialog.show(); progressDialog.setCancelable(false); progressDialog.getWindow().setLayout((int) (screenWidth / 1.1), LinearLayout.LayoutParams.WRAP_CONTENT); }
public void dialogHide(){
if (progressDialog.isShowing()) {
progressBar.setVisibility(View.INVISIBLE);
progressDialog.hide();
}
}
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/white" android:layout_margin="@dimen/dp_10" app:cardBackgroundColor="@color/white" app:cardCornerRadius="@dimen/dp_10" app:cardElevation="@dimen/dp_5" app:cardUseCompatPadding="true" app:contentPadding="@dimen/dp_5" android:layout_height="wrap_content">
<com.github.ybq.android.spinkit.SpinKitView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/spin_kit"
style="@style/SpinKitView.FadingCircle"
android:layout_width="wrap_content"
android:indeterminate="true"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
app:SpinKit_Color="@color/sky_lue"
android:background="?selectableItemBackgroundBorderless"
android:padding="10dp"/>
</androidx.cardview.widget.CardView>
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.ybq.android.spinkit.SpinKitView.setVisibility(int)' on a null object reference
what the hell is wrong with this library.?