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,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="define_AdInsLibrariesv2">year;owner</string>
|
||||
<string name="library_AdInsLibrariesv2_author">AdIns</string>
|
||||
<string name="library_AdInsLibrariesv2_authorWebsite">http://gegemobile.com/</string>
|
||||
<string name="library_AdInsLibrariesv2_libraryName">MSS v2</string>
|
||||
<string name="library_AdInsLibrariesv2_libraryDescription">
|
||||
AdInsLibraries is a library to offer you all the information you need of your libraries!
|
||||
Most modern apps feature an "Used Library"-Section and for this some information of those libs is required.
|
||||
As it gets annoying to copy those strings always to your app I have developed this small helper library to
|
||||
provide the required information.
|
||||
</string>
|
||||
<string name="library_AdInsLibrariesv2_libraryVersion">2.1.0</string>
|
||||
<string name="library_AdInsLibrariesv2_libraryWebsite">https://github.com/mikepenz/AdInsLibraries</string>
|
||||
<string name="library_AdInsLibrariesv2_licenseId">mit</string>
|
||||
<string name="library_AdInsLibrariesv2_isOpenSource">true</string>
|
||||
<string name="library_AdInsLibrariesv2_repositoryLink">https://github.com/mikepenz/AdInsLibraries</string>
|
||||
<!-- Custom variables section -->
|
||||
<string name="library_AdInsLibrariesv2_owner">AdIns</string>
|
||||
<string name="library_AdInsLibrariesv2_year">2014</string>
|
||||
</resources>
|
|
@ -0,0 +1,40 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/mainLayout"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
<View
|
||||
android:id="@+id/actionbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/actionbar_background" />
|
||||
|
||||
<!-- <uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout -->
|
||||
<!-- android:id="@+id/ptr_layout" -->
|
||||
<!-- android:layout_width="match_parent" -->
|
||||
<!-- android:layout_height="match_parent" -->
|
||||
<!-- android:layout_below="@+id/actionbar" -->
|
||||
<!-- android:padding="4dp" > -->
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/swiperefresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/actionbar"
|
||||
android:padding="4dp">
|
||||
<GridView
|
||||
android:id="@+id/gridStatus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:numColumns="3"
|
||||
android:horizontalSpacing="4dp"
|
||||
android:verticalSpacing="4dp">
|
||||
|
||||
</GridView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<!-- </uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout> -->
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,301 @@
|
|||
package com.adins.mss.coll.fragments.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.dynamicform.DynamicFormActivity;
|
||||
import com.adins.mss.base.dynamicform.form.questions.ImageViewerActivity;
|
||||
import com.adins.mss.base.dynamicform.form.questions.viewholder.ImageQuestionViewHolder;
|
||||
import com.adins.mss.base.timeline.Constants;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.commons.Toaster;
|
||||
import com.adins.mss.coll.commons.ViewManager;
|
||||
import com.adins.mss.coll.interfaces.DepositReportImpl;
|
||||
import com.adins.mss.coll.interfaces.DepositReportInterface;
|
||||
import com.adins.mss.coll.interfaces.OnCameraInAppListener;
|
||||
import com.adins.mss.coll.interfaces.callback.DepositReportCallback;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.DepositReportD;
|
||||
import com.adins.mss.dao.DepositReportH;
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.foundation.camerainapp.CameraActivity;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.image.Utils;
|
||||
import com.soundcloud.android.crop.Crop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by kusnendi.muhamad on 31/07/2017.
|
||||
*/
|
||||
|
||||
public class DepositReportTransferView extends ViewManager {
|
||||
private FragmentActivity activity;
|
||||
private DepositReportInterface iDepositReport;
|
||||
private AppCompatSpinner transferBySpinner;
|
||||
private View asBank;
|
||||
private View asCashier;
|
||||
private EditText editNomorRekening;
|
||||
private EditText editNamaBank;
|
||||
private EditText editBatchId;
|
||||
private EditText editNamaKasir;
|
||||
private ImageView imageBukti;
|
||||
private Button buttonSelectPhoto;
|
||||
private Button buttonSend;
|
||||
public Bundle savedInstanceState;
|
||||
private View view;
|
||||
protected static byte[] byteImage = null;
|
||||
public String total = "";
|
||||
public String batchId;
|
||||
protected static Bitmap image = null;
|
||||
protected static Bitmap tempImage = null;
|
||||
private OnCameraInAppListener onCameraInAppListener;
|
||||
private DepositReportImpl.SendDepositReportTask sendDepositReportTask;
|
||||
|
||||
public void setBatchId(String batchId) {
|
||||
this.batchId = batchId;
|
||||
}
|
||||
|
||||
public DepositReportTransferView(FragmentActivity activity, OnCameraInAppListener requestActivityResult) {
|
||||
super(activity);
|
||||
this.activity = activity;
|
||||
this.onCameraInAppListener = requestActivityResult;
|
||||
iDepositReport= new DepositReportImpl(activity);
|
||||
}
|
||||
|
||||
public View layoutInflater(LayoutInflater inflater, ViewGroup container) {
|
||||
view = inflater.inflate(R.layout.new_fragment_deposit_report_transfer, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
if(view!=null) {
|
||||
asBank = view.findViewById(R.id.transferAsBank);
|
||||
asCashier = view.findViewById(R.id.transferAsCashier);
|
||||
transferBySpinner = (AppCompatSpinner) view.findViewById(R.id.transferBySpinner);
|
||||
transferBySpinner.setAdapter(new ArrayAdapter<String>(activity, R.layout.spinner_style2, R.id.text_spin, activity.getResources().getStringArray(R.array.transfer_spinner)));
|
||||
|
||||
editNomorRekening = (EditText) view.findViewById(R.id.txtAccountNo);
|
||||
editBatchId = (EditText) view.findViewById(R.id.txtBatchId);
|
||||
editNamaBank = (EditText) view.findViewById(R.id.txtBankName);
|
||||
editNamaKasir = (EditText) view.findViewById(R.id.txtCashierName);
|
||||
imageBukti = (ImageView) view.findViewById(R.id.imgBukti);
|
||||
buttonSelectPhoto = (Button) view.findViewById(R.id.btnTakePhoto);
|
||||
buttonSend = (Button) view.findViewById(R.id.btnSend);
|
||||
|
||||
editBatchId.setText(batchId);
|
||||
|
||||
imageBukti.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View paramView) {
|
||||
if(imageBukti.getDrawable()!=null && image!=null){
|
||||
if(byteImage==null) byteImage = Utils.bitmapToByte(tempImage);
|
||||
imageBukti.setDrawingCacheEnabled(true);
|
||||
imageBukti.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
|
||||
imageBukti.buildDrawingCache();
|
||||
image = Bitmap.createBitmap(imageBukti.getDrawingCache(true));
|
||||
Global.getSharedGlobal().setIsViewer(true);
|
||||
|
||||
Global.getSharedGlobal().setIsViewer(true);
|
||||
Bundle extras = new Bundle();
|
||||
extras.putByteArray(ImageViewerActivity.BUND_KEY_IMAGE, byteImage);
|
||||
extras.putInt(ImageViewerActivity.BUND_KEY_IMAGE_QUALITY, Utils.picQuality);
|
||||
extras.putBoolean(ImageViewerActivity.BUND_KEY_IMAGE_ISVIEWER, Global.getSharedGlobal().getIsViewer());
|
||||
|
||||
Intent intent = new Intent(activity, ImageViewerActivity.class);
|
||||
intent.putExtras(extras);
|
||||
imageBukti.setDrawingCacheEnabled(false);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttonSelectPhoto.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Constants.flag_edit=2;
|
||||
openCameraApp(activity);
|
||||
}
|
||||
});
|
||||
|
||||
buttonSend.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
buttonSend.setClickable(false);
|
||||
buttonSelectPhoto.setClickable(false);
|
||||
buttonSend.setEnabled(false);
|
||||
|
||||
if (!GlobalData.getSharedGlobalData().getButtonClicked()) {
|
||||
if(null != editNamaKasir) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE) ;
|
||||
imm.hideSoftInputFromWindow(editNamaKasir.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
if(Tool.isInternetconnected(activity)) {
|
||||
sendDepositReportTask = iDepositReport.sendDepositReport(activity);
|
||||
sendDepositReportTask.image = image;
|
||||
sendDepositReportTask.tempImage = tempImage;
|
||||
sendDepositReportTask.total = total;
|
||||
sendDepositReportTask.listener = MyCallback;
|
||||
sendDepositReportTask.execute(editBatchId.getText().toString(),
|
||||
editNomorRekening.getText().toString().trim(),
|
||||
editNamaBank.getText().toString().trim(),
|
||||
editNamaKasir.getText().toString().trim(),
|
||||
String.valueOf(asBank.getVisibility()));
|
||||
|
||||
}else{
|
||||
Toaster.warning(activity, activity.getString(R.string.failed_send_data));
|
||||
buttonSend.setClickable(true);
|
||||
buttonSelectPhoto.setClickable(true);
|
||||
buttonSend.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
transferBySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position == 0) {
|
||||
asBank.setVisibility(View.VISIBLE);
|
||||
asCashier.setVisibility(View.GONE);
|
||||
} else {
|
||||
asBank.setVisibility(View.GONE);
|
||||
asCashier.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
asBank.setVisibility(View.GONE);
|
||||
asCashier.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
editBatchId.setText(batchId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DepositReportCallback MyCallback = new DepositReportCallback() {
|
||||
@Override
|
||||
public void OnFillHeader(int totalTask, int paidTask, int failTask, int visitTask) {}
|
||||
|
||||
@Override
|
||||
public void OnFillDetail(HashMap<DepositReportH, List<DepositReportD>> packedListOfBatch) {}
|
||||
|
||||
@Override
|
||||
public void OnLoadReconcileData(List<TaskD> reconcileReport, int totalNeedPrint) {}
|
||||
|
||||
@Override
|
||||
public void OnError(boolean value) {
|
||||
buttonSend.setClickable(true);
|
||||
buttonSelectPhoto.setClickable(true);
|
||||
buttonSend.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnFinish(boolean value) {
|
||||
try {
|
||||
imageBukti.setDrawingCacheEnabled(false);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
private void openCameraApp(FragmentActivity mActivity) {
|
||||
if (GlobalData.getSharedGlobalData().isUseOwnCamera()) {
|
||||
int quality = Utils.picQuality;
|
||||
int thumbHeight = Utils.picHeight;
|
||||
int thumbWidht = Utils.picWidth;
|
||||
|
||||
Intent intent = new Intent(mActivity, CameraActivity.class);
|
||||
intent.putExtra(CameraActivity.PICTURE_WIDTH, thumbWidht);
|
||||
intent.putExtra(CameraActivity.PICTURE_HEIGHT, thumbHeight);
|
||||
intent.putExtra(CameraActivity.PICTURE_QUALITY, quality);
|
||||
|
||||
onCameraInAppListener.onImageCapture(intent, Utils.REQUEST_IN_APP_CAMERA);
|
||||
}
|
||||
else{
|
||||
try {
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
if(intent.resolveActivity(mActivity.getPackageManager())!=null){
|
||||
File photoFile = null;
|
||||
try {
|
||||
photoFile = ImageQuestionViewHolder.createImageFile(activity.getApplicationContext());
|
||||
} catch (IOException ex) {
|
||||
FireCrash.log(ex);
|
||||
}
|
||||
if (photoFile != null) {
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT,
|
||||
Uri.fromFile(photoFile));
|
||||
activity.startActivityForResult(intent, Utils.REQUEST_CAMERA);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) { FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == Utils.REQUEST_IN_APP_CAMERA && resultCode == Activity.RESULT_OK) {
|
||||
Bundle bundle = data.getExtras();
|
||||
if (bundle != null) {
|
||||
Uri uri = Uri.parse(bundle.getString(CameraActivity.PICTURE_URI));
|
||||
File file = new File(uri.getPath());
|
||||
image = Utils.pathToBitmapWithRotation(file);
|
||||
tempImage = Utils.pathToBitmapWithRotation(file);
|
||||
byteImage = Utils.pathBitmapToByteWithRotation(file);
|
||||
imageBukti.setImageBitmap(image);
|
||||
}
|
||||
} else if (requestCode == Utils.REQUEST_CAMERA && resultCode == Activity.RESULT_OK) {
|
||||
Uri uri = Uri.parse(DynamicFormActivity.getmCurrentPhotoPath());
|
||||
File file = new File(uri.getPath());
|
||||
image = Utils.pathToBitmapWithRotation(file);
|
||||
byteImage = Utils.pathBitmapToByteWithRotation(file);
|
||||
tempImage = Utils.pathToBitmapWithRotation(file);
|
||||
imageBukti.setImageBitmap(image);
|
||||
} else if (requestCode == Crop.REQUEST_PICK && resultCode == Activity.RESULT_OK) {
|
||||
Uri outputUri = data.getData();
|
||||
try {
|
||||
image = BitmapFactory.decodeStream(activity.getContentResolver().openInputStream(outputUri));
|
||||
tempImage = BitmapFactory.decodeStream(activity.getContentResolver().openInputStream(outputUri));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
imageBukti.setImageBitmap(image);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,361 @@
|
|||
/*
|
||||
* Copyright (C) 2013 Manuel Peinado
|
||||
*
|
||||
* 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.manuelpeinado.fadingactionbar;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.manuelpeinado.fadingactionbar.view.ObservableScrollView;
|
||||
import com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader;
|
||||
import com.manuelpeinado.fadingactionbar.view.OnScrollChangedCallback;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class FadingActionBarHelperBase {
|
||||
protected static final String TAG = "FadingActionBarHelper";
|
||||
private Drawable mActionBarBackgroundDrawable;
|
||||
private FrameLayout mHeaderContainer;
|
||||
private int mActionBarBackgroundResId;
|
||||
private int mHeaderLayoutResId;
|
||||
private View mHeaderView;
|
||||
private int mHeaderOverlayLayoutResId;
|
||||
private View mHeaderOverlayView;
|
||||
private int mContentLayoutResId;
|
||||
private View mContentView;
|
||||
private LayoutInflater mInflater;
|
||||
private boolean mLightActionBar;
|
||||
private boolean mUseParallax = true;
|
||||
private int mLastDampedScroll;
|
||||
private int mLastHeaderHeight = -1;
|
||||
private boolean mFirstGlobalLayoutPerformed;
|
||||
private FrameLayout mMarginView;
|
||||
private View mListViewBackgroundView;
|
||||
private Drawable.Callback mDrawableCallback = new Drawable.Callback() {
|
||||
@Override
|
||||
public void invalidateDrawable(Drawable who) {
|
||||
setActionBarBackgroundDrawable(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleDrawable(Drawable who, Runnable what, long when) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unscheduleDrawable(Drawable who, Runnable what) {
|
||||
}
|
||||
};
|
||||
private int mLastScrollPosition;
|
||||
private OnScrollChangedCallback mOnScrollChangedListener = new OnScrollChangedCallback() {
|
||||
public void onScroll(int l, int t) {
|
||||
onNewScroll(t);
|
||||
}
|
||||
};
|
||||
private OnScrollListener mOnScrollListener = new OnScrollListener() {
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
View topChild = view.getChildAt(0);
|
||||
if (topChild == null) {
|
||||
onNewScroll(0);
|
||||
} else if (topChild != mMarginView) {
|
||||
onNewScroll(mHeaderContainer.getHeight());
|
||||
} else {
|
||||
onNewScroll(-topChild.getTop());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
}
|
||||
};
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T actionBarBackground(int drawableResId) {
|
||||
mActionBarBackgroundResId = drawableResId;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T actionBarBackground(Drawable drawable) {
|
||||
mActionBarBackgroundDrawable = drawable;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T headerLayout(int layoutResId) {
|
||||
mHeaderLayoutResId = layoutResId;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T headerView(View view) {
|
||||
mHeaderView = view;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T headerOverlayLayout(int layoutResId) {
|
||||
mHeaderOverlayLayoutResId = layoutResId;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T headerOverlayView(View view) {
|
||||
mHeaderOverlayView = view;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T contentLayout(int layoutResId) {
|
||||
mContentLayoutResId = layoutResId;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T contentView(View view) {
|
||||
mContentView = view;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T lightActionBar(boolean value) {
|
||||
mLightActionBar = value;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final <T extends FadingActionBarHelperBase> T parallax(boolean value) {
|
||||
mUseParallax = value;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public final View createView(Context context) {
|
||||
return createView(LayoutInflater.from(context));
|
||||
}
|
||||
|
||||
public final View createView(LayoutInflater inflater) {
|
||||
//
|
||||
// Prepare everything
|
||||
|
||||
mInflater = inflater;
|
||||
if (mContentView == null) {
|
||||
mContentView = inflater.inflate(mContentLayoutResId, null);
|
||||
}
|
||||
if (mHeaderView == null) {
|
||||
mHeaderView = inflater.inflate(mHeaderLayoutResId, null, false);
|
||||
}
|
||||
|
||||
//
|
||||
// See if we are in a ListView, WebView or ScrollView scenario
|
||||
|
||||
ListView listView = (ListView) mContentView.findViewById(android.R.id.list);
|
||||
View root;
|
||||
if (listView != null) {
|
||||
root = createListView(listView);
|
||||
} else if (mContentView instanceof ObservableWebViewWithHeader) {
|
||||
root = createWebView();
|
||||
} else {
|
||||
root = createScrollView();
|
||||
}
|
||||
|
||||
if (mHeaderOverlayView == null && mHeaderOverlayLayoutResId != 0) {
|
||||
mHeaderOverlayView = inflater.inflate(mHeaderOverlayLayoutResId, mMarginView, false);
|
||||
}
|
||||
if (mHeaderOverlayView != null) {
|
||||
mMarginView.addView(mHeaderOverlayView);
|
||||
}
|
||||
|
||||
// Use measured height here as an estimate of the header height, later on after the layout is complete
|
||||
// we'll use the actual height
|
||||
int widthMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.MATCH_PARENT, MeasureSpec.EXACTLY);
|
||||
int heightMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY);
|
||||
mHeaderView.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
updateHeaderHeight(mHeaderView.getMeasuredHeight());
|
||||
|
||||
root.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
int headerHeight = mHeaderContainer.getHeight();
|
||||
if (!mFirstGlobalLayoutPerformed && headerHeight != 0) {
|
||||
updateHeaderHeight(headerHeight);
|
||||
mFirstGlobalLayoutPerformed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public void initActionBar(Activity activity) {
|
||||
if (mActionBarBackgroundDrawable == null) {
|
||||
mActionBarBackgroundDrawable = activity.getResources().getDrawable(mActionBarBackgroundResId, activity.getTheme());
|
||||
}
|
||||
setActionBarBackgroundDrawable(mActionBarBackgroundDrawable);
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
mActionBarBackgroundDrawable.setCallback(mDrawableCallback);
|
||||
}
|
||||
mActionBarBackgroundDrawable.setAlpha(0);
|
||||
}
|
||||
|
||||
protected abstract int getActionBarHeight();
|
||||
|
||||
protected abstract boolean isActionBarNull();
|
||||
|
||||
protected abstract void setActionBarBackgroundDrawable(Drawable drawable);
|
||||
|
||||
protected <T> T getActionBarWithReflection(Activity activity, String methodName) {
|
||||
try {
|
||||
Method method = activity.getClass().getMethod(methodName);
|
||||
return (T) method.invoke(activity);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private View createWebView() {
|
||||
ViewGroup webViewContainer = (ViewGroup) mInflater.inflate(R.layout.fab__webview_container, null);
|
||||
|
||||
ObservableWebViewWithHeader webView = (ObservableWebViewWithHeader) mContentView;
|
||||
webView.setOnScrollChangedCallback(mOnScrollChangedListener);
|
||||
|
||||
webViewContainer.addView(webView);
|
||||
|
||||
mHeaderContainer = (FrameLayout) webViewContainer.findViewById(R.id.fab__header_container);
|
||||
initializeGradient(mHeaderContainer);
|
||||
mHeaderContainer.addView(mHeaderView, 0);
|
||||
|
||||
mMarginView = new FrameLayout(webView.getContext());
|
||||
mMarginView.setBackgroundColor(Color.TRANSPARENT);
|
||||
mMarginView.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
webView.addView(mMarginView);
|
||||
|
||||
return webViewContainer;
|
||||
}
|
||||
|
||||
private View createScrollView() {
|
||||
ViewGroup scrollViewContainer = (ViewGroup) mInflater.inflate(R.layout.fab__scrollview_container, null);
|
||||
|
||||
ObservableScrollView scrollView = (ObservableScrollView) scrollViewContainer.findViewById(R.id.fab__scroll_view);
|
||||
scrollView.setOnScrollChangedCallback(mOnScrollChangedListener);
|
||||
|
||||
ViewGroup contentContainer = (ViewGroup) scrollViewContainer.findViewById(R.id.fab__container);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
mContentView.setLayoutParams(layoutParams);
|
||||
contentContainer.addView(mContentView);
|
||||
mHeaderContainer = (FrameLayout) scrollViewContainer.findViewById(R.id.fab__header_container);
|
||||
initializeGradient(mHeaderContainer);
|
||||
mHeaderContainer.addView(mHeaderView, 0);
|
||||
mMarginView = (FrameLayout) contentContainer.findViewById(R.id.fab__content_top_margin);
|
||||
|
||||
return scrollViewContainer;
|
||||
}
|
||||
|
||||
private View createListView(ListView listView) {
|
||||
ViewGroup contentContainer = (ViewGroup) mInflater.inflate(R.layout.fab__listview_container, null);
|
||||
contentContainer.addView(mContentView);
|
||||
|
||||
mHeaderContainer = (FrameLayout) contentContainer.findViewById(R.id.fab__header_container);
|
||||
initializeGradient(mHeaderContainer);
|
||||
mHeaderContainer.addView(mHeaderView, 0);
|
||||
|
||||
mMarginView = new FrameLayout(listView.getContext());
|
||||
mMarginView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, 0));
|
||||
listView.addHeaderView(mMarginView, null, false);
|
||||
|
||||
// Make the background as high as the screen so that it fills regardless of the amount of scroll.
|
||||
mListViewBackgroundView = contentContainer.findViewById(R.id.fab__listview_background);
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams();
|
||||
params.height = Utils.getDisplayHeight(listView.getContext());
|
||||
mListViewBackgroundView.setLayoutParams(params);
|
||||
|
||||
listView.setOnScrollListener(mOnScrollListener);
|
||||
return contentContainer;
|
||||
}
|
||||
|
||||
private void onNewScroll(int scrollPosition) {
|
||||
if (isActionBarNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int currentHeaderHeight = mHeaderContainer.getHeight();
|
||||
if (currentHeaderHeight != mLastHeaderHeight) {
|
||||
updateHeaderHeight(currentHeaderHeight);
|
||||
}
|
||||
|
||||
int headerHeight = currentHeaderHeight - getActionBarHeight();
|
||||
float ratio = (float) Math.min(Math.max(scrollPosition, 0), headerHeight) / headerHeight;
|
||||
int newAlpha = (int) (ratio * 255);
|
||||
mActionBarBackgroundDrawable.setAlpha(newAlpha);
|
||||
|
||||
addParallaxEffect(scrollPosition);
|
||||
}
|
||||
|
||||
private void addParallaxEffect(int scrollPosition) {
|
||||
float damping = mUseParallax ? 0.5f : 1.0f;
|
||||
int dampedScroll = (int) (scrollPosition * damping);
|
||||
int offset = mLastDampedScroll - dampedScroll;
|
||||
mHeaderContainer.offsetTopAndBottom(offset);
|
||||
|
||||
if (mListViewBackgroundView != null) {
|
||||
offset = mLastScrollPosition - scrollPosition;
|
||||
mListViewBackgroundView.offsetTopAndBottom(offset);
|
||||
}
|
||||
|
||||
if (mFirstGlobalLayoutPerformed) {
|
||||
mLastScrollPosition = scrollPosition;
|
||||
mLastDampedScroll = dampedScroll;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHeaderHeight(int headerHeight) {
|
||||
ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) mMarginView.getLayoutParams();
|
||||
params.height = headerHeight;
|
||||
mMarginView.setLayoutParams(params);
|
||||
if (mListViewBackgroundView != null) {
|
||||
FrameLayout.LayoutParams params2 = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams();
|
||||
params2.topMargin = headerHeight;
|
||||
mListViewBackgroundView.setLayoutParams(params2);
|
||||
}
|
||||
mLastHeaderHeight = headerHeight;
|
||||
}
|
||||
|
||||
private void initializeGradient(ViewGroup headerContainer) {
|
||||
View gradientView = headerContainer.findViewById(R.id.fab__gradient);
|
||||
int gradient = R.drawable.fab__gradient;
|
||||
if (mLightActionBar) {
|
||||
gradient = R.drawable.fab__gradient_light;
|
||||
}
|
||||
gradientView.setBackgroundResource(gradient);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 485 B |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 842 B |
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
|
@ -0,0 +1,656 @@
|
|||
package com.adins.mss.coll.fragments;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.depositreport.DepositReportBatchIdBean;
|
||||
import com.adins.mss.base.depositreport.DepositReportBatchIdRequest;
|
||||
import com.adins.mss.base.depositreport.DepositReportBatchIdResponse;
|
||||
import com.adins.mss.base.depositreport.DetailTaskHRequest;
|
||||
import com.adins.mss.base.depositreport.DetailTaskHResponse;
|
||||
import com.adins.mss.base.depositreport.TaskLogHelper;
|
||||
import com.adins.mss.base.tasklog.TaskLog;
|
||||
import com.adins.mss.base.todolist.ToDoList;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.coll.NewMCMainActivity;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.api.DepositReportReconcileApi;
|
||||
import com.adins.mss.coll.models.DepositReportAdapter;
|
||||
import com.adins.mss.coll.models.DepositReportReconcileResponse;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.DepositReportH;
|
||||
import com.adins.mss.dao.PrintItem;
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.db.dataaccess.DepositReportHDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.PrintItemDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
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.HttpCryptedConnection;
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
|
||||
import com.google.firebase.perf.FirebasePerformance;
|
||||
import com.google.firebase.perf.metrics.HttpMetric;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.adins.mss.base.todolist.form.PriorityTabFragment.toDoList;
|
||||
|
||||
public class DepositReportFragmentNew extends Fragment {
|
||||
private static Menu mainMenu;
|
||||
public List<TaskH> listTaskRecap;
|
||||
DepositReportAdapter adapter;
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
mainMenu = menu;
|
||||
try {
|
||||
menu.findItem(R.id.menuMore).setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context activity) {
|
||||
setHasOptionsMenu(true);
|
||||
super.onAttach(activity);
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
insertPrintItemForDeposit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
Utility.freeMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_deposit_report, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.search).setVisibility(View.GONE);
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.spinner).setVisibility(View.GONE);
|
||||
getActivity().setTitle(getString(R.string.title_mn_depositreport));
|
||||
|
||||
Button recapitulateButton = view.findViewById(R.id.recapitulateButton);
|
||||
recapitulateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
recapitulate();
|
||||
}
|
||||
});
|
||||
|
||||
final List<DepositReportH> reports = DepositReportHDataAccess.getAllForAllUser(getActivity());
|
||||
ListView list = getView().findViewById(R.id.recapitulationList);
|
||||
adapter = new DepositReportAdapter(getActivity(), reports);
|
||||
list.setAdapter(adapter);
|
||||
|
||||
list.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
DepositReportDetailActivity.report = reports.get(position);
|
||||
Intent intent = new Intent(getActivity(), DepositReportDetailActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.menuMore) {
|
||||
mainMenu.findItem(R.id.recapitulation).setVisible(true);
|
||||
mainMenu.findItem(R.id.summary).setVisible(true);
|
||||
mainMenu.findItem(R.id.mnViewMap).setVisible(false);
|
||||
}
|
||||
if (item.getItemId() == R.id.recapitulation) {
|
||||
recapitulate();
|
||||
}
|
||||
if (item.getItemId() == R.id.summary) {
|
||||
summarize();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void summarize() {
|
||||
DepositReportSummaryFragment fragment = new DepositReportSummaryFragment();
|
||||
FragmentTransaction transaction = NewMCMainActivity.fragmentManager.beginTransaction();
|
||||
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
|
||||
transaction.replace(R.id.content_frame, fragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
private void recapitulate() {
|
||||
if (Tool.isInternetconnected(getActivity())) {
|
||||
initialize();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.jsonParseFailed), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
loadData();
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
new AsyncTask<Void, Void, DepositReportReconcileResponse>() {
|
||||
boolean isError = false;
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = ProgressDialog.show(getActivity(),
|
||||
"", getString(R.string.progressWait), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DepositReportReconcileResponse doInBackground(Void... params) {
|
||||
if (Tool.isInternetconnected(getActivity())) {
|
||||
TaskLog log = new TaskLog(getActivity());
|
||||
List<TaskH> result = log.getListTaskLog();
|
||||
|
||||
List<TaskH> onlineLog = TaskLogHelper.getTaskLog(getActivity());
|
||||
if (onlineLog != null) {
|
||||
if (result == null) result = new ArrayList<>();
|
||||
List<String> uuidListTaskH = new ArrayList<>();
|
||||
|
||||
for (TaskH taskH : result) {
|
||||
uuidListTaskH.add(taskH.getUuid_task_h());
|
||||
}
|
||||
|
||||
Iterator<TaskH> iterator = onlineLog.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskH taskH = iterator.next();
|
||||
|
||||
if (uuidListTaskH.contains(taskH.getUuid_task_h())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineLog.size() > 0) {
|
||||
for (TaskH taskH : onlineLog) {
|
||||
taskH.setUuid_user(GlobalData.getSharedGlobalData().getUser().getUuid_user());
|
||||
taskH.setStatus(TaskHDataAccess.STATUS_SEND_SENT);
|
||||
TaskHDataAccess.addOrReplace(getActivity(), taskH);
|
||||
result.add(taskH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result != null && result.size() > 0) {
|
||||
for (TaskH taskH : result) {
|
||||
List<TaskD> taskDs = TaskDDataAccess.getAll(getActivity(), taskH.getUuid_task_h(),
|
||||
TaskDDataAccess.ALL_TASK);
|
||||
if (taskDs == null || taskDs.size() == 0) {
|
||||
DetailTaskHResponse response = null;
|
||||
|
||||
DetailTaskHRequest request = new DetailTaskHRequest();
|
||||
request.setUuidTaskH(taskH.getUuid_task_h());
|
||||
request.setFlag(taskH.getFlag());
|
||||
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(getActivity(),
|
||||
GlobalData.getSharedGlobalData().isEncrypt(), GlobalData.getSharedGlobalData().isDecrypt());
|
||||
String url = GlobalData.getSharedGlobalData().getURL_GET_TASK_LOG();
|
||||
HttpConnectionResult serverResult;
|
||||
// Firebase Performance Trace Network Request
|
||||
HttpMetric networkMetric = FirebasePerformance.getInstance().newHttpMetric(
|
||||
url, FirebasePerformance.HttpMethod.POST);
|
||||
Utility.metricStart(networkMetric, GsonHelper.toJson(request));
|
||||
|
||||
try {
|
||||
serverResult = httpConn.requestToServer(url, GsonHelper.toJson(request),
|
||||
Global.DEFAULTCONNECTIONTIMEOUT);
|
||||
Utility.metricStop(networkMetric, serverResult);
|
||||
|
||||
if (serverResult != null && serverResult.isOK()) {
|
||||
try {
|
||||
response = GsonHelper.fromJson(serverResult.getResult(),
|
||||
DetailTaskHResponse.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
isError = true;
|
||||
}
|
||||
} else {
|
||||
isError = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
isError = true;
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (response != null && response.getTaskDs() != null) {
|
||||
TaskDDataAccess.addOrReplace(getActivity(), response.getTaskDs());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<TaskD> reports = TaskDDataAccess.getTaskDTagTotal(getActivity());
|
||||
|
||||
List<String> taskId = new ArrayList<String>();
|
||||
List<String> flag = new ArrayList<String>();
|
||||
TaskH taskH;
|
||||
for (TaskD taskD : reports) {
|
||||
taskH = TaskHDataAccess.getOneHeader(getActivity(), taskD.getUuid_task_h());
|
||||
taskH.setIs_reconciled("0");
|
||||
TaskHDataAccess.addOrReplace(getActivity(), taskH);
|
||||
taskId.add(taskH.getTask_id());
|
||||
flag.add(taskH.getFlag());
|
||||
}
|
||||
DepositReportReconcileApi api = new DepositReportReconcileApi(getActivity());
|
||||
|
||||
try {
|
||||
return api.request(taskId, flag);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
isError = true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(DepositReportReconcileResponse depositReportReconcileResponse) {
|
||||
super.onPostExecute(depositReportReconcileResponse);
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (isError) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.jsonParseFailed), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (depositReportReconcileResponse == null) {
|
||||
final List<DepositReportH> reports = DepositReportHDataAccess.getAllForAllUser(getActivity());
|
||||
ListView list = getView().findViewById(R.id.recapitulationList);
|
||||
adapter = new DepositReportAdapter(getActivity(), reports);
|
||||
list.setAdapter(adapter);
|
||||
|
||||
list.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
DepositReportDetailActivity.report = reports.get(position);
|
||||
Intent intent = new Intent(getActivity(), DepositReportDetailActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
} else if (depositReportReconcileResponse.getStatus().getCode() != 0) {
|
||||
NiftyDialogBuilder.getInstance(getActivity())
|
||||
.withMessage(depositReportReconcileResponse.getStatus().getMessage())
|
||||
.withTitle(getString(R.string.server_error))
|
||||
.withButton1Text(getString(R.string.btnClose))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
return;
|
||||
} else {
|
||||
List<String> taskId = depositReportReconcileResponse.getTaskId();
|
||||
if (taskId != null) {
|
||||
for (String task : taskId) {
|
||||
TaskH taskH = TaskHDataAccess.getOneTaskHeader(getActivity(), task);
|
||||
taskH.setIs_reconciled("1");
|
||||
TaskHDataAccess.addOrReplace(getActivity(), taskH);
|
||||
}
|
||||
}
|
||||
|
||||
final List<DepositReportH> reports = DepositReportHDataAccess.getAllForAllUser(getActivity());
|
||||
ListView list = getView().findViewById(R.id.recapitulationList);
|
||||
adapter = new DepositReportAdapter(getActivity(), reports);
|
||||
list.setAdapter(adapter);
|
||||
|
||||
list.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
DepositReportDetailActivity.report = reports.get(position);
|
||||
Intent intent = new Intent(getActivity(), DepositReportDetailActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
toDoList = new ToDoList(getActivity());
|
||||
listTaskRecap = toDoList.getListTaskInStatusForMultiUser(ToDoList.SEARCH_BY_ALL_SENT, "BATCHID");
|
||||
|
||||
if (listTaskRecap != null && listTaskRecap.size() > 0) {
|
||||
BatchIdTask task = new BatchIdTask();
|
||||
task.execute();
|
||||
} else {
|
||||
DepositReportRecapitulateFragmentNew fragment = new DepositReportRecapitulateFragmentNew();
|
||||
FragmentTransaction transaction = NewMCMainActivity.fragmentManager.beginTransaction();
|
||||
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
|
||||
transaction.replace(R.id.content_frame, fragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.search).setVisibility(View.GONE);
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.spinner).setVisibility(View.GONE);
|
||||
getActivity().setTitle(getString(R.string.title_mn_depositreport));
|
||||
}
|
||||
|
||||
public void insertPrintItemForDeposit() {
|
||||
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(getActivity(),
|
||||
"wasInsertedDepositPrint", Context.MODE_PRIVATE);
|
||||
String isInsert = sharedPref.getString("isInsertDepositPrint", Global.FALSE_STRING);
|
||||
if (isInsert.equals(Global.FALSE_STRING)) {
|
||||
ObscuredSharedPreferences.Editor sharedPrefEditor = sharedPref.edit();
|
||||
sharedPrefEditor.putString("isInsertDepositPrint", Global.TRUE_STRING);
|
||||
sharedPrefEditor.commit();
|
||||
|
||||
PrintItem itemLogo = new PrintItem(Tool.getUUID());
|
||||
itemLogo.setPrint_type_id(Global.PRINT_LOGO);
|
||||
itemLogo.setPrint_item_label("LOGO");
|
||||
itemLogo.setPrint_item_order(1);
|
||||
itemLogo.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemLogo);
|
||||
|
||||
PrintItem itemBranchName = new PrintItem(Tool.getUUID());
|
||||
itemBranchName.setPrint_type_id(Global.PRINT_BRANCH_NAME);
|
||||
itemBranchName.setPrint_item_label("Branch Name");
|
||||
itemBranchName.setPrint_item_order(2);
|
||||
itemBranchName.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemBranchName);
|
||||
|
||||
PrintItem itemBranchAddr = new PrintItem(Tool.getUUID());
|
||||
itemBranchAddr.setPrint_type_id(Global.PRINT_BRANCH_ADDRESS);
|
||||
itemBranchAddr.setPrint_item_label("Branch Address");
|
||||
itemBranchAddr.setPrint_item_order(2);
|
||||
itemBranchAddr.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemBranchAddr);
|
||||
|
||||
PrintItem itemNewLineE = new PrintItem(Tool.getUUID());
|
||||
itemNewLineE.setPrint_type_id(Global.PRINT_NEW_LINE);
|
||||
itemNewLineE.setPrint_item_label("999New Line");
|
||||
itemNewLineE.setPrint_item_order(3);
|
||||
itemNewLineE.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemNewLineE);
|
||||
|
||||
/*PrintItem itemNewLine1= new PrintItem(Tool.getUUID());
|
||||
itemNewLine1.setPrint_type_id(Global.PRINT_NEW_LINE);
|
||||
itemNewLine1.setPrint_item_label("998New Line");
|
||||
itemNewLine1.setPrint_item_order(4);
|
||||
itemNewLine1.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemNewLine1);*/
|
||||
|
||||
PrintItem itemTitle = new PrintItem(Tool.getUUID());
|
||||
itemTitle.setPrint_type_id(Global.PRINT_LABEL_CENTER_BOLD);
|
||||
itemTitle.setPrint_item_label("Bukti Deposit Report");
|
||||
itemTitle.setPrint_item_order(10);
|
||||
itemTitle.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemTitle);
|
||||
|
||||
/*PrintItem itemNewLine2= new PrintItem(Tool.getUUID());
|
||||
itemNewLine2.setPrint_type_id(Global.PRINT_NEW_LINE);
|
||||
itemNewLine2.setPrint_item_label("998New Line");
|
||||
itemNewLine2.setPrint_item_order(4);
|
||||
itemNewLine2.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemNewLine2);*/
|
||||
|
||||
PrintItem itemBatchId = new PrintItem(Tool.getUUID());
|
||||
itemBatchId.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemBatchId.setPrint_item_label("Batch ID");
|
||||
itemBatchId.setPrint_item_order(11);
|
||||
itemBatchId.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemBatchId);
|
||||
|
||||
PrintItem itemCollName = new PrintItem(Tool.getUUID());
|
||||
itemCollName.setPrint_type_id(Global.PRINT_USER_NAME);
|
||||
itemCollName.setPrint_item_label("Coll Name");
|
||||
itemCollName.setPrint_item_order(12);
|
||||
itemCollName.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemCollName);
|
||||
|
||||
PrintItem itemTransferBy = new PrintItem(Tool.getUUID());
|
||||
itemTransferBy.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemTransferBy.setPrint_item_label("Transfer By");
|
||||
itemTransferBy.setPrint_item_order(20);
|
||||
itemTransferBy.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemTransferBy);
|
||||
|
||||
PrintItem itemCashierName = new PrintItem(Tool.getUUID());
|
||||
itemCashierName.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemCashierName.setPrint_item_label("Cashier Name");
|
||||
itemCashierName.setPrint_item_order(30);
|
||||
itemCashierName.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemCashierName);
|
||||
|
||||
PrintItem itemAccountNo = new PrintItem(Tool.getUUID());
|
||||
itemAccountNo.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemAccountNo.setPrint_item_label("Account No");
|
||||
itemAccountNo.setPrint_item_order(30);
|
||||
itemAccountNo.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemAccountNo);
|
||||
|
||||
PrintItem itemBankName = new PrintItem(Tool.getUUID());
|
||||
itemBankName.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemBankName.setPrint_item_label("Bank Name");
|
||||
itemBankName.setPrint_item_order(40);
|
||||
itemBankName.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemBankName);
|
||||
|
||||
PrintItem itemTransDate = new PrintItem(Tool.getUUID());
|
||||
itemTransDate.setPrint_type_id(Global.PRINT_TIMESTAMP);
|
||||
itemTransDate.setPrint_item_label("Print Date");
|
||||
itemTransDate.setPrint_item_order(42);
|
||||
itemTransDate.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemTransDate);
|
||||
|
||||
PrintItem itemNewLine3 = new PrintItem(Tool.getUUID());
|
||||
itemNewLine3.setPrint_type_id(Global.PRINT_NEW_LINE);
|
||||
itemNewLine3.setPrint_item_label("999New Line");
|
||||
itemNewLine3.setPrint_item_order(45);
|
||||
itemNewLine3.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemNewLine3);
|
||||
|
||||
PrintItem itemTitleDetail = new PrintItem(Tool.getUUID());
|
||||
itemTitleDetail.setPrint_type_id(Global.PRINT_LABEL_CENTER_BOLD);
|
||||
itemTitleDetail.setPrint_item_label("Deposit Detail");
|
||||
itemTitleDetail.setPrint_item_order(50);
|
||||
itemTitleDetail.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemTitleDetail);
|
||||
|
||||
int ANO_order = 60;
|
||||
int DAM_order = 61;
|
||||
int DIV_order = 62;
|
||||
for (int i = 0; i < 30; i++) {
|
||||
PrintItem itemAgreementNo = new PrintItem(Tool.getUUID());
|
||||
itemAgreementNo.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemAgreementNo.setPrint_item_label(i + "Agreement No");
|
||||
itemAgreementNo.setPrint_item_order(ANO_order);
|
||||
itemAgreementNo.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemAgreementNo);
|
||||
|
||||
PrintItem itemDepositAmt = new PrintItem(Tool.getUUID());
|
||||
itemDepositAmt.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemDepositAmt.setPrint_item_label(i + "Deposit Amount");
|
||||
itemDepositAmt.setPrint_item_order(DAM_order);
|
||||
itemDepositAmt.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemDepositAmt);
|
||||
|
||||
PrintItem itemNewLine = new PrintItem(Tool.getUUID());
|
||||
itemNewLine.setPrint_type_id(Global.PRINT_NEW_LINE);
|
||||
itemNewLine.setPrint_item_label(i + "New Line");
|
||||
itemNewLine.setPrint_item_order(DIV_order);
|
||||
itemNewLine.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemNewLine);
|
||||
|
||||
ANO_order = ANO_order + 3;
|
||||
DAM_order = DAM_order + 3;
|
||||
DIV_order = DIV_order + 3;
|
||||
}
|
||||
|
||||
PrintItem itemTotalAmt = new PrintItem(Tool.getUUID());
|
||||
itemTotalAmt.setPrint_type_id(Global.PRINT_ANSWER);
|
||||
itemTotalAmt.setPrint_item_label("Total");
|
||||
itemTotalAmt.setPrint_item_order(200);
|
||||
itemTotalAmt.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemTotalAmt);
|
||||
|
||||
PrintItem itemNewLineT = new PrintItem(Tool.getUUID());
|
||||
itemNewLineT.setPrint_type_id(Global.PRINT_NEW_LINE);
|
||||
itemNewLineT.setPrint_item_label("999New Line");
|
||||
itemNewLineT.setPrint_item_order(210);
|
||||
itemNewLineT.setUuid_scheme("DUMYUUIDSCHEMEFORDEPOSITREPORT");
|
||||
PrintItemDataAccess.addOrReplace(getActivity(), itemNewLineT);
|
||||
}
|
||||
}
|
||||
|
||||
private class BatchIdTask extends AsyncTask<Void, Void, List<DepositReportBatchIdBean>> {
|
||||
private ProgressDialog progressDialog;
|
||||
private String errMessage, message;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
progressDialog = ProgressDialog.show(getContext(), "", getString(com.adins.mss.base.R.string.progressWait));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DepositReportBatchIdBean> doInBackground(Void... Void) {
|
||||
if (Tool.isInternetconnected(getActivity())) {
|
||||
List<String> listUuidRequest = new ArrayList<>();
|
||||
for (TaskH taskHRequest : listTaskRecap) {
|
||||
listUuidRequest.add(taskHRequest.getTask_id());
|
||||
}
|
||||
|
||||
DepositReportBatchIdRequest request = new DepositReportBatchIdRequest();
|
||||
request.setListTaskID(listUuidRequest);
|
||||
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
|
||||
String json = GsonHelper.toJson(request);
|
||||
String url = GlobalData.getSharedGlobalData().getURL_GET_BATCHID_LIST();
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(getActivity(), encrypt, decrypt);
|
||||
HttpConnectionResult serverResult = null;
|
||||
// Firebase Performance Trace Network Request
|
||||
HttpMetric networkMetric = FirebasePerformance.getInstance().newHttpMetric(
|
||||
url, FirebasePerformance.HttpMethod.POST);
|
||||
Utility.metricStart(networkMetric, json);
|
||||
|
||||
try {
|
||||
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
|
||||
Utility.metricStop(networkMetric, serverResult);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (serverResult != null && serverResult.isOK()) {
|
||||
try {
|
||||
String responseBody = serverResult.getResult();
|
||||
DepositReportBatchIdResponse response = GsonHelper.fromJson(responseBody, DepositReportBatchIdResponse.class);
|
||||
|
||||
if (response.getStatus().getCode() != 0) {
|
||||
message = response.getStatus().getMessage();
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
return response.getListBatchID();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Global.IS_DEV) {
|
||||
e.printStackTrace();
|
||||
errMessage = e.getMessage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = getString(com.adins.mss.base.R.string.server_down);
|
||||
}
|
||||
|
||||
} else {
|
||||
errMessage = getString(com.adins.mss.base.R.string.no_internet_connection);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<DepositReportBatchIdBean> batchTask) {
|
||||
super.onPostExecute(batchTask);
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (batchTask != null && batchTask.size() > 0) {
|
||||
for (DepositReportBatchIdBean taskBean : batchTask) {
|
||||
if ("1".equalsIgnoreCase(taskBean.getFlagDeposit()) &&
|
||||
(taskBean.getBatchId() != null && !taskBean.getBatchId().isEmpty())) {
|
||||
TaskH taskH = TaskHDataAccess.getOneTaskHeader(getActivity(), taskBean.getTaskId());
|
||||
taskH.setBatch_id(taskBean.getBatchId());
|
||||
TaskHDataAccess.addOrReplace(getActivity(), taskH);
|
||||
} else if ("0".equalsIgnoreCase(taskBean.getFlagDeposit()) &&
|
||||
(taskBean.getBatchId() != null && !taskBean.getBatchId().isEmpty())) {
|
||||
TaskH taskH = TaskHDataAccess.getOneTaskHeader(getActivity(), taskBean.getTaskId());
|
||||
if ("0".equalsIgnoreCase(taskH.getIs_reconciled())) {
|
||||
taskH.setIs_reconciled("1");
|
||||
TaskHDataAccess.addOrReplace(getActivity(), taskH);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (message != null) {
|
||||
Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show();
|
||||
} else if (errMessage != null) {
|
||||
Toast.makeText(getContext(), errMessage, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
DepositReportRecapitulateFragmentNew fragment = new DepositReportRecapitulateFragmentNew();
|
||||
FragmentTransaction transaction = NewMCMainActivity.fragmentManager.beginTransaction();
|
||||
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
|
||||
transaction.replace(R.id.content_frame, fragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
|
@ -0,0 +1,163 @@
|
|||
package com.adins.mss.base.todo.form;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
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.mainmenu.MainMenuActivity;
|
||||
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.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.androidquery.AQuery;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class NewTaskActivity extends Fragment {
|
||||
protected View view;
|
||||
protected AQuery query;
|
||||
protected List<Scheme> objects;
|
||||
private User user = GlobalData.getSharedGlobalData().getUser();
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
protected abstract NewTaskAdapter getNewTaskAdapter();
|
||||
|
||||
protected TaskH setNewTaskH(Scheme scheme) {
|
||||
TaskH taskH = null;
|
||||
taskH = new TaskH();
|
||||
taskH.setUuid_task_h(Tool.getUUID());
|
||||
taskH.setUser(user);
|
||||
taskH.setScheme(scheme);
|
||||
taskH.setStatus(TaskHDataAccess.STATUS_SEND_INIT);
|
||||
taskH.setIs_prepocessed(TaskHDataAccess.STATUS_SEND_INIT);
|
||||
taskH.setIs_verification("0");
|
||||
return taskH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
Utility.freeMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context activity) {
|
||||
super.onAttach(activity);
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(getActivity(), getString(R.string.screen_name_new_task), null);
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
// UI code goes here
|
||||
/*try {
|
||||
if (MainMenuActivity.mnTaskList != null)
|
||||
MainMenuActivity.mnTaskList.setCounter(String
|
||||
.valueOf(ToDoList
|
||||
.getCounterTaskList(getActivity())));
|
||||
if (MainMenuActivity.mnLog != null)
|
||||
MainMenuActivity.mnLog
|
||||
.setCounter(String.valueOf(TaskLogImpl
|
||||
.getCounterLog(getActivity())));
|
||||
if (MainMenuActivity.menuAdapter != null)
|
||||
MainMenuActivity.menuAdapter.notifyDataSetChanged();
|
||||
} catch (Exception e) { FireCrash.log(e);
|
||||
// TODO: handle exception
|
||||
}*/
|
||||
try {
|
||||
MainMenuActivity.setDrawerCounter();
|
||||
} 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 Drawer Counter"));
|
||||
}
|
||||
}
|
||||
});
|
||||
getActivity().getActionBar().setTitle(getString(R.string.title_mn_newtask));
|
||||
getActivity().getActionBar().removeAllTabs();
|
||||
getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
screenName = FirebaseAnalytics.getInstance(getActivity());
|
||||
if (view != null) {
|
||||
ViewGroup parent = (ViewGroup) view.getParent();
|
||||
if (parent != null)
|
||||
parent.removeView(view);
|
||||
}
|
||||
try {
|
||||
view = inflater.inflate(R.layout.newtask_layout, container, false);
|
||||
query = new AQuery(view);
|
||||
query.id(android.R.id.list).adapter(getNewTaskAdapter());
|
||||
query.id(android.R.id.list).itemClicked(this, "itemClick");
|
||||
if (SchemeDataAccess.getAll(getContext()).size() == 0) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.no_scheme_found), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
ACRA.getErrorReporter().putCustomData("errorInflateView", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorInflateView", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat inflate view"));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Keep
|
||||
public void itemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
Scheme selectedScheme = getNewTaskAdapter().getItem(position);
|
||||
TaskH selectedTask = setNewTaskH(selectedScheme);
|
||||
SurveyHeaderBean header = new SurveyHeaderBean(selectedTask);
|
||||
// TODO Action Lempar ke Customer ACtivity
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(CustomerFragment.SURVEY_HEADER, header);
|
||||
bundle.putInt(CustomerFragment.SURVEY_MODE, Global.MODE_NEW_SURVEY);
|
||||
Fragment fragment = CustomerFragment.create(bundle);
|
||||
|
||||
for (int i = 1; i < getFragmentManager().getBackStackEntryCount(); i++)
|
||||
NewMainActivity.fragmentManager.popBackStack();
|
||||
|
||||
FragmentTransaction transaction = MainMenuActivity.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();
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,205 @@
|
|||
package com.adins.mss.coll.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.commons.TaskListener;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.interfaces.ReportSummaryImpl;
|
||||
import com.adins.mss.coll.interfaces.ReportSummaryInterface;
|
||||
import com.adins.mss.coll.models.ReportSummaryResponse;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
|
||||
|
||||
/**
|
||||
* Created by Aditya Purwa on 2/16/2015.
|
||||
*/
|
||||
public class ReportSummaryFragment extends Fragment implements TaskListener {
|
||||
private View view;
|
||||
private TextView tanggal;
|
||||
private TextView collector;
|
||||
private TextView totalToBeCollected;
|
||||
private TextView totalPaid;
|
||||
private ReportSummaryInterface iReportSummary;
|
||||
TableLayout table;
|
||||
private View row;
|
||||
private TextView txt_Aggrmn_No;
|
||||
private TextView txt_Status;
|
||||
private TextView txt_result;
|
||||
private List<ReportSummaryResponse> listTask = new ArrayList<>();
|
||||
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
screenName = FirebaseAnalytics.getInstance(getActivity());
|
||||
Context context= this.getContext();
|
||||
iReportSummary = new ReportSummaryImpl(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
Utility.freeMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.search).setVisibility(View.GONE);
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.spinner).setVisibility(View.GONE);
|
||||
getActivity().setTitle(getString(R.string.title_mn_reportsummary));
|
||||
|
||||
tanggal = (TextView) view.findViewById(R.id.txtDate);
|
||||
totalToBeCollected = (TextView) view.findViewById(R.id.txtCollected);
|
||||
totalPaid = (TextView) view.findViewById(R.id.txtPaid);
|
||||
table = (TableLayout) view.findViewById(R.id.tableSummary);
|
||||
|
||||
tanggal.setText(getString(R.string.text_empty));
|
||||
totalToBeCollected.setText(getString(R.string.text_empty));
|
||||
totalPaid.setText(getString(R.string.text_empty));
|
||||
|
||||
iReportSummary.getReportSummary(this);
|
||||
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showAllUserHelp(ReportSummaryFragment.this.getActivity(),ReportSummaryFragment.this.getClass().getSimpleName());
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (view != null) {
|
||||
ViewGroup parent = (ViewGroup) view.getParent();
|
||||
if (parent != null)
|
||||
parent.removeView(view);
|
||||
}
|
||||
try {
|
||||
view = inflater.inflate(R.layout.new_fragment_report_summary, container, false);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == R.id.mnGuide){
|
||||
if(!Global.BACKPRESS_RESTRICTION) {
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showAllUserHelp(ReportSummaryFragment.this.getActivity(), ReportSummaryFragment.this.getClass().getSimpleName());
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(getActivity(), getString(R.string.screen_name_report_summary), null);
|
||||
getActivity().findViewById(com.adins.mss.base.R.id.search).setVisibility(View.GONE);
|
||||
getActivity().setTitle(getString(R.string.title_mn_reportsummary));
|
||||
// getActivity().getActionBar().setTitle(getString(R.string.title_mn_reportsummary));
|
||||
// getActivity().getActionBar().removeAllTabs();
|
||||
// getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
setHasOptionsMenu(true);
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleteTask(Object result) {
|
||||
ReportSummaryResponse reportSummaryResponse = (ReportSummaryResponse) result;
|
||||
tanggal.setText(reportSummaryResponse.getCurrent_date());
|
||||
totalToBeCollected.setText(Tool.separateThousand(String.format(Locale.US, "%.0f",reportSummaryResponse.getTotal_to_be_paid())));
|
||||
totalPaid.setText(Tool.separateThousand(String.format(Locale.US, "%.0f",reportSummaryResponse.getTotal_received())));
|
||||
|
||||
listTask = reportSummaryResponse.getList_task();
|
||||
if (listTask != null) {
|
||||
for (ReportSummaryResponse listResponse : listTask) {
|
||||
row = LayoutInflater.from(getContext()).inflate(R.layout.new_fragment_report_summary_row, table, false);
|
||||
txt_Aggrmn_No = (TextView) row.findViewById(R.id.fieldAgrmnNo);
|
||||
txt_Status = (TextView) row.findViewById(R.id.fieldStatus);
|
||||
txt_result = (TextView) row.findViewById(R.id.fieldResult);
|
||||
|
||||
txt_Aggrmn_No.setText(listResponse.getAgreementNo());
|
||||
txt_Status.setText(listResponse.getStatusTask());
|
||||
if(!"-".equals(listResponse.getAmountPaid())){
|
||||
txt_result.setText(Tool.separateThousand(String.format(Locale.US, "%.0f", Double.parseDouble(listResponse.getAmountPaid()))));
|
||||
} else if (listResponse.getPtp().length() > 1) {
|
||||
txt_result.setText(listResponse.getPtp());
|
||||
} else {
|
||||
txt_result.setText(listResponse.getNote());
|
||||
}
|
||||
|
||||
table.addView(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelTask(boolean value) {
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocalData(Object result) {
|
||||
|
||||
}
|
||||
|
||||
// private static Menu mainMenu;
|
||||
//
|
||||
// @Override
|
||||
// public void onPrepareOptionsMenu(Menu menu) {
|
||||
// super.onPrepareOptionsMenu(menu);
|
||||
// mainMenu = menu;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onOptionsItemSelected(NewMenuItem item) {
|
||||
// // Handle item selection
|
||||
// int id = item.getItemId();
|
||||
// if (id == R.id.menuMore) {
|
||||
// mainMenu.findItem(R.id.mnViewMap).setVisible(false);
|
||||
// mainMenu.findItem(R.id.mnViewAllHeader).setVisible(false);
|
||||
// }
|
||||
//
|
||||
// return super.onOptionsItemSelected(item);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/login_color" />
|
||||
<!--<gradient-->
|
||||
<!--android:startColor="@color/gradient_start"-->
|
||||
<!--android:endColor="@color/gradient_end"-->
|
||||
<!--android:angle="270" />-->
|
||||
</shape>
|
|
@ -0,0 +1,48 @@
|
|||
package com.services;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class NotificationService extends Service {
|
||||
public static NotificationThread auto;
|
||||
public static Class mss;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate();
|
||||
startNotificationThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDestroy();
|
||||
stopNotificationThread();
|
||||
}
|
||||
|
||||
public synchronized void startNotificationThread() {
|
||||
if (auto == null) {
|
||||
auto = new NotificationThread(getApplicationContext(),this);
|
||||
auto.start();
|
||||
} else {
|
||||
auto.start();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopNotificationThread() {
|
||||
if (auto != null) {
|
||||
auto.requestStop();
|
||||
auto = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,291 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 01/09/2016.
|
||||
*/
|
||||
public class DrawingCanvasActivity extends FragmentActivity implements View.OnClickListener {
|
||||
public static final int IMG_SAVE_QUALITY = 80;
|
||||
public static final String BUND_KEY_IMAGE_RESULT = "com.adins.mss.base.dynamicform.form.questions.BUND_KEY_IMAGE_RESULT";
|
||||
public static QuestionBean bean;
|
||||
private DrawCanvas mView;
|
||||
private int colorbg = Color.BLACK;
|
||||
private int colorpen = Color.WHITE;
|
||||
private LinearLayout canvasLayout;
|
||||
private Button btnClear;
|
||||
private Button btnEdit;
|
||||
private Button btnErase;
|
||||
private Button btnSave;
|
||||
private Paint mPaint;
|
||||
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
screenName = FirebaseAnalytics.getInstance(this);
|
||||
setContentView(R.layout.drawing_layout);
|
||||
mView = new DrawCanvas(this);
|
||||
canvasLayout = (LinearLayout) findViewById(R.id.canvasLayout);
|
||||
canvasLayout.addView(mView);
|
||||
btnClear = (Button) findViewById(R.id.btnClear);
|
||||
btnEdit = (Button) findViewById(R.id.btnEdit);
|
||||
btnErase = (Button) findViewById(R.id.btnErase);
|
||||
btnSave = (Button) findViewById(R.id.btnSave);
|
||||
btnClear.setOnClickListener(this);
|
||||
btnEdit.setOnClickListener(this);
|
||||
btnErase.setOnClickListener(this);
|
||||
btnSave.setOnClickListener(this);
|
||||
|
||||
|
||||
mPaint = new Paint();
|
||||
defaultPaint();
|
||||
|
||||
Toast.makeText(this, getString(R.string.infoDraw), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(this, getString(R.string.screen_name_signature_canvas), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
|
||||
super.onPause();
|
||||
Global.haveLogin = 1;
|
||||
}
|
||||
|
||||
public void defaultPaint() {
|
||||
btnEdit.setBackgroundResource(R.drawable.button_background2);
|
||||
btnErase.setBackgroundResource(R.drawable.button_background);
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setDither(true);
|
||||
mPaint.setColor(colorpen);
|
||||
mPaint.setStyle(Paint.Style.STROKE);
|
||||
mPaint.setStrokeJoin(Paint.Join.ROUND);
|
||||
mPaint.setStrokeCap(Paint.Cap.ROUND);
|
||||
mPaint.setStrokeWidth(10);
|
||||
}
|
||||
|
||||
public void setColorPen(int color) {
|
||||
mPaint.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mPaint.setXfermode(null);
|
||||
mPaint.setAlpha(0xFF);
|
||||
int id = v.getId();
|
||||
if (id == R.id.btnClear) {
|
||||
mView.clear();
|
||||
defaultPaint();
|
||||
} else if (id == R.id.btnErase) {
|
||||
btnErase.setBackgroundResource(R.drawable.button_background2);
|
||||
btnEdit.setBackgroundResource(R.drawable.button_background);
|
||||
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
mPaint.setStrokeJoin(Paint.Join.ROUND);
|
||||
mPaint.setStrokeCap(Paint.Cap.SQUARE);
|
||||
mPaint.setStrokeWidth(30);
|
||||
} else if (id == R.id.btnSave) {
|
||||
try {
|
||||
byte[] b = mView.getByteBitmap();
|
||||
Intent intent = new Intent();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putByteArray(BUND_KEY_IMAGE_RESULT, b);
|
||||
intent.putExtras(bundle);
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
} catch (OutOfMemoryError e) {
|
||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.processing_failed), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
mView.recycleView();
|
||||
finish();
|
||||
} else if (id == R.id.btnEdit) {
|
||||
defaultPaint();
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
DrawingCanvasActivity.bean = null;
|
||||
Utility.freeMemory();
|
||||
}
|
||||
|
||||
public class DrawCanvas extends View {
|
||||
private static final float TOUCH_TOLERANCE = 4;
|
||||
private Bitmap mBitmap;
|
||||
private Canvas mCanvas;
|
||||
private Path mPath;
|
||||
private Paint mBitmapPaint;
|
||||
private float mX, mY;
|
||||
|
||||
public DrawCanvas(Context c) {
|
||||
super(c);
|
||||
// --
|
||||
DisplayMetrics displaymetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
||||
int height = displaymetrics.heightPixels;
|
||||
int widht = displaymetrics.widthPixels;
|
||||
|
||||
try {
|
||||
mBitmap = Bitmap.createBitmap(widht, height, Bitmap.Config.RGB_565);
|
||||
mCanvas = new Canvas(mBitmap);
|
||||
mPath = new Path();
|
||||
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
|
||||
|
||||
byte[] savedImage = null;
|
||||
try {
|
||||
savedImage = bean.getImgAnswer();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
if (savedImage != null && savedImage.length > 0) {
|
||||
Bitmap source = BitmapFactory.decodeByteArray(savedImage, 0, savedImage.length);
|
||||
mCanvas.drawBitmap(source, 0, 0, mBitmapPaint);
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.drawColor(colorbg);
|
||||
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
}
|
||||
|
||||
private void touch_start(float x, float y) {
|
||||
mPath.reset();
|
||||
mPath.moveTo(x, y);
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
|
||||
private void touch_move(float x, float y) {
|
||||
float dx = Math.abs(x - mX);
|
||||
float dy = Math.abs(y - mY);
|
||||
if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
|
||||
mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
}
|
||||
|
||||
private void touch_up() {
|
||||
mPath.lineTo(mX, mY);
|
||||
// commit the path to our offscreen
|
||||
mCanvas.drawPath(mPath, mPaint);
|
||||
// kill this so we don't double draw
|
||||
mPath.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
touch_start(x, y);
|
||||
invalidate();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
touch_move(x, y);
|
||||
invalidate();
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
touch_up();
|
||||
invalidate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----
|
||||
public void clear() {
|
||||
if (mCanvas != null) {
|
||||
mCanvas.drawColor(colorbg);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void recycleView() {
|
||||
if (mBitmap != null) {
|
||||
mBitmap.recycle();
|
||||
mBitmap = null;
|
||||
}
|
||||
if (mCanvas != null) {
|
||||
mCanvas = null;
|
||||
mPath = null;
|
||||
mBitmapPaint = null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getByteBitmap() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
mBitmap.compress(Bitmap.CompressFormat.JPEG, IMG_SAVE_QUALITY, baos);
|
||||
byte[] b = baos.toByteArray();
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.adins.mss.odr.news;
|
||||
|
||||
import com.adins.mss.dao.MobileContentH;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JsonResponseNewsHeader extends MssResponseType{
|
||||
@SerializedName("listResponseServer")
|
||||
List<MobileContentH> listResponseServer;
|
||||
|
||||
public List<MobileContentH> getListHeader() {
|
||||
return listResponseServer;
|
||||
}
|
||||
public void setListContentHeader(List<MobileContentH> listHeader) {
|
||||
this.listResponseServer = listHeader;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.adins.mss.base.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.LocaleList;
|
||||
|
||||
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 29/03/2016.
|
||||
*/
|
||||
public class LocaleHelper {
|
||||
public static final String BAHASA_INDONESIA = "in";
|
||||
public static final String ENGLSIH = "en";
|
||||
private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language";
|
||||
|
||||
private LocaleHelper() {
|
||||
}
|
||||
|
||||
public static void onCreate(Context context) {
|
||||
String lang = getPersistedData(context, Locale.getDefault().getLanguage());
|
||||
setLocale(context, lang);
|
||||
}
|
||||
|
||||
public static void onCreate(Context context, String defaultLanguage) {
|
||||
String lang = getPersistedData(context, defaultLanguage);
|
||||
setLocale(context, lang);
|
||||
}
|
||||
|
||||
public static String getLanguage(Context context) {
|
||||
return getPersistedData(context, Locale.getDefault().getLanguage());
|
||||
}
|
||||
|
||||
public static void setLocale(Context context, String language) {
|
||||
persist(context, language);
|
||||
updateResources(context, language);
|
||||
}
|
||||
|
||||
private static String getPersistedData(Context context, String defaultLanguage) {
|
||||
ObscuredSharedPreferences preferences = ObscuredSharedPreferences.getPrefs(context,"APP_LANGUAGE",Context.MODE_PRIVATE);
|
||||
return preferences.getString(SELECTED_LANGUAGE, defaultLanguage);
|
||||
}
|
||||
|
||||
private static void persist(Context context, String language) {
|
||||
ObscuredSharedPreferences preferences = ObscuredSharedPreferences.getPrefs(context,"APP_LANGUAGE",Context.MODE_PRIVATE);
|
||||
ObscuredSharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
editor.putString(SELECTED_LANGUAGE, language);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
private static void updateResources(Context context, String language) {
|
||||
Locale locale = new Locale(language);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
Resources resources = context.getResources();
|
||||
|
||||
Configuration configuration = resources.getConfiguration();
|
||||
configuration.locale = locale;
|
||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||
}
|
||||
|
||||
public static ContextWrapper wrap(Context context, Locale newLocale) {
|
||||
Resources res = context.getResources();
|
||||
Configuration configuration = res.getConfiguration();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
configuration.setLocale(newLocale);
|
||||
LocaleList localeList = new LocaleList(newLocale);
|
||||
LocaleList.setDefault(localeList);
|
||||
configuration.setLocales(localeList);
|
||||
context = context.createConfigurationContext(configuration);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
configuration.setLocale(newLocale);
|
||||
context = context.createConfigurationContext(configuration);
|
||||
} else {
|
||||
configuration.locale = newLocale;
|
||||
res.updateConfiguration(configuration, res.getDisplayMetrics());
|
||||
}
|
||||
|
||||
return new ContextWrapper(context);
|
||||
}
|
||||
public static Context onAttach(Context context) {
|
||||
String lang = getPersistedData(context, Locale.getDefault().getLanguage());
|
||||
setLocale(context, lang);
|
||||
return context;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
</paths>
|
Loading…
Add table
Add a link
Reference in a new issue