mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-07-01 05:14:17 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,139 @@
|
|||
package com.adins.mss.coll;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.LoginActivity;
|
||||
import com.adins.mss.base.NewMainActivity;
|
||||
import com.adins.mss.base.dynamictheme.DynamicTheme;
|
||||
import com.adins.mss.base.dynamictheme.ThemeLoader;
|
||||
import com.adins.mss.base.login.DefaultLoginModel;
|
||||
import com.adins.mss.coll.login.MCDefaultLoginModel;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.GeneralParameter;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class MCLoginActivity extends LoginActivity implements ThemeLoader.ColorSetLoaderCallback {
|
||||
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
//instantiate theme loader
|
||||
themeLoader = new ThemeLoader(this);
|
||||
|
||||
defaultConfig = new HashMap<>();
|
||||
defaultConfig.put("cipher_unsupported_device", Global.SQLITE_CIPHER_UNSUPPORTED);
|
||||
this.fetchConfig();
|
||||
|
||||
PackageInfo pInfo = null;
|
||||
String sqliteCipherException;
|
||||
String deviceModel = Build.MODEL;
|
||||
|
||||
screenName = FirebaseAnalytics.getInstance(this);
|
||||
|
||||
try {
|
||||
sqliteCipherException = GlobalData.getSharedGlobalData().getRemoteConfig().getString("cipher_unsupported_device");
|
||||
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
Global.APP_VERSION = pInfo.versionName;
|
||||
Global.BUILD_VERSION = pInfo.versionCode;
|
||||
Global.IS_DEV = BuildConfig.IS_DEV;
|
||||
Global.FLAVORS = BuildConfig.IS_FLAVORS;
|
||||
Global.IS_BYPASSROOT = BuildConfig.IS_BYPASSROOT;
|
||||
Global.IS_DBENCRYPT = (!sqliteCipherException.contains(deviceModel)) && BuildConfig.IS_DBENCRYPT;
|
||||
} catch (NameNotFoundException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if(Global.AUTOLOGIN_ENABLE){
|
||||
NewMainActivity.setMainMenuClass(NewMCMainActivity.class);
|
||||
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(getApplicationContext(),
|
||||
"GlobalData", Context.MODE_PRIVATE);
|
||||
hasLogged = sharedPref.getBoolean("HAS_LOGGED", false);
|
||||
if (hasLogged /*&& GlobalData.getSharedGlobalData().getUser() != null*/) {
|
||||
super.onCreate(savedInstanceState);
|
||||
NewMainActivity.InitializeGlobalDataIfError(getApplicationContext());
|
||||
|
||||
String uuidUser = GlobalData.getSharedGlobalData().getUser() == null ? sharedPref.getString("UUID_USER", "") : GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
//check theme config.
|
||||
GeneralParameter generalParameter = GeneralParameterDataAccess.getOne(this, uuidUser,
|
||||
Global.GS_THEME_CONFIG_COLLECTION);
|
||||
|
||||
if(generalParameter != null){
|
||||
String urlConfig = generalParameter.getGs_value();
|
||||
themeLoader.loadThemeFromUrl(urlConfig,this);
|
||||
}
|
||||
else {//go to main activity
|
||||
Intent intent = new Intent(getApplicationContext(), NewMCMainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else {//load directly login page and load saved theme
|
||||
super.onCreate(savedInstanceState);
|
||||
logo.setImageResource(com.adins.mss.base.R.drawable.icon_coll_act);
|
||||
try {
|
||||
loadSavedTheme();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {//load directly login page and load saved theme
|
||||
super.onCreate(savedInstanceState);
|
||||
logo.setImageResource(com.adins.mss.base.R.drawable.icon_coll_act);
|
||||
loadSavedTheme();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSavedTheme(){
|
||||
if(themeLoader != null){
|
||||
themeLoader.loadSavedColorSet(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DefaultLoginModel getNewDefaultLoginModel(Context context) {
|
||||
// TODO Auto-generated method stub
|
||||
return new MCDefaultLoginModel(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHasLoaded(DynamicTheme dynamicTheme) {//callback load from local db
|
||||
if(dynamicTheme != null && dynamicTheme.getThemeItemList().size() > 0){
|
||||
applyColorTheme(dynamicTheme);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHasLoaded(DynamicTheme dynamicTheme, boolean needUpdate) {//callback load from server
|
||||
Intent intent = new Intent(getApplicationContext(), NewMCMainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(this,getString(R.string.screen_name_coll_login),null);
|
||||
|
||||
defaultConfig = new HashMap<>();
|
||||
defaultConfig.put("cipher_unsupported_device", Global.SQLITE_CIPHER_UNSUPPORTED);
|
||||
this.fetchConfig();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.adins.mss.odr;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
package com.adins.mss.base.timeline;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.format.DateFormat;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.todolist.ToDoList;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Timeline;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.image.Utils;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by kusnendi.muhamad on 26/07/2017.
|
||||
*/
|
||||
|
||||
public class TimelineImpl implements TimelineInterface {
|
||||
|
||||
private static String tempUuidUser;
|
||||
private Activity activity;
|
||||
private Context context;
|
||||
private Bitmap bitmap;
|
||||
private List<Timeline> timelines;
|
||||
private String cashLimit;
|
||||
private String coh;
|
||||
private double limit;
|
||||
private double cashOnHand;
|
||||
private String sLimit;
|
||||
private String sCOH;
|
||||
private TimelineListener timelineListener;
|
||||
private int position = 0;
|
||||
private NewTimelineFragment timelineFragment;
|
||||
private static final String DATE_TIME_FORMAT = "yyyy.MM.dd G \'at\' HH:mm:ss z";
|
||||
private static final String ERROR_REFRESH_BACKGROUND = "errorRefreshBackgroundTask";
|
||||
|
||||
public TimelineImpl(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public TimelineImpl(Activity activity, TimelineListener timelineListener) {
|
||||
this.activity = activity;
|
||||
this.timelineListener = timelineListener;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
setTempUuidUser(GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
return UserDataAccess.getOne(context, getTempUuidUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCOHAktif() {
|
||||
String parameter = GeneralParameterDataAccess.getOne(activity, GlobalData.getSharedGlobalData().getUser().getUuid_user(),
|
||||
Global.GS_CASHONHAND).getGs_value();
|
||||
return parameter != null && parameter.equals(Global.TRUE_STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncTask<Void, Void, Bitmap> refreshImageBitmap(final int viewId, final int defaultDrawable, final byte[] byteImage) {
|
||||
return new AsyncTask<Void, Void, Bitmap>() {
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... args) {
|
||||
if (byteImage != null) {
|
||||
try {
|
||||
return Utils.byteToBitmap(byteImage);
|
||||
} catch (OutOfMemoryError ex) {
|
||||
ex.printStackTrace();
|
||||
ACRA.getErrorReporter().putCustomData("errorOutOfMemory", ex.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorOutOfMemory", DateFormat.format(DATE_TIME_FORMAT, Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception OutOfMemory"));
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
ACRA.getErrorReporter().putCustomData("errorConvertingByteToBitmap", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorConvertingByteToBitmap", DateFormat.format(DATE_TIME_FORMAT, Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat convert byte to bitmap"));
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap res) {
|
||||
super.onPostExecute(res);
|
||||
if (res != null) {
|
||||
setBitmap(res);
|
||||
timelineListener.onSuccessImageBitmap(res, viewId, defaultDrawable);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncTask<Void, Void, List<Timeline>> refreshBackgroundTask() {
|
||||
final int TASK_DURATION = 2 * 1000; // 2 seconds
|
||||
return new AsyncTask<Void, Void, List<Timeline>>() {
|
||||
@Override
|
||||
protected List<Timeline> doInBackground(Void... params) {
|
||||
// Sleep for a small amount of time to simulate a background-task
|
||||
try {
|
||||
Thread.sleep(TASK_DURATION);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
ACRA.getErrorReporter().putCustomData(ERROR_REFRESH_BACKGROUND, e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData(ERROR_REFRESH_BACKGROUND, DateFormat.format(DATE_TIME_FORMAT, Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Thread.sleep"));
|
||||
}
|
||||
try {
|
||||
int range = GlobalData.getSharedGlobalData().getKeepTimelineInDays();
|
||||
position = getPosition();
|
||||
timelineFragment = new NewTimelineFragment();
|
||||
return timelineFragment.getTimeline(position, range);
|
||||
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
ACRA.getErrorReporter().putCustomData(ERROR_REFRESH_BACKGROUND, e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData(ERROR_REFRESH_BACKGROUND, DateFormat.format(DATE_TIME_FORMAT, Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set range"));
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<Timeline> records) {
|
||||
super.onPostExecute(records);
|
||||
if (records != null) {
|
||||
setTimelines(records);
|
||||
timelineListener.onSuccessBackgroundTask(records);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setCashOnHand() {
|
||||
try {
|
||||
setCashLimit(GlobalData.getSharedGlobalData().getUser().getCash_limit());
|
||||
setLimit(cashLimit != null ? Double.parseDouble(cashLimit) : 0.0);
|
||||
setCoh(GlobalData.getSharedGlobalData().getUser().getCash_on_hand());
|
||||
setCashOnHand(coh != null ? Double.parseDouble(coh) : 0.0);
|
||||
setsLimit(Tool.separateThousand(limit));
|
||||
setsCOH(Tool.separateThousand(cashOnHand));
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<Timeline> getTimelines() {
|
||||
return timelines;
|
||||
}
|
||||
|
||||
public void setTimelines(List<Timeline> timelines) {
|
||||
this.timelines = timelines;
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.bitmap = bitmap;
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String getCashLimit() {
|
||||
return cashLimit;
|
||||
}
|
||||
|
||||
public void setCashLimit(String cashLimit) {
|
||||
this.cashLimit = cashLimit;
|
||||
}
|
||||
|
||||
public String getCoh() {
|
||||
return coh;
|
||||
}
|
||||
|
||||
public void setCoh(String coh) {
|
||||
this.coh = coh;
|
||||
}
|
||||
|
||||
public double getCashOnHand() {
|
||||
return cashOnHand;
|
||||
}
|
||||
|
||||
public void setCashOnHand(double cashOnHand) {
|
||||
this.cashOnHand = cashOnHand;
|
||||
}
|
||||
|
||||
public double getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(double limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getsLimit() {
|
||||
return sLimit;
|
||||
}
|
||||
|
||||
public void setsLimit(String sLimit) {
|
||||
this.sLimit = sLimit;
|
||||
}
|
||||
|
||||
public String getsCOH() {
|
||||
return sCOH;
|
||||
}
|
||||
|
||||
public void setsCOH(String sCOH) {
|
||||
this.sCOH = sCOH;
|
||||
}
|
||||
|
||||
public long getTaskListCounter() {
|
||||
return ToDoList.getAllCounter(activity);
|
||||
}
|
||||
|
||||
|
||||
public static String getTempUuidUser() {
|
||||
return tempUuidUser;
|
||||
}
|
||||
|
||||
public static void setTempUuidUser(String tempUuidUser) {
|
||||
TimelineImpl.tempUuidUser = tempUuidUser;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
<option name="myConfigurationMap">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$">
|
||||
<value>
|
||||
<SvnBranchConfiguration>
|
||||
<option name="branchUrls">
|
||||
<list>
|
||||
<option value="https://ppd-vsc-svr.ad-ins.com/svn/MSS/BaseProject/Android/branches" />
|
||||
<option value="https://ppd-vsc-svr.ad-ins.com/svn/MSS/BaseProject/Android/tags" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="trunkUrl" value="https://ppd-vsc-svr.ad-ins.com/svn/MSS/BaseProject/Android/trunk" />
|
||||
</SvnBranchConfiguration>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="mySupportsUserInfoFilter" value="true" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,772 @@
|
|||
package com.adins.mss.base.todolist.form;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.dynamicform.CustomerFragment;
|
||||
import com.adins.mss.base.dynamicform.SurveyHeaderBean;
|
||||
import com.adins.mss.base.dynamicform.TaskManager;
|
||||
import com.adins.mss.base.dynamicform.newlead.NewLeadFragment;
|
||||
import com.adins.mss.base.timeline.TimelineImpl;
|
||||
import com.adins.mss.base.timeline.TimelineInterface;
|
||||
import com.adins.mss.base.todolist.ToDoList;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.GeneralParameter;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
import com.adins.mss.foundation.dialog.DialogManager;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder_PL;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by muhammad.aap on 11/12/2018.
|
||||
*/
|
||||
|
||||
public class NewToDoListTabFragment extends Fragment implements OnTaskListClickListener, TasklistListener {
|
||||
public static final String uuidSchemeDummy = "schemeDummy";
|
||||
private static final String ARG_COLUMN_COUNT = "column-count";
|
||||
public static ToDoList toDoList;
|
||||
private List<TaskH> listTaskH;
|
||||
public static Handler mHandler;
|
||||
private static String param;
|
||||
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
public static NewToDoListViewAdapter viewAdapter;
|
||||
public NewToDoListTabFragment.FormAdapter formAdapter;
|
||||
public NewToDoListTabFragment.NewToDoListAdapter newToDoListAdapter;
|
||||
private List<Scheme> formListName;
|
||||
private static Scheme selectedScheme;
|
||||
private TextView textView;
|
||||
private RecyclerView recyclerView;
|
||||
private RelativeLayout layout;
|
||||
private TextView dataNotFound;
|
||||
private boolean isNewToDoListOpen = false;
|
||||
public static NewToDoListTabFragment.NewToDoListHandler handler;
|
||||
private TasklistInterface iTasklist;
|
||||
private TimelineInterface iTimeline;
|
||||
|
||||
private static Menu mainMenu;
|
||||
public static boolean isMenuClicked = false;
|
||||
|
||||
private BottomNavigationView bottomNav;
|
||||
|
||||
private int formPosition = 0;
|
||||
public static int taskPosition = 0;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static NewToDoListTabFragment newInstance(int columnCount) {
|
||||
NewToDoListTabFragment fragment = new NewToDoListTabFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_COLUMN_COUNT, Integer.parseInt(param));
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private void setToolbar() {
|
||||
getActivity().findViewById(R.id.search).setVisibility(View.VISIBLE);
|
||||
getActivity().findViewById(R.id.spinner).setVisibility(View.GONE);
|
||||
getActivity().setTitle("");
|
||||
|
||||
// olivia : set tampilan toolbar untuk masing" density
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
switch (displayMetrics.densityDpi) {
|
||||
case DisplayMetrics.DENSITY_MEDIUM:
|
||||
getActivity().findViewById(R.id.search).setLayoutParams(new Toolbar.LayoutParams(200, Toolbar.LayoutParams.WRAP_CONTENT));
|
||||
break;
|
||||
case DisplayMetrics.DENSITY_HIGH:
|
||||
getActivity().findViewById(R.id.search).setLayoutParams(new Toolbar.LayoutParams(300, Toolbar.LayoutParams.WRAP_CONTENT));
|
||||
break;
|
||||
case DisplayMetrics.DENSITY_XHIGH:
|
||||
getActivity().findViewById(R.id.search).setLayoutParams(new Toolbar.LayoutParams(470, Toolbar.LayoutParams.WRAP_CONTENT));
|
||||
break;
|
||||
case DisplayMetrics.DENSITY_XXHIGH:
|
||||
getActivity().findViewById(R.id.search).setLayoutParams(new Toolbar.LayoutParams(710, Toolbar.LayoutParams.WRAP_CONTENT));
|
||||
break;
|
||||
case DisplayMetrics.DENSITY_XXXHIGH:
|
||||
getActivity().findViewById(R.id.search).setLayoutParams(new Toolbar.LayoutParams(950, Toolbar.LayoutParams.WRAP_CONTENT));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
mainMenu = menu;
|
||||
menu.findItem(R.id.menuMore).setVisible(true);
|
||||
setToolbar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
if(isMenuClicked == false){
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.menuMore) {
|
||||
mainMenu.findItem(R.id.mnViewMap).setVisible(true);
|
||||
isMenuClicked=false;
|
||||
}
|
||||
if (id == R.id.mnViewMap) {
|
||||
MapsViewerFragment fragment = new MapsViewerFragment();
|
||||
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();
|
||||
isMenuClicked=true;
|
||||
}
|
||||
// olivia : menu View All Header sdh tidak digunakan karena hampir sama dgn Task List
|
||||
else if (id == R.id.mnViewAllHeader) {
|
||||
AllHeaderViewerFragment viewerFragment = AllHeaderViewerFragment.newInstance(AllHeaderViewerFragment.REQ_PRIORITY_LIST);
|
||||
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, viewerFragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
isMenuClicked=true;
|
||||
}
|
||||
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
isNewToDoListOpen = false;
|
||||
bottomNav.getMenu().findItem(R.id.taskListNav).setEnabled(true);
|
||||
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
mSwipeRefreshLayout.destroyDrawingCache();
|
||||
mSwipeRefreshLayout.clearAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
isNewToDoListOpen = true;
|
||||
isMenuClicked = false;
|
||||
setToolbar();
|
||||
|
||||
bottomNav.getMenu().findItem(R.id.taskListNav).setEnabled(false);
|
||||
|
||||
listTaskH = iTasklist.getSelectedTaskH(taskPosition);
|
||||
viewAdapter = new NewToDoListViewAdapter(getActivity(), listTaskH, NewToDoListTabFragment.this, param);
|
||||
recyclerView.setAdapter(viewAdapter);
|
||||
viewAdapter.notifyDataSetChanged();
|
||||
initBackground(listTaskH);
|
||||
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
|
||||
try {
|
||||
setCashOnHandUI();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
ACRA.getErrorReporter().putCustomData("errorOnResume", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorOnResume", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Set Cash UI"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
NewMainActivity.setCounter();
|
||||
} catch (Exception e) {
|
||||
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("ErrorMainMenuActivity", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Drawer Counter"));
|
||||
}
|
||||
DialogManager.showTimeProviderAlert(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
Fragment fragment = this;
|
||||
iTasklist = new TasklistImpl(fragment, this);
|
||||
iTimeline = new TimelineImpl(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
param = iTasklist.getParam();
|
||||
toDoList = iTasklist.getTodoList();
|
||||
listTaskH = new ArrayList<>();
|
||||
|
||||
mHandler = new Handler();
|
||||
|
||||
try {
|
||||
listTaskH = iTasklist.getTaskH(null, 0);
|
||||
ViewMapActivity.setListTaskH(listTaskH);
|
||||
} catch (Exception e) {
|
||||
ACRA.getErrorReporter().putCustomData("ErrorOnCreate", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("ErrorOnCreate", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set List TaskH"));
|
||||
if (Global.IS_DEV)
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
formListName = new ArrayList<>();
|
||||
formListName.clear();
|
||||
setAllschemeSpinner();
|
||||
formListName.addAll(SchemeDataAccess.getAllActivePriorityScheme(getActivity()));
|
||||
viewAdapter = new NewToDoListViewAdapter(getActivity(), listTaskH, this, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.new_fragment_task_list, container, false);
|
||||
|
||||
bottomNav = (BottomNavigationView) getActivity().findViewById(R.id.bottomNav);
|
||||
|
||||
// olivia : untuk trigger dialog search ketika klik layout search di toolbar
|
||||
textView = (TextView) getActivity().findViewById(R.id.searchTask);
|
||||
textView.setText(getString(R.string.all_form_all_task));
|
||||
taskPosition = 0;
|
||||
formPosition = 0;
|
||||
getActivity().findViewById(R.id.buttonSearch).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
searchDialog();
|
||||
}
|
||||
});
|
||||
|
||||
// Set the adapter
|
||||
if (view instanceof RelativeLayout) {
|
||||
handler = new NewToDoListTabFragment.NewToDoListHandler();
|
||||
Context context = view.getContext();
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.listTask);
|
||||
layout = (RelativeLayout) view.findViewById(R.id.layout);
|
||||
dataNotFound = (TextView) view.findViewById(R.id.txv_data_not_found);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.getRecycledViewPool().setMaxRecycledViews(1, 500);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
initBackground(listTaskH);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.setAdapter(viewAdapter);
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refreshTimeline);
|
||||
mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.tv_light),
|
||||
getResources().getColor(R.color.tv_normal),
|
||||
getResources().getColor(R.color.tv_dark),
|
||||
getResources().getColor(R.color.tv_darker));
|
||||
mSwipeRefreshLayout
|
||||
.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
iTasklist.setSelectedScheme(selectedScheme);
|
||||
iTasklist.setSelectedTask(taskPosition);
|
||||
iTasklist.initiateRefresh(true);
|
||||
}
|
||||
});
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
|
||||
try {
|
||||
setCashOnHandUI();
|
||||
} catch (Exception e) {
|
||||
ACRA.getErrorReporter().putCustomData("errorOnResume", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorOnResume", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Set Cash UI"));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
public void initBackground(List<TaskH> taskHList) {
|
||||
if (taskHList.size() == 0) {
|
||||
layout.setBackgroundResource(R.drawable.bg_notfound);
|
||||
} else {
|
||||
layout.setBackgroundResource(R.color.bgColor);
|
||||
}
|
||||
}
|
||||
|
||||
// olivia : melakukan search sesuai value di dropdown
|
||||
public void doSearch() {
|
||||
selectedScheme = formAdapter.getItem(formPosition);
|
||||
iTasklist.setSelectedScheme(selectedScheme);
|
||||
iTasklist.cancelRefreshTask();
|
||||
iTasklist.setSelectedTask(taskPosition);
|
||||
listTaskH = iTasklist.getSelectedTaskH(taskPosition);
|
||||
|
||||
viewAdapter = new NewToDoListViewAdapter(getActivity(), listTaskH, NewToDoListTabFragment.this, param);
|
||||
recyclerView.setAdapter(viewAdapter);
|
||||
viewAdapter.notifyDataSetChanged();
|
||||
initBackground(listTaskH);
|
||||
}
|
||||
|
||||
public void setAdapter(String[] listTask) {
|
||||
formListName = new ArrayList<>();
|
||||
formListName.clear();
|
||||
setAllschemeSpinner();
|
||||
formListName.addAll(SchemeDataAccess.getAllActivePriorityScheme(getActivity()));
|
||||
newToDoListAdapter = new NewToDoListTabFragment.NewToDoListAdapter(getActivity(), R.layout.spinner_style2, listTask);
|
||||
newToDoListAdapter.setDropDownViewResource(R.layout.spinner_style);
|
||||
formAdapter = new NewToDoListTabFragment.FormAdapter(getActivity(), R.layout.spinner_style2, R.id.text_spin, formListName);
|
||||
formAdapter.setDropDownViewResource(R.layout.spinner_style);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshBackgroundCancelled(boolean value) {
|
||||
if (mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing())
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshBackgroundComplete(List<TaskH> result) {
|
||||
onRefreshComplete(result);
|
||||
initBackground(listTaskH);
|
||||
}
|
||||
|
||||
private void setCashOnHandUI() {
|
||||
iTimeline.setCashOnHand();
|
||||
}
|
||||
|
||||
private void setAllschemeSpinner() {
|
||||
Scheme schemeDummy = new Scheme();
|
||||
schemeDummy.setUuid_scheme(uuidSchemeDummy);
|
||||
schemeDummy.setScheme_description(getString(R.string.all_form));
|
||||
schemeDummy.setForm_id("schemeDummy");
|
||||
|
||||
formListName.add(0, schemeDummy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
iTasklist.cancelRefreshTask();
|
||||
Utility.freeMemory();
|
||||
try {
|
||||
mainMenu.findItem(R.id.menuMore).setVisible(false);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
bottomNav.getMenu().findItem(R.id.taskListNav).setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClickListener(TaskH item, int position) {
|
||||
try {
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application) && iTimeline.isCOHAktif() && iTimeline.getLimit() > 0 && iTimeline.getCashOnHand() >= iTimeline.getLimit()) {
|
||||
DialogManager.showAlertNotif(getActivity(), getActivity().getString(R.string.limit_coh), "Cash On Hand");
|
||||
} else {
|
||||
Scheme scheme = null;
|
||||
scheme = item.getScheme();
|
||||
if (scheme == null) {
|
||||
if (item.getUuid_scheme() != null) {
|
||||
scheme = SchemeDataAccess.getOne(getActivity(),
|
||||
item.getUuid_scheme());
|
||||
if (scheme != null)
|
||||
item.setScheme(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
if (scheme == null) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.task_cant_seen),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
if (!GlobalData.getSharedGlobalData().getDoingTask()) {
|
||||
SurveyHeaderBean header = new SurveyHeaderBean(item);
|
||||
Fragment fragment = null;
|
||||
if (GlobalData.getSharedGlobalData().getApplication().equals(Global.APPLICATION_ORDER))
|
||||
fragment = NewLeadFragment.create(header);
|
||||
else
|
||||
fragment = CustomerFragment.create(header);
|
||||
FragmentTransaction transaction = getFragmentManager().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();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ACRA.getErrorReporter().putCustomData("errorClickListener", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorClickListener", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat click item"));
|
||||
String message = e.getMessage();
|
||||
Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemLongClickListener(final TaskH item, int position) {
|
||||
try {
|
||||
if(item.getStatus().equals(TaskHDataAccess.STATUS_SEND_UPLOADING)){
|
||||
try {
|
||||
final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(getActivity());
|
||||
dialogBuilder.withTitle(getActivity().getString(R.string.info_capital))
|
||||
.withMessage(getActivity().getString(R.string.confirm_upload)+" "+item.getCustomer_name()+" ?")
|
||||
.withButton1Text(getActivity().getString(R.string.btnYes))
|
||||
.withButton2Text(getActivity().getString(R.string.btnCancel))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
dialogBuilder.dismiss();
|
||||
if (Tool.isInternetconnected(getActivity())) {
|
||||
if (Global.isIsUploading() || Global.isIsManualUploading()) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.upload_on_queue), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
try {
|
||||
List<TaskD> taskd = TaskDDataAccess.getUnsentImageByTaskH(getActivity(), item.getUuid_user(), item.getUuid_task_h());
|
||||
TaskManager.ManualUploadImage(getActivity(), taskd);
|
||||
for (int i = 1; i < getActivity().getSupportFragmentManager().getBackStackEntryCount(); i++)
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.request_error), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.no_internet_connection), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setButton2Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialogBuilder.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else if(item.getStatus().equals(TaskHDataAccess.STATUS_SEND_PENDING)){
|
||||
String btnText1 = getActivity().getString(R.string.btnSend);
|
||||
if(item.getIs_prepocessed()!= null && item.getIs_prepocessed().equals(Global.FORM_TYPE_VERIFICATION))
|
||||
btnText1 = getActivity().getString(R.string.verifyBtn);
|
||||
else if(item.getIs_prepocessed()!= null && item.getIs_prepocessed().equals(Global.FORM_TYPE_APPROVAL))
|
||||
btnText1 = getActivity().getString(R.string.approveBtn);
|
||||
final NiftyDialogBuilder_PL dialogBuilder = NiftyDialogBuilder_PL.getInstance(getActivity());
|
||||
dialogBuilder.withNoTitle()
|
||||
.withNoMessage()
|
||||
.withButton1Text(btnText1)
|
||||
.withButton2Text(getActivity().getString(R.string.btnDelete))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
dialogBuilder.dismiss();
|
||||
if (Tool.isInternetconnected(getActivity())) {
|
||||
if(item.getTask_id()!=null) {
|
||||
if(item.getIs_prepocessed() != null && item.getIs_prepocessed().equals(Global.FORM_TYPE_VERIFICATION)) {
|
||||
if (item.getFlag_survey() != null && item.getFlag_survey().equals(Global.FLAG_FOR_REJECTEDTASK))
|
||||
new TaskManager().sendApprovalTaskOnBackground(getActivity(), item, Global.FLAG_FOR_REJECTEDTASK, false, item.getVerification_notes());
|
||||
else if (item.getFlag_survey() != null && item.getFlag_survey().equals(Global.FLAG_FOR_REJECTEDTASK_WITHRESURVEY))
|
||||
new TaskManager().sendRejectedWithReSurveyTask(getActivity(), item, Global.FLAG_FOR_REJECTEDTASK_WITHRESURVEY, Global.VERIFICATION_FLAG);
|
||||
else
|
||||
new TaskManager.ForceSendTaskOnBackground(getActivity(), item.getTask_id()).execute();
|
||||
} else if(item.getIs_prepocessed() != null && item.getIs_prepocessed().equals(Global.FORM_TYPE_APPROVAL)) {
|
||||
if (item.getFlag_survey() != null && item.getFlag_survey().equals(Global.FLAG_FOR_REJECTEDTASK))
|
||||
new TaskManager().sendApprovalTaskOnBackground(getActivity(), item, Global.FLAG_FOR_REJECTEDTASK, true, item.getVerification_notes());
|
||||
else if (item.getFlag_survey() != null && item.getFlag_survey().equals(Global.FLAG_FOR_REJECTEDTASK_WITHRESURVEY))
|
||||
new TaskManager().sendRejectedWithReSurveyTask(getActivity(), item, Global.FLAG_FOR_REJECTEDTASK_WITHRESURVEY, Global.APPROVAL_FLAG);
|
||||
else
|
||||
new TaskManager().sendApprovalTaskOnBackground(getActivity(), item, Global.FLAG_FOR_APPROVALTASK, true, item.getVerification_notes());
|
||||
} else
|
||||
new TaskManager.ForceSendTaskOnBackground(getActivity(), item.getTask_id()).execute();
|
||||
|
||||
for (int i = 1; i < getActivity().getSupportFragmentManager().getBackStackEntryCount(); i++)
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listTaskH.clear();
|
||||
listTaskH.addAll(iTasklist.getSelectedTaskH(0));
|
||||
viewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else{
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.no_internet_connection), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setButton2Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TaskHDataAccess.deleteWithRelation(getActivity(), item);
|
||||
if(item.getTask_id()!=null)
|
||||
ToDoList.removeSurveyFromList(item.getTask_id());
|
||||
iTasklist.setSelectedScheme(selectedScheme);
|
||||
iTasklist.setSelectedTask(taskPosition);
|
||||
iTasklist.initiateRefresh(true);
|
||||
dialogBuilder.dismiss();
|
||||
}
|
||||
}).show();
|
||||
}else if (item.getStatus().equals(TaskHDataAccess.STATUS_SEND_SAVEDRAFT)){
|
||||
final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(getActivity());
|
||||
dialogBuilder.withTitle(getActivity().getString(R.string.info_capital))
|
||||
.withMessage(getActivity().getString(R.string.confirm_delete)+" "+item.getCustomer_name()+" ?")
|
||||
.withButton1Text(getActivity().getString(R.string.btnYes))
|
||||
.withButton2Text(getActivity().getString(R.string.btnCancel))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
TaskHDataAccess.deleteWithRelation(getActivity(), item);
|
||||
ToDoList.removeSurveyFromList(item.getTask_id());
|
||||
iTasklist.setSelectedScheme(selectedScheme);
|
||||
iTasklist.setSelectedTask(taskPosition);
|
||||
iTasklist.initiateRefresh(true);
|
||||
dialogBuilder.dismiss();
|
||||
}
|
||||
})
|
||||
.setButton2Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialogBuilder.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
FireCrash.log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void onRefreshComplete(List<TaskH> result) {
|
||||
try {
|
||||
listTaskH.clear();
|
||||
listTaskH = result;
|
||||
viewAdapter = new NewToDoListViewAdapter(getActivity(), listTaskH, NewToDoListTabFragment.this, param);
|
||||
recyclerView.setAdapter(viewAdapter);
|
||||
|
||||
viewAdapter.notifyDataSetChanged();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
try {
|
||||
viewAdapter.notifyDataSetChanged();
|
||||
} catch (Exception e2) {
|
||||
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Notify Data Set Changed"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
viewAdapter.notifyDataSetChanged();
|
||||
} catch (Exception e2) {
|
||||
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("ErrorOnRefreshCompleted", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat set Notify Data Set Changed"));
|
||||
}
|
||||
}
|
||||
// Stop the refreshing indicator
|
||||
if (mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing())
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
public void searchDialog() {
|
||||
final AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.Dialog_NoTitle)
|
||||
.setView(R.layout.new_dialog_search)
|
||||
.create();
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
|
||||
wmlp.gravity = Gravity.BOTTOM;
|
||||
wmlp.windowAnimations = R.style.DialogAnimation;
|
||||
dialog.show();
|
||||
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
final AppCompatSpinner searchForm = (AppCompatSpinner) dialog.findViewById(R.id.spinnerForm);
|
||||
final AppCompatSpinner searchTask = (AppCompatSpinner) dialog.findViewById(R.id.spinnerTask);
|
||||
Button search = (Button) dialog.findViewById(R.id.btnSearch);
|
||||
|
||||
String[] listTask = getActivity().getResources().getStringArray(R.array.taskSearch);
|
||||
|
||||
newToDoListAdapter = new NewToDoListTabFragment.NewToDoListAdapter(getActivity(), R.layout.spinner_style2, listTask);
|
||||
newToDoListAdapter.setDropDownViewResource(R.layout.spinner_style);
|
||||
formAdapter = new NewToDoListTabFragment.FormAdapter(getActivity(), R.layout.spinner_style2, R.id.text_spin, formListName);
|
||||
formAdapter.setDropDownViewResource(R.layout.spinner_style);
|
||||
|
||||
searchForm.setAdapter(formAdapter);
|
||||
searchTask.setAdapter(newToDoListAdapter);
|
||||
|
||||
searchForm.setSelection(formPosition);
|
||||
searchTask.setSelection(taskPosition);
|
||||
|
||||
search.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
taskPosition = searchTask.getSelectedItemPosition();
|
||||
formPosition = searchForm.getSelectedItemPosition();
|
||||
|
||||
Scheme scheme = (Scheme) searchForm.getSelectedItem();
|
||||
|
||||
textView.setText(scheme.getScheme_description() + " . " + searchTask.getSelectedItem().toString());
|
||||
|
||||
doSearch();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class FormAdapter extends ArrayAdapter<Scheme> {
|
||||
private Activity activity;
|
||||
private List<Scheme> values;
|
||||
|
||||
public FormAdapter(Activity activity, int resource, int textViewResourceId, List<Scheme> objects) {
|
||||
super(activity, resource, textViewResourceId, objects);
|
||||
this.activity = activity;
|
||||
this.values = objects;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return values.size();
|
||||
}
|
||||
|
||||
public Scheme getItem(int position) {
|
||||
return values.get(position);
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.spinner_style2, parent, false);
|
||||
TextView label = (TextView) view.findViewById(R.id.text_spin);
|
||||
label.setText(values.get(position).getScheme_description());
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.spinner_style, parent, false);
|
||||
TextView label = (TextView) view.findViewById(R.id.text_spin);
|
||||
label.setText(values.get(position).getScheme_description());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public class NewToDoListAdapter extends ArrayAdapter<String> {
|
||||
private Activity activity;
|
||||
private String[] values;
|
||||
|
||||
public NewToDoListAdapter(Activity activity, int resource, String[] objects) {
|
||||
super(activity, resource, objects);
|
||||
this.activity = activity;
|
||||
this.values = objects;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return values.length;
|
||||
}
|
||||
|
||||
public String getItem(int position) {
|
||||
return values[position];
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.spinner_style2, parent, false);
|
||||
TextView label = (TextView) view.findViewById(R.id.text_spin);
|
||||
label.setText(values[position]);
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater inflater = activity.getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.spinner_style, parent, false);
|
||||
TextView label = (TextView) view.findViewById(R.id.text_spin);
|
||||
label.setText(values[position]);
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public static NewToDoListTabFragment.NewToDoListHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static void setHandler(NewToDoListTabFragment.NewToDoListHandler handler) {
|
||||
NewToDoListTabFragment.handler = handler;
|
||||
}
|
||||
|
||||
public class NewToDoListHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
try {
|
||||
if (isNewToDoListOpen) {
|
||||
iTasklist.initiateRefresh(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
ACRA.getErrorReporter().putCustomData("errorRefresh", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorRefresh", Tool.getSystemDateTime().toLocaleString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat initiate Refresh"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.Account;
|
||||
import com.adins.mss.dao.AccountDao;
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 11/16/2017.
|
||||
*/
|
||||
|
||||
public class AccountDataAccess {
|
||||
|
||||
protected static DaoSession getDaoSession(Context context){
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
protected static AccountDao getAccountDao(Context context) {
|
||||
return getDaoSession(context).getAccountDao();
|
||||
}
|
||||
|
||||
public static void add(Context context, Account account){
|
||||
getAccountDao(context).insert(account);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void add(Context context, List<Account> accountList){
|
||||
getAccountDao(context).insertInTx(accountList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void addOrReplace(Context context, Account account){
|
||||
getAccountDao(context).insertOrReplaceInTx(account);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void addOrReplace(Context context, List<Account> accountList){
|
||||
getAccountDao(context).insertOrReplaceInTx(accountList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void clean(Context context){
|
||||
getAccountDao(context).deleteAll();
|
||||
}
|
||||
|
||||
public static void delete(Context context, Account account){
|
||||
getAccountDao(context).delete(account);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void update(Context context, Account account){
|
||||
getAccountDao(context).update(account);
|
||||
}
|
||||
|
||||
public static List<Account> getAll(Context context){
|
||||
QueryBuilder<Account> qb = getAccountDao(context).queryBuilder();
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static Account getOne(Context context, String uuid){
|
||||
QueryBuilder<Account> qb = getAccountDao(context).queryBuilder();
|
||||
qb.where(AccountDao.Properties.Uuid_account.eq(uuid));
|
||||
qb.build();
|
||||
|
||||
if ((qb.list() == null) || qb.list().isEmpty()) return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,288 @@
|
|||
package com.adins.mss.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import android.database.Cursor;
|
||||
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import de.greenrobot.dao.internal.SqlUtils;
|
||||
import de.greenrobot.dao.internal.DaoConfig;
|
||||
import de.greenrobot.dao.database.Database;
|
||||
import de.greenrobot.dao.database.DatabaseStatement;
|
||||
import de.greenrobot.dao.query.Query;
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
import com.adins.mss.dao.ErrorLog;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "TR_ERROR_LOG".
|
||||
*/
|
||||
public class ErrorLogDao extends AbstractDao<ErrorLog, String> {
|
||||
|
||||
public static final String TABLENAME = "TR_ERROR_LOG";
|
||||
|
||||
/**
|
||||
* Properties of entity ErrorLog.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Uuid_error_log = new Property(0, String.class, "uuid_error_log", true, "UUID_ERROR_LOG");
|
||||
public final static Property Error_description = new Property(1, String.class, "error_description", false, "ERROR_DESCRIPTION");
|
||||
public final static Property Device_name = new Property(2, String.class, "device_name", false, "DEVICE_NAME");
|
||||
public final static Property Dtm_activity = new Property(3, java.util.Date.class, "dtm_activity", false, "DTM_ACTIVITY");
|
||||
public final static Property Uuid_user = new Property(4, String.class, "uuid_user", false, "UUID_USER");
|
||||
public final static Property Task_id = new Property(5, String.class, "task_id", false, "TASK_ID");
|
||||
};
|
||||
|
||||
private DaoSession daoSession;
|
||||
|
||||
private Query<ErrorLog> user_ErrorLogListQuery;
|
||||
private Query<ErrorLog> taskH_ErrorLogListQuery;
|
||||
|
||||
public ErrorLogDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public ErrorLogDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
this.daoSession = daoSession;
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"TR_ERROR_LOG\" (" + //
|
||||
"\"UUID_ERROR_LOG\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_error_log
|
||||
"\"ERROR_DESCRIPTION\" TEXT," + // 1: error_description
|
||||
"\"DEVICE_NAME\" TEXT," + // 2: device_name
|
||||
"\"DTM_ACTIVITY\" INTEGER," + // 3: dtm_activity
|
||||
"\"UUID_USER\" TEXT," + // 4: uuid_user
|
||||
"\"TASK_ID\" TEXT);"); // 5: task_id
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_ERROR_LOG\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected void bindValues(DatabaseStatement stmt, ErrorLog entity) {
|
||||
stmt.clearBindings();
|
||||
stmt.bindString(1, entity.getUuid_error_log());
|
||||
|
||||
String error_description = entity.getError_description();
|
||||
if (error_description != null) {
|
||||
stmt.bindString(2, error_description);
|
||||
}
|
||||
|
||||
String device_name = entity.getDevice_name();
|
||||
if (device_name != null) {
|
||||
stmt.bindString(3, device_name);
|
||||
}
|
||||
|
||||
java.util.Date dtm_activity = entity.getDtm_activity();
|
||||
if (dtm_activity != null) {
|
||||
stmt.bindLong(4, dtm_activity.getTime());
|
||||
}
|
||||
|
||||
String uuid_user = entity.getUuid_user();
|
||||
if (uuid_user != null) {
|
||||
stmt.bindString(5, uuid_user);
|
||||
}
|
||||
|
||||
String task_id = entity.getTask_id();
|
||||
if (task_id != null) {
|
||||
stmt.bindString(6, task_id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachEntity(ErrorLog entity) {
|
||||
super.attachEntity(entity);
|
||||
entity.__setDaoSession(daoSession);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public ErrorLog readEntity(Cursor cursor, int offset) {
|
||||
ErrorLog entity = new ErrorLog( //
|
||||
cursor.getString(offset + 0), // uuid_error_log
|
||||
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // error_description
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // device_name
|
||||
cursor.isNull(offset + 3) ? null : new java.util.Date(cursor.getLong(offset + 3)), // dtm_activity
|
||||
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // uuid_user
|
||||
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // task_id
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, ErrorLog entity, int offset) {
|
||||
entity.setUuid_error_log(cursor.getString(offset + 0));
|
||||
entity.setError_description(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
|
||||
entity.setDevice_name(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setDtm_activity(cursor.isNull(offset + 3) ? null : new java.util.Date(cursor.getLong(offset + 3)));
|
||||
entity.setUuid_user(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
|
||||
entity.setTask_id(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected String updateKeyAfterInsert(ErrorLog entity, long rowId) {
|
||||
return entity.getUuid_error_log();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String getKey(ErrorLog entity) {
|
||||
if(entity != null) {
|
||||
return entity.getUuid_error_log();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "errorLogList" to-many relationship of User. */
|
||||
public List<ErrorLog> _queryUser_ErrorLogList(String uuid_user) {
|
||||
synchronized (this) {
|
||||
if (user_ErrorLogListQuery == null) {
|
||||
QueryBuilder<ErrorLog> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Uuid_user.eq(null));
|
||||
user_ErrorLogListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<ErrorLog> query = user_ErrorLogListQuery.forCurrentThread();
|
||||
query.setParameter(0, uuid_user);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "errorLogList" to-many relationship of TaskH. */
|
||||
public List<ErrorLog> _queryTaskH_ErrorLogList(String task_id) {
|
||||
synchronized (this) {
|
||||
if (taskH_ErrorLogListQuery == null) {
|
||||
QueryBuilder<ErrorLog> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Task_id.eq(null));
|
||||
taskH_ErrorLogListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<ErrorLog> query = taskH_ErrorLogListQuery.forCurrentThread();
|
||||
query.setParameter(0, task_id);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
private String selectDeep;
|
||||
|
||||
protected String getSelectDeep() {
|
||||
if (selectDeep == null) {
|
||||
StringBuilder builder = new StringBuilder("SELECT ");
|
||||
SqlUtils.appendColumns(builder, "T", getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T0", daoSession.getUserDao().getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T1", daoSession.getTaskHDao().getAllColumns());
|
||||
builder.append(" FROM TR_ERROR_LOG T");
|
||||
builder.append(" LEFT JOIN MS_USER T0 ON T.\"UUID_USER\"=T0.\"UUID_USER\"");
|
||||
builder.append(" LEFT JOIN TR_TASK_H T1 ON T.\"TASK_ID\"=T1.\"UUID_TASK_H\"");
|
||||
builder.append(' ');
|
||||
selectDeep = builder.toString();
|
||||
}
|
||||
return selectDeep;
|
||||
}
|
||||
|
||||
protected ErrorLog loadCurrentDeep(Cursor cursor, boolean lock) {
|
||||
ErrorLog entity = loadCurrent(cursor, 0, lock);
|
||||
int offset = getAllColumns().length;
|
||||
|
||||
User user = loadCurrentOther(daoSession.getUserDao(), cursor, offset);
|
||||
entity.setUser(user);
|
||||
offset += daoSession.getUserDao().getAllColumns().length;
|
||||
|
||||
TaskH taskH = loadCurrentOther(daoSession.getTaskHDao(), cursor, offset);
|
||||
entity.setTaskH(taskH);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public ErrorLog loadDeep(Long key) {
|
||||
assertSinglePk();
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(getSelectDeep());
|
||||
builder.append("WHERE ");
|
||||
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
|
||||
String sql = builder.toString();
|
||||
|
||||
String[] keyArray = new String[] { key.toString() };
|
||||
Cursor cursor = db.rawQuery(sql, keyArray);
|
||||
|
||||
try {
|
||||
boolean available = cursor.moveToFirst();
|
||||
if (!available) {
|
||||
return null;
|
||||
} else if (!cursor.isLast()) {
|
||||
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
|
||||
}
|
||||
return loadCurrentDeep(cursor, true);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
|
||||
public List<ErrorLog> loadAllDeepFromCursor(Cursor cursor) {
|
||||
int count = cursor.getCount();
|
||||
List<ErrorLog> list = new ArrayList<ErrorLog>(count);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
if (identityScope != null) {
|
||||
identityScope.lock();
|
||||
identityScope.reserveRoom(count);
|
||||
}
|
||||
try {
|
||||
do {
|
||||
list.add(loadCurrentDeep(cursor, false));
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
if (identityScope != null) {
|
||||
identityScope.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<ErrorLog> loadDeepAllAndCloseCursor(Cursor cursor) {
|
||||
try {
|
||||
return loadAllDeepFromCursor(cursor);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** A raw-style query where you can pass any WHERE clause and arguments. */
|
||||
public List<ErrorLog> queryDeep(String where, String... selectionArg) {
|
||||
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
|
||||
return loadDeepAllAndCloseCursor(cursor);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
package com.adins.mss.odr.news;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.dao.MobileContentD;
|
||||
import com.adins.mss.dao.MobileContentH;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.MobileContentDDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.MobileContentHDataAccess;
|
||||
import com.adins.mss.foundation.http.HttpCryptedConnection;
|
||||
import com.adins.mss.foundation.http.KeyValue;
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class News {
|
||||
private static Context context;
|
||||
private static Activity activity;
|
||||
private static List<MobileContentH> listHeaderSVR;
|
||||
private static List<MobileContentH> listNewsChildSVR;
|
||||
private static List<MobileContentD> listContentSVR;
|
||||
|
||||
private static List<MobileContentH> listNewsParent;
|
||||
private static List<MobileContentH> listNewsChild;
|
||||
private static MobileContentH contentH;
|
||||
private static List<MobileContentD> listContent;
|
||||
// private static String uuid_user = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
int i = 1;
|
||||
|
||||
// public void getNewsHeaderFromServer() {
|
||||
// try {
|
||||
// listHeaderSVR = getlistNewsParentFromServer();
|
||||
// if(listHeaderSVR!=null || listHeaderSVR.size()>0){
|
||||
//
|
||||
// for(MobileContentH contentP : listHeaderSVR){
|
||||
// contentP.setUser(user);
|
||||
// if(contentP.getUuid_parent_content()==null||
|
||||
// contentP.getUuid_parent_content().equals("")){
|
||||
//
|
||||
// }
|
||||
// MobileContentHDataAccess.add(context, contentP);
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// System.out.println(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
public News(Activity activity) {
|
||||
News.context = activity;
|
||||
News.activity=activity;
|
||||
}
|
||||
|
||||
public static long getCounterNews(Context context) {
|
||||
long counter = 0;
|
||||
try {
|
||||
counter = MobileContentHDataAccess.getParentCounter(context, GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
// MOMainMenuActivity.mnNews.setCounter(String.valueOf(listNewsParent.size()));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
public void getNewsContentFromServer(MobileContentH contentH) {
|
||||
try {
|
||||
String uuid_mobile_content_h = contentH.getUuid_mobile_content_h();
|
||||
listContent = getListContentFromServer(uuid_mobile_content_h);
|
||||
if(listContent!=null || listContent.size()>0){
|
||||
for(MobileContentD contentD : listContent){
|
||||
contentD.setMobileContentH(contentH);
|
||||
MobileContentDDataAccess.add(context, contentD);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<MobileContentH> getlistNewsParent() {
|
||||
listNewsParent = MobileContentHDataAccess.getAllParent(context, GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
return listNewsParent;
|
||||
}
|
||||
|
||||
public List<MobileContentH> getAllNews() {
|
||||
List<MobileContentH> listNewsParent = MobileContentHDataAccess.getAll(context, GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
return listNewsParent;
|
||||
}
|
||||
|
||||
public List<MobileContentH> getlistNewsChild(String Uuid_mobile_content_h_Parent) {
|
||||
listNewsChild = MobileContentHDataAccess.getAll(context, GlobalData.getSharedGlobalData().getUser().getUuid_user(), Uuid_mobile_content_h_Parent);
|
||||
return listNewsChild;
|
||||
}
|
||||
|
||||
public List<MobileContentH> getlistNewsChildWithoutDate(String Uuid_mobile_content_h_Parent) {
|
||||
listNewsChild = MobileContentHDataAccess.getAllWithoutDate(context, GlobalData.getSharedGlobalData().getUser().getUuid_user(), Uuid_mobile_content_h_Parent);
|
||||
return listNewsChild;
|
||||
}
|
||||
|
||||
public MobileContentH getContent(String Uuid_mobile_content_h_Parent) {
|
||||
contentH = MobileContentHDataAccess.getOne(context, Uuid_mobile_content_h_Parent);
|
||||
return contentH;
|
||||
}
|
||||
|
||||
public List<MobileContentD> getlistContent(String Uuid_mobile_content_h_Child) {
|
||||
listContent = MobileContentDDataAccess.getAll(context, Uuid_mobile_content_h_Child);
|
||||
return listContent;
|
||||
}
|
||||
|
||||
public List<MobileContentD> getlistContentOnDate(String Uuid_mobile_content_h_Child) {
|
||||
listContent = MobileContentDDataAccess.getAllOnDate(context, Uuid_mobile_content_h_Child);
|
||||
return listContent;
|
||||
}
|
||||
|
||||
public List<MobileContentD> getlistContentWithoutDate(String Uuid_mobile_content_h_Child) {
|
||||
listContent = MobileContentDDataAccess.getAll(context, Uuid_mobile_content_h_Child);
|
||||
return listContent;
|
||||
}
|
||||
|
||||
public List<MobileContentD> getListContentFromServer(
|
||||
String uuid_mobile_content_h) {
|
||||
JsonRequestNews requestType = new JsonRequestNews();
|
||||
requestType.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
requestType.addImeiAndroidIdToUnstructured();
|
||||
requestType.setuuid_mobile_content_h(uuid_mobile_content_h);
|
||||
|
||||
String data = GsonHelper.toJson(requestType);
|
||||
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity, encrypt, decrypt);
|
||||
// HttpConnectionResult result = null;
|
||||
String result = null;
|
||||
JsonResponseNewsContent content = GsonHelper.fromJson(result, JsonResponseNewsContent.class);
|
||||
listContent = content.getListMobileContentD();
|
||||
|
||||
return listContent;
|
||||
}
|
||||
|
||||
// private List<MobileContentH> getlistNewsParentFromServer() {
|
||||
// JsonRequestNews requestType = new JsonRequestNews();
|
||||
// requestType.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
// requestType.addItemToUnstructured(imeIvalue, false);
|
||||
//// requestType.setListContentHeader(getlistNewsParent());
|
||||
// Gson gson = new GsonBuilder().setDateFormat("ddMMyyyyHHmmss").create();
|
||||
//
|
||||
// String json = gson.toJson(requestType);
|
||||
// String url = "Global.URL_GET_NEWS";
|
||||
//
|
||||
// HttpCryptedConnection httpConn = new HttpCryptedConnection(Global.ENCRYPT_COMM, Global.DECRYPT_COMM);
|
||||
//
|
||||
// HttpConnectionResult result = null;
|
||||
// try {
|
||||
// result = httpConn.requestHTTPPost(url, json);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// String data = result.getResult();
|
||||
// data ="{\"listHeader\":[{\"content_description\":\"Lorem ipsum dolor sit amet.\",\"content_name\":\"YAMAHA\",\"effective_date\":\"25022015101314\",\"uuid_mobile_content_h\":\"c0db330c-47eb-4f1b-bfd8-139d27749789\"},{\"content_description\":\"Lorem ipsum dolor sit amet.\",\"content_name\":\"TOYOTA\",\"effective_date\":\"25022015101314\",\"uuid_mobile_content_h\":\"0bd0210a-91f1-40a3-b2f4-347229fb702a\"},{\"content_description\":\"Lorem ipsum dolor sit amet.\",\"content_name\":\"YAMAHA MX\",\"effective_date\":\"25022015101314\",\"uuid_mobile_content_h\":\"2e635f95-2f8e-4681-8393-bd086426c92a\",\"uuid_parent_content\":\"c0db330c-47eb-4f1b-bfd8-139d27749789\"},{\"content_description\":\"Lorem ipsum dolor sit amet.\",\"content_name\":\"YAMAHA R1000\",\"effective_date\":\"25022015101314\",\"uuid_mobile_content_h\":\"6777a562-6efe-4ebf-b16c-0efd7e280e03\",\"uuid_parent_content\":\"c0db330c-47eb-4f1b-bfd8-139d27749789\"}],\"status\":{\"code\":\"1\"}}";
|
||||
// try {
|
||||
//// result = httpConn.requestHTTPPost(Global.URL_GET_CONTENTNEWS, data);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// JsonResponseNewsHeader news = gson.fromJson(data, JsonResponseNewsHeader.class);
|
||||
// listNewsParent = news.getListHeader();
|
||||
//// MobileContentHDataAccess.add(context, mobileContentHList);
|
||||
// return listNewsParent;
|
||||
// }
|
||||
|
||||
private List<MobileContentH> getlistNewsChildFromServer(
|
||||
String uuid_mobile_content_h) {
|
||||
// TODO Bikin cara buat dapetin dari server
|
||||
// MobileContentHDataAccess.add(context, mobileContentHList);
|
||||
|
||||
return listNewsChild;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.adins.mss.base.loyalti.mypointdashboard;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class DetailKompetisiRequest extends MssRequestType {
|
||||
|
||||
@SerializedName("LOGIN_ID")
|
||||
protected String LOGIN_ID;
|
||||
|
||||
public String getLOGIN_ID() {
|
||||
return LOGIN_ID;
|
||||
}
|
||||
|
||||
public void setLOGIN_ID(String LOGIN_ID) {
|
||||
this.LOGIN_ID = LOGIN_ID;
|
||||
}
|
||||
|
||||
// @SerializedName("MEMBERSHIP_PROGRAM_CODE")
|
||||
// protected ArrayList<String> MEMBERSHIP_PROGRAM_CODE;
|
||||
//
|
||||
// public ArrayList<String> getMEMBERSHIP_PROGRAM_CODE() {
|
||||
// return MEMBERSHIP_PROGRAM_CODE;
|
||||
// }
|
||||
//
|
||||
// public void setMEMBERSHIP_PROGRAM_CODE(ArrayList<String> MEMBERSHIP_PROGRAM_CODE) {
|
||||
// this.MEMBERSHIP_PROGRAM_CODE = MEMBERSHIP_PROGRAM_CODE;
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z"/>
|
||||
</vector>
|
Loading…
Add table
Add a link
Reference in a new issue