Search in sources :

Example 1 with ListReportModel

use of com.ushahidi.android.app.models.ListReportModel in project Ushahidi_Android by ushahidi.

the class CategorySpinnerAdater method refresh.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.ushahidi.android.app.adapters.BaseArrayAdapter#refresh()
	 */
@Override
public void refresh() {
    ListReportModel mListReportModel = new ListReportModel();
    List<CategoryEntity> listCategories = mListReportModel.getParentCategories();
    if (listCategories != null && listCategories.size() > 0) {
        // This is to make room for all categories label
        CategoryEntity cat = new CategoryEntity();
        cat.setCategoryTitle(context.getString(R.string.all_categories));
        cat.setCategoryPosition(0);
        cat.setDbId(0);
        cat.setCategoryId(0);
        cat.setParentId(0);
        cat.setCategoryColor("000000");
        add(cat.getCategoryTitle(), cat);
        for (CategoryEntity category : listCategories) {
            add(category.getCategoryTitle(), category);
            // add child categories
            List<CategoryEntity> listChildrenCategories = mListReportModel.getChildrenCategories(category.getCategoryId());
            if (listChildrenCategories != null && listChildrenCategories.size() > 0) {
                for (CategoryEntity childrenCategories : listChildrenCategories) {
                    add(childrenCategories.getCategoryTitle(), childrenCategories);
                }
            }
        }
    }
}
Also used : ListReportModel(com.ushahidi.android.app.models.ListReportModel) CategoryEntity(com.ushahidi.android.app.entities.CategoryEntity)

Example 2 with ListReportModel

use of com.ushahidi.android.app.models.ListReportModel in project Ushahidi_Android by ushahidi.

the class AddReportActivity method setCheckedCategories.

/**
	 * Get check selected categories
	 * 
	 * @param aSelectedCategories
	 */
private boolean[] setCheckedCategories() {
    // FIXME: Look into making this more efficient
    if (mVectorCategories != null && mVectorCategories.size() > 0) {
        ListReportModel mListReportModel = new ListReportModel();
        List<CategoryEntity> listCategories = mListReportModel.getAllCategories();
        if (listCategories != null && listCategories.size() > 0) {
            int categoryCount = listCategories.size();
            int categoryAmount = 0;
            if (categoryCount > 0) {
                categoryAmount = categoryCount;
            } else {
                categoryAmount = 1;
            }
            boolean[] categories = new boolean[categoryAmount];
            mCategoryLength = categories.length;
            int i = 0;
            for (CategoryEntity category : mListReportModel.getAllCategories()) {
                if (mVectorCategories.contains(String.valueOf(category.getCategoryId()))) {
                    categories[i] = true;
                } else {
                    categories[i] = false;
                }
                i++;
            }
            return categories;
        }
    }
    return null;
}
Also used : ListReportModel(com.ushahidi.android.app.models.ListReportModel) CategoryEntity(com.ushahidi.android.app.entities.CategoryEntity)

Example 3 with ListReportModel

use of com.ushahidi.android.app.models.ListReportModel in project Ushahidi_Android by ushahidi.

the class ViewReportSlideActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReports = new ListReportModel();
    this.mCategoryId = getIntent().getExtras().getInt("category", 0);
    int pos = getIntent().getExtras().getInt("id", 0);
    if (mCategoryId > 0) {
        mReports.loadReportByCategory(mCategoryId);
    } else {
        mReports.load();
    }
    NUM_PAGES = mReports.getReports().size();
    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (MapPager) findViewById(R.id.report_pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // When changing pages, reset the action bar actions since they
            // are dependent
            // on which page is currently active. An alternative approach is
            // to have each
            // fragment expose actions itself (rather than the activity
            // exposing actions),
            // but for simplicity, the activity provides the actions in this one
            supportInvalidateOptionsMenu();
        }
    });
    mPager.setCurrentItem(pos, true);
}
Also used : ListReportModel(com.ushahidi.android.app.models.ListReportModel) ViewPager(android.support.v4.view.ViewPager)

Example 4 with ListReportModel

use of com.ushahidi.android.app.models.ListReportModel in project Ushahidi_Android by ushahidi.

the class ViewReportFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.view_report, container, false);
    mView = new ViewReportView(rootView, getActivity());
    mReports = new ListReportModel();
    mView.mMapView.onCreate(savedInstanceState);
    if (mCategoryId > 0) {
        mReports.loadReportByCategory(mCategoryId);
    } else {
        mReports.load();
    }
    // Get GoogleMap from MapView
    mMap = mView.mMapView.getMap();
    try {
        MapsInitializer.initialize(getActivity());
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
    // Initialize views with report data. This also handles map
    // initialization
    initReport(mPageNumber);
    fetchComments();
    // Set the title view to show the page number.
    mView.setPageIndicator(getString(R.string.title_template_step, mPageNumber + 1, mReports.getReports().size()));
    return rootView;
}
Also used : ViewGroup(android.view.ViewGroup) ListReportModel(com.ushahidi.android.app.models.ListReportModel) ViewReportView(com.ushahidi.android.app.views.ViewReportView) GooglePlayServicesNotAvailableException(com.google.android.gms.common.GooglePlayServicesNotAvailableException)

Example 5 with ListReportModel

use of com.ushahidi.android.app.models.ListReportModel in project Ushahidi_Android by ushahidi.

the class ViewReportFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPageNumber = getArguments().getInt(ARG_PAGE);
    mCategoryId = getArguments().getInt(ARG_CAT_ID);
    mReports = new ListReportModel();
}
Also used : ListReportModel(com.ushahidi.android.app.models.ListReportModel)

Aggregations

ListReportModel (com.ushahidi.android.app.models.ListReportModel)8 CategoryEntity (com.ushahidi.android.app.entities.CategoryEntity)3 Handler (android.os.Handler)1 ViewPager (android.support.v4.view.ViewPager)1 ViewGroup (android.view.ViewGroup)1 GooglePlayServicesNotAvailableException (com.google.android.gms.common.GooglePlayServicesNotAvailableException)1 PopupAdapter (com.ushahidi.android.app.adapters.PopupAdapter)1 ListCommentModel (com.ushahidi.android.app.models.ListCommentModel)1 ViewReportView (com.ushahidi.android.app.views.ViewReportView)1