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,284 @@
|
|||
package com.adins.mss.base.tasklog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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.commons.TaskListener;
|
||||
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.todolist.form.OnTaskListClickListener;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.dummy.userhelp_dummy.Adapter.NewTaskLogDummyAdapter;
|
||||
import com.adins.mss.dummy.userhelp_dummy.UserHelpGeneralDummy;
|
||||
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LogResultActivity extends Fragment implements OnTaskListClickListener {
|
||||
public static TaskH selectedLog;
|
||||
private static Menu mainMenu;
|
||||
private List<TaskH> objects;
|
||||
private NewTaskLogAdapter adapter;
|
||||
|
||||
private RelativeLayout layoutView;
|
||||
private RecyclerView recyclerView;
|
||||
private TextView dataNotFound;
|
||||
private TaskLogInterface iTaskLog;
|
||||
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private static boolean showDummy = true;
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
TaskListener myListener = new TaskListener() {
|
||||
@Override
|
||||
public void onCompleteTask(Object result) {
|
||||
adapter.setObjects((List<TaskH>) result);
|
||||
objects = adapter.getObjects();
|
||||
Global.setListOfSentTask(objects);
|
||||
|
||||
if (objects == null || objects.isEmpty()) {
|
||||
dataNotFound.setVisibility(View.VISIBLE);
|
||||
layoutView.setBackgroundResource(R.drawable.bg_notfound);
|
||||
} else {
|
||||
layoutView.setBackgroundResource(R.color.bgColor);
|
||||
dataNotFound.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
if (mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelTask(boolean value) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocalData(Object result) {
|
||||
//EMPTY
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
Utility.freeMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context activity) {
|
||||
super.onAttach(activity);
|
||||
setHasOptionsMenu(true);
|
||||
iTaskLog = new TaskLogImpl(activity);
|
||||
|
||||
try {
|
||||
objects = Global.getListOfSentTask();
|
||||
if (objects == null || objects.isEmpty()) {
|
||||
updateList();
|
||||
}
|
||||
|
||||
adapter = new NewTaskLogAdapter(activity, objects, true, LogResultActivity.this);
|
||||
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
objects = iTaskLog.getListTaskLog();
|
||||
if (adapter != null) {
|
||||
adapter.setObjects(objects);
|
||||
objects = adapter.getObjects();
|
||||
Global.setListOfSentTask(objects);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
iTaskLog.cancelOnlineLog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
screenName = FirebaseAnalytics.getInstance(getActivity());
|
||||
View view = inflater.inflate(R.layout.new_fragment_log, container, false);
|
||||
|
||||
/**
|
||||
* 2017-09-07
|
||||
* Kusnendi
|
||||
* Add title on toolbar
|
||||
*/
|
||||
getActivity().findViewById(R.id.search).setVisibility(View.GONE);
|
||||
getActivity().findViewById(R.id.spinner).setVisibility(View.GONE);
|
||||
getActivity().setTitle(getString(R.string.title_mn_log));
|
||||
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.listLog);
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.getRecycledViewPool().setMaxRecycledViews(1, 500);
|
||||
|
||||
dataNotFound = (TextView) view.findViewById(R.id.txv_data_not_found);
|
||||
if (adapter == null) {
|
||||
try {
|
||||
if (objects == null || objects.isEmpty()) {
|
||||
objects = iTaskLog.getListTaskLog();
|
||||
Global.setListOfSentTask(objects);
|
||||
}
|
||||
|
||||
adapter = new NewTaskLogAdapter(getActivity(), objects, true, LogResultActivity.this);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.ENABLE_USER_HELP &&
|
||||
showDummy &&
|
||||
Global.userHelpDummyGuide.get(LogResultActivity.this.getClass().getSimpleName()) != null &&
|
||||
!Global.userHelpDummyGuide.get(LogResultActivity.this.getClass().getSimpleName()).isEmpty()) {
|
||||
NewTaskLogDummyAdapter dummyAdapter = new NewTaskLogDummyAdapter();
|
||||
recyclerView.setAdapter(dummyAdapter);
|
||||
UserHelpGeneralDummy userHelpGeneralDummy = new UserHelpGeneralDummy();
|
||||
userHelpGeneralDummy.showDummyLog(LogResultActivity.this.getActivity(),LogResultActivity.this.getClass().getSimpleName(),recyclerView,this,adapter);
|
||||
showDummy = false;
|
||||
}else {
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refreshTimeline);
|
||||
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
iTaskLog.callOnlineLog(myListener);
|
||||
}
|
||||
});
|
||||
|
||||
layoutView = (RelativeLayout) view.findViewById(R.id.layout);
|
||||
if (objects == null || objects.isEmpty()) {
|
||||
dataNotFound.setVisibility(View.VISIBLE);
|
||||
layoutView.setBackgroundResource(R.drawable.bg_notfound);
|
||||
}
|
||||
|
||||
if (!GlobalData.getSharedGlobalData().getApplication().equals(Global.APPLICATION_COLLECTION)) {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
adapter = null;
|
||||
Global.setListOfSentTask(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(getActivity(), getString(R.string.screen_name_log), null);
|
||||
getActivity().findViewById(R.id.search).setVisibility(View.GONE);
|
||||
getActivity().findViewById(R.id.spinner).setVisibility(View.GONE);
|
||||
getActivity().setTitle(R.string.title_mn_log);
|
||||
try {
|
||||
updateList();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == R.id.mnGuide && !Global.BACKPRESS_RESTRICTION){
|
||||
NewTaskLogDummyAdapter dummyAdapter = new NewTaskLogDummyAdapter();
|
||||
recyclerView.setAdapter(dummyAdapter);
|
||||
UserHelpGeneralDummy userHelpGeneralDummy = new UserHelpGeneralDummy();
|
||||
userHelpGeneralDummy.showDummyLog(LogResultActivity.this.getActivity(), LogResultActivity.this.getClass().getSimpleName(), recyclerView, this, adapter);
|
||||
showDummy = false;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClickListener(TaskH item, int position) {
|
||||
if (Boolean.FALSE.equals(GlobalData.getSharedGlobalData().getDoingTask())) {
|
||||
selectedLog = item;
|
||||
try {
|
||||
Scheme scheme = null;
|
||||
scheme = selectedLog.getScheme();
|
||||
if (scheme == null && selectedLog.getUuid_scheme() != null) {
|
||||
scheme = SchemeDataAccess.getOne(getActivity(), selectedLog.getUuid_scheme());
|
||||
if (scheme != null)
|
||||
selectedLog.setScheme(scheme);
|
||||
}
|
||||
|
||||
if (scheme == null) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.task_cant_seen),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
SurveyHeaderBean header = new SurveyHeaderBean(selectedLog);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(CustomerFragment.SURVEY_HEADER, header);
|
||||
bundle.putInt(CustomerFragment.SURVEY_MODE, Global.MODE_VIEW_SENT_SURVEY);
|
||||
Fragment fragment = com.adins.mss.base.dynamicform.CustomerFragment.create(header);
|
||||
|
||||
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();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.scheme_not_found_sync),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemLongClickListener(TaskH item, int position) {
|
||||
//EMPTY
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<!--
|
||||
As the main content view, the view below consumes the entire
|
||||
space available using match_parent in both dimensions.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!--
|
||||
android:layout_gravity="start" tells DrawerLayout to treat
|
||||
this as a sliding drawer on the left side for left-to-right
|
||||
languages and on the right side for right-to-left languages.
|
||||
The drawer is given a fixed width in dp and extends the full height of
|
||||
the container. A solid background is used for contrast
|
||||
with the content view.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="260dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:paddingTop="?android:attr/actionBarSize"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1" >
|
||||
|
||||
<!-- <include
|
||||
android:id="@+id/include1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="150dp"
|
||||
layout="@layout/header_profile" /> -->
|
||||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="260dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:background="#dfdfdf"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="#000000"
|
||||
android:dividerHeight="1px" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- <ListView -->
|
||||
<!-- android:id="@+id/right_drawer" -->
|
||||
<!-- android:paddingTop="?android:attr/actionBarSize" -->
|
||||
<!-- android:layout_width="240dp" -->
|
||||
<!-- android:layout_height="match_parent" -->
|
||||
<!-- android:layout_gravity="end" -->
|
||||
<!-- android:choiceMode="singleChoice" -->
|
||||
<!-- android:divider="@android:color/transparent" -->
|
||||
<!-- android:dividerHeight="0dp" -->
|
||||
<!-- android:background="#111"/> -->
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/layouttemp" >
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/horizontalScrollView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
android:accessibilityLiveRegion="assertive">
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight=".5">
|
||||
<DatePicker
|
||||
android:id="@+id/gDatePicker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false"
|
||||
android:scaleX=".8"
|
||||
android:scaleY=".8"
|
||||
android:spinnersShown="true"
|
||||
android:translationX="-25dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".5"
|
||||
android:translationX="-40dp">
|
||||
|
||||
<TimePicker
|
||||
android:id="@+id/gTimePicker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX=".8"
|
||||
android:scaleY=".8"
|
||||
android:translationX="-30dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCancel2"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btnCancel"
|
||||
android:textColor="#FFFFFF"
|
||||
android:background="@drawable/button_background" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnOK"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:background="@drawable/button_background"
|
||||
android:text="@string/btnOk"
|
||||
android:textColor="#FFFFFF" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_grayscale"
|
||||
android:orientation="vertical" >
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
android:padding="5dp">
|
||||
<LinearLayout
|
||||
android:padding="5dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@color/gradient_start"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<ToggleButton
|
||||
android:id="@+id/btnVoiceNotes"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:drawableTop="@drawable/ic_record"
|
||||
android:textOn="Tap to Stop"
|
||||
android:textOff="Tap to Record"
|
||||
android:textColor="@color/tv_white"
|
||||
android:background="@android:color/transparent" />
|
||||
<TextView
|
||||
android:id="@+id/txtNoVoiceNote"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="7dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:shadowColor="@color/tv_darker"
|
||||
android:maxLength="500"
|
||||
android:text="@string/voice_notes_not_available"
|
||||
android:textColor="@color/tv_white"
|
||||
android:visibility="gone">
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout android:id="@+id/recorderLayout"
|
||||
android:padding="5dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@color/gradient_end"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnPlay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_play"
|
||||
android:background="@drawable/circle_button"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnStop"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_stop"
|
||||
android:background="@drawable/circle_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSave"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btnSave" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,57 @@
|
|||
package com.adins.mss.svy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.config.ConfigFileReader;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.acra.ACRA.PREF_DISABLE_ACRA;
|
||||
import static org.acra.ACRA.PREF_ENABLE_ACRA;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class DisableAcraTest {
|
||||
|
||||
Context context;
|
||||
|
||||
@Before
|
||||
public void setUpContext(){
|
||||
context = InstrumentationRegistry.getTargetContext().getApplicationContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisableAcra(){
|
||||
//used for acra log
|
||||
User a = null;
|
||||
try {
|
||||
String id = a.getBranch_id();
|
||||
}
|
||||
catch (NullPointerException e){
|
||||
ACRA.getErrorReporter().putCustomData("User Null Exception",e.getMessage());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Null Pointer User"));
|
||||
}
|
||||
|
||||
//this code is taken from ACRA code to check acra disable
|
||||
//check disable from acra preference
|
||||
SharedPreferences acraPref = ACRA.getACRASharedPreferences();
|
||||
final boolean enableAcra = acraPref.getBoolean(PREF_ENABLE_ACRA, true);
|
||||
boolean disableAcra = acraPref.getBoolean(PREF_DISABLE_ACRA, !enableAcra);
|
||||
|
||||
//test if pref disable acra is true
|
||||
Assert.assertTrue(disableAcra);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.dao.UserDao;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
public class UserDataAccess {
|
||||
|
||||
private UserDataAccess() {
|
||||
}
|
||||
|
||||
/**
|
||||
* use to generate dao session that you can access modelDao
|
||||
*
|
||||
* @param context --> context from activity
|
||||
* @return
|
||||
*/
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get user dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static UserDao getUserDao(Context context) {
|
||||
return getDaoSession(context).getUserDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add user as entity
|
||||
*
|
||||
* @param context
|
||||
* @param user
|
||||
*/
|
||||
public static void add(Context context, User user) {
|
||||
getUserDao(context).insertInTx(user);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add user as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param userList
|
||||
*/
|
||||
public static void add(Context context, List<User> userList) {
|
||||
getUserDao(context).insertInTx(userList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void addOrReplace(Context context, User user) {
|
||||
getUserDao(context).insertOrReplaceInTx(user);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void addOrReplace(Context context, List<User> userList) {
|
||||
getUserDao(context).insertOrReplaceInTx(userList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all content in table.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void clean(Context context) {
|
||||
getUserDao(context).deleteAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param user
|
||||
*/
|
||||
public static void delete(Context context, User user) {
|
||||
getUserDao(context).delete(user);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by user
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
*/
|
||||
public static void delete(Context context, String uuidUser) {
|
||||
QueryBuilder<User> qb = getUserDao(context).queryBuilder();
|
||||
qb.where(UserDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.build().forCurrentThread();
|
||||
getUserDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param user
|
||||
*/
|
||||
public static void update(Context context, User user) {
|
||||
getUserDao(context).update(user);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_user = param
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
* @return
|
||||
*/
|
||||
public static List<User> getAll(Context context, String uuidUser) {
|
||||
QueryBuilder<User> qb = getUserDao(context).queryBuilder();
|
||||
qb.where(UserDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list() == null) return new ArrayList<>();
|
||||
else return qb.list();
|
||||
}
|
||||
|
||||
public static List<User> getAll(Context context) {
|
||||
QueryBuilder<User> qb = getUserDao(context).queryBuilder();
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list() == null) return new ArrayList<>();
|
||||
else return qb.list();
|
||||
}
|
||||
|
||||
public static List<User> getAllUserActive(Context context){
|
||||
QueryBuilder<User> qb = getUserDao(context).queryBuilder();
|
||||
|
||||
// if (GlobalData.getSharedGlobalData().getUser() != null && GlobalData.getSharedGlobalData().getUser()
|
||||
// .getUuid_user() != null) {
|
||||
// qb.whereOr(UserDao.Properties.Facebook_id.eq("1"), UserDao.Properties.Uuid_user.eq(GlobalData.getSharedGlobalData().getUser()
|
||||
// .getUuid_user()));
|
||||
// }else{
|
||||
qb.where(UserDao.Properties.Facebook_id.eq("1"));
|
||||
// }
|
||||
|
||||
qb.build().forCurrentThread();
|
||||
List<User> userListName = qb.list();
|
||||
if(qb.list() == null) return null;
|
||||
else return qb.list();
|
||||
}
|
||||
|
||||
public static User getOne(Context context, String uuidUser) {
|
||||
QueryBuilder<User> qb = getUserDao(context).queryBuilder();
|
||||
qb.where(UserDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list() != null) {
|
||||
if (!qb.list().isEmpty()) return qb.list().get(0);
|
||||
else return null;
|
||||
} else return null;
|
||||
}
|
||||
|
||||
public static User getOne(Context context) {
|
||||
QueryBuilder<User> qb = getUserDao(context).queryBuilder();
|
||||
qb.build().forCurrentThread();
|
||||
if (qb.list() != null) {
|
||||
if (!qb.list().isEmpty()) return qb.list().get(0);
|
||||
else return null;
|
||||
} else return null;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 269 KiB |
|
@ -0,0 +1,77 @@
|
|||
package com.adins.mss.odr.news;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.dao.MobileContentD;
|
||||
import com.adins.mss.dao.MobileContentH;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.odr.R;
|
||||
import com.androidquery.AQuery;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class NewsContentActivity extends Activity{
|
||||
MobileContentH objects;
|
||||
List<MobileContentD> objectDetail = null;
|
||||
News news;
|
||||
String uuidH;
|
||||
ViewPager viewPager;
|
||||
AQuery query;
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.mobile_content_layout);
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
uuidH =bundle.getString("uuid_taskH");
|
||||
|
||||
viewPager = (ViewPager) findViewById(R.id.newsImage);
|
||||
news= new News(this);
|
||||
|
||||
objects = news.getContent(uuidH);
|
||||
// news.getNewsContentFromServer(objects);
|
||||
|
||||
query = new AQuery(this);
|
||||
query.id(R.id.newsDesc).text(objects.getContent_description());
|
||||
objectDetail = news.getlistContentOnDate(uuidH);
|
||||
|
||||
List<MobileContentD> allObjectDetail = news.getlistContentWithoutDate(uuidH);
|
||||
|
||||
NewsContentAdapter adapter = new NewsContentAdapter(this, objectDetail);
|
||||
viewPager.setAdapter(adapter);
|
||||
if(objectDetail==null || objectDetail.size()==0)
|
||||
if(allObjectDetail!=null&&allObjectDetail.size()>0){
|
||||
NiftyDialogBuilder dialogBuilder;
|
||||
dialogBuilder = NiftyDialogBuilder.getInstance(this);
|
||||
dialogBuilder.withTitle("INFO").
|
||||
withIcon(android.R.drawable.ic_dialog_info).
|
||||
withMessage(getString(R.string.data_expired)).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
Context context = newBase;
|
||||
Locale locale;
|
||||
try {
|
||||
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
|
||||
if (null == locale) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
}
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} catch (Exception e) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} finally {
|
||||
super.attachBaseContext(context);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -0,0 +1,23 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Created by noerhayati.dm on 8/2/2018.
|
||||
*/
|
||||
|
||||
public class JsonResponseValidationQuestion extends MssResponseType {
|
||||
|
||||
@SerializedName("otp")
|
||||
private String otp;
|
||||
|
||||
public String getOtp() {
|
||||
return otp;
|
||||
}
|
||||
|
||||
public void setOtp(String otp) {
|
||||
this.otp = otp;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.soundcloud.android.crop;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
/*
|
||||
* Modified from original in AOSP.
|
||||
*/
|
||||
abstract class MonitoredActivity extends Activity {
|
||||
|
||||
private final ArrayList<LifeCycleListener> listeners = new ArrayList<LifeCycleListener>();
|
||||
|
||||
public void addLifeCycleListener(LifeCycleListener listener) {
|
||||
if (listeners.contains(listener)) return;
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeLifeCycleListener(LifeCycleListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
for (LifeCycleListener listener : listeners) {
|
||||
listener.onActivityCreated(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
for (LifeCycleListener listener : listeners) {
|
||||
listener.onActivityDestroyed(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
for (LifeCycleListener listener : listeners) {
|
||||
listener.onActivityStarted(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
for (LifeCycleListener listener : listeners) {
|
||||
listener.onActivityStopped(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
Context context = newBase;
|
||||
Locale locale;
|
||||
try{
|
||||
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} catch (Exception e) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} finally {
|
||||
super.attachBaseContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static interface LifeCycleListener {
|
||||
public void onActivityCreated(MonitoredActivity activity);
|
||||
|
||||
public void onActivityDestroyed(MonitoredActivity activity);
|
||||
|
||||
public void onActivityStarted(MonitoredActivity activity);
|
||||
|
||||
public void onActivityStopped(MonitoredActivity activity);
|
||||
}
|
||||
|
||||
public static class LifeCycleAdapter implements LifeCycleListener {
|
||||
public void onActivityCreated(MonitoredActivity activity) {
|
||||
}
|
||||
|
||||
public void onActivityDestroyed(MonitoredActivity activity) {
|
||||
}
|
||||
|
||||
public void onActivityStarted(MonitoredActivity activity) {
|
||||
}
|
||||
|
||||
public void onActivityStopped(MonitoredActivity activity) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
Add table
Add a link
Reference in a new issue