kaopiz / kprogresshud Goto Github PK
View Code? Open in Web Editor NEWAn implement of ProgressHUD for Android, similar to MBProgressHUD, SVProgressHUD for iOS.
License: Apache License 2.0
An implement of ProgressHUD for Android, similar to MBProgressHUD, SVProgressHUD for iOS.
License: Apache License 2.0
Can't dismiss the KPProgressHUD in my application Please Help me...?
KProgressHUD.create(SearchCompany.this).setStyle(KProgressHUD.Style.SPIN_INDETERMINATE) .setLabel("Please Wait").setCancellable(true).show();
出现 进度条setProgress(0) ,初始化 绘制进度时,绘制实心 部分 向左偏移!
解决办法: BarView类中 setProgress方法中 mInBound矩形类中的right位置:加上 mBoundGap
@OverRide
public void setProgress(int progress) {
this.mProgress = progress;
mInBound.set(mBoundGap, mBoundGap,
mBoundGap+(getWidth() - mBoundGap) * mProgress / mMax, getHeight() - mBoundGap);
invalidate();
}
exception:not attached to window manager
suggest:
public void dismiss() {
if (mContent!=null && !(Activity)mContext.isFinish() &&mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
how can open progress just on fragment not all the activity , I need my menu and my toolbar and Bottom navigation active when this progress showrd. what is best way ?
android.view.WindowLeaked: Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{360ddfca V.ED.... R......D 0,0-108,108} that was originally added here
code:
hud = KProgressHUD.create(this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setCancellable(false)
.setAnimationSpeed(2)
.setDimAmount(0.5f)
.show();
There's currently no way to set a OnCancelListener
The bar determinate progress bar is not showing the progress while working with the Async task
How do you make the radius smaller, it doesn't look that big
aha.. will you add progress.isShowing() in next version ?
It is very good library to use. Please allow some customization like adding background color, text color etc. to make better.
Is it possible, that the ProgressHUD doesn't block the UI?
I want to leave the User the freedom to switch to another Activity by going into a SlideIn-Menu. The ProgressHUD is blocking the possibility though.
.setCancellable(true) removes the ProgressHUD, which is not my intention. It has to keep rotating while the user is going into the SlideIn-Menu.
Android Studio 4.2 suggest change jcenter() to mavenCentral().
https://developer.android.com/studio/build/jcenter-migration
JFrog, the company that maintains the JCenter artifact repository used by many Android projects, recently announced the deprecation and upcoming retirement of JCenter. According to the announcement, JCenter will allow downloads of existing artifacts until February 1, 2022.
Developers who publish artifacts on JCenter should start migrating their packages to a new host, such as Maven Central.
In the near future, we will provide additional information about migrating Android projects away from JCenter on this page.
Please how I can solve this issue,
I declared a variable (private KProgressHUD progressHUD;)
I already added and sync the library in gradle successfully
but I get an error message as the subject
Hi, i have to show hub on Application class, this mean no activity created for this time, so i have the above question, thanks
The library seems to have become broken since the last time I used it. I have no idea what has changed. Whenever I show the HUD it crashes the app.
To reproduce, all I have to do is the following:
The result is this error:
java.lang.NoSuchFieldError: No field container of type I in class Lcom/kaopiz/kprogresshud/R$id; or its superclasses (declaration of 'com.kaopiz.kprogresshud.R$id' appears in /data/app/com.rspsystems.hudtest3-1/split_lib_slice_5_apk.apk) at com.kaopiz.kprogresshud.KProgressHUD$ProgressDialog.initViews(KProgressHUD.java:292) at com.kaopiz.kprogresshud.KProgressHUD$ProgressDialog.onCreate(KProgressHUD.java:281) at android.app.Dialog.dispatchOnCreate(Dialog.java:514) at android.app.Dialog.show(Dialog.java:380) at com.kaopiz.kprogresshud.KProgressHUD.show(KProgressHUD.java:233)
(The rest of the strack trace is left out to reduce clutter)
This even happens in an old project I had no problems with half a year ago. Only thing I can think of that has changed since then, is that Android Studio forced me to update gradle from 2.3.0-Beta1 to 2.3.3.
I use code below to show progress :
hud=KProgressHUD.create(context)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setAnimationSpeed(2)
.setDimAmount(Constants.HUD_DIM_AMOUNT)
.setMaxProgress(100);
hud.show();
Why this hides device keyboard? I want keyboard to be visible.
Thanks
when hub dismiss, can cancel something request.
我的KProgressHUD.Style.SPIN_INDETERMINATE 模式下为什么半径好大啊 这个怎么调小点
Hello
It would be great if you added support for custom typeface
Thanks for great component.
Attempt to invoke virtual method 'void com.kaopiz.kprogresshud.KProgressHUD.dismiss()' on a null object reference
建议自定义View 能加个时间,然后自动消失吗
Could you give some insights why this library is a good idea?
I just leave this here:
There is no way to handle onCancel Event
for ex.
ProgressDialog myDialog = ProgressDialog.show(
mContext,
"Please wait...",
"Loading the data",
true,
true,
new DialogInterface.OnCancelListener(){
@OverRide
public void onCancel(DialogInterface dialog) {
Log.d(TAG,"onCancel");
onjName.cancel(true);
}
}
);
This is the error log,(android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@28109859 is not valid; is your activity running?)I had already dropped it when I called back,And this is the current activity of this,Why the problem?
看了api好像没有设置正在加载的时候页面是否可交互
Is there any way I can change size of Label? (I mean label from setLabel() method)
Can we get a feature like this, thanks.
java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity
at com.kaopiz.kprogresshud.KProgressHUD.dismiss(KProgressHUD.java:329)
at crm.pixtech.com.CustomDialoges.CustomContactInfoDialog.ShowDialog(CustomContactInfoDialog.java:159)
at crm.pixtech.com.CustomDialoges.CustomContactInfoDialog.access$100(CustomContactInfoDialog.java:39)
at crm.pixtech.com.CustomDialoges.CustomContactInfoDialog$1.onSuccess(CustomContactInfoDialog.java:135)
at crm.pixtech.com.NetworkRequest.Network.lambda$GET_REQUEST$2$Network(Network.java:288)
at crm.pixtech.com.NetworkRequest.Network$$Lambda$2.onResponse(Unknown Source)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:78)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:106)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
能不能点返回实体按钮不消失?
Is it possible to reset the size of the hud? I use one hud for multiple views and some require it to be a set size (just a spinner) and others need it to be dynamic as it will need to expand based on the text it will display.
It this possible to get the hud back to the WRAP_CONTENT
state?
I want to custom a kprogresshud, but i can not import the AnnularView class
Hi there, I really like your library however in of my use cases I want to show the progress dialog at the top of the view (not on the center) is it somehow possible to change the gravity to my choice? If I apply a custom imageview will it show at the position of the imageview?
ths~
.../app/src/main/AndroidManifest.xml:13:9-36 Error: Attribute application@allowBackup value=(false) from AndroidManifest.xml:9:9-36 is also present at [com.kaopiz:kprogresshud:1.1.0] AndroidManifest.xml:12:9-35 value=(true). Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-34:19 to override. .../app/src/main/AndroidManifest.xml:13:9-36 Error: Attribute application@supportsRtl value=(false) from AndroidManifest.xml:13:9-36 is also present at [com.kaopiz:kprogresshud:1.1.0] AndroidManifest.xml:13:9-35 value=(true). Suggestion: add 'tools:replace="android:supportsRtl"' to <application> element at AndroidManifest.xml:7:5-34:19 to override.
传入全局上下文 又加载不出来
android 9.0系统,一加5,loading时状态栏会消失,加载完毕会显示出来
Hi,
thanks for this awesome tool.
I was just wondering if it was possible to add an AnimationDrawable to a CustomView? I want to animate a couple of images to create my own custom loading HUD...
Thanks
调用progressHUD.dismiss();之后,界面无法响应点击事件。
Hello
I just want to show it with spinner, but when I will got success or error I want to switch it to simple toast. Is it possible? I tried to do that
View v = new View(LoginActivity.this);
v.setLayoutParams(new LinearLayout.LayoutParams(1, 1));
v.setBackgroundColor(Color.TRANSPARENT);
hud.setCustomView(v);
hud.setDetailsLabel("Something went wrong");
But it doesn't work as expected...
Please help.
In BarView, onDraw() method:
canvas.drawRoundRect(mBound, mRadius, mRadius, mOuterPaint);
canvas.drawRoundRect(mInBound, mRadius, mRadius, mInnerPaint);
This is not a regular rounded rectangle.
recommended change to this:
canvas.drawRoundRect(mBound, mBound.height()/2, mBound.height()/2, mOuterPaint);
canvas.drawRoundRect(mInBound, mInBound.height()/2, mInBound.height()/2, mInnerPaint);
Dear support,
I add the KProgressHUD in my InitsViews() and call InitsViews onCreate, but the loader on the section i mentioned here is not showing up, and no error return
if (!prefManager.geRole().equals("0")) {
hud.show(); //<<===================Not working , it does not shw up , No error return , no force close , but not show up
String[] user = prefManager.geRole().split(":");
helpView.loadUrl(Splash.main.getWelcome() + "?name=" + user[0] + "&private=" + user[1] + "&user_id=" + user[2] + "&random=" +
getRandomNumberInRange(999, 15000));
} else {
hud.show(); //<<===================Not working , it does not shw up , No error return , no force close , but not show up
helpView.loadUrl(Splash.main.getWelcome());
}
package com.hala.instgram.views;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.PopupMenu;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewConfiguration;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.hala.instgram.R;
import com.hala.instgram.helper.PrefManager;
import com.hala.instgram.helper.WebAppInterface;
import com.hala.instgram.network.ServerRequests;
import com.kaopiz.kprogresshud.KProgressHUD;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static com.hala.instgram.helper.WebAppInterface.xvflage;
public class MainPage extends AppCompatActivity {
public static WebView helpView;
FloatingActionButton floatingActionButton;
PrefManager prefManager;
KProgressHUD hud;
private FirebaseAnalytics mFirebaseAnalytics;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_page);
InitsViews();
}
public void InitsViews() {
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
prefManager = new PrefManager(this);
helpView = findViewById(R.id.de);
helpView.addJavascriptInterface(new WebAppInterface(this), "AndroidInterface");
helpView.getSettings().setJavaScriptEnabled(true);
helpView.getSettings().setDomStorageEnabled(true);
helpView.getSettings().setAppCacheEnabled(true);
ImageView imageView = new ImageView(this);
imageView.setBackgroundResource(R.drawable.original);
hud = KProgressHUD.create(MainPage.this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setCancellable(false)
.setAnimationSpeed(2)
.setBackgroundColor(Color.parseColor("#ffa10197"))
.setDimAmount(0);
hud.show();
floatingActionButton = findViewById(R.id.floatingActionButton);
if (!prefManager.geRole().equals("0")) {
floatingActionButton.setImageResource(R.drawable.ic_logout);
}
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@SuppressLint("RestrictedApi")
@Override
public void onClick(View v) {
if (!prefManager.geRole().equals("0")) {
showDialog1();
} else {
hud.show();
floatingActionButton.setVisibility(View.GONE);
helpView.loadUrl(Splash.main.getLogin());
}
}
});
helpView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
helpView.setVisibility(View.GONE);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
hud.dismiss();
if (prefManager.isFirstTimeLaunch()) {
if (view.getUrl().equals(Splash.main.getWebsite() + "/")) {
injectScriptFile(view, "lib.js");
getSupportActionBar().setSubtitle(view.getUrl());
}
if (view.getUrl().contains(Splash.main.getLogin())) {
getSupportActionBar().setSubtitle(view.getUrl());
}
}
helpView.setVisibility(View.VISIBLE);
}
});
if (!prefManager.geRole().equals("0")) {
hud.show();
String[] user = prefManager.geRole().split(":");
helpView.loadUrl(Splash.main.getWelcome() + "?name=" + user[0] + "&private=" + user[1] + "&user_id=" + user[2] + "&random=" +
getRandomNumberInRange(999, 15000));
} else {
hud.show();
helpView.loadUrl(Splash.main.getWelcome());
}
}
@SuppressLint("RestrictedApi")
@Override
public void onBackPressed() {
if (!helpView.getUrl().contains(Splash.main.getWelcome())) {
if (!prefManager.geRole().equals("0")) {
hud.show();
String[] user = prefManager.geRole().split(":");
helpView.loadUrl(Splash.main.getWelcome() + "?name=" + user[0] + "&private=" + user[1] + "&user_id=" + user[2] + "&random=" +
getRandomNumberInRange(999, 15000));
} else {
hud.show();
helpView.loadUrl(Splash.main.getWelcome());
}
floatingActionButton.setVisibility(View.VISIBLE);
getSupportActionBar().setSubtitle(null);
} else {
finish();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_favorite:
hud.show();
getSupportActionBar().setSubtitle(null);
helpView.loadUrl(Splash.main.getHelp());
return true;
case R.id.action_help:
View buttonAddProduct = findViewById(R.id.action_help);
showPopupMenu(buttonAddProduct);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void injectScriptFile(WebView view, String scriptFile) {
InputStream input;
try {
xvflage = true;
InputStream stream = new ByteArrayInputStream(Splash.main.getActions().getJavascript().getBytes());
Log.e("javascr", Splash.main.getActions().getJavascript());
input = getAssets().open(scriptFile);
int x = input.available();
byte[] buffer = new byte[x];
input.read(buffer);
input.close();
// String-ify the script byte-array using BASE64 encoding !!!
String encoded = Base64.encodeToString(buffer, Base64.NO_WRAP);
String encoded1 = Base64.encodeToString(Splash.main.getActions().getJavascript().getBytes(), Base64.NO_WRAP);
Log.e("ed", encoded);
view.loadUrl("javascript:(function() {" +
"var parent = document.getElementsByTagName('head').item(0);" +
"var script = document.createElement('script');" +
"script.type = 'text/javascript';" +
// Tell the browser to BASE64-decode the string into your script !!!
"script.innerHTML = window.atob('" + encoded + "');" +
"parent.appendChild(script)" +
"})()");
view.loadUrl("javascript:(function() {" +
"var parent = document.getElementsByTagName('head').item(0);" +
"var script = document.createElement('script');" +
"script.type = 'text/javascript';" +
// Tell the browser to BASE64-decode the string into your script !!!
"script.innerHTML = window.atob('" + encoded1 + "');" +
"parent.appendChild(script)" +
"})()");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("deprecation")
public void clearCookies(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
Log.d("f", "Using clearCookies code for API >=" + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1));
CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush();
} else {
Log.d("f", "Using clearCookies code for API <" + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1));
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
cookieSyncMngr.startSync();
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncMngr.stopSync();
cookieSyncMngr.sync();
}
startActivity(new Intent(MainPage.this, Splash.class));
finish();
}
private void showPopupMenu(View view) {
// inflate menu
PopupMenu popup = new PopupMenu(MainPage.this, view);
for (int x = 0; x < Splash.main.getMenu().size(); x++)
{
popup.getMenu().add(Splash.main.getMenu().get(x).getText());
}
popup.setOnMenuItemClickListener(new MyMenuItemClickListener());
popup.show();
}
public void showDialog1() {
// Create the object of
// AlertDialog Builder class
AlertDialog.Builder builder = new AlertDialog.Builder(MainPage.this);
builder.setMessage("Are you sure you want to disconnect your Instagram account form InstaGroup app?");
builder.setTitle("InstaGroup");
builder.setCancelable(false);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onClick(DialogInterface dialog,
int which) {
helpView.clearCache(true);
helpView.clearHistory();
prefManager.setrole("0");
prefManager.setFirstTimeLaunch(true);
clearCookies(MainPage.this);
floatingActionButton.setImageResource(R.drawable.ic_add);
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
}
});
// Create the Alert dialog
AlertDialog alertDialog = builder.create();
// Show the Alert Dialog box
alertDialog.show();
}
@Override
protected void onResume() {
if (!prefManager.geRole().equals("0")) {
String[] user = prefManager.geRole().split(":");
helpView.loadUrl(Splash.main.getWelcome() + "?name=" + user[0] + "&private=" + user[1] + "&user_id=" + user[2] + "&random=" +
getRandomNumberInRange(999, 15000));
} else {
helpView.loadUrl(Splash.main.getWelcome());
}
super.onResume();
}
@Override
public void onPause() {
finish();
super.onPause();
}
private int getRandomNumberInRange(int min, int max) {
if (min >= max) {
throw new IllegalArgumentException("max must be greater than min");
}
Random r = new Random();
return r.nextInt((max - min) + 1) + min;
}
/**
* Click listener for popup menu items
*/
class MyMenuItemClickListener implements PopupMenu.OnMenuItemClickListener {
public MyMenuItemClickListener() {
}
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
for (int x = 0; x < Splash.main.getMenu().size(); x++) {
if (menuItem.getTitle().equals(Splash.main.getMenu().get(x).getText())) {
hud.show();
helpView.loadUrl(Splash.main.getMenu().get(x).getUrl());
getSupportActionBar().setSubtitle(null);
}
}
return true;
}
}
}
I have used this library, it awesome and easy but There is no gravity control function.
In lollipop and marshmallow by default it appears at the center left side of the screen . How can i manage to bring it in center ?
The progress bar is working fine but as soon as I add "'com.kaopiz:kprogresshud:1.1.0'" to the gradle some of my layouts started displaying alignment issues and some overlapping controls as well.
To confirm this I took a fresh development and it worked fine and then I just added the above line to the gradle and compiled then I can see the alignment issues appears. Any idea?
Checked with 2-3 Gradle versions and Android studio versions.
My current Android Studio version is 2.3.3
My current Gradle Version 2.10
My current Android Plugin Version 2.1.0
I am not able to change the text size(EX: please wait).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.