add project adins

This commit is contained in:
Alfrid Sanjaya Leo Putra 2024-07-25 14:44:22 +07:00
commit f8f85d679d
5299 changed files with 625430 additions and 0 deletions

View file

@ -0,0 +1,15 @@
package com.adins.mss.foundation.camera;
/**
* Interface to receive image and location after capture image
*
* @author bong.rk
*/
public interface ImageCallBack {
/**
* @param image - image byte, result of image capturing
* @param locationBean - location listener to get location
*/
public void onPictureTaken(byte[] image, Object locationBean);
}

View file

@ -0,0 +1,200 @@
package com.adins.mss.base.loyalti.monthlypointacquisition;
import com.adins.mss.base.loyalti.model.GroupPointData;
import com.adins.mss.base.loyalti.model.LoyaltyPointsRequest;
import com.adins.mss.base.loyalti.model.LoyaltyPointsResponse;
import com.adins.mss.base.loyalti.model.PointDetail;
import com.adins.mss.base.loyalti.model.RankDetail;
import com.adins.mss.base.loyalti.monthlypointacquisition.contract.ILoyaltyPointsDataSource;
import com.adins.mss.base.loyalti.monthlypointacquisition.contract.MonthlyPointContract;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class MonthlyPointsPresenter implements MonthlyPointContract.Presenter, ILoyaltyPointsDataSource.ReqPointsListener {
private MonthlyPointContract.View view;
private MonthlyPointsLogic monthlyPointsLogic;
//data hold
private LoyaltyPointsResponse pointsData;
public MonthlyPointsPresenter(MonthlyPointContract.View view, MonthlyPointsLogic logic) {
this.view = view;
this.monthlyPointsLogic = logic;
}
@Override
public void init() {
//no operation on init
}
@Override
public void getMonthlyPointsData(LoyaltyPointsRequest reqData) {
monthlyPointsLogic.getMonthlyPointsData(reqData,this);
}
@Override
public float getAvgPoint() {
return monthlyPointsLogic.getAvgPoint(pointsData.dataDetail);
}
@Override
public int getMaxPoint() {
return monthlyPointsLogic.getMaxPoint(pointsData.dataDetail);
}
@Override
public int getTotalPoints() {
return monthlyPointsLogic.getTotalPoints(pointsData.dataDetail);
}
@Override
public int getCurrentMonth() {
Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
int currMonth = calendar.get(Calendar.MONTH);
if(currMonth < 0)
return 0;//default use january when error
else if(currMonth >= 12)
currMonth = 11;
for (int i=0; i<pointsData.dataDetail.size(); i++) {
GroupPointData group = pointsData.dataDetail.get(i);
if(group == null)
continue;
int month = Integer.parseInt(group.getGroupPointValue()[0]);
if(month == currMonth+1){
currMonth = i;
break;
}
}
if(currMonth >= pointsData.dataDetail.size()){
currMonth = pointsData.dataDetail.size() - 1;
}
return currMonth;
}
@Override
public String[] getMonths() {
if(pointsData == null || pointsData.dataDetail.isEmpty())
return new String[]{};
String[] monthNames = new String[pointsData.dataDetail.size()];
Calendar calendar = Calendar.getInstance();
List<GroupPointData> groups = pointsData.dataDetail;
int monthIdx = 0;
for(int i=0; i<groups.size(); i++){
GroupPointData groupData = groups.get(i);
if(groupData.isMonth()){
monthIdx = Integer.valueOf(groupData.getGroupPointValue()[0]) - 1;
calendar.set(Calendar.MONTH,monthIdx);
monthNames[i] = calendar.getDisplayName(Calendar.MONTH,Calendar.LONG,Locale.getDefault());
}
}
return monthNames;
}
@Override
public GroupPointData getPointDataAt(int monthIdx) {
if(pointsData == null || pointsData.dataDetail.isEmpty())
return null;
if(monthIdx >= pointsData.dataDetail.size()){
return null;
}
return pointsData.dataDetail.get(monthIdx);
}
@Override
public List<PointDetail> getPointDetails() {
if(pointsData == null)
return new ArrayList<>();
List<PointDetail> pointCategories = new ArrayList<>();
for (GroupPointData groupPoint:pointsData.dataDetail) {
if(groupPoint == null)
continue;
if(groupPoint.pointDetails == null || groupPoint.pointDetails.isEmpty())
continue;
for (PointDetail pointDetail:groupPoint.pointDetails) {
if(pointDetail == null)
continue;
if(isContainsPointDetails(pointCategories,pointDetail.rewardProgram)){
continue;
}
pointCategories.add(pointDetail);
}
}
return pointCategories;
}
private boolean isContainsPointDetails(List<PointDetail> list,String rewardProgram){
boolean result = false;
for (PointDetail pointDetail:list){
if(pointDetail.rewardProgram.equals(rewardProgram)){
result = true;
break;
}
}
return result;
}
@Override
public List<RankDetail> getRanks() {
if(pointsData == null || pointsData.dataDetail.isEmpty())
return new ArrayList<>();
return pointsData.dataDetail.get(0).rankDetails;
}
@Override
public void onSuccess(LoyaltyPointsResponse pointsData) {
if(pointsData == null || pointsData.dataDetail.isEmpty()){
view.onGetDataFailed("No data detail found");
return;
}
this.pointsData = pointsData;
//convert point and rank data to 2d array to satisfy view
float[][] pointDataSet = new float[pointsData.dataDetail.size()][];
RankDetail[][] rankDataSet = new RankDetail[pointsData.dataDetail.size()][pointsData.dataDetail.get(0).rankDetails.size()];
List<PointDetail> pointDetailsDataSet = new ArrayList<>();
for(int i=0; i<pointDataSet.length; i++){
float[] yVals = new float[pointsData.dataDetail.get(i).pointDetails.size()];
for (int j=0; j<yVals.length; j++){
yVals[j] = Integer.parseInt(pointsData.dataDetail.get(i).pointDetails.get(j).point);
pointDetailsDataSet.add(pointsData.dataDetail.get(i).pointDetails.get(j));
}
pointDataSet[i] = yVals;
}
for(int i=0; i<rankDataSet.length; i++){
for (int j=0; j<rankDataSet[i].length; j++){
rankDataSet[i][j] = pointsData.dataDetail.get(i).rankDetails.get(j);
}
}
view.onDataReceived(pointDataSet,rankDataSet,pointDetailsDataSet);
}
@Override
public void onFailed(String message) {
view.onGetDataFailed(message);
}
}

View file

@ -0,0 +1,212 @@
package com.adins.mss.base.plugins;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.util.TypedValue;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
/**
* Created by Aditya Purwa on 1/5/2015.
* Used to create a fading action bar when the activity host a list view.
*/
public class FadingActionBarPlugin extends ActivityPlugin {
/**
* Background resource for the action bar.
*/
private final int actionBarBackground;
/**
* List view header. Fading action bar will only work with a list view that have a header.
*/
private final View listViewHeader;
/**
* List view to implement the fading action bar plugin to.
*/
private final ListView listView;
/**
* Used to check whether the list view scroll has already passed the header.
*/
private boolean isOutOfBounds;
/**
* Store reference to the action bar to apply the fade.
*/
private ActionBar actionBar;
/**
* Store reference to the action bar background drawable.
*/
private Drawable actionBarBackgroundDrawable;
/**
* Used to store the last alpha for the action bar background.
* This is used to increase performance to prevent background invalidation.
*/
private float lastAlpha;
/**
* Initialize a new instance of the fading action bar plugin.
* This will make the action bar fade in when the list view is scrolled pass through its header.
*
* @param context Context for the plugin. Must be an activity. To prevent unwanted graphical issue,
* request for action bar overlay mode for your activity, as there is unlikely
* any reason that you want a fading action bar for non overlay action bar.
* @param listView This could be any list view inside your activity.
* Preferably this list view should be the only view inside your activity.
* The list view must have a header added, leaving the list view header empty
* will result in undesired results.
* @param listViewHeader The header that have been added to the list view.
* @param actionBarBackground Resource id for the action bar drawable. This is the color that you want for your
* action bar.
*/
public FadingActionBarPlugin(Context context, ListView listView, View listViewHeader, int actionBarBackground) {
super(context);
this.listView = listView;
this.listViewHeader = listViewHeader;
this.actionBarBackground = actionBarBackground;
}
/**
* Gets the action bar background resource.
*
* @return Action bar background resource id.
*/
public int getActionBarBackground() {
return actionBarBackground;
}
/**
* Gets the list view for the plugin.
*
* @return List view.
*/
public ListView getListView() {
return listView;
}
@Override
protected boolean checkSupport() {
if (!(getContext() instanceof Activity)) {
return false;
}
if (listView == null) {
return false;
}
if (listViewHeader == null) {
return false;
}
return true;
}
@Override
public boolean apply() {
if (!checkSupport()) {
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
actionBarBackgroundDrawable = getContextAsActivity().getResources().getDrawable(actionBarBackground, getContext().getTheme());
} else {
actionBarBackgroundDrawable = getContextAsActivity().getResources().getDrawable(actionBarBackground);
}
setDrawableCallbackBelowJellyBeanMr2();
actionBar = getContextAsActivity().getActionBar();
actionBar.setBackgroundDrawable(actionBarBackgroundDrawable);
final float actionBarSize = getActionBarSize();
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
View header = view.getChildAt(0);
// The first child may be null, especially during initialization.
if (header != null) {
float peak = listViewHeader.getHeight() - actionBarSize;
float top = Math.abs(header.getTop());
if (top >= peak || firstVisibleItem > 0) {
isOutOfBounds = true;
processActionBarAlpha(1);
} else {
isOutOfBounds = false;
}
if (!isOutOfBounds) {
float normal = Math.abs(header.getTop()) / peak;
normal = normal >= 1 ? 1 : normal;
processActionBarAlpha(normal);
}
}
}
});
return true;
}
/**
* Get the size for the current active theme action bar.
*
* @return Size for the action bar, the height.
*/
private float getActionBarSize() {
TypedValue size = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.actionBarSize, size, true);
return size.getDimension(getContextAsActivity().getResources().getDisplayMetrics());
}
/**
* Used to handle drawable issue below JELLY_BEAN_MR2.
*/
private void setDrawableCallbackBelowJellyBeanMr2() {
// Invalidation issue below JELLY_BEAN_MR2.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
final Handler handler = new Handler();
actionBarBackgroundDrawable.setCallback(new Drawable.Callback() {
@Override
public void invalidateDrawable(Drawable who) {
actionBar.setBackgroundDrawable(who);
}
@Override
public void scheduleDrawable(Drawable who, Runnable what, long when) {
handler.postAtTime(what, when);
}
@Override
public void unscheduleDrawable(Drawable who, Runnable what) {
handler.removeCallbacks(what);
}
});
}
}
@Override
public void cancel() {
listView.setOnScrollListener(null);
processActionBarAlpha(1);
}
/**
* Process the action bar alpha and apply it to the action bar drawable.
*
* @param normal Normal value for the alpha.
*/
private void processActionBarAlpha(float normal) {
// Prevent background drawable invalidation to increase performance.
if (normal == lastAlpha) {
return;
}
actionBarBackgroundDrawable.setAlpha((int) (normal * 255));
actionBarBackgroundDrawable.invalidateSelf();
lastAlpha = normal;
}
}

View file

@ -0,0 +1,195 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.InstallmentSchedule;
import com.adins.mss.dao.InstallmentScheduleDao;
import com.adins.mss.foundation.db.DaoOpenHelper;
import java.util.Collections;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
public class InstallmentScheduleDataAccess {
private InstallmentScheduleDataAccess() {
}
/**
* use to generate dao session that you can access modelDao
*
* @param context --> context from activity
* @return
*/
protected static DaoSession getDaoSession(Context context) {
return DaoOpenHelper.getDaoSession(context);
}
/**
* get installmentSchedule dao and you can access the DB
*
* @param context
* @return
*/
protected static InstallmentScheduleDao getInstallmentScheduleDao(Context context) {
return getDaoSession(context).getInstallmentScheduleDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
DaoOpenHelper.closeAll();
}
/**
* add installmentSchedule as entity
*
* @param context
* @param installmentSchedule
*/
public static void add(Context context, InstallmentSchedule installmentSchedule) {
getInstallmentScheduleDao(context).insertInTx(installmentSchedule);
getDaoSession(context).clear();
}
/**
* add installmentSchedule as list entity
*
* @param context
* @param installmentScheduleList
*/
public static void add(Context context, List<InstallmentSchedule> installmentScheduleList) {
getInstallmentScheduleDao(context).insertInTx(installmentScheduleList);
getDaoSession(context).clear();
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getInstallmentScheduleDao(context).deleteAll();
getDaoSession(context).clear();
}
/**
* @param context
* @param installmentSchedule
*/
public static void delete(Context context, InstallmentSchedule installmentSchedule) {
getInstallmentScheduleDao(context).deleteInTx(installmentSchedule);
getDaoSession(context).clear();
}
/**
* delete data by uuidTaskH
*
* @param context
* @param uuidTaskH
*/
public static void delete(Context context, String uuidTaskH) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.where(InstallmentScheduleDao.Properties.Uuid_task_h.eq(uuidTaskH));
qb.build();
if (!qb.list().isEmpty()) {
getInstallmentScheduleDao(context).deleteInTx(qb.list());
}
getDaoSession(context).clear();
}
public static void deleteByAgreementNo(Context context, String agreement_no) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.where(InstallmentScheduleDao.Properties.Agreement_no.eq(agreement_no));
qb.build();
if (!qb.list().isEmpty()) {
getInstallmentScheduleDao(context).deleteInTx(qb.list());
}
getDaoSession(context).clear();
}
/**
* @param context
* @param installmentSchedule
*/
public static void update(Context context, InstallmentSchedule installmentSchedule) {
getInstallmentScheduleDao(context).update(installmentSchedule);
getDaoSession(context).clear();
}
public static void addOrReplace(Context context, InstallmentSchedule installmentSchedule) {
getInstallmentScheduleDao(context).insertOrReplaceInTx(installmentSchedule);
getDaoSession(context).clear();
}
public static void addOrReplace(Context context, List<InstallmentSchedule> installmentSchedules) {
getInstallmentScheduleDao(context).insertOrReplaceInTx(installmentSchedules);
getDaoSession(context).clear();
}
private static InstallmentSchedule getOne(Context context, String agreementNo) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.where(InstallmentScheduleDao.Properties.Agreement_no.eq(agreementNo));
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
private static InstallmentSchedule getOneInst(Context context, String uuid_installment) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.where(InstallmentScheduleDao.Properties.Uuid_installment_schedule.eq(uuid_installment));
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
//
// /**
// * select * from table where uuid_user = param
// *
// * @param context
// * @param uuidUser
// * @return
// */
public static List<InstallmentSchedule> getAll(Context context) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.build();
return qb.list();
}
/**
* get all data by agreementNo
*
* @param context
* @param agreementNo
* @return
*/
public static List<InstallmentSchedule> getAll(Context context, String agreementNo) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.where(InstallmentScheduleDao.Properties.Agreement_no.eq(agreementNo));
qb.build();
if (!qb.list().isEmpty()) {
return qb.list();
} else return Collections.emptyList();
}
/**
* select installmentSchedule per
*
* @param context
* @return
*/
public static List<InstallmentSchedule> getAllByTask(Context context, String uuidTaskH) {
QueryBuilder<InstallmentSchedule> qb = getInstallmentScheduleDao(context).queryBuilder();
qb.where(InstallmentScheduleDao.Properties.Uuid_task_h.eq(uuidTaskH));
qb.build();
if (!qb.list().isEmpty()) {
return qb.list();
} else return Collections.emptyList();
}
}

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lookupReviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_medium"
android:background="@color/tv_white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0."
android:paddingRight="@dimen/ptr_progress_bar_stroke_width"
android:layout_alignParentLeft="true"
android:id="@+id/questionNoLabel" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="label"
android:layout_toRightOf="@+id/questionNoLabel"
android:id="@+id/questionTextLabel" />
<TableLayout
android:layout_below="@id/questionTextLabel"
android:id="@+id/reviewLookupAnswerLayout"
android:layout_width="match_parent"
android:stretchColumns="1"
android:layout_height="wrap_content">
</TableLayout>
<TextView
android:id="@+id/questionTextAnswer"
android:layout_width="match_parent"
android:text="answer"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Small"
android:layout_below="@+id/reviewLookupAnswerLayout"
android:layout_toRightOf="@+id/questionNoLabel"
android:layout_toEndOf="@+id/questionNoLabel" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/line_height"
android:background="@color/tv_gray"
android:layout_below="@+id/questionTextAnswer"/>
</RelativeLayout>

View file

@ -0,0 +1,379 @@
package com.adins.mss.coll.fragments;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.checkin.CheckInManager;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.util.LocaleHelper;
import com.adins.mss.coll.R;
import com.adins.mss.coll.api.CollectionActivityApi;
import com.adins.mss.coll.commons.Toaster;
import com.adins.mss.coll.models.CollectionActivityResponse;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.CollectionActivity;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.UserHelp.UserHelp;
import com.adins.mss.foundation.db.dataaccess.CollectionActivityDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.location.UpdateMenuIcon;
import com.google.firebase.analytics.FirebaseAnalytics;
import org.acra.ACRA;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
/**
* Created by dian.ina on 07/05/2015.
*/
public class CollectionActivityFragment extends AppCompatActivity {
public CollectionActivityResponse collActivityResponse;
ImageButton button;
private String taskId;
private ConnectivityManager connectivityManager;
private NetworkInfo activeNetworkInfo;
private List<CollectionActivity> collectionActivityLocalList = null;
public static CollectionActivity itemCollectionActivity;
private FirebaseAnalytics screenName;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
screenName = FirebaseAnalytics.getInstance(this);
setContentView(R.layout.new_fragment_collection_activity);
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
Bundle bundle = getIntent().getExtras();
taskId = bundle.getString(Global.BUND_KEY_TASK_ID);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.title_mn_collectionactivity));
toolbar.setTitleTextColor(getResources().getColor(com.adins.mss.base.R.color.fontColorWhite));
setSupportActionBar(toolbar);
TaskH taskH = TaskHDataAccess.getOneTaskHeader(this, taskId);
collectionActivityLocalList = CollectionActivityDataAccess.getAllbyTask(this, taskH.getUuid_task_h());
connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
loadData();
button = (ImageButton) findViewById(R.id.imageBtnDownload);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
button.setEnabled(false);
button.setClickable(false);
try {
saveData(getApplicationContext(), collActivityResponse);
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().handleSilentException(new Exception("Error: download collection activity Error. "+ e.getMessage()));
}
}
});
}
@Override
protected void onResume() {
super.onResume();
//Set Firebase screen name
screenName.setCurrentScreen(this, getString(R.string.screen_name_collection_act), null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(com.adins.mss.base.R.menu.main_menu, menu);
mainMenu = menu;
return true;
}
@Override
public void onBackPressed() {
if(!Global.BACKPRESS_RESTRICTION) {
super.onBackPressed();
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
updateMenuIcon(Global.isGPS);
if(Global.ENABLE_USER_HELP &&
(Global.userHelpGuide.get(CollectionActivityFragment.this.getClass().getSimpleName())!=null) ||
Global.userHelpDummyGuide.get(CollectionActivityFragment.this.getClass().getSimpleName()) != null){
menu.findItem(com.adins.mss.base.R.id.mnGuide).setVisible(true);
}
return super.onPrepareOptionsMenu(menu);
}
private static Menu mainMenu;
public static void updateMenuIcon(boolean isGPS) {
UpdateMenuIcon uItem = new UpdateMenuIcon();
uItem.updateGPSIcon(mainMenu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == com.adins.mss.base.R.id.mnGPS && Global.LTM != null) {
if (Global.LTM.getIsConnected()) {
Global.LTM.removeLocationListener();
Global.LTM.connectLocationClient();
} else {
CheckInManager.startGPSTracking(getApplicationContext());
}
Animation a = AnimationUtils.loadAnimation(this, com.adins.mss.base.R.anim.gps_rotate);
findViewById(com.adins.mss.base.R.id.mnGPS).startAnimation(a);
}
if(item.getItemId() == R.id.mnGuide && !Global.BACKPRESS_RESTRICTION){
UserHelp.reloadUserHelp(getApplicationContext(), CollectionActivityFragment.this);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
UserHelp.showAllUserHelp(CollectionActivityFragment.this, CollectionActivityFragment.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
}
return super.onOptionsItemSelected(item);
}
@Override
protected void attachBaseContext(Context newBase) {
Context context = newBase;
Locale locale;
try{
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
context = LocaleHelper.wrap(newBase, locale);
} catch (Exception e) {
locale = new Locale(LocaleHelper.ENGLSIH);
context = LocaleHelper.wrap(newBase, locale);
} finally {
super.attachBaseContext(context);
}
}
protected void saveData(Context context, CollectionActivityResponse collActResp) {
if(collActResp!=null && collActResp.getStatus().getCode()==0){
List<CollectionActivity> collectionActivityList = collActResp.getCollectionHistoryList();
if(collectionActivityList!=null&&!collectionActivityList.isEmpty()){
TaskH taskH = TaskHDataAccess.getOneTaskHeader(context, taskId);
CollectionActivityDataAccess.delete(context, taskH.getUuid_task_h());
for(CollectionActivity collectionActivity : collectionActivityList){
if (collectionActivity.getUuid_collection_activity() == null){
collectionActivity.setUuid_collection_activity(Tool.getUUID());
}
collectionActivity.setUuid_task_h(taskH.getUuid_task_h());
}
CollectionActivityDataAccess.add(getApplicationContext(), collectionActivityList);
}
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.data_saved), Toast.LENGTH_SHORT).show();
}else{
Toaster.warning(context, context.getString(R.string.failed_save_data));
}
button.setEnabled(true);
button.setClickable(true);
}
public void loadData() {
new AsyncTask<Void, Void, CollectionActivityResponse>() {
private ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(CollectionActivityFragment.this,
"", getString(R.string.progressWait), true);
}
@Override
protected CollectionActivityResponse doInBackground(Void... params) {
CollectionActivityApi api = new CollectionActivityApi(CollectionActivityFragment.this);
try {
//bong 21 mei 15 - check internet connection
if(Tool.isInternetconnected(getApplicationContext())){
return api.request(taskId);
}
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Override
protected void onPostExecute(CollectionActivityResponse collectionActivityResponse) {
super.onPostExecute(collectionActivityResponse);
if (progressDialog!=null&&progressDialog.isShowing()){
try {
progressDialog.dismiss();
} catch (Exception e) { FireCrash.log(e);
}
}
if(!GlobalData.isRequireRelogin()) {
if (collectionActivityResponse == null) {
TaskH taskH = TaskHDataAccess.getOneTaskHeader(getApplicationContext(), taskId);
if (taskH != null) {
List<CollectionActivity> collectionActivityList = CollectionActivityDataAccess.getAllbyTask(getApplicationContext(), taskH.getUuid_task_h());
if (collectionActivityList != null && !collectionActivityList.isEmpty()) {
TextView agreementNumber = (TextView) findViewById(R.id.agreementNumber);
agreementNumber.setText(collectionActivityList.get(0).getAgreement_no());
TableLayout table = (TableLayout) findViewById(R.id.tableHeaders);
int index = 1;
for (CollectionActivity item : collectionActivityList) {
View row = LayoutInflater.from(CollectionActivityFragment.this).inflate(R.layout.view_row_collection_activity, table, false);
TextView no = (TextView) row.findViewById(R.id.no);
TextView activityDate = (TextView) row.findViewById(R.id.activityDate);
TextView action = (TextView) row.findViewById(R.id.action);
TextView collectorName = (TextView) row.findViewById(R.id.collectorName);
row.setTag(item);
no.setText(String.valueOf(index++));
activityDate.setText(Formatter.formatDate(item.getActivity_date(), Global.DATE_STR_FORMAT));
action.setText(item.getActivity());
collectorName.setText(item.getCollector_name());
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemCollectionActivity = (CollectionActivity) v.getTag();
Intent intent = new Intent(CollectionActivityFragment.this, CollectionActivityDetailFragment.class);
startActivity(intent);
}
});
table.addView(row);
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
UserHelp.showAllUserHelp(CollectionActivityFragment.this, CollectionActivityFragment.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
} else {
NiftyDialogBuilder.getInstance(CollectionActivityFragment.this)
.withMessage(getString(R.string.no_data_found_offline))
.withTitle(getString(R.string.no_data_found_offline))
.isCancelableOnTouchOutside(false)
.withButton1Text(getString(R.string.btnClose))
.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
NiftyDialogBuilder.getInstance(CollectionActivityFragment.this).dismiss();
}
})
.show();
}
}
}
else if (collectionActivityResponse.getStatus().getCode() != 0) {
NiftyDialogBuilder.getInstance(CollectionActivityFragment.this)
.withMessage(collectionActivityResponse.getStatus().getMessage())
.withTitle(getString(R.string.server_error))
.isCancelableOnTouchOutside(false)
.withButton1Text(getString(R.string.btnClose))
.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
})
.show();
return;
}
else {
collActivityResponse = collectionActivityResponse;
TextView agreementNumber = (TextView) findViewById(R.id.agreementNumber);
agreementNumber.setText(collectionActivityResponse.getAgreementNo());
TableLayout table = (TableLayout) findViewById(R.id.tableHeaders);
int index = 1;
for (CollectionActivity item : collectionActivityResponse.getCollectionHistoryList()) {
View row = LayoutInflater.from(CollectionActivityFragment.this).inflate(R.layout.view_row_collection_activity, table, false);
TextView no = (TextView) row.findViewById(R.id.no);
TextView activityDate = (TextView) row.findViewById(R.id.activityDate);
TextView action = (TextView) row.findViewById(R.id.action);
TextView collectorName = (TextView) row.findViewById(R.id.collectorName);
row.setTag(item);
no.setText(String.valueOf(index++));
activityDate.setText(Formatter.formatDate(item.getActivity_date(), Global.DATE_STR_FORMAT));
action.setText(item.getActivity());
collectorName.setText(item.getCollector_name());
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemCollectionActivity = (CollectionActivity) v.getTag();
Intent intent = new Intent(CollectionActivityFragment.this, CollectionActivityDetailFragment.class);
startActivity(intent);
}
});
table.addView(row);
}
if (collectionActivityResponse.getCollectionHistoryList().isEmpty()) {
NiftyDialogBuilder.getInstance(CollectionActivityFragment.this)
.withMessage(R.string.no_data_from_server)
.withTitle(getString(R.string.info_capital))
.isCancelableOnTouchOutside(false)
.withButton1Text(getString(R.string.btnClose))
.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
})
.show();
} else {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
UserHelp.showAllUserHelp(CollectionActivityFragment.this, CollectionActivityFragment.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
}
}
}
}
}.execute();
}
}

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 Chris Banes
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@id/ptr_content"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?android:attr/colorBackground">
<TextView
android:id="@id/ptr_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center" />
</FrameLayout>
<fr.castorflex.android.smoothprogressbar.SmoothProgressBar
android:id="@id/ptr_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/ptr_progress_bar_stroke_width"/>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/logContainer">
<androidx.cardview.widget.CardView
android:id="@+id/closingTaskItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="5dp"
app:cardElevation="@dimen/card_shadow"
android:layout_margin="@dimen/card_margin"
app:cardBackgroundColor="@color/fontColorWhite">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/lblContractNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:paddingBottom="5dp"
android:text="@string/label_agreement_no"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_form_color"
android:drawableTint="@color/colorMC"
android:drawablePadding="5dp"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/contractNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:layout_marginLeft="5dp"
android:paddingBottom="5dp"
android:text="Sample Contract No"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/lblCustomerName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="@string/customer_name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_person_color"
android:drawableTint="@color/colorMC"
android:drawablePadding="5dp"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/customerName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="0.4"
android:text="Sample Name"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,104 @@
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
app:cardBackgroundColor="@color/fontColorWhite"
app:cardCornerRadius="10dp"
app:cardElevation="5dp"
app:contentPadding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--<ImageView-->
<!--android:id="@+id/imgPromo"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="200dp"-->
<!--android:scaleType="center"-->
<!--android:src="@drawable/img_notavailable" />-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.viewpager.widget.ViewPager
android:id="@+id/newsImage"
android:layout_width="match_parent"
android:layout_height="300dp" />
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@drawable/bg_indicator" />
<LinearLayout
android:id="@+id/pagesContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginBottom="30dp"
android:gravity="center_horizontal"
android:orientation="horizontal" />
<!--<ImageView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_alignBottom="@+id/newsImage"-->
<!--android:layout_alignTop="@+id/newsImage"-->
<!--android:layout_alignRight="@+id/newsImage"-->
<!--android:layout_marginRight="10dp"-->
<!--android:src="@drawable/"/>-->
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:drawablePadding="5dp"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:drawablePadding="5dp"
android:text="Desc"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<ImageView
android:id="@+id/imgShare"
android:layout_weight="1"
android:layout_height="50dp"
android:layout_width="50dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:src="@drawable/ic_share_black_24dp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>