Beispiel #1
0
 public void selectCategory(int category_id, boolean forceUpdate) {
   if (mCategoryId != category_id || forceUpdate) {
     mCategoryId = category_id;
     if ((mAdapter = getAdapter(mCategoryId)) == null) {
       mAdapter =
           new MainListAdapter(
               getActivity(),
               AccountManager.getInstance().getAccountsByCategory(mCategoryId),
               Application.getThemedIcons(),
               R.drawable.pb_unknown);
       mListView.postDelayed(
           new Runnable() {
             @Override
             public void run() {
               mAdapter.enableAnimation(false);
             }
           },
           100);
       cacheAdapter(mCategoryId, mAdapter);
     }
     mAdapter.setListener(this);
     mListView.setAdapter(mAdapter);
     mAdapter.notifyDataSetChanged();
     mToBeRemoved = new int[mAdapter.getCount()];
     ((TextView) mListView.getEmptyView()).setText(R.string.no_accounts);
     mCategoryIcon = -1;
     mCategoryName = null;
   }
 }
Beispiel #2
0
 public void setSearch(ArrayList<AccountManager.Account> result) {
   mAdapter =
       new MainListAdapter(
           getActivity(), result, Application.getThemedIcons(), R.drawable.pb_unknown);
   mAdapter.enableAnimation(false);
   mAdapter.setListener(this);
   mListView.setAdapter(mAdapter);
   mAdapter.notifyDataSetChanged();
   mToBeRemoved = new int[mAdapter.getCount()];
   ((TextView) mListView.getEmptyView()).setText(R.string.empty_search);
 }
Beispiel #3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    mListView = (ListView) rootView.findViewById(android.R.id.list);
    if ((mAdapter = getAdapter(mCategoryId)) == null) {
      mAdapter =
          new MainListAdapter(
              getActivity(),
              AccountManager.getInstance().getAccountsByCategory(mCategoryId),
              Application.getThemedIcons(),
              R.drawable.pb_unknown);
      mListView.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              mAdapter.enableAnimation(false);
            }
          },
          100);
      cacheAdapter(mCategoryId, mAdapter);
    }
    mAdapter.setListener(this);
    mListView.setAdapter(mAdapter);
    mListView.setEmptyView(rootView.findViewById(android.R.id.empty));
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);
    mToBeRemoved = new int[mAdapter.getCount()];
    mFab = (ImageButton) rootView.findViewById(R.id.fab);
    mFab.setOnClickListener(this);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
      LayerDrawable background = (LayerDrawable) mFab.getBackground();
      background
          .getDrawable(1)
          .setColorFilter(C.ThemedColors[C.colorAccent], PorterDuff.Mode.SRC_ATOP);
    }
    if (!getResources().getBoolean(R.bool.snackbar_left_align)) {
      mFabToPush = (int) (getResources().getDimension(R.dimen.snackbar_height_single) + 0.5f);
    } else {
      mFabToPush = 0;
    }
    mCategoryEditView = rootView.findViewById(R.id.category_editor);
    EditText editCategoryName = (EditText) rootView.findViewById(R.id.category_name);
    editCategoryName.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {
            if (mActionMode != null) {
              mCategoryName = s.toString();
              mCategorySavable = mCategoryName.length() > 0;
              mActionMode.invalidate();
            }
          }
        });
    if (mIsEditing) {
      mIsEditing = false;
      editCategory();
    } else if (mSelectionMode) {
      mActionMode = ((MainActivity) getActivity()).startSupportActionMode(mActionModeCallback);
    }
    return rootView;
  }