mirror of
https://github.com/hmalik144/DaysLeft.git
synced 2025-12-10 03:05:29 +00:00
25/06 version
This commit is contained in:
4
.idea/assetWizardSettings.xml
generated
4
.idea/assetWizardSettings.xml
generated
@@ -23,7 +23,7 @@
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_sort_black_24dp.xml" />
|
||||
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_filter_list_black_24dp.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
@@ -34,7 +34,7 @@
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="ffffff" />
|
||||
<entry key="outputName" value="ic_sort_black_24dp" />
|
||||
<entry key="outputName" value="ic_filter_list_black_24dp" />
|
||||
<entry key="sourceFile" value="C:\Users\h_mal" />
|
||||
</map>
|
||||
</option>
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AddItemActivity extends AppCompatActivity {
|
||||
fragmentTransaction.replace(R.id.container,addTaskFragment).addToBackStack("Task").commit();
|
||||
}
|
||||
|
||||
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar2);
|
||||
ProgressBar progressBar = findViewById(R.id.progressBar2);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
|
||||
|
||||
@@ -2,43 +2,28 @@ package com.appttude.h_mal.days_left.AddItems;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.media.tv.TvContract;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationSet;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
||||
import com.appttude.h_mal.days_left.Global.DateDialog;
|
||||
import com.appttude.h_mal.days_left.Global.FirebaseClass;
|
||||
@@ -51,17 +36,9 @@ import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.database.DataSnapshot;
|
||||
import com.google.firebase.database.DatabaseError;
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
import com.google.firebase.database.FirebaseDatabase;
|
||||
import com.google.firebase.database.ValueEventListener;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.EMPLOYER_FIREBASE;
|
||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.PIECE;
|
||||
@@ -72,7 +49,6 @@ import static com.appttude.h_mal.days_left.Global.FirebaseClass.USER_FIREBASE;
|
||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.auth;
|
||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.getDateTimeString;
|
||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.mDatabase;
|
||||
import static com.appttude.h_mal.days_left.MainActivity.Epoch2DateTimes;
|
||||
|
||||
|
||||
public class AddShiftActivity extends AppCompatActivity {
|
||||
@@ -469,8 +445,8 @@ public class AddShiftActivity extends AppCompatActivity {
|
||||
|
||||
currentTag = "start";
|
||||
|
||||
startTimeTextView = view.findViewById(R.id.start_time);
|
||||
finishTimeTextView = view.findViewById(R.id.finish_time);
|
||||
startTimeTextView = view.findViewById(R.id.from_date);
|
||||
finishTimeTextView = view.findViewById(R.id.to_date);
|
||||
timePickerTimePicker = view.findViewById(R.id.time_picker);
|
||||
breakEditText = view.findViewById(R.id.breaktime);
|
||||
TextView okText = view.findViewById(R.id.ok);
|
||||
@@ -540,8 +516,6 @@ public class AddShiftActivity extends AppCompatActivity {
|
||||
toggleTextButtons(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (timeString != null){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
timePickerTimePicker.setHour(getTime(timeString)[0]);
|
||||
|
||||
@@ -52,12 +52,7 @@ public class AssociatedTasksClass implements ValueEventListener {
|
||||
DialogListAdapter dialogListAdapter = new DialogListAdapter(activity,taskObjects);
|
||||
listView.setAdapter(dialogListAdapter);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(dialogView);
|
||||
@@ -65,6 +60,14 @@ public class AssociatedTasksClass implements ValueEventListener {
|
||||
final AlertDialog alertDialog = builder.create();
|
||||
alertDialog.show();
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity();
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
package com.appttude.h_mal.days_left.AddItems;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
||||
import com.appttude.h_mal.days_left.R;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import static com.appttude.h_mal.days_left.MainActivity.Epoch2DateString;
|
||||
import static com.appttude.h_mal.days_left.MainActivity.Epoch2DateTimes;
|
||||
|
||||
public class InsertTimeDialog{
|
||||
|
||||
Context context;
|
||||
@@ -75,8 +64,8 @@ public class InsertTimeDialog{
|
||||
public AlertDialog.Builder setView(View view) {
|
||||
view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search_employer, null);
|
||||
|
||||
startTimeTextView = view.findViewById(R.id.start_time);
|
||||
finishTimeTextView = view.findViewById(R.id.finish_time);
|
||||
startTimeTextView = view.findViewById(R.id.from_date);
|
||||
finishTimeTextView = view.findViewById(R.id.to_date);
|
||||
timePickerTimePicker = view.findViewById(R.id.time_picker);
|
||||
// breakEditText = view.findViewById(R.id.breaktime);
|
||||
|
||||
|
||||
@@ -73,19 +73,19 @@ public class PreviouslyUsedItemsClass implements ValueEventListener {
|
||||
AbnListAdapter abnListAdapter = new AbnListAdapter(activity,abnObjectArrayList);
|
||||
listView.setAdapter(abnListAdapter);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity();
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(dialogView);
|
||||
|
||||
final AlertDialog alertDialog = builder.create();
|
||||
alertDialog.show();
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity();
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.widget.ProgressBar;
|
||||
|
||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
||||
import com.appttude.h_mal.days_left.Global.FirebaseClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@@ -109,10 +110,19 @@ public class SearchAsyncTask extends AsyncTask<URL,Void,String>{
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
AbnObject currentAbnObject = abnObjectArrayList.get(position);
|
||||
|
||||
Intent returnIntent = new Intent();
|
||||
final Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra("AbnObject",currentAbnObject);
|
||||
activity.setResult(Activity.RESULT_OK,returnIntent);
|
||||
activity.finish();
|
||||
new FirebaseClass().newAbnEntry(currentAbnObject.getAbn(), new FirebaseClass.matchListener() {
|
||||
@Override
|
||||
public void abnMatch(Boolean confirm) {
|
||||
if (!confirm){
|
||||
//push to server
|
||||
}else {
|
||||
activity.setResult(Activity.RESULT_OK,returnIntent);
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}else if (abnObjectArrayList == null){
|
||||
|
||||
@@ -41,9 +41,14 @@ public class CustomValueEventListener implements ValueEventListener {
|
||||
shiftsMap.put(postSnapshot.getKey(),postSnapshot.getValue(ShiftObject.class));
|
||||
}
|
||||
|
||||
// shiftObjectArrayList.stream().filter()
|
||||
|
||||
if (shiftObjectArrayList.size() > 0){
|
||||
if (fragmentManager.getFragments().size() == 0){
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
|
||||
}
|
||||
|
||||
}else {
|
||||
Toast.makeText(context, "List Empty", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.appttude.h_mal.days_left;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.appttude.h_mal.days_left.Abn.AbnListAdapter;
|
||||
import com.appttude.h_mal.days_left.Abn.AbnObject;
|
||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class FilterDialogClass extends AlertDialog {
|
||||
|
||||
private FilterDialogClickListener listener;
|
||||
private TextView fromButton;
|
||||
private TextView toButton;
|
||||
private DatePicker datePicker;
|
||||
|
||||
private String dateSelectionFrom;
|
||||
private String dateSelectionTo;
|
||||
|
||||
private String currentTag = "from";
|
||||
|
||||
protected FilterDialogClass(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
protected FilterDialogClass(@NonNull Context context, int selection, FilterDialogClickListener listener) {
|
||||
super(context);
|
||||
init(selection);
|
||||
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
||||
public void init(int selection){
|
||||
View view;
|
||||
if (selection == 0){
|
||||
view = viewOne();
|
||||
}else {
|
||||
view = viewTwo();
|
||||
}
|
||||
|
||||
setView(view);
|
||||
setButton(BUTTON_NEGATIVE, getContext().getResources().getString(android.R.string.cancel), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public View viewOne(){
|
||||
View view = View.inflate(getContext(),R.layout.dialog_previous_abns_used,null);
|
||||
|
||||
final ListView listView = view.findViewById(R.id.list_item_list_dialog);
|
||||
view.findViewById(R.id.button_list_dialog).setVisibility(View.GONE);
|
||||
|
||||
Map<String, AbnObject> mappedList = new HashMap<>();
|
||||
|
||||
for(ShiftObject shiftObject : MainActivity.shiftObjectArrayList){
|
||||
mappedList.put(shiftObject.getAbnObject().getAbn(),shiftObject.getAbnObject());
|
||||
}
|
||||
|
||||
final List<AbnObject> abnObjectList = new ArrayList<>(mappedList.values());
|
||||
|
||||
listView.setAdapter(new AbnListAdapter(getContext(),abnObjectList));
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String currentAbn = abnObjectList.get(position).getAbn();
|
||||
|
||||
listener.applyAbn(currentAbn);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public View viewTwo(){
|
||||
View view = View.inflate(getContext(),R.layout.date_selector_dialog,null);
|
||||
|
||||
fromButton = view.findViewById(R.id.from_date);
|
||||
toButton = view.findViewById(R.id.to_date);
|
||||
datePicker = view.findViewById(R.id.date_picker);
|
||||
|
||||
fromButton.setOnClickListener(onClickListener);
|
||||
toButton.setOnClickListener(onClickListener);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
datePicker.setOnDateChangedListener(dateChangedListener);
|
||||
}else{
|
||||
datePicker.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleTextButtons(true);
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
String dateString = retrieveDateString(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) +1, calendar.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
dateSelectionFrom = dateString;
|
||||
dateSelectionTo = dateString;
|
||||
|
||||
setButton(BUTTON_POSITIVE, getContext().getResources().getString(android.R.string.yes), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//interface results back
|
||||
if (!dateSelectionFrom.equals(dateSelectionTo)){
|
||||
listener.applyDates(dateSelectionFrom,dateSelectionTo);
|
||||
}
|
||||
|
||||
Toast.makeText(getContext(), dateSelectionFrom + " - " + dateSelectionTo, Toast.LENGTH_SHORT).show();
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public interface FilterDialogClickListener {
|
||||
void applyDates(String arg1,String arg2);
|
||||
|
||||
void applyAbn(String abn);
|
||||
}
|
||||
|
||||
DatePicker.OnDateChangedListener dateChangedListener = new DatePicker.OnDateChangedListener() {
|
||||
@Override
|
||||
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||
monthOfYear = monthOfYear + 1;
|
||||
if (currentTag.equals("from")){
|
||||
dateSelectionFrom = retrieveDateString(year, monthOfYear, dayOfMonth);
|
||||
}else {
|
||||
dateSelectionTo = retrieveDateString(year, monthOfYear, dayOfMonth);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
currentTag = (String) v.getTag();
|
||||
|
||||
if (currentTag.equals("from")){
|
||||
toggleTextButtons(true);
|
||||
setDateOnDatePicker(dateSelectionFrom);
|
||||
|
||||
}else {
|
||||
toggleTextButtons(false);
|
||||
setDateOnDatePicker(dateSelectionTo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private String retrieveDateString(int year, int monthOfYear, int dayOfMonth){
|
||||
DecimalFormat mFormat= new DecimalFormat("00");
|
||||
|
||||
String monthString = mFormat.format(monthOfYear );
|
||||
String dayString = mFormat.format(dayOfMonth);
|
||||
|
||||
return year + "-" + monthString + "-" + dayString;
|
||||
}
|
||||
|
||||
private void setDateOnDatePicker(String dateString){
|
||||
/* 2019-06-04 */
|
||||
int year = Integer.parseInt(dateString.substring(0,4));
|
||||
int month = Integer.parseInt(dateString.substring(5,7)) - 1;
|
||||
int day = Integer.parseInt(dateString.substring(8));
|
||||
|
||||
datePicker.init(year,month,day,dateChangedListener);
|
||||
|
||||
}
|
||||
|
||||
private void toggleTextButtons(boolean top){
|
||||
setFadeAnimation(fromButton);
|
||||
setFadeAnimation(toButton);
|
||||
|
||||
if (top){
|
||||
fromButton.setTypeface(null, Typeface.BOLD);
|
||||
toButton.setTypeface(null, Typeface.NORMAL);
|
||||
|
||||
fromButton.setBackgroundColor(getContext().getResources().getColor(R.color.one));
|
||||
toButton.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));
|
||||
}else {
|
||||
toButton.setTypeface(null, Typeface.BOLD);
|
||||
fromButton.setTypeface(null, Typeface.NORMAL);
|
||||
|
||||
toButton.setBackgroundColor(getContext().getResources().getColor(R.color.one));
|
||||
fromButton.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));
|
||||
}
|
||||
}
|
||||
|
||||
private void setFadeAnimation(View view){
|
||||
Animation bottomUp = AnimationUtils.loadAnimation(getContext(),
|
||||
R.anim.fade_in);
|
||||
|
||||
view.setAnimation(bottomUp);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -20,7 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
class FireAdapter extends FirebaseListAdapter<ShiftObject>{
|
||||
|
||||
String TAG = "FireAdapter";
|
||||
|
||||
@@ -98,6 +100,8 @@ class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
return getRef(i).getKey();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected ShiftObject parseSnapshot(DataSnapshot snapshot) {
|
||||
shiftObjects.add(snapshot.getValue(ShiftObject.class));
|
||||
@@ -105,7 +109,6 @@ class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getBreakTimeString(int breakMins){
|
||||
float hoursFloat = breakMins/60;
|
||||
|
||||
@@ -124,4 +127,5 @@ class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -81,6 +81,25 @@ public class FragmentList extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle("Are you sure you want to delete?");
|
||||
builder.setNegativeButton(android.R.string.no, null);
|
||||
builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
//todo: delete from previously used if last entry
|
||||
adapter.getRef(position).removeValue();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -96,9 +115,14 @@ public class FragmentList extends Fragment {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
case R.id.app_bar_filter:
|
||||
filterData();
|
||||
return false;
|
||||
|
||||
case R.id.app_bar_soft:
|
||||
sortData();
|
||||
return false;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -110,8 +134,6 @@ public class FragmentList extends Fragment {
|
||||
final String[] grpname = {"Name","Date Added","Date of shift"};
|
||||
int checkedItem = -1;
|
||||
|
||||
|
||||
|
||||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(getContext());
|
||||
alt_bld.setTitle("Sort by:");
|
||||
alt_bld.setSingleChoiceItems(grpname, checkedItem, new DialogInterface
|
||||
@@ -119,11 +141,8 @@ public class FragmentList extends Fragment {
|
||||
public void onClick(DialogInterface dialog, final int item) {
|
||||
switch (item){
|
||||
case 0:
|
||||
Query q1 = reference.orderByChild("abnObject/companyName")
|
||||
.equalTo("GREEN CLOUD NURSERY");
|
||||
|
||||
q1.orderByChild("shiftDate")
|
||||
.equalTo("2019-04-12");
|
||||
Query q1 = reference.orderByChild("abnObject/companyName").equalTo("GREEN CLOUD NURSERY");
|
||||
// .startAt("2018-04-12").endAt("2019-03-29");
|
||||
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
||||
break;
|
||||
@@ -136,30 +155,92 @@ public class FragmentList extends Fragment {
|
||||
default:
|
||||
|
||||
}
|
||||
listView.setAdapter(adapter);
|
||||
dialog.dismiss();
|
||||
listView.setAdapter(adapter);
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
// .setPositiveButton("Ascending", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
//// sortOrder = sortQuery[0] + " ASC";
|
||||
//
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// }).setNegativeButton("Descending", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int id) {
|
||||
//// sortOrder = sortQuery[0] + " DESC";
|
||||
//
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// })
|
||||
;
|
||||
});
|
||||
AlertDialog alert = alt_bld.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
private void filterData(){
|
||||
final String[] groupName = {"Name","Date Added","Shift Type"};
|
||||
int checkedItem = -1;
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle("Filter by:");
|
||||
builder.setSingleChoiceItems(groupName, checkedItem, new DialogInterface
|
||||
.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, final int item) {
|
||||
dialog.dismiss();
|
||||
|
||||
switch (item){
|
||||
case 0:
|
||||
final FilterDialogClass filterDialog = new FilterDialogClass(getContext(), 0, new FilterDialogClass.FilterDialogClickListener() {
|
||||
@Override
|
||||
public void applyDates(String arg1, String arg2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyAbn(String abn) {
|
||||
applyFilter(abn,null);
|
||||
}
|
||||
});
|
||||
filterDialog.show();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
final FilterDialogClass filterDialog2 = new FilterDialogClass(getContext(), 1, new FilterDialogClass.FilterDialogClickListener() {
|
||||
@Override
|
||||
public void applyDates(String arg1, String arg2) {
|
||||
applyFilter(arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyAbn(String abn) {
|
||||
|
||||
}
|
||||
});
|
||||
filterDialog2.show();
|
||||
break;
|
||||
case 2:
|
||||
AlertDialog.Builder typeDialog = new AlertDialog.Builder(getContext());
|
||||
final String[] typeString = {"Hourly", "Piece Rate"};
|
||||
|
||||
typeDialog.setSingleChoiceItems(new String[]{"Hourly", "Piece Rate"}, -1, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Query q1 = reference.orderByChild("taskObject/workType").equalTo(typeString[which]);
|
||||
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
typeDialog.create().show();
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
private void applyFilter(String arg1, String arg2){
|
||||
Query q1;
|
||||
if (arg2 == null){
|
||||
q1 = reference.orderByChild("abnObject/abn").equalTo(arg1);
|
||||
}else {
|
||||
q1 = reference.orderByChild("shiftDate").startAt(arg1).endAt(arg2);
|
||||
}
|
||||
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
public static Date convertDate(String s){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
Date d = null;
|
||||
@@ -182,4 +263,6 @@ public class FragmentList extends Fragment {
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,16 +49,15 @@ public class FirebaseClass {
|
||||
public static DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
|
||||
public static FirebaseAuth auth = FirebaseAuth.getInstance();
|
||||
|
||||
Context context;
|
||||
Uri filePath;
|
||||
|
||||
public interface Response {
|
||||
void retrieveAbnStringList(List<String> abnList);
|
||||
void retrieveAbnObjectList(List<AbnObject> abnObjects);
|
||||
void retrieveTaskList(List<TaskObject> taskObjects);
|
||||
}
|
||||
|
||||
public Response delegate;
|
||||
public interface matchListener{
|
||||
void abnMatch(Boolean confirm);
|
||||
}
|
||||
|
||||
public interface Complete{
|
||||
void taskCompleted(Boolean success);
|
||||
@@ -67,12 +66,6 @@ public class FirebaseClass {
|
||||
public FirebaseClass() {
|
||||
}
|
||||
|
||||
public FirebaseClass(Context context, Uri filePath, Response delegate) {
|
||||
this.context = context;
|
||||
this.filePath = filePath;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
// public void uploadImage(String path, String name) {
|
||||
//
|
||||
// if(filePath != null) {
|
||||
@@ -355,7 +348,7 @@ public class FirebaseClass {
|
||||
|
||||
@Override
|
||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
||||
delegate.retrieveAbnStringList(abnList);
|
||||
delegate.retrieveAbnStringList(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -383,6 +376,28 @@ public class FirebaseClass {
|
||||
});
|
||||
}
|
||||
|
||||
public void newAbnEntry(final String currentAbn, final matchListener delegate){
|
||||
DatabaseReference listRef = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child("recent" + EMPLOYER_FIREBASE);
|
||||
listRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
||||
@Override
|
||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
||||
for (DataSnapshot current : dataSnapshot.getChildren()){
|
||||
if (current.getKey().equals(currentAbn)){
|
||||
delegate.abnMatch(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
delegate.abnMatch(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
||||
delegate.abnMatch(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void retrieveListOfTasks (String abn, final Response delegate){
|
||||
DatabaseReference taskListReference = mDatabase.child(EMPLOYER_FIREBASE).child(abn).child(TASK_FIREBASE);
|
||||
taskListReference.keepSynced(true);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
|
||||
reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
||||
reference.addListenerForSingleValueEvent(new CustomValueEventListener(this,fragmentManager,progressBar));
|
||||
reference.addValueEventListener(new CustomValueEventListener(this,fragmentManager,progressBar));
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -175,22 +175,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
case "InsuranceFragment":
|
||||
title = "Insurance";
|
||||
break;
|
||||
case "logbookFragment":
|
||||
title = "Logbook";
|
||||
break;
|
||||
case "MotFragment":
|
||||
title = "M.O.T";
|
||||
break;
|
||||
case "PrivateHireLicenseFragment":
|
||||
title = "Private Hire License";
|
||||
break;
|
||||
case "VehicleSetupFragment":
|
||||
title = "Vehicle Profile";
|
||||
break;
|
||||
case "UserMainFragment":
|
||||
return;
|
||||
case "ArchiveFragment":
|
||||
return;
|
||||
default:
|
||||
title = getResources().getString(R.string.app_name);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
package com.appttude.h_mal.days_left;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
||||
import com.appttude.h_mal.days_left.Objects.TaskObject;
|
||||
import com.appttude.h_mal.days_left.Objects.TimeObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapListViewAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
private Context context;
|
||||
private final ArrayList mData;
|
||||
|
||||
public MapListViewAdapter(Context context, Map<String,ShiftObject> map) {
|
||||
this.context = context;
|
||||
mData = new ArrayList();
|
||||
mData.addAll(map.entrySet());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
@@ -15,8 +35,8 @@ public class MapListViewAdapter extends BaseAdapter implements Filterable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
public ShiftObject getItem(int position) {
|
||||
return (ShiftObject)((Map.Entry) mData.get(position)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,13 +44,90 @@ public class MapListViewAdapter extends BaseAdapter implements Filterable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getId(int position){
|
||||
return (String) ((Map.Entry) mData.get(position)).getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return null;
|
||||
View listItemView = convertView;
|
||||
if (convertView == null){
|
||||
listItemView = LayoutInflater.from(context).inflate(R.layout.list_item, parent,false);
|
||||
}
|
||||
|
||||
ShiftObject currentShift = getItem(position);
|
||||
|
||||
TextView farmNameTextView = listItemView.findViewById(R.id.farm_name);
|
||||
TextView dateTextView = listItemView.findViewById(R.id.date);
|
||||
TextView tastTextView = listItemView.findViewById(R.id.task_name);
|
||||
TextView typeTextView = listItemView.findViewById(R.id.type);
|
||||
LinearLayout timeHolderLinearLayout = listItemView.findViewById(R.id.time_holder);
|
||||
TextView timeTextView = listItemView.findViewById(R.id.time);
|
||||
LinearLayout breakHolderLinearLayout = listItemView.findViewById(R.id.break_holder);
|
||||
TextView breakTimeTextView = listItemView.findViewById(R.id.break_time);
|
||||
LinearLayout unitsHolderLinearLayout = listItemView.findViewById(R.id.units_holder);
|
||||
TextView unitsTextView = listItemView.findViewById(R.id.units);
|
||||
TextView locationTextView = listItemView.findViewById(R.id.location);
|
||||
|
||||
dateTextView.setText(currentShift.getShiftDate());
|
||||
|
||||
TaskObject taskObject = currentShift.getTaskObject();
|
||||
tastTextView.setText(taskObject.getTask());
|
||||
String s = taskObject.getWorkType() + " - $" + taskObject.getRate() + "/";
|
||||
if (taskObject.getWorkType().equals("Hourly")){
|
||||
s = s + "Hour";
|
||||
timeHolderLinearLayout.setVisibility(View.VISIBLE);
|
||||
unitsHolderLinearLayout.setVisibility(View.GONE);
|
||||
|
||||
TimeObject timeObject = currentShift.getTimeObject();
|
||||
|
||||
timeTextView.setText(timeObject.getTimeIn() + " - " + timeObject.getTimeOut());
|
||||
|
||||
if (timeObject.getBreakEpoch() > 0){
|
||||
breakHolderLinearLayout.setVisibility(View.VISIBLE);
|
||||
String breakString = getBreakTimeString(timeObject.getBreakEpoch());
|
||||
breakTimeTextView.setText(breakString);
|
||||
}else {
|
||||
breakHolderLinearLayout.setVisibility(View.GONE);
|
||||
}
|
||||
unitsTextView.setText(String.valueOf(timeObject.getHours()));
|
||||
|
||||
}else {
|
||||
s = s + "Unit";
|
||||
timeHolderLinearLayout.setVisibility(View.GONE);
|
||||
unitsHolderLinearLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
unitsTextView.setText(String.valueOf(currentShift.getUnitsCount()));
|
||||
}
|
||||
|
||||
typeTextView.setText(s);
|
||||
farmNameTextView.setText(currentShift.getAbnObject().getCompanyName());
|
||||
|
||||
locationTextView.setText(currentShift.getAbnObject().getState() + " - " + currentShift.getAbnObject().getPostCode());
|
||||
|
||||
return listItemView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getBreakTimeString(int breakMins){
|
||||
float hoursFloat = breakMins/60;
|
||||
|
||||
int hoursInt = (int) Math.floor(hoursFloat);
|
||||
int minsInt = breakMins - (hoursInt*60);
|
||||
|
||||
String s = "";
|
||||
if (hoursInt > 0){
|
||||
s = hoursInt + " h" + " ";
|
||||
}
|
||||
|
||||
if (minsInt > 0){
|
||||
s = s + minsInt + " m";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ShiftListViewAdapter extends ArrayAdapter<ShiftObject> {
|
||||
return s;
|
||||
}
|
||||
|
||||
private class ValueFilter extends Filter {
|
||||
public class fireFilter extends Filter{
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
@@ -119,28 +119,25 @@ public class ShiftListViewAdapter extends ArrayAdapter<ShiftObject> {
|
||||
|
||||
// if (constraint != null && constraint.length() > 0) {
|
||||
// ArrayList<ShiftObject> filterList = new ArrayList<>();
|
||||
// for (int i = 0; i < mStringFilterList.size(); i++) {
|
||||
// if ((mStringFilterList.get(i).getBabyname().toUpperCase())
|
||||
// .contains(constraint.toString().toUpperCase())) {
|
||||
// BabyDetailsData babydata = new BabyDetailsData(mStringFilterList.get(i)
|
||||
// .getBabyname(), mStringFilterList.get(i)
|
||||
// .getBabypicture());
|
||||
// filterList.add(babydata);
|
||||
//
|
||||
// for (ShiftObject shiftObject : shiftObjects){
|
||||
// if (shiftObject.getAbnObject().getCompanyName().toUpperCase().contains(constraint.toString().toUpperCase())){
|
||||
// filterList.add(shiftObject);
|
||||
// }
|
||||
// }
|
||||
// results.count = filterList.size();
|
||||
// results.values = filterList;
|
||||
//
|
||||
// } else {
|
||||
// results.count = mStringFilterList.size();
|
||||
// results.values = mStringFilterList;
|
||||
// results.count = shiftObjects.size();
|
||||
// results.values = shiftObjects;
|
||||
// }
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint,
|
||||
FilterResults results) {
|
||||
// babylist = (ArrayList<BabyDetailsData>) results.values;
|
||||
notifyDataSetChanged();
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
app/src/main/res/drawable/ic_filter_list_black_24dp.xml
Normal file
5
app/src/main/res/drawable/ic_filter_list_black_24dp.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
|
||||
</vector>
|
||||
49
app/src/main/res/layout/date_selector_dialog.xml
Normal file
49
app/src/main/res/layout/date_selector_dialog.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/from_date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:tag="from"
|
||||
android:text="From" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/to_date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:tag="to"
|
||||
android:text="To" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<DatePicker
|
||||
android:id="@+id/date_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:headerBackground="@color/colorPrimaryDark"
|
||||
android:numbersSelectorColor="@color/colorPrimary">
|
||||
|
||||
</DatePicker>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -13,7 +13,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_time"
|
||||
android:id="@+id/from_date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_weight="1"
|
||||
@@ -27,7 +27,7 @@
|
||||
<!--android:layout_margin="4dp"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/finish_time"
|
||||
android:id="@+id/to_date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@android:dimen/app_icon_size"
|
||||
android:layout_weight="1"
|
||||
|
||||
@@ -4,10 +4,18 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/app_bar_filter"
|
||||
android:icon="@drawable/ic_sort_black_24dp"
|
||||
android:icon="@drawable/ic_filter_list_black_24dp"
|
||||
android:title="Filter"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/app_bar_soft"
|
||||
android:icon="@drawable/ic_sort_black_24dp"
|
||||
android:title="Sort"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
</menu>
|
||||
Reference in New Issue
Block a user