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: 6.7 KiB |
|
@ -0,0 +1,170 @@
|
|||
package com.adins.mss.coll.fragments.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.adins.mss.base.dynamictheme.DynamicTheme;
|
||||
import com.adins.mss.base.dynamictheme.ThemeLoader;
|
||||
import com.adins.mss.base.dynamictheme.ThemeUtility;
|
||||
import com.adins.mss.coll.Navigator;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.commons.ViewManager;
|
||||
import com.adins.mss.coll.fragments.DepositReportDetailActivity;
|
||||
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.models.DepositReportAdapter;
|
||||
import com.adins.mss.dao.DepositReportH;
|
||||
import com.adins.mss.foundation.db.dataaccess.DepositReportHDataAccess;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by kusnendi.muhamad on 28/07/2017.
|
||||
*/
|
||||
|
||||
public class DepositReportView extends ViewManager implements ThemeLoader.ColorSetLoaderCallback {
|
||||
private Activity activity;
|
||||
private Context context;
|
||||
private DepositReportAdapter adapter;
|
||||
private NavigatorInterface navigator;
|
||||
private DepositReportInterface iDepositReport;
|
||||
private static Menu mainMenu;
|
||||
private View view;
|
||||
Button recapitulateButton;
|
||||
|
||||
public DepositReportView(Activity activity){
|
||||
super(activity);
|
||||
this.activity = activity;
|
||||
this.context = activity.getApplicationContext();
|
||||
this.navigator= new Navigator(context);
|
||||
iDepositReport= new DepositReportImpl(context);
|
||||
}
|
||||
|
||||
public View layoutInflater(LayoutInflater inflater, ViewGroup container) {
|
||||
view = inflater.inflate(R.layout.new_fragment_deposit_report, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish() {
|
||||
//Prepare Print Item for Deposit
|
||||
iDepositReport.insertPrintItemForDeposit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
recapitulateButton = (Button) view.findViewById(R.id.btnRecapitulate);
|
||||
recapitulateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
navigator.route(Navigator.DEPOSIT_REPORT_RECAPITULATE);
|
||||
//recapitulate();
|
||||
}
|
||||
});
|
||||
//Cleanup deposit report before today
|
||||
cleanup();
|
||||
//Load Data From Server
|
||||
iDepositReport.getDepositReportH(activity, this);
|
||||
}
|
||||
|
||||
private void loadSavedTheme(){
|
||||
ThemeLoader themeLoader = new ThemeLoader(context);
|
||||
themeLoader.loadSavedColorSet(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu) {
|
||||
mainMenu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOptionsItemSelected(int id) {
|
||||
switch (id) {
|
||||
case R.id.menuMore:
|
||||
mainMenu.findItem(R.id.recapitulation).setVisible(true);
|
||||
mainMenu.findItem(R.id.summary).setVisible(true);
|
||||
mainMenu.findItem(R.id.mnViewMap).setVisible(false);
|
||||
break;
|
||||
|
||||
case R.id.recapitulation:
|
||||
navigator.route(Navigator.DEPOSIT_REPORT_RECAPITULATE);
|
||||
break;
|
||||
|
||||
case R.id.summary:
|
||||
navigator.route(Navigator.DEPOSIT_REPORT_SUMMARIZE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
Date today = cal.getTime();
|
||||
|
||||
DepositReportHDataAccess.deleteDepositReport(activity, today);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleteTask(Object result) {
|
||||
final List<DepositReportH> reports = (List<DepositReportH>) result;
|
||||
ListView list = (ListView) activity.findViewById(R.id.listRecapitulation);
|
||||
adapter = new DepositReportAdapter(context, reports);
|
||||
list.setAdapter(adapter);
|
||||
|
||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
DepositReportDetailActivity.report = reports.get(position);
|
||||
Intent intent = new Intent(context, DepositReportDetailActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHasLoaded(DynamicTheme dynamicTheme) {
|
||||
if(dynamicTheme != null && dynamicTheme.getThemeItemList().size() > 0){
|
||||
applyTheme(dynamicTheme);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyTheme(DynamicTheme dynamicTheme){
|
||||
int btnPressedColor = Color.parseColor(ThemeUtility.getColorItemValue(dynamicTheme,"btn_bg_pressed"));
|
||||
int btnNormalColor = Color.parseColor(ThemeUtility.getColorItemValue(dynamicTheme,"btn_bg_normal"));
|
||||
int[][] states = new int[][] {
|
||||
new int[] { android.R.attr.state_pressed}, // pressed
|
||||
new int[] {} // normal
|
||||
};
|
||||
|
||||
int[] colorlist = new int[]{
|
||||
btnPressedColor,
|
||||
btnNormalColor
|
||||
};
|
||||
ColorStateList colorStateList = new ColorStateList(states,colorlist);
|
||||
ThemeUtility.setViewBackground(recapitulateButton,colorStateList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHasLoaded(DynamicTheme dynamicTheme, boolean needUpdate) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_grayscale">
|
||||
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/resultOrderlist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="10dp"
|
||||
android:divider="@android:color/white"
|
||||
android:childDivider="@android:color/white"
|
||||
android:dividerHeight="2dp"
|
||||
android:fadingEdge="none"/>
|
||||
|
||||
</RelativeLayout>
|
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
|
@ -0,0 +1,276 @@
|
|||
package com.adins.mss.base.authentication;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.syncfile.FileSyncHelper;
|
||||
import com.adins.mss.base.update.DownloadUpdate;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.User;
|
||||
import com.adins.mss.foundation.dialog.DialogManager;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.adins.mss.foundation.notification.Notification;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AuthenticationTask implements Authentication.AuthenticationHandler {
|
||||
public static final String LOGIN_PREFERENES = "login_preferences";
|
||||
public static onImportSuccess importSuccess;
|
||||
private ProgressDialog progressDialog;
|
||||
private FragmentActivity mContext;
|
||||
private Activity activity;
|
||||
|
||||
public AuthenticationTask(FragmentActivity context) {
|
||||
this.mContext = context;
|
||||
Notification.getSharedNotification().clearNotifAll(mContext);
|
||||
progressDialog = ProgressDialog.show(
|
||||
mContext, "",
|
||||
context.getString(R.string.authentication_user), true);
|
||||
String username = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
String password = GlobalData.getSharedGlobalData().getUser().getPassword();
|
||||
|
||||
PackageInfo pInfo = null;
|
||||
try {
|
||||
pInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
if (Global.IS_DEV)
|
||||
e.printStackTrace();
|
||||
}
|
||||
int buildNumber = 0;
|
||||
|
||||
if(pInfo != null) {
|
||||
Global.BUILD_VERSION = pInfo.versionCode;
|
||||
Global.APP_VERSION = pInfo.versionName;
|
||||
buildNumber = Global.BUILD_VERSION;
|
||||
}
|
||||
|
||||
Authentication.authenticateOnBackground(
|
||||
mContext,
|
||||
username,
|
||||
password,
|
||||
buildNumber,
|
||||
this);
|
||||
}
|
||||
|
||||
public AuthenticationTask(Activity context) {
|
||||
this.activity = context;
|
||||
Notification.getSharedNotification().clearNotifAll(mContext);
|
||||
progressDialog = ProgressDialog.show(
|
||||
mContext, "",
|
||||
context.getString(R.string.authentication_user), true);
|
||||
String username = GlobalData.getSharedGlobalData().getUser().getLogin_id();
|
||||
String password = GlobalData.getSharedGlobalData().getUser().getPassword();
|
||||
|
||||
PackageInfo pInfo = null;
|
||||
try {
|
||||
pInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
if (Global.IS_DEV)
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int buildNumber = 0;
|
||||
if(pInfo != null){
|
||||
Global.BUILD_VERSION = pInfo.versionCode;
|
||||
Global.APP_VERSION = pInfo.versionName;
|
||||
buildNumber = Global.BUILD_VERSION;
|
||||
}
|
||||
|
||||
Authentication.authenticateOnBackground(
|
||||
mContext,
|
||||
username,
|
||||
password,
|
||||
buildNumber,
|
||||
this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFail(Authentication authentication,
|
||||
HttpConnectionResult httpConnectionResult) {
|
||||
closeProgress();
|
||||
|
||||
//bong 6 may 15 - penjagaan message yang ditampilkan saat login dengan inactive user
|
||||
if (authentication == null) {
|
||||
if (httpConnectionResult != null) {
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
httpConnectionResult.getResult(),
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
} else {
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
mContext.getString(R.string.connection_failed),
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
//bong 7 may 15 - penjagaan jika belum login ke wifi
|
||||
MssResponseType responseFromServer = null;
|
||||
if (httpConnectionResult.isOK()) {
|
||||
responseFromServer = GsonHelper.fromJson(httpConnectionResult.getResult(), MssResponseType.class);
|
||||
|
||||
if (responseFromServer.getStatus().getCode() == Global.STATUS_CODE_APPL_CLEANSING) {
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
responseFromServer.getStatus().getMessage(),
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
mContext.getString(R.string.connection_failed_http) + httpConnectionResult.getStatusCode()
|
||||
+ mContext.getString(R.string.divider_vertical_bar) + httpConnectionResult.getResult(),
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginFail(Authentication auth, String message) {
|
||||
closeProgress();
|
||||
if (message.contains("Password") || message.contains("password") || message.contains("IMEI") || message.contains("imei")) {
|
||||
DialogManager.showForceExitAlert(mContext, mContext.getString(R.string.password_not_match));
|
||||
} else
|
||||
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onForceUpdate(Authentication auth, String message,
|
||||
String otaLink) {
|
||||
closeProgress();
|
||||
showForceUpdateDialog(otaLink);
|
||||
}
|
||||
|
||||
private void showForceUpdateDialog(final String otaLink) {
|
||||
NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(mContext)
|
||||
.withTitle(mContext.getString(R.string.server))
|
||||
.withMessage(mContext.getString(R.string.critical_update))
|
||||
.withButton1Text(mContext.getString(R.string.update)).setButton1Click(
|
||||
new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openUpdate(otaLink);
|
||||
}
|
||||
}
|
||||
).isCancelable(false)
|
||||
.isCancelableOnTouchOutside(false);
|
||||
builder.show();
|
||||
|
||||
}
|
||||
private void openUpdate(String otaLink) {
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
File file = new File(mContext.getApplicationContext().getFilesDir(), "app.apk");
|
||||
if (file.exists()) {
|
||||
Uri apkURI = FileProvider.getUriForFile(
|
||||
mContext.getApplicationContext(), mContext.getPackageName() + ".provider", file);
|
||||
intent.setDataAndType(apkURI, "application/vnd.android.package-archive");
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
DownloadUpdate downloadUpdate = new DownloadUpdate(mContext);
|
||||
downloadUpdate.execute(otaLink);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInactiveUser(Authentication auth) {
|
||||
closeProgress();
|
||||
DialogManager.UninstallerHandler(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginSuccess(Authentication authentication, String otaLink,
|
||||
boolean needUpdatePassword, boolean pwdExp,
|
||||
boolean needUpdateApplication, String message,
|
||||
User authenticatedUser) {
|
||||
closeProgress();
|
||||
importSuccess = new onImportSuccess();
|
||||
if (needUpdateApplication) {
|
||||
showAskForUpdateDialog(otaLink);
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalData.getSharedGlobalData().setUser(authenticatedUser);
|
||||
FileSyncHelper.senderID = 1;
|
||||
FileSyncHelper.startFileSync(mContext);
|
||||
}
|
||||
|
||||
private void goToSynchronize() {
|
||||
Utility.stopAllServices(mContext);
|
||||
Intent syncIntent = Global.syncIntent;
|
||||
mContext.startActivity(syncIntent);
|
||||
mContext.finish();
|
||||
}
|
||||
|
||||
private void showAskForUpdateDialog(final String otaLink) {
|
||||
final NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(mContext);
|
||||
builder.withTitle(mContext.getString(R.string.server)).isCancelableOnTouchOutside(false).isCancelable(false)
|
||||
.withMessage(mContext.getString(R.string.update_available))
|
||||
.withButton1Text(mContext.getString(R.string.later))
|
||||
.setButton1Click(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
builder.dismiss();
|
||||
FileSyncHelper.senderID = 1;
|
||||
FileSyncHelper.startFileSync(mContext);
|
||||
}
|
||||
})
|
||||
.withButton2Text(mContext.getString(R.string.update))
|
||||
.setButton2Click(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
builder.dismiss();
|
||||
openUpdate(otaLink);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
private void closeProgress() {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public class onImportSuccess extends Handler {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
Bundle data = msg.getData();
|
||||
boolean success = data.getBoolean("importSuccess", false);
|
||||
if (success) {
|
||||
goToSynchronize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
package com.adins.mss.base.dynamicform.form.questions.viewholder;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.depositreport.GetImageTask;
|
||||
import com.adins.mss.base.dynamicform.CustomerFragment;
|
||||
import com.adins.mss.base.dynamicform.form.questions.ImageViewerActivity;
|
||||
import com.adins.mss.base.dynamicform.form.questions.OnQuestionClickListener;
|
||||
import com.adins.mss.base.timeline.MapsViewer;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.image.Utils;
|
||||
import com.adins.mss.foundation.questiongenerator.QuestionBean;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by gigin.ginanjar on 06/09/2016.
|
||||
*/
|
||||
public class ReviewImageViewHolder extends RecyclerView.ViewHolder implements GetImageTask.GetImageData {
|
||||
public RelativeLayout layout;
|
||||
public TextView mLabelNo;
|
||||
public TextView mQuestionLabel;
|
||||
public TextView mQuestionAnswer;
|
||||
public ImageView mImageAnswer;
|
||||
public ImageView mThumbLocation;
|
||||
public QuestionBean bean;
|
||||
public FragmentActivity mActivity;
|
||||
public OnQuestionClickListener listener;
|
||||
|
||||
public ReviewImageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
layout = (RelativeLayout) itemView.findViewById(R.id.imageReviewLayout);
|
||||
mLabelNo = (TextView) itemView.findViewById(R.id.questionNoLabel);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionImageLabel);
|
||||
mQuestionAnswer = (TextView) itemView.findViewById(R.id.questionImageAnswer);
|
||||
mThumbLocation = (ImageView) itemView.findViewById(R.id.imgLocationAnswer);
|
||||
mImageAnswer = (ImageView) itemView.findViewById(R.id.imgPhotoAnswer);
|
||||
}
|
||||
|
||||
public ReviewImageViewHolder(View itemView, FragmentActivity activity, OnQuestionClickListener listener) {
|
||||
super(itemView);
|
||||
layout = (RelativeLayout) itemView.findViewById(R.id.imageReviewLayout);
|
||||
mLabelNo = (TextView) itemView.findViewById(R.id.questionNoLabel);
|
||||
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionImageLabel);
|
||||
mQuestionAnswer = (TextView) itemView.findViewById(R.id.questionImageAnswer);
|
||||
mThumbLocation = (ImageView) itemView.findViewById(R.id.imgLocationAnswer);
|
||||
mImageAnswer = (ImageView) itemView.findViewById(R.id.imgPhotoAnswer);
|
||||
mActivity = activity;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void bind(final QuestionBean item, final int group, final int number) {
|
||||
bean = item;
|
||||
mLabelNo.setText(number + ".");
|
||||
String qLabel = bean.getQuestion_label();
|
||||
mQuestionLabel.setText(qLabel);
|
||||
String answerType = bean.getAnswer_type();
|
||||
setImageAnswer(answerType);
|
||||
layout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onReviewClickListener(bean, group, number - 1);
|
||||
}
|
||||
});
|
||||
if (Tool.isHaveLocation(bean.getAnswer_type())) {
|
||||
mThumbLocation.setVisibility(View.VISIBLE);
|
||||
mThumbLocation.setImageResource(R.drawable.ic_absent);
|
||||
} else {
|
||||
mThumbLocation.setVisibility(View.GONE);
|
||||
}
|
||||
String qAnswer = bean.getAnswer();
|
||||
if (qAnswer != null && !qAnswer.isEmpty()) {
|
||||
mQuestionAnswer.setText(qAnswer);
|
||||
} else {
|
||||
mQuestionAnswer.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private void setImageAnswer(String answerType) {
|
||||
bindImageAnswer();
|
||||
}
|
||||
|
||||
private void bindImageAnswer() {
|
||||
byte[] img = bean.getImgAnswer();
|
||||
if (img != null && img.length > 0) {
|
||||
new BitmapWorkerTask(mImageAnswer).execute(bean);
|
||||
mImageAnswer.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Global.getSharedGlobal().setIsViewer(true);
|
||||
Bundle extras = new Bundle();
|
||||
extras.putByteArray(ImageViewerActivity.BUND_KEY_IMAGE, bean.getImgAnswer());
|
||||
extras.putInt(ImageViewerActivity.BUND_KEY_IMAGE_QUALITY, Utils.picQuality);
|
||||
extras.putBoolean(ImageViewerActivity.BUND_KEY_IMAGE_ISVIEWER, Global.getSharedGlobal().getIsViewer());
|
||||
Intent intent = new Intent(mActivity, ImageViewerActivity.class);
|
||||
intent.putExtras(extras);
|
||||
mActivity.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
mThumbLocation.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (bean.getLocationInfo() != null) {
|
||||
try {
|
||||
String lat = bean.getLocationInfo().getLatitude();
|
||||
String lng = bean.getLocationInfo().getLongitude();
|
||||
int accuracy = bean.getLocationInfo().getAccuracy();
|
||||
Intent intent = new Intent(mActivity, MapsViewer.class);
|
||||
intent.putExtra("latitude", lat);
|
||||
intent.putExtra("longitude", lng);
|
||||
intent.putExtra("accuracy", accuracy);
|
||||
mActivity.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
String lat = bean.getLatitude();
|
||||
String lng = bean.getLongitude();
|
||||
Intent intent = new Intent(mActivity, MapsViewer.class);
|
||||
intent.putExtra("latitude", lat);
|
||||
intent.putExtra("longitude", lng);
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(mActivity, mActivity.getString(R.string.msgUnavaibleLocation),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Tool.isHaveLocation(bean.getAnswer_type())) {
|
||||
mThumbLocation.setImageResource(R.drawable.ic_absent);
|
||||
mThumbLocation.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mThumbLocation.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (CustomerFragment.isViewTask()) {
|
||||
mImageAnswer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
List<NameValuePair> params = new ArrayList<>();
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_UUID_TASKH,
|
||||
CustomerFragment.getHeader().getTaskH().getUuid_task_h()));
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_QUESTIONID, bean.getQuestion_id()));
|
||||
if (null == bean.getImgAnswer()) {
|
||||
new GetImageTask(mActivity, params, mImageAnswer, mQuestionAnswer, bean, ReviewImageViewHolder.this).execute();
|
||||
} else {
|
||||
bindImageAnswer();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mImageAnswer.setImageResource(android.R.drawable.ic_menu_gallery);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getImageData(boolean data) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
class BitmapWorkerTask extends AsyncTask<QuestionBean, Void, Bitmap> {
|
||||
private final WeakReference<ImageView> imageViewReference;
|
||||
private byte[] data;
|
||||
private int[] resolusi;
|
||||
|
||||
public BitmapWorkerTask(ImageView imageView) {
|
||||
imageViewReference = new WeakReference<>(imageView);
|
||||
}
|
||||
|
||||
// Decode image in background.
|
||||
@Override
|
||||
protected Bitmap doInBackground(QuestionBean... params) {
|
||||
QuestionBean bean = params[0];
|
||||
data = bean.getImgAnswer();
|
||||
Bitmap bm = Utils.byteToBitmap(data);
|
||||
resolusi = new int[2];
|
||||
resolusi[0] = bm.getWidth();
|
||||
resolusi[1] = bm.getHeight();
|
||||
int[] res = Tool.getThumbnailResolution(bm.getWidth(), bm.getHeight());
|
||||
Bitmap thumbnail = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
// Once complete, see if ImageView is still around and set bitmap.
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
if (imageViewReference != null && bitmap != null) {
|
||||
final ImageView imageView = imageViewReference.get();
|
||||
if (imageView != null) {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
Utility.freeMemory();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.MobileContentD;
|
||||
import com.adins.mss.dao.MobileContentDDao;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
|
||||
public class MobileContentDDataAccess {
|
||||
private MobileContentDDataAccess() {
|
||||
}
|
||||
|
||||
/**
|
||||
* use to generate dao session that you can access modelDao
|
||||
*
|
||||
* @param context --> context from activity
|
||||
* @return
|
||||
*/
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get mobileContentD dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static MobileContentDDao getMobileContentDDao(Context context) {
|
||||
return getDaoSession(context).getMobileContentDDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add or replace one mobileContentD
|
||||
*
|
||||
* @param context
|
||||
* @param mobileContentD
|
||||
*/
|
||||
public static void addOrReplace(Context context, MobileContentD mobileContentD) {
|
||||
getMobileContentDDao(context).insertOrReplaceInTx(mobileContentD);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add or replace mobileContentDList
|
||||
*
|
||||
* @param context
|
||||
* @param mobileContentDList
|
||||
*/
|
||||
public static void addOrReplace(Context context, List<MobileContentD> mobileContentDList) {
|
||||
getMobileContentDDao(context).insertOrReplaceInTx(mobileContentDList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add mobileContentD as entity
|
||||
*
|
||||
* @param context
|
||||
* @param mobileContentD
|
||||
*/
|
||||
public static void add(Context context, MobileContentD mobileContentD) {
|
||||
getMobileContentDDao(context).insertInTx(mobileContentD);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add mobileContentD as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param mobileContentD
|
||||
*/
|
||||
public static void add(Context context, List<MobileContentD> mobileContentD) {
|
||||
getMobileContentDDao(context).insertInTx(mobileContentD);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all content in table.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void clean(Context context) {
|
||||
getMobileContentDDao(context).deleteAll();
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param mobileCOntentD
|
||||
*/
|
||||
public static void delete(Context context, MobileContentD mobileCOntentD) {
|
||||
getMobileContentDDao(context).deleteInTx(mobileCOntentD);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by keyMobileCOntentH
|
||||
*
|
||||
* @param context
|
||||
* @param keyMobileContentH
|
||||
*/
|
||||
public static void delete(Context context, String keyMobileContentH) {
|
||||
QueryBuilder<MobileContentD> qb = getMobileContentDDao(context).queryBuilder();
|
||||
qb.where(MobileContentDDao.Properties.Uuid_mobile_content_h.eq(keyMobileContentH));
|
||||
qb.build();
|
||||
getMobileContentDDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param mobileContentD
|
||||
*/
|
||||
public static void update(Context context, MobileContentD mobileContentD) {
|
||||
getMobileContentDDao(context).updateInTx(mobileContentD);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_mobile_content_h = param
|
||||
*
|
||||
* @param context
|
||||
* @param keyMobileContentH
|
||||
* @return
|
||||
*/
|
||||
public static List<MobileContentD> getAll(Context context, String keyMobileContentH) {
|
||||
QueryBuilder<MobileContentD> qb = getMobileContentDDao(context).queryBuilder();
|
||||
qb.where(MobileContentDDao.Properties.Uuid_mobile_content_h.eq(keyMobileContentH));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<MobileContentD> getAllOnDate(Context context, String keyMobileContentH) {
|
||||
QueryBuilder<MobileContentD> qb = getMobileContentDDao(context).queryBuilder();
|
||||
qb.where(MobileContentDDao.Properties.Uuid_mobile_content_h.eq(keyMobileContentH)
|
||||
, MobileContentDDao.Properties.Start_date.lt(Tool.getSystemDateTime())
|
||||
, MobileContentDDao.Properties.End_date.gt(Tool.getSystemDateTime()));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* getOne mobileContentD
|
||||
*
|
||||
* @param context
|
||||
* @param keyMobileContentD
|
||||
* @return
|
||||
*/
|
||||
public static MobileContentD getOne(Context context, String keyMobileContentD) {
|
||||
QueryBuilder<MobileContentD> qb = getMobileContentDDao(context).queryBuilder();
|
||||
qb.where(MobileContentDDao.Properties.Uuid_mobile_content_d.eq(keyMobileContentD));
|
||||
qb.build();
|
||||
if (!qb.list().isEmpty())
|
||||
return qb.list().get(0);
|
||||
else return null;
|
||||
}
|
||||
|
||||
public static List<MobileContentD> getAllContent(Context context){
|
||||
QueryBuilder<MobileContentD> qb = getMobileContentDDao(context).queryBuilder();
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
|
@ -0,0 +1,19 @@
|
|||
package com.adins.mss.odr.news;
|
||||
|
||||
import com.adins.mss.dao.MobileContentD;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JsonResponseNewsContent extends MssResponseType{
|
||||
@SerializedName("contentNewsDetail")
|
||||
List<MobileContentD> contentNewsDetail;
|
||||
|
||||
public List<MobileContentD> getListMobileContentD() {
|
||||
return contentNewsDetail;
|
||||
}
|
||||
public void setListMobileContentD(List<MobileContentD> listMobileContentD) {
|
||||
this.contentNewsDetail = listMobileContentD;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue