Android Open Source - utexas-utilities Transaction Adapter






From Project

Back to project page utexas-utilities.

License

The source code is released under:

Apache License

If you think the Android project utexas-utilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nasageek.utexasutilities.adapters;
/*w w  w. j  a  v  a2 s  .c  o  m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.foound.widget.AmazingAdapter;
import com.nasageek.utexasutilities.R;
import com.nasageek.utexasutilities.fragments.TransactionsFragment;
import com.nasageek.utexasutilities.model.Transaction;

import java.util.ArrayList;

public class TransactionAdapter extends AmazingAdapter {
    private Context con;
    private ArrayList<Boolean> areHeaders;
    private ArrayList<Transaction> transactions;
    private LayoutInflater li;
    private String currentDate;
    boolean isSectionHeader;
    private TransactionsFragment frag;

    public TransactionAdapter(Context c, TransactionsFragment frag,
            ArrayList<Transaction> transactions) {
        con = c;
        this.transactions = transactions;
        this.frag = frag;
        areHeaders = new ArrayList<Boolean>();
        li = (LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        // just call updateHeaders() here? Did I duplicate this for a reason?
        for (int i = 0; i < transactions.size(); i++) {
            String date = transactions.get(i).getDate();
            if (i == 0) {
                currentDate = date;
                areHeaders.add(true);
            } else if (currentDate.equals(date)) {
                areHeaders.add(false);
            } else {
                areHeaders.add(true);
                currentDate = date;
            }
        }
    }

    @Override
    public int getCount() {
        return transactions.size();
    }

    @Override
    public Object getItem(int position) {
        return transactions.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public boolean areAllItemsEnabled() {
        return true;
    }

    @Override
    public boolean isEnabled(int i) {
        return false;
    }

    // TODO: fix crash on refresh when in the middle of a scroll
    @Override
    public View getAmazingView(int position, View convertView, ViewGroup parent) {

        /*
         * if(position == transactions.size() - 1) return new View(con);
         */
        Transaction trans = transactions.get(position);

        String date = trans.getDate();
        String reason = "\t" + trans.getReason();
        String cost = trans.getCost();

        ViewGroup lin = (ViewGroup) convertView;

        if (areHeaders.size() == transactions.size() && areHeaders.get(position)) {
            lin = (ViewGroup) li.inflate(R.layout.trans_item_header_view, null, false);
            TextView dateview = (TextView) lin.findViewById(R.id.list_item_section_text);
            dateview.setText(date);
        } else {
            lin = (ViewGroup) li.inflate(R.layout.trans_item_view, null, false);
        }

        TextView left = (TextView) lin.findViewById(R.id.itemview);
        left.setText(reason);
        TextView right = (TextView) lin.findViewById(R.id.costview);
        right.setText(cost);

        return lin;
    }

    public void updateHeaders() {
        areHeaders.clear();
        for (int i = 0; i < transactions.size(); i++) {
            String date = transactions.get(i).getDate();
            if (i == 0) {
                currentDate = date;
                areHeaders.add(true);
            } else if (currentDate.equals(date)) {
                areHeaders.add(false);
            } else {
                areHeaders.add(true);
                currentDate = date;
            }
        }
    }

    @Override
    protected View getLoadingView(ViewGroup parent) {
        if (con != null) {
            LayoutInflater inflater = (LayoutInflater) con
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            return inflater.inflate(R.layout.loading_content_layout, parent, false);
        } else {
            return new View(con);
        }
    }

    @Override
    protected void onNextPageRequested(int page) {

        if (super.automaticNextPageLoading) {
            nextPage();
            // Log.d("TransactionAdapter","Page requested!");
            frag.parser(false);
        }
        super.automaticNextPageLoading = false;
    }

    @Override
    protected void bindSectionHeader(View view, int position, boolean displaySectionHeader) {
        return;
    }

    @Override
    public void configurePinnedHeader(View header, int position, int alpha) {
        return;
    }

    @Override
    public int getPositionForSection(int section) {
        return 0;
    }

    @Override
    public int getSectionForPosition(int position) {
        return 0;
    }

    @Override
    public String[] getSections() {
        return null;
    }

}




Java Source Code List

com.google.maps.android.ui.MyIconGenerator.java
com.mapsaurus.paneslayout.ActivityDelegate.java
com.mapsaurus.paneslayout.FragmentLauncher.java
com.mapsaurus.paneslayout.MenuItemWrapper.java
com.mapsaurus.paneslayout.MySlidingPaneLayout.java
com.mapsaurus.paneslayout.PanesActivity.java
com.mapsaurus.paneslayout.PanesLayout.java
com.mapsaurus.paneslayout.PanesSizer.java
com.mapsaurus.paneslayout.PhoneDelegate.java
com.mapsaurus.paneslayout.SimpleScrollView.java
com.mapsaurus.paneslayout.TabletDelegate.java
com.nasageek.utexasutilities.AsyncTask.java
com.nasageek.utexasutilities.AttachmentDownloadService.java
com.nasageek.utexasutilities.AuthCookie.java
com.nasageek.utexasutilities.BlackboardDashboardXmlParser.java
com.nasageek.utexasutilities.BuildingDatabase.java
com.nasageek.utexasutilities.BuildingProvider.java
com.nasageek.utexasutilities.BuildingSaxHandler.java
com.nasageek.utexasutilities.ChangeLog.java
com.nasageek.utexasutilities.ChangeableContextTask.java
com.nasageek.utexasutilities.CourseMapSaxHandler.java
com.nasageek.utexasutilities.FixedListPreference.java
com.nasageek.utexasutilities.LoginWebViewClient.java
com.nasageek.utexasutilities.MarkerManager.java
com.nasageek.utexasutilities.MyPair.java
com.nasageek.utexasutilities.MyScrollView.java
com.nasageek.utexasutilities.PlacemarkSaxHandler.java
com.nasageek.utexasutilities.PnaAuthCookie.java
com.nasageek.utexasutilities.RouteSaxHandler.java
com.nasageek.utexasutilities.SecurePreferences.java
com.nasageek.utexasutilities.TempLoginException.java
com.nasageek.utexasutilities.UTilitiesApplication.java
com.nasageek.utexasutilities.UtdAuthCookie.java
com.nasageek.utexasutilities.Utility.java
com.nasageek.utexasutilities.WrappedViewPager.java
com.nasageek.utexasutilities.WrappingSlidingDrawer.java
com.nasageek.utexasutilities.activities.AboutMeActivity.java
com.nasageek.utexasutilities.activities.BalanceActivity.java
com.nasageek.utexasutilities.activities.BlackboardPanesActivity.java
com.nasageek.utexasutilities.activities.CampusMapActivity.java
com.nasageek.utexasutilities.activities.DataUsageActivity.java
com.nasageek.utexasutilities.activities.LoginActivity.java
com.nasageek.utexasutilities.activities.MenuActivity.java
com.nasageek.utexasutilities.activities.NutritionInfoActivity.java
com.nasageek.utexasutilities.activities.Preferences.java
com.nasageek.utexasutilities.activities.ScheduleActivity.java
com.nasageek.utexasutilities.activities.UTilitiesActivity.java
com.nasageek.utexasutilities.adapters.BBClassAdapter.java
com.nasageek.utexasutilities.adapters.CourseMapAdapter.java
com.nasageek.utexasutilities.adapters.MultiPanePagerAdapter.java
com.nasageek.utexasutilities.adapters.MyFragmentPagerAdapter.java
com.nasageek.utexasutilities.adapters.ScheduleClassAdapter.java
com.nasageek.utexasutilities.adapters.TransactionAdapter.java
com.nasageek.utexasutilities.fragments.ActionModeFragment.java
com.nasageek.utexasutilities.fragments.BlackboardAnnouncementsFragment.java
com.nasageek.utexasutilities.fragments.BlackboardCourseListFragment.java
com.nasageek.utexasutilities.fragments.BlackboardCourseMapFragment.java
com.nasageek.utexasutilities.fragments.BlackboardDashboardFragment.java
com.nasageek.utexasutilities.fragments.BlackboardDownloadableItemFragment.java
com.nasageek.utexasutilities.fragments.BlackboardExternalItemFragment.java
com.nasageek.utexasutilities.fragments.BlackboardFragment.java
com.nasageek.utexasutilities.fragments.BlackboardGradesFragment.java
com.nasageek.utexasutilities.fragments.BlackboardPagerFragment.java
com.nasageek.utexasutilities.fragments.CourseScheduleFragment.java
com.nasageek.utexasutilities.fragments.DatePickerFragment.java
com.nasageek.utexasutilities.fragments.DoubleDatePickerDialogFragment.java
com.nasageek.utexasutilities.fragments.ExamScheduleFragment.java
com.nasageek.utexasutilities.fragments.MenuFragment.java
com.nasageek.utexasutilities.fragments.NutritionInfoFragment.java
com.nasageek.utexasutilities.fragments.PickCalendarDialogFragment.java
com.nasageek.utexasutilities.fragments.TransactionsFragment.java
com.nasageek.utexasutilities.model.BBClass.java
com.nasageek.utexasutilities.model.Building.java
com.nasageek.utexasutilities.model.Classtime.java
com.nasageek.utexasutilities.model.CourseMapItem.java
com.nasageek.utexasutilities.model.FeedItem.java
com.nasageek.utexasutilities.model.Placemark.java
com.nasageek.utexasutilities.model.Transaction.java
com.nasageek.utexasutilities.model.UTClass.java
com.viewpagerindicator.MyTabPageIndicator.java