Exemplo n.º 1
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (Utilities.deviceOnline(context)) buttonRefresh.setVisibility(View.GONE);
    else buttonRefresh.setVisibility(View.VISIBLE);
  }
Exemplo n.º 2
0
  /** Method to get the recent music asynchronously */
  public void getRecentMusic() {
    if (!Utilities.deviceOnline(context) || working) return;

    dismissButtonRefresh();
    showProgressBar();
    deleteItems();

    // starts the thread
    getRecentMusic(0, 30);
  }
Exemplo n.º 3
0
  /** Open MusicPlayerActivity activity */
  private void goToMusicPLayerActivity(int position) {
    if (!Utilities.deviceOnline(context)) {
      Toast.makeText(context.getApplicationContext(), "Not online", Toast.LENGTH_SHORT).show();
      return;
    }

    final Bundle bundle = new Bundle();
    final MusicBean bean = (MusicBean) musicAdapter.getBeanAt(position);

    Intent intent = new Intent(context, MusicPlayerActivity.class);
    bundle.putParcelable("bean", bean);
    intent.putExtra("bean", bundle);

    startActivity(intent);
    getActivity().overridePendingTransition(R.anim.trans_corner_from, R.anim.trans_corner_to);
  }
Exemplo n.º 4
0
  /**
   * Start the filter search asynchronously. The bundle contains alla the users input. We pass all
   * the info to DownloadService service to start to download the images.
   */
  public void startFilterSearch(Bundle bundle) {
    if (!Utilities.deviceOnline(context) || working) return;

    dismissButtonRefresh();

    musicAdapter.setLoadingType(3);
    showProgressBar();
    deleteItems();

    DownloadResultReceiver resultReceiver = new DownloadResultReceiver(new Handler());
    resultReceiver.setReceiver(this);
    Intent intent = new Intent(Intent.ACTION_SYNC, null, context, DownloadService.class);

    // query info
    intent.putExtra(MUSIC_RECEIVER, resultReceiver);
    intent.putExtra(FilterMusicFragment.ARTIST, bundle.getString(FilterMusicFragment.ARTIST));
    intent.putExtra(FilterMusicFragment.TITLE, bundle.getString(FilterMusicFragment.TITLE));
    intent.putExtra(FilterMusicFragment.GENRE, bundle.getString(FilterMusicFragment.GENRE));
    intent.putExtra(FilterMusicFragment.PER_PAGE, bundle.getString(FilterMusicFragment.PER_PAGE));

    getActivity().startService(intent);
  }
Exemplo n.º 5
0
  /** Method to initialize the UI components and to get the recent music. */
  private void compute() {
    buttonRefresh = (RelativeLayout) view.findViewById(R.id.buttonRefreshInternet);

    if (Utilities.deviceOnline(context)) buttonRefresh.setVisibility(View.GONE);

    buttonRefresh.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            if (!Utilities.deviceOnline(context))
              Toast.makeText(
                      context.getApplicationContext(),
                      "There is no internet connection",
                      Toast.LENGTH_SHORT)
                  .show();
            else {
              buttonRefresh.setVisibility(View.GONE);
              getRecentMusic();
            }
          }
        });

    progressBar = (ProgressBar) view.findViewById(R.id.p_bar);
    progressbar_bottom = (ProgressBar) view.findViewById(R.id.p_bar_bottom);
    progressbar_bottom
        .getIndeterminateDrawable()
        .setColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_gallery);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(context);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(llm);
    musicAdapter = new MusicVideoAdapter(context, 1, false);
    recyclerView.setAdapter(musicAdapter);

    // on item click
    musicAdapter.setOnItemClickListener(
        new MusicVideoAdapter.OnItemClickListener() {

          @Override
          public void onItemClick(View view, int position) {

            goToMusicPLayerActivity(position);
          }
        });

    // endless list which loads more data when reaching the bottom of the view
    musicAdapter.setOnBottomListener(
        new MusicVideoAdapter.OnBottomListener() {

          @Override
          public void onBottomLoadMoreData(int loadingType, int loadingPageNumber) {
            progressbar_bottom.setVisibility(View.VISIBLE);

            if (loadingType == 1) getRecentMusic(0, loadingPageNumber);
            else searchMusicByKey(userInput.get(0), userInput.get(1), loadingPageNumber);
          }
        });

    getRecentMusic();
  }