@SuppressLint("NewApi")
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_stickylistheaders, container, false);
    StickyListHeadersListView listView =
        (StickyListHeadersListView) rootView.findViewById(R.id.activity_stickylistheaders_listview);
    listView.setFitsSystemWindows(true);

    AlphaInAnimationAdapter animationAdapter;

    MyStickyListHeadersTravelAdapter adapterTravel =
        new MyStickyListHeadersTravelAdapter(getActivity().getApplicationContext());
    animationAdapter = new AlphaInAnimationAdapter(adapterTravel);

    StickyListHeadersAdapterDecorator stickyListHeadersAdapterDecorator =
        new StickyListHeadersAdapterDecorator(animationAdapter);
    stickyListHeadersAdapterDecorator.setListViewWrapper(
        new StickyListHeadersListViewWrapper(listView));
    assert animationAdapter.getViewAnimator() != null;
    animationAdapter.getViewAnimator().setInitialDelayMillis(500);
    assert stickyListHeadersAdapterDecorator.getViewAnimator() != null;
    stickyListHeadersAdapterDecorator.getViewAnimator().setInitialDelayMillis(500);
    listView.setAdapter(stickyListHeadersAdapterDecorator);

    return rootView;
  }
        @Override
        public void onClick(View v) {
          int colorMode = PrefUtils.getInt(_context, R.string.pref_foreground_color, 0);
          colorMode = (colorMode + 1) % 2;
          int color;
          if (colorMode == 0) {
            color = TEXT_COLOR_DARK;
          } else {
            color = TEXT_COLOR_LIGHT;
          }

          setTextColorConfiguration(_panelView, panelTextIds, color);

          TextView text = (TextView) _panelView.findViewById(R.id.text_title);
          text.setTextColor(color);
          text = (TextView) _panelView.findViewById(R.id.text_artist);
          text.setTextColor(color);

          StickyListHeadersListView list =
              (StickyListHeadersListView) _panelView.findViewById(R.id.list_current_songs);
          OverlaySongInfoListAdapter adapter = (OverlaySongInfoListAdapter) list.getAdapter();
          if (adapter != null) {
            adapter.setTextColor(color);
            adapter.notifyDataSetChanged();
          }

          PrefUtils.setInt(_context, R.string.pref_foreground_color, colorMode);

          startTimeoutTimer();
        }
示例#3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final MyExpenses ctx = (MyExpenses) getActivity();
    if (mAccount == null) {
      TextView tv = new TextView(ctx);
      tv.setText(
          "Error loading transaction list for account " + getArguments().getLong(KEY_ACCOUNTID));
      return tv;
    }
    mManager = getLoaderManager();
    setGrouping();
    setColors();

    View v = inflater.inflate(R.layout.expenses_list, null, false);
    // TODO check if still needed with Appcompat
    // work around the problem that the view pager does not display its background correctly with
    // Sherlock
    if (Build.VERSION.SDK_INT < 11) {
      v.setBackgroundColor(
          ctx.getResources()
              .getColor(
                  MyApplication.PrefKey.UI_THEME_KEY.value("dark").equals("light")
                      ? android.R.color.white
                      : android.R.color.black));
    }
    mListView = (StickyListHeadersListView) v.findViewById(R.id.list);
    setAdapter();
    mListView.setOnHeaderClickListener(this);
    mListView.setDrawingListUnderStickyHeader(false);
    mManager.initLoader(GROUPING_CURSOR, null, this);
    mManager.initLoader(TRANSACTION_CURSOR, null, this);
    mManager.initLoader(SUM_CURSOR, null, this);
    // Now create a simple cursor adapter and set it to display

    mListView.setEmptyView(v.findViewById(R.id.empty));
    mListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            FragmentManager fm = ctx.getSupportFragmentManager();
            DialogFragment f = (DialogFragment) fm.findFragmentByTag("TRANSACTION_DETAIL");
            if (f == null) {
              FragmentTransaction ft = getFragmentManager().beginTransaction();
              ft.add(TransactionDetailFragment.newInstance(id), "TRANSACTION_DETAIL");
              ft.commitAllowingStateLoss();
            }
          }
        });
    registerForContextualActionBar(mListView.getWrappedList());
    return v;
  }
  public void setListInformation(SongInfoList info) {
    StickyListHeadersListView list =
        (StickyListHeadersListView) _panelView.findViewById(R.id.list_current_songs);
    OverlaySongInfoListAdapter adapter = (OverlaySongInfoListAdapter) list.getAdapter();
    if (adapter == null || adapter.isChanged(info)) {

      if (adapter != null) {
        adapter.clearArtworkCache();
      }

      adapter = new OverlaySongInfoListAdapter(_context, info, _onListItemClickListener);
      list.setAdapter(adapter);
      adapter.notifyDataSetChanged();
    }
  }
示例#5
0
 @SuppressLint("NewApi")
 public void onDrawerOpened() {
   if (mActionMode != null) {
     mCheckedListItems = mListView.getWrappedList().getCheckedItemPositions().clone();
     mActionMode.finish();
   }
 }
  private void initEvents() {
    final String eventsJson = JsonUtils.loadJsonFromAsset(this, "events.json");
    final Gson gson = new Gson();
    final Response response = gson.fromJson(eventsJson, Response.class);

    mEventsAdapter = new EventsAdapter(this, R.layout.cell_event, response.getEvents());
    mEventsList.setAdapter(mEventsAdapter);
    mEventsList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(
              final AdapterView<?> parent, final View view, final int position, final long id) {
            selectDate(mEventsAdapter.getItem(position).getDate());
          }
        });
  }
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   switch (buttonView.getId()) {
     case R.id.sticky_checkBox:
       stickyList.setAreHeadersSticky(isChecked);
       break;
     case R.id.fade_checkBox:
       fadeHeader = isChecked;
       break;
     case R.id.draw_behind_checkBox:
       stickyList.setDrawingListUnderStickyHeader(isChecked);
       break;
     case R.id.fast_scroll_checkBox:
       stickyList.setFastScrollEnabled(isChecked);
       stickyList.setFastScrollAlwaysVisible(isChecked);
       break;
   }
 }
示例#8
0
 public void onDrawerClosed() {
   if (mCheckedListItems != null) {
     for (int i = 0; i < mCheckedListItems.size(); i++) {
       if (mCheckedListItems.valueAt(i)) {
         mListView.getWrappedList().setItemChecked(mCheckedListItems.keyAt(i), true);
       }
     }
   }
   mCheckedListItems = null;
 }
示例#9
0
  private void setAdapter() {
    Context ctx = getActivity();
    // Create an array to specify the fields we want to display in the list
    String[] from = new String[] {KEY_LABEL_MAIN, KEY_DATE, KEY_AMOUNT};

    // and an array of the fields we want to bind those fields to
    int[] to = new int[] {R.id.category, R.id.date, R.id.amount};
    mAdapter = new MyGroupedAdapter(ctx, R.layout.expense_row, null, from, to, 0);
    mListView.setAdapter(mAdapter);
  }
示例#10
0
 @Override
 protected void configureMenu11(Menu menu, int count) {
   super.configureMenu11(menu, count);
   if (count == 1) {
     SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions();
     for (int i = 0; i < checkedItemPositions.size(); i++) {
       if (checkedItemPositions.valueAt(i)) {
         configureMenuInternal(menu, checkedItemPositions.keyAt(i));
         break;
       }
     }
   }
 }
示例#11
0
  @Override
  public View onCreateView(
      final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout._artist_tab_profile_fragment, container, false);

    setHasOptionsMenu(true);

    mAdapter = new ShowProfileAdapter(getActivity(), header, body);

    stickyList = (StickyListHeadersListView) view.findViewById(R.id.listProfileShowMan);
    stickyList.setOnItemClickListener(this);
    stickyList.setOnHeaderClickListener(this);
    stickyList.setOnStickyHeaderChangedListener(this);
    stickyList.setOnStickyHeaderOffsetChangedListener(this);

    View headerView = getActivity().getLayoutInflater().inflate(R.layout.list_header, null);
    ImageView imageView = (ImageView) headerView.findViewById(R.id.imageViewShowMan);
    imageView.setImageResource(R.mipmap.ic_launcher);
    stickyList.addHeaderView(headerView);
    //        stickyList.addFooterView(getLayoutInflater().inflate(R.layout.list_footer, null));
    //        stickyList.setEmptyView(findViewById(R.id.empty));
    stickyList.setDrawingListUnderStickyHeader(true);
    stickyList.setAreHeadersSticky(true);
    stickyList.setAdapter(mAdapter);

    stickyList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 11) {
              Intent intent = new Intent(getActivity(), ShowFeedbacks.class);
              startActivity(intent);
              getActivity().overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
            }
          }
        });

    return view;
  }
  public OverlayViewManager(Context context) {
    _context = context;
    _windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    _timeoutHandler = new Handler();

    Resources resources = _context.getResources();
    TEXT_COLOR_DARK = resources.getColor(R.color.overlay_title_dark);
    TEXT_COLOR_LIGHT = resources.getColor(R.color.overlay_title_light);

    _panelParams =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    _panelParams.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;

    _openParams =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    _openParams.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final int[] panelButtonIds =
        new int[] {
          R.id.image_artwork,
          R.id.button_hide,
          R.id.button_track_down,
          R.id.button_play_or_pause,
          R.id.button_track_up,
          R.id.button_stop,
          R.id.button_open_close_list,
        };
    final View.OnClickListener[] panelListeners =
        new View.OnClickListener[] {
          _onArtworkClickListener,
          _onHideClickListener,
          _onTrackDownClickListener,
          _onPlayPauseClickListener,
          _onTrackUpClickListener,
          _onStopClickListener,
          _onOpenCloseListClickListener,
        };
    _panelView = inflater.inflate(R.layout.overlay_play_panel, null);
    setupButtonListener(_panelView, panelButtonIds, panelListeners);

    setupPlayPauseButton(_panelView, false);

    View layout = _panelView.findViewById(R.id.layout_panel);
    layout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            startTimeoutTimer();
            return false;
          }
        });
    int defaultColor = _context.getResources().getColor(R.color.overlay_panel_background);
    int color = PrefUtils.getInt(_context, R.string.pref_background_color, defaultColor);
    layout.setBackgroundColor(color);

    StickyListHeadersListView list =
        (StickyListHeadersListView) _panelView.findViewById(R.id.list_current_songs);
    list.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            startTimeoutTimer();
            return false;
          }
        });
    list.setDrawingListUnderStickyHeader(false);

    SeekBar bar = (SeekBar) _panelView.findViewById(R.id.seekbar_position);
    bar.setTag(R.id.tag_is_dragging, false);
    bar.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            seekBar.setTag(R.id.tag_is_dragging, false);
            startTimeoutTimer();

            Intent intent = new Intent(_context, OverlayMusicPlayerService.class);
            intent.setAction(OverlayMusicPlayerService.ACTION_SEEK);
            intent.putExtra(OverlayMusicPlayerService.PRM_SEEK_TIME, seekBar.getProgress());
            _context.startService(intent);
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            seekBar.setTag(R.id.tag_is_dragging, true);
            stopTimeoutTimer();
          }

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
              TextView time = (TextView) _panelView.findViewById(R.id.text_position);
              time.setText(TimecodeUtils.format(progress));
            }
          }
        });

    int colorMode = PrefUtils.getInt(_context, R.string.pref_foreground_color, 0);
    if (colorMode == 0) {
      color = TEXT_COLOR_DARK;
    } else {
      color = TEXT_COLOR_LIGHT;
    }
    setTextColorConfiguration(_panelView, panelTextIds, color);

    final int[] openButtonIds =
        new int[] {
          R.id.button_open,
        };
    final View.OnClickListener[] openlListeners =
        new View.OnClickListener[] {
          _onOpenClickListener,
        };
    _openView = inflater.inflate(R.layout.overlay_open_button, null);
    setupButtonListener(_openView, openButtonIds, openlListeners);

    layout = _openView.findViewById(R.id.layout_open);
    layout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            View view = _openView.findViewById(R.id.button_open);
            int visiblity = view.getVisibility();
            if (visiblity != View.VISIBLE) {
              view.setVisibility(View.VISIBLE);
            }

            startTimeoutTimer();

            return false;
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
    refreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            new Handler()
                .postDelayed(
                    new Runnable() {
                      @Override
                      public void run() {
                        refreshLayout.setRefreshing(false);
                      }
                    },
                    1000);
          }
        });

    mAdapter = new TestBaseAdapter(this);

    stickyList = (StickyListHeadersListView) findViewById(R.id.list);
    stickyList.setOnItemClickListener(this);
    stickyList.setOnHeaderClickListener(this);
    stickyList.setOnStickyHeaderChangedListener(this);
    stickyList.setOnStickyHeaderOffsetChangedListener(this);
    stickyList.addHeaderView(getLayoutInflater().inflate(R.layout.list_header, null));
    stickyList.addFooterView(getLayoutInflater().inflate(R.layout.list_footer, null));
    stickyList.setEmptyView(findViewById(R.id.empty));
    stickyList.setDrawingListUnderStickyHeader(true);
    stickyList.setAreHeadersSticky(true);
    stickyList.setAdapter(mAdapter);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */);

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    restoreButton = (Button) findViewById(R.id.restore_button);
    restoreButton.setOnClickListener(buttonListener);
    openExpandableListButton = (Button) findViewById(R.id.open_expandable_list_button);
    openExpandableListButton.setOnClickListener(buttonListener);
    updateButton = (Button) findViewById(R.id.update_button);
    updateButton.setOnClickListener(buttonListener);
    clearButton = (Button) findViewById(R.id.clear_button);
    clearButton.setOnClickListener(buttonListener);

    stickyCheckBox = (CheckBox) findViewById(R.id.sticky_checkBox);
    stickyCheckBox.setOnCheckedChangeListener(checkBoxListener);
    fadeCheckBox = (CheckBox) findViewById(R.id.fade_checkBox);
    fadeCheckBox.setOnCheckedChangeListener(checkBoxListener);
    drawBehindCheckBox = (CheckBox) findViewById(R.id.draw_behind_checkBox);
    drawBehindCheckBox.setOnCheckedChangeListener(checkBoxListener);
    fastScrollCheckBox = (CheckBox) findViewById(R.id.fast_scroll_checkBox);
    fastScrollCheckBox.setOnCheckedChangeListener(checkBoxListener);

    stickyList.setStickyHeaderTopOffset(-20);
  }