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,221 @@
package com.adins.mss.dao;
import com.adins.mss.dao.DaoSession;
import de.greenrobot.dao.DaoException;
import com.adins.mss.base.util.ExcludeFromGson;
import com.google.gson.annotations.SerializedName;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table "TR_RECEIPTVOUCHER".
*/
public class ReceiptVoucher {
/** Not-null value. */
@SerializedName("uuid_rv_number")
private String uuid_receipt_voucher;
@SerializedName("status_rv")
private String rv_status;
@SerializedName("rv_number")
private String rv_number;
@SerializedName("flag_sources")
private String flag_sources;
@SerializedName("usr_crt")
private String usr_crt;
@SerializedName("dtm_crt")
private java.util.Date dtm_crt;
@SerializedName("dtm_use")
private java.util.Date dtm_use;
@SerializedName("uuid_user")
private String uuid_user;
@SerializedName("uuid_task_h")
private String uuid_task_h;
/** Used to resolve relations */
private transient DaoSession daoSession;
/** Used for active entity operations. */
private transient ReceiptVoucherDao myDao;
private User user;
private String user__resolvedKey;
private TaskH taskH;
private String taskH__resolvedKey;
public ReceiptVoucher() {
}
public ReceiptVoucher(String uuid_receipt_voucher) {
this.uuid_receipt_voucher = uuid_receipt_voucher;
}
public ReceiptVoucher(String uuid_receipt_voucher, String rv_status, String rv_number, String flag_sources, String usr_crt, java.util.Date dtm_crt, java.util.Date dtm_use, String uuid_user, String uuid_task_h) {
this.uuid_receipt_voucher = uuid_receipt_voucher;
this.rv_status = rv_status;
this.rv_number = rv_number;
this.flag_sources = flag_sources;
this.usr_crt = usr_crt;
this.dtm_crt = dtm_crt;
this.dtm_use = dtm_use;
this.uuid_user = uuid_user;
this.uuid_task_h = uuid_task_h;
}
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getReceiptVoucherDao() : null;
}
/** Not-null value. */
public String getUuid_receipt_voucher() {
return uuid_receipt_voucher;
}
/** Not-null value; ensure this value is available before it is saved to the database. */
public void setUuid_receipt_voucher(String uuid_receipt_voucher) {
this.uuid_receipt_voucher = uuid_receipt_voucher;
}
public String getRv_status() {
return rv_status;
}
public void setRv_status(String rv_status) {
this.rv_status = rv_status;
}
public String getRv_number() {
return rv_number;
}
public void setRv_number(String rv_number) {
this.rv_number = rv_number;
}
public String getFlag_sources() {
return flag_sources;
}
public void setFlag_sources(String flag_sources) {
this.flag_sources = flag_sources;
}
public String getUsr_crt() {
return usr_crt;
}
public void setUsr_crt(String usr_crt) {
this.usr_crt = usr_crt;
}
public java.util.Date getDtm_crt() {
return dtm_crt;
}
public void setDtm_crt(java.util.Date dtm_crt) {
this.dtm_crt = dtm_crt;
}
public java.util.Date getDtm_use() {
return dtm_use;
}
public void setDtm_use(java.util.Date dtm_use) {
this.dtm_use = dtm_use;
}
public String getUuid_user() {
return uuid_user;
}
public void setUuid_user(String uuid_user) {
this.uuid_user = uuid_user;
}
public String getUuid_task_h() {
return uuid_task_h;
}
public void setUuid_task_h(String uuid_task_h) {
this.uuid_task_h = uuid_task_h;
}
/** To-one relationship, resolved on first access. */
public User getUser() {
String __key = this.uuid_user;
if (user__resolvedKey == null || user__resolvedKey != __key) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
UserDao targetDao = daoSession.getUserDao();
User userNew = targetDao.load(__key);
synchronized (this) {
user = userNew;
user__resolvedKey = __key;
}
}
return user;
}
public void setUser(User user) {
synchronized (this) {
this.user = user;
uuid_user = user == null ? null : user.getUuid_user();
user__resolvedKey = uuid_user;
}
}
/** To-one relationship, resolved on first access. */
public TaskH getTaskH() {
String __key = this.uuid_task_h;
if (taskH__resolvedKey == null || taskH__resolvedKey != __key) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
TaskHDao targetDao = daoSession.getTaskHDao();
TaskH taskHNew = targetDao.load(__key);
synchronized (this) {
taskH = taskHNew;
taskH__resolvedKey = __key;
}
}
return taskH;
}
public void setTaskH(TaskH taskH) {
synchronized (this) {
this.taskH = taskH;
uuid_task_h = taskH == null ? null : taskH.getUuid_task_h();
taskH__resolvedKey = uuid_task_h;
}
}
/** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
}

View file

@ -0,0 +1,21 @@
package com.adins.mss.base.commons;
import android.location.Location;
import com.google.android.gms.location.LocationListener;
/**
* Created by kusnendi.muhamad on 26/07/2017.
*/
public class LocationServices implements LocationListener {
/**
* Method for listening location change
*/
@Override
public void onLocationChanged(Location location) {
//
}
}

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/ntf_no"
android:gravity="left" />
<View
android:id="@+id/view_line"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/ntf_name"
android:gravity="left" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/ntf_amount"
android:gravity="right|center" />
</TableRow>

View file

@ -0,0 +1,345 @@
package com.adins.mss.odr;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.NewMainActivity;
import com.adins.mss.base.about.activity.AboutActivity;
import com.adins.mss.base.mainmenu.NewMenuItem;
import com.adins.mss.base.timeline.NewTimelineFragment;
import com.adins.mss.base.todo.form.GetSchemeTask;
import com.adins.mss.base.todolist.form.NewToDoListTabFragment;
import com.adins.mss.base.util.LocaleHelper;
import com.adins.mss.constant.Global;
import com.adins.mss.odr.accounts.GetAccount;
import com.adins.mss.odr.catalogue.api.GetPromo;
import com.adins.mss.odr.followup.FragmentFollowUpSearch;
import com.adins.mss.odr.marketingreport.MarketingReportFragment;
import com.adins.mss.odr.news.NewsHeaderTask;
import com.adins.mss.odr.opportunities.FragmentOpportunities;
import com.adins.mss.odr.products.FragmentProduct;
import com.adins.mss.base.loyalti.mypointdashboard.DashboardMyPoint;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.services.ForegroundServiceNotification;
import com.services.MOApplicationRunningService;
import com.services.MainServices;
import com.services.NotificationThread;
import java.util.Locale;
/**
* Created by Wendy.Alexander on 02/10/2019.
*/
public class NewMOMainActivity extends NewMainActivity {
private FirebaseAnalytics screenName;
@Override
public void onCreate(Bundle savedInstanceState) {
NewMainActivity.setMss(this.getClass());
super.onCreate(savedInstanceState);
navigation = findViewById(com.adins.mss.base.R.id.bottomNav);
navigation.getMenu().findItem(R.id.taskListNav).setTitle("Check Order");
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
navCounter = findViewById(com.adins.mss.base.R.id.counter);
navCounter.setVisibility(View.INVISIBLE);
screenName = FirebaseAnalytics.getInstance(this);
AboutActivity.setChangeLog(ChangeLog.getChangeLog(getApplicationContext()), 1);
if (savedInstanceState == null) {
Fragment frag = new NewTimelineFragment();
FragmentTransaction trans = fragmentManager.beginTransaction();
trans.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
trans.add(com.adins.mss.base.R.id.content_frame, frag);
trans.commit();
}
}
@Override
protected void attachBaseContext(Context newBase) {
Context context = newBase;
Locale locale;
try {
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
if (null == locale) {
locale = new Locale(LocaleHelper.ENGLSIH);
}
context = LocaleHelper.wrap(newBase, locale);
} catch (Exception e) {
locale = new Locale(LocaleHelper.ENGLSIH);
context = LocaleHelper.wrap(newBase, locale);
} finally {
super.attachBaseContext(context);
}
}
@Override
public void onResume() {
super.onResume();
//Set Firebase screen name
screenName.setCurrentScreen(this, getString(R.string.screen_name_odr_main_menu), null);
if (Global.REDIRECT_TIMELINE.equals(Global.getREDIRECT())) {
super.openTimeline();
Global.setREDIRECT(null);
return;
}
if (!ForegroundServiceNotification.isServiceAvailable(this, MOApplicationRunningService.class)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(getLocationServiceIntent());
} else {
startService(getLocationServiceIntent());
}
}
Global.syncIntent = new Intent(getApplicationContext(), MOSynchronizeActivity.class);
if (NewMainActivity.getMss() == null) {
NewMainActivity.setMss(this.getClass());
MainServices.mainClass = mss;
}
NewMainActivity.setMainMenuClass(NewMOMainActivity.class);
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
@Override
public Intent getLocationServiceIntent() {
//Location service turned off for MO, Application Running Notification instead
return new Intent(this, MOApplicationRunningService.class);
}
protected void actionFromNotif(Intent intent) {
try {
String action = intent.getAction();
if (action != null) {
if (action.equals(NotificationThread.TASKLIST_NOTIFICATION_KEY)) {
if (Global.PLAN_TASK_ENABLED) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.mn_plantask));
} else {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_tasklist));
}
Fragment fragment1 = new NewToDoListTabFragment();
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment1);
transaction.addToBackStack(null);
transaction.commitAllowingStateLoss();
} else if (action.equals(Global.MAINMENU_NOTIFICATION_KEY)) {
gotoTimeline();
}
}
} catch (Exception e) {
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
actionFromNotif(intent);
}
@Override
protected Intent getIntentSynchronize() {
return new Intent(this, MOSynchronizeActivity.class);
}
@Override
protected void ApplicationMenu(NewMenuItem menuItem) {
super.ApplicationMenu(menuItem);
Global.isNewlead = false;
if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_newlead))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_newlead));
gotoNewLead();
} else if (menuItem.getName().equalsIgnoreCase(getString(R.string.title_mn_account))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_account));
gotoAccount();
} else if (menuItem.getName().equalsIgnoreCase(getString(R.string.title_mn_followup))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_followup));
gotoFollowUp();
} else if (menuItem.getName().equalsIgnoreCase(getString(R.string.title_mn_marketingreport))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_marketingreport));
gotoMktReport();
} else if (menuItem.getName().equalsIgnoreCase(getString(R.string.title_mn_catalogue))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_catalogue));
gotoCatalogue();
} else if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_products))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_products));
gotoProducts();
} else if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_opportunities))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_opportunities));
gotoOpportunities();
} else if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_cancelorder))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_cancelorder));
gotoCancelOrder();
} else if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_checkorder))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_checkorder));
gotoCheckOrder();
} else if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_promo))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_promo));
gotoPromo();
} else if (menuItem.getName().equalsIgnoreCase(getString(com.adins.mss.base.R.string.title_mn_neworder))) {
logEventCountMenuAccessed(getString(com.adins.mss.base.R.string.title_mn_neworder));
gotoNewTask();
} else if (menuItem.getName().equalsIgnoreCase(getString(R.string.title_mn_dashboard))) {
logEventCountMenuAccessed(getString(R.string.title_mn_dashboard));
goToDashboardMyPoint();
}
}
private void gotoOpportunities() {
fragment = new FragmentOpportunities();
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, com.adins.mss.base.R.anim.activity_close_scale,
com.adins.mss.base.R.anim.activity_open_scale, com.adins.mss.base.R.anim.activity_close_translate);
transaction.replace(com.adins.mss.base.R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
protected void gotoNewLead() {
Global.isNewlead = true;
GetSchemeTask task = new GetSchemeTask(this, new MONewTaskActivity(), true);
task.execute();
}
@Override
public void gotoTimeline() {
super.gotoTimeline();
}
@Override
protected void gotoAbout() {
AboutActivity.setChangeLog(ChangeLog.getChangeLog(this), 1);
super.gotoAbout();
}
protected void gotoAccount() {
GetAccount task = new GetAccount(this);
task.execute();
}
protected void gotoFollowUp() {
fragment = new FragmentFollowUpSearch();
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, com.adins.mss.base.R.anim.activity_close_scale,
com.adins.mss.base.R.anim.activity_open_scale, com.adins.mss.base.R.anim.activity_close_translate);
transaction.replace(com.adins.mss.base.R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
protected void gotoMktReport() {
fragment = new MarketingReportFragment();
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, com.adins.mss.base.R.anim.activity_close_scale,
com.adins.mss.base.R.anim.activity_open_scale, com.adins.mss.base.R.anim.activity_close_translate);
transaction.replace(com.adins.mss.base.R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
protected void gotoCatalogue() {
GetPromo task = new GetPromo(this);
task.execute();
}
private void gotoProducts() {
fragment = new FragmentProduct();
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, com.adins.mss.base.R.anim.activity_close_scale,
com.adins.mss.base.R.anim.activity_open_scale, com.adins.mss.base.R.anim.activity_close_translate);
transaction.replace(com.adins.mss.base.R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
protected void gotoCancelOrder() {
fragment = new OrderFilterActivity();
Bundle args = new Bundle();
args.putInt(Global.BUND_KEY_TASK_TYPE, Global.TASK_CANCEL_ORDER);
fragment.setArguments(args);
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction
.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
transaction.replace(com.adins.mss.base.R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
protected void gotoCheckOrder() {
fragment = new CheckOrderActivity();
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction
.setCustomAnimations(com.adins.mss.base.R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
transaction.replace(com.adins.mss.base.R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
protected void gotoNewTask() {
Global.isNewlead = false;
GetSchemeTask task = new GetSchemeTask(this, new MONewTaskActivity(), true);
task.execute();
}
protected void gotoPromo() {
NewsHeaderTask task = new NewsHeaderTask(this, getResources().getString(R.string.progressWait), getString(R.string.msgNoList), R.id.content_frame);
task.execute();
}
protected void goToDashboardMyPoint(){
fragment = new DashboardMyPoint();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale,
R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
if (Global.BACKPRESS_RESTRICTION) {
return false;
}
int i = menuItem.getItemId();
if (i == com.adins.mss.base.R.id.timelineNav) {
gotoTimeline();
return true;
} else if (i == com.adins.mss.base.R.id.menuNav) {
gotoMainMenu();
return true;
} else if (i == com.adins.mss.base.R.id.taskListNav) {
gotoCheckOrder();
return true;
}
return false;
}
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,95 @@
package com.adins.mss.base.todolist.form.followup;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.adins.mss.base.NewMainActivity;
import com.adins.mss.base.R;
import com.adins.mss.base.todolist.form.OnTaskListClickListener;
import com.adins.mss.base.todolist.form.PriorityViewAdapter;
import com.adins.mss.dao.TaskH;
import java.util.ArrayList;
import java.util.List;
public class FollowUpAdapter extends PriorityViewAdapter {
private List<TaskH> mValues;
private List<FollowUpTask> followUpTasks;
private Context mContext;
private OnTaskListClickListener mListener;
public FollowUpAdapter(Context context, List<TaskH> items, OnTaskListClickListener listener, String param) {
super(context, items, listener, param);
mValues = items;
mListener = listener;
mContext = context;
}
public void setFollowUpTasks (List<FollowUpTask> followUpTasks){
this.followUpTasks = followUpTasks;
List<TaskH> taskHList = new ArrayList<>();
for(FollowUpTask task : followUpTasks){
taskHList.add(task.getFollowUpTaskHeader());
}
changeDataset(taskHList);
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_task_list_item, parent, false);
return new FollowUpViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
final TaskH taskH = followUpTasks.get(position).getFollowUpTaskHeader();
holder.bind(taskH);
holder.imgStatus.setVisibility(View.GONE);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putString("uuidTaskH", taskH.getUuid_task_h());
bundle.putString("customerName", taskH.getCustomer_name());
bundle.putString("agreementNo", taskH.getAppl_no());
bundle.putString("flagTask", followUpTasks.get(position).getFlagTask());
bundle.putString("tglJanjiBayar", followUpTasks.get(position).getTglJanjiBayar());
FollowUpFormFragment fragment = new FollowUpFormFragment();
fragment.setArguments(bundle);
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
});
}
@Override
public int getItemCount() {
return followUpTasks != null ? followUpTasks.size() : 0;
}
public class FollowUpViewHolder extends PriorityViewAdapter.ViewHolder{
public FollowUpViewHolder(View view) {
super(view);
}
@Override
public void bind(TaskH taskH) {
super.bind(taskH);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,714 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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.
*/
package com.adins.libs.nineoldandroids.view;
import android.view.View;
import android.view.animation.Interpolator;
import com.adins.libs.nineoldandroids.animation.Animator;
import com.adins.libs.nineoldandroids.animation.ValueAnimator;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
class ViewPropertyAnimatorHC extends ViewPropertyAnimator {
/**
* Constants used to associate a property being requested and the mechanism used to set
* the property (this class calls directly into View to set the properties in question).
*/
private static final int NONE = 0x0000;
private static final int TRANSLATION_X = 0x0001;
private static final int TRANSLATION_Y = 0x0002;
private static final int SCALE_X = 0x0004;
private static final int SCALE_Y = 0x0008;
private static final int ROTATION = 0x0010;
private static final int ROTATION_X = 0x0020;
private static final int ROTATION_Y = 0x0040;
private static final int X = 0x0080;
private static final int Y = 0x0100;
private static final int ALPHA = 0x0200;
private static final int TRANSFORM_MASK = TRANSLATION_X | TRANSLATION_Y | SCALE_X | SCALE_Y |
ROTATION | ROTATION_X | ROTATION_Y | X | Y;
/**
* A WeakReference holding the View whose properties are being animated by this class.
* This is set at construction time.
*/
private final WeakReference<View> mView;
/**
* This list holds the properties that have been asked to animate. We allow the caller to
* request several animations prior to actually starting the underlying animator. This
* enables us to run one single animator to handle several properties in parallel. Each
* property is tossed onto the pending list until the animation actually starts (which is
* done by posting it onto mView), at which time the pending list is cleared and the properties
* on that list are added to the list of properties associated with that animator.
*/
ArrayList<NameValuesHolder> mPendingAnimations = new ArrayList<NameValuesHolder>();
/**
* The duration of the underlying Animator object. By default, we don't set the duration
* on the Animator and just use its default duration. If the duration is ever set on this
* Animator, then we use the duration that it was set to.
*/
private long mDuration;
/**
* A flag indicating whether the duration has been set on this object. If not, we don't set
* the duration on the underlying Animator, but instead just use its default duration.
*/
private boolean mDurationSet = false;
/**
* The startDelay of the underlying Animator object. By default, we don't set the startDelay
* on the Animator and just use its default startDelay. If the startDelay is ever set on this
* Animator, then we use the startDelay that it was set to.
*/
private long mStartDelay = 0;
/**
* A flag indicating whether the startDelay has been set on this object. If not, we don't set
* the startDelay on the underlying Animator, but instead just use its default startDelay.
*/
private boolean mStartDelaySet = false;
/**
* The interpolator of the underlying Animator object. By default, we don't set the interpolator
* on the Animator and just use its default interpolator. If the interpolator is ever set on
* this Animator, then we use the interpolator that it was set to.
*/
private /*Time*/ Interpolator mInterpolator;
/**
* A flag indicating whether the interpolator has been set on this object. If not, we don't set
* the interpolator on the underlying Animator, but instead just use its default interpolator.
*/
private boolean mInterpolatorSet = false;
/**
* Listener for the lifecycle events of the underlying
*/
private Animator.AnimatorListener mListener = null;
/**
* This listener is the mechanism by which the underlying Animator causes changes to the
* properties currently being animated, as well as the cleanup after an animation is
* complete.
*/
private AnimatorEventListener mAnimatorEventListener = new AnimatorEventListener();
/**
* This list tracks the list of properties being animated by any particular animator.
* In most situations, there would only ever be one animator running at a time. But it is
* possible to request some properties to animate together, then while those properties
* are animating, to request some other properties to animate together. The way that
* works is by having this map associate the group of properties being animated with the
* animator handling the animation. On every update event for an Animator, we ask the
* map for the associated properties and set them accordingly.
*/
private HashMap<Animator, PropertyBundle> mAnimatorMap =
new HashMap<Animator, PropertyBundle>();
/**
* The mechanism by which the user can request several properties that are then animated
* together works by posting this Runnable to start the underlying Animator. Every time
* a property animation is requested, we cancel any previous postings of the Runnable
* and re-post it. This means that we will only ever run the Runnable (and thus start the
* underlying animator) after the caller is done setting the properties that should be
* animated together.
*/
private Runnable mAnimationStarter = new Runnable() {
@Override
public void run() {
startAnimation();
}
};
/**
* Constructor, called by View. This is private by design, as the user should only
* get a ViewPropertyAnimator by calling View.animate().
*
* @param view The View associated with this ViewPropertyAnimator
*/
ViewPropertyAnimatorHC(View view) {
mView = new WeakReference<View>(view);
}
/**
* Sets the duration for the underlying animator that animates the requested properties.
* By default, the animator uses the default value for ValueAnimator. Calling this method
* will cause the declared value to be used instead.
*
* @param duration The length of ensuing property animations, in milliseconds. The value
* cannot be negative.
* @return This object, allowing calls to methods in this class to be chained.
*/
public ViewPropertyAnimator setDuration(long duration) {
if (duration < 0) {
throw new IllegalArgumentException("Animators cannot have negative duration: " +
duration);
}
mDurationSet = true;
mDuration = duration;
return this;
}
/**
* Returns the current duration of property animations. If the duration was set on this
* object, that value is returned. Otherwise, the default value of the underlying Animator
* is returned.
*
* @return The duration of animations, in milliseconds.
* @see #setDuration(long)
*/
public long getDuration() {
if (mDurationSet) {
return mDuration;
} else {
// Just return the default from ValueAnimator, since that's what we'd get if
// the value has not been set otherwise
return new ValueAnimator().getDuration();
}
}
@Override
public long getStartDelay() {
if (mStartDelaySet) {
return mStartDelay;
} else {
// Just return the default from ValueAnimator (0), since that's what we'd get if
// the value has not been set otherwise
return 0;
}
}
@Override
public ViewPropertyAnimator setStartDelay(long startDelay) {
if (startDelay < 0) {
throw new IllegalArgumentException("Animators cannot have negative duration: " +
startDelay);
}
mStartDelaySet = true;
mStartDelay = startDelay;
return this;
}
@Override
public ViewPropertyAnimator setInterpolator(/*Time*/Interpolator interpolator) {
mInterpolatorSet = true;
mInterpolator = interpolator;
return this;
}
@Override
public ViewPropertyAnimator setListener(Animator.AnimatorListener listener) {
mListener = listener;
return this;
}
@Override
public void start() {
startAnimation();
}
@Override
public void cancel() {
if (mAnimatorMap.size() > 0) {
HashMap<Animator, PropertyBundle> mAnimatorMapCopy =
(HashMap<Animator, PropertyBundle>) mAnimatorMap.clone();
Set<Animator> animatorSet = mAnimatorMapCopy.keySet();
for (Animator runningAnim : animatorSet) {
runningAnim.cancel();
}
}
mPendingAnimations.clear();
View v = mView.get();
if (v != null) {
v.removeCallbacks(mAnimationStarter);
}
}
@Override
public ViewPropertyAnimator x(float value) {
animateProperty(X, value);
return this;
}
@Override
public ViewPropertyAnimator xBy(float value) {
animatePropertyBy(X, value);
return this;
}
@Override
public ViewPropertyAnimator y(float value) {
animateProperty(Y, value);
return this;
}
@Override
public ViewPropertyAnimator yBy(float value) {
animatePropertyBy(Y, value);
return this;
}
@Override
public ViewPropertyAnimator rotation(float value) {
animateProperty(ROTATION, value);
return this;
}
@Override
public ViewPropertyAnimator rotationBy(float value) {
animatePropertyBy(ROTATION, value);
return this;
}
@Override
public ViewPropertyAnimator rotationX(float value) {
animateProperty(ROTATION_X, value);
return this;
}
@Override
public ViewPropertyAnimator rotationXBy(float value) {
animatePropertyBy(ROTATION_X, value);
return this;
}
@Override
public ViewPropertyAnimator rotationY(float value) {
animateProperty(ROTATION_Y, value);
return this;
}
@Override
public ViewPropertyAnimator rotationYBy(float value) {
animatePropertyBy(ROTATION_Y, value);
return this;
}
@Override
public ViewPropertyAnimator translationX(float value) {
animateProperty(TRANSLATION_X, value);
return this;
}
@Override
public ViewPropertyAnimator translationXBy(float value) {
animatePropertyBy(TRANSLATION_X, value);
return this;
}
@Override
public ViewPropertyAnimator translationY(float value) {
animateProperty(TRANSLATION_Y, value);
return this;
}
@Override
public ViewPropertyAnimator translationYBy(float value) {
animatePropertyBy(TRANSLATION_Y, value);
return this;
}
@Override
public ViewPropertyAnimator scaleX(float value) {
animateProperty(SCALE_X, value);
return this;
}
@Override
public ViewPropertyAnimator scaleXBy(float value) {
animatePropertyBy(SCALE_X, value);
return this;
}
@Override
public ViewPropertyAnimator scaleY(float value) {
animateProperty(SCALE_Y, value);
return this;
}
@Override
public ViewPropertyAnimator scaleYBy(float value) {
animatePropertyBy(SCALE_Y, value);
return this;
}
@Override
public ViewPropertyAnimator alpha(float value) {
animateProperty(ALPHA, value);
return this;
}
@Override
public ViewPropertyAnimator alphaBy(float value) {
animatePropertyBy(ALPHA, value);
return this;
}
/**
* Starts the underlying Animator for a set of properties. We use a single animator that
* simply runs from 0 to 1, and then use that fractional value to set each property
* value accordingly.
*/
private void startAnimation() {
ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
ArrayList<NameValuesHolder> nameValueList =
(ArrayList<NameValuesHolder>) mPendingAnimations.clone();
mPendingAnimations.clear();
int propertyMask = 0;
int propertyCount = nameValueList.size();
for (int i = 0; i < propertyCount; ++i) {
NameValuesHolder nameValuesHolder = nameValueList.get(i);
propertyMask |= nameValuesHolder.mNameConstant;
}
mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
animator.addUpdateListener(mAnimatorEventListener);
animator.addListener(mAnimatorEventListener);
if (mStartDelaySet) {
animator.setStartDelay(mStartDelay);
}
if (mDurationSet) {
animator.setDuration(mDuration);
}
if (mInterpolatorSet) {
animator.setInterpolator(mInterpolator);
}
animator.start();
}
/**
* Utility function, called by the various x(), y(), etc. methods. This stores the
* constant name for the property along with the from/delta values that will be used to
* calculate and set the property during the animation. This structure is added to the
* pending animations, awaiting the eventual start() of the underlying animator. A
* Runnable is posted to start the animation, and any pending such Runnable is canceled
* (which enables us to end up starting just one animator for all of the properties
* specified at one time).
*
* @param constantName The specifier for the property being animated
* @param toValue The value to which the property will animate
*/
private void animateProperty(int constantName, float toValue) {
float fromValue = getValue(constantName);
float deltaValue = toValue - fromValue;
animatePropertyBy(constantName, fromValue, deltaValue);
}
/**
* Utility function, called by the various xBy(), yBy(), etc. methods. This method is
* just like animateProperty(), except the value is an offset from the property's
* current value, instead of an absolute "to" value.
*
* @param constantName The specifier for the property being animated
* @param byValue The amount by which the property will change
*/
private void animatePropertyBy(int constantName, float byValue) {
float fromValue = getValue(constantName);
animatePropertyBy(constantName, fromValue, byValue);
}
/**
* Utility function, called by animateProperty() and animatePropertyBy(), which handles the
* details of adding a pending animation and posting the request to start the animation.
*
* @param constantName The specifier for the property being animated
* @param startValue The starting value of the property
* @param byValue The amount by which the property will change
*/
private void animatePropertyBy(int constantName, float startValue, float byValue) {
// First, cancel any existing animations on this property
if (mAnimatorMap.size() > 0) {
Animator animatorToCancel = null;
Set<Animator> animatorSet = mAnimatorMap.keySet();
for (Animator runningAnim : animatorSet) {
PropertyBundle bundle = mAnimatorMap.get(runningAnim);
if (bundle.cancel(constantName)) {
// property was canceled - cancel the animation if it's now empty
// Note that it's safe to break out here because every new animation
// on a property will cancel a previous animation on that property, so
// there can only ever be one such animation running.
if (bundle.mPropertyMask == NONE) {
// the animation is no longer changing anything - cancel it
animatorToCancel = runningAnim;
break;
}
}
}
if (animatorToCancel != null) {
animatorToCancel.cancel();
}
}
NameValuesHolder nameValuePair = new NameValuesHolder(constantName, startValue, byValue);
mPendingAnimations.add(nameValuePair);
View v = mView.get();
if (v != null) {
v.removeCallbacks(mAnimationStarter);
v.post(mAnimationStarter);
}
}
/**
* This method handles setting the property values directly in the View object's fields.
* propertyConstant tells it which property should be set, value is the value to set
* the property to.
*
* @param propertyConstant The property to be set
* @param value The value to set the property to
*/
private void setValue(int propertyConstant, float value) {
//final View.TransformationInfo info = mView.mTransformationInfo;
View v = mView.get();
if (v != null) {
switch (propertyConstant) {
case TRANSLATION_X:
//info.mTranslationX = value;
v.setTranslationX(value);
break;
case TRANSLATION_Y:
//info.mTranslationY = value;
v.setTranslationY(value);
break;
case ROTATION:
//info.mRotation = value;
v.setRotation(value);
break;
case ROTATION_X:
//info.mRotationX = value;
v.setRotationX(value);
break;
case ROTATION_Y:
//info.mRotationY = value;
v.setRotationY(value);
break;
case SCALE_X:
//info.mScaleX = value;
v.setScaleX(value);
break;
case SCALE_Y:
//info.mScaleY = value;
v.setScaleY(value);
break;
case X:
//info.mTranslationX = value - v.mLeft;
v.setX(value);
break;
case Y:
//info.mTranslationY = value - v.mTop;
v.setY(value);
break;
case ALPHA:
//info.mAlpha = value;
v.setAlpha(value);
break;
}
}
}
/**
* This method gets the value of the named property from the View object.
*
* @param propertyConstant The property whose value should be returned
* @return float The value of the named property
*/
private float getValue(int propertyConstant) {
//final View.TransformationInfo info = mView.mTransformationInfo;
View v = mView.get();
if (v != null) {
switch (propertyConstant) {
case TRANSLATION_X:
//return info.mTranslationX;
return v.getTranslationX();
case TRANSLATION_Y:
//return info.mTranslationY;
return v.getTranslationY();
case ROTATION:
//return info.mRotation;
return v.getRotation();
case ROTATION_X:
//return info.mRotationX;
return v.getRotationX();
case ROTATION_Y:
//return info.mRotationY;
return v.getRotationY();
case SCALE_X:
//return info.mScaleX;
return v.getScaleX();
case SCALE_Y:
//return info.mScaleY;
return v.getScaleY();
case X:
//return v.mLeft + info.mTranslationX;
return v.getX();
case Y:
//return v.mTop + info.mTranslationY;
return v.getY();
case ALPHA:
//return info.mAlpha;
return v.getAlpha();
}
}
return 0;
}
/**
* This class holds information about the overall animation being run on the set of
* properties. The mask describes which properties are being animated and the
* values holder is the list of all property/value objects.
*/
private static class PropertyBundle {
int mPropertyMask;
ArrayList<NameValuesHolder> mNameValuesHolder;
PropertyBundle(int propertyMask, ArrayList<NameValuesHolder> nameValuesHolder) {
mPropertyMask = propertyMask;
mNameValuesHolder = nameValuesHolder;
}
/**
* Removes the given property from being animated as a part of this
* PropertyBundle. If the property was a part of this bundle, it returns
* true to indicate that it was, in fact, canceled. This is an indication
* to the caller that a cancellation actually occurred.
*
* @param propertyConstant The property whose cancellation is requested.
* @return true if the given property is a part of this bundle and if it
* has therefore been canceled.
*/
boolean cancel(int propertyConstant) {
if ((mPropertyMask & propertyConstant) != 0 && mNameValuesHolder != null) {
int count = mNameValuesHolder.size();
for (int i = 0; i < count; ++i) {
NameValuesHolder nameValuesHolder = mNameValuesHolder.get(i);
if (nameValuesHolder.mNameConstant == propertyConstant) {
mNameValuesHolder.remove(i);
mPropertyMask &= ~propertyConstant;
return true;
}
}
}
return false;
}
}
/**
* This is the information we need to set each property during the animation.
* mNameConstant is used to set the appropriate field in View, and the from/delta
* values are used to calculate the animated value for a given animation fraction
* during the animation.
*/
private static class NameValuesHolder {
int mNameConstant;
float mFromValue;
float mDeltaValue;
NameValuesHolder(int nameConstant, float fromValue, float deltaValue) {
mNameConstant = nameConstant;
mFromValue = fromValue;
mDeltaValue = deltaValue;
}
}
/**
* Utility class that handles the various Animator events. The only ones we care
* about are the end event (which we use to clean up the animator map when an animator
* finishes) and the update event (which we use to calculate the current value of each
* property and then set it on the view object).
*/
private class AnimatorEventListener
implements Animator.AnimatorListener, ValueAnimator.AnimatorUpdateListener {
@Override
public void onAnimationStart(Animator animation) {
if (mListener != null) {
mListener.onAnimationStart(animation);
}
}
@Override
public void onAnimationCancel(Animator animation) {
if (mListener != null) {
mListener.onAnimationCancel(animation);
}
}
@Override
public void onAnimationRepeat(Animator animation) {
if (mListener != null) {
mListener.onAnimationRepeat(animation);
}
}
@Override
public void onAnimationEnd(Animator animation) {
if (mListener != null) {
mListener.onAnimationEnd(animation);
}
mAnimatorMap.remove(animation);
// If the map is empty, it means all animation are done or canceled, so the listener
// isn't needed anymore. Not nulling it would cause it to leak any objects used in
// its implementation
if (mAnimatorMap.isEmpty()) {
mListener = null;
}
}
/**
* Calculate the current value for each property and set it on the view. Invalidate
* the view object appropriately, depending on which properties are being animated.
*
* @param animation The animator associated with the properties that need to be
* set. This animator holds the animation fraction which we will use to calculate
* the current value of each property.
*/
@Override
public void onAnimationUpdate(ValueAnimator animation) {
// alpha requires slightly different treatment than the other (transform) properties.
// The logic in setAlpha() is not simply setting mAlpha, plus the invalidation
// logic is dependent on how the view handles an internal call to onSetAlpha().
// We track what kinds of properties are set, and how alpha is handled when it is
// set, and perform the invalidation steps appropriately.
//boolean alphaHandled = false;
//mView.invalidateParentCaches();
float fraction = animation.getAnimatedFraction();
PropertyBundle propertyBundle = mAnimatorMap.get(animation);
int propertyMask = propertyBundle.mPropertyMask;
if ((propertyMask & TRANSFORM_MASK) != 0) {
View v = mView.get();
if (v != null) {
v.invalidate(/*false*/);
}
}
ArrayList<NameValuesHolder> valueList = propertyBundle.mNameValuesHolder;
if (valueList != null) {
int count = valueList.size();
for (int i = 0; i < count; ++i) {
NameValuesHolder values = valueList.get(i);
float value = values.mFromValue + fraction * values.mDeltaValue;
//if (values.mNameConstant == ALPHA) {
// alphaHandled = mView.setAlphaNoInvalidation(value);
//} else {
setValue(values.mNameConstant, value);
//}
}
}
/*if ((propertyMask & TRANSFORM_MASK) != 0) {
mView.mTransformationInfo.mMatrixDirty = true;
mView.mPrivateFlags |= View.DRAWN; // force another invalidation
}*/
// invalidate(false) in all cases except if alphaHandled gets set to true
// via the call to setAlphaNoInvalidation(), above
View v = mView.get();
if (v != null) {
v.invalidate(/*alphaHandled*/);
}
}
}
}

View file

@ -0,0 +1,256 @@
package com.services;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import androidx.core.app.NotificationCompat;
import android.text.format.DateFormat;
import com.adins.mss.base.AppContext;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.NewMainActivity;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.notification.Notification;
import com.adins.mss.logger.Logger;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import com.services.models.JsonRequestCheckOrder;
import com.services.models.JsonResponseServer;
import org.acra.ACRA;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/**
* Created by angga.permadi on 4/29/2016.
*/
public class SurveyAssignmentThread extends Thread {
public static final int ASSIGNMENT_NOTIFICATION_ID = 123;
public static final String ASSIGNMENT_NOTIFICATION_KEY = "ASSIGNMENT_NOTIFICATION_KEY";
public String uuidUser;
public List<JsonResponseServer.ResponseServer> dummyResults;
private Context context;
private int interval; // in miliseconds
private volatile boolean keepRunning = true;
public SurveyAssignmentThread(Context context) {
// TODO Auto-generated constructor stub
this.context = context;
this.dummyResults = new ArrayList<>();
interval = Global.MINUTE * 10;
try {
uuidUser = GlobalData.getSharedGlobalData().getUser()
.getUuid_user();
if (uuidUser != null) {
if (GeneralParameterDataAccess.getOne(context, uuidUser, "PRM04_F5IN")
.getGs_value() != null
&& !GeneralParameterDataAccess
.getOne(context, uuidUser, "PRM04_F5IN").getGs_value()
.isEmpty()) {
interval = Integer.parseInt(GeneralParameterDataAccess.getOne(
context, uuidUser, "PRM04_F5IN").getGs_value()) * 1000; // from
// milisecond
// to
// second
}
} else {
keepRunning = false;
}
} catch (Exception e) {
FireCrash.log(e);
if (Global.user != null) {
uuidUser = Global.user.getUuid_user();
if (uuidUser != null) {
if (GeneralParameterDataAccess.getOne(context, uuidUser, "PRM04_F5IN")
.getGs_value() != null
&& !GeneralParameterDataAccess
.getOne(context, uuidUser, "PRM04_F5IN").getGs_value()
.isEmpty()) {
interval = Integer.parseInt(GeneralParameterDataAccess.getOne(
context, uuidUser, "PRM04_F5IN").getGs_value()) * 1000; // from
// milisecond
// to
// second
}
}
} else {
keepRunning = false;
}
}
}
@Override
public void run() {
super.run();
while (keepRunning) {
try {
String resp;
JsonResponseServer result = null;
if (Tool.isInternetconnected(context)) {
JsonRequestCheckOrder requestCheckOrder = new JsonRequestCheckOrder();
requestCheckOrder.setAudit(GlobalData.getSharedGlobalData().getAuditData());
requestCheckOrder.setFlag(Global.FLAG_FOR_ORDERASSIGNMENT);
String json = GsonHelper.toJson(requestCheckOrder);
String url = GlobalData.getSharedGlobalData().getURL_GET_LIST_ASSIGNMENT();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult serverResult = null;
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, serverResult);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
if (serverResult != null) {
resp = serverResult.getResult();
try {
result = GsonHelper.fromJson(resp, JsonResponseServer.class);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
}
}
String resultString = result == null ? "null" : result.toString();
Logger.d(this, "response from notif assignment task : " + resultString);
if (result != null && result.getStatus().getCode() == 0) {
List<JsonResponseServer.ResponseServer> listResponse = result.getListResponseServer();
if (listResponse != null && listResponse.size() > 0) {
showNotification(listResponse.size(), isEquals(dummyResults, listResponse));
dummyResults = listResponse;
} else {
cancelNotification();
}
GlobalData.getSharedGlobalData().setCounterAssignment(listResponse == null ? 0 : listResponse.size());
updateAssignmentCounter(listResponse == null ? 0 : listResponse.size());
}
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
doSleep(interval);
}
}
private void showNotification(int notifCount, boolean isSilent) {
String notifTitle = context.getString(R.string.assignment_task);
String message = context.getString(R.string.notification_assignment, notifCount);
Intent resultIntent = new Intent(context, AppContext.getInstance().getHomeClass());
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
resultIntent.setAction(ASSIGNMENT_NOTIFICATION_KEY);
PendingIntent pendingIntent = PendingIntent
.getActivity(context, ASSIGNMENT_NOTIFICATION_ID, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.getSharedNotification().setDefaultIcon(
NotificationThread.getNotificationIcon());
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(NotificationThread.getNotificationIcon());
builder.setContentTitle(notifTitle).setNumber(notifCount);
builder.setContentText(message).setNumber(notifCount);
builder.setPriority(NORM_PRIORITY);
NotificationCompat.BigTextStyle inboxStyle =
new NotificationCompat.BigTextStyle();
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle(notifTitle);
inboxStyle.bigText(message);
inboxStyle.setSummaryText(context.getString(R.string.click_to_open_assignment_task));
builder.setStyle(inboxStyle);
builder.setAutoCancel(true);
builder.setContentIntent(pendingIntent);
if (isSilent) {
builder.setSound(null);
builder.setVibrate(new long[]{0L, 0L});
} else {
builder.setDefaults(android.app.Notification.DEFAULT_ALL);
}
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(ASSIGNMENT_NOTIFICATION_ID, builder.build());
}
private void cancelNotification() {
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(ASSIGNMENT_NOTIFICATION_ID);
}
private boolean isEquals(List<JsonResponseServer.ResponseServer> objects1,
List<JsonResponseServer.ResponseServer> objects2) {
if (objects1.size() == 0) return false;
if (objects1.size() != objects2.size()) return false;
for (int i = 0; i < objects1.size(); i++) {
if (!objects1.get(i).getFlag().equals(objects2.get(i).getFlag())) return false;
}
return true;
}
public void requestStop() {
keepRunning = false;
}
private void doSleep(int time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
private void updateAssignmentCounter(final int count) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
// UI code goes here
try {
if (NewMainActivity.mnSurveyAssign != null)
NewMainActivity.mnSurveyAssign.setCounter(String.valueOf(count));
NewMainActivity.setCounter();
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", e.getMessage());
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Drawer Counter"));
}
}
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -0,0 +1,195 @@
/*
* Copyright 2012 Kevin Gaudin
*
* 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.
*/
package org.acra;
import android.content.Context;
import org.acra.collector.CrashReportData;
import org.acra.sender.ReportSender;
import org.acra.sender.ReportSenderException;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import static org.acra.ACRA.LOG_TAG;
/**
* Checks and send reports on a separate Thread.
*
* @author Kevin Gaudin
*/
final class SendWorker extends Thread {
private final Context context;
private final boolean sendOnlySilentReports;
private final boolean approvePendingReports;
private final CrashReportFileNameParser fileNameParser = new CrashReportFileNameParser();
private final List<ReportSender> reportSenders;
/**
* Creates a new {@link SendWorker} to try sending pending reports.
*
* @param context ApplicationContext in which the reports are being sent.
* @param reportSenders List of ReportSender to use to send the crash reports.
* @param sendOnlySilentReports If set to true, will send only reports which have been
* explicitly declared as silent by the application developer.
* @param approvePendingReports if this endWorker should approve pending reports before
* sending any reports.
*/
public SendWorker(Context context, List<ReportSender> reportSenders, boolean sendOnlySilentReports,
boolean approvePendingReports) {
this.context = context;
this.reportSenders = reportSenders;
this.sendOnlySilentReports = sendOnlySilentReports;
this.approvePendingReports = approvePendingReports;
}
/*
* (non-Javadoc)
*
* @see java.lang.Thread#run()
*/
@Override
public void run() {
if (approvePendingReports) {
approvePendingReports();
}
checkAndSendReports(context, sendOnlySilentReports);
}
/**
* Flag all pending reports as "approved" by the user. These reports can be
* sent.
*/
private void approvePendingReports() {
ACRA.log.d(LOG_TAG, "Mark all pending reports as approved.");
final CrashReportFinder reportFinder = new CrashReportFinder(context);
final String[] reportFileNames = reportFinder.getCrashReportFiles();
for (String reportFileName : reportFileNames) {
if (!fileNameParser.isApproved(reportFileName)) {
final File reportFile = new File(context.getFilesDir(), reportFileName);
// TODO look into how this could cause a file to go from
// -approved.stacktrace to -approved-approved.stacktrace
final String newName = reportFileName.replace(ACRAConstants.REPORTFILE_EXTENSION,
ACRAConstants.APPROVED_SUFFIX + ACRAConstants.REPORTFILE_EXTENSION);
// TODO Look into whether rename is atomic. Is there a better
// option?
final File newFile = new File(context.getFilesDir(), newName);
if (!reportFile.renameTo(newFile)) {
ACRA.log.e(LOG_TAG, "Could not rename approved report from " + reportFile + " to " + newFile);
}
}
}
}
/**
* Send pending reports.
*
* @param context The application context.
* @param sendOnlySilentReports Send only reports explicitly declared as SILENT by the
* developer (sent via
* {@link ErrorReporter#handleSilentException(Throwable)}.
*/
private void checkAndSendReports(Context context, boolean sendOnlySilentReports) {
ACRA.log.d(LOG_TAG, "#checkAndSendReports - start");
final CrashReportFinder reportFinder = new CrashReportFinder(context);
final String[] reportFiles = reportFinder.getCrashReportFiles();
Arrays.sort(reportFiles);
int reportsSentCount = 0;
for (String curFileName : reportFiles) {
if (sendOnlySilentReports && !fileNameParser.isSilent(curFileName)) {
continue;
}
if (reportsSentCount >= ACRAConstants.MAX_SEND_REPORTS) {
break; // send only a few reports to avoid overloading the
// network
}
ACRA.log.i(LOG_TAG, "Sending file " + curFileName);
try {
final CrashReportPersister persister = new CrashReportPersister(context);
final CrashReportData previousCrashReport = persister.load(curFileName);
sendCrashReport(previousCrashReport);
deleteFile(context, curFileName);
} catch (RuntimeException e) {
ACRA.log.e(LOG_TAG, "Failed to send crash reports for " + curFileName, e);
deleteFile(context, curFileName);
break; // Something really unexpected happened. Don't try to
// send any more reports now.
} catch (IOException e) {
ACRA.log.e(LOG_TAG, "Failed to load crash report for " + curFileName, e);
deleteFile(context, curFileName);
break; // Something unexpected happened when reading the crash
// report. Don't try to send any more reports now.
} catch (ReportSenderException e) {
ACRA.log.e(LOG_TAG, "Failed to send crash report for " + curFileName, e);
// An issue occurred while sending this report but we can still try to
// send other reports. Report sending is limited by ACRAConstants.MAX_SEND_REPORTS
// so there's not much to fear about overloading a failing server.
}
reportsSentCount++;
}
ACRA.log.d(LOG_TAG, "#checkAndSendReports - finish");
}
/**
* Sends the report with all configured ReportSenders. If at least one
* sender completed its job, the report is considered as sent and will not
* be sent again for failing senders.
*
* @param errorContent Crash data.
* @throws ReportSenderException if unable to send the crash report.
*/
private void sendCrashReport(CrashReportData errorContent) throws ReportSenderException {
if (!ACRA.isDebuggable() || ACRA.getConfig().sendReportsInDevMode()) {
boolean sentAtLeastOnce = false;
for (ReportSender sender : reportSenders) {
try {
sender.send(context, errorContent);
// If at least one sender worked, don't re-send the report
// later.
sentAtLeastOnce = true;
} catch (ReportSenderException e) {
if (!sentAtLeastOnce) {
throw e; // Don't log here because we aren't dealing
// with the Exception here.
} else {
ACRA.log.w(LOG_TAG,
"ReportSender of class "
+ sender.getClass().getName()
+ " failed but other senders completed their task. ACRA will not send this report again.");
}
}
}
}
}
private void deleteFile(Context context, String fileName) {
final boolean deleted = context.deleteFile(fileName);
if (!deleted) {
ACRA.log.w(LOG_TAG, "Could not delete error report : " + fileName);
}
}
}

View file

@ -0,0 +1,73 @@
package com.adins.mss.coll;
import android.content.Context;
import android.os.Bundle;
import androidx.fragment.app.FragmentTransaction;
import com.adins.mss.coll.fragments.DepositReportRecapitulateFragment;
import com.adins.mss.coll.fragments.DepositReportSummaryFragment;
import com.adins.mss.coll.fragments.DepositReportTransferFragment;
import com.adins.mss.coll.interfaces.NavigatorInterface;
/**
* Created by kusnendi.muhamad on 28/07/2017.
*/
public class Navigator implements NavigatorInterface {
public static final String DEPOSIT_REPORT_RECAPITULATE = "DEPOSIT_REPORT_RECAPITULATE";
public static final String DEPOSIT_REPORT_SUMMARIZE = "DEPOSIT_REPORT_SUMMARIZE";
public static final String DEPOSIT_REPORT_TRANSFER = "DEPOSIT_REPORT_TRANSFER";
private Context context;
private Bundle bundle;
public Navigator(Context context) {
this.context = context;
}
public Navigator(Context context, Bundle bundle) {
this.context = context;
this.bundle = bundle;
}
public void route(String navigate) {
switch (navigate) {
case DEPOSIT_REPORT_SUMMARIZE: summarize();
break;
case DEPOSIT_REPORT_RECAPITULATE: recapitulate();
break;
case DEPOSIT_REPORT_TRANSFER: transfer();
break;
default:
break;
}
}
private void summarize() {
DepositReportSummaryFragment fragment = new DepositReportSummaryFragment();
FragmentTransaction transaction = NewMCMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate,R.anim.activity_close_scale,R.anim.activity_open_scale,R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
private void recapitulate() {
DepositReportRecapitulateFragment fragment = new DepositReportRecapitulateFragment();
FragmentTransaction transaction = NewMCMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate,R.anim.activity_close_scale,R.anim.activity_open_scale,R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
private void transfer() {
DepositReportTransferFragment fragment = new DepositReportTransferFragment();
fragment.setArguments(bundle);
FragmentTransaction transaction = NewMCMainActivity.fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.activity_open_translate,R.anim.activity_close_scale,R.anim.activity_open_scale,R.anim.activity_close_translate);
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
}

View file

@ -0,0 +1,78 @@
package com.adins.mss.svy.models;
import androidx.annotation.Keep;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class SuggestOnVerification extends MssResponseType {
@SerializedName("listUser")
public List<ListUser> listUser;
/**
* Gets the listUser
*/
public List<ListUser> getListUser() {
return this.listUser;
}
/**
* Sets the listUser
*/
public void setListUser(List<ListUser> value) {
this.listUser = value;
}
public class ListUser {
@Keep
public String uuid_ms_user;
@Keep
public String fullname;
@Keep
public String is_suggested;
/**
* Gets the uuid_ms_user
*/
public String getUuid_ms_user() {
return this.uuid_ms_user;
}
/**
* Sets the uuid_ms_user
*/
public void setUuid_ms_user(String value) {
this.uuid_ms_user = value;
}
/**
* Gets the fullname
*/
public String getFullname() {
return this.fullname;
}
/**
* Sets the fullname
*/
public void setFullname(String value) {
this.fullname = value;
}
/**
* Gets the is_suggested
*/
public String getIs_suggested() {
return this.is_suggested;
}
/**
* Sets the is_suggested
*/
public void setIs_suggested(String value) {
this.is_suggested = value;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB