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,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/gradient_end"
|
||||
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2L4.26,14zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8L5.08,8c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14L9.66,14c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.59,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z"/>
|
||||
</vector>
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -0,0 +1,197 @@
|
|||
package com.adins.mss.coll.fragments.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.coll.Navigator;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.commons.Generator;
|
||||
import com.adins.mss.coll.commons.Toaster;
|
||||
import com.adins.mss.coll.commons.ViewManager;
|
||||
import com.adins.mss.coll.interfaces.callback.DepositReportCallback;
|
||||
import com.adins.mss.coll.interfaces.DepositReportImpl;
|
||||
import com.adins.mss.coll.interfaces.DepositReportInterface;
|
||||
import com.adins.mss.coll.interfaces.NavigatorInterface;
|
||||
import com.adins.mss.coll.tool.Constants;
|
||||
import com.adins.mss.dao.DepositReportD;
|
||||
import com.adins.mss.dao.DepositReportH;
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by kusnendi.muhamad on 28/07/2017.
|
||||
*/
|
||||
|
||||
public class DepositReportRecapitulateView extends ViewManager {
|
||||
|
||||
protected double total = 0;
|
||||
|
||||
public String batchId;
|
||||
public Activity activity;
|
||||
|
||||
private View view;
|
||||
private int totalNeedPrint;
|
||||
private DepositReportInterface depositReport;
|
||||
List<TaskD> reportsReconcile = new ArrayList<TaskD>();
|
||||
|
||||
private TextView txtBatchId;
|
||||
private TextView txtTotal;
|
||||
|
||||
public DepositReportRecapitulateView(Activity activity) {
|
||||
super(activity);
|
||||
this.activity = activity;
|
||||
depositReport = new DepositReportImpl(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish() {
|
||||
depositReport.getReportsReconcile(this);
|
||||
}
|
||||
|
||||
public View layoutInflater(LayoutInflater inflater, ViewGroup container) {
|
||||
view = inflater.inflate(R.layout.new_fragment_deposit_report_recapitulate, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
txtBatchId = (TextView) view.findViewById(R.id.batchId);
|
||||
txtTotal = (TextView) view.findViewById(R.id.total);
|
||||
|
||||
txtBatchId.setText(Generator.generateBatchId(activity));
|
||||
batchId = txtBatchId.getText().toString().trim();
|
||||
txtTotal.setText(Tool.separateThousand(String.valueOf(total)));
|
||||
|
||||
Button transferButton = (Button) view.findViewById(R.id.btnTransfer);
|
||||
|
||||
transferButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
total = depositReport.sumOfItems(reportsReconcile);
|
||||
if(total!=0) doTransfer();
|
||||
else Toast.makeText(activity, activity.getString(R.string.transfer_failed), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getTotal() {
|
||||
txtTotal.setText(Tool.separateThousand(String.valueOf(total)));
|
||||
}
|
||||
|
||||
private void doTransfer() {
|
||||
ListView list = (ListView) view.findViewById(R.id.listRecapitulationDetail);
|
||||
if (list.getAdapter().getCount() == 0) {
|
||||
Toaster.warning(activity, activity.getString(R.string.nothing_to_report));
|
||||
return;
|
||||
}else if (totalNeedPrint > 0) {
|
||||
Toaster.warning(activity, activity.getString(R.string.prompt_printRV));
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal totalValue = new BigDecimal(total);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.KEY_BUND_BATCHID, batchId);
|
||||
bundle.putString("TOTAL_DEPOSIT", totalValue.toString());
|
||||
|
||||
|
||||
NavigatorInterface navigator = new Navigator(activity, bundle);
|
||||
navigator.route(Navigator.DEPOSIT_REPORT_TRANSFER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnLoadReconcileData(List<TaskD> reconcileReport, int totalNeedPrint) {
|
||||
this.reportsReconcile = reconcileReport;
|
||||
this.totalNeedPrint = totalNeedPrint;
|
||||
containerInit();
|
||||
}
|
||||
|
||||
private class RecapitulationListAdapter extends ArrayAdapter<TaskD> {
|
||||
private final TaskD[] originalItems;
|
||||
|
||||
public RecapitulationListAdapter(Context context, int resource, TaskD[] objects) {
|
||||
super(context, resource, objects);
|
||||
originalItems = objects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return super.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
|
||||
view = LayoutInflater.from(getContext()).inflate(R.layout.new_recapitulation_detail_item, parent, false);
|
||||
|
||||
TextView label = (TextView) view.findViewById(R.id.itemLabel);
|
||||
TextView value = (TextView) view.findViewById(R.id.itemValue);
|
||||
|
||||
if (position == getCount()-1) {
|
||||
total = depositReport.sumOfItems(new ArrayList<TaskD>(Arrays.asList(originalItems)));
|
||||
getTotal();
|
||||
}
|
||||
|
||||
TaskD item = getItem(position);
|
||||
if (!item.getText_answer().equals("0") && !item.getText_answer().equals("")) {
|
||||
label.setText(item.getTaskH().getAppl_no());
|
||||
value.setText(Tool.separateThousand(item.getText_answer()));
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
private class RecapitulationListAdapterDummy extends ArrayAdapter<TaskD> {
|
||||
|
||||
public RecapitulationListAdapterDummy(Context context, int resource) {
|
||||
super(context, resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
|
||||
view = LayoutInflater.from(getContext()).inflate(R.layout.new_recapitulation_detail_item, parent, false);
|
||||
|
||||
TextView label = (TextView) view.findViewById(R.id.itemLabel);
|
||||
TextView value = (TextView) view.findViewById(R.id.itemValue);
|
||||
|
||||
label.setText("Sample Batch1");
|
||||
value.setText(Tool.separateThousand(10000));
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
public void containerDummy(){
|
||||
ListView list = (ListView) view.findViewById(R.id.listRecapitulationDetail);
|
||||
list.setAdapter(new RecapitulationListAdapterDummy(activity, R.layout.new_recapitulation_detail_item));
|
||||
}
|
||||
public void containerInit(){
|
||||
ListView list = (ListView) view.findViewById(R.id.listRecapitulationDetail);
|
||||
list.setAdapter(new RecapitulationListAdapter(activity, R.layout.new_recapitulation_detail_item,
|
||||
reportsReconcile.toArray(new TaskD[reportsReconcile.size()])));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright (C) 2015 Paul Burke
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.adins.mss.base.todolist.form.helper;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
|
||||
/**
|
||||
* An implementation of {@link ItemTouchHelper.Callback} that enables basic drag & drop and
|
||||
* swipe-to-dismiss. Drag events are automatically started by an item long-press.<br/>
|
||||
* </br/>
|
||||
* Expects the <code>RecyclerView.Adapter</code> to listen for {@link
|
||||
* ItemTouchHelperAdapter} callbacks and the <code>RecyclerView.ViewHolder</code> to implement
|
||||
* {@link ItemTouchHelperViewHolder}.
|
||||
*
|
||||
* @author Paul Burke (ipaulpro)
|
||||
*/
|
||||
public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
|
||||
|
||||
public static final float ALPHA_FULL = 1.0f;
|
||||
|
||||
private final ItemTouchHelperAdapter mAdapter;
|
||||
|
||||
public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) {
|
||||
mAdapter = adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLongPressDragEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemViewSwipeEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
// Set movement flags based on the layout manager
|
||||
if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
|
||||
final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
|
||||
final int swipeFlags = 0;
|
||||
return makeMovementFlags(dragFlags, swipeFlags);
|
||||
} else {
|
||||
final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
|
||||
final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
|
||||
return makeMovementFlags(dragFlags, swipeFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) {
|
||||
if (source.getItemViewType() != target.getItemViewType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Notify the adapter of the move
|
||||
mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) {
|
||||
// Notify the adapter of the dismissal
|
||||
mAdapter.onItemDismiss(viewHolder.getAdapterPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
|
||||
// Fade out the view as it is swiped out of the parent's bounds
|
||||
final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
|
||||
viewHolder.itemView.setAlpha(alpha);
|
||||
viewHolder.itemView.setTranslationX(dX);
|
||||
} else {
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
|
||||
// We only want the active item to change
|
||||
if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
|
||||
if (viewHolder instanceof ItemTouchHelperViewHolder) {
|
||||
// Let the view holder know that this item is being moved or dragged
|
||||
ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder;
|
||||
itemViewHolder.onItemSelected();
|
||||
}
|
||||
}
|
||||
|
||||
super.onSelectedChanged(viewHolder, actionState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
super.clearView(recyclerView, viewHolder);
|
||||
|
||||
viewHolder.itemView.setAlpha(ALPHA_FULL);
|
||||
|
||||
if (viewHolder instanceof ItemTouchHelperViewHolder) {
|
||||
// Tell the view holder it's time to restore the idle state
|
||||
ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder;
|
||||
itemViewHolder.onItemClear();
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -0,0 +1,423 @@
|
|||
package com.adins.mss.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.ImageFormat;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.camera.Camera;
|
||||
import com.adins.mss.foundation.camera.ImageCallBack;
|
||||
import com.adins.mss.foundation.image.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by winy.firdasari on 14/01/2015.
|
||||
*/
|
||||
public class CameraPreviewActivity extends Activity {
|
||||
|
||||
// ---
|
||||
private static final int BACK_MENU_ID = Menu.FIRST;
|
||||
private static final int OPTIONS_MENU_ID = Menu.FIRST + 1;
|
||||
private static final int CAPTURE_MENU_ID = Menu.FIRST + 2;
|
||||
RelativeLayout container;
|
||||
Context context;
|
||||
boolean hasCamera;
|
||||
private Preview mPreview;
|
||||
private ListAdapter listPicSize;
|
||||
private int rotate = 0;
|
||||
private Button btCapture;
|
||||
private Activity activity;
|
||||
private int actualWidht = Utils.picWidth;
|
||||
private int actualHeight = Utils.picHeight;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Hide the window title.
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
context = this;
|
||||
mPreview = new Preview(this);
|
||||
setContentView(mPreview);
|
||||
hasCamera = Camera.checkCameraHardware(this);
|
||||
|
||||
setContentView(R.layout.camera_preview_layout);
|
||||
container = (RelativeLayout) findViewById(R.id.container);
|
||||
|
||||
LinearLayout previewContainer = (LinearLayout) findViewById(R.id.previewContainer);
|
||||
previewContainer.addView(mPreview);
|
||||
|
||||
btCapture = (Button) findViewById(R.id.btCaptureCam);
|
||||
|
||||
btCapture.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mPreview.mCamera.setAutoFocus();
|
||||
mPreview.mCamera.setFlashAuto();
|
||||
mPreview.mCamera.getPicture(new ImageCallBack() {
|
||||
@Override
|
||||
public void onPictureTaken(byte[] bytes, Object o) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Camera.BUND_KEY_IMAGE_BYTE, bytes);
|
||||
setResult(Global.REQUEST_CAMERA, intent);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
this.activity = 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 boolean getLCDSceenTipeLandscape() {
|
||||
boolean result = false;
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
String str_ScreenSize = "The Android Screen is: W="
|
||||
+ dm.widthPixels
|
||||
+ " x H="
|
||||
+ dm.heightPixels;
|
||||
|
||||
result = dm.widthPixels > dm.heightPixels;
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
menu.add(0, BACK_MENU_ID, 0, "Back");
|
||||
menu.add(0, OPTIONS_MENU_ID, 0, "Options");
|
||||
menu.add(0, CAPTURE_MENU_ID, 0, "Capture");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case BACK_MENU_ID:
|
||||
this.finish();
|
||||
return true;
|
||||
case OPTIONS_MENU_ID:
|
||||
this.showOptions();
|
||||
return true;
|
||||
case CAPTURE_MENU_ID:
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void showOptions() {
|
||||
this.loadSupportedPicSize();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Picture Size");
|
||||
builder.setSingleChoiceItems(listPicSize, -1, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
String resolution = (String) listPicSize.getItem(item);
|
||||
String[] sz = resolution.split("x");
|
||||
int w = Integer.parseInt(sz[0]);
|
||||
int h = Integer.parseInt(sz[1]);
|
||||
|
||||
mPreview.setPictureSize(w, h);
|
||||
mPreview.mCamera.getCamera().stopPreview();
|
||||
android.hardware.Camera.Size previewSize = mPreview.getOptimalPreviewSize(w, h);
|
||||
mPreview.setPreviewSize(previewSize.width, previewSize.height);
|
||||
mPreview.mCamera.getCamera().startPreview();
|
||||
try {
|
||||
dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.picture_resolution, resolution), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void loadSupportedPicSize() {
|
||||
if (listPicSize == null) {
|
||||
List<String> listSize = mPreview.getSupportedPictureSize();
|
||||
listPicSize = new ArrayAdapter<String>(this, R.layout.picture_size_list, listSize);
|
||||
}
|
||||
}
|
||||
|
||||
public class Preview extends SurfaceView implements SurfaceHolder.Callback {
|
||||
private SurfaceHolder mHolder;
|
||||
private Camera mCamera;
|
||||
|
||||
public Preview(Context context) {
|
||||
super(context);
|
||||
mHolder = getHolder();
|
||||
mHolder.addCallback(this);
|
||||
}
|
||||
|
||||
public List<String> getSupportedPictureSize() {
|
||||
List<android.hardware.Camera.Size> listSize = mCamera.getCamera().getParameters().getSupportedPictureSizes();
|
||||
List<String> listSizeStr = new ArrayList<>();
|
||||
|
||||
for (android.hardware.Camera.Size size : listSize) {
|
||||
listSizeStr.add(size.width + "x" + size.height);
|
||||
}
|
||||
|
||||
return listSizeStr;
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
try {
|
||||
android.hardware.Camera cam = android.hardware.Camera.open();
|
||||
mCamera = new Camera(context, activity, cam, cam.getParameters());
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
|
||||
// default to set picture size to lowest resolution
|
||||
List<android.hardware.Camera.Size> listSupportedSize = mCamera.getCamera().getParameters().getSupportedPictureSizes();
|
||||
if (listSupportedSize != null && !listSupportedSize.isEmpty()) {
|
||||
android.hardware.Camera.Size minimumSize = listSupportedSize.get(searchMostSuportedSizeFromParam(listSupportedSize));
|
||||
android.hardware.Camera.Parameters parameters = mCamera.getCamera().getParameters();
|
||||
parameters.setPictureSize(minimumSize.width, minimumSize.height);
|
||||
mCamera.getCamera().setParameters(parameters);
|
||||
}
|
||||
|
||||
try {
|
||||
mCamera.getCamera().setPreviewDisplay(holder);
|
||||
mCamera.getCamera().setFaceDetectionListener(new com.adins.mss.foundation.camera.FaceDetectionListener());
|
||||
mCamera.startFaceDetection();
|
||||
} catch (IOException exception) {
|
||||
mCamera.getCamera().release();
|
||||
mCamera = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int searchMostSuportedSizeFromParam(List<android.hardware.Camera.Size> listSupportedSize) {
|
||||
android.hardware.Camera.Size suportedSize;
|
||||
int idx = 0;
|
||||
//search for match w x h
|
||||
for (int i = 0; i < listSupportedSize.size(); i++) {
|
||||
if (listSupportedSize.get(i).width == actualWidht && listSupportedSize.get(i).height == actualHeight) {
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
//search for match h
|
||||
for (int i = 0; i < listSupportedSize.size(); i++) {
|
||||
if (listSupportedSize.get(i).height == actualHeight) {
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//search for match w
|
||||
for (int i = 0; i < listSupportedSize.size(); i++) {
|
||||
if (listSupportedSize.get(i).width == actualWidht) {
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return listSupportedSize.size() - 1;
|
||||
}
|
||||
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
mCamera.getCamera().stopPreview();
|
||||
mCamera.getCamera().release();
|
||||
mCamera = null;
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||
android.hardware.Camera.Parameters parameters = mCamera.getCamera().getParameters();
|
||||
android.hardware.Camera.Size resultSize = null;
|
||||
|
||||
try {
|
||||
resultSize = getOptimalPreviewSize(w, h);
|
||||
if (resultSize != null) {
|
||||
w = resultSize.width;
|
||||
h = resultSize.height;
|
||||
}
|
||||
if (resultSize != null)
|
||||
parameters.setPreviewSize(w, h);
|
||||
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
resultSize = null;
|
||||
}
|
||||
|
||||
parameters.setPictureFormat(ImageFormat.JPEG);
|
||||
parameters.setFocusMode(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO);
|
||||
parameters.setFlashMode(android.hardware.Camera.Parameters.FLASH_MODE_OFF);
|
||||
|
||||
if (resultSize != null) {
|
||||
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
|
||||
android.hardware.Camera.CameraInfo info =
|
||||
new android.hardware.Camera.CameraInfo();
|
||||
android.hardware.Camera.getCameraInfo(android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK, info);
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
case Surface.ROTATION_0:
|
||||
degrees = 0;
|
||||
break;
|
||||
case Surface.ROTATION_90:
|
||||
degrees = 90;
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
degrees = 180;
|
||||
break;
|
||||
case Surface.ROTATION_270:
|
||||
degrees = 270;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int result;
|
||||
if (info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||
result = (info.orientation + degrees) % 360;
|
||||
result = (360 - result) % 360; // compensate the mirror
|
||||
} else { // back-facing
|
||||
result = (info.orientation - degrees + 360) % 360;
|
||||
}
|
||||
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
rotate = 90;
|
||||
}
|
||||
|
||||
//khusus untuk device dengan lcd landscape, ex: htc chacha
|
||||
if (result == 90 && getLCDSceenTipeLandscape()) {
|
||||
result = 0;
|
||||
} else if (result == 0 && !getLCDSceenTipeLandscape()) {
|
||||
result = 270;
|
||||
} else if (result == 180 && !getLCDSceenTipeLandscape()) {
|
||||
result = 90;
|
||||
} else if (result == 270 && getLCDSceenTipeLandscape()) {
|
||||
result = 180;
|
||||
}
|
||||
|
||||
mCamera.getCamera().setDisplayOrientation(result);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
mCamera.getCamera().setParameters(parameters);
|
||||
mCamera.getCamera().setFaceDetectionListener(new com.adins.mss.foundation.camera.FaceDetectionListener());
|
||||
mCamera.startFaceDetection();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
parameters = mCamera.getCamera().getParameters();
|
||||
parameters.setPictureFormat(ImageFormat.JPEG);
|
||||
parameters.setFocusMode(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO);
|
||||
parameters.setFlashMode(android.hardware.Camera.Parameters.FLASH_MODE_AUTO);
|
||||
|
||||
try {
|
||||
mCamera.getCamera().setParameters(parameters);
|
||||
mCamera.getCamera().setFaceDetectionListener(new com.adins.mss.foundation.camera.FaceDetectionListener());
|
||||
mCamera.startFaceDetection();
|
||||
} catch (Exception e2) {
|
||||
parameters = mCamera.getCamera().getParameters();
|
||||
mCamera.getCamera().setParameters(parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mCamera.getCamera().startPreview();
|
||||
}
|
||||
|
||||
public void setPictureSize(int width, int height) {
|
||||
android.hardware.Camera.Parameters cp = mCamera.getCamera().getParameters();
|
||||
cp.setPictureSize(width, height);
|
||||
mCamera.getCamera().setParameters(cp);
|
||||
}
|
||||
|
||||
public android.hardware.Camera.Size getOptimalPreviewSize(int picWidth, int picHeight) {
|
||||
List<android.hardware.Camera.Size> sizes = mCamera.getCamera().getParameters().getSupportedPreviewSizes();
|
||||
final double ASPECT_TOLERANCE = 0.1;
|
||||
double targetRatio = (double) picWidth / picHeight;
|
||||
if (sizes == null)
|
||||
return null;
|
||||
|
||||
android.hardware.Camera.Size optimalSize = null;
|
||||
double minDiff = Double.MAX_VALUE;
|
||||
|
||||
int targetHeight = picHeight;
|
||||
|
||||
// Try to find an size match aspect ratio and size
|
||||
for (android.hardware.Camera.Size size : sizes) {
|
||||
double ratio = (double) size.width / size.height;
|
||||
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)
|
||||
continue;
|
||||
if (Math.abs(size.height - targetHeight) < minDiff) {
|
||||
optimalSize = size;
|
||||
minDiff = Math.abs(size.height - targetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot find the one match the aspect ratio, ignore the
|
||||
// requirement
|
||||
if (optimalSize == null) {
|
||||
minDiff = Double.MAX_VALUE;
|
||||
for (android.hardware.Camera.Size size : sizes) {
|
||||
if (Math.abs(size.height - targetHeight) < minDiff) {
|
||||
optimalSize = size;
|
||||
minDiff = Math.abs(size.height - targetHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimalSize;
|
||||
}
|
||||
|
||||
public void setPreviewSize(int width, int height) {
|
||||
android.hardware.Camera.Parameters cp = mCamera.getCamera().getParameters();
|
||||
cp.setPreviewSize(width, height);
|
||||
mCamera.getCamera().setParameters(cp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/location_information_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bgColorWhite">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/location_icon"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:background="@drawable/ic_location_on_blue_24dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/use_your_location"
|
||||
android:textColor="#000000"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/location_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/explanation_one"
|
||||
android:layout_width="330dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/location_explanation"
|
||||
android:textColor="#353635"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/map_with_pin_image_container"
|
||||
app:layout_constraintBottom_toTopOf="@id/termAndCondition"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/termAndCondition"
|
||||
android:layout_width="330dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
app:layout_constraintBottom_toTopOf="@id/turn_on_text"
|
||||
app:layout_constraintHorizontal_bias="0.506"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/explanation_one">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/PrivacyAndPolicyText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:text="@string/privacyAndPolicy"
|
||||
android:textColor="#0645AD"
|
||||
android:textSize="14sp"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="|"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/termAndConditionText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:text="@string/termAndCondition"
|
||||
android:textColor="#0645AD"
|
||||
android:textSize="14sp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/map_with_pin_image_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="20dp"
|
||||
android:elevation="10dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_text"
|
||||
app:layout_constraintBottom_toTopOf="@id/explanation_one">
|
||||
<ImageView
|
||||
android:id="@+id/map_with_pin_image"
|
||||
android:layout_width="220dp"
|
||||
android:layout_height="220dp"
|
||||
android:background="@drawable/map_with_pin_vector"
|
||||
/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/turn_on_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:background="@drawable/button_background2"
|
||||
android:text="@string/turn_on"
|
||||
android:textColor="#ffff"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:gravity="center"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,756 @@
|
|||
package com.adins.mss.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import android.database.Cursor;
|
||||
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import de.greenrobot.dao.internal.SqlUtils;
|
||||
import de.greenrobot.dao.internal.DaoConfig;
|
||||
import de.greenrobot.dao.database.Database;
|
||||
import de.greenrobot.dao.database.DatabaseStatement;
|
||||
import de.greenrobot.dao.query.Query;
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
import com.adins.mss.dao.TaskH;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "TR_TASK_H".
|
||||
*/
|
||||
public class TaskHDao extends AbstractDao<TaskH, String> {
|
||||
|
||||
public static final String TABLENAME = "TR_TASK_H";
|
||||
|
||||
/**
|
||||
* Properties of entity TaskH.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Uuid_task_h = new Property(0, String.class, "uuid_task_h", true, "UUID_TASK_H");
|
||||
public final static Property Task_id = new Property(1, String.class, "task_id", false, "TASK_ID");
|
||||
public final static Property Status = new Property(2, String.class, "status", false, "STATUS");
|
||||
public final static Property Is_printable = new Property(3, String.class, "is_printable", false, "IS_PRINTABLE");
|
||||
public final static Property Customer_name = new Property(4, String.class, "customer_name", false, "CUSTOMER_NAME");
|
||||
public final static Property Customer_phone = new Property(5, String.class, "customer_phone", false, "CUSTOMER_PHONE");
|
||||
public final static Property Customer_address = new Property(6, String.class, "customer_address", false, "CUSTOMER_ADDRESS");
|
||||
public final static Property Notes = new Property(7, String.class, "notes", false, "NOTES");
|
||||
public final static Property Submit_date = new Property(8, java.util.Date.class, "submit_date", false, "SUBMIT_DATE");
|
||||
public final static Property Submit_duration = new Property(9, String.class, "submit_duration", false, "SUBMIT_DURATION");
|
||||
public final static Property Submit_size = new Property(10, String.class, "submit_size", false, "SUBMIT_SIZE");
|
||||
public final static Property Submit_result = new Property(11, String.class, "submit_result", false, "SUBMIT_RESULT");
|
||||
public final static Property Assignment_date = new Property(12, java.util.Date.class, "assignment_date", false, "ASSIGNMENT_DATE");
|
||||
public final static Property Print_count = new Property(13, Integer.class, "print_count", false, "PRINT_COUNT");
|
||||
public final static Property Draft_date = new Property(14, java.util.Date.class, "draft_date", false, "DRAFT_DATE");
|
||||
public final static Property Usr_crt = new Property(15, String.class, "usr_crt", false, "USR_CRT");
|
||||
public final static Property Dtm_crt = new Property(16, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
|
||||
public final static Property Priority = new Property(17, String.class, "priority", false, "PRIORITY");
|
||||
public final static Property Latitude = new Property(18, String.class, "latitude", false, "LATITUDE");
|
||||
public final static Property Longitude = new Property(19, String.class, "longitude", false, "LONGITUDE");
|
||||
public final static Property Scheme_last_update = new Property(20, java.util.Date.class, "scheme_last_update", false, "SCHEME_LAST_UPDATE");
|
||||
public final static Property Is_verification = new Property(21, String.class, "is_verification", false, "IS_VERIFICATION");
|
||||
public final static Property Is_preview_server = new Property(22, String.class, "is_preview_server", false, "IS_PREVIEW_SERVER");
|
||||
public final static Property Uuid_user = new Property(23, String.class, "uuid_user", false, "UUID_USER");
|
||||
public final static Property Voice_note = new Property(24, byte[].class, "voice_note", false, "VOICE_NOTE");
|
||||
public final static Property Uuid_scheme = new Property(25, String.class, "uuid_scheme", false, "UUID_SCHEME");
|
||||
public final static Property Zip_code = new Property(26, String.class, "zip_code", false, "ZIP_CODE");
|
||||
public final static Property Start_date = new Property(27, java.util.Date.class, "start_date", false, "START_DATE");
|
||||
public final static Property Open_date = new Property(28, java.util.Date.class, "open_date", false, "OPEN_DATE");
|
||||
public final static Property Appl_no = new Property(29, String.class, "appl_no", false, "APPL_NO");
|
||||
public final static Property Is_prepocessed = new Property(30, String.class, "is_prepocessed", false, "IS_PREPOCESSED");
|
||||
public final static Property Last_saved_question = new Property(31, Integer.class, "last_saved_question", false, "LAST_SAVED_QUESTION");
|
||||
public final static Property Is_reconciled = new Property(32, String.class, "is_reconciled", false, "IS_RECONCILED");
|
||||
public final static Property Pts_date = new Property(33, java.util.Date.class, "pts_date", false, "PTS_DATE");
|
||||
public final static Property Access_mode = new Property(34, String.class, "access_mode", false, "ACCESS_MODE");
|
||||
public final static Property Rv_number = new Property(35, String.class, "rv_number", false, "RV_NUMBER");
|
||||
public final static Property Status_rv = new Property(36, String.class, "status_rv", false, "STATUS_RV");
|
||||
public final static Property No_rangka = new Property(37, String.class, "no_rangka", false, "NO_RANGKA");
|
||||
public final static Property No_plat = new Property(38, String.class, "no_plat", false, "NO_PLAT");
|
||||
public final static Property No_mesin = new Property(39, String.class, "no_mesin", false, "NO_MESIN");
|
||||
public final static Property Flag = new Property(40, String.class, "flag", false, "FLAG");
|
||||
public final static Property Message = new Property(41, String.class, "message", false, "MESSAGE");
|
||||
public final static Property Form_version = new Property(42, String.class, "form_version", false, "FORM_VERSION");
|
||||
public final static Property Flag_survey = new Property(43, String.class, "flag_survey", false, "FLAG_SURVEY");
|
||||
public final static Property Uuid_resurvey_user = new Property(44, String.class, "uuid_resurvey_user", false, "UUID_RESURVEY_USER");
|
||||
public final static Property Resurvey_suggested = new Property(45, String.class, "resurvey_suggested", false, "RESURVEY_SUGGESTED");
|
||||
public final static Property Verification_notes = new Property(46, String.class, "verification_notes", false, "VERIFICATION_NOTES");
|
||||
public final static Property Od = new Property(47, String.class, "od", false, "OD");
|
||||
public final static Property Amt_due = new Property(48, String.class, "amt_due", false, "AMT_DUE");
|
||||
public final static Property Inst_no = new Property(49, String.class, "inst_no", false, "INST_NO");
|
||||
public final static Property Status_code = new Property(50, String.class, "status_code", false, "STATUS_CODE");
|
||||
public final static Property Uuid_account = new Property(51, String.class, "uuid_account", false, "UUID_ACCOUNT");
|
||||
public final static Property Uuid_product = new Property(52, String.class, "uuid_product", false, "UUID_PRODUCT");
|
||||
public final static Property Reference_number = new Property(53, String.class, "reference_number", false, "REFERENCE_NUMBER");
|
||||
public final static Property Data_dukcapil = new Property(54, String.class, "data_dukcapil", false, "DATA_DUKCAPIL");
|
||||
public final static Property Seq_no = new Property(55, Integer.class, "seq_no", false, "SEQ_NO");
|
||||
public final static Property Batch_id = new Property(56, String.class, "batch_id", false, "BATCH_ID");
|
||||
public final static Property Survey_location = new Property(57, String.class, "survey_location", false, "SURVEY_LOCATION");
|
||||
};
|
||||
|
||||
private DaoSession daoSession;
|
||||
|
||||
private Query<TaskH> user_TaskHListQuery;
|
||||
private Query<TaskH> scheme_TaskHListQuery;
|
||||
|
||||
public TaskHDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public TaskHDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
this.daoSession = daoSession;
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"TR_TASK_H\" (" + //
|
||||
"\"UUID_TASK_H\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_task_h
|
||||
"\"TASK_ID\" TEXT," + // 1: task_id
|
||||
"\"STATUS\" TEXT," + // 2: status
|
||||
"\"IS_PRINTABLE\" TEXT," + // 3: is_printable
|
||||
"\"CUSTOMER_NAME\" TEXT," + // 4: customer_name
|
||||
"\"CUSTOMER_PHONE\" TEXT," + // 5: customer_phone
|
||||
"\"CUSTOMER_ADDRESS\" TEXT," + // 6: customer_address
|
||||
"\"NOTES\" TEXT," + // 7: notes
|
||||
"\"SUBMIT_DATE\" INTEGER," + // 8: submit_date
|
||||
"\"SUBMIT_DURATION\" TEXT," + // 9: submit_duration
|
||||
"\"SUBMIT_SIZE\" TEXT," + // 10: submit_size
|
||||
"\"SUBMIT_RESULT\" TEXT," + // 11: submit_result
|
||||
"\"ASSIGNMENT_DATE\" INTEGER," + // 12: assignment_date
|
||||
"\"PRINT_COUNT\" INTEGER," + // 13: print_count
|
||||
"\"DRAFT_DATE\" INTEGER," + // 14: draft_date
|
||||
"\"USR_CRT\" TEXT," + // 15: usr_crt
|
||||
"\"DTM_CRT\" INTEGER," + // 16: dtm_crt
|
||||
"\"PRIORITY\" TEXT," + // 17: priority
|
||||
"\"LATITUDE\" TEXT," + // 18: latitude
|
||||
"\"LONGITUDE\" TEXT," + // 19: longitude
|
||||
"\"SCHEME_LAST_UPDATE\" INTEGER," + // 20: scheme_last_update
|
||||
"\"IS_VERIFICATION\" TEXT," + // 21: is_verification
|
||||
"\"IS_PREVIEW_SERVER\" TEXT," + // 22: is_preview_server
|
||||
"\"UUID_USER\" TEXT," + // 23: uuid_user
|
||||
"\"VOICE_NOTE\" BLOB," + // 24: voice_note
|
||||
"\"UUID_SCHEME\" TEXT," + // 25: uuid_scheme
|
||||
"\"ZIP_CODE\" TEXT," + // 26: zip_code
|
||||
"\"START_DATE\" INTEGER," + // 27: start_date
|
||||
"\"OPEN_DATE\" INTEGER," + // 28: open_date
|
||||
"\"APPL_NO\" TEXT," + // 29: appl_no
|
||||
"\"IS_PREPOCESSED\" TEXT," + // 30: is_prepocessed
|
||||
"\"LAST_SAVED_QUESTION\" INTEGER," + // 31: last_saved_question
|
||||
"\"IS_RECONCILED\" TEXT," + // 32: is_reconciled
|
||||
"\"PTS_DATE\" INTEGER," + // 33: pts_date
|
||||
"\"ACCESS_MODE\" TEXT," + // 34: access_mode
|
||||
"\"RV_NUMBER\" TEXT," + // 35: rv_number
|
||||
"\"STATUS_RV\" TEXT," + // 36: status_rv
|
||||
"\"NO_RANGKA\" TEXT," + // 37: no_rangka
|
||||
"\"NO_PLAT\" TEXT," + // 38: no_plat
|
||||
"\"NO_MESIN\" TEXT," + // 39: no_mesin
|
||||
"\"FLAG\" TEXT," + // 40: flag
|
||||
"\"MESSAGE\" TEXT," + // 41: message
|
||||
"\"FORM_VERSION\" TEXT," + // 42: form_version
|
||||
"\"FLAG_SURVEY\" TEXT," + // 43: flag_survey
|
||||
"\"UUID_RESURVEY_USER\" TEXT," + // 44: uuid_resurvey_user
|
||||
"\"RESURVEY_SUGGESTED\" TEXT," + // 45: resurvey_suggested
|
||||
"\"VERIFICATION_NOTES\" TEXT," + // 46: verification_notes
|
||||
"\"OD\" TEXT," + // 47: od
|
||||
"\"AMT_DUE\" TEXT," + // 48: amt_due
|
||||
"\"INST_NO\" TEXT," + // 49: inst_no
|
||||
"\"STATUS_CODE\" TEXT," + // 50: status_code
|
||||
"\"UUID_ACCOUNT\" TEXT," + // 51: uuid_account
|
||||
"\"UUID_PRODUCT\" TEXT," + // 52: uuid_product
|
||||
"\"REFERENCE_NUMBER\" TEXT," + // 53: reference_number
|
||||
"\"DATA_DUKCAPIL\" TEXT," + // 54: data_dukcapil
|
||||
"\"SEQ_NO\" INTEGER," + // 55: seq_no
|
||||
"\"BATCH_ID\" TEXT," + // 56: batch_id
|
||||
"\"SURVEY_LOCATION\" TEXT);"); // 57: survey_location
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_TASK_H\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected void bindValues(DatabaseStatement stmt, TaskH entity) {
|
||||
stmt.clearBindings();
|
||||
stmt.bindString(1, entity.getUuid_task_h());
|
||||
|
||||
String task_id = entity.getTask_id();
|
||||
if (task_id != null) {
|
||||
stmt.bindString(2, task_id);
|
||||
}
|
||||
|
||||
String status = entity.getStatus();
|
||||
if (status != null) {
|
||||
stmt.bindString(3, status);
|
||||
}
|
||||
|
||||
String is_printable = entity.getIs_printable();
|
||||
if (is_printable != null) {
|
||||
stmt.bindString(4, is_printable);
|
||||
}
|
||||
|
||||
String customer_name = entity.getCustomer_name();
|
||||
if (customer_name != null) {
|
||||
stmt.bindString(5, customer_name);
|
||||
}
|
||||
|
||||
String customer_phone = entity.getCustomer_phone();
|
||||
if (customer_phone != null) {
|
||||
stmt.bindString(6, customer_phone);
|
||||
}
|
||||
|
||||
String customer_address = entity.getCustomer_address();
|
||||
if (customer_address != null) {
|
||||
stmt.bindString(7, customer_address);
|
||||
}
|
||||
|
||||
String notes = entity.getNotes();
|
||||
if (notes != null) {
|
||||
stmt.bindString(8, notes);
|
||||
}
|
||||
|
||||
java.util.Date submit_date = entity.getSubmit_date();
|
||||
if (submit_date != null) {
|
||||
stmt.bindLong(9, submit_date.getTime());
|
||||
}
|
||||
|
||||
String submit_duration = entity.getSubmit_duration();
|
||||
if (submit_duration != null) {
|
||||
stmt.bindString(10, submit_duration);
|
||||
}
|
||||
|
||||
String submit_size = entity.getSubmit_size();
|
||||
if (submit_size != null) {
|
||||
stmt.bindString(11, submit_size);
|
||||
}
|
||||
|
||||
String submit_result = entity.getSubmit_result();
|
||||
if (submit_result != null) {
|
||||
stmt.bindString(12, submit_result);
|
||||
}
|
||||
|
||||
java.util.Date assignment_date = entity.getAssignment_date();
|
||||
if (assignment_date != null) {
|
||||
stmt.bindLong(13, assignment_date.getTime());
|
||||
}
|
||||
|
||||
Integer print_count = entity.getPrint_count();
|
||||
if (print_count != null) {
|
||||
stmt.bindLong(14, print_count);
|
||||
}
|
||||
|
||||
java.util.Date draft_date = entity.getDraft_date();
|
||||
if (draft_date != null) {
|
||||
stmt.bindLong(15, draft_date.getTime());
|
||||
}
|
||||
|
||||
String usr_crt = entity.getUsr_crt();
|
||||
if (usr_crt != null) {
|
||||
stmt.bindString(16, usr_crt);
|
||||
}
|
||||
|
||||
java.util.Date dtm_crt = entity.getDtm_crt();
|
||||
if (dtm_crt != null) {
|
||||
stmt.bindLong(17, dtm_crt.getTime());
|
||||
}
|
||||
|
||||
String priority = entity.getPriority();
|
||||
if (priority != null) {
|
||||
stmt.bindString(18, priority);
|
||||
}
|
||||
|
||||
String latitude = entity.getLatitude();
|
||||
if (latitude != null) {
|
||||
stmt.bindString(19, latitude);
|
||||
}
|
||||
|
||||
String longitude = entity.getLongitude();
|
||||
if (longitude != null) {
|
||||
stmt.bindString(20, longitude);
|
||||
}
|
||||
|
||||
java.util.Date scheme_last_update = entity.getScheme_last_update();
|
||||
if (scheme_last_update != null) {
|
||||
stmt.bindLong(21, scheme_last_update.getTime());
|
||||
}
|
||||
|
||||
String is_verification = entity.getIs_verification();
|
||||
if (is_verification != null) {
|
||||
stmt.bindString(22, is_verification);
|
||||
}
|
||||
|
||||
String is_preview_server = entity.getIs_preview_server();
|
||||
if (is_preview_server != null) {
|
||||
stmt.bindString(23, is_preview_server);
|
||||
}
|
||||
|
||||
String uuid_user = entity.getUuid_user();
|
||||
if (uuid_user != null) {
|
||||
stmt.bindString(24, uuid_user);
|
||||
}
|
||||
|
||||
byte[] voice_note = entity.getVoice_note();
|
||||
if (voice_note != null) {
|
||||
stmt.bindBlob(25, voice_note);
|
||||
}
|
||||
|
||||
String uuid_scheme = entity.getUuid_scheme();
|
||||
if (uuid_scheme != null) {
|
||||
stmt.bindString(26, uuid_scheme);
|
||||
}
|
||||
|
||||
String zip_code = entity.getZip_code();
|
||||
if (zip_code != null) {
|
||||
stmt.bindString(27, zip_code);
|
||||
}
|
||||
|
||||
java.util.Date start_date = entity.getStart_date();
|
||||
if (start_date != null) {
|
||||
stmt.bindLong(28, start_date.getTime());
|
||||
}
|
||||
|
||||
java.util.Date open_date = entity.getOpen_date();
|
||||
if (open_date != null) {
|
||||
stmt.bindLong(29, open_date.getTime());
|
||||
}
|
||||
|
||||
String appl_no = entity.getAppl_no();
|
||||
if (appl_no != null) {
|
||||
stmt.bindString(30, appl_no);
|
||||
}
|
||||
|
||||
String is_prepocessed = entity.getIs_prepocessed();
|
||||
if (is_prepocessed != null) {
|
||||
stmt.bindString(31, is_prepocessed);
|
||||
}
|
||||
|
||||
Integer last_saved_question = entity.getLast_saved_question();
|
||||
if (last_saved_question != null) {
|
||||
stmt.bindLong(32, last_saved_question);
|
||||
}
|
||||
|
||||
String is_reconciled = entity.getIs_reconciled();
|
||||
if (is_reconciled != null) {
|
||||
stmt.bindString(33, is_reconciled);
|
||||
}
|
||||
|
||||
java.util.Date pts_date = entity.getPts_date();
|
||||
if (pts_date != null) {
|
||||
stmt.bindLong(34, pts_date.getTime());
|
||||
}
|
||||
|
||||
String access_mode = entity.getAccess_mode();
|
||||
if (access_mode != null) {
|
||||
stmt.bindString(35, access_mode);
|
||||
}
|
||||
|
||||
String rv_number = entity.getRv_number();
|
||||
if (rv_number != null) {
|
||||
stmt.bindString(36, rv_number);
|
||||
}
|
||||
|
||||
String status_rv = entity.getStatus_rv();
|
||||
if (status_rv != null) {
|
||||
stmt.bindString(37, status_rv);
|
||||
}
|
||||
|
||||
String no_rangka = entity.getNo_rangka();
|
||||
if (no_rangka != null) {
|
||||
stmt.bindString(38, no_rangka);
|
||||
}
|
||||
|
||||
String no_plat = entity.getNo_plat();
|
||||
if (no_plat != null) {
|
||||
stmt.bindString(39, no_plat);
|
||||
}
|
||||
|
||||
String no_mesin = entity.getNo_mesin();
|
||||
if (no_mesin != null) {
|
||||
stmt.bindString(40, no_mesin);
|
||||
}
|
||||
|
||||
String flag = entity.getFlag();
|
||||
if (flag != null) {
|
||||
stmt.bindString(41, flag);
|
||||
}
|
||||
|
||||
String message = entity.getMessage();
|
||||
if (message != null) {
|
||||
stmt.bindString(42, message);
|
||||
}
|
||||
|
||||
String form_version = entity.getForm_version();
|
||||
if (form_version != null) {
|
||||
stmt.bindString(43, form_version);
|
||||
}
|
||||
|
||||
String flag_survey = entity.getFlag_survey();
|
||||
if (flag_survey != null) {
|
||||
stmt.bindString(44, flag_survey);
|
||||
}
|
||||
|
||||
String uuid_resurvey_user = entity.getUuid_resurvey_user();
|
||||
if (uuid_resurvey_user != null) {
|
||||
stmt.bindString(45, uuid_resurvey_user);
|
||||
}
|
||||
|
||||
String resurvey_suggested = entity.getResurvey_suggested();
|
||||
if (resurvey_suggested != null) {
|
||||
stmt.bindString(46, resurvey_suggested);
|
||||
}
|
||||
|
||||
String verification_notes = entity.getVerification_notes();
|
||||
if (verification_notes != null) {
|
||||
stmt.bindString(47, verification_notes);
|
||||
}
|
||||
|
||||
String od = entity.getOd();
|
||||
if (od != null) {
|
||||
stmt.bindString(48, od);
|
||||
}
|
||||
|
||||
String amt_due = entity.getAmt_due();
|
||||
if (amt_due != null) {
|
||||
stmt.bindString(49, amt_due);
|
||||
}
|
||||
|
||||
String inst_no = entity.getInst_no();
|
||||
if (inst_no != null) {
|
||||
stmt.bindString(50, inst_no);
|
||||
}
|
||||
|
||||
String status_code = entity.getStatus_code();
|
||||
if (status_code != null) {
|
||||
stmt.bindString(51, status_code);
|
||||
}
|
||||
|
||||
String uuid_account = entity.getUuid_account();
|
||||
if (uuid_account != null) {
|
||||
stmt.bindString(52, uuid_account);
|
||||
}
|
||||
|
||||
String uuid_product = entity.getUuid_product();
|
||||
if (uuid_product != null) {
|
||||
stmt.bindString(53, uuid_product);
|
||||
}
|
||||
|
||||
String reference_number = entity.getReference_number();
|
||||
if (reference_number != null) {
|
||||
stmt.bindString(54, reference_number);
|
||||
}
|
||||
|
||||
String data_dukcapil = entity.getData_dukcapil();
|
||||
if (data_dukcapil != null) {
|
||||
stmt.bindString(55, data_dukcapil);
|
||||
}
|
||||
|
||||
Integer seq_no = entity.getSeq_no();
|
||||
if (seq_no != null) {
|
||||
stmt.bindLong(56, seq_no);
|
||||
}
|
||||
|
||||
String batch_id = entity.getBatch_id();
|
||||
if (batch_id != null) {
|
||||
stmt.bindString(57, batch_id);
|
||||
}
|
||||
|
||||
String survey_location = entity.getSurvey_location();
|
||||
if (survey_location != null) {
|
||||
stmt.bindString(58, survey_location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachEntity(TaskH entity) {
|
||||
super.attachEntity(entity);
|
||||
entity.__setDaoSession(daoSession);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public TaskH readEntity(Cursor cursor, int offset) {
|
||||
TaskH entity = new TaskH( //
|
||||
cursor.getString(offset + 0), // uuid_task_h
|
||||
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // task_id
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // status
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // is_printable
|
||||
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // customer_name
|
||||
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // customer_phone
|
||||
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // customer_address
|
||||
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // notes
|
||||
cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)), // submit_date
|
||||
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // submit_duration
|
||||
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // submit_size
|
||||
cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // submit_result
|
||||
cursor.isNull(offset + 12) ? null : new java.util.Date(cursor.getLong(offset + 12)), // assignment_date
|
||||
cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13), // print_count
|
||||
cursor.isNull(offset + 14) ? null : new java.util.Date(cursor.getLong(offset + 14)), // draft_date
|
||||
cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // usr_crt
|
||||
cursor.isNull(offset + 16) ? null : new java.util.Date(cursor.getLong(offset + 16)), // dtm_crt
|
||||
cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // priority
|
||||
cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // latitude
|
||||
cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // longitude
|
||||
cursor.isNull(offset + 20) ? null : new java.util.Date(cursor.getLong(offset + 20)), // scheme_last_update
|
||||
cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // is_verification
|
||||
cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // is_preview_server
|
||||
cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // uuid_user
|
||||
cursor.isNull(offset + 24) ? null : cursor.getBlob(offset + 24), // voice_note
|
||||
cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // uuid_scheme
|
||||
cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26), // zip_code
|
||||
cursor.isNull(offset + 27) ? null : new java.util.Date(cursor.getLong(offset + 27)), // start_date
|
||||
cursor.isNull(offset + 28) ? null : new java.util.Date(cursor.getLong(offset + 28)), // open_date
|
||||
cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29), // appl_no
|
||||
cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30), // is_prepocessed
|
||||
cursor.isNull(offset + 31) ? null : cursor.getInt(offset + 31), // last_saved_question
|
||||
cursor.isNull(offset + 32) ? null : cursor.getString(offset + 32), // is_reconciled
|
||||
cursor.isNull(offset + 33) ? null : new java.util.Date(cursor.getLong(offset + 33)), // pts_date
|
||||
cursor.isNull(offset + 34) ? null : cursor.getString(offset + 34), // access_mode
|
||||
cursor.isNull(offset + 35) ? null : cursor.getString(offset + 35), // rv_number
|
||||
cursor.isNull(offset + 36) ? null : cursor.getString(offset + 36), // status_rv
|
||||
cursor.isNull(offset + 37) ? null : cursor.getString(offset + 37), // no_rangka
|
||||
cursor.isNull(offset + 38) ? null : cursor.getString(offset + 38), // no_plat
|
||||
cursor.isNull(offset + 39) ? null : cursor.getString(offset + 39), // no_mesin
|
||||
cursor.isNull(offset + 40) ? null : cursor.getString(offset + 40), // flag
|
||||
cursor.isNull(offset + 41) ? null : cursor.getString(offset + 41), // message
|
||||
cursor.isNull(offset + 42) ? null : cursor.getString(offset + 42), // form_version
|
||||
cursor.isNull(offset + 43) ? null : cursor.getString(offset + 43), // flag_survey
|
||||
cursor.isNull(offset + 44) ? null : cursor.getString(offset + 44), // uuid_resurvey_user
|
||||
cursor.isNull(offset + 45) ? null : cursor.getString(offset + 45), // resurvey_suggested
|
||||
cursor.isNull(offset + 46) ? null : cursor.getString(offset + 46), // verification_notes
|
||||
cursor.isNull(offset + 47) ? null : cursor.getString(offset + 47), // od
|
||||
cursor.isNull(offset + 48) ? null : cursor.getString(offset + 48), // amt_due
|
||||
cursor.isNull(offset + 49) ? null : cursor.getString(offset + 49), // inst_no
|
||||
cursor.isNull(offset + 50) ? null : cursor.getString(offset + 50), // status_code
|
||||
cursor.isNull(offset + 51) ? null : cursor.getString(offset + 51), // uuid_account
|
||||
cursor.isNull(offset + 52) ? null : cursor.getString(offset + 52), // uuid_product
|
||||
cursor.isNull(offset + 53) ? null : cursor.getString(offset + 53), // reference_number
|
||||
cursor.isNull(offset + 54) ? null : cursor.getString(offset + 54), // data_dukcapil
|
||||
cursor.isNull(offset + 55) ? null : cursor.getInt(offset + 55), // seq_no
|
||||
cursor.isNull(offset + 56) ? null : cursor.getString(offset + 56), // batch_id
|
||||
cursor.isNull(offset + 57) ? null : cursor.getString(offset + 57) // survey_location
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, TaskH entity, int offset) {
|
||||
entity.setUuid_task_h(cursor.getString(offset + 0));
|
||||
entity.setTask_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
|
||||
entity.setStatus(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setIs_printable(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
entity.setCustomer_name(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
|
||||
entity.setCustomer_phone(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
|
||||
entity.setCustomer_address(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
|
||||
entity.setNotes(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
|
||||
entity.setSubmit_date(cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)));
|
||||
entity.setSubmit_duration(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
|
||||
entity.setSubmit_size(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
|
||||
entity.setSubmit_result(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
|
||||
entity.setAssignment_date(cursor.isNull(offset + 12) ? null : new java.util.Date(cursor.getLong(offset + 12)));
|
||||
entity.setPrint_count(cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13));
|
||||
entity.setDraft_date(cursor.isNull(offset + 14) ? null : new java.util.Date(cursor.getLong(offset + 14)));
|
||||
entity.setUsr_crt(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
|
||||
entity.setDtm_crt(cursor.isNull(offset + 16) ? null : new java.util.Date(cursor.getLong(offset + 16)));
|
||||
entity.setPriority(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
|
||||
entity.setLatitude(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
|
||||
entity.setLongitude(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
|
||||
entity.setScheme_last_update(cursor.isNull(offset + 20) ? null : new java.util.Date(cursor.getLong(offset + 20)));
|
||||
entity.setIs_verification(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
|
||||
entity.setIs_preview_server(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22));
|
||||
entity.setUuid_user(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23));
|
||||
entity.setVoice_note(cursor.isNull(offset + 24) ? null : cursor.getBlob(offset + 24));
|
||||
entity.setUuid_scheme(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25));
|
||||
entity.setZip_code(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26));
|
||||
entity.setStart_date(cursor.isNull(offset + 27) ? null : new java.util.Date(cursor.getLong(offset + 27)));
|
||||
entity.setOpen_date(cursor.isNull(offset + 28) ? null : new java.util.Date(cursor.getLong(offset + 28)));
|
||||
entity.setAppl_no(cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29));
|
||||
entity.setIs_prepocessed(cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30));
|
||||
entity.setLast_saved_question(cursor.isNull(offset + 31) ? null : cursor.getInt(offset + 31));
|
||||
entity.setIs_reconciled(cursor.isNull(offset + 32) ? null : cursor.getString(offset + 32));
|
||||
entity.setPts_date(cursor.isNull(offset + 33) ? null : new java.util.Date(cursor.getLong(offset + 33)));
|
||||
entity.setAccess_mode(cursor.isNull(offset + 34) ? null : cursor.getString(offset + 34));
|
||||
entity.setRv_number(cursor.isNull(offset + 35) ? null : cursor.getString(offset + 35));
|
||||
entity.setStatus_rv(cursor.isNull(offset + 36) ? null : cursor.getString(offset + 36));
|
||||
entity.setNo_rangka(cursor.isNull(offset + 37) ? null : cursor.getString(offset + 37));
|
||||
entity.setNo_plat(cursor.isNull(offset + 38) ? null : cursor.getString(offset + 38));
|
||||
entity.setNo_mesin(cursor.isNull(offset + 39) ? null : cursor.getString(offset + 39));
|
||||
entity.setFlag(cursor.isNull(offset + 40) ? null : cursor.getString(offset + 40));
|
||||
entity.setMessage(cursor.isNull(offset + 41) ? null : cursor.getString(offset + 41));
|
||||
entity.setForm_version(cursor.isNull(offset + 42) ? null : cursor.getString(offset + 42));
|
||||
entity.setFlag_survey(cursor.isNull(offset + 43) ? null : cursor.getString(offset + 43));
|
||||
entity.setUuid_resurvey_user(cursor.isNull(offset + 44) ? null : cursor.getString(offset + 44));
|
||||
entity.setResurvey_suggested(cursor.isNull(offset + 45) ? null : cursor.getString(offset + 45));
|
||||
entity.setVerification_notes(cursor.isNull(offset + 46) ? null : cursor.getString(offset + 46));
|
||||
entity.setOd(cursor.isNull(offset + 47) ? null : cursor.getString(offset + 47));
|
||||
entity.setAmt_due(cursor.isNull(offset + 48) ? null : cursor.getString(offset + 48));
|
||||
entity.setInst_no(cursor.isNull(offset + 49) ? null : cursor.getString(offset + 49));
|
||||
entity.setStatus_code(cursor.isNull(offset + 50) ? null : cursor.getString(offset + 50));
|
||||
entity.setUuid_account(cursor.isNull(offset + 51) ? null : cursor.getString(offset + 51));
|
||||
entity.setUuid_product(cursor.isNull(offset + 52) ? null : cursor.getString(offset + 52));
|
||||
entity.setReference_number(cursor.isNull(offset + 53) ? null : cursor.getString(offset + 53));
|
||||
entity.setData_dukcapil(cursor.isNull(offset + 54) ? null : cursor.getString(offset + 54));
|
||||
entity.setSeq_no(cursor.isNull(offset + 55) ? null : cursor.getInt(offset + 55));
|
||||
entity.setBatch_id(cursor.isNull(offset + 56) ? null : cursor.getString(offset + 56));
|
||||
entity.setSurvey_location(cursor.isNull(offset + 57) ? null : cursor.getString(offset + 57));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected String updateKeyAfterInsert(TaskH entity, long rowId) {
|
||||
return entity.getUuid_task_h();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
public String getKey(TaskH entity) {
|
||||
if(entity != null) {
|
||||
return entity.getUuid_task_h();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@Override
|
||||
protected boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "taskHList" to-many relationship of User. */
|
||||
public List<TaskH> _queryUser_TaskHList(String uuid_user) {
|
||||
synchronized (this) {
|
||||
if (user_TaskHListQuery == null) {
|
||||
QueryBuilder<TaskH> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Uuid_user.eq(null));
|
||||
user_TaskHListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<TaskH> query = user_TaskHListQuery.forCurrentThread();
|
||||
query.setParameter(0, uuid_user);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
/** Internal query to resolve the "taskHList" to-many relationship of Scheme. */
|
||||
public List<TaskH> _queryScheme_TaskHList(String uuid_scheme) {
|
||||
synchronized (this) {
|
||||
if (scheme_TaskHListQuery == null) {
|
||||
QueryBuilder<TaskH> queryBuilder = queryBuilder();
|
||||
queryBuilder.where(Properties.Uuid_scheme.eq(null));
|
||||
scheme_TaskHListQuery = queryBuilder.build();
|
||||
}
|
||||
}
|
||||
Query<TaskH> query = scheme_TaskHListQuery.forCurrentThread();
|
||||
query.setParameter(0, uuid_scheme);
|
||||
return query.list();
|
||||
}
|
||||
|
||||
private String selectDeep;
|
||||
|
||||
protected String getSelectDeep() {
|
||||
if (selectDeep == null) {
|
||||
StringBuilder builder = new StringBuilder("SELECT ");
|
||||
SqlUtils.appendColumns(builder, "T", getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T0", daoSession.getUserDao().getAllColumns());
|
||||
builder.append(',');
|
||||
SqlUtils.appendColumns(builder, "T1", daoSession.getSchemeDao().getAllColumns());
|
||||
builder.append(" FROM TR_TASK_H T");
|
||||
builder.append(" LEFT JOIN MS_USER T0 ON T.\"UUID_USER\"=T0.\"UUID_USER\"");
|
||||
builder.append(" LEFT JOIN MS_SCHEME T1 ON T.\"UUID_SCHEME\"=T1.\"UUID_SCHEME\"");
|
||||
builder.append(' ');
|
||||
selectDeep = builder.toString();
|
||||
}
|
||||
return selectDeep;
|
||||
}
|
||||
|
||||
protected TaskH loadCurrentDeep(Cursor cursor, boolean lock) {
|
||||
TaskH entity = loadCurrent(cursor, 0, lock);
|
||||
int offset = getAllColumns().length;
|
||||
|
||||
User user = loadCurrentOther(daoSession.getUserDao(), cursor, offset);
|
||||
entity.setUser(user);
|
||||
offset += daoSession.getUserDao().getAllColumns().length;
|
||||
|
||||
Scheme scheme = loadCurrentOther(daoSession.getSchemeDao(), cursor, offset);
|
||||
entity.setScheme(scheme);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public TaskH loadDeep(Long key) {
|
||||
assertSinglePk();
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(getSelectDeep());
|
||||
builder.append("WHERE ");
|
||||
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
|
||||
String sql = builder.toString();
|
||||
|
||||
String[] keyArray = new String[] { key.toString() };
|
||||
Cursor cursor = db.rawQuery(sql, keyArray);
|
||||
|
||||
try {
|
||||
boolean available = cursor.moveToFirst();
|
||||
if (!available) {
|
||||
return null;
|
||||
} else if (!cursor.isLast()) {
|
||||
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
|
||||
}
|
||||
return loadCurrentDeep(cursor, true);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
|
||||
public List<TaskH> loadAllDeepFromCursor(Cursor cursor) {
|
||||
int count = cursor.getCount();
|
||||
List<TaskH> list = new ArrayList<TaskH>(count);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
if (identityScope != null) {
|
||||
identityScope.lock();
|
||||
identityScope.reserveRoom(count);
|
||||
}
|
||||
try {
|
||||
do {
|
||||
list.add(loadCurrentDeep(cursor, false));
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
if (identityScope != null) {
|
||||
identityScope.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<TaskH> loadDeepAllAndCloseCursor(Cursor cursor) {
|
||||
try {
|
||||
return loadAllDeepFromCursor(cursor);
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** A raw-style query where you can pass any WHERE clause and arguments. */
|
||||
public List<TaskH> queryDeep(String where, String... selectionArg) {
|
||||
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
|
||||
return loadDeepAllAndCloseCursor(cursor);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions.viewholder;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.adins.mss.base.AppContext;
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.dynamicform.Constant;
|
||||
import com.adins.mss.base.dynamicform.CustomerFragment;
|
||||
import com.adins.mss.base.dynamicform.JsonRequestTextOnline;
|
||||
import com.adins.mss.base.dynamicform.JsonResponseTextOnline;
|
||||
import com.adins.mss.base.util.EventBusHelper;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.http.AuditDataType;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.http.HttpCryptedConnection;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
import com.adins.mss.foundation.questiongenerator.form.QuestionView;
|
||||
|
||||
public class TextOnlineViewHolder extends RecyclerView.ViewHolder{
|
||||
RecyclerView mRecyclerView;
|
||||
private FragmentActivity mActivity;
|
||||
QuestionView mView;
|
||||
private TextView mQuestionLabel;
|
||||
private EditText mQuestionAnswer;
|
||||
private ImageButton mButtonSearch;
|
||||
private QuestionBean bean;
|
||||
|
||||
|
||||
|
||||
public TextOnlineViewHolder(View itemView, FragmentActivity mActivity) {
|
||||
super(itemView);
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionTextLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionTextLabel);
|
||||
mQuestionAnswer = (EditText) itemView.findViewById(R.id.questionTextAnswer);
|
||||
mButtonSearch = (ImageButton) itemView.findViewById(R.id.buttonSearchOnline);
|
||||
this.mActivity = mActivity;
|
||||
}
|
||||
|
||||
public TextOnlineViewHolder(View itemView, RecyclerView recyclerView, FragmentActivity mActivity){
|
||||
super(itemView);
|
||||
mRecyclerView = recyclerView;
|
||||
mView = (QuestionView) itemView.findViewById(R.id.questionTextLayout);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionTextLabel);
|
||||
mQuestionAnswer = (EditText) itemView.findViewById(R.id.questionTextAnswer);
|
||||
mButtonSearch = (ImageButton) itemView.findViewById(R.id.buttonSearchOnline);
|
||||
this.mActivity = mActivity;
|
||||
}
|
||||
|
||||
public void bind(final QuestionBean item, int number) {
|
||||
bean = item;
|
||||
String questionLabel = number + ". " + bean.getQuestion_label();
|
||||
String answer = bean.getAnswer();
|
||||
View.OnClickListener clickListener;
|
||||
|
||||
mQuestionLabel.setText(questionLabel);
|
||||
mQuestionAnswer.setSingleLine(true);
|
||||
mQuestionAnswer.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
|
||||
if (bean.isRelevanted()) {
|
||||
mQuestionAnswer.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
}
|
||||
|
||||
mQuestionAnswer.setSingleLine(false);
|
||||
mQuestionAnswer.setCursorVisible(false);
|
||||
mQuestionAnswer.setEnabled(false);
|
||||
|
||||
if (null != answer && !answer.isEmpty()) {
|
||||
mQuestionAnswer.setText(answer);
|
||||
} else {
|
||||
mQuestionAnswer.setText(null);
|
||||
}
|
||||
|
||||
if (Global.TRUE_STRING.equals(bean.getIs_mandatory())) {
|
||||
mQuestionAnswer.setHint(AppContext.getAppContext().getString(R.string.requiredField));
|
||||
} else {
|
||||
mQuestionAnswer.setHint("");
|
||||
}
|
||||
|
||||
clickListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
EventBusHelper.post(bean);
|
||||
TextOnlineTask textOnlineTask= new TextOnlineTask(mActivity, bean);
|
||||
textOnlineTask.execute();
|
||||
}
|
||||
};
|
||||
mButtonSearch.setOnClickListener(clickListener);
|
||||
}
|
||||
private class TextOnlineTask extends AsyncTask<String, Void, String> {
|
||||
private QuestionBean bean;
|
||||
private Activity activity;
|
||||
private ProgressDialog progressDialog;
|
||||
private String errMessage;
|
||||
|
||||
public TextOnlineTask(Activity activity, QuestionBean bean){
|
||||
this.activity = activity;
|
||||
this.bean=bean;
|
||||
}
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = ProgressDialog.show(activity, "", activity.getString(R.string.please_wait), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... strings) {
|
||||
if (Tool.isInternetconnected(activity)) {
|
||||
JsonRequestTextOnline request = new JsonRequestTextOnline();
|
||||
AuditDataType auditData = GlobalData.getSharedGlobalData().getAuditData();
|
||||
request.setAudit(auditData);
|
||||
request.setTaskId(CustomerFragment.header.getTask_id());
|
||||
request.setRefId(bean.getIdentifier_name());
|
||||
String url = GlobalData.getSharedGlobalData().getURL_GET_TEXT_ONLINE_ANSWER();
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity, encrypt, decrypt);
|
||||
HttpConnectionResult serverResult = null;
|
||||
String json = GsonHelper.toJson(request);
|
||||
try {
|
||||
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
|
||||
} catch (Exception e) {
|
||||
errMessage = activity.getString(R.string.msgConnectionFailed);
|
||||
return null;
|
||||
}
|
||||
if (null != serverResult && serverResult.isOK()) {
|
||||
return serverResult.getResult();
|
||||
} else {
|
||||
errMessage = activity.getString(R.string.connection_failed);
|
||||
}
|
||||
} else {
|
||||
errMessage = activity.getString(R.string.no_internet_connection);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
super.onPostExecute(result);
|
||||
if (progressDialog != null) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
progressDialog = null;
|
||||
}
|
||||
if (null != errMessage && !errMessage.isEmpty()) {
|
||||
Toast.makeText(activity, errMessage, Toast.LENGTH_SHORT).show();
|
||||
} else if (null != result) {
|
||||
processingResponseServer(result);
|
||||
}
|
||||
}
|
||||
|
||||
private void processingResponseServer(String result) {
|
||||
JsonResponseTextOnline json = GsonHelper.fromJson(result, JsonResponseTextOnline.class);
|
||||
if (1 == json.getStatus().getCode() && "success".equalsIgnoreCase(json.getStatus().getMessage())) {
|
||||
String answers = json.getAnswer();
|
||||
QuestionBean mBean = Constant.listOfQuestion.get(bean.getIdentifier_name());
|
||||
mBean.setAnswer(answers);
|
||||
mBean.setReadOnly(true);
|
||||
mQuestionAnswer.setText(answers);
|
||||
EventBusHelper.post(json);
|
||||
} else {
|
||||
Toast.makeText(activity, json.getStatus().getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,75 @@
|
|||
package org.acra.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import static org.acra.ACRA.LOG_TAG;
|
||||
|
||||
/**
|
||||
* Responsible for wrapping calls to PackageManager to ensure that they always complete without throwing RuntimeExceptions.
|
||||
* <p>
|
||||
* Depending upon the state of the application it is possible that
|
||||
* <ul>
|
||||
* <li>Context has no PackageManager.</li>
|
||||
* <li>PackageManager returned by Context throws RuntimeException("Package manager has died")
|
||||
* because it cannot contact the remote PackageManager service.
|
||||
* </li>
|
||||
* </ul>
|
||||
* I suspect that PackageManager death is caused during app installation.
|
||||
* But we need to make ACRA bullet proof, so it's better to handle the condition safely so that the error report itself doesn't fail.
|
||||
* </p>
|
||||
*
|
||||
* @author William Ferguson
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public final class PackageManagerWrapper {
|
||||
|
||||
private final Context context;
|
||||
|
||||
public PackageManagerWrapper(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permission Manifest.permission to check whether it has been granted.
|
||||
* @return true if the permission has been granted to the app, false if it hasn't been granted or the PackageManager could not be contacted.
|
||||
*/
|
||||
public boolean hasPermission(String permission) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
if (pm == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return pm.checkPermission(permission, context.getPackageName()) == PackageManager.PERMISSION_GRANTED;
|
||||
} catch (RuntimeException e) {
|
||||
// To catch RuntimeException("Package manager has died") that can occur on some version of Android,
|
||||
// when the remote PackageManager is unavailable. I suspect this sometimes occurs when the App is being reinstalled.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PackageInfo for the current application or null if the PackageManager could not be contacted.
|
||||
*/
|
||||
public PackageInfo getPackageInfo() {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
if (pm == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return pm.getPackageInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
ACRA.log.v(LOG_TAG, "Failed to find PackageInfo for current App : " + context.getPackageName());
|
||||
return null;
|
||||
} catch (RuntimeException e) {
|
||||
// To catch RuntimeException("Package manager has died") that can occur on some version of Android,
|
||||
// when the remote PackageManager is unavailable. I suspect this sometimes occurs when the App is being reinstalled.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,683 @@
|
|||
package com.adins.mss.foundation.image;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
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.constant.Global;
|
||||
import com.adins.mss.foundation.camerainapp.helper.Logger;
|
||||
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Utils {
|
||||
public static int REQUEST_CAMERA = 1;
|
||||
public static int REQUEST_IN_APP_CAMERA = 2;
|
||||
public static int picWidth = 480;
|
||||
public static int picHeight = 640;
|
||||
public static int picQuality = 75;
|
||||
public static int picHQWidth = 540;
|
||||
public static int picHQHeight = 960;
|
||||
public static int picHQQuality = 85;
|
||||
|
||||
public static void CopyStream(InputStream is, OutputStream os) {
|
||||
final int buffer_size = 1024;
|
||||
try {
|
||||
byte[] bytes = new byte[buffer_size];
|
||||
for (; ; ) {
|
||||
int count = is.read(bytes, 0, buffer_size);
|
||||
if (count == -1)
|
||||
break;
|
||||
os.write(bytes, 0, count);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
FireCrash.log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getImageBitmap(String url) {
|
||||
Bitmap myImg = BitmapFactory.decodeFile(url);
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postRotate(0);
|
||||
Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(),
|
||||
matrix, true);
|
||||
return rotated;
|
||||
}
|
||||
|
||||
public static Bitmap byteToBitmap(byte[] byte_image) {
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length);
|
||||
if (bm == null) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
//ignored
|
||||
} else {
|
||||
options.inPurgeable = true;
|
||||
}
|
||||
options.inPreferredConfig = Config.RGB_565;
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length, options);
|
||||
|
||||
// Calculate inSampleSize
|
||||
options.inSampleSize = 4;
|
||||
// Decode bitmap with inSampleSize set
|
||||
options.inJustDecodeBounds = false;
|
||||
bm = BitmapFactory.decodeByteArray(byte_image, 0, byte_image.length, options);
|
||||
}
|
||||
return bm;
|
||||
}
|
||||
|
||||
public static Bitmap pathToBitmap(File imgFile) {
|
||||
Bitmap bitmap = null;
|
||||
if (imgFile.exists()) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = false;
|
||||
options.inPreferredConfig = Config.RGB_565;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
//ignored
|
||||
} else {
|
||||
options.inDither = true;
|
||||
}
|
||||
bitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
|
||||
int[] res = getSmallResolution(bitmap.getWidth(), bitmap.getHeight());
|
||||
bitmap = Bitmap.createScaledBitmap(bitmap, res[0], res[1], false);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Bitmap pathToBitmapWithRotation(File imgFile) {
|
||||
Bitmap bitmap = null;
|
||||
if (imgFile.exists()) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = false;
|
||||
options.inPreferredConfig = Config.RGB_565;
|
||||
options.inDither = true;
|
||||
bitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
|
||||
int[] res = getSmallResolution(bitmap.getWidth(), bitmap.getHeight());
|
||||
bitmap = Bitmap.createScaledBitmap(bitmap, res[0], res[1], false);
|
||||
|
||||
int rotation = Utils.getExifRotation(imgFile);
|
||||
bitmap = ImageManipulation.rotateImage(bitmap, rotation);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Bitmap absPathToBitmap(String absolutePath) {
|
||||
Bitmap bitmap = null;
|
||||
File imgFile = new File(absolutePath);
|
||||
if (imgFile.exists()) {
|
||||
bitmap = BitmapFactory.decodeFile(absolutePath);
|
||||
int[] res = getSmallResolution(bitmap.getWidth(), bitmap.getHeight());
|
||||
bitmap = Bitmap.createScaledBitmap(bitmap, res[0], res[1], false);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static byte[] base64ToByte(String base64String) {
|
||||
byte[] imageByte = Base64.decode(base64String);
|
||||
return imageByte;
|
||||
}
|
||||
|
||||
public static String byteToBase64(byte[] byte_image) {
|
||||
String base64String = new String(Base64.encode(byte_image));
|
||||
return base64String;
|
||||
}
|
||||
|
||||
public static byte[] bitmapToByte(Bitmap bitmap) {
|
||||
byte[] bitmapArray = null;
|
||||
if(bitmap == null)
|
||||
return bitmapArray;
|
||||
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);
|
||||
|
||||
bitmapArray = stream.toByteArray();
|
||||
if (!bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
return bitmapArray;
|
||||
}
|
||||
|
||||
public static byte[] bitmapToByte(Bitmap bitmap, int quality) {
|
||||
byte[] bitmapArray = null;
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream);
|
||||
|
||||
bitmapArray = stream.toByteArray();
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
return bitmapArray;
|
||||
}
|
||||
|
||||
public static byte[] pathBitmapToByte(File imgFile) {
|
||||
Bitmap bitmap = pathToBitmap(imgFile);
|
||||
return bitmapToByte(bitmap);
|
||||
}
|
||||
|
||||
public static byte[] pathBitmapToByteWithRotation(File imgFile) {
|
||||
Bitmap bitmap = pathToBitmap(imgFile);
|
||||
int rotation = Utils.getExifRotation(imgFile);
|
||||
bitmap = ImageManipulation.rotateImage(bitmap, rotation);
|
||||
return bitmapToByte(bitmap);
|
||||
}
|
||||
|
||||
public static int getExifRotation(File imageFile) {
|
||||
if (imageFile == null) return 0;
|
||||
try {
|
||||
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
|
||||
// We only recognize a subset of orientation tag values
|
||||
switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)) {
|
||||
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||
return 90;
|
||||
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||
return 180;
|
||||
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||
return 270;
|
||||
default:
|
||||
return ExifInterface.ORIENTATION_UNDEFINED;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Logger.e("Error getting Exif data", e.getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveBitmapProfiletoPath(Context context, Bitmap bitmap) {
|
||||
OutputStream outputStream = null;
|
||||
File filename = new File(context.getFilesDir(), "imgProfile");
|
||||
Uri saveUri = Uri.fromFile(filename);
|
||||
if (filename.exists()) {
|
||||
boolean deleteResult = filename.delete();
|
||||
if(!deleteResult){
|
||||
Toast.makeText(context, "Failed to delete file", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
try {
|
||||
outputStream = context.getContentResolver().openOutputStream(saveUri);
|
||||
if (outputStream != null) {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, outputStream);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Logger.e("Cannot open file: " + saveUri, e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
bitmap = null;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveBitmapHeadertoPath(Context context, Bitmap bitmap) {
|
||||
OutputStream outputStream = null;
|
||||
File filename = new File(context.getFilesDir(), "imgHeader");
|
||||
Uri saveUri = Uri.fromFile(filename);
|
||||
if (filename.exists()) {
|
||||
boolean deleteResult = filename.delete();
|
||||
if(!deleteResult){
|
||||
Toast.makeText(context, "Failed to delete file", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
try {
|
||||
outputStream = context.getContentResolver().openOutputStream(saveUri);
|
||||
if (outputStream != null) {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, outputStream);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Logger.e("Cannot open file: " + saveUri, e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
bitmap = null;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteLatestPicture(Context context) {
|
||||
|
||||
File f = new File(context.getExternalFilesDir(null) + "/DCIM/Camera");
|
||||
|
||||
File[] files = f.listFiles();
|
||||
|
||||
Arrays.sort(files, new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
|
||||
if (((File) o1).lastModified() > ((File) o2).lastModified()) {
|
||||
return -1;
|
||||
} else if (((File) o1).lastModified() < ((File) o2).lastModified()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
boolean deleteResult = files[0].delete();
|
||||
if(!deleteResult){
|
||||
Toast.makeText(context, "Failed to delete file", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteLatestPictureLGE(Context context) {
|
||||
|
||||
File f = new File(context.getExternalFilesDir(null)+ "/DCIM/100LGDSC");
|
||||
|
||||
File[] files = f.listFiles();
|
||||
|
||||
Arrays.sort(files, new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
|
||||
if (((File) o1).lastModified() > ((File) o2).lastModified()) {
|
||||
return -1;
|
||||
} else if (((File) o1).lastModified() < ((File) o2).lastModified()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
boolean deleteResult = files[0].delete();
|
||||
if(!deleteResult){
|
||||
Toast.makeText(context, "Failed to delete file", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static int calculateInSampleSize(
|
||||
BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
||||
// Raw height and width of image
|
||||
final int height = options.outHeight;
|
||||
final int width = options.outWidth;
|
||||
int inSampleSize = 1;
|
||||
|
||||
if (height > reqHeight || width > reqWidth) {
|
||||
|
||||
final int halfHeight = height / 2;
|
||||
final int halfWidth = width / 2;
|
||||
|
||||
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
|
||||
// height and width larger than the requested height and width.
|
||||
while ((halfHeight / inSampleSize) > reqHeight
|
||||
&& (halfWidth / inSampleSize) > reqWidth) {
|
||||
inSampleSize *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
return inSampleSize;
|
||||
}
|
||||
|
||||
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
|
||||
int reqWidth, int reqHeight) {
|
||||
|
||||
// First decode with inJustDecodeBounds=true to check dimensions
|
||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeResource(res, resId, options);
|
||||
|
||||
// Calculate inSampleSize
|
||||
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
|
||||
|
||||
// Decode bitmap with inSampleSize set
|
||||
options.inJustDecodeBounds = false;
|
||||
return BitmapFactory.decodeResource(res, resId, options);
|
||||
}
|
||||
|
||||
public static Bitmap getResizedBitmap(Bitmap bm, int newHeight) {
|
||||
int sourceWidth = bm.getWidth();
|
||||
int sourceHeight = bm.getHeight();
|
||||
|
||||
float nPercentH = ((float) newHeight / (float) sourceHeight);
|
||||
int destWidth = Math.max(Math.round(sourceWidth * nPercentH), 1);
|
||||
int destHeight = newHeight;
|
||||
|
||||
// CREATE A MATRIX FOR THE MANIPULATION
|
||||
Matrix matrix = new Matrix();
|
||||
// RESIZE THE BIT MAP
|
||||
matrix.postScale(destWidth, destHeight);
|
||||
|
||||
// "RECREATE" THE NEW BITMAP
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(
|
||||
bm, 0, 0, destWidth, destHeight, matrix, false);
|
||||
if (bm != null && !bm.isRecycled()) {
|
||||
bm.recycle();
|
||||
}
|
||||
return resizedBitmap;
|
||||
}
|
||||
|
||||
public static Bitmap getResizedBitmap(Bitmap bm, int newWidth, int newHeight) {
|
||||
int width = bm.getWidth();
|
||||
int height = bm.getHeight();
|
||||
float scaleWidth = ((float) newWidth) / width;
|
||||
float scaleHeight = ((float) newHeight) / height;
|
||||
// CREATE A MATRIX FOR THE MANIPULATION
|
||||
Matrix matrix = new Matrix();
|
||||
// RESIZE THE BIT MAP
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
|
||||
// "RECREATE" THE NEW BITMAP
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(
|
||||
bm, 0, 0, width, height, matrix, false);
|
||||
return resizedBitmap;
|
||||
}
|
||||
|
||||
public static Bitmap decodeSampledBitmapFromResource(File imgFile,
|
||||
int reqWidth, int reqHeight) {
|
||||
|
||||
// First decode with inJustDecodeBounds=true to check dimensions
|
||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
//ignored
|
||||
} else {
|
||||
options.inDither = false;
|
||||
}
|
||||
BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
|
||||
|
||||
// Calculate inSampleSize
|
||||
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
|
||||
|
||||
// Decode bitmap with inSampleSize set
|
||||
options.inJustDecodeBounds = false;
|
||||
return BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
|
||||
}
|
||||
|
||||
public static int neededRotation(File ff) {
|
||||
try {
|
||||
ExifInterface exif = new ExifInterface(ff.getAbsolutePath());
|
||||
int orientation = exif.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
||||
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
|
||||
return 270;
|
||||
}
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
|
||||
return 180;
|
||||
}
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
|
||||
return 90;
|
||||
}
|
||||
return 0;
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ExifData getDataOnExif(File ff) {
|
||||
ExifData exifData = new ExifData();
|
||||
try {
|
||||
ExifInterface exif = new ExifInterface(ff.getAbsolutePath());
|
||||
if (exif != null) {
|
||||
int orientation = exif.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
||||
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
|
||||
exifData.setOrientation(270);
|
||||
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
|
||||
exifData.setOrientation(180);
|
||||
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
|
||||
exifData.setOrientation(90);
|
||||
} else {
|
||||
exifData.setOrientation(0);
|
||||
}
|
||||
int sourceWidth = exif.getAttributeInt(
|
||||
ExifInterface.TAG_IMAGE_WIDTH, picWidth);
|
||||
int sourceHeight = exif.getAttributeInt(
|
||||
ExifInterface.TAG_IMAGE_LENGTH, picHeight);
|
||||
exifData.setWidth(sourceWidth);
|
||||
exifData.setHeight(sourceHeight);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return exifData;
|
||||
}
|
||||
|
||||
public static int getSquareCropDimensionForBitmap(Bitmap bitmap) {
|
||||
int dimension = 0;
|
||||
//If the bitmap is wider than it is tall
|
||||
//use the height as the square crop dimension
|
||||
if (bitmap.getWidth() >= bitmap.getHeight()) {
|
||||
dimension = bitmap.getHeight();
|
||||
}
|
||||
//If the bitmap is taller than it is wide
|
||||
//use the width as the square crop dimension
|
||||
else {
|
||||
dimension = bitmap.getWidth();
|
||||
}
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public static void setCameraParameter(Context context) {
|
||||
String param = GeneralParameterDataAccess.getOne(context, GlobalData.getSharedGlobalData().getUser().getUuid_user(),
|
||||
Global.GS_IMG_QUALITY).getGs_value();
|
||||
if (param != null && param.length() > 0) {
|
||||
String[] values = Tool.split(param, "&");
|
||||
for (String value : values) {
|
||||
String[] newParam = Tool.split(value, "=");
|
||||
String nCode = newParam[0];
|
||||
String nValue = newParam[1];
|
||||
if (nCode.equals("width"))
|
||||
picWidth = Integer.valueOf(nValue);
|
||||
else if (nCode.equals("height"))
|
||||
picHeight = Integer.valueOf(nValue);
|
||||
else if (nCode.equals("jpegquality"))
|
||||
picQuality = Integer.valueOf(nValue);
|
||||
}
|
||||
}
|
||||
|
||||
String paramHQ = GeneralParameterDataAccess.getOne(context, GlobalData.getSharedGlobalData().getUser().getUuid_user(),
|
||||
Global.GS_IMG_HIGH_QUALITY).getGs_value();
|
||||
if (paramHQ != null && paramHQ.length() > 0) {
|
||||
String[] values = Tool.split(paramHQ, "&");
|
||||
for (String value : values) {
|
||||
String[] newParam = Tool.split(value, "=");
|
||||
String nCode = newParam[0];
|
||||
String nValue = newParam[1];
|
||||
if (nCode.equals("width"))
|
||||
picHQWidth = Integer.valueOf(nValue);
|
||||
else if (nCode.equals("height"))
|
||||
picHQHeight = Integer.valueOf(nValue);
|
||||
else if (nCode.equals("jpegquality"))
|
||||
picHQQuality = Integer.valueOf(nValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap resizeImageByPath(Bitmap bm) {
|
||||
int[] res = getSmallResolution(bm.getWidth(), bm.getHeight());
|
||||
Bitmap bmp = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
|
||||
OutputStream stream = new ByteArrayOutputStream();
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, picQuality, stream);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
public static int[] getSmallResolution(int oriW, int oriH) {
|
||||
int[] resolution = new int[2];
|
||||
|
||||
double widthRatio = (double) oriW / picWidth;
|
||||
double heightRatio = (double) oriH / picHeight;
|
||||
double ratio = Math.max(widthRatio, heightRatio);
|
||||
if (ratio == 0d) {
|
||||
ratio = 1d;
|
||||
}
|
||||
resolution[0] = (int) Math.floor(oriW / ratio);
|
||||
resolution[1] = (int) Math.floor(oriH / ratio);
|
||||
|
||||
return resolution;
|
||||
}
|
||||
|
||||
public static byte[] resizeBitmapWithWatermark(Bitmap bm, int rotate, int actualWidth, int actualHeight, int jpegQuality, Activity activity) {
|
||||
Log.i("Utils","image quality : " + jpegQuality);
|
||||
Bitmap bmp = Bitmap.createScaledBitmap(bm, actualWidth, actualHeight, true);
|
||||
|
||||
//rotate image if potraid
|
||||
if (rotate != 0) {
|
||||
Matrix mat = new Matrix();
|
||||
mat.preRotate(rotate);// /in degree
|
||||
|
||||
// Bitmap
|
||||
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),
|
||||
bmp.getHeight(), mat, true);
|
||||
}
|
||||
//untuk nambah watermark
|
||||
Bitmap bmpFinal = ImageManipulation.waterMark(bmp, activity.getString(R.string.watermark), Color.WHITE, 80, 32, false);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
bmpFinal.compress(Bitmap.CompressFormat.JPEG, jpegQuality, stream);
|
||||
|
||||
try {
|
||||
if (bm != null && !bm.isRecycled()) {
|
||||
bm.recycle();
|
||||
}
|
||||
if (bmp != null && !bmp.isRecycled()) {
|
||||
bmp.recycle();
|
||||
}
|
||||
if (bmpFinal != null && !bmpFinal.isRecycled()) {
|
||||
bmpFinal.recycle();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] resizeBitmapFileWithWatermark(File imgFile, int rotate, int actualWidth, int actualHeight, int jpegQuality, Activity activity, boolean isHQ) {
|
||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
if (isHQ)
|
||||
options.inPreferredConfig = Config.ARGB_8888;
|
||||
else
|
||||
options.inPreferredConfig = Config.RGB_565;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
//ignored
|
||||
} else {
|
||||
options.inDither = true;
|
||||
}
|
||||
options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight);
|
||||
|
||||
// Decode bitmap with inSampleSize set
|
||||
options.inJustDecodeBounds = false;
|
||||
Bitmap bm = BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
|
||||
|
||||
Matrix mat = new Matrix();
|
||||
mat.preRotate(rotate);// in degree
|
||||
// Bitmap
|
||||
Bitmap bmp = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),
|
||||
bm.getHeight(), mat, true);
|
||||
|
||||
//untuk nambah watermark
|
||||
Bitmap bmpFinal = ImageManipulation.waterMark(bmp, activity.getString(R.string.watermark), Color.WHITE, 80, 32, false);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
bmpFinal.compress(Bitmap.CompressFormat.JPEG, jpegQuality, stream);
|
||||
|
||||
try {
|
||||
if (bm != null && !bm.isRecycled()) {
|
||||
bm.recycle();
|
||||
}
|
||||
if (bmp != null && !bmp.isRecycled()) {
|
||||
bmp.recycle();
|
||||
}
|
||||
if (bmpFinal != null && !bmpFinal.isRecycled()) {
|
||||
bmpFinal.recycle();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
public Bitmap transform(Bitmap source, int mSize, boolean isHeightScale) {
|
||||
float scale;
|
||||
int newSize;
|
||||
Bitmap scaleBitmap;
|
||||
if (isHeightScale) {
|
||||
scale = (float) mSize / source.getHeight();
|
||||
newSize = Math.round(source.getWidth() * scale);
|
||||
scaleBitmap = Bitmap.createScaledBitmap(source, newSize, mSize, true);
|
||||
} else {
|
||||
scale = (float) mSize / source.getWidth();
|
||||
newSize = Math.round(source.getHeight() * scale);
|
||||
scaleBitmap = Bitmap.createScaledBitmap(source, mSize, newSize, true);
|
||||
}
|
||||
if (scaleBitmap != source && (source != null && !source.isRecycled())) {
|
||||
source.recycle();
|
||||
}
|
||||
|
||||
return scaleBitmap;
|
||||
}
|
||||
|
||||
public Bitmap transformFromFile(File imgFile, int mSize, boolean isHeightScale) {
|
||||
|
||||
Bitmap scaleBitmap;
|
||||
Bitmap source;
|
||||
|
||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
//ignored
|
||||
} else {
|
||||
options.inDither = false;
|
||||
}
|
||||
source = BitmapFactory.decodeFile(imgFile.getAbsolutePath(), options);
|
||||
float scale;
|
||||
int newSize;
|
||||
if (isHeightScale) {
|
||||
scale = (float) mSize / source.getHeight();
|
||||
newSize = Math.round(source.getWidth() * scale);
|
||||
scaleBitmap = Bitmap.createScaledBitmap(source, newSize, mSize, true);
|
||||
} else {
|
||||
scale = (float) mSize / source.getWidth();
|
||||
newSize = Math.round(source.getHeight() * scale);
|
||||
scaleBitmap = Bitmap.createScaledBitmap(source, mSize, newSize, true);
|
||||
}
|
||||
|
||||
if (scaleBitmap != source) {
|
||||
if (source != null && !source.isRecycled()) {
|
||||
source.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
return scaleBitmap;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue