Пример #1
0
  public void update(final ArrayList<ArrayList<Lyrics>> results) {
    if (getView() == null) return;
    int index = megaListView.getFirstVisiblePosition();
    View v = megaListView.getChildAt(0);
    int top = (v == null) ? 0 : (v.getTop() - megaListView.getPaddingTop());
    lyricsArray = results;

    megaListView.setAdapter(new LocalAdapter(getActivity(), results, mTouchListener, megaListView));
    megaListView.setEmptyView(
        ((ViewGroup) getView().findViewById(R.id.local_empty_database_textview).getParent()));
    getListView().setSelectionFromTop(index, top);
    setListShown(true);
  }
Пример #2
0
 @Override
 public void onActivityCreated(Bundle onSavedInstanceState) {
   super.onActivityCreated(onSavedInstanceState);
   if (megaListView != null) {
     View fragmentView = getView();
     TypedValue typedValue = new TypedValue();
     getActivity().getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true);
     if (fragmentView != null) fragmentView.setBackgroundColor(typedValue.data);
     megaListView.setDividerHeight(0);
     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
       megaListView.setSelector(R.drawable.abc_list_selector_disabled_holo_dark);
     megaListView.setFastScrollEnabled(true);
     megaListView.setDrawSelectorOnTop(true);
   }
 }
Пример #3
0
  public void setListShown(final boolean visible) {
    final Animation fadeIn = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
    final Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
    Animation.AnimationListener listener =
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            progressBar.setVisibility(visible ? View.GONE : View.VISIBLE);
            megaListView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        };
    fadeIn.setAnimationListener(listener);
    fadeOut.setAnimationListener(listener);
    progressBar.startAnimation(visible ? fadeOut : fadeIn);
    megaListView.startAnimation(visible ? fadeIn : fadeOut);
  }
Пример #4
0
 public ExpandableListAdapter getExpandableListAdapter() {
   return megaListView.getExpandableListAdapter();
 }
Пример #5
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    final MainActivity mainActivity = ((MainActivity) this.getActivity());
    super.onViewCreated(view, savedInstanceState);
    if (this.isHidden()) return;

    DrawerAdapter drawerAdapter =
        ((DrawerAdapter) ((ListView) mainActivity.findViewById(R.id.drawer_list)).getAdapter());
    if (drawerAdapter.getSelectedItem() != 1) {
      drawerAdapter.setSelectedItem(1);
      drawerAdapter.notifyDataSetChanged();
    }

    megaListView.setOnGroupClickListener(
        new ExpandableListView.OnGroupClickListener() {

          @Override
          public boolean onGroupClick(
              ExpandableListView parent, View v, int groupPosition, long id) {
            final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator);
            RotateAnimation anim;
            if (megaListView.isGroupExpanded(groupPosition)) {
              megaListView.collapseGroupWithAnimation(groupPosition);
              if (indicator != null) {
                anim =
                    new RotateAnimation(
                        180f, 360f, indicator.getWidth() / 2, indicator.getHeight() / 2);
                anim.setInterpolator(new DecelerateInterpolator(3));
                anim.setDuration(500);
                anim.setFillAfter(true);
                indicator.startAnimation(anim);
              }
            } else {
              megaListView.expandGroupWithAnimation(groupPosition);
              if (indicator != null) {
                anim =
                    new RotateAnimation(
                        0f, 180f, indicator.getWidth() / 2, indicator.getHeight() / 2);
                anim.setInterpolator(new DecelerateInterpolator(2));
                anim.setDuration(500);
                anim.setFillAfter(true);
                indicator.startAnimation(anim);
              }
            }
            return true;
          }
        });

    megaListView.setOnChildClickListener(
        new ExpandableListView.OnChildClickListener() {
          @Override
          public boolean onChildClick(
              ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
            if (mSwiping) {
              mSwiping = false;
              return false;
            }
            final MainActivity mainActivity = (MainActivity) getActivity();
            megaListView.setOnChildClickListener(null); // prevents bug on double tap
            mainActivity.updateLyricsFragment(
                R.animator.slide_out_start,
                R.animator.slide_in_start,
                true,
                lyricsArray.get(groupPosition).get(childPosition));
            return true;
          }
        });

    this.isActiveFragment = true;
    new DBContentLister(this).execute();
  }