title: Creating a Circle ProgressBar
body: <p>I have an app which loads feeds from a webservice. Uuntil the feed is loaded I show a Dialog saying "please wait...".
  I want to show a <em>Circle ProgressBar</em> instead.</p>
  
  <p>What I am showing
  <img src="https://i.stack.imgur.com/G3viu.png" alt="current"></p>
  
  <p>What I want to show
  <img src="https://i.stack.imgur.com/4LBLx.png" alt="desired"></p>
  
  <pre><code>public class M {
      static ProgressDialog pDialog;
      private static SharedPreferences mSharedPreferences;
  
      public static void showLoadingDialog(Context mContext) {
          pDialog = new ProgressDialog(mContext);
          pDialog.setMessage(mContext.getString(R.string.please_wait));
          pDialog.setIndeterminate(true);
          pDialog.setCancelable(true);
          pDialog.show();
      }
  }
  </code></pre>
  
  <p>Activity that shows that Progress Dialog</p>
  
  <pre><code>public class HomeFragment extends Fragment implements OnClickListener {
      public RecyclerView postsList;
      public View mView;
      public FloatingActionButton mFabButton;
      public Toolbar toolbar;
      public Intent mIntent;
      public LinearLayoutManager layoutManager;
      int currentPage = 1;
      private HomeListAdapter mHomeListAdapter;
  
      private SwipeRefreshLayout mSwipeRefreshLayout;
  
      private CacheManager mCacheManager;
      private Gson mGson;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          mCacheManager = CacheManager.getInstance(getActivity().getApplicationContext());
          mGson = new Gson();
  
          mView = inflater.inflate(R.layout.fragment_home, container, false);
          initializeView();
          ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.title_home);
          ((AppCompatActivity) getActivity()).getSupportActionBar().setShowHideAnimationEnabled(true);
          getPosts(true);
          return mView;
      }
  
      private void initializeView() {
          postsList = (RecyclerView) mView.findViewById(R.id.postsList);
          mFabButton = (FloatingActionButton) mView.findViewById(R.id.fabButton);
          mFabButton.setOnClickListener(this);
          mFabButton.setRippleColor(getActivity().getResources().getColor(R.color.accentColor));
          //layout manager
          layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
          layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
          postsList.setLayoutManager(layoutManager);
          mHomeListAdapter = new HomeListAdapter(getActivity(), new ArrayList&lt;PostsItem&gt;());
          postsList.setAdapter(mHomeListAdapter);
          mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipeHome);
  
          mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
  
              @Override
              public void onRefresh() {
                  setCurrentPage(1);
                  getPosts(false);
              }
          });
          //setting up our OnScrollListener
          postsList.addOnScrollListener(new HidingScrollListener(layoutManager) {
              @Override
              public void onHide() {
                  FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFabButton.getLayoutParams();
                  int fabBottomMargin = lp.bottomMargin;
                  mFabButton.animate().translationY(mFabButton.getHeight() + fabBottomMargin).setInterpolator(new AccelerateInterpolator(2)).start();
              }
  
              @Override
              public void onShow() {
                  mFabButton.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
              }
  
              @Override
              public void onLoadMore(int currentPage) {
  
                  setCurrentPage(currentPage);
                  getPosts(false);
              }
          });
      }
  
      @Override
      public void onDestroy() {
          super.onResume();
          M.hideLoadingDialog();
      }
  
      public void getPosts(boolean isMain) {
  
          if (M.isNetworkAvailable(getActivity().getApplicationContext())) {
              if (isMain) {
  
                  M.showLoadingDialog(getActivity());
              }
              PostsAPI mPostsAPI = APIService.createService(PostsAPI.class, M.getToken(getActivity()));
              mPostsAPI.getPosts(getCurrentPage(), new Callback&lt;List&lt;PostsItem&gt;&gt;() {
                  @Override
                  public void success(List&lt;PostsItem&gt; postsItems, retrofit.client.Response response) {
                      if (postsItems.size() == 0) {
  
                      } else {
                          try {
                              mCacheManager.write(mGson.toJson(postsItems), "Posts-" + getCurrentPage() + ".json");
                          } catch (Exception e) {
                              e.printStackTrace();
                          }
                      }
                      updateView(postsItems);
                  }
  
                  @Override
                  public void failure(RetrofitError error) {
                      M.T(getActivity(), getString(R.string.ServerError));
                      M.hideLoadingDialog();
                  }
              });
  
          } else {
              try {
                  String Posts = mCacheManager.readString("Posts-" + getCurrentPage() + ".json");
                  Gson mgson = new Gson();
                  updateView((List&lt;PostsItem&gt;) mgson.fromJson(Posts, new TypeToken&lt;List&lt;PostsItem&gt;&gt;() {
                  }.getType()));
  
              } catch (Exception e) {
  //                M.L(e.getMessage());
              }
          }
      }
  
      private void showWelcomeMessage() {
          mView.findViewById(R.id.welcomePanel).setVisibility(View.VISIBLE);
          postsList.setVisibility(View.GONE);
      }
  
      private void updateView(List&lt;PostsItem&gt; postsItems) {
  
          if (getCurrentPage() != 1) {
              List&lt;PostsItem&gt; oldItems = mHomeListAdapter.getPosts();
              if (oldItems.size() == 0 &amp;&amp; postsItems.size() == 0) {
                  showWelcomeMessage();
              }
              oldItems.addAll(postsItems);
              mHomeListAdapter.setPosts(oldItems);
          } else {
              if (postsItems.size() == 0) {
                  showWelcomeMessage();
              }
              mHomeListAdapter.setPosts(postsItems);
          }
          if (mSwipeRefreshLayout.isRefreshing()) {
              mSwipeRefreshLayout.setRefreshing(false);
          }
          M.hideLoadingDialog();
      }
  
      @Override
      public void onClick(View v) {
          if (v.getId() == R.id.fabButton) {
              mIntent = new Intent(getActivity(), PublishActivity.class);
              startActivity(mIntent);
          }
      }
  
      public int getCurrentPage() {
          return currentPage;
      }
  
      public void setCurrentPage(int currentPage) {
          this.currentPage = currentPage;
      }
  }
  </code></pre>