Search in sources :

Example 46 with ProgressBar

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;
}
Also used : VolleyError(com.android.volley.VolleyError) StringRequest(com.android.volley.toolbox.StringRequest) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) TextView(android.widget.TextView) ImageLoader(com.android.volley.toolbox.ImageLoader) ProgressBar(android.widget.ProgressBar) Nullable(android.support.annotation.Nullable)

Example 47 with ProgressBar

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;
}
Also used : ProgressBar(android.widget.ProgressBar)

Example 48 with ProgressBar

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;
}
Also used : ProgressBar(android.widget.ProgressBar)

Example 49 with ProgressBar

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;
}
Also used : View(android.view.View) ProgressBar(android.widget.ProgressBar) Nullable(android.support.annotation.Nullable)

Example 50 with ProgressBar

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;
}
Also used : Bundle(android.os.Bundle) GridView(android.widget.GridView) ProgressBar(android.widget.ProgressBar) SearchView(android.support.v7.widget.SearchView) ItunesAdapter(de.danoeh.antennapod.adapter.itunes.ItunesAdapter) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Observable(rx.Observable) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) MenuItemUtils(de.danoeh.antennapod.menuhandler.MenuItemUtils) MenuInflater(android.view.MenuInflater) Locale(java.util.Locale) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) View(android.view.View) Button(android.widget.Button) Response(okhttp3.Response) AntennapodHttpClient(de.danoeh.antennapod.core.service.download.AntennapodHttpClient) Log(android.util.Log) Request(okhttp3.Request) LayoutInflater(android.view.LayoutInflater) R(de.danoeh.antennapod.R) MenuItemCompat(android.support.v4.view.MenuItemCompat) Fragment(android.support.v4.app.Fragment) ClientConfig(de.danoeh.antennapod.core.ClientConfig) IOException(java.io.IOException) ViewGroup(android.view.ViewGroup) URLEncoder(java.net.URLEncoder) List(java.util.List) TextView(android.widget.TextView) OkHttpClient(okhttp3.OkHttpClient) Podcast(de.danoeh.antennapod.adapter.itunes.ItunesAdapter.Podcast) OnlineFeedViewActivity(de.danoeh.antennapod.activity.OnlineFeedViewActivity) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Subscription(rx.Subscription) JSONArray(org.json.JSONArray) ItunesAdapter(de.danoeh.antennapod.adapter.itunes.ItunesAdapter) OnlineFeedViewActivity(de.danoeh.antennapod.activity.OnlineFeedViewActivity) OkHttpClient(okhttp3.OkHttpClient) ArrayList(java.util.ArrayList) Podcast(de.danoeh.antennapod.adapter.itunes.ItunesAdapter.Podcast) Request(okhttp3.Request) Intent(android.content.Intent) IOException(java.io.IOException) GridView(android.widget.GridView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) Observable(rx.Observable) Response(okhttp3.Response) JSONObject(org.json.JSONObject)

Aggregations

ProgressBar (android.widget.ProgressBar)193 TextView (android.widget.TextView)66 View (android.view.View)63 ImageView (android.widget.ImageView)41 LinearLayout (android.widget.LinearLayout)30 Context (android.content.Context)18 ViewGroup (android.view.ViewGroup)16 WindowManager (android.view.WindowManager)14 FrameLayout (android.widget.FrameLayout)14 Drawable (android.graphics.drawable.Drawable)13 Dialog (android.app.Dialog)12 Button (android.widget.Button)12 RelativeLayout (android.widget.RelativeLayout)12 LayoutInflater (android.view.LayoutInflater)11 SuppressLint (android.annotation.SuppressLint)10 LayoutParams (android.widget.LinearLayout.LayoutParams)9 Intent (android.content.Intent)8 LayoutParams (android.view.ViewGroup.LayoutParams)8 AlertDialog (android.app.AlertDialog)7 TypedArray (android.content.res.TypedArray)7