com.simadanesh.isatis.ScreenSlideActivity.java Source code

Java tutorial

Introduction

Here is the source code for com.simadanesh.isatis.ScreenSlideActivity.java

Source

/*
 * Copyright 2012 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.simadanesh.isatis;

import static android.app.Activity.RESULT_OK;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.pdf.PdfDocument;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.simadanesh.dataBase.InspectionCodeDA;
import com.simadanesh.dataBase.ManehCodeDA;
import com.simadanesh.dataBase.QueuePictureDA;
import com.simadanesh.dataBase.ReadingListDetailDA;
import com.simadanesh.dataBase.ReadingListHeaderDA;
import com.simadanesh.dataBase.RegisterFieldDA;
import com.simadanesh.dataBase.ValidationDA;
import com.simadanesh.datacontract.CalculationResult;
import com.simadanesh.datacontract.CalculationResults;
import com.simadanesh.datacontract.ControlResult;
import com.simadanesh.datacontract.ControlResults;
import com.simadanesh.datacontract.ManehCode;
import com.simadanesh.datacontract.QueuePicture;
import com.simadanesh.datacontract.ReadingListDetail;
import com.simadanesh.datacontract.Validation;
import com.simadanesh.online.GetFastCalculationWCF;
import com.simadanesh.online.OnlineControlWCF;
import com.simadanesh.online.WcfBase;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.simadanesh.isatis.R;
import static com.simadanesh.isatis.MainPage1Fragment.REQUEST_IMAGE_CAPTURE;

/**
 * Demonstrates a "screen-slide" animation using a {@link ViewPager}. Because
 * {@link ViewPager} automatically plays such an animation when calling
 * {@link ViewPager#setCurrentItem(int)}, there isn't any animation-specific
 * code in this sample.
 *
 * <p>
 * This sample shows a "next" button that advances the user to the next step in
 * a wizard, animating the current screen out (to the left) and the next screen
 * in (from the right). The reverse animation is played when the user presses
 * the "previous" button.</p>
 *
 * @see ScreenSlidePageFragment
 */
public class ScreenSlideActivity extends FragmentActivity implements WcfBase.PleaseWait {

    /**
     * The pager widget, which handles animation and allows swiping horizontally
     * to access previous and next wizard steps.
     */
    private ViewPager mPager;
    private ProgressDialog mProgressDialog;
    private TextView mtextProgress;

    /**
     * The pager adapter, which provides the pages to the view pager widget.
     */
    private PagerAdapter mPagerAdapter;
    private ProgressBar progressbar;
    private int callCount = 0;
    String filterName = "";
    Dialog search_dialog = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CommonPlace.manehCodes = ManehCodeDA.getInstance(this).getAll();
        CommonPlace.inspectionCodes = InspectionCodeDA.getInstance(this).getAll();
        CommonPlace.CurrentRegisterFields = RegisterFieldDA.getInstance(this).getAll("fldPartitionCode=?", "",
                new String[] { CommonPlace.currentCityPartition.getFldPartitionCode() });
        LoadValidationCriterias();

        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
                Log.e("Alert", "Lets See if it Works !!!" + paramThrowable.toString());
            }
        });
        Utility.InitializeDefatultSettings(this);
        CommonPlace.slideActivity = this;
        getActionBar().setDisplayHomeAsUpEnabled(true);

        setContentView(R.layout.activity_screen_slide);
        mtextProgress = (TextView) findViewById(R.id.txtProgress);

        Utility.applyFont(findViewById(R.id.reading_page));
        LinearLayout taskbarLayout = (LinearLayout) findViewById(R.id.taskbarpanel);
        taskbarLayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Button btnCamera = (Button) findViewById(R.id.btnCamera);
                if (btnCamera.getTextSize() > 0) {
                    btnCamera.setTextSize(0);
                } else {
                    btnCamera.setTextSize(20);
                }

            }
        });
        progressbar = (ProgressBar) findViewById(R.id.reading_progress);
        progressbar.setProgress(0);

        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new View.OnClickListener() {

            Dialog mydialog;

            public void onClick(View v) {
                ShowSubmitDialog();
            }
        });

        Button btnCamera = (Button) findViewById(R.id.btnCamera);
        btnCamera.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                dispatchTakePictureIntentOrShowPicture();
            }

        });

        Button btnInspection = (Button) findViewById(R.id.btnInspection);
        btnInspection.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                ShowInspectionDialog();
            }

        });

        Button btnonlineControl = (Button) findViewById(R.id.btnOnline_control);
        btnonlineControl.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                ShowOnlineControl();
            }

        });

        Button btnOnlineCalculation = (Button) findViewById(R.id.btnCalculation);
        btnOnlineCalculation.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                ShowOnlineCalculation();
            }

        });

        // Instantiate a ViewPager and a PagerAdapter.
        mPager = (ViewPager) findViewById(R.id.pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
        mPager.setAdapter(mPagerAdapter);
        mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {

                // When changing pages, reset the action bar actions since they are dependent
                // on which page is currently active. An alternative approach is to have each
                // fragment expose actions itself (rather than the activity exposing actions),
                // but for simplicity, the activity provides the actions in this sample.
                invalidateOptionsMenu();
            }
        });
        try {
            // int last = mSavedBundle.getInt("Reading-" + CommonPlace.currentReadingList.getId());
            // mPager.setCurrentItem(last);
        } catch (Exception ex) {
            ex.toString();
        }

        final Handler handler1 = new Handler();
        try {
            final int pos = Integer.parseInt(CommonPlace.currentReadingList.Position);
            handler1.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mPager.setCurrentItem(pos);
                }
            }, 500);
        } catch (Exception ex) {

        }
    }

    private void ShowOnlineCalculation() {
        GetFastCalculationWCF wcf = new GetFastCalculationWCF(this,
                new WcfBase.OnWcfCallFinished<CalculationResults>() {

                    public void onDataReady(CalculationResults res) {
                        Toast.makeText(ScreenSlideActivity.this, res.Code + " web service answered",
                                Toast.LENGTH_LONG).show();
                        try {
                            if (res.Code == 0) {
                                if (res.List.size() > 0) {
                                    //makePDF(res.List.get(0));
                                    makeBMP(res.List.get(0));
                                }
                            }
                        } catch (Exception ex) {
                            Toast.makeText(ScreenSlideActivity.this, ex.toString(), Toast.LENGTH_LONG).show();

                        }
                    }
                });
        ReadingListDetail detail = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem());
        if ("".equals(detail.EditDate)) {
            detail.EditDate = Utility.NowDate();
        }
        if ("".equals(detail.fldManehCodeNow)) {
            detail.fldManehCodeNow = "0";
        }
        if ("".equals(detail.fldNowDigit)) {
            detail.fldNowDigit = detail.fldPreviousDigit;
        }
        wcf.Calculate(getToken(), detail.tbListDetail_ID, detail.fldNowDigit, detail.fldManehCodeNow,
                detail.EditDate);
    }

    void makePDF(CalculationResult res) {

        PdfDocument doc = new PdfDocument();
        PdfDocument.PageInfo inf = new PdfDocument.PageInfo.Builder(400, 800, 1).create();
        PdfDocument.Page page = doc.startPage(inf);

        Canvas canvas = page.getCanvas();

        //canvas.drawARGB(155, 253, 255, 253);
        canvas.drawARGB(255, 255, 255, 255);
        Paint p = new Paint();
        p.setTypeface(Utility.getNazaninFont());
        p.setTextSize(25);
        p.setAntiAlias(true);

        int y = 20;
        Drawable d = getResources().getDrawable(R.drawable.abfa);
        d.setBounds(100, 10, 300, 210);
        d.draw(canvas);
        p.setTextAlign(Paint.Align.CENTER);
        y += 210;
        canvas.drawText("   ?  ", 200, y, p);
        y += 40;
        canvas.drawText("  ", 200, y, p);
        y += 40;
        canvas.drawText("  ", 200, y, p);
        y += 40;
        canvas.drawText(":" + Utility.NowDate(), 200, y, p);
        y += 40;
        canvas.drawText("___________________________", 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.CustomerNumber, 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.Title, 200, y, p);
        y += 40;
        canvas.drawText(" :" + Seprate3(res.BillAmount), 200, y, p);
        y += 40;
        canvas.drawText(" :" + Seprate3(res.PreviousDebt), 200, y, p);

        y += 40;
        Paint p1 = new Paint();
        p1.setTypeface(Utility.getNazaninFont());
        p1.setARGB(255, 0, 0, 0);
        p1.setAntiAlias(true);
        p1.setStrokeWidth(40);
        p1.setStyle(Paint.Style.STROKE);
        canvas.drawLine(10, y, 390, y, p1);
        p.setARGB(255, 255, 255, 255);
        canvas.drawText("  :" + Seprate3(res.TotalAmount) + " ", 200, y, p);
        p.setARGB(255, 0, 0, 0);

        y += 40;
        canvas.drawText("__________________________", 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.BillIdentifier, 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.PaymentIdentifier, 200, y, p);

        doc.finishPage(page);
        //File file = new File(getCacheDir()+ "/billing.png");
        File file = new File("/sdcard/billing.pdf");
        FileOutputStream outfile;
        try {
            outfile = new FileOutputStream(file);
            //bmp.compress(Bitmap.CompressFormat.PNG, 100, outfile);
            doc.writeTo(outfile);
            doc.close();

            Intent intent = new Intent();
            intent.setAction(android.content.Intent.ACTION_VIEW);
            //intent.setDataAndType(Uri.fromFile(file), "image/*");
            intent.setDataAndType(Uri.fromFile(file), "application/pdf");
            startActivity(intent);
            //new RetrieveFeedTask().execute(bmp);

        } catch (Exception ex) {
            Log.e("error", ex.toString());
            new AlertDialog.Builder(this).setMessage(
                    "    ? pdf    ? \n https://cafebazaar.ir/app/com.kdanmobile.android.pdfreader.google.pad/?l=fa   ")
                    .show();
        }

    }

    void makeBMP(CalculationResult res) {

        Bitmap bmp = Bitmap.createBitmap(400, 800, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bmp);

        //canvas.drawARGB(155, 253, 255, 253);
        canvas.drawARGB(255, 255, 255, 255);
        Paint p = new Paint();
        p.setTypeface(Utility.getNazaninFont());
        p.setTextSize(25);
        p.setAntiAlias(true);

        int y = 20;
        Drawable d = getResources().getDrawable(R.drawable.abfa);
        d.setBounds(100, 10, 300, 210);
        d.draw(canvas);
        p.setTextAlign(Paint.Align.CENTER);
        y += 210;
        canvas.drawText("   ?  ", 200, y, p);
        y += 40;
        canvas.drawText("  ", 200, y, p);
        y += 40;
        canvas.drawText("  ", 200, y, p);
        y += 40;
        canvas.drawText(":" + Utility.NowDate(), 200, y, p);
        y += 40;
        canvas.drawText("___________________________", 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.CustomerNumber, 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.Title, 200, y, p);
        y += 40;
        canvas.drawText(" :" + Seprate3(res.BillAmount), 200, y, p);
        y += 40;
        canvas.drawText(" :" + Seprate3(res.PreviousDebt), 200, y, p);

        y += 40;
        Paint p1 = new Paint();
        p1.setTypeface(Utility.getNazaninFont());
        p1.setARGB(255, 0, 0, 0);
        p1.setAntiAlias(true);
        p1.setStrokeWidth(40);
        p1.setStyle(Paint.Style.STROKE);
        canvas.drawLine(10, y, 390, y, p1);
        p.setARGB(255, 255, 255, 255);
        canvas.drawText("  :" + Seprate3(res.TotalAmount) + " ", 200, y, p);
        p.setARGB(255, 0, 0, 0);

        y += 40;
        canvas.drawText("__________________________", 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.BillIdentifier, 200, y, p);
        y += 40;
        canvas.drawText(" :" + res.PaymentIdentifier, 200, y, p);

        /* Path pth = new Path();
         pth.addArc(10, 20, 390, 790, 0, 360);
            
         p.setColor(Color.argb(20, 10, 10, 10));
         p.setTextSize(30);
         String watermark = "";
         for (int i = 0; i < 15; i++) {
         watermark += "  ";
         }
         canvas.drawTextOnPath(watermark, pth, 0, 0, p);*/
        //File file = new File(getCacheDir()+ "/billing.png");
        File file = new File("/sdcard/billing.png");
        FileOutputStream outfile;
        try {
            outfile = new FileOutputStream(file);
            bmp.compress(Bitmap.CompressFormat.PNG, 100, outfile);

            Intent intent = new Intent();
            intent.setAction(android.content.Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(file), "image/*");
            startActivity(intent);

        } catch (Exception ex) {
            Log.e("error", ex.toString());
        }

    }

    private String Seprate3(String instr) {
        String result = "";
        int l = 0;
        for (int i = instr.length() - 1; i >= 0; i--) {
            if (l > 0 && l % 3 == 0) {
                result = ',' + result;
            }
            l++;
            result = instr.charAt(i) + result;
        }
        return result;
    }

    private void showSearchDialog() {
        if (search_dialog == null) {
            search_dialog = new Dialog(this);
            search_dialog.setContentView(R.layout.search_view);
            search_dialog.setCancelable(true);
            Utility.applyFont(search_dialog.findViewById(R.id.panel));
            Button btnok = (Button) search_dialog.findViewById(R.id.btn_ok);
            btnok.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    executeSearch();
                }

            });
            Button btnCancel = (Button) search_dialog.findViewById(R.id.btn_cancel);
            btnCancel.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    search_dialog.dismiss();
                }
            });
            search_dialog.setTitle(R.string.search);
        }

        search_dialog.show();
    }

    private void executeSearch() {
        Spinner sp_search_type = (Spinner) search_dialog.findViewById(R.id.sp_search_type);
        EditText searchValue = (EditText) search_dialog.findViewById(R.id.search_value);
        int searchType = sp_search_type.getSelectedItemPosition();
        String searchkey = searchValue.getText().toString();
        switch (searchType) {
        case 0:
            searchByIdentificationCode(searchkey);
            break;
        case 1:
            searchByCustomerNumber(searchkey);
            break;
        }
    }

    private void showNewCustomerForm() {
        startActivity(new Intent(this, NewCustomerActivity.class));
    }

    class RetrieveFeedTask extends AsyncTask<Bitmap, Void, Void> {

        protected void onPostExecute(String feed) {
            // TODO: check this.exception
            // TODO: do something with the feed
        }

        @Override
        protected Void doInBackground(Bitmap... params) {
            try {
                //Socket sock = new Socket("172.20.43.36", 9100);
                //PrintWriter oStream = new PrintWriter(sock.getOutputStream());
                //oStream.println("HI,test from Android Device\n");
                //oStream.println("    1");
                //oStream.println("\n\n\n");

                //OutputStream oStream = sock.getOutputStream();
                /*String sig = "/9j/4AAQSkZJRgABAgEBLAEsAAD/4QoORXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodpAAQAAAABAAAApAAAANAALcbAAAAnEAAtxsAAACcQQWRvYmUgUGhvdG9zaG9wIENTMyBXaW5kb3dzADIwMTQ6MDI6MjUgMTI6MjQ6MzYAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAcaADAAQAAAABAAAAMAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEAAgAAAgEABAAAAAEAAAEuAgIABAAAAAEAAAjYAAAAAAAAAEgAAAABAAAASAAAAAH/2P/gABBKRklGAAECAABIAEgAAP/tAAxBZG9iZV9DTQAB/+4ADkFkb2JlAGSAAAAAAf/bAIQADAgICAkIDAkJDBELCgsRFQ8MDA8VGBMTFRMTGBEMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAENCwsNDg0QDg4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AAAASAAvZmYAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAAAQAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP////////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA/////////////////////////////wPoAAA4QklNBAAAAAAAAAIAAThCSU0EAgAAAAAACAAAAAAAAAAAOEJJTQQwAAAAAAAEAQEBAThCSU0ELQAAAAAABgABAAAABThCSU0ECAAAAAAAEAAAAAEAAAJAAAACQAAAAAA4QklNBB4AAAAAAAQAAAAAOEJJTQQaAAAAAANJAAAABgAAAAAAAAAAAAAAMAAAAHEAAAAKAFUAbgB0AGkAdABsAGUAZAAtADEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAHEAAAAwAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAABudWxsAAAAAgAAAAZib3VuZHNPYmpjAAAAAQAAAAAAAFJjdDEAAAAEAAAAAFRvcCBsb25nAAAAAAAAAABMZWZ0bG9uZwAAAAAAAAAAQnRvbWxvbmcAAAAwAAAAAFJnaHRsb25nAAAAcQAAAAZzbGljZXNWbExzAAAAAU9iamMAAAABAAAAAAAFc2xpY2UAAAASAAAAB3NsaWNlSURsb25nAAAAAAAAAAdncm91cElEbG9uZwAAAAAAAAAGb3JpZ2luZW51bQAAAAxFU2xpY2VPcmlnaW4AAAANYXV0b0dlbmVyYXRlZAAAAABUeXBlZW51bQAAAApFU2xpY2VUeXBlAAAAAEltZyAAAAAGYm91bmRzT2JqYwAAAAEAAAAAAABSY3QxAAAABAAAAABUb3AgbG9uZwAAAAAAAAAATGVmdGxvbmcAAAAAAAAAAEJ0b21sb25nAAAAMAAAAABSZ2h0bG9uZwAAAHEAAAADdXJsVEVYVAAAAAEAAAAAAABudWxsVEVYVAAAAAEAAAAAAABNc2dlVEVYVAAAAAEAAAAAA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gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8P3hwYWNrZXQgZW5kPSJ3Ij8+/+IMWElDQ19QUk9GSUxFAAEBAAAMSEx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EQMRAAAQEUAAAAAArhAAAAAwzGoFAAFiwEMJg2Nt12ZoBBupM9QAA//aAAgBAQMBPxCL6a9u4ywF0YBAnc8egeQaGJ0bdt7Y/M/M2PqVRnDbkk9pSDhALh00hsToJw1+J2fWCwBH6s2TkY3xzUt+s2A/YK8bbKkEOkk4iSRDk2QsF1hGJTNSUOmDbeEMQU2S2fCuS/CYr8e4HtaH7EAVpIFIGwQ4DEthsawgCQGgvjdKN606aLZZlMktBjbFVytmNJkWK3AD/UtQlbg9TdbP+GsIAo8NA5W+6YYdrUEz1SZOaMXKMoKbqa1mq4U8QQxYY97/ANzsGwh1ipqAHGpH5IoUa8VqWOYoVNZdyL8NAviCSZ+3If5sCSacyWOgsKAP2vpFiKNmxlls9Om5Esn19gKqEfDtDdJ1d7pe5Vey4++i/sFPlGBgYLGscj4xwgiIZp3O7BGUptEUFTG0AqUnRH+1e3C2hvZUcRV+/MXRhFEtE59pBGbiWQyyUB+UHQDC1Oc05hAgRaIsxEQFpzEuO4qS6lWk7bYdYANyIKTOahvBwJvPpOKSfNQ8hBDEG+kYnrSAibaawISC+Ugwp+KBqxX3OnKsqEBr8+kgXEpCAIcl1aZ+TQQS/ByseNM6l2Fpe6JTVN4AuyiNfI+WuxTJZmb0K7WUoKzeHx//2gAIAQIDAT8Q5r57iLWD2Vxqb4rwry6ORpeOidsMzqdE7n3EeuK/YfJqbP2OCoFx3UrLA7mX0WO5YTDuWGobnbOmdR8v/9oACAEDAwE/EOM5XBBDSY9rqFTDAGyGj1gVOyOMwaWOI1S+EDXcGy+QKnZ5GA+8PCdkz4TlfhH+2GgGrzAAUl/kLxbqFZKX/cRS0IwqsdTAXh/7P9kCIeoILJlXtMyQF9w01tmxRKUEuj7BHJKPk3KrUo+cJZTH8advUdQxBlxsPyI1Vm4jdWIiJzT8hytPl//Z";
                 byte[] imageAsBytes = android.util.Base64
                 .decode(sig, android.util.Base64.DEFAULT);
                    
                 Bitmap btMap = BitmapFactory.decodeByteArray(imageAsBytes, 0,
                 imageAsBytes.length);
                    
                 Bitmap bitmapOrg = resizeImage(btMap, 384,
                 150);// Bit*/
                //byte[] sendbuf = StartBmpToPrintCode(bitmapOrg, 0);
                //byte[] sendbuf = StartBmpToPrintCode(params[0], 0);
                //oStream.write(sendbuf);
                //oStream.close();
                //sock.close();
                //PrintManager printManager = (PrintManager)ScreenSlideActivity.this.getSystemService(Context.PRINT_SERVICE);
                //String jobName = ScreenSlideActivity.this.getString(R.string.app_name) +" Document";
                //printManager.print(jobName, new PrintDocumentAdapter(this),null);
            } catch (Exception e) {
                Log.e("HERE:", e.toString());
            }
            return null;
        }
    }

    public static Bitmap resizeImage(Bitmap bitmap, int w, int h) {
        Bitmap BitmapOrg = bitmap;
        int width = BitmapOrg.getWidth();
        int height = BitmapOrg.getHeight();
        int newWidth = w;
        int newHeight = h;

        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
        Matrix matrix = new Matrix();
        matrix.postScale(scaleWidth, scaleHeight);
        Bitmap resizedBitmap = Bitmap.createBitmap(BitmapOrg, 0, 0, width, height, matrix, true);
        return resizedBitmap;
    }

    private static byte[] StartBmpToPrintCode(Bitmap bitmap, int t) {
        byte temp = 0;
        int j = 7;
        int start = 0;
        if (bitmap != null) {
            int mWidth = bitmap.getWidth();
            int mHeight = bitmap.getHeight();

            int[] mIntArray = new int[mWidth * mHeight];
            byte[] data = new byte[mWidth * mHeight];
            bitmap.getPixels(mIntArray, 0, mWidth, 0, 0, mWidth, mHeight);
            encodeYUV420SP(data, mIntArray, mWidth, mHeight, t);
            byte[] result = new byte[mWidth * mHeight / 8];
            for (int i = 0; i < mWidth * mHeight; i++) {
                temp = (byte) ((byte) (data[i] << j) + temp);
                j--;
                if (j < 0) {
                    j = 7;
                }
                if (i % 8 == 7) {
                    result[start++] = temp;
                    temp = 0;
                }
            }
            if (j != 7) {
                result[start++] = temp;
            }

            int aHeight = 24 - mHeight % 24;
            byte[] add = new byte[aHeight * 48];
            byte[] nresult = new byte[mWidth * mHeight / 8 + aHeight * 48];
            System.arraycopy(result, 0, nresult, 0, result.length);
            System.arraycopy(add, 0, nresult, result.length, add.length);

            byte[] byteContent = new byte[(mWidth / 8 + 4) * (mHeight + aHeight)];// 
            byte[] bytehead = new byte[4];// ???
            bytehead[0] = (byte) 0x1f;
            bytehead[1] = (byte) 0x10;
            bytehead[2] = (byte) (mWidth / 8);
            bytehead[3] = (byte) 0x00;
            for (int index = 0; index < mHeight + aHeight; index++) {
                System.arraycopy(bytehead, 0, byteContent, index * 52, 4);
                System.arraycopy(nresult, index * 48, byteContent, index * 52 + 4, 48);

            }
            return byteContent;
        }
        return null;

    }

    public static void encodeYUV420SP(byte[] yuv420sp, int[] rgba, int width, int height, int t) {
        final int frameSize = width * height;
        int[] U, V;
        U = new int[frameSize];
        V = new int[frameSize];
        final int uvwidth = width / 2;
        int r, g, b, y, u, v;
        int bits = 8;
        int index = 0;
        int f = 0;
        for (int j = 0; j < height; j++) {
            for (int i = 0; i < width; i++) {
                r = (rgba[index] & 0xff000000) >> 24;
                g = (rgba[index] & 0xff0000) >> 16;
                b = (rgba[index] & 0xff00) >> 8;
                // rgb to yuv
                y = ((66 * r + 129 * g + 25 * b + 128) >> 8) + 16;
                u = ((-38 * r - 74 * g + 112 * b + 128) >> 8) + 128;
                v = ((112 * r - 94 * g - 18 * b + 128) >> 8) + 128;
                // clip y
                // yuv420sp[index++] = (byte) ((y < 0) ? 0 : ((y > 255) ? 255 :
                // y));
                byte temp = (byte) ((y < 0) ? 0 : ((y > 255) ? 255 : y));
                if (t == 0) {
                    yuv420sp[index++] = temp > 0 ? (byte) 1 : (byte) 0;
                } else {
                    yuv420sp[index++] = temp > 0 ? (byte) 0 : (byte) 1;
                }

                // {
                // if (f == 0) {
                // yuv420sp[index++] = 0;
                // f = 1;
                // } else {
                // yuv420sp[index++] = 1;
                // f = 0;
                // }
                // }
            }

        }
        f = 0;
    }

    private void ShowSubmitDialog() {
        GetRegisterFieldsDialog d = new GetRegisterFieldsDialog(this);
        ReadingListDetail detail = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem());
        d.ReadingListDetail = detail;
        d.show();

    }

    private void ShowInspectionDialog() {
        GetInspectionDialog d = new GetInspectionDialog(this);
        ReadingListDetail detail = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem());
        d.ReadingListDetail = detail;
        d.show();
    }

    void dispatchTakePictureIntentOrShowPicture() {

        ReadingListDetail detail = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem());
        if (detail.PicturePath == null || detail.PicturePath.equals("")) {

            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            // Ensure that there's a camera activity to handle the intent
            if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) {
                // Create the File where the photo should go
                File photoFile = null;
                try {
                    photoFile = createImageFile();
                } catch (IOException ex) {
                    ex.toString();
                    // Error occurred while creating the File
                }
                // Continue only if the File was successfully created
                if (photoFile != null) {
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                    startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
                }
            }
        } else {
            Intent intent = new Intent();
            intent.setAction(android.content.Intent.ACTION_VIEW);
            //intent.setDataAndType(Uri.fromFile(file), "image/*");
            intent.setDataAndType(Uri.fromFile(new File(detail.PicturePath)), "image/*");
            startActivity(intent);
        }
    }

    //    String mCurrentPhotoPath;
    private File createImageFile() throws IOException {
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp;
        File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
        //File image = new File(storageDir + "/" + imageFileName + ".jpg");
        File image = new File(storageDir + "/Mahnaam" + System.currentTimeMillis() + ".jpg");
        mCurrentPhotoPath = image;
        return image;
    }

    private void searchByIdentificationCode(String searchKey) {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and fldIdentificationCode like ?", "",
                new String[] { CommonPlace.currentReadingList.id + "", "%" + searchKey + "%" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = " " + searchKey + " ";
        mPager.setCurrentItem(0);
        setTitle();
    }

    private void searchByCustomerNumber(String searchKey) {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and FldCustomerNumber like ?", "",
                new String[] { CommonPlace.currentReadingList.id + "", "%" + searchKey + "%" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = " " + searchKey + " ";
        mPager.setCurrentItem(0);
        setTitle();
    }

    private void showfilterMenu() {
        View p = findViewById(R.id.anchorer);
        progressbar.setVisibility(View.GONE);

        final PopupMenu popup = new PopupMenu(this, p);
        //Inflating the Popup using xml file  
        popup.getMenuInflater().inflate(R.menu.filter, popup.getMenu());
        for (int i = 0; i < popup.getMenu().size(); i++) {
            MenuItem item = popup.getMenu().getItem(i);
            String countstr = "0";
            switch (item.getItemId()) {
            case R.id.filter_no_filter:
                countstr = countFilterNofilter();
                break;
            case R.id.filter_no_data:
                countstr = countFilterNodata();
                break;
            case R.id.filter_valid_reading:
                countstr = countFilterValid();
                break;
            case R.id.filter_hilow:
                countstr = countFilterHilow();
                break;
            case R.id.filter_maneh:
                countstr = countFilterManeh();

                break;
            case R.id.filter_inspection:
                countstr = countFilterInspection();
                break;
            case R.id.filter_register_field:
                countstr = countFilterRegisterField();
                break;
            case R.id.filter_not_register_field:
                countstr = countFilterRegisterNotField();
                break;

            }
            item.setTitle(item.getTitle() + "\t" + countstr);
        }

        //registering popup with OnMenuItemClickListener  
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                case R.id.filter_no_filter:
                    filterNofilter();
                    break;
                case R.id.filter_no_data:
                    filterNodata();
                    break;
                case R.id.filter_valid_reading:
                    filterValid();
                    break;
                case R.id.filter_hilow:
                    filterHilow();
                    break;
                case R.id.filter_maneh:
                    //filterManeh();
                    showManehMenu();
                    break;
                case R.id.filter_inspection:
                    filterInspection();
                    break;
                case R.id.filter_register_field:
                    filterRegisterField();
                    break;
                case R.id.filter_not_register_field:
                    filterRegisterNotField();
                    break;

                }
                return true;
            }
        });

        final Handler handler1 = new Handler();
        progressbar.setVisibility(View.GONE);
        //android.R.attr.progressBarStyleLarge
        handler1.postDelayed(new Runnable() {
            @Override
            public void run() {
                popup.show();
            }
        }, 100);
    }

    private void showManehMenu() {
        View p = findViewById(R.id.anchorer);
        progressbar.setVisibility(View.GONE);

        final PopupMenu popup = new PopupMenu(this, p);
        //Inflating the Popup using xml file  
        for (ManehCode m : CommonPlace.manehCodes) {
            if (!m.Maneh_fldCode.equals("0")) {
                int cnt = ReadingListDetailDA.getInstance(this).getCount("HeaderID=? and fldManehCodeNow=?", "",
                        new String[] { CommonPlace.currentReadingList.id + "", m.Maneh_fldCode });
                popup.getMenu().add(0, Integer.parseInt(m.Maneh_fldCode), 0, m.fldTiltle + "\t" + cnt);
            }
        }
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                filterManeh(item.getItemId(), item.getTitle().toString());
                return true;
            }
        });

        final Handler handler1 = new Handler();
        progressbar.setVisibility(View.GONE);
        //android.R.attr.progressBarStyleLarge
        handler1.postDelayed(new Runnable() {
            @Override
            public void run() {
                popup.show();
            }
        }, 100);
    }

    String countFilterNofilter() {
        int count = ReadingListDetailDA.getInstance(this).Count("HeaderID=?",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterNodata() {
        int count = ReadingListDetailDA.getInstance(this).Count(
                "HeaderID=? and fldNowDigit in('-1','') and fldManehCodeNow in ('','0')",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterValid() {
        int count = ReadingListDetailDA.getInstance(this).Count("HeaderID=? and IsHighLow=0 and IsOnlineHighLow=0",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterHilow() {
        int count = ReadingListDetailDA.getInstance(this).Count("HeaderID=? and (IsHighLow=1 or IsOnlineHighLow=1)",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterManeh() {
        int count = ReadingListDetailDA.getInstance(this).Count("HeaderID=? and fldManehCodeNow not in('','0')",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterInspection() {
        int count = ReadingListDetailDA.getInstance(this).Count(
                "HeaderID=? and tbListDetail_ID in(select ListDetailID from InspectionField)",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterRegisterField() {
        int count = ReadingListDetailDA.getInstance(this).Count(
                "HeaderID=? and tbListDetail_ID in(select ListDetailID from RegisterFieldInfo)",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    String countFilterRegisterNotField() {
        int count = ReadingListDetailDA.getInstance(this).Count(
                "HeaderID=? and tbListDetail_ID not in(select ListDetailID from RegisterFieldInfo)",
                new String[] { CommonPlace.currentReadingList.id + "" });
        return count + "";
    }

    void filterNofilter() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll("HeaderID=?", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = "";
        mPager.setCurrentItem(0);
        setTitle();
        // mPager.setCurrentItem(0);
    }

    void filterNodata() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and fldNowDigit in('-1','') and fldManehCodeNow in ('','0')", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = "";
        mPager.setCurrentItem(0);
        setTitle();
    }

    void filterValid() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and IsHighLow=0 and IsOnlineHighLow=0", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = "";
        mPager.setCurrentItem(0);
        setTitle();
    }

    void filterHilow() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and (IsHighLow=1 or IsOnlineHighLow=1)", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = "";
        mPager.setCurrentItem(0);
        setTitle();
    }

    void filterManeh(int manehId, String title) {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and fldManehCodeNow =?", "",
                new String[] { CommonPlace.currentReadingList.id + "", manehId + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = title;
        mPager.setCurrentItem(0);
        setTitle();
    }

    void filterInspection() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and tbListDetail_ID in(select ListDetailID from InspectionField)", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = "";
        mPager.setCurrentItem(0);
        setTitle();
    }

    void filterRegisterField() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and tbListDetail_ID in(select ListDetailID from RegisterFieldInfo)", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = "";
        mPager.setCurrentItem(0);
        setTitle();
    }

    void filterRegisterNotField() {
        CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(this).getAll(
                "HeaderID=? and tbListDetail_ID not in(select ListDetailID from RegisterFieldInfo)", "",
                new String[] { CommonPlace.currentReadingList.id + "" });
        pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        mPagerAdapter.notifyDataSetChanged();
        filterName = " ";
        mPager.setCurrentItem(0);
        setTitle();
    }

    void setTitle() {
        // setTitle(filterName + "" + (mPager.getCurrentItem() + 1) + "/" + mPagerAdapter.getCount());
        setTitle(filterName);
        mtextProgress.setText((mPager.getCurrentItem() + 1) + "  " + mPagerAdapter.getCount());
        CommonPlace.currentReadingList.Position = "" + mPager.getCurrentItem();
    }

    public interface onImageTaken {

        public void Taken(boolean canceled, String path);
    }

    onImageTaken onImageTakenListener = null;

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
            if (onImageTakenListener != null) {
                onImageTakenListener.Taken(false, mCurrentPhotoPath.toString());
            } else {
                SavePictureToUpload(mCurrentPhotoPath);
            }
        } else {
            Toast.makeText(this, "Canceled", Toast.LENGTH_SHORT).show();
            if (onImageTakenListener != null) {
                onImageTakenListener.Taken(true, "");
            }
        }

    }

    private void SavePictureToUpload(File f) {

        ReadingListDetail detail = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem());
        QueuePicture pic = new QueuePicture();
        pic.Description = "Description";
        pic.InspectionCode = "9999";
        pic.ListDetailID = detail.getTbListDetail_ID();
        pic.FilePath = f.toString();
        QueuePictureDA.getInstance(this).Insert(pic);
        detail.PicturePath = mCurrentPhotoPath.toString();
        ReadingListDetailDA.getInstance(this).update(detail);

    }

    boolean step10 = false;
    File mCurrentPhotoPath;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        try {
            getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

            menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

            // Add either a "next" or "finish" button to the action bar, depending on which page
            // is currently selected.
            MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
                    (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                            : R.string.action_next);
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            item.setIcon(R.drawable.ic_menu_forward);

            MenuItem stepItem = menu.add(Menu.NONE, R.id.action_step_ten, Menu.NONE,
                    step10 ? R.string.action_step_ten : R.string.action_step_one);

            stepItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

            MenuItem turn_on_flash_Item = menu.add(Menu.NONE, R.id.action_turn_on_flash, Menu.NONE,
                    R.string.action_turn_on_light);

            turn_on_flash_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            turn_on_flash_Item.setIcon(R.drawable.ic_menu_flashlight);

            MenuItem filter_Item = menu.add(Menu.NONE, R.id.action_filter, Menu.NONE, R.string.filter);

            filter_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            filter_Item.setIcon(R.drawable.filter);

            MenuItem search_Item = menu.add(Menu.NONE, R.id.action_search, Menu.NONE, R.string.search);

            search_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

            MenuItem addCustomer_Item = menu.add(Menu.NONE, R.id.action_new_customer, Menu.NONE,
                    R.string.new_customer);

            addCustomer_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

            setTitle();
            progressbar.setProgress(mPager.getCurrentItem() + 1);
            progressbar.setMax(mPagerAdapter.getCount());
            final Handler handler = new Handler();
            progressbar.setVisibility(View.VISIBLE);
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    callCount--;
                    if (callCount <= 0) {
                        progressbar.setVisibility(View.GONE);
                    }
                }
            }, 3000);
            callCount++;
        } catch (Exception ex) {
            ex.toString();
        }
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            // Navigate "up" the demo structure to the launchpad activity.
            // See http://developer.android.com/design/patterns/navigation.html for more.
            //NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
            this.finish();
            return true;

        case R.id.action_previous:
            // Go to the previous step in the wizard. If there is no previous step,
            // setCurrentItem will do nothing.
            if (step10) {
                mPager.setCurrentItem(mPager.getCurrentItem() - 10);
            } else {
                mPager.setCurrentItem(mPager.getCurrentItem() - 1);
            }
            return true;

        case R.id.action_next:
            // Advance to the next step in the wizard. If there is no next step, setCurrentItem
            // will do nothing.
            if (step10) {
                mPager.setCurrentItem(mPager.getCurrentItem() + 10);
            } else {
                mPager.setCurrentItem(mPager.getCurrentItem() + 1);
            }

            return true;
        case R.id.action_step_ten:
            step10 = !step10;
            invalidateOptionsMenu();
            return true;
        case R.id.action_turn_on_flash:
            switchFlash();
            return true;
        case R.id.action_filter:
            showfilterMenu();
            return true;
        case R.id.action_search:
            showSearchDialog();
            return true;
        case R.id.action_new_customer:
            showNewCustomerForm();
            return true;

        }

        return super.onOptionsItemSelected(item);
    }

    private void switchFlash() {
        boolean hasFlash = getApplicationContext().getPackageManager()
                .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
        if (!hasFlash) {
            // device doesn't support flash
            // Show alert message and close the application
            AlertDialog alert = new AlertDialog.Builder(this).create();
            alert.setTitle("Error");
            alert.setMessage("Sorry, your device doesn't support flash light!");
            alert.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            alert.show();
            return;
        }
        if (isFlashOn) {
            // turn off flash
            turnOffFlash();
        } else {
            // turn on flash
            turnOnFlash();
        }

    }

    Camera camera;
    Parameters params;

    private void getCamera() {
        if (camera == null) {
            try {
                camera = Camera.open();
                params = camera.getParameters();
            } catch (RuntimeException e) {
                Log.e("Camera Error. Failed to Open. Error: ", e.getMessage());
            }
        }
    }

    boolean isFlashOn;

    private void turnOnFlash() {
        if (!isFlashOn) {
            getCamera();
            if (camera == null || params == null) {
                return;
            }
            // play sound
            //playSound();
            params = camera.getParameters();
            params.setFlashMode(Parameters.FLASH_MODE_TORCH);
            camera.setParameters(params);
            camera.startPreview();
            isFlashOn = true;
            // changing button/switch image
            //toggleButtonImage();
        }
    }

    private void turnOffFlash() {
        if (isFlashOn) {
            if (camera == null || params == null) {
                return;
            }
            // play sound
            //playSound();
            params = camera.getParameters();
            params.setFlashMode(Parameters.FLASH_MODE_OFF);
            camera.setParameters(params);
            camera.stopPreview();
            isFlashOn = false;
            // changing button/switch image
            //toggleButtonImage();
        }
    }

    private void LoadValidationCriterias() {
        List<Validation> lst = ValidationDA.getInstance(this).getAll("fldPartitionCode=?", "",
                new String[] { CommonPlace.currentCityPartition.getFldPartitionCode() });
        for (Validation List : lst) {
            try {
                String item = List.getFldTitle();
                String Value = List.getFldValue();
                String[] vals;
                if ("fldHighLowCondition".equals(item)) {
                    vals = Value.split(":");
                    if (vals.length > 0) {
                        CommonPlace.LowFactor = Float.parseFloat(vals[0]);
                        CommonPlace.highFactor = Float.parseFloat(vals[1]);
                    }
                } else if ("fldStartDate".equals(item)) {
                    CommonPlace.fldStartDate = Value;
                } else if ("fldEndDate".equals(item)) {
                    CommonPlace.fldEndDate = Value;
                } else if ("fldReadingAllowedTimes".equals(item)) {
                    vals = Value.split("\\|");
                    CommonPlace.fldReadingAllowedTimes.clear();
                    for (String val : vals) {
                        CommonPlace.fldReadingAllowedTimes.add(val);
                    }
                } else if ("fldManehAllowedPercent".equals(item)) {
                    vals = Value.split("\\|");
                    for (String val : vals) {
                        String[] vv = val.split(":");
                        CommonPlace.fldManehAllowedPercent.put(vv[0], Float.valueOf(vv[1]));
                    }
                } else if ("fldHighLowOkNumber".equals(item)) {
                    CommonPlace.highLowOkNumber = Integer.parseInt(Value);
                } else if ("fldPreviousDigitShow".equals(item)) {
                    CommonPlace.fldPreviousDigitShow = "1".equals(Value);
                } else if ("fldPreviousDateShow".equals(item)) {
                    CommonPlace.fldPreviousDateShow = "1".equals(Value);
                } else if ("fldAllowedCalculate".equals(item)) {
                    CommonPlace.fldAllowedCalculate = "1".equals(Value);
                } else if ("fldAllowedOnlineControl".equals(item)) {
                    CommonPlace.fldAllowedOnlineControl = "1".equals(Value);
                } else if ("fldDayReadingAllowedNumber".equals(item)) {
                    CommonPlace.fldDayReadingAllowedNumber = Integer.parseInt(Value);
                } else if ("fldManehForcedImage".equals(item)) {
                    CommonPlace.fldManehForcedImage.clear();
                    vals = Value.split("\\|");
                    for (String val : vals) {
                        String[] vv = val.split(":");
                        if ("1".equals(vv[1])) {
                            CommonPlace.fldManehForcedImage.add(vv[0]);
                        }
                    }

                }
            } catch (Exception ex) {
                // Toast.makeText(this, ex.toString(), Toast.LENGTH_SHORT).show();
                Log.e("validation ", ex.toString());
            }
        }
    }

    ScreenSlidePageFragment[] pages;

    /**
     * A simple pager adapter that represents 5 {@link ScreenSlidePageFragment}
     * objects, in sequence.
     */
    private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {

        public ScreenSlidePagerAdapter(FragmentManager fm) {
            super(fm);
            CommonPlace.currentReadingListDetails = ReadingListDetailDA.getInstance(CommonPlace.slideActivity)
                    .getAll("HeaderID=?", "", new String[] { CommonPlace.currentReadingList.getId() + "" });
            pages = new ScreenSlidePageFragment[CommonPlace.currentReadingListDetails.size()];
        }

        @Override
        public Fragment getItem(int position) {
            if (pages[position] == null) {
                pages[position] = new ScreenSlidePageFragment();//.create(details.get(position));
                Bundle bundle = new Bundle(2);
                bundle.putInt("position", position);
                pages[position].setArguments(bundle);
            }
            return pages[position];

        }

        @Override
        public int getItemPosition(Object object) {
            return POSITION_NONE;
        }

        @Override
        public int getCount() {
            return CommonPlace.currentReadingListDetails.size();
        }
    }

    public void pleaseWait() {
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage(getResources().getString(R.string.info_connecting_server));
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();

    }

    public void onProgressUpdate(Integer... values) {
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setMax(100);
        if (values[0] <= 100) {
            mProgressDialog.setProgress(values[0]);
        }

    }

    public void CloseWait() {
        mProgressDialog.dismiss();
    }

    private void ShowOnlineControl() {
        ReadingListDetail detil = CommonPlace.currentReadingListDetails.get(mPager.getCurrentItem());
        if (detil.fldNowDigit.equals("") || detil.fldNowDigit.equals("-1")) {
            Toast.makeText(this,
                    " ?        .",
                    Toast.LENGTH_LONG).show();
        } else {

            OnlineControlWCF onlineControlWCF = new OnlineControlWCF(this,
                    new WcfBase.OnWcfCallFinished<ControlResults>() {

                        public void onDataReady(ControlResults res) {

                            ShowControlResult(res);

                        }

                    });
            onlineControlWCF.CheckControl(getToken(), detil.tbListDetail_ID, detil.fldNowDigit,
                    detil.EditDate.equals("") ? Utility.NowDate() : detil.EditDate);
            Toast.makeText(this, "Control", Toast.LENGTH_SHORT).show();
        }
    }

    private void ShowControlResult(ControlResults res) {
        String MessagString = "";
        if (res.List.size() > 0) {
            ControlResult r = res.List.get(0);
            if (r.ControlCode.equals("0")) {
                MessagString = getResources().getString(R.string.valid_reading) + "\n" + r.Title;

            } else {
                MessagString = getResources().getString(R.string.invalid_reading) + "\n" + r.Title;

            }
        } else {
            MessagString = getResources().getString(R.string.validation_failed) + "\n";

        }
        new AlertDialog.Builder(this).setMessage(MessagString).setPositiveButton(R.string.ok, null)
                .setTitle(R.string.validation_result).show();
    }

    private String getToken() {
        if (CommonPlace.currentUser != null) {
            return CommonPlace.currentUser.getToken();
        } else {
            return "";
        }

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed(); //To change body of generated methods, choose Tools | Templates.
        ReadingListHeaderDA.getInstance(this).update(CommonPlace.currentReadingList);
        try {
            CommonPlace.currentMapFragment.refresh();
        } catch (Exception ex) {
            ex.toString();
        }
    }

}