mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-07-01 05:14:17 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp"
|
||||
android:background="@drawable/spinner_background" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtTaskID"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dummy_task_id"
|
||||
android:textColor="@color/tv_white"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgStatus"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_schema"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtName"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:text="@string/dummy_header_name_2"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/tv_white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:lines="1"
|
||||
android:text="@string/dummy_date"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/tv_white" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center_horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtStatusTask"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dummy_status_task"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/tv_white"
|
||||
android:textSize="10dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtScheme"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:textColor="@color/tv_white"
|
||||
android:minLines="2"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/dummy_scheme_name"
|
||||
android:textSize="10dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,53 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/changeLanguage"
|
||||
android:textColor="@color/gradient_end"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp">
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/english_language"
|
||||
android:id="@+id/rdEnglish"
|
||||
android:checked="true"
|
||||
android:padding="5dp"/>
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/indonesian_language"
|
||||
android:id="@+id/rdBahasa"
|
||||
android:checked="false"
|
||||
android:padding="5dp"/>
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSave"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:text="@string/btnSave"
|
||||
android:textColor="@color/fontColorWhite"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,519 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.soundcloud.android.crop;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.BitmapRegionDecoder;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.net.Uri;
|
||||
import android.opengl.GLES10;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.timeline.Constants;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.camerainapp.helper.Logger;
|
||||
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
|
||||
import com.adins.mss.foundation.image.ImageManipulation;
|
||||
import com.adins.mss.foundation.image.Utils;
|
||||
import com.soundcloud.android.crop.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/*
|
||||
* Modified from original in AOSP.
|
||||
*/
|
||||
public class CropImageActivity extends MonitoredActivity {
|
||||
|
||||
private static final boolean IN_MEMORY_CROP = Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD_MR1;
|
||||
private static final int SIZE_DEFAULT = 2048;
|
||||
private static final int SIZE_LIMIT = 4096;
|
||||
|
||||
private final Handler handler = new Handler();
|
||||
|
||||
private int aspectX;
|
||||
private int aspectY;
|
||||
|
||||
// Output image size
|
||||
private int maxX;
|
||||
private int maxY;
|
||||
private int exifRotation;
|
||||
|
||||
private Uri sourceUri;
|
||||
private Uri saveUri;
|
||||
|
||||
private boolean isSaving;
|
||||
|
||||
private int sampleSize;
|
||||
private RotateBitmap rotateBitmap;
|
||||
private CropImageView imageView;
|
||||
private HighlightView cropView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.crop__activity_crop);
|
||||
try {
|
||||
initViews();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
|
||||
setupFromIntent();
|
||||
if (rotateBitmap == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
startCrop();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
imageView = (CropImageView) findViewById(R.id.crop_image);
|
||||
imageView.context = this;
|
||||
imageView.setDrawingCacheEnabled(true);
|
||||
imageView.setRecycler(new ImageViewTouchBase.Recycler() {
|
||||
@Override
|
||||
public void recycle(Bitmap b) {
|
||||
b.recycle();
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btn_done).setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
onSaveClicked();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btn_rotate).setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
// onRotateClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void onRotateClick() {
|
||||
// TODO Masih Belum Bener
|
||||
Bitmap croppedImage = Bitmap.createBitmap(imageView.getDrawingCache());
|
||||
croppedImage = ImageManipulation.rotateImage(croppedImage, 90);
|
||||
rotateBitmap.setBitmap(croppedImage);
|
||||
new Cropper().makeDefault();
|
||||
imageView.setImageBitmapResetBase(croppedImage, true);
|
||||
imageView.center(true, true);
|
||||
}
|
||||
|
||||
private void setupFromIntent() {
|
||||
Intent intent = getIntent();
|
||||
Bundle extras = intent.getExtras();
|
||||
|
||||
if (extras != null) {
|
||||
aspectX = extras.getInt(Crop.Extra.ASPECT_X);
|
||||
aspectY = extras.getInt(Crop.Extra.ASPECT_Y);
|
||||
maxX = extras.getInt(Crop.Extra.MAX_X);
|
||||
maxY = extras.getInt(Crop.Extra.MAX_Y);
|
||||
saveUri = extras.getParcelable(MediaStore.EXTRA_OUTPUT);
|
||||
}
|
||||
|
||||
sourceUri = intent.getData();
|
||||
if (sourceUri != null) {
|
||||
exifRotation = CropUtil.getExifRotation(CropUtil.getFromMediaUri(getContentResolver(), sourceUri));
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
sampleSize = calculateBitmapSampleSize(sourceUri);
|
||||
is = getContentResolver().openInputStream(sourceUri);
|
||||
BitmapFactory.Options option = new BitmapFactory.Options();
|
||||
option.inSampleSize = sampleSize;
|
||||
rotateBitmap = new RotateBitmap(BitmapFactory.decodeStream(is, null, option), exifRotation);
|
||||
} catch (IOException e) {
|
||||
Log.e("Error reading image: " + e.getMessage(), e);
|
||||
setResultException(e);
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.e("OOM reading image: " + e.getMessage(), e);
|
||||
setResultException(e);
|
||||
} finally {
|
||||
CropUtil.closeSilently(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateBitmapSampleSize(Uri bitmapUri) throws IOException {
|
||||
InputStream is = null;
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
try {
|
||||
is = getContentResolver().openInputStream(bitmapUri);
|
||||
BitmapFactory.decodeStream(is, null, options); // Just get image size
|
||||
} finally {
|
||||
CropUtil.closeSilently(is);
|
||||
}
|
||||
|
||||
int maxSize = getMaxImageSize();
|
||||
int sampleSize = 1;
|
||||
while (options.outHeight / sampleSize > maxSize || options.outWidth / sampleSize > maxSize) {
|
||||
sampleSize = sampleSize << 1;
|
||||
}
|
||||
return sampleSize;
|
||||
}
|
||||
|
||||
private int getMaxImageSize() {
|
||||
int textureLimit = getMaxTextureSize();
|
||||
if (textureLimit == 0) {
|
||||
return SIZE_DEFAULT;
|
||||
} else {
|
||||
return Math.min(textureLimit, SIZE_LIMIT);
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxTextureSize() {
|
||||
// The OpenGL texture size is the maximum size that can be drawn in an ImageView
|
||||
int[] maxSize = new int[1];
|
||||
GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
|
||||
return maxSize[0];
|
||||
}
|
||||
|
||||
private void startCrop() {
|
||||
if (isFinishing()) {
|
||||
return;
|
||||
}
|
||||
imageView.setImageRotateBitmapResetBase(rotateBitmap, true);
|
||||
CropUtil.startBackgroundJob(this, null, getResources().getString(R.string.crop__wait),
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (imageView.getScale() == 1F) {
|
||||
imageView.center(true, true);
|
||||
}
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
new Cropper().crop();
|
||||
}
|
||||
}, handler
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* This should use the decode/crop/encode single step API so that the whole
|
||||
* (possibly large) Bitmap doesn't need to be read into memory
|
||||
*/
|
||||
private void onSaveClicked() {
|
||||
if (cropView == null || isSaving) {
|
||||
return;
|
||||
}
|
||||
isSaving = true;
|
||||
|
||||
Bitmap croppedImage = null;
|
||||
Rect r = cropView.getScaledCropRect(sampleSize);
|
||||
int width = r.width();
|
||||
int height = r.height();
|
||||
|
||||
int outWidth = width, outHeight = height;
|
||||
if (maxX > 0 && maxY > 0 && (width > maxX || height > maxY)) {
|
||||
float ratio = (float) width / (float) height;
|
||||
if ((float) maxX / (float) maxY > ratio) {
|
||||
outHeight = maxY;
|
||||
outWidth = (int) ((float) maxY * ratio + .5f);
|
||||
} else {
|
||||
outWidth = maxX;
|
||||
outHeight = (int) ((float) maxX / ratio + .5f);
|
||||
}
|
||||
}
|
||||
|
||||
if (IN_MEMORY_CROP && rotateBitmap != null) {
|
||||
croppedImage = inMemoryCrop(rotateBitmap, croppedImage, r, width, height, outWidth, outHeight);
|
||||
if (croppedImage != null) {
|
||||
imageView.setImageBitmapResetBase(croppedImage, true);
|
||||
imageView.center(true, true);
|
||||
imageView.highlightViews.clear();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
croppedImage = decodeRegionCrop(croppedImage, r);
|
||||
} catch (IllegalArgumentException e) {
|
||||
setResultException(e);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (croppedImage != null) {
|
||||
imageView.setImageRotateBitmapResetBase(new RotateBitmap(croppedImage, exifRotation), true);
|
||||
imageView.center(true, true);
|
||||
imageView.highlightViews.clear();
|
||||
}
|
||||
}
|
||||
saveImage(croppedImage);
|
||||
}
|
||||
|
||||
private void saveImage(Bitmap croppedImage) {
|
||||
if (croppedImage != null) {
|
||||
final Bitmap b = croppedImage;
|
||||
CropUtil.startBackgroundJob(this, null, getResources().getString(R.string.crop__saving),
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
saveOutput(b);
|
||||
}
|
||||
}, handler
|
||||
);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(10)
|
||||
private Bitmap decodeRegionCrop(Bitmap croppedImage, Rect rect) {
|
||||
// Release memory now
|
||||
clearImageView();
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = getContentResolver().openInputStream(sourceUri);
|
||||
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(is, false);
|
||||
final int width = decoder.getWidth();
|
||||
final int height = decoder.getHeight();
|
||||
|
||||
if (exifRotation != 0) {
|
||||
// Adjust crop area to account for image rotation
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.setRotate(-exifRotation);
|
||||
|
||||
RectF adjusted = new RectF();
|
||||
matrix.mapRect(adjusted, new RectF(rect));
|
||||
|
||||
// Adjust to account for origin at 0,0
|
||||
adjusted.offset(adjusted.left < 0 ? width : 0, adjusted.top < 0 ? height : 0);
|
||||
rect = new Rect((int) adjusted.left, (int) adjusted.top, (int) adjusted.right, (int) adjusted.bottom);
|
||||
}
|
||||
|
||||
try {
|
||||
croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Rethrow with some extra information
|
||||
throw new IllegalArgumentException("Rectangle " + rect + " is outside of the image ("
|
||||
+ width + "," + height + "," + exifRotation + ")", e);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Logger.e("Error cropping image: " + e.getMessage(), e);
|
||||
finish();
|
||||
} catch (OutOfMemoryError e) {
|
||||
Logger.e("OOM cropping image: " + e.getMessage(), e);
|
||||
setResultException(e);
|
||||
} finally {
|
||||
CropUtil.closeSilently(is);
|
||||
}
|
||||
return croppedImage;
|
||||
}
|
||||
|
||||
private Bitmap inMemoryCrop(RotateBitmap rotateBitmap, Bitmap croppedImage, Rect r,
|
||||
int width, int height, int outWidth, int outHeight) {
|
||||
// In-memory crop means potential OOM errors,
|
||||
// but we have no choice as we can't selectively decode a bitmap with this API level
|
||||
System.gc();
|
||||
|
||||
try {
|
||||
croppedImage = Bitmap.createBitmap(outWidth, outHeight, Bitmap.Config.RGB_565);
|
||||
|
||||
Canvas canvas = new Canvas(croppedImage);
|
||||
RectF dstRect = new RectF(0, 0, width, height);
|
||||
|
||||
Matrix m = new Matrix();
|
||||
m.setRectToRect(new RectF(r), dstRect, Matrix.ScaleToFit.FILL);
|
||||
m.preConcat(rotateBitmap.getRotateMatrix());
|
||||
canvas.drawBitmap(rotateBitmap.getBitmap(), m, null);
|
||||
} catch (OutOfMemoryError e) {
|
||||
Logger.e("OOM cropping image: " + e.getMessage(), e);
|
||||
setResultException(e);
|
||||
System.gc();
|
||||
}
|
||||
|
||||
// Release bitmap memory as soon as possible
|
||||
clearImageView();
|
||||
return croppedImage;
|
||||
}
|
||||
|
||||
private void clearImageView() {
|
||||
imageView.clear();
|
||||
if (rotateBitmap != null) {
|
||||
rotateBitmap.recycle();
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
private void saveOutput(Bitmap croppedImage) {
|
||||
if (saveUri != null) {
|
||||
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = getContentResolver().openOutputStream(saveUri);
|
||||
if (outputStream != null) {
|
||||
croppedImage.compress(Bitmap.CompressFormat.JPEG, 70, outputStream);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
setResultException(e);
|
||||
Logger.e("Cannot open file: " + saveUri, e);
|
||||
} finally {
|
||||
CropUtil.closeSilently(outputStream);
|
||||
}
|
||||
|
||||
if (!IN_MEMORY_CROP) {
|
||||
// In-memory crop negates the rotation
|
||||
CropUtil.copyExifRotation(
|
||||
CropUtil.getFromMediaUri(getContentResolver(), sourceUri),
|
||||
CropUtil.getFromMediaUri(getContentResolver(), saveUri)
|
||||
);
|
||||
}
|
||||
|
||||
setResultUri(saveUri);
|
||||
}
|
||||
|
||||
final Bitmap b = ImageManipulation.rotateImage(croppedImage, exifRotation);
|
||||
// croppedImage;
|
||||
|
||||
if (Constants.flag_edit == 0) {
|
||||
String temp_uuid_user = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
User user = UserDataAccess.getOne(imageView.context, temp_uuid_user);
|
||||
user.setImage_cover(Utils.bitmapToByte(b));
|
||||
UserDataAccess.addOrReplace(imageView.context, user);
|
||||
//GlobalData.getSharedGlobalData().setUser(user);
|
||||
} else {
|
||||
String temp_uuid_user = GlobalData.getSharedGlobalData().getUser().getUuid_user();
|
||||
User user = UserDataAccess.getOne(imageView.context, temp_uuid_user);
|
||||
user.setImage_profile(Utils.bitmapToByte(b));
|
||||
UserDataAccess.addOrReplace(imageView.context, user);
|
||||
//GlobalData.getSharedGlobalData().setUser(user);
|
||||
}
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
imageView.clear();
|
||||
b.recycle();
|
||||
}
|
||||
});
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (rotateBitmap != null) {
|
||||
rotateBitmap.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSaving() {
|
||||
return isSaving;
|
||||
}
|
||||
|
||||
private void setResultUri(Uri uri) {
|
||||
setResult(RESULT_OK, new Intent().putExtra(MediaStore.EXTRA_OUTPUT, uri));
|
||||
}
|
||||
|
||||
private void setResultException(Throwable throwable) {
|
||||
setResult(Crop.RESULT_ERROR, new Intent().putExtra(Crop.Extra.ERROR, throwable));
|
||||
}
|
||||
|
||||
private class Cropper {
|
||||
|
||||
private void makeDefault() {
|
||||
if (rotateBitmap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
HighlightView hv = new HighlightView(imageView);
|
||||
final int width = rotateBitmap.getWidth();
|
||||
final int height = rotateBitmap.getHeight();
|
||||
|
||||
Rect imageRect = new Rect(0, 0, width, height);
|
||||
|
||||
// Make the default size about 4/5 of the width or height
|
||||
int cropWidth = Math.min(width, height) * 4 / 5;
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
int cropHeight = cropWidth;
|
||||
|
||||
if (aspectX != 0 && aspectY != 0) {
|
||||
if (aspectX > aspectY) {
|
||||
cropHeight = cropWidth * aspectY / aspectX;
|
||||
} else {
|
||||
cropWidth = cropHeight * aspectX / aspectY;
|
||||
}
|
||||
}
|
||||
|
||||
int x = (width - cropWidth) / 2;
|
||||
int y = (height - cropHeight) / 2;
|
||||
|
||||
RectF cropRect = new RectF(x, y, x + cropWidth, y + cropHeight);
|
||||
hv.setup(imageView.getUnrotatedMatrix(), imageRect, cropRect, aspectX != 0 && aspectY != 0);
|
||||
imageView.add(hv);
|
||||
}
|
||||
|
||||
public void crop() {
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
makeDefault();
|
||||
imageView.invalidate();
|
||||
if (imageView.highlightViews.size() == 1) {
|
||||
cropView = imageView.highlightViews.get(0);
|
||||
cropView.setFocus(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.adins.mss.foundation.UserHelp.Bean;
|
||||
|
||||
public class UserHelpView {
|
||||
private String viewid;
|
||||
private UserHelpProperties properties;
|
||||
|
||||
public String getViewid() {
|
||||
return viewid;
|
||||
}
|
||||
|
||||
public void setViewid(String viewid) {
|
||||
this.viewid = viewid;
|
||||
}
|
||||
|
||||
public UserHelpProperties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(UserHelpProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,262 @@
|
|||
package com.adins.mss.svy.reassignment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.OnGroupClickListener;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.formatter.Formatter;
|
||||
import com.adins.mss.svy.assignment.OrderAssignmentResult;
|
||||
import com.adins.mss.svy.models.ExpandableListAdapter;
|
||||
import com.adins.mss.svy.reassignment.JsonResponseServer.ResponseServer;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class OrderReassignmentResult extends ResultOrderActivity implements OnGroupClickListener{
|
||||
public static final String ON_SURVEY = "OnSurvey";
|
||||
public static final String ON_PROGRESS_SURVEY = "On Progress Survey";
|
||||
public static final String ON_CA = "OnCA";
|
||||
public static final String ON_CA1 = "On CA";
|
||||
private int taskType;
|
||||
private String searchByStatus;
|
||||
private List<ResponseServer> responseServer;
|
||||
ExpandableListAdapter listAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
taskType = this.getIntent().getIntExtra(Global.BUND_KEY_TASK_TYPE, 0);
|
||||
}
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
expListView.setGroupIndicator(null);
|
||||
expListView.setOnGroupClickListener(this);
|
||||
|
||||
Intent i = getIntent();
|
||||
searchByStatus = i.getStringExtra("status");
|
||||
if(searchByStatus==null){
|
||||
searchByStatus="1";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
Context context = newBase;
|
||||
Locale locale;
|
||||
try{
|
||||
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} catch (Exception e) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} finally {
|
||||
super.attachBaseContext(context);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getUsedURL() {
|
||||
return GlobalData.getSharedGlobalData().getURL_GET_LIST_REASSIGNMENT();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<NameValuePair> generateRequestParam() throws ParseException {
|
||||
String sdtSDate = "1";
|
||||
String sdtEDate = "1";
|
||||
if(startDate==null||endDate==null||"".equalsIgnoreCase(startDate)||"".equalsIgnoreCase(endDate)
|
||||
||"1".equalsIgnoreCase(startDate)||"1".equalsIgnoreCase(endDate)){
|
||||
|
||||
}else{
|
||||
//convert format date biar bisa di tranlate di DB servernya
|
||||
SimpleDateFormat f = new SimpleDateFormat(Global.DATE_STR_FORMAT);
|
||||
|
||||
Date sDate,eDate;
|
||||
sDate = f.parse(startDate);
|
||||
eDate = f.parse(endDate);
|
||||
sdtSDate = Formatter.formatDate(sDate, Global.DATE_STR_FORMAT_GSON);
|
||||
sdtEDate = Formatter.formatDate(eDate, Global.DATE_STR_FORMAT_GSON);
|
||||
}
|
||||
|
||||
if (orderNumber == null) orderNumber = "1";
|
||||
|
||||
String flag = flagParamForType(this.taskType);
|
||||
|
||||
List<NameValuePair> param = new ArrayList<NameValuePair>();
|
||||
|
||||
param.add(new BasicNameValuePair("startdate", sdtSDate));
|
||||
param.add(new BasicNameValuePair("enddate", sdtEDate));
|
||||
param.add(new BasicNameValuePair("ordernumber", orderNumber));
|
||||
param.add(new BasicNameValuePair("flag", flag));
|
||||
param.add(new BasicNameValuePair("status", searchByStatus ));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
protected String flagParamForType(int taskType){
|
||||
|
||||
String flagParam;
|
||||
switch (taskType) {
|
||||
case Global.TASK_ORDER_ASSIGNMENT:
|
||||
flagParam = Global.FLAG_FOR_ORDERASSIGNMENT;
|
||||
break;
|
||||
case Global.TASK_ORDER_REASSIGNMENT:
|
||||
flagParam = Global.FLAG_FOR_ORDERREASSIGNMENT;
|
||||
break;
|
||||
case Global.TASK_CANCEL_ORDER:
|
||||
//bangkit 20141027 change param from UO to UOC
|
||||
flagParam = Global.FLAG_FOR_CANCELORDER;
|
||||
break;
|
||||
default:
|
||||
flagParam = "";
|
||||
break;
|
||||
}
|
||||
return flagParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition,
|
||||
long id) {
|
||||
// TODO Auto-generated method stub
|
||||
String nomorOrder = responseServer.get(groupPosition).getKey();
|
||||
String uuid_task_h = responseServer.get(groupPosition).getFlag();
|
||||
String formName = responseServer.get(groupPosition).getFormName();
|
||||
gotoDetailData(taskType, nomorOrder, uuid_task_h, formName);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void gotoDetailData(int taskType, String nomorOrder, String uuid_task_h, String formName){
|
||||
|
||||
Intent intent = null;
|
||||
|
||||
switch (taskType) {
|
||||
case Global.TASK_ORDER_ASSIGNMENT:
|
||||
break;
|
||||
case Global.TASK_ORDER_REASSIGNMENT:
|
||||
intent = new Intent(this, OrderAssignmentResult.class);
|
||||
intent.putExtra(Global.BUND_KEY_ORDERNO, nomorOrder);
|
||||
intent.putExtra(Global.BUND_KEY_FORM_NAME, formName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
intent.putExtra(Global.BUND_KEY_TASK_TYPE, taskType);
|
||||
intent.putExtra(Global.BUND_KEY_ORDERNO, nomorOrder);
|
||||
intent.putExtra(Global.BUND_KEY_UUID_TASKH, uuid_task_h);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
protected String flagParamForStatusCode(String code){
|
||||
String flagParam;
|
||||
|
||||
if(ON_SURVEY.equalsIgnoreCase(code)){
|
||||
flagParam = ON_PROGRESS_SURVEY;
|
||||
}else if (ON_CA.equalsIgnoreCase(code)){
|
||||
flagParam = ON_CA1;
|
||||
}else{
|
||||
flagParam = "";
|
||||
}
|
||||
|
||||
return flagParam;
|
||||
}
|
||||
@Override
|
||||
protected void processServerResponse(String result) {
|
||||
listDataHeader = new ArrayList<String>();
|
||||
listDataChild = new HashMap<String, List<String>>();
|
||||
LinkedHashMap<String, String> listResult = new LinkedHashMap<>();
|
||||
|
||||
try {
|
||||
JsonResponseServer resultOrder= GsonHelper.fromJson(result, JsonResponseServer.class);
|
||||
if(resultOrder.getStatus().getCode() == 0){
|
||||
responseServer = resultOrder.getListResponseServer();
|
||||
if(responseServer != null && responseServer.size() > 0){
|
||||
for(int i=0; i<responseServer.size(); i++){
|
||||
ResponseServer mobileBean = responseServer.get(i);
|
||||
|
||||
String orderNo = "";
|
||||
if(mobileBean.getKey()!=null)
|
||||
orderNo = mobileBean.getKey();
|
||||
String customerName = mobileBean.getValue();
|
||||
listResult.put(orderNo, customerName);
|
||||
listAdapter = new ExpandableListAdapter(this, listResult);
|
||||
expListView.setAdapter(listAdapter);
|
||||
}
|
||||
}
|
||||
else{
|
||||
String message;
|
||||
if(resultOrder.getStatus().getMessage()!=null){
|
||||
message = getString(com.adins.mss.base.R.string.data_not_found) +resultOrder.getStatus().getMessage();
|
||||
}else{
|
||||
message = getString(com.adins.mss.base.R.string.data_not_found);
|
||||
}
|
||||
final NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(this);
|
||||
builder.withTitle(getString(com.adins.mss.base.R.string.info_capital))
|
||||
.withMessage(message)
|
||||
.withButton1Text(getString(com.adins.mss.base.R.string.btnOk))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
builder.dismiss();
|
||||
finish();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}else{
|
||||
if(GlobalData.isRequireRelogin()){
|
||||
return;
|
||||
}
|
||||
final NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(this);
|
||||
builder.withTitle(getString(com.adins.mss.base.R.string.info_capital))
|
||||
.withMessage(getString(com.adins.mss.base.R.string.data_not_found))
|
||||
.withButton1Text(getString(com.adins.mss.base.R.string.btnOk))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
builder.dismiss();
|
||||
finish();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
if(Global.IS_DEV) System.out.println(e);
|
||||
final NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(this);
|
||||
builder.withTitle(getString(com.adins.mss.base.R.string.info_capital))
|
||||
.withMessage(e.getMessage())
|
||||
.withButton1Text(getString(com.adins.mss.base.R.string.btnOk))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
builder.dismiss();
|
||||
finish();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
After Width: | Height: | Size: 341 B |
Loading…
Add table
Add a link
Reference in a new issue