mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +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,82 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:background="@drawable/bg_grayscale">
|
||||
|
||||
<!-- <com.fima.cardsui.views.CardUI -->
|
||||
<!-- android:layout_below="@+id/export" -->
|
||||
<!-- android:id="@+id/cardsview" -->
|
||||
<!-- android:layout_width="match_parent" -->
|
||||
<!-- android:layout_height="match_parent"/> -->
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:headerDividersEnabled="true"
|
||||
android:footerDividersEnabled="true"
|
||||
android:scrollbarSize="1dp"
|
||||
android:layout_below="@+id/appDescription"
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
android:background="#ffffff"
|
||||
android:divider="#eeeeee"
|
||||
android:dividerHeight="5dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_logo"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:src="@drawable/icon_mss_new" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_appName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/btnCheckUpdate"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/app_name_order"
|
||||
android:fontFamily="sans-serif-condensed"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/appDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/iconDivider"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/app_desc_order"
|
||||
android:textSize="@dimen/textSizeSmall_openSource"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" />
|
||||
|
||||
<View
|
||||
android:id="@+id/iconDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
android:layout_alignLeft="@+id/appDescription"
|
||||
android:layout_below="@+id/txt_appName"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCheckUpdate"
|
||||
android:background="@drawable/button_background"
|
||||
android:textColor="@color/tv_white"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/app_logo"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/checkUpdate" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.adins.mss.coll.interfaces;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* Created by shaladin on 8/14/17.
|
||||
*/
|
||||
|
||||
public interface OnCameraInAppListener {
|
||||
public void onImageCapture(Intent intent, int requestCode);
|
||||
}
|
|
@ -0,0 +1,545 @@
|
|||
package com.adins.mss.base.login;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import androidx.core.content.FileProvider;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.BuildConfig;
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.NewChangePasswordActivity;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.authentication.Authentication;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.errorhandler.ErrorMessageHandler;
|
||||
import com.adins.mss.base.errorhandler.IShowError;
|
||||
import com.adins.mss.base.syncfile.FileSyncHelper;
|
||||
import com.adins.mss.base.update.DownloadUpdate;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.broadcast.SubmitSubscribedTopicTask;
|
||||
import com.adins.mss.foundation.dialog.DialogManager;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.adins.mss.foundation.oauth2.OAuth2Client;
|
||||
import com.adins.mss.foundation.oauth2.Token;
|
||||
import com.adins.mss.foundation.oauth2.store.SharedPreferencesTokenStore;
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Aditya Purwa on 1/6/2015.
|
||||
* Default implementation of login.
|
||||
*/
|
||||
public abstract class DefaultLoginModel extends LoginModel implements Authentication.AuthenticationHandler, IShowError {
|
||||
|
||||
public static final String LOGIN_PREFERENCES = "login_preferences";
|
||||
public static final String LOGIN_PREFERENCES_USERNAME = "login_preferences.USERNAME";
|
||||
public static final String LOGIN_PREFERENCES_PASSWORD = "login_preferences.PASSWORD";
|
||||
public static final String LOGIN_PREFERENCES_REMEMBER_ME = "login_preferences.REMEMBER_ME";
|
||||
public static final String PWD_EXP = "passwordExpired";
|
||||
public static String tenantId;
|
||||
public static onImportSuccess importSuccess;
|
||||
private final ObscuredSharedPreferences loginPreferences;
|
||||
private String username;
|
||||
private String password;
|
||||
private boolean isRememberMe;
|
||||
private ProgressDialog progressDialog;
|
||||
private ErrorMessageHandler errorMessageHandler;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of context model.
|
||||
*
|
||||
* @param context The context for the model. Must be an activity.
|
||||
*/
|
||||
public DefaultLoginModel(Context context) {
|
||||
super(context);
|
||||
loginPreferences = ObscuredSharedPreferences.getPrefs(context, LOGIN_PREFERENCES, Context.MODE_PRIVATE);
|
||||
errorMessageHandler = new ErrorMessageHandler();
|
||||
errorMessageHandler.setiShowError(this);
|
||||
}
|
||||
|
||||
public static void showGPSAlert(final Activity activity) {
|
||||
try {
|
||||
LocationManager lm = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
|
||||
if (lm.getProvider(LocationManager.GPS_PROVIDER) != null) {
|
||||
final boolean gpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
if (!gpsEnabled) {
|
||||
final NiftyDialogBuilder ndb = NiftyDialogBuilder.getInstance(activity);
|
||||
ndb.withTitle(activity.getString(R.string.gps_unable))
|
||||
.withMessage(activity.getString(R.string.gps_warning))
|
||||
.withButton1Text(activity.getString(R.string.gps_button))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ndb.dismiss();
|
||||
Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
activity.startActivity(settingsIntent);
|
||||
|
||||
}
|
||||
});
|
||||
ndb.isCancelable(false);
|
||||
ndb.show();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isRememberMe() {
|
||||
return isRememberMe;
|
||||
}
|
||||
|
||||
public void setRememberMe(boolean isRememberMe) {
|
||||
this.isRememberMe = isRememberMe;
|
||||
}
|
||||
|
||||
String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setTenantId(String username) {
|
||||
String[] idNtenant = Tool.split(username, "@");
|
||||
if (idNtenant.length > 1)
|
||||
tenantId = idNtenant[1];
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public boolean login() {
|
||||
|
||||
if (!ValidateInput()) {
|
||||
Toast.makeText(getContext(), getContext().getString(R.string.login_mandatory), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if (GlobalData.getSharedGlobalData().isRequiresAccessToken()) {
|
||||
getAccessTokenAndLogin(getContext());
|
||||
} else {
|
||||
doLogin();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void getAccessTokenAndLogin(final Context context) {
|
||||
new AsyncTask<Void, Void, String>() {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
progressDialog = ProgressDialog.show(getContext(), "", getContext().getString(R.string.please_wait), true);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
String result = "";
|
||||
String urlService = GlobalData.getSharedGlobalData().getUrlMain();
|
||||
int idx = urlService.indexOf("/services");
|
||||
String urlMain = urlService.substring(0, idx);
|
||||
OAuth2Client client = new OAuth2Client(getUsername(), getPassword(), GlobalData.getSharedGlobalData().getClientId(), null, urlMain);
|
||||
GlobalData.getSharedGlobalData().setoAuth2Client(client);
|
||||
try {
|
||||
Token token = client.getAccessToken(context);
|
||||
result = "success";
|
||||
if (result.equals("success")) {
|
||||
SharedPreferencesTokenStore tokenStore = new SharedPreferencesTokenStore(context);
|
||||
tokenStore.store(GlobalData.getSharedGlobalData().getoAuth2Client().getUsername(), token);
|
||||
GlobalData.getSharedGlobalData().setToken(token);
|
||||
}
|
||||
} catch (RuntimeException ex) {
|
||||
result = ex.getMessage();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
result = "Token Failed to store in Shared Preferences";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
closeProgress();
|
||||
if (result.equals("success")) {
|
||||
doLogin();
|
||||
} else {
|
||||
//intishar: change error message mechanism
|
||||
if(errorMessageHandler != null)
|
||||
errorMessageHandler.processError("",result, ErrorMessageHandler.TOAST_TYPE);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
protected void doLogin() {
|
||||
ObscuredSharedPreferences.Editor loginPreferencesEditor = loginPreferences.edit();
|
||||
if (isRememberMe()) {
|
||||
loginPreferencesEditor.putString(LOGIN_PREFERENCES_USERNAME, getUsername());
|
||||
loginPreferencesEditor.putString(LOGIN_PREFERENCES_PASSWORD, getPassword());
|
||||
loginPreferencesEditor.putBoolean(LOGIN_PREFERENCES_REMEMBER_ME, isRememberMe());
|
||||
loginPreferencesEditor.apply();
|
||||
} else {
|
||||
loginPreferencesEditor.clear();
|
||||
loginPreferencesEditor.apply();
|
||||
}
|
||||
try {
|
||||
if (Tool.isInternetconnected(getContext())) {
|
||||
setTenantId(getUsername());
|
||||
progressDialog = ProgressDialog.show(getContext(), "", getContext().getString(R.string.please_wait), true);
|
||||
progressDialog.show();
|
||||
Global.IS_LOGIN = true;
|
||||
Authentication.authenticateOnBackground(
|
||||
getContext(),
|
||||
getUsername(),
|
||||
getPassword(),
|
||||
getBuildNumber(),
|
||||
this);
|
||||
} else {
|
||||
Toast.makeText(getContext(), getContext().getString(R.string.connection_failed), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract int getBuildNumber();
|
||||
|
||||
private boolean ValidateInput() {
|
||||
return
|
||||
(getUsername() != null && getPassword() != null) &&
|
||||
(getUsername().length() > 0 && getPassword().length() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exit() {
|
||||
getContextAsActivity().finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFail(Authentication authentication, HttpConnectionResult httpConnectionResult) {
|
||||
closeProgress();
|
||||
//bong 6 may 15 - penjagaan message yang ditampilkan saat login dengan inactive user
|
||||
if (authentication == null) {
|
||||
//intishar: change error message mechanism
|
||||
if(errorMessageHandler != null)
|
||||
errorMessageHandler.processError(httpConnectionResult, httpConnectionResult.getResult(), ErrorMessageHandler.TOAST_TYPE);
|
||||
return;
|
||||
}
|
||||
//bong 7 may 15 - penjagaan jika belum login ke wifi
|
||||
MssResponseType responseFromServer = null;
|
||||
if (httpConnectionResult.isOK()) {
|
||||
responseFromServer = GsonHelper.fromJson(httpConnectionResult.getResult(), MssResponseType.class);
|
||||
|
||||
if (responseFromServer.getStatus().getCode() == Global.STATUS_CODE_APPL_CLEANSING) {
|
||||
Toast.makeText(
|
||||
getContext(),
|
||||
responseFromServer.getStatus().getMessage(),
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//intishar: change error message mechanism
|
||||
if(errorMessageHandler != null)
|
||||
errorMessageHandler.processError(httpConnectionResult, httpConnectionResult.getResult(), ErrorMessageHandler.TOAST_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginFail(Authentication authentication, String message) {
|
||||
closeProgress();
|
||||
if (message.contains("Android ID") || message.contains("android ID")) {
|
||||
Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showUserHelp(getContextAsActivity(), getContextAsActivity().findViewById(R.id.androidId),
|
||||
getContext().getString(R.string.androidIdnotregistered));
|
||||
}
|
||||
}, 2000);
|
||||
} else
|
||||
Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onForceUpdate(Authentication authentication, String message, String otaLink) {
|
||||
closeProgress();
|
||||
showForceUpdateDialog(otaLink);
|
||||
}
|
||||
|
||||
private void showForceUpdateDialog(final String otaLink) {
|
||||
NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(getContext())
|
||||
.withTitle(getContext().getString(R.string.server))
|
||||
.withMessage(getContext().getString(R.string.critical_update))
|
||||
.withButton1Text(getContext().getString(R.string.update)).setButton1Click(
|
||||
new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openUpdate(otaLink);
|
||||
}
|
||||
}
|
||||
).isCancelable(false)
|
||||
.isCancelableOnTouchOutside(false);
|
||||
builder.show();
|
||||
|
||||
}
|
||||
|
||||
private void openUpdate(String otaLink) {
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
File file = new File(context.getFilesDir(), "app.apk");
|
||||
if(file.exists()){
|
||||
Uri apkURI = FileProvider.getUriForFile(
|
||||
context, context.getPackageName() + ".provider", file);
|
||||
intent.setDataAndType(apkURI, "application/vnd.android.package-archive");
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
getContextAsActivity().startActivity(intent);
|
||||
} else{
|
||||
DownloadUpdate downloadUpdate = new DownloadUpdate(context);
|
||||
downloadUpdate.execute(otaLink);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInactiveUser(Authentication authentication) {
|
||||
try {
|
||||
closeProgress();
|
||||
String fullname = GlobalData.getSharedGlobalData().getUser() != null ? GlobalData.getSharedGlobalData().getUser().getFullname() : "";
|
||||
if(fullname == null || fullname.equals("")){
|
||||
fullname = Authentication.getTemp_loginID();
|
||||
if(fullname.contains("@")){
|
||||
fullname = fullname.substring(0,fullname.indexOf('@'));
|
||||
}
|
||||
}
|
||||
String message = getContext().getString(R.string.inactive_user, fullname);
|
||||
Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show();
|
||||
DialogManager.uninstallAPK(getContext());
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginSuccess(Authentication authentication, String otaLink, boolean needUpdatePassword,
|
||||
boolean pwdExp, boolean needUpdateApplication,
|
||||
String message, User authenticatedUser) {
|
||||
|
||||
//check if activity context has destroyed
|
||||
Activity activity = (Activity)context;
|
||||
if(activity.isFinishing()){
|
||||
return;
|
||||
}
|
||||
|
||||
closeProgress();
|
||||
importSuccess = new onImportSuccess();
|
||||
GlobalData.getSharedGlobalData().setUser(authenticatedUser);
|
||||
|
||||
if (needUpdateApplication) {
|
||||
showAskForUpdateDialog(otaLink, needUpdatePassword, pwdExp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (needUpdatePassword || pwdExp) {
|
||||
forceUpdatePassword(pwdExp);
|
||||
return;
|
||||
}
|
||||
|
||||
FileSyncHelper.senderID = 0;
|
||||
FileSyncHelper.startFileSync(getContext());
|
||||
}
|
||||
|
||||
private void forceUpdatePassword(boolean pwdExp) {
|
||||
loginPreferences.edit().putBoolean("is_expired", true)
|
||||
.apply();
|
||||
|
||||
Intent intent = new Intent(getContext(), NewChangePasswordActivity.class);
|
||||
if (pwdExp)
|
||||
intent.putExtra(PWD_EXP, "1");
|
||||
else intent.putExtra(PWD_EXP, "0");
|
||||
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
|
||||
public void closeProgress() {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private void goToSynchronize() {
|
||||
doSubscribe();
|
||||
Intent syncIntent = getIntentSynchronize();
|
||||
getContext().startActivity(syncIntent);
|
||||
}
|
||||
|
||||
protected abstract Intent getIntentSynchronize();
|
||||
|
||||
private void showAskForUpdateDialog(final String otaLink, final boolean needUpdatePassword, final boolean pwdExp) {
|
||||
final NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(getContext());
|
||||
builder.withTitle(getContext().getString(R.string.server)).isCancelableOnTouchOutside(false).isCancelable(false)
|
||||
.withMessage(getContext().getString(R.string.update_available))
|
||||
.withButton1Text(getContext().getString(R.string.later))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
builder.dismiss();
|
||||
if (needUpdatePassword || pwdExp) {
|
||||
forceUpdatePassword(pwdExp);
|
||||
} else {
|
||||
FileSyncHelper.senderID = 0;
|
||||
FileSyncHelper.startFileSync(getContext());
|
||||
}
|
||||
}
|
||||
})
|
||||
.withButton2Text(getContext().getString(R.string.update))
|
||||
.setButton2Click(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
builder.dismiss();
|
||||
openUpdate(otaLink);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
public void doSubscribe() {
|
||||
try {
|
||||
List<String> topicList = new ArrayList<>();
|
||||
User user = GlobalData.getSharedGlobalData().getUser();
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
String buildConfig = BuildConfig.FLAVOR.toUpperCase();
|
||||
if (buildConfig.length() == 0) {
|
||||
buildConfig = Global.FLAVORS;
|
||||
}
|
||||
String usedTenant = "";
|
||||
String userLogin = user.getLogin_id().split("@")[0];
|
||||
if (user.getLogin_id().contains("@")) {
|
||||
String tenant = user.getLogin_id().split("@")[1];
|
||||
if (null != tenant && !"".equalsIgnoreCase(tenant)) {
|
||||
usedTenant = "-" + tenant.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
String topicIndividu = "INDIVIDU-" + userLogin.toUpperCase() + "-" + buildConfig + usedTenant;
|
||||
FirebaseMessaging.getInstance().subscribeToTopic(topicIndividu);
|
||||
topicList.add(topicIndividu);
|
||||
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
|
||||
String topicAllMC = "ALL-MC-" + buildConfig + usedTenant;
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("ALL-MC-" + buildConfig + usedTenant);
|
||||
topicList.add(topicAllMC);
|
||||
if (null != user.getUuid_branch()) {
|
||||
String branchMC = "BRANCH-" + user.getUuid_branch() + "-" + buildConfig + usedTenant;
|
||||
FirebaseMessaging.getInstance().subscribeToTopic(branchMC);
|
||||
topicList.add(branchMC);
|
||||
}
|
||||
if (null != user.getUuid_group()) {
|
||||
String[] listGroup = user.getUuid_group().split(";");
|
||||
for (int i = 0; i < listGroup.length; i++) {
|
||||
String groupMC = "GROUP-" + listGroup[i] + "-" + buildConfig + usedTenant;
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("GROUP-" + listGroup[i] + "-" + buildConfig + usedTenant);
|
||||
topicList.add(groupMC);
|
||||
}
|
||||
}
|
||||
} else if (Global.APPLICATION_ORDER.equalsIgnoreCase(application)) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("ALL-MO-" + buildConfig + usedTenant);
|
||||
if (null != user.getUuid_group()) {
|
||||
String[] listGroup = user.getUuid_group().split(";");
|
||||
for (int i = 0; i < listGroup.length; i++) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("GROUP-" + listGroup[i] + "-" + buildConfig + usedTenant);
|
||||
}
|
||||
}
|
||||
if (null != user.getUuid_branch()) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("BRANCH-" + user.getUuid_branch() + "-" + buildConfig + usedTenant);
|
||||
}
|
||||
if (null != user.getUuid_dealer()) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("DEALER-" + user.getUuid_dealer() + "-" + buildConfig + usedTenant);
|
||||
}
|
||||
} else if (Global.APPLICATION_SURVEY.equalsIgnoreCase(application)) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("ALL-MS-" + buildConfig + usedTenant);
|
||||
if (null != user.getUuid_branch()) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("BRANCH-" + user.getUuid_branch() + "-" + buildConfig + usedTenant);
|
||||
}
|
||||
if (null != user.getUuid_group()) {
|
||||
String[] listGroup = user.getUuid_group().split(";");
|
||||
for (int i = 0; i < listGroup.length; i++) {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("GROUP-" + listGroup[i] + "-" + buildConfig + usedTenant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*SubmitSubscribedTopicTask submitSubscribedTopicTask = new SubmitSubscribedTopicTask(getContext(), GlobalData.getSharedGlobalData().getUser().getUuid_user(), topicList);
|
||||
submitSubscribedTopicTask.execute();*/
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
ACRA.getErrorReporter().putCustomData("errorToSubcribe", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorToSubcribe", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Subcribe Topic"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String errorSubject, String errorMsg, int notifType) {
|
||||
if(errorSubject != null && !errorSubject.equals(""))
|
||||
Toast.makeText(getContext(), errorSubject+":"+errorMsg, Toast.LENGTH_LONG).show();
|
||||
else {
|
||||
Toast.makeText(getContext(), errorMsg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public class onImportSuccess extends Handler {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
Bundle data = msg.getData();
|
||||
boolean success = data.getBoolean("importSuccess", false);
|
||||
if (success) {
|
||||
getContextAsActivity().finish();
|
||||
goToSynchronize();
|
||||
importSuccess = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.adins.mss.base.todolist.form.followup;
|
||||
|
||||
import com.adins.mss.dao.TaskH;
|
||||
|
||||
public class FollowUpTask{
|
||||
String flagTask;
|
||||
TaskH followUpTaskHeader;
|
||||
String tglJanjiBayar;
|
||||
|
||||
public String getTglJanjiBayar() {
|
||||
return tglJanjiBayar;
|
||||
}
|
||||
|
||||
public void setTglJanjiBayar(String tglJanjiBayar) {
|
||||
this.tglJanjiBayar = tglJanjiBayar;
|
||||
}
|
||||
|
||||
public String getFlagTask() {
|
||||
return flagTask;
|
||||
}
|
||||
|
||||
public void setFlagTask(String flagTask) {
|
||||
this.flagTask = flagTask;
|
||||
}
|
||||
|
||||
public TaskH getFollowUpTaskHeader() {
|
||||
return followUpTaskHeader;
|
||||
}
|
||||
|
||||
public void setFollowUpTaskHeader(TaskH followUpTaskHeader) {
|
||||
this.followUpTaskHeader = followUpTaskHeader;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* Copyright 2010 Emmanuel Astier & 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.collector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.acra.ACRA.LOG_TAG;
|
||||
|
||||
/**
|
||||
* Inspects a {@link Configuration} object through reflection API in order to
|
||||
* generate a human readable String with values replaced with their constants
|
||||
* names. The {@link Configuration#toString()} method was not enough as values
|
||||
* like 0, 1, 2 or 3 don't look readable to me. Using reflection API allows to
|
||||
* retrieve hidden fields and can make us hope to be compatible with all Android
|
||||
* API levels, even those which are not published yet.
|
||||
*
|
||||
* @author Kevin Gaudin
|
||||
*/
|
||||
public final class ConfigurationCollector {
|
||||
|
||||
private static final String SUFFIX_MASK = "_MASK";
|
||||
private static final String FIELD_SCREENLAYOUT = "screenLayout";
|
||||
private static final String FIELD_UIMODE = "uiMode";
|
||||
private static final String FIELD_MNC = "mnc";
|
||||
private static final String FIELD_MCC = "mcc";
|
||||
private static final String PREFIX_UI_MODE = "UI_MODE_";
|
||||
private static final String PREFIX_TOUCHSCREEN = "TOUCHSCREEN_";
|
||||
private static final String PREFIX_SCREENLAYOUT = "SCREENLAYOUT_";
|
||||
private static final String PREFIX_ORIENTATION = "ORIENTATION_";
|
||||
private static final String PREFIX_NAVIGATIONHIDDEN = "NAVIGATIONHIDDEN_";
|
||||
private static final String PREFIX_NAVIGATION = "NAVIGATION_";
|
||||
private static final String PREFIX_KEYBOARDHIDDEN = "KEYBOARDHIDDEN_";
|
||||
private static final String PREFIX_KEYBOARD = "KEYBOARD_";
|
||||
private static final String PREFIX_HARDKEYBOARDHIDDEN = "HARDKEYBOARDHIDDEN_";
|
||||
|
||||
private final HashMap<String, SparseArray<String>> mValueArrays = new HashMap<String, SparseArray<String>>();
|
||||
|
||||
private ConfigurationCollector() {
|
||||
|
||||
final SparseArray<String> hardKeyboardHiddenValues = new SparseArray<String>();
|
||||
final SparseArray<String> keyboardValues = new SparseArray<String>();
|
||||
final SparseArray<String> keyboardHiddenValues = new SparseArray<String>();
|
||||
final SparseArray<String> navigationValues = new SparseArray<String>();
|
||||
final SparseArray<String> navigationHiddenValues = new SparseArray<String>();
|
||||
final SparseArray<String> orientationValues = new SparseArray<String>();
|
||||
final SparseArray<String> screenLayoutValues = new SparseArray<String>();
|
||||
final SparseArray<String> touchScreenValues = new SparseArray<String>();
|
||||
final SparseArray<String> uiModeValues = new SparseArray<String>();
|
||||
|
||||
for (final Field f : Configuration.class.getFields()) {
|
||||
if (Modifier.isStatic(f.getModifiers()) && Modifier.isFinal(f.getModifiers())) {
|
||||
final String fieldName = f.getName();
|
||||
try {
|
||||
if (fieldName.startsWith(PREFIX_HARDKEYBOARDHIDDEN)) {
|
||||
hardKeyboardHiddenValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_KEYBOARD)) {
|
||||
keyboardValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_KEYBOARDHIDDEN)) {
|
||||
keyboardHiddenValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_NAVIGATION)) {
|
||||
navigationValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_NAVIGATIONHIDDEN)) {
|
||||
navigationHiddenValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_ORIENTATION)) {
|
||||
orientationValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_SCREENLAYOUT)) {
|
||||
screenLayoutValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_TOUCHSCREEN)) {
|
||||
touchScreenValues.put(f.getInt(null), fieldName);
|
||||
} else if (fieldName.startsWith(PREFIX_UI_MODE)) {
|
||||
uiModeValues.put(f.getInt(null), fieldName);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
ACRA.log.w(LOG_TAG, "Error while inspecting device configuration: ", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
ACRA.log.w(LOG_TAG, "Error while inspecting device configuration: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mValueArrays.put(PREFIX_HARDKEYBOARDHIDDEN, hardKeyboardHiddenValues);
|
||||
mValueArrays.put(PREFIX_KEYBOARD, keyboardValues);
|
||||
mValueArrays.put(PREFIX_KEYBOARDHIDDEN, keyboardHiddenValues);
|
||||
mValueArrays.put(PREFIX_NAVIGATION, navigationValues);
|
||||
mValueArrays.put(PREFIX_NAVIGATIONHIDDEN, navigationHiddenValues);
|
||||
mValueArrays.put(PREFIX_ORIENTATION, orientationValues);
|
||||
mValueArrays.put(PREFIX_SCREENLAYOUT, screenLayoutValues);
|
||||
mValueArrays.put(PREFIX_TOUCHSCREEN, touchScreenValues);
|
||||
mValueArrays.put(PREFIX_UI_MODE, uiModeValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some fields contain multiple value types which can be isolated by
|
||||
* applying a bitmask. That method returns the concatenation of active
|
||||
* values.
|
||||
*
|
||||
* @param valueNames The array containing the different values and names for this
|
||||
* field. Must contain mask values too.
|
||||
* @param bitfield The bitfield to inspect.
|
||||
* @return The names of the different values contained in the bitfield,
|
||||
* separated by '+'.
|
||||
*/
|
||||
private static String activeFlags(SparseArray<String> valueNames, int bitfield) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
// Look for masks, apply it an retrieve the masked value
|
||||
for (int i = 0; i < valueNames.size(); i++) {
|
||||
final int maskValue = valueNames.keyAt(i);
|
||||
if (valueNames.get(maskValue).endsWith(SUFFIX_MASK)) {
|
||||
final int value = bitfield & maskValue;
|
||||
if (value > 0) {
|
||||
if (result.length() > 0) {
|
||||
result.append('+');
|
||||
}
|
||||
result.append(valueNames.get(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current Configuration for this application.
|
||||
*
|
||||
* @param context Context for the application being reported.
|
||||
* @return A String representation of the current configuration for the application.
|
||||
*/
|
||||
public static String collectConfiguration(Context context) {
|
||||
try {
|
||||
final ConfigurationCollector collector = new ConfigurationCollector();
|
||||
final Configuration crashConf = context.getResources().getConfiguration();
|
||||
return collector.toString(crashConf);
|
||||
} catch (RuntimeException e) {
|
||||
ACRA.log.w(LOG_TAG, "Couldn't retrieve CrashConfiguration for : " + context.getPackageName(), e);
|
||||
return "Couldn't retrieve crash config";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to generate a human readable String listing all values
|
||||
* from the provided Configuration instance.
|
||||
*
|
||||
* @param conf The Configuration to be described.
|
||||
* @return A String describing all the fields of the given Configuration,
|
||||
* with values replaced by constant names.
|
||||
*/
|
||||
private String toString(Configuration conf) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
for (final Field f : conf.getClass().getFields()) {
|
||||
try {
|
||||
if (!Modifier.isStatic(f.getModifiers())) {
|
||||
final String fieldName = f.getName();
|
||||
result.append(fieldName).append('=');
|
||||
if (f.getType().equals(int.class)) {
|
||||
result.append(getFieldValueName(conf, f));
|
||||
} else if (f.get(conf) != null) {
|
||||
result.append(f.get(conf).toString());
|
||||
}
|
||||
result.append('\n');
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
ACRA.log.e(LOG_TAG, "Error while inspecting device configuration: ", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
ACRA.log.e(LOG_TAG, "Error while inspecting device configuration: ", e);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the name of the constant defined in the {@link Configuration}
|
||||
* class which defines the value of a field in a {@link Configuration}
|
||||
* instance.
|
||||
*
|
||||
* @param conf The instance of {@link Configuration} where the value is
|
||||
* stored.
|
||||
* @param f The {@link Field} to be inspected in the {@link Configuration}
|
||||
* instance.
|
||||
* @return The value of the field f in instance conf translated to its
|
||||
* constant name.
|
||||
* @throws IllegalAccessException if the supplied field is inaccessible.
|
||||
*/
|
||||
private String getFieldValueName(Configuration conf, Field f) throws IllegalAccessException {
|
||||
final String fieldName = f.getName();
|
||||
if (fieldName.equals(FIELD_MCC) || fieldName.equals(FIELD_MNC)) {
|
||||
return Integer.toString(f.getInt(conf));
|
||||
} else if (fieldName.equals(FIELD_UIMODE)) {
|
||||
return activeFlags(mValueArrays.get(PREFIX_UI_MODE), f.getInt(conf));
|
||||
} else if (fieldName.equals(FIELD_SCREENLAYOUT)) {
|
||||
return activeFlags(mValueArrays.get(PREFIX_SCREENLAYOUT), f.getInt(conf));
|
||||
} else {
|
||||
final SparseArray<String> values = mValueArrays.get(fieldName.toUpperCase() + '_');
|
||||
if (values == null) {
|
||||
// Unknown field, return the raw int as String
|
||||
return Integer.toString(f.getInt(conf));
|
||||
}
|
||||
|
||||
final String value = values.get(f.getInt(conf));
|
||||
if (value == null) {
|
||||
// Unknown value, return the raw int as String
|
||||
return Integer.toString(f.getInt(conf));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,151 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bgColor" >
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="7dp"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
app:cardBackgroundColor="@color/fontColorWhite">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lblSearchBy"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/gradient_end"
|
||||
android:textStyle="bold"
|
||||
android:padding="5dp"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/byDate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.8"
|
||||
android:text="@string/lblStartDate"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_gravity="center_vertical" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.3">
|
||||
<EditText
|
||||
android:id="@+id/txtStartDate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@+id/btnStartDate"
|
||||
android:layout_marginRight="10dp"
|
||||
android:padding="5dp"
|
||||
android:background="@drawable/dropdown_background"
|
||||
android:editable="false"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_centerVertical="true"/>
|
||||
<ImageButton
|
||||
android:id="@+id/btnStartDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="@drawable/transparent_bg"
|
||||
android:src="@drawable/icon_calendar"
|
||||
android:elevation="5dp"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.8"
|
||||
android:text="@string/lblEndDate"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_gravity="center_vertical" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.3">
|
||||
<EditText
|
||||
android:id="@+id/txtEndDate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@+id/btnEndDate"
|
||||
android:layout_marginRight="10dp"
|
||||
android:padding="5dp"
|
||||
android:background="@drawable/dropdown_background"
|
||||
android:editable="false"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_centerVertical="true"/>
|
||||
<ImageButton
|
||||
android:id="@+id/btnEndDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@drawable/transparent_bg"
|
||||
android:src="@drawable/icon_calendar"
|
||||
android:elevation="5dp"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSearchOrder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:text="@string/btnOk"
|
||||
android:textColor="@color/fontColorWhite"
|
||||
android:gravity="center_vertical|center_horizontal"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</ScrollView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/resultLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:contentPadding="7dp"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
app:cardBackgroundColor="@color/fontColorWhite"
|
||||
android:visibility="gone">
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/resultListView"
|
||||
android:visibility="visible"
|
||||
android:padding="5dp">
|
||||
</ListView>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,107 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.dao.TaskHSequence;
|
||||
import com.adins.mss.dao.TaskHSequenceDao;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
/**
|
||||
* Created by ACER 471 on 3/15/2017.
|
||||
*/
|
||||
|
||||
public class TaskHSequenceDataAccess {
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Training dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static TaskHSequenceDao getTaskHSequenceDao(Context context) {
|
||||
return getDaoSession(context).getTaskHSequenceDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add training as entity
|
||||
*
|
||||
* @param context
|
||||
* @param taskHSequence
|
||||
* @return
|
||||
*/
|
||||
public static void addOrReplace(Context context, TaskHSequence taskHSequence) {
|
||||
getTaskHSequenceDao(context).insertOrReplaceInTx(taskHSequence);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static List<TaskHSequence> getAllOrderAsc(Context context) {
|
||||
QueryBuilder<TaskHSequence> qb = getTaskHSequenceDao(context).queryBuilder();
|
||||
qb.orderAsc(TaskHSequenceDao.Properties.Sequence);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static TaskHSequence getTaskHSeqByUUIDTaskH(Context context, String uuidTaskH) {
|
||||
QueryBuilder<TaskHSequence> qb = getTaskHSequenceDao(context).queryBuilder();
|
||||
qb.where(TaskHSequenceDao.Properties.Uuid_task_h.eq(uuidTaskH));
|
||||
qb.build();
|
||||
if (qb.list().size() > 0) {
|
||||
return qb.list().get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static TaskHSequence getLastSequence(Context context) {
|
||||
QueryBuilder<TaskHSequence> qb = getTaskHSequenceDao(context).queryBuilder();
|
||||
// qb.where(TaskHSequenceDao.Properties.Sequence.eq(uuidUser));
|
||||
qb.orderAsc(TaskHSequenceDao.Properties.Sequence);
|
||||
qb.build();
|
||||
if (qb.list() != null) {
|
||||
if (qb.list().size() > 0) return qb.list().get(0);
|
||||
else return null;
|
||||
} else return null;
|
||||
}
|
||||
|
||||
public static TaskHSequence getUuidTaskHSequence(Context context, String uuid_task_h) { //still error
|
||||
QueryBuilder<TaskHSequence> qb = getTaskHSequenceDao(context).queryBuilder();
|
||||
qb.where(TaskHSequenceDao.Properties.Uuid_task_h.eq(uuid_task_h));
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list() != null) {
|
||||
return qb.list().get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void clean(Context context) {
|
||||
getTaskHSequenceDao(context).deleteAll();
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void insertAllNewTaskHSeq(Context context, List<TaskH> taskH) {
|
||||
for (int i = 0; i < taskH.size(); i++) {
|
||||
TaskHSequence taskHSequence = new TaskHSequence();
|
||||
taskHSequence.setSequence(i);
|
||||
taskHSequence.setUuid_task_h(taskH.get(i).getUuid_task_h());
|
||||
TaskHSequenceDataAccess.addOrReplace(context, taskHSequence);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Add table
Add a link
Reference in a new issue