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);
}
}
}
}
}
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;
}
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);
}
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;
}
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();
}
Aggregations