Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
  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());
          }
        });
  }
Ejemplo n.º 4
0
  @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);
  }