mirror of
https://github.com/hmalik144/DaysLeft.git
synced 2026-01-31 02:41:45 +00:00
16/06 version
This commit is contained in:
@@ -152,7 +152,6 @@ public class AddShiftActivity extends AppCompatActivity {
|
||||
if (ShiftID != null){
|
||||
DatabaseReference reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE).child(ShiftID);
|
||||
|
||||
|
||||
reference.addListenerForSingleValueEvent(new ValueEventListener() {
|
||||
@Override
|
||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.appttude.h_mal.days_left;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
||||
import com.google.firebase.database.DataSnapshot;
|
||||
import com.google.firebase.database.DatabaseError;
|
||||
import com.google.firebase.database.ValueEventListener;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.appttude.h_mal.days_left.MainActivity.shiftObjectArrayList;
|
||||
import static com.appttude.h_mal.days_left.MainActivity.shiftsMap;
|
||||
|
||||
public class CustomValueEventListener implements ValueEventListener {
|
||||
|
||||
private Context context;
|
||||
private FragmentManager fragmentManager;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
public CustomValueEventListener(Context context, FragmentManager fragmentManager, ProgressBar progressBar) {
|
||||
this.context = context;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.progressBar = progressBar;
|
||||
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
||||
|
||||
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
|
||||
shiftObjectArrayList.add(postSnapshot.getValue(ShiftObject.class));
|
||||
shiftsMap.put(postSnapshot.getKey(),postSnapshot.getValue(ShiftObject.class));
|
||||
}
|
||||
|
||||
if (shiftObjectArrayList.size() > 0){
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
|
||||
}else {
|
||||
Toast.makeText(context, "List Empty", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.appttude.h_mal.days_left;
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -11,6 +12,7 @@ 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 com.firebase.ui.database.FirebaseListAdapter;
|
||||
import com.google.firebase.database.DataSnapshot;
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
import com.google.firebase.database.Query;
|
||||
|
||||
@@ -22,7 +24,7 @@ class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
|
||||
String TAG = "FireAdapter";
|
||||
|
||||
Query ref;
|
||||
List<ShiftObject> shiftObjects;
|
||||
|
||||
/**
|
||||
* @param activity The activity containing the ListView
|
||||
@@ -36,8 +38,7 @@ class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
*/
|
||||
public FireAdapter(Activity activity, Class<ShiftObject> modelClass, int modelLayout, Query ref) {
|
||||
super(activity, modelClass, modelLayout, ref);
|
||||
this.ref = ref;
|
||||
|
||||
shiftObjects = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,6 +98,14 @@ class FireAdapter extends FirebaseListAdapter<ShiftObject> {
|
||||
return getRef(i).getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShiftObject parseSnapshot(DataSnapshot snapshot) {
|
||||
shiftObjects.add(snapshot.getValue(ShiftObject.class));
|
||||
return super.parseSnapshot(snapshot);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getBreakTimeString(int breakMins){
|
||||
float hoursFloat = breakMins/60;
|
||||
|
||||
|
||||
@@ -13,10 +13,13 @@ import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
||||
import com.appttude.h_mal.days_left.R;
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.appttude.h_mal.days_left.Global.FirebaseClass.SHIFT_FIREBASE;
|
||||
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.mDatabase;
|
||||
import static com.appttude.h_mal.days_left.MainActivity.shiftsMap;
|
||||
|
||||
|
||||
public class FragmentHome extends Fragment {
|
||||
@@ -37,13 +40,16 @@ public class FragmentHome extends Fragment {
|
||||
RecyclerView recyclerView = view.findViewById(R.id.recycler);
|
||||
// recyclerView.setAdapter(new RecyclerViewAdapter(getContext()));
|
||||
|
||||
DatabaseReference reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
||||
reference.keepSynced(true);
|
||||
// DatabaseReference reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
||||
// reference.keepSynced(true);
|
||||
|
||||
recyclerView.setAdapter(new FireRecyclerAdapter(ShiftObject.class,R.layout.item_one,RecyclerView.ViewHolder.class,reference,getContext()));
|
||||
// recyclerView.setAdapter(new FireRecyclerAdapter(ShiftObject.class,R.layout.item_one,RecyclerView.ViewHolder.class,reference,getContext()));
|
||||
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(getContext(),new ArrayList<>(shiftsMap.values()));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
// recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@ 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
|
||||
@@ -117,13 +119,19 @@ public class FragmentList extends Fragment {
|
||||
public void onClick(DialogInterface dialog, final int item) {
|
||||
switch (item){
|
||||
case 0:
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("abnObject/companyName"));
|
||||
Query q1 = reference.orderByChild("abnObject/companyName")
|
||||
.equalTo("GREEN CLOUD NURSERY");
|
||||
|
||||
q1.orderByChild("shiftDate")
|
||||
.equalTo("2019-04-12");
|
||||
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, q1);
|
||||
break;
|
||||
case 1:
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("shiftDate"));
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("dateTimeAdded"));
|
||||
break;
|
||||
case 2:
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("dateTimeAdded"));
|
||||
adapter = new FireAdapter(getActivity(), ShiftObject.class, R.layout.list_item, reference.orderByChild("shiftDate"));
|
||||
break;
|
||||
default:
|
||||
|
||||
|
||||
@@ -90,8 +90,6 @@ public class FragmentTools extends Fragment {
|
||||
shiftObjectArrayList = new ArrayList<>();
|
||||
|
||||
mFunctions = FirebaseFunctions.getInstance();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -114,10 +114,9 @@ public class DateDialog extends DatePickerDialog {
|
||||
mMonth = month + 1;
|
||||
mDay = dayOfMonth;
|
||||
|
||||
editText.setText(String.format("%02d", mDay) + "/" +
|
||||
String.format("%02d", (mMonth)) +"/" +
|
||||
mYear
|
||||
);
|
||||
String date = mYear + "-" + String.format("%02d", mMonth) + "-" + String.format("%02d", mDay);
|
||||
|
||||
editText.setText(date);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -51,7 +51,9 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@@ -71,26 +73,28 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private DatabaseReference reference;
|
||||
public static List<ShiftObject> shiftObjectArrayList;
|
||||
public static Map<String,ShiftObject> shiftsMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_drawer_main);
|
||||
|
||||
shiftObjectArrayList = new ArrayList<>();
|
||||
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
progressBar = (ProgressBar) findViewById(R.id.progressBar2);
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
|
||||
|
||||
// reference.addListenerForSingleValueEvent(valueEventListener);
|
||||
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
|
||||
|
||||
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
|
||||
reference = mDatabase.child(USER_FIREBASE).child(auth.getUid()).child(SHIFT_FIREBASE);
|
||||
reference.addListenerForSingleValueEvent(new CustomValueEventListener(this,fragmentManager,progressBar));
|
||||
|
||||
progressBar = (ProgressBar) findViewById(R.id.progressBar2);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -99,8 +103,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
@@ -127,9 +129,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
|
||||
|
||||
setupDrawer();
|
||||
|
||||
parseXmlLayout();
|
||||
@@ -138,28 +137,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||
}
|
||||
|
||||
ValueEventListener valueEventListener = new ValueEventListener() {
|
||||
@Override
|
||||
public void onDataChange(@NonNull final DataSnapshot dataSnapshot) {
|
||||
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
|
||||
shiftObjectArrayList.add(postSnapshot.getValue(ShiftObject.class));
|
||||
}
|
||||
|
||||
if (shiftObjectArrayList.size() > 0){
|
||||
// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
// fragmentTransaction.replace(R.id.container,new FragmentHome()).commit();
|
||||
}else {
|
||||
Toast.makeText(MainActivity.this, "List Empty", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
||||
Toast.makeText(MainActivity.this, "Cancelled", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
};
|
||||
|
||||
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.appttude.h_mal.days_left;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
|
||||
public class MapListViewAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.appttude.h_mal.days_left.Login.LoginFragment;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -76,4 +77,5 @@ public class ShiftObject {
|
||||
|
||||
this.dateTimeAdded = dt1.format(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,210 +13,308 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
||||
import com.appttude.h_mal.days_left.arc.ArcAnimation;
|
||||
import com.appttude.h_mal.days_left.bar.BarAnimation;
|
||||
|
||||
import com.appttude.h_mal.days_left.arc.CircleView;
|
||||
import com.appttude.h_mal.days_left.bar.BarView;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
//
|
||||
// String TAG = "something";
|
||||
//
|
||||
|
||||
String TAG = "something";
|
||||
|
||||
private Context context;
|
||||
// private int dx;
|
||||
//
|
||||
public RecyclerViewAdapter(Context context) {
|
||||
private List<ShiftObject> shiftObjectList;
|
||||
private int uniqueEntries;
|
||||
private int[] typeCount;
|
||||
|
||||
public RecyclerViewAdapter(Context context, List<ShiftObject> shiftObjectList) {
|
||||
this.context = context;
|
||||
this.shiftObjectList = shiftObjectList;
|
||||
uniqueEntries = countDistinct();
|
||||
typeCount = countShiftType();
|
||||
}
|
||||
//
|
||||
// class ItemOne extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// CircleView arc;
|
||||
// TextView days;
|
||||
//
|
||||
// public ItemOne(View itemView){
|
||||
// super(itemView);
|
||||
// arc = itemView.findViewById(R.id.arc_view);
|
||||
// days = itemView.findViewById(R.id.days_completed);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class ItemTwo extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// BarView barView;
|
||||
// LinearLayout linearLayout;
|
||||
//// LinearLayout textholder;
|
||||
//// LinearLayout bottomTextholder;
|
||||
//
|
||||
// public ItemTwo(View itemView){
|
||||
// super(itemView);
|
||||
//
|
||||
// barView = itemView.findViewById(R.id.bar);
|
||||
// linearLayout = itemView.findViewById(R.id.lin);
|
||||
//// textholder = itemView.findViewById(R.id.text_holder);
|
||||
//// bottomTextholder = itemView.findViewById(R.id.bottom_text_holder);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class ItemThree extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// private TextView cardTitle;
|
||||
// private ImageView cardIcon;
|
||||
// private TextView units;
|
||||
// private TextView totalEarned;
|
||||
// private LinearLayout textholderTop;
|
||||
// private LinearLayout textholderBottom;
|
||||
//
|
||||
// public ItemThree(View itemView){
|
||||
// super(itemView);
|
||||
//
|
||||
// cardTitle = itemView.findViewById(R.id.card_title);
|
||||
// cardIcon = itemView.findViewById(R.id.card_icon);
|
||||
// units = itemView.findViewById(R.id.units);
|
||||
// totalEarned = itemView.findViewById(R.id.total_earned);
|
||||
// textholderTop = itemView.findViewById(R.id.text_holder);
|
||||
// textholderBottom = itemView.findViewById(R.id.text_holder_two);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
class ItemOne extends RecyclerView.ViewHolder {
|
||||
|
||||
CircleView arc;
|
||||
TextView days;
|
||||
|
||||
public ItemOne(View itemView){
|
||||
super(itemView);
|
||||
arc = itemView.findViewById(R.id.arc_view);
|
||||
days = itemView.findViewById(R.id.days_completed);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemTwo extends RecyclerView.ViewHolder {
|
||||
|
||||
BarView barView;
|
||||
LinearLayout linearLayout;
|
||||
TextView pcText;
|
||||
TextView hrText;
|
||||
// LinearLayout textholder;
|
||||
// LinearLayout bottomTextholder;
|
||||
|
||||
public ItemTwo(View itemView){
|
||||
super(itemView);
|
||||
|
||||
barView = itemView.findViewById(R.id.bar);
|
||||
linearLayout = itemView.findViewById(R.id.lin);
|
||||
pcText = itemView.findViewById(R.id.pc_amount_text);
|
||||
hrText = itemView.findViewById(R.id.hr_amount_text);
|
||||
// textholder = itemView.findViewById(R.id.text_holder);
|
||||
// bottomTextholder = itemView.findViewById(R.id.bottom_text_holder);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class ItemThree extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView cardTitle;
|
||||
private ImageView cardIcon;
|
||||
private TextView units;
|
||||
private TextView totalEarned;
|
||||
private LinearLayout textholderTop;
|
||||
private LinearLayout textholderBottom;
|
||||
|
||||
public ItemThree(View itemView){
|
||||
super(itemView);
|
||||
|
||||
cardTitle = itemView.findViewById(R.id.card_title);
|
||||
cardIcon = itemView.findViewById(R.id.card_icon);
|
||||
units = itemView.findViewById(R.id.units);
|
||||
totalEarned = itemView.findViewById(R.id.total_earned);
|
||||
textholderTop = itemView.findViewById(R.id.text_holder);
|
||||
textholderBottom = itemView.findViewById(R.id.text_holder_two);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
// switch (i) {
|
||||
// case 1:
|
||||
// final View itemOne = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_one, viewGroup, false);
|
||||
// return new ItemOne(itemOne);
|
||||
// case 2:
|
||||
// final View itemTwo = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_two, viewGroup, false);
|
||||
// return new ItemTwo(itemTwo);
|
||||
// case 3:
|
||||
// final View itemThree = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_three, viewGroup, false);
|
||||
// return new ItemThree(itemThree);
|
||||
// }
|
||||
//
|
||||
switch (i) {
|
||||
case 1:
|
||||
final View itemOne = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_one, viewGroup, false);
|
||||
return new ItemOne(itemOne);
|
||||
case 2:
|
||||
final View itemTwo = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_two, viewGroup, false);
|
||||
return new ItemTwo(itemTwo);
|
||||
case 3:
|
||||
final View itemThree = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_three, viewGroup, false);
|
||||
return new ItemThree(itemThree);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
//
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int i) {
|
||||
//
|
||||
// switch (holder.getItemViewType()) {
|
||||
// case 1:
|
||||
// final ItemOne viewHolderCurrent = (ItemOne) holder;
|
||||
//
|
||||
// CircleView arcView = viewHolderCurrent.arc;
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// arcView.setPaintColor(context.getColor(R.color.two));
|
||||
// }
|
||||
//
|
||||
// int days = 76;
|
||||
//
|
||||
// int complete = (360 * days)/88;
|
||||
//
|
||||
// viewHolderCurrent.days.setText(String.valueOf(days));
|
||||
//
|
||||
// ArcAnimation animation = new ArcAnimation(arcView, complete);
|
||||
// animation.setDuration(600);
|
||||
// arcView.startAnimation(animation);
|
||||
//
|
||||
// break;
|
||||
// case 2:
|
||||
// final ItemTwo viewTwo = (ItemTwo) holder;
|
||||
//
|
||||
// final BarView barView = viewTwo.barView;
|
||||
// final LinearLayout linearLayout = viewTwo.linearLayout;
|
||||
//
|
||||
// barView.setCover(0.56f);
|
||||
//
|
||||
// barView.setColourOne(context.getResources().getColor(R.color.four));
|
||||
// barView.setColourTwo(context.getResources().getColor(R.color.three));
|
||||
//
|
||||
//// viewTwo.textholder.setPadding(60,0,60,0);
|
||||
//// viewTwo.bottomTextholder.setPadding(60,0,60,0);
|
||||
//
|
||||
// linearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
// @Override
|
||||
// public void onGlobalLayout() {
|
||||
// Log.i(TAG, "onGlobalLayout: " + linearLayout.getWidth());
|
||||
//
|
||||
// BarAnimation barAnimation = new BarAnimation(barView, linearLayout.getWidth(), 0);
|
||||
// barAnimation.setDuration(600);
|
||||
// barView.setAnimation(barAnimation);
|
||||
// linearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// break;
|
||||
//
|
||||
// case 3:
|
||||
// final ItemThree viewCounting = (ItemThree) holder;
|
||||
//
|
||||
// TextView cardTitle = viewCounting.cardTitle;
|
||||
// ImageView cardIcon = viewCounting.cardIcon;
|
||||
// TextView units = viewCounting.units;
|
||||
// TextView totalEarned = viewCounting.totalEarned;
|
||||
// LinearLayout top = viewCounting.textholderTop;
|
||||
// LinearLayout bottom = viewCounting.textholderBottom;
|
||||
//
|
||||
//// top.setPadding(60,0,60,0);
|
||||
//// bottom.setPadding(60,0,60,0);
|
||||
//// cardIcon.setPadding(0,0,10,0);
|
||||
//
|
||||
// if (i == 2){
|
||||
// cardTitle.setText("Hourly");
|
||||
// cardIcon.setImageResource(R.drawable.clock_icon);
|
||||
// units.setText("296" + "Hours");
|
||||
// totalEarned.setText("$" + "907.53");
|
||||
// }
|
||||
// if (i == 3){
|
||||
// cardTitle.setText("Piece");
|
||||
// cardTitle.setTextColor(context.getResources().getColor(R.color.three));
|
||||
// cardIcon.setImageResource(R.drawable.piece);
|
||||
// cardIcon.setRotation(270);
|
||||
// units.setText("180" + "Pcs");
|
||||
// totalEarned.setText("$" + "67.53");
|
||||
// }
|
||||
// if (i == 4){
|
||||
// cardTitle.setVisibility(View.GONE);
|
||||
// cardIcon.setVisibility(View.GONE);
|
||||
//
|
||||
// totalEarned.setText("$" + "974.53");
|
||||
//
|
||||
// viewCounting.textholderTop.setVisibility(View.GONE);
|
||||
// }
|
||||
// }
|
||||
|
||||
switch (holder.getItemViewType()) {
|
||||
case 1:
|
||||
final ItemOne viewHolderCurrent = (ItemOne) holder;
|
||||
|
||||
CircleView arcView = viewHolderCurrent.arc;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
arcView.setPaintColor(context.getColor(R.color.two));
|
||||
}
|
||||
|
||||
int days = uniqueEntries;
|
||||
|
||||
int complete = (360 * days)/88;
|
||||
|
||||
viewHolderCurrent.days.setText(String.valueOf(days));
|
||||
|
||||
ArcAnimation animation = new ArcAnimation(arcView, complete);
|
||||
animation.setDuration(600);
|
||||
arcView.startAnimation(animation);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
final ItemTwo viewTwo = (ItemTwo) holder;
|
||||
|
||||
final BarView barView = viewTwo.barView;
|
||||
final LinearLayout linearLayout = viewTwo.linearLayout;
|
||||
|
||||
float cover = (float) typeCount[1]/shiftObjectList.size();
|
||||
|
||||
barView.setCover(cover);
|
||||
|
||||
barView.setColourOne(context.getResources().getColor(R.color.four));
|
||||
barView.setColourTwo(context.getResources().getColor(R.color.three));
|
||||
|
||||
viewTwo.pcText.setText(String.valueOf(typeCount[1]));
|
||||
viewTwo.hrText.setText(String.valueOf(typeCount[0]));
|
||||
|
||||
// viewTwo.textholder.setPadding(60,0,60,0);
|
||||
// viewTwo.bottomTextholder.setPadding(60,0,60,0);
|
||||
|
||||
linearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
Log.i(TAG, "onGlobalLayout: " + linearLayout.getWidth());
|
||||
|
||||
BarAnimation barAnimation = new BarAnimation(barView, linearLayout.getWidth(), 0);
|
||||
barAnimation.setDuration(600);
|
||||
barView.setAnimation(barAnimation);
|
||||
linearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
final ItemThree viewCounting = (ItemThree) holder;
|
||||
|
||||
TextView cardTitle = viewCounting.cardTitle;
|
||||
ImageView cardIcon = viewCounting.cardIcon;
|
||||
TextView units = viewCounting.units;
|
||||
TextView totalEarned = viewCounting.totalEarned;
|
||||
LinearLayout top = viewCounting.textholderTop;
|
||||
LinearLayout bottom = viewCounting.textholderBottom;
|
||||
|
||||
// top.setPadding(60,0,60,0);
|
||||
// bottom.setPadding(60,0,60,0);
|
||||
// cardIcon.setPadding(0,0,10,0);
|
||||
|
||||
if (i == 2){
|
||||
cardTitle.setText("Hourly");
|
||||
cardIcon.setImageResource(R.drawable.clock_icon);
|
||||
String hours = String.format("%.2f", calculateHours());
|
||||
units.setText(hours + " Hours");
|
||||
|
||||
String total = String.format("%.2f", calculateAccumulatedPay(0));
|
||||
totalEarned.setText("$" + total);
|
||||
}
|
||||
if (i == 3){
|
||||
cardTitle.setText("Piece");
|
||||
cardTitle.setTextColor(context.getResources().getColor(R.color.three));
|
||||
cardIcon.setImageResource(R.drawable.piece);
|
||||
cardIcon.setRotation(270);
|
||||
String pieces = String.format("%.2f", calculateUnits());
|
||||
units.setText(pieces + " Units");
|
||||
String total = String.format("%.2f", calculateAccumulatedPay(1));
|
||||
totalEarned.setText("$" + total);
|
||||
}
|
||||
if (i == 4){
|
||||
cardTitle.setVisibility(View.GONE);
|
||||
cardIcon.setVisibility(View.GONE);
|
||||
|
||||
String total = String.format("%.2f", calculateAccumulatedPay(3));
|
||||
totalEarned.setText("$" + total);
|
||||
|
||||
viewCounting.textholderTop.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 5;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public int getItemViewType(int position) {
|
||||
// int type = 0;
|
||||
//
|
||||
// switch (position){
|
||||
// case 0:
|
||||
// type = 1;
|
||||
// break;
|
||||
// case 1:
|
||||
// type = 2;
|
||||
// break;
|
||||
// case 2:
|
||||
// type = 3;
|
||||
// break;
|
||||
// case 3:
|
||||
// type = 3;
|
||||
// break;
|
||||
// case 4:
|
||||
// type = 3;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return type;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
int type = 0;
|
||||
|
||||
switch (position){
|
||||
case 0:
|
||||
type = 1;
|
||||
break;
|
||||
case 1:
|
||||
type = 2;
|
||||
break;
|
||||
case 2:
|
||||
type = 3;
|
||||
break;
|
||||
case 3:
|
||||
type = 3;
|
||||
break;
|
||||
case 4:
|
||||
type = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
private int countDistinct() {
|
||||
HashSet<String> hs = new HashSet<>();
|
||||
|
||||
for(int i = 0; i < shiftObjectList.size(); i++) {
|
||||
|
||||
hs.add(shiftObjectList.get(i).getShiftDate());
|
||||
}
|
||||
|
||||
return hs.size();
|
||||
}
|
||||
|
||||
private int[] countShiftType(){
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
for (ShiftObject shiftObject : shiftObjectList){
|
||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
||||
i++;
|
||||
}else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return new int[]{i,j};
|
||||
}
|
||||
|
||||
private float calculateHours(){
|
||||
float hours = 0;
|
||||
for (ShiftObject shiftObject : shiftObjectList){
|
||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
||||
hours = hours + shiftObject.getTimeObject().getHours() - shiftObject.getTimeObject().getBreakEpoch();
|
||||
}
|
||||
}
|
||||
|
||||
return hours;
|
||||
}
|
||||
|
||||
private float calculateUnits(){
|
||||
float units = 0;
|
||||
for (ShiftObject shiftObject : shiftObjectList){
|
||||
if (shiftObject.getTaskObject().getWorkType().equals("Piece Rate")){
|
||||
units = units + shiftObject.getUnitsCount();
|
||||
}
|
||||
}
|
||||
|
||||
return units;
|
||||
}
|
||||
|
||||
private float calculateAccumulatedPay(int type){
|
||||
float pay = 0;
|
||||
|
||||
for (ShiftObject shiftObject : shiftObjectList){
|
||||
if (type == 0){
|
||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
||||
pay = pay + (shiftObject.getTaskObject().getRate() *
|
||||
(shiftObject.getTimeObject().getHours() - shiftObject.getTimeObject().getBreakEpoch()));
|
||||
}
|
||||
}else if (type == 1){
|
||||
if (shiftObject.getTaskObject().getWorkType().equals("Piece Rate")){
|
||||
pay = pay + (shiftObject.getTaskObject().getRate() * shiftObject.getUnitsCount());
|
||||
}
|
||||
}else {
|
||||
if (shiftObject.getTaskObject().getWorkType().equals("Hourly")){
|
||||
pay = pay + (shiftObject.getTaskObject().getRate() *
|
||||
(shiftObject.getTimeObject().getHours() - shiftObject.getTimeObject().getBreakEpoch()));
|
||||
}else {
|
||||
pay = pay + (shiftObject.getTaskObject().getRate() * shiftObject.getUnitsCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pay;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.appttude.h_mal.days_left.Objects.ShiftObject;
|
||||
@@ -108,4 +110,37 @@ public class ShiftListViewAdapter extends ArrayAdapter<ShiftObject> {
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private class ValueFilter extends Filter {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
FilterResults results = new FilterResults();
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// results.count = filterList.size();
|
||||
// results.values = filterList;
|
||||
// } else {
|
||||
// results.count = mStringFilterList.size();
|
||||
// results.values = mStringFilterList;
|
||||
// }
|
||||
return results;
|
||||
}
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint,
|
||||
FilterResults results) {
|
||||
// babylist = (ArrayList<BabyDetailsData>) results.values;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
android:text="Piece Rate" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pc_amount_text"
|
||||
style="@style/text_minor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -103,6 +104,7 @@
|
||||
android:background="@color/two" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hr_amount_text"
|
||||
style="@style/text_minor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user