Notes
Notes - notes.io |
@Inject
Context context;
@Inject
ViewModelFactory factory;
FragmentDashboardBinding binding;
DatePickerDialog datePickerDialog;
private DashboardViewModel dashboardViewModel;
private PrakarViewModel prakarViewModel;
private String[] fiscalYears = {"०७५/७६", "२०७६/७७", "२०७७/२०७८", "२०७८/२०७९", "२०७९/२०८०"};
private String[] months = {"बैशाख", "जेठ", "आषाढ", "साउन", "भाद्र", "आश्विन", "कार्तिक", "मंसिर", "पौष", "माघ", "फागुन", "चैत्र"};
private String[] group = {"आजको", "हिजोको", "अस्तिको"};
public DashboardFragment() {
}
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_dashboard, container, false);
dashboardViewModel = new ViewModelProvider(this, factory).get(DashboardViewModel.class);
prakarViewModel = new ViewModelProvider(this, factory).get(PrakarViewModel.class);
binding.setViewModel(dashboardViewModel);
// binding.setViewModel(prakarViewModel);
// binding.wada1.setOnClickListener(v -> {
// Dialog dialog = new Dialog(Objects.requireNonNull(getActivity()));
// dialog.setContentView(R.layout.fragment_popup);
// dialog.show();
//
//
// });
binding.calender.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String date = "2076/12/13";
String parts[] = date.split("/");
final Calendar calen = Calendar.getInstance();
int day = calen.get(Calendar.DAY_OF_MONTH);
int month = calen.get(Calendar.MONTH);
int year = calen.get(Calendar.YEAR);
int days = Integer.parseInt(parts[0]);
int months = Integer.parseInt(parts[1]);
int years = Integer.parseInt(parts[2]);
calen.set(Calendar.YEAR, years);
calen.set(Calendar.MONTH, (months - 1));
calen.set(Calendar.DAY_OF_MONTH, days);
datePickerDialog = new DatePickerDialog(getContext(), (datePicker, year1, month1, day1) -> {
binding.text2.setText(year1 + "/" + (month1 + 1) + "/" + day1);
}, year, month, day);
datePickerDialog.show();
}
});
dashboardViewModel.getYearlyReport().observe(getViewLifecycleOwner(), yearlyData -> {
ArrayList<BarEntry> bivaran = new ArrayList<>();
ArrayList<String> label = new ArrayList<>();
for (int i = 0; i < yearlyData.size(); i++) {
bivaran.add(new BarEntry(i, Integer.parseInt(yearlyData.get(i).getGroups().get(0).getPapers_count()) + Integer.parseInt(yearlyData.get(i).getGroups().get(1).getPapers_count()) + Integer.parseInt(yearlyData.get(i).getGroups().get(2).getPapers_count())));
// bivaran.add(new BarEntry(i, yearlyData.get(0).getGroups().get(0).getTemplates().get(2).getPaper_dates().size() + i));
label.add(yearlyData.get(i).getName());
}
BarDataSet bivaranDataSet = new BarDataSet(bivaran, "वडा अनुसारको जम्मा सिफारिस");
bivaranDataSet.setColors(ColorTemplate.COLORFUL_COLORS);
BarData bivaranData = new BarData(bivaranDataSet);
//bivaranData.setBarWidth(0.9f);
binding.bargraph.animateXY(1000, 1000);
binding.bargraph.getDescription().setEnabled(false);
binding.bargraph.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
//binding.bargraph.getXAxis().setTextSize(10f);
binding.bargraph.setFitBars(true);
//binding.bargraph.setPadding(5, 5, 10, 5);
binding.bargraph.setVisibleXRangeMaximum(6);
binding.bargraph.setMaxVisibleValueCount(6);
binding.bargraph.setDrawBarShadow(false);
binding.bargraph.setPinchZoom(false);
binding.bargraph.setDrawGridBackground(false);
// binding.bargraph.setScaleMinima(3f, binding.bargraph.getScaleY());
//binding.bargraph.setExtraOffsets(5, 10, 5, 27);
binding.bargraph.setData(bivaranData);
XAxis xAxis = binding.bargraph.getXAxis();
xAxis.setCenterAxisLabels(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//xAxis.setLabelRotationAngle(90);
xAxis.setValueFormatter(new IndexAxisValueFormatter(label));
Legend legends = binding.bargraph.getLegend();
legends.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
legends.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
legends.setOrientation(Legend.LegendOrientation.HORIZONTAL);
legends.setXEntrySpace(1f);
legends.setFormToTextSpace(1f);
legends.setFormSize(1f);
xAxis.setGranularity(1);
binding.bargraph.invalidate();
});
ArrayAdapter<String> dayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, group);
dayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
binding.hijokoSpinner.setAdapter(dayAdapter);
// binding.fiscalYearSpinner.setOnItemSelectedListener();
// binding.hijokoSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
//
//
// @Override
// public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// ((TextView) parent.getChildAt(0)).setTextColor(Color.WHITE);
// if (parent.getId() == R.id.hijokoSpinner) {
//
// binding.hijoko.setVisibility(View.VISIBLE);
//
// }
//
// @Override
// public void onNothingSelected(android.widget.AdapterView<?> parent) {
//
// }
//
// });
return binding.getRoot();
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
dashboardViewModel.getYearlyReport().observe(getViewLifecycleOwner(), yearlyData -> {
dashboardViewModel.setChartAdapter(yearlyData);
});
dashboardViewModel.getTemplateReport().observe(getViewLifecycleOwner(), templateReport -> {
dashboardViewModel.setChartPrakarAdapter(templateReport);
});
ArrayAdapter<String> fiscalAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, fiscalYears);
ArrayAdapter<String> monthAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, months);
// dashboardViewModel.getAllYearData().observe(getViewLifecycleOwner(), alldata -> {
// // List<String> yearlydata = new ArrayList<>();
//// for (int i = 0; i < alldata.size(); i++) {
//// yearlydata.add(alldata.get(i).getFiscal_year());
//// }
//
//
//
fiscalAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
binding.fiscalYearSpinner.setAdapter(fiscalAdapter);
binding.monthSpinner.setAdapter(monthAdapter);
binding.monthSpinner.setOnItemSelectedListener(((view, position, id, item) -> {
dashboardViewModel.setMonth(item.toString());
}));
binding.fiscalYearSpinner.setOnItemSelectedListener((view, position, id, item) -> {
Toast.makeText(context, "" + item, Toast.LENGTH_SHORT).show();
dashboardViewModel.setYear(item.toString());
});
// });
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team