use of android.widget.ProgressBar in project saga-android by AnandChowdhary.
the class OnClickDialog method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View mView = inflater.inflate(R.layout.dialog_on_click, container, false);
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
final ProgressBar mProgress = (ProgressBar) mView.findViewById(R.id.progress_doc);
mImageLoader.get(url, new ImageLoader.ImageListener() {
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
((ImageView) mView.findViewById(R.id.album_iv_doc)).setImageBitmap(response.getBitmap());
}
@Override
public void onErrorResponse(VolleyError error) {
//should get a cache hit
}
});
((TextView) mView.findViewById(R.id.artist_value_tv_doc)).setText(arts);
((TextView) mView.findViewById(R.id.track_value_tv_doc)).setText(title);
ImageButton mDownload = (ImageButton) mView.findViewById(R.id.download_btn_doc);
mDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MusicDownloader.startDownload(getActivity(), title, arts, new MusicDownloader.DownloaderListener() {
@Override
public void showProgressBar() {
mProgress.setVisibility(View.VISIBLE);
}
@Override
public void hideProgressBar() {
mProgress.setVisibility(View.GONE);
}
@Override
public void onSuccess() {
mTracker.send(new HitBuilders.EventBuilder().setCategory("Music Download").setAction("Click").build());
dismiss();
}
});
}
});
ImageButton mShare = (ImageButton) mView.findViewById(R.id.share_btn_doc);
mShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mProgress.setVisibility(View.VISIBLE);
String url = null;
try {
url = "http://rhythmsa.ga/api/sharable.php?q=" + URLEncoder.encode(title + " " + arts, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
mProgress.setVisibility(View.GONE);
Log.d("kthenks", response);
if (Patterns.WEB_URL.matcher(response).matches()) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, "Hey! Check out this amazing song - " + title + " by " + arts + ". " + response + "\nShared via Saga Music app - http://getsa.ga/apk");
try {
startActivity(Intent.createChooser(i, "Share via"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), "No application available to share song", Toast.LENGTH_SHORT).show();
}
mTracker.send(new HitBuilders.EventBuilder().setCategory("Music Share").setAction("Click").build());
} else
Toast.makeText(getActivity(), "Error in sharing", Toast.LENGTH_SHORT).show();
dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mProgress.setVisibility(View.GONE);
VolleyLog.d("kthenks", "Error: " + error.getMessage());
Toast.makeText(getActivity(), "Error connecting to the Internet", Toast.LENGTH_SHORT).show();
dismiss();
}
});
request.setShouldCache(false);
mQueue.add(request);
}
});
return mView;
}
use of android.widget.ProgressBar in project QuickAndroid by ImKarl.
the class BaseAdapterHelper method setProgress.
/**
* Sets the progress of a ProgressBar.
* @param viewId The view id.
* @param progress The progress.
* @return The BaseAdapterHelper for chaining.
*/
@SuppressWarnings("unchecked")
public H setProgress(int viewId, int progress) {
ProgressBar view = retrieveView(viewId);
view.setProgress(progress);
return (H) this;
}
use of android.widget.ProgressBar in project QuickAndroid by ImKarl.
the class BaseAdapterHelper method setMax.
/**
* Sets the range of a ProgressBar to 0...max.
* @param viewId The view id.
* @param max The max value of a ProgressBar.
* @return The BaseAdapterHelper for chaining.
*/
@SuppressWarnings("unchecked")
public H setMax(int viewId, int max) {
ProgressBar view = retrieveView(viewId);
view.setMax(max);
return (H) this;
}
use of android.widget.ProgressBar in project SimpleCropView by IsseiAoki.
the class ProgressDialogFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_progress_dialog, null, false);
ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress);
progressBar.getIndeterminateDrawable().setColorFilter(getContext().getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_IN);
return view;
}
use of android.widget.ProgressBar in project AntennaPod by AntennaPod.
the class ItunesSearchFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
gridView = (GridView) root.findViewById(R.id.gridView);
adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
gridView.setAdapter(adapter);
//Show information about the podcast when the list item is clicked
gridView.setOnItemClickListener((parent, view1, position, id) -> {
Podcast podcast = searchResults.get(position);
if (!podcast.feedUrl.contains("itunes.apple.com")) {
Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl);
intent.putExtra(OnlineFeedViewActivity.ARG_TITLE, "iTunes");
startActivity(intent);
} else {
gridView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
subscription = Observable.create((Observable.OnSubscribe<String>) subscriber -> {
OkHttpClient client = AntennapodHttpClient.getHttpClient();
Request.Builder httpReq = new Request.Builder().url(podcast.feedUrl).header("User-Agent", ClientConfig.USER_AGENT);
try {
Response response = client.newCall(httpReq.build()).execute();
if (response.isSuccessful()) {
String resultString = response.body().string();
JSONObject result = new JSONObject(resultString);
JSONObject results = result.getJSONArray("results").getJSONObject(0);
String feedUrl = results.getString("feedUrl");
subscriber.onNext(feedUrl);
} else {
String prefix = getString(R.string.error_msg_prefix);
subscriber.onError(new IOException(prefix + response));
}
} catch (IOException | JSONException e) {
subscriber.onError(e);
}
subscriber.onCompleted();
}).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(feedUrl -> {
progressBar.setVisibility(View.GONE);
gridView.setVisibility(View.VISIBLE);
Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, feedUrl);
intent.putExtra(OnlineFeedViewActivity.ARG_TITLE, "iTunes");
startActivity(intent);
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
progressBar.setVisibility(View.GONE);
gridView.setVisibility(View.VISIBLE);
String prefix = getString(R.string.error_msg_prefix);
new MaterialDialog.Builder(getActivity()).content(prefix + " " + error.getMessage()).neutralText(android.R.string.ok).show();
});
}
});
progressBar = (ProgressBar) root.findViewById(R.id.progressBar);
txtvError = (TextView) root.findViewById(R.id.txtvError);
butRetry = (Button) root.findViewById(R.id.butRetry);
txtvEmpty = (TextView) root.findViewById(android.R.id.empty);
loadToplist();
return root;
}
Aggregations