Skip to content

Commit

Permalink
Merge pull request #1882 from rahul-gill/master
Browse files Browse the repository at this point in the history
Neccessary changes after dependency updates
  • Loading branch information
rahul-gill authored Aug 6, 2022
2 parents 4e0c32f + 7d74941 commit 0f219b1
Show file tree
Hide file tree
Showing 71 changed files with 1,152 additions and 1,729 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -30,7 +25,6 @@
import com.mifos.mifosxdroid.R;
import com.mifos.mifosxdroid.adapters.PathTrackingAdapter;
import com.mifos.mifosxdroid.core.MifosBaseActivity;
import com.mifos.mifosxdroid.core.RecyclerItemClickListener;
import com.mifos.objects.user.UserLatLng;
import com.mifos.objects.user.UserLocation;
import com.mifos.utils.CheckSelfPermissionAndRequest;
Expand All @@ -42,15 +36,19 @@

import javax.inject.Inject;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
* @author fomenkoo
*/
public class PathTrackingActivity extends MifosBaseActivity implements PathTrackingMvpView,
SwipeRefreshLayout.OnRefreshListener, RecyclerItemClickListener.OnItemClickListener {
public class PathTrackingActivity extends MifosBaseActivity implements PathTrackingMvpView, SwipeRefreshLayout.OnRefreshListener {

@BindView(R.id.rv_path_tacker)
RecyclerView rvPathTracker;
Expand All @@ -67,32 +65,13 @@ public class PathTrackingActivity extends MifosBaseActivity implements PathTrack
@Inject
PathTrackingPresenter pathTrackingPresenter;

@Inject
PathTrackingAdapter pathTrackingAdapter;

private Intent intentLocationService;
private BroadcastReceiver notificationReceiver;
private List<UserLocation> userLocations;
private SweetUIErrorHandler sweetUIErrorHandler;

@Override
public void onItemClick(View childView, int position) {
List<UserLatLng> userLatLngs =
pathTrackingAdapter.getLatLngList(userLocations.get(position).getLatlng());
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="
+ userLatLngs.get(0).getLat() + "," + userLatLngs.get(0).getLng() + "&daddr="
+ userLatLngs.get(userLatLngs.size() - 1).getLat() + "," + ""
+ userLatLngs.get(userLatLngs.size() - 1).getLng();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(Intent.createChooser(intent, getString(R.string.start_tracking)));
}

@Override
public void onItemLongPress(View childView, int position) {

}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -113,14 +92,24 @@ public void showUserInterface() {
userLocations = new ArrayList<>();
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
pathTrackingAdapter.setContext(this);
mLayoutManager.setReverseLayout(true);
mLayoutManager.setStackFromEnd(true);
rvPathTracker.setLayoutManager(mLayoutManager);
rvPathTracker.setHasFixedSize(false);
rvPathTracker.scrollToPosition(0);
pathTrackingAdapter = new PathTrackingAdapter(userLocation -> {
List<UserLatLng> userLatLngs =
pathTrackingAdapter.getLatLngList(userLocation.getLatlng());
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="
+ userLatLngs.get(0).getLat() + "," + userLatLngs.get(0).getLng() + "&daddr="
+ userLatLngs.get(userLatLngs.size() - 1).getLat() + "," + ""
+ userLatLngs.get(userLatLngs.size() - 1).getLng();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(Intent.createChooser(intent, getString(R.string.start_tracking)));
return null;
});
rvPathTracker.setAdapter(pathTrackingAdapter);
rvPathTracker.addOnItemTouchListener(new RecyclerItemClickListener(this, this));
swipeRefreshLayout.setColorSchemeColors(this
.getResources().getIntArray(R.array.swipeRefreshColors));
swipeRefreshLayout.setOnRefreshListener(this);
Expand Down Expand Up @@ -200,6 +189,7 @@ public void requestPermission() {
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case Constants.PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION: {
// If request is cancelled, the result arrays are empty.
Expand All @@ -210,7 +200,7 @@ public void onRequestPermissionsResult(int requestCode,
} else {
// permission denied
Toast.makeText(getApplicationContext(), getResources()
.getString(R.string.permission_denied_to_access_fine_location) ,
.getString(R.string.permission_denied_to_access_fine_location),
Toast.LENGTH_SHORT).show();
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.mifos.mifosxdroid.adapters

import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.mifos.mifosxdroid.R
import com.mifos.mifosxdroid.core.SelectableAdapter
import com.mifos.mifosxdroid.views.CircularImageView
import com.mifos.objects.group.Center
import com.mifos.utils.Utils


class CentersListAdapter(
val onCenterClick: (Int) -> Unit,
val onCenterLongClick: (Int) -> Unit
) : SelectableAdapter<CentersListAdapter.ViewHolder>() {

private var centers: List<Center> = ArrayList()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val viewHolder = ViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.row_center_list_item, parent, false)
)
viewHolder.itemView.setOnClickListener {
if(viewHolder.adapterPosition != RecyclerView.NO_POSITION)
onCenterClick(viewHolder.adapterPosition)
}
viewHolder.itemView.setOnLongClickListener {
if(viewHolder.adapterPosition != RecyclerView.NO_POSITION)
onCenterLongClick(viewHolder.adapterPosition)
return@setOnLongClickListener true
}
return viewHolder
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val center = centers[position]
holder.apply {
tvAccountNumber.text = String.format(
itemView.context.getString(R.string.centerList_account_prefix), center.accountNo
)
tvCenterId.text = center.id.toString()
tvCenterName.text = center.name
if (center.staffId != null) {
tvStaffId.text = center.staffId.toString()
tvStaffName.text = center.staffName
} else {
tvStaffId.text = ""
tvStaffName.setText(R.string.no_staff)
}
tvOfficeId.text = center.officeId.toString()
tvOfficeName.text = center.officeName
ivStatusIndicator.setImageDrawable(
Utils.setCircularBackground(
if(center.active) R.color.light_green else R.color.light_red,
itemView.context
)
)

//Changing the Color of Selected Centers
viewSelectedOverlay.setBackgroundColor(
if (isSelected(position))
ContextCompat.getColor(itemView.context,R.color.gray_light)
else Color.WHITE
)
ivSyncStatus.visibility = if (center.isSync) View.VISIBLE else View.INVISIBLE
}
}


fun setCenters(centers: List<Center>) {
this.centers = centers
notifyDataSetChanged()
}

fun getItem(position: Int) = centers[position]


override fun getItemId(i: Int) = 0L

override fun getItemCount() = centers.size


class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
val ivStatusIndicator: CircularImageView = v.findViewById(R.id.iv_status_indicator)
val tvAccountNumber: TextView = v.findViewById(R.id.tv_account_number)
val tvCenterName: TextView = v.findViewById(R.id.tv_center_name)
val tvCenterId: TextView = v.findViewById(R.id.tv_center_id)
val tvStaffName: TextView = v.findViewById(R.id.tv_staff_name)
val tvStaffId: TextView = v.findViewById(R.id.tv_staff_id)
val tvOfficeName: TextView = v.findViewById(R.id.tv_office_name)
val tvOfficeId: TextView = v.findViewById(R.id.tv_office_id)
val viewSelectedOverlay: LinearLayout = v.findViewById(R.id.linearLayout)
val ivSyncStatus: ImageView = v.findViewById(R.id.iv_sync_status)
}

}
Loading

0 comments on commit 0f219b1

Please sign in to comment.