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
Binary file not shown.
After Width: | Height: | Size: 266 B |
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.adins.libs.nineoldandroids.animation;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.adins.libs.nineoldandroids.animation.Keyframe.IntKeyframe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This class holds a collection of IntKeyframe objects and is called by ValueAnimator to calculate
|
||||
* values between those keyframes for a given animation. The class internal to the animation
|
||||
* package because it is an implementation detail of how Keyframes are stored and used.
|
||||
* <p>
|
||||
* <p>This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
|
||||
* float, exists to speed up the getValue() method when there is no custom
|
||||
* TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
|
||||
* Object equivalents of these primitive types.</p>
|
||||
*/
|
||||
class IntKeyframeSet extends KeyframeSet {
|
||||
private int firstValue;
|
||||
private int lastValue;
|
||||
private int deltaValue;
|
||||
private boolean firstTime = true;
|
||||
|
||||
public IntKeyframeSet(IntKeyframe... keyframes) {
|
||||
super(keyframes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(float fraction) {
|
||||
return getIntValue(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntKeyframeSet clone() {
|
||||
ArrayList<Keyframe> keyframes = mKeyframes;
|
||||
int numKeyframes = mKeyframes.size();
|
||||
IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes];
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone();
|
||||
}
|
||||
IntKeyframeSet newSet = new IntKeyframeSet(newKeyframes);
|
||||
return newSet;
|
||||
}
|
||||
|
||||
public int getIntValue(float fraction) {
|
||||
if (mNumKeyframes == 2) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue();
|
||||
lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue();
|
||||
deltaValue = lastValue - firstValue;
|
||||
}
|
||||
if (mInterpolator != null) {
|
||||
fraction = mInterpolator.getInterpolation(fraction);
|
||||
}
|
||||
if (mEvaluator == null) {
|
||||
return firstValue + (int) (fraction * deltaValue);
|
||||
} else {
|
||||
return ((Number) mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue();
|
||||
}
|
||||
}
|
||||
if (fraction <= 0f) {
|
||||
final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
|
||||
final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1);
|
||||
int prevValue = prevKeyframe.getIntValue();
|
||||
int nextValue = nextKeyframe.getIntValue();
|
||||
float prevFraction = prevKeyframe.getFraction();
|
||||
float nextFraction = nextKeyframe.getFraction();
|
||||
final /*Time*/ Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
|
||||
return mEvaluator == null ?
|
||||
prevValue + (int) (intervalFraction * (nextValue - prevValue)) :
|
||||
((Number) mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
|
||||
intValue();
|
||||
} else if (fraction >= 1f) {
|
||||
final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2);
|
||||
final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1);
|
||||
int prevValue = prevKeyframe.getIntValue();
|
||||
int nextValue = nextKeyframe.getIntValue();
|
||||
float prevFraction = prevKeyframe.getFraction();
|
||||
float nextFraction = nextKeyframe.getFraction();
|
||||
final /*Time*/ Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
|
||||
return mEvaluator == null ?
|
||||
prevValue + (int) (intervalFraction * (nextValue - prevValue)) :
|
||||
((Number) mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue();
|
||||
}
|
||||
IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
|
||||
for (int i = 1; i < mNumKeyframes; ++i) {
|
||||
IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i);
|
||||
if (fraction < nextKeyframe.getFraction()) {
|
||||
final /*Time*/ Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevKeyframe.getFraction()) /
|
||||
(nextKeyframe.getFraction() - prevKeyframe.getFraction());
|
||||
int prevValue = prevKeyframe.getIntValue();
|
||||
int nextValue = nextKeyframe.getIntValue();
|
||||
return mEvaluator == null ?
|
||||
prevValue + (int) (intervalFraction * (nextValue - prevValue)) :
|
||||
((Number) mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
|
||||
intValue();
|
||||
}
|
||||
prevKeyframe = nextKeyframe;
|
||||
}
|
||||
// shouldn't get here
|
||||
return ((Number) mKeyframes.get(mNumKeyframes - 1).getValue()).intValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,428 @@
|
|||
package com.adins.mss.base.receipt;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Loise on 12/04/2018.
|
||||
*/
|
||||
|
||||
/**
|
||||
* class untuk membangun struk dalam bentuk gambar
|
||||
*/
|
||||
public class ReceiptBuilder {
|
||||
List<IDrawItem> listItems = new ArrayList<>();
|
||||
private int backgroundColor = Color.WHITE;
|
||||
private float textSize;
|
||||
private int color = Color.BLACK;
|
||||
private int width;
|
||||
private int marginTop, marginBottom, marginLeft, marginRight;
|
||||
private Typeface typeface;
|
||||
private Paint.Align align = Paint.Align.LEFT;
|
||||
|
||||
/**
|
||||
* konstruktor untuk inisialisasi lebar struk (biasanya 384)
|
||||
* @param width lebar kertas printer dalam pixel
|
||||
*/
|
||||
public ReceiptBuilder(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mengubah ukuran teks
|
||||
* @param textSize ukuran font teks
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setTextSize(float textSize) {
|
||||
this.textSize = textSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah warna background struk
|
||||
* @param backgroundColor
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setBackgroudColor(int backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah warna teks
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah font teks untuk satu baris
|
||||
* @param context
|
||||
* @param typefacePath
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setTypeface(Context context, String typefacePath) {
|
||||
typeface = Typeface.createFromAsset(context.getAssets(), typefacePath);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengembalikan font menjadi default
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setDefaultTypeface() {
|
||||
typeface = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah alignment
|
||||
* @param align Paint.Align
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setAlign(Paint.Align align) {
|
||||
this.align = align;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah margin atas bawah kiri kanan
|
||||
* @param margin ukuran margin semua sisi dalam pixel
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setMargin(int margin) {
|
||||
this.marginLeft = margin;
|
||||
this.marginRight = margin;
|
||||
this.marginTop = margin;
|
||||
this.marginBottom = margin;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah margin atas bawah dan kiri kanan terpisah
|
||||
* @param marginTopBottom ukuran margin atas bawah dalam pixel
|
||||
* @param marginLeftRight ukuran margin kiri kanan dalam pixel
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setMargin(int marginTopBottom, int marginLeftRight) {
|
||||
this.marginLeft = marginLeftRight;
|
||||
this.marginRight = marginLeftRight;
|
||||
this.marginTop = marginTopBottom;
|
||||
this.marginBottom = marginTopBottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mengubah margin kiri
|
||||
* @param margin ukuran margin kiri dalam pixel
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setMarginLeft(int margin) {
|
||||
this.marginLeft = margin;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah margin kanan
|
||||
* @param margin ukuran margin kanan dalam pixel
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setMarginRight(int margin) {
|
||||
this.marginRight = margin;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah margin atas
|
||||
* @param margin ukuran margin atas dalam pixel
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setMarginTop(int margin) {
|
||||
this.marginTop = margin;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* memngubah margin bawah
|
||||
* @param margin
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder setMarginBottom(int margin) {
|
||||
this.marginBottom = margin;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah objek teks satu baris
|
||||
* @param text teks yang ingin digambar
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addText(String text) {
|
||||
return addText(text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* mengubah objek teks dengan atau tanpa pindah baris
|
||||
* @param text teks yang akan digambar
|
||||
* @param newLine apakah pindah baris atau tidak
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addText(String text, Boolean newLine) {
|
||||
DrawText drawerText = new DrawText(text);
|
||||
drawerText.setTextSize(this.textSize);
|
||||
drawerText.setColor(this.color);
|
||||
drawerText.setNewLine(newLine);
|
||||
if (typeface != null) {
|
||||
drawerText.setTypeface(typeface);
|
||||
}
|
||||
if (align != null) {
|
||||
drawerText.setAlign(align);
|
||||
}
|
||||
listItems.add(drawerText);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah objek gambar pada struk
|
||||
* @param bitmap gambar yang ingin dimasukkan
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addImage(Bitmap bitmap) {
|
||||
DrawImage drawerImage = new DrawImage(bitmap);
|
||||
if (align != null) {
|
||||
drawerImage.setAlign(align);
|
||||
}
|
||||
listItems.add(drawerImage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah objek generik pada struk
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addItem(IDrawItem item) {
|
||||
listItems.add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah area kosong pada struk
|
||||
* @param height tinggi area kosong dalam pixel
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addBlankSpace(int height) {
|
||||
listItems.add(new DrawBlankSpace(height));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah paragraf baru dalam teks
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addParagraph() {
|
||||
listItems.add(new DrawBlankSpace((int) textSize));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah garis dari kiri ke kanan kertas
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addLine() {
|
||||
return addLine(width - marginRight - marginLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* menambah garis dengan lebar tertentu
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public ReceiptBuilder addLine(int size) {
|
||||
DrawLine line = new DrawLine(size);
|
||||
line.setAlign(align);
|
||||
line.setColor(color);
|
||||
listItems.add(line);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReceiptBuilder addLine(int size, int weigth) {
|
||||
int _size = size > 0 ? size : (width - marginRight - marginLeft);
|
||||
DrawLine line = new DrawLine(_size, weigth);
|
||||
line.setAlign(align);
|
||||
line.setColor(color);
|
||||
listItems.add(line);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengembalikan tinggi struk dalam pixel
|
||||
* @return
|
||||
*/
|
||||
private int getHeight() {
|
||||
int height = 5 + marginTop + marginBottom;
|
||||
for (IDrawItem item : listItems) {
|
||||
height += item.getHeight();
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* menggambar semua objek pada canvas
|
||||
* @return
|
||||
*/
|
||||
private Bitmap drawImage() {
|
||||
Bitmap image = Bitmap.createBitmap(width - marginRight - marginLeft, getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(image);
|
||||
canvas.drawColor(backgroundColor);
|
||||
float size = marginTop;
|
||||
for (IDrawItem item : listItems) {
|
||||
item.drawOnCanvas(canvas, 0, size);
|
||||
size += item.getHeight();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* mengenerate gambar bitmap dari semua item yang ditambahkan
|
||||
* @param context Context
|
||||
* @return Bitmap struk
|
||||
*/
|
||||
public Bitmap build(Context context) {
|
||||
Bitmap image = Bitmap.createBitmap(width, getHeight(), Bitmap.Config.RGB_565);
|
||||
Canvas canvas = new Canvas(image);
|
||||
Paint paint = new Paint();
|
||||
//Menggambar logo pada samping struk
|
||||
//Bitmap bitmap = BitmapFactory.decodeStream(context.getResources().openRawResource(R.raw.side_logo), null, opt);
|
||||
|
||||
// BitmapDrawable drawable = scaleImage((BitmapDrawable) ContextCompat.getDrawable(context, R.raw.side_logo),(float)1,context);
|
||||
// Bitmap temp = drawable.getBitmap();
|
||||
// drawable = new BitmapDrawable(context.getResources(),Bitmap.createScaledBitmap(temp,30,164, true));
|
||||
// drawable.setTileModeY(Shader.TileMode.REPEAT);
|
||||
//comment sampai sini bila tidak mau logo di samping dan sesuaikan margin
|
||||
|
||||
canvas.drawColor(backgroundColor);
|
||||
canvas.drawBitmap(drawImage(), marginLeft, 0, paint);
|
||||
|
||||
//lebar area
|
||||
// drawable.setBounds(0,0,30,canvas.getHeight());
|
||||
// drawable.draw(canvas);
|
||||
return image;
|
||||
}
|
||||
|
||||
public BitmapDrawable scaleImage (Drawable image, float scaleFactor, Context context) {
|
||||
|
||||
if ((image == null) || !(image instanceof BitmapDrawable)) {
|
||||
return (BitmapDrawable)image;
|
||||
}
|
||||
|
||||
Bitmap b = ((BitmapDrawable)image).getBitmap();
|
||||
|
||||
int sizeX = Math.round(image.getIntrinsicWidth() * scaleFactor);
|
||||
int sizeY = Math.round(image.getIntrinsicHeight() * scaleFactor);
|
||||
|
||||
Bitmap bitmapResized = Bitmap.createScaledBitmap(b, sizeX, sizeY, false);
|
||||
|
||||
image = new BitmapDrawable(context.getResources(), bitmapResized);
|
||||
return (BitmapDrawable)image;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample cara membuat struk bitmap, jangan lupa menyediakan file font yang sesuai didalam folder assets
|
||||
* @param context
|
||||
* @return Bitmap sample struk
|
||||
*/
|
||||
public static Bitmap getTestBitmap(Context context){
|
||||
ReceiptBuilder receipt = new ReceiptBuilder(384);
|
||||
BitmapFactory.Options opt = new BitmapFactory.Options();
|
||||
opt.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||
opt.inPurgeable = true;
|
||||
opt.inInputShareable = true;
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(context.getResources().openRawResource(R.raw.adins_logo), null, opt);
|
||||
receipt.setMarginTop(10).
|
||||
setMarginBottom(10).
|
||||
setMarginRight(5).
|
||||
setMarginLeft(5).
|
||||
setAlign(Paint.Align.CENTER).
|
||||
addImage(bitmap).
|
||||
addParagraph().
|
||||
addBlankSpace(20).
|
||||
setAlign(Paint.Align.CENTER).
|
||||
setColor(Color.BLACK).
|
||||
setTextSize(18).
|
||||
setTypeface(context, "fonts/RobotoMono-Regular.ttf").
|
||||
addText("LakeFront Cafe").
|
||||
addText("1234 Main St.").
|
||||
addText("Palo Alto, CA 94568").
|
||||
addText("999-999-9999").
|
||||
addBlankSpace(30).
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addText("Terminal ID: 123456", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("1234").
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addLine().
|
||||
addText("08/15/16", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("SERVER #4").
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addParagraph().
|
||||
addText("CHASE VISA - INSERT").
|
||||
addText("AID: A000000000011111").
|
||||
addText("ACCT #: *********1111").
|
||||
addParagraph().
|
||||
setTypeface(context, "fonts/RobotoMono-Bold.ttf").
|
||||
addText("CREDIT SALE").
|
||||
addText("UID: 12345678", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("REF #: 1234").
|
||||
setTypeface(context, "fonts/RobotoMono-Regular.ttf").
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addText("BATCH #: 091", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("AUTH #: 0701C").
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addParagraph().
|
||||
setTypeface(context, "fonts/RobotoMono-Bold.ttf").
|
||||
addText("AMOUNT", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("$ 15.00").
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addParagraph().
|
||||
addText("TIP", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("$ ").
|
||||
addLine(180).
|
||||
setAlign(Paint.Align.LEFT).
|
||||
addParagraph().
|
||||
addText("TOTAL", false).
|
||||
setAlign(Paint.Align.RIGHT).
|
||||
addText("$ ").
|
||||
addLine(180).
|
||||
addParagraph().
|
||||
setAlign(Paint.Align.CENTER).
|
||||
setTypeface(context, "fonts/RobotoMono-Regular.ttf").
|
||||
addText("APPROVED");
|
||||
receipt.addLine();
|
||||
|
||||
return receipt.build(context);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#002F5F</color>
|
||||
<color name="text_color">#FFFFFF</color>
|
||||
<color name="divider_color">#11000000</color>
|
||||
<color name="msg_color">#FFFFFFFF</color>
|
||||
<color name="dialog_bg">#030039</color>
|
||||
|
||||
<color name="btn_press_color">#66013c3b</color>
|
||||
<color name="btn_unpress_color">#22000000</color>
|
||||
|
||||
<color name="txt_view">#001135</color>
|
||||
|
||||
<!-- Text View -->
|
||||
<color name="tv_darker">#01011C</color>
|
||||
<color name="tv_dark">#150082</color>
|
||||
<color name="tv_normal">#0300AC</color>
|
||||
<color name="tv_normal_press">#040190</color>
|
||||
<color name="tv_light">#322ED9</color>
|
||||
<color name="tv_lighter">#EAA</color>
|
||||
<color name="tv_gray">#cccccc</color>
|
||||
<color name="tv_gray_light">#DDDDDD</color>
|
||||
<color name="tv_white">#FFFFFF</color>
|
||||
<color name="tv_black">#000000</color>
|
||||
<!-- Text View -->
|
||||
<color name="tv_darker_trans">#33041741</color>
|
||||
<color name="tv_dark_trans">#50005baa</color>
|
||||
<color name="tv_normal_trans">#500a4cde</color>
|
||||
<color name="tv_light_trans">#33d92e32</color>
|
||||
|
||||
<!-- Theme about colors -->
|
||||
<color name="theme_default_primary">#536dfe</color>
|
||||
<color name="theme_default_primary_dark">#3f51b5</color>
|
||||
<color name="theme_accent">#ff4081</color>
|
||||
<color name="theme_window_background">#ECECEC</color>
|
||||
|
||||
<color name="card">#FAFAFA</color>
|
||||
|
||||
<color name="title_openSource">#212121</color>
|
||||
<color name="text_openSource">#727272</color>
|
||||
|
||||
<color name="dividerDark_openSource">#AAA</color>
|
||||
<color name="dividerLight_openSource">#DADADA</color>
|
||||
|
||||
<color name="default_progress_bar_color">#FF33B5E5</color>
|
||||
|
||||
<color name="crop__button_bar">#f3f3f3</color>
|
||||
<color name="crop__button_text">#666666</color>
|
||||
<color name="crop__selector_pressed">#1a000000</color>
|
||||
<color name="crop__selector_focused">#77000000</color>
|
||||
|
||||
<color name="drawer_background">#cfcfcf</color>
|
||||
|
||||
<!-- Action Bar -->
|
||||
<!-- <color name="ab_start">#2c2d31</color> -->
|
||||
<!-- <color name="ab_end">#2c2d31</color> -->
|
||||
<color name="ab_start">#002F5F</color>
|
||||
<color name="ab_end">#002F5F</color>
|
||||
|
||||
<!-- Gradient -->
|
||||
<color name="gradient_start">#5E9CD8</color>
|
||||
<color name="gradient_end">#2F5275</color>
|
||||
<!--#ed3e58-->
|
||||
<!--#ee314d-->
|
||||
<!--d0132f-->
|
||||
<!--c80b27-->
|
||||
<color name="child_view_background">#FFDFE5</color>
|
||||
<color name="login_color">#002F5F</color>
|
||||
</resources>
|
|
@ -0,0 +1,199 @@
|
|||
package com.adins.mss.base.dialogfragments;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.NewMainActivity;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.dynamicform.CustomerFragment;
|
||||
import com.adins.mss.base.dynamicform.FormBean;
|
||||
import com.adins.mss.base.dynamicform.QuestionSetTask;
|
||||
import com.adins.mss.base.dynamicform.SurveyHeaderBean;
|
||||
import com.adins.mss.base.todo.form.NewTaskAdapter;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.androidquery.AQuery;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.DaoException;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 10/23/2017.
|
||||
*/
|
||||
|
||||
public abstract class NewTaskDialog extends DialogFragment {
|
||||
protected View view;
|
||||
protected AQuery query;
|
||||
protected List<Scheme> objects;
|
||||
private User user = GlobalData.getSharedGlobalData().getUser();
|
||||
SurveyHeaderBean header;
|
||||
Scheme lastUpdateScheme;
|
||||
public Boolean isEditable = false;
|
||||
private FirebaseAnalytics screenName;
|
||||
public NewTaskDialog() {
|
||||
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Dialog_NoTitle);
|
||||
}
|
||||
|
||||
protected abstract NewTaskAdapter getNewTaskAdapter();
|
||||
|
||||
protected TaskH setNewTaskH(Scheme scheme) {
|
||||
TaskH taskH = null;
|
||||
taskH = new TaskH();
|
||||
taskH.setUuid_task_h(Tool.getUUID());
|
||||
taskH.setUser(user);
|
||||
taskH.setScheme(scheme);
|
||||
taskH.setStatus(TaskHDataAccess.STATUS_SEND_INIT);
|
||||
taskH.setIs_prepocessed(TaskHDataAccess.STATUS_SEND_INIT);
|
||||
taskH.setIs_verification("0");
|
||||
return taskH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
screenName = FirebaseAnalytics.getInstance(getActivity());
|
||||
View view = inflater.inflate(R.layout.new_dialog_new_task, container, false);
|
||||
|
||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
|
||||
WindowManager.LayoutParams wmlp = getDialog().getWindow().getAttributes();
|
||||
wmlp.gravity = Gravity.BOTTOM;
|
||||
wmlp.windowAnimations = R.style.DialogAnimation;
|
||||
getDialog().getWindow().setAttributes(wmlp);
|
||||
|
||||
query = new AQuery(view);
|
||||
query.id(android.R.id.list).adapter(getNewTaskAdapter());
|
||||
query.id(android.R.id.list).itemClicked(this, "itemClick");
|
||||
|
||||
Button btnCancel = (Button) view.findViewById(R.id.btnCancel);
|
||||
btnCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
if (SchemeDataAccess.getAll(getContext()).isEmpty()) {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.no_scheme_found), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(getActivity(), getString(R.string.screen_name_new_order), null);
|
||||
}
|
||||
|
||||
public void itemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
Scheme selectedScheme = getNewTaskAdapter().getItem(position);
|
||||
TaskH selectedTask = setNewTaskH(selectedScheme);
|
||||
header = new SurveyHeaderBean(selectedTask);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(CustomerFragment.SURVEY_HEADER, header);
|
||||
bundle.putInt(CustomerFragment.SURVEY_MODE, Global.MODE_NEW_SURVEY);
|
||||
if(selectedScheme.getForm_type().equals("KTP")){
|
||||
CustomerFragment.setHeader(header);
|
||||
int mode = Global.MODE_NEW_SURVEY;
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
isEditable = false;
|
||||
GlobalData.getSharedGlobalData().setDoingTask(true);
|
||||
CustomerFragment.CheckScheme checkScheme = new CustomerFragment.CheckScheme(getActivity());
|
||||
checkScheme.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
Scheme scheme = null;
|
||||
try {
|
||||
String uuidScheme = header.getUuid_scheme();
|
||||
scheme = SchemeDataAccess.getOne(getActivity(), uuidScheme);
|
||||
} catch (DaoException e) {
|
||||
ACRA.getErrorReporter().putCustomData("errorGetScheme", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorGetSchemeTime", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Get Scheme"));
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
ACRA.getErrorReporter().putCustomData("errorGetScheme", e.getMessage());
|
||||
ACRA.getErrorReporter().putCustomData("errorGetSchemeTime", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
|
||||
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat Get Scheme"));
|
||||
}
|
||||
|
||||
if (scheme != null) {
|
||||
header.setScheme(scheme);
|
||||
FormBean formBean = new FormBean(scheme);
|
||||
if (lastUpdateScheme != null) {
|
||||
formBean = null;
|
||||
formBean = new FormBean(lastUpdateScheme);
|
||||
}
|
||||
if (header.getStart_date() == null) {
|
||||
if (header.getPriority() != null && header.getPriority().length() > 0) {
|
||||
} else {
|
||||
header.setStart_date(Tool.getSystemDateTime());
|
||||
}
|
||||
}
|
||||
header.setForm(formBean);
|
||||
header.setIs_preview_server(formBean.getIs_preview_server());
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
if (isEditable) {
|
||||
mode = Global.MODE_NEW_SURVEY;
|
||||
header.setStatus(TaskHDataAccess.STATUS_SEND_DOWNLOAD);
|
||||
}
|
||||
extras.putInt(Global.BUND_KEY_MODE_SURVEY, mode);
|
||||
extras.putString(Global.BUND_KEY_UUID_TASKH, header.getUuid_task_h());
|
||||
extras.putSerializable(Global.BUND_KEY_SURVEY_BEAN, header);
|
||||
extras.putSerializable(Global.BUND_KEY_FORM_BEAN, formBean);
|
||||
|
||||
QuestionSetTask task = new QuestionSetTask(getActivity(), extras);
|
||||
task.execute();
|
||||
dismiss();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getActivity().getString(R.string.request_error),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
dismiss();
|
||||
}
|
||||
}else {
|
||||
Fragment fragment = CustomerFragment.create(bundle);
|
||||
|
||||
dismiss();
|
||||
|
||||
FragmentTransaction transaction = NewMainActivity.fragmentManager.beginTransaction();
|
||||
transaction.setCustomAnimations(R.anim.activity_open_translate, R.anim.activity_close_scale, R.anim.activity_open_scale, R.anim.activity_close_translate);
|
||||
transaction.replace(R.id.content_frame, fragment);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
include ':msscoll', ':databasegenerator', ':mssbase'
|
Loading…
Add table
Add a link
Reference in a new issue