Example usage for android.content Intent setDataAndType

List of usage examples for android.content Intent setDataAndType

Introduction

In this page you can find the example usage for android.content Intent setDataAndType.

Prototype

public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) 

Source Link

Document

(Usually optional) Set the data for the intent along with an explicit MIME data type.

Usage

From source file:com.ifoer.expeditionphone.MainActivity.java

public Intent getPdfFileIntent(String path) {
    Intent i = new Intent("android.intent.action.VIEW");
    i.addCategory("android.intent.category.DEFAULT");
    i.addFlags(268435456);/*from   www.j a v a2  s .  c  o  m*/
    i.setDataAndType(Uri.fromFile(new File(path)), "application/pdf");
    return i;
}

From source file:com.abeo.tia.noordin.PropertyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_property);

    // load titles from strings.xml
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
    // load icons from strings.xml
    navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);
    // Find Set Function
    set(navMenuTitles, navMenuIcons);/*from  ww w . j a  va 2s  . c  o m*/
    // Find Button by Id
    buttonWalkIn = (Button) findViewById(R.id.button_PropertyWalkin);
    buttonFind = (Button) findViewById(R.id.button_PropertyFind);
    buttonAdd = (Button) findViewById(R.id.button_PropertyAdd);
    buttonEdit = (Button) findViewById(R.id.button_PropertyEdit);
    buttonConfirm = (Button) findViewById(R.id.button_PropertyConfirm);
    buttonPropertyList = (Button) findViewById(R.id.button_PropertyList);
    buttonRelatedCaes = (Button) findViewById(R.id.button_PropertyRelateCases);
    ZoomButton_propertyPdf1 = (ZoomButton) findViewById(R.id.zoomButton_propertyPdf1);

    // Find EditText Fields
    propertytitleNo = (EditText) findViewById(R.id.editText_ProperTytitleNo);
    propertyLotType = (EditText) findViewById(R.id.editText_PropertyLotType);
    propertyLotPTDNo = (EditText) findViewById(R.id.editText_PropertyLotPTDNo);
    propertyFormerlyKnownAs = (EditText) findViewById(R.id.editText_PropertyFormerlyKnownAs);
    propertyBandarPekanMukin = (EditText) findViewById(R.id.editText_PropertyBandarPekanMukin);
    //propertyDaerahState = (EditText) findViewById(R.id.editText_PropertyDaerahState);
    propertyNageriArea = (EditText) findViewById(R.id.editText_PropertyNageriArea);

    propertyLOTAREA_SQM = (EditText) findViewById(R.id.editText_PropertyLotArea);
    //propertyLOTAREA_SQFT = (EditText) findViewById(R.id.editText_PropertySqMeter);
    propertyLASTUPDATEDON = (EditText) findViewById(R.id.editText_PropertyLastUpdateOn);

    propertyDEVLICNO = (EditText) findViewById(R.id.editText_PropertyDevLicense);
    propertyDVLPR_LOC = (EditText) findViewById(R.id.editText_PropertySolicitorLoc);
    propertyLSTCHG_BRANCH = (EditText) findViewById(R.id.editText_PropertyBranch);
    propertyLSTCHG_PANO = (EditText) findViewById(R.id.editText_PropertyPAName);
    propertyLSTCHG_PRSTNO = (EditText) findViewById(R.id.editText_PropertyPresentaionNo);

    // Find By Id spinner Address To Use
    spinnerpropertyTitleType = (Spinner) findViewById(R.id.spinner_PropertyTitleType);
    spinnerpropertyPROJECT = (Spinner) findViewById(R.id.spinner_PropertyProjectDropdown);
    spinnerpropertyLSTCHG_BANKNAME = (Spinner) findViewById(R.id.spinner_PropertyProjectBank);
    spinnerpropertyDEVELOPER = (Spinner) findViewById(R.id.spinner_PropertyDevelopoer);
    spinnerpropertyDEVSOLICTOR = (Spinner) findViewById(R.id.spinner_PropertySolicitor);
    spinnerpropertySTATE = (Spinner) findViewById(R.id.state);

    QryGroup13 = (CheckBox) findViewById(R.id.PropetyCharged);

    // Find the SharedPreferences Firstname
    SharedPreferences FirstName = getSharedPreferences("LoginData", Context.MODE_PRIVATE);
    String FirName = FirstName.getString("FIRSETNAME", "");
    TextView welcome = (TextView) findViewById(R.id.textView_welcome);
    welcome.setText("Welcome " + FirName);

    // Spinner click listener
    spinnerpropertySTATE.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ID = (TextView) view.findViewById(R.id.Id);
            stateval_id = ID.getText().toString();
            TEXT = (TextView) view.findViewById(R.id.Name);
            stateval = TEXT.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener

    // Spinner click listener
    spinnerpropertyTitleType.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            textTitle_id = (TextView) view.findViewById(R.id.Id);
            titleValue_id = textTitle_id.getText().toString();
            textTitle = (TextView) view.findViewById(R.id.Name);
            titleValue = textTitle.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + titleValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });

    // Spinner click listener
    spinnerpropertyPROJECT.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            textProject_id = (TextView) view.findViewById(R.id.Id);
            projectValue_id = textProject_id.getText().toString();
            textProject = (TextView) view.findViewById(R.id.Name);
            projectValue = textProject.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + projectValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });

    // Spinner click listener
    spinnerpropertyDEVELOPER.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            textDeveloper_id = (TextView) view.findViewById(R.id.Id);
            developerValue_id = textDeveloper_id.getText().toString();
            textDeveloper = (TextView) view.findViewById(R.id.Name);
            developerValue = textDeveloper.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + developerValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
    // Spinner click listener
    spinnerpropertyDEVSOLICTOR.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            textSolicitor_id = (TextView) view.findViewById(R.id.Id);
            solicitorValue_id = textSolicitor_id.getText().toString();
            textSolicitor = (TextView) view.findViewById(R.id.Name);
            solicitorValue = textSolicitor.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + solicitorValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });

    // Spinner click listener
    spinnerpropertyLSTCHG_BANKNAME.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            textBank_id = (TextView) view.findViewById(R.id.Id);
            bankValue_id = textBank_id.getText().toString();
            textBank = (TextView) view.findViewById(R.id.Name);

            bankValue = textBank.getText().toString();

            // Showing selected spinner item
            //Toast.makeText(parent.getContext(), "Selected: " + bankValue, Toast.LENGTH_LONG).show();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });

    spinnerpropertyTitleType.requestFocus();
    // Find disable spinner
    spinnerpropertyDEVELOPER.setEnabled(false);
    spinnerpropertyDEVELOPER.setClickable(false);

    spinnerpropertyPROJECT.setEnabled(false);
    spinnerpropertyPROJECT.setClickable(false);

    spinnerpropertyDEVSOLICTOR.setEnabled(false);
    spinnerpropertyDEVSOLICTOR.setClickable(false);

    spinnerpropertyLSTCHG_BANKNAME.setEnabled(false);
    spinnerpropertyLSTCHG_BANKNAME.setClickable(false);

    // PropertyWalkin button enable
    buttonWalkIn.setEnabled(true);
    buttonWalkIn.setClickable(true);
    buttonWalkIn.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

    // Find button enable
    buttonFind.setClickable(false);
    buttonFind.setTextColor(getApplication().getResources().getColor(R.color.gray));

    // PropertyList button enable
    buttonPropertyList.setEnabled(true);
    buttonPropertyList.setClickable(true);
    buttonPropertyList.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

    buttonFind.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            spinnerpropertyTitleType.requestFocus();
            spinnerpropertyTitleType.setFocusableInTouchMode(true);

            // find button disable
            buttonFind.setClickable(false);
            buttonFind.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Property Related case list button enable
            buttonRelatedCaes.setEnabled(false);
            buttonRelatedCaes.setClickable(false);
            buttonRelatedCaes.setTextColor(getApplication().getResources().getColor(R.color.gray));

        }
    });

    // Add button enable
    buttonAdd.setClickable(true);
    buttonAdd.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

    buttonAdd.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // change boolean flag
            isADD = true;

            // Add button disable
            buttonAdd.setClickable(false);
            buttonAdd.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Walk-in button enable
            buttonWalkIn.setEnabled(true);
            buttonWalkIn.setClickable(true);
            buttonWalkIn.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

            // Confirm button enable
            buttonConfirm.setEnabled(true);
            buttonConfirm.setClickable(true);
            buttonConfirm.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

            // Property List button enable
            buttonPropertyList.setEnabled(false);
            buttonPropertyList.setClickable(false);
            buttonPropertyList.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Related button enable
            buttonRelatedCaes.setEnabled(false);
            buttonRelatedCaes.setClickable(false);
            buttonRelatedCaes.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Related button enable
            buttonEdit.setEnabled(false);
            buttonEdit.setClickable(false);
            buttonEdit.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Set edit text enable
            spinnerpropertyTitleType.setEnabled(true);
            spinnerpropertyTitleType.setClickable(true);
            spinnerpropertyTitleType.setFocusable(true);
            spinnerpropertyTitleType.setFocusableInTouchMode(true);
            spinnerpropertyTitleType.setSelection(0);

            spinnerpropertySTATE.setEnabled(true);
            spinnerpropertySTATE.setClickable(true);
            spinnerpropertySTATE.setFocusable(true);
            spinnerpropertySTATE.setFocusableInTouchMode(true);
            spinnerpropertySTATE.setSelection(0);

            propertytitleNo.setEnabled(true);
            propertytitleNo.setClickable(true);
            propertytitleNo.setFocusableInTouchMode(true);
            propertytitleNo.setText("");

            propertyLotType.setEnabled(true);
            propertyLotType.setClickable(true);
            propertyLotType.setFocusableInTouchMode(true);
            propertyLotType.setText("");

            propertyLotPTDNo.setEnabled(true);
            propertyLotPTDNo.setClickable(true);
            propertyLotPTDNo.setFocusableInTouchMode(true);
            propertyLotPTDNo.setText("");

            propertyFormerlyKnownAs.setEnabled(true);
            propertyFormerlyKnownAs.setClickable(true);
            propertyFormerlyKnownAs.setFocusableInTouchMode(true);
            propertyFormerlyKnownAs.setText("");

            propertyBandarPekanMukin.setEnabled(true);
            propertyBandarPekanMukin.setClickable(true);
            propertyBandarPekanMukin.setFocusableInTouchMode(true);
            propertyBandarPekanMukin.setText("");

            //propertyDaerahState.setEnabled(true);
            //propertyDaerahState.setClickable(true);
            //propertyDaerahState.setFocusableInTouchMode(true);
            //propertyDaerahState.setText("");

            propertyNageriArea.setEnabled(true);
            propertyNageriArea.setClickable(true);
            propertyNageriArea.setFocusableInTouchMode(true);
            propertyNageriArea.setText("");

            propertyLOTAREA_SQM.setEnabled(true);
            propertyLOTAREA_SQM.setClickable(true);
            propertyLOTAREA_SQM.setFocusableInTouchMode(true);
            propertyLOTAREA_SQM.setText("");

            //propertyLOTAREA_SQFT.setEnabled(true);
            //propertyLOTAREA_SQFT.setClickable(true);
            //propertyLOTAREA_SQFT.setFocusableInTouchMode(true);
            //propertyLOTAREA_SQFT.setText("");

            propertyLASTUPDATEDON.setEnabled(false);
            propertyLASTUPDATEDON.setClickable(false);
            propertyLASTUPDATEDON.setFocusableInTouchMode(false);
            propertyLASTUPDATEDON.setText("");

            spinnerpropertyDEVELOPER.setEnabled(true);
            spinnerpropertyDEVELOPER.setClickable(true);
            spinnerpropertyDEVELOPER.setFocusableInTouchMode(true);
            spinnerpropertyDEVELOPER.setSelection(0);

            spinnerpropertyPROJECT.setEnabled(true);
            spinnerpropertyPROJECT.setClickable(true);
            spinnerpropertyPROJECT.setFocusableInTouchMode(true);
            spinnerpropertyPROJECT.setSelection(0);

            propertyDEVLICNO.setEnabled(true);
            propertyDEVLICNO.setClickable(true);
            propertyDEVLICNO.setFocusableInTouchMode(true);
            propertyDEVLICNO.setText("");

            spinnerpropertyDEVSOLICTOR.setEnabled(true);
            spinnerpropertyDEVSOLICTOR.setClickable(true);
            spinnerpropertyDEVSOLICTOR.setFocusableInTouchMode(true);
            spinnerpropertyDEVSOLICTOR.setSelection(0);

            propertyDVLPR_LOC.setEnabled(true);
            propertyDVLPR_LOC.setClickable(true);
            propertyDVLPR_LOC.setFocusableInTouchMode(true);
            propertyDVLPR_LOC.setText("");

            spinnerpropertyLSTCHG_BANKNAME.setEnabled(true);
            spinnerpropertyLSTCHG_BANKNAME.setClickable(true);
            spinnerpropertyLSTCHG_BANKNAME.setFocusableInTouchMode(true);
            spinnerpropertyLSTCHG_BANKNAME.setSelection(0);

            propertyLSTCHG_BRANCH.setEnabled(true);
            propertyLSTCHG_BRANCH.setClickable(true);
            propertyLSTCHG_BRANCH.setFocusableInTouchMode(true);
            propertyLSTCHG_BRANCH.setText("");

            propertyLSTCHG_PANO.setEnabled(true);
            propertyLSTCHG_PANO.setClickable(true);
            propertyLSTCHG_PANO.setFocusableInTouchMode(true);
            propertyLSTCHG_PANO.setText("");

            propertyLSTCHG_PRSTNO.setEnabled(true);
            propertyLSTCHG_PRSTNO.setClickable(true);
            propertyLSTCHG_PRSTNO.setFocusableInTouchMode(true);
            propertyLSTCHG_PRSTNO.setText("");

        }
    });

    buttonWalkIn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) { // TODO Auto-generated method
            Intent i = new Intent(PropertyActivity.this, WalkInActivity.class);
            startActivity(i);

        }
    });

    // Find ZoomButton for property list
    ZoomButton_propertyPdf1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!TITLELINK.equals("")) {

                String pdfurl = "http://54.251.51.69:3878" + TITLELINK; //YOUR URL TO PDF
                String googleDocsUrl = "http://docs.google.com/viewer?url=" + pdfurl;
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse(googleDocsUrl), "text/html");
                startActivity(intent);
            }
        }
    });

    // Find Button for edit property details

    buttonEdit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // change the boolean flag
            isEdit = true;

            // Confirm button enable
            buttonConfirm.setEnabled(true);
            buttonConfirm.setClickable(true);
            buttonConfirm.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

            // Add button disable
            buttonAdd.setEnabled(false);
            buttonAdd.setClickable(false);
            buttonAdd.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Edit button disable
            buttonEdit.setEnabled(false);
            buttonEdit.setClickable(false);
            buttonEdit.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Walk-in button disable
            buttonWalkIn.setEnabled(false);
            buttonWalkIn.setClickable(false);
            buttonWalkIn.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // PropertyList button disable
            buttonPropertyList.setEnabled(false);
            buttonPropertyList.setClickable(false);
            buttonPropertyList.setTextColor(getApplication().getResources().getColor(R.color.gray));

            // Related case button enable
            buttonRelatedCaes.setEnabled(true);
            buttonRelatedCaes.setClickable(true);
            buttonRelatedCaes.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

            // edit text enable
            spinnerpropertyTitleType.setClickable(true);
            spinnerpropertyTitleType.setEnabled(true);
            spinnerpropertyTitleType.setFocusableInTouchMode(true);

            spinnerpropertySTATE.setClickable(true);
            spinnerpropertySTATE.setEnabled(true);
            spinnerpropertySTATE.setFocusableInTouchMode(true);

            propertytitleNo.setClickable(true);
            propertytitleNo.setEnabled(true);
            propertytitleNo.setFocusableInTouchMode(true);

            propertyLotType.setClickable(true);
            propertyLotType.setEnabled(true);
            propertyLotType.setFocusableInTouchMode(true);

            propertyLotPTDNo.setClickable(true);
            propertyLotPTDNo.setEnabled(true);
            propertyLotPTDNo.setFocusableInTouchMode(true);

            propertyFormerlyKnownAs.setClickable(true);
            propertyFormerlyKnownAs.setEnabled(true);
            propertyFormerlyKnownAs.setFocusableInTouchMode(true);

            propertyBandarPekanMukin.setClickable(true);
            propertyBandarPekanMukin.setEnabled(true);
            propertyBandarPekanMukin.setFocusableInTouchMode(true);

            //propertyDaerahState.setClickable(true);
            //propertyDaerahState.setEnabled(true);
            //propertyDaerahState.setFocusableInTouchMode(true);

            propertyNageriArea.setClickable(true);
            propertyNageriArea.setEnabled(true);
            propertyNageriArea.setFocusableInTouchMode(true);

            propertyLOTAREA_SQM.setClickable(true);
            propertyLOTAREA_SQM.setEnabled(true);
            propertyLOTAREA_SQM.setFocusableInTouchMode(true);

            //propertyLOTAREA_SQFT.setClickable(true);
            //propertyLOTAREA_SQFT.setEnabled(true);
            //propertyLOTAREA_SQFT.setFocusableInTouchMode(true);

            propertyLASTUPDATEDON.setClickable(false);
            propertyLASTUPDATEDON.setEnabled(false);
            propertyLASTUPDATEDON.setFocusableInTouchMode(false);

            spinnerpropertyDEVELOPER.setClickable(true);
            spinnerpropertyDEVELOPER.setEnabled(true);
            spinnerpropertyDEVELOPER.setFocusable(true);
            spinnerpropertyDEVELOPER.setFocusableInTouchMode(true);

            spinnerpropertyPROJECT.setClickable(true);
            spinnerpropertyPROJECT.setEnabled(true);
            spinnerpropertyPROJECT.setFocusableInTouchMode(true);

            propertyDEVLICNO.setClickable(true);
            propertyDEVLICNO.setEnabled(true);
            propertyDEVLICNO.setFocusableInTouchMode(true);

            spinnerpropertyDEVSOLICTOR.setClickable(true);
            spinnerpropertyDEVSOLICTOR.setEnabled(true);
            spinnerpropertyDEVSOLICTOR.setFocusableInTouchMode(true);

            propertyDVLPR_LOC.setClickable(true);
            propertyDVLPR_LOC.setEnabled(true);
            propertyDVLPR_LOC.setFocusableInTouchMode(true);

            spinnerpropertyLSTCHG_BANKNAME.setClickable(true);
            spinnerpropertyLSTCHG_BANKNAME.setEnabled(true);
            spinnerpropertyLSTCHG_BANKNAME.setFocusableInTouchMode(true);

            propertyLSTCHG_BRANCH.setClickable(true);
            propertyLSTCHG_BRANCH.setEnabled(true);
            propertyLSTCHG_BRANCH.setFocusableInTouchMode(true);

            propertyLSTCHG_PANO.setClickable(true);
            propertyLSTCHG_PANO.setEnabled(true);
            propertyLSTCHG_PANO.setFocusableInTouchMode(true);

            propertyLSTCHG_PRSTNO.setClickable(true);
            propertyLSTCHG_PRSTNO.setEnabled(true);
            propertyLSTCHG_PRSTNO.setFocusableInTouchMode(true);

        }
    });

    // Find Confirm button

    buttonConfirm.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(PropertyActivity.this);

            // set title
            alertDialogBuilder.setTitle("Confirm");

            // set dialog message
            alertDialogBuilder.setMessage("Click yes to save!").setCancelable(false)
                    .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                            if (isADD == true && isEdit == false) {
                                // call edit webservice for property details
                                addDatapropertyDetails();

                            } else {

                                // call edit webservice for property details
                                sendDataEditpropertyDetails();

                            }
                            Intent i = getIntent();
                            startActivity(i);

                        }
                    }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // if this button is clicked, just close
                            // the dialog box and do nothing
                            dialog.cancel();
                        }
                    });
            // create alert dialog
            AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();

        }
    });

    // Find Property List on button Click

    buttonPropertyList.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            spinnerpropertyTitleType.setEnabled(true);
            spinnerpropertyTitleType.requestFocus();
            spinnerpropertyTitleType.setClickable(true);
            spinnerpropertyTitleType.setFocusable(true);

            spinnerpropertySTATE.setEnabled(true);
            spinnerpropertySTATE.requestFocus();
            spinnerpropertySTATE.setClickable(true);
            spinnerpropertySTATE.setFocusable(true);

            //Toast.makeText(PropertyActivity.this, "Search button clicked!", Toast.LENGTH_SHORT).show();
            // Call web service
            webRequestPropertyDetails();
        }
    });

    // Find Property Case List on button click

    buttonRelatedCaes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            webRequestPropertyCaseList();
            //Toast.makeText(PropertyActivity.this, "Related case clicked", Toast.LENGTH_SHORT).show();
        }
    });

    // Result Bundle getting from list item click to property activity
    Bundle b = getIntent().getExtras();
    if (b != null) {

        // Add button disable
        buttonAdd.setClickable(true);
        buttonAdd.setFocusable(true);
        buttonAdd.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

        // Find button enable
        buttonFind.setClickable(false);
        buttonFind.setFocusable(false);
        buttonFind.setTextColor(getApplication().getResources().getColor(R.color.gray));

        // PropertyList button enable
        buttonPropertyList.setClickable(false);
        buttonPropertyList.setFocusable(false);
        buttonPropertyList.setTextColor(getApplication().getResources().getColor(R.color.gray));
        // Related Case button enable
        buttonRelatedCaes.setClickable(true);
        buttonRelatedCaes.setFocusable(true);
        buttonRelatedCaes.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

        // Edit button enable
        buttonEdit.setClickable(true);
        buttonEdit.setFocusable(true);
        buttonEdit.setTextColor(getApplication().getResources().getColor(R.color.royalBlue));

        codeDetailResponse = b.getString("CODE_T");
        System.out.println("Property Text Details");
        System.out.println(codeDetailResponse);
        codeResonse_listview = codeDetailResponse;

        titleTypeDetailResponse = b.getString("TITLETYPE_T");
        System.out.println(titleTypeDetailResponse);
        spinnerpropertyTitleType.setEnabled(false);
        spinnerpropertyTitleType.setClickable(false);

        spinnerpropertySTATE.setEnabled(false);
        spinnerpropertySTATE.setClickable(false);

        titleNoDetailResponse = b.getString("TITLENO_T");
        System.out.println(titleNoDetailResponse);
        propertytitleNo.setEnabled(false);
        propertytitleNo.setClickable(false);
        propertytitleNo.setText(titleNoDetailResponse);

        lotTypeDetailResponse = b.getString("LOTTYPE_T");
        System.out.println(lotTypeDetailResponse);
        propertyLotType.setEnabled(false);
        propertyLotType.setClickable(false);
        propertyLotType.setText(lotTypeDetailResponse);

        lotNoDetailResponse = b.getString("LOTNO_T");
        System.out.println(lotNoDetailResponse);
        propertyLotPTDNo.setEnabled(false);
        propertyLotPTDNo.setClickable(false);
        propertyLotPTDNo.setText(lotNoDetailResponse);

        formerlyDetailResponse = b.getString("FORMERLY_KNOWN_AS_T");
        System.out.println(formerlyDetailResponse);
        propertyFormerlyKnownAs.setEnabled(false);
        propertyFormerlyKnownAs.setClickable(false);
        propertyFormerlyKnownAs.setText(formerlyDetailResponse);

        bpmDetailResponse = b.getString("BPM_T");
        System.out.println(bpmDetailResponse);
        propertyBandarPekanMukin.setEnabled(false);
        propertyBandarPekanMukin.setClickable(false);
        propertyBandarPekanMukin.setText(bpmDetailResponse);

        stateDetailResponse = b.getString("STATE_T");
        System.out.println(stateDetailResponse);
        statevalue = stateDetailResponse;
        //propertyDaerahState.setEnabled(false);
        //propertyDaerahState.setClickable(false);
        //propertyDaerahState.setText(stateDetailResponse);

        areaDetailResponse = b.getString("AREA_T");
        System.out.println(areaDetailResponse);
        propertyNageriArea.setEnabled(false);
        propertyNageriArea.setClickable(false);
        propertyNageriArea.setText(areaDetailResponse);

        lotAreaDetailResponse = b.getString("LOTAREA_SQM_T");
        System.out.println(lotAreaDetailResponse);
        propertyLOTAREA_SQM.setEnabled(false);
        propertyLOTAREA_SQM.setClickable(false);
        propertyLOTAREA_SQM.setText(lotAreaDetailResponse);

        lotaresSoftDetailResponse = b.getString("LOTAREA_SQFT_T");
        System.out.println(lotaresSoftDetailResponse);
        //propertyLOTAREA_SQFT.setEnabled(false);
        //propertyLOTAREA_SQFT.setClickable(false);
        propertyLOTAREA_SQM.setText(lotaresSoftDetailResponse);

        lastupDateDetailResponse = b.getString("LASTUPDATEDON_T");
        System.out.println(lastupDateDetailResponse);
        propertyLASTUPDATEDON.setEnabled(false);
        propertyLASTUPDATEDON.setClickable(false);
        propertyLASTUPDATEDON.setText(lastupDateDetailResponse);

        developerDetailResponse = b.getString("DEVELOPER_T");
        System.out.println(developerDetailResponse);
        spinnerpropertyDEVELOPER.setEnabled(false);
        spinnerpropertyDEVELOPER.setClickable(false);

        developerCodeResponse = b.getString("DVLPR_CODE_T");
        System.out.println(developerCodeResponse);
        spinnerpropertyDEVELOPER.setEnabled(false);
        spinnerpropertyDEVELOPER.setClickable(false);

        projectDetailResponse = b.getString("PROJECT_T");
        System.out.println(projectDetailResponse);
        spinnerpropertyPROJECT.setEnabled(false);
        spinnerpropertyPROJECT.setClickable(false);

        DevlicNoDetailResponse = b.getString("DEVLICNO_T");
        System.out.println(DevlicNoDetailResponse);
        propertyDEVLICNO.setEnabled(false);
        propertyDEVLICNO.setClickable(false);
        propertyDEVLICNO.setText(DevlicNoDetailResponse);

        devSolictorDetailResponse = b.getString("DEVSOLICTOR_T");
        System.out.println(devSolictorDetailResponse);
        spinnerpropertyDEVSOLICTOR.setEnabled(false);
        spinnerpropertyDEVSOLICTOR.setClickable(false);

        devSolictorCodeResponse = b.getString("DVLPR_SOL_CODE_T");
        System.out.println(devSolictorCodeResponse);
        spinnerpropertyDEVSOLICTOR.setEnabled(false);
        spinnerpropertyDEVSOLICTOR.setClickable(false);

        devSolictorLocDetailResponse = b.getString("DVLPR_LOC_T");
        System.out.println(devSolictorLocDetailResponse);
        propertyDVLPR_LOC.setEnabled(false);
        propertyDVLPR_LOC.setClickable(false);
        propertyDVLPR_LOC.setText(devSolictorLocDetailResponse);

        bankCodeResponse = b.getString("LSTCHG_BANKNAME_T");
        System.out.println(bankCodeResponse);
        spinnerpropertyLSTCHG_BANKNAME.setEnabled(false);
        spinnerpropertyLSTCHG_BANKNAME.setClickable(false);

        bankDetailResponse = b.getString("LSTCHG_BANKNAME_T");
        System.out.println(bankDetailResponse);
        spinnerpropertyLSTCHG_BANKNAME.setEnabled(false);
        spinnerpropertyLSTCHG_BANKNAME.setClickable(false);

        branchDetailResponse = b.getString("LSTCHG_BRANCH_T");
        System.out.println(branchDetailResponse);
        propertyLSTCHG_BRANCH.setEnabled(false);
        propertyLSTCHG_BRANCH.setClickable(false);
        propertyLSTCHG_BRANCH.setText(branchDetailResponse);

        panNoDetailResponse = b.getString("LSTCHG_PANO_T");
        System.out.println(panNoDetailResponse);
        propertyLSTCHG_PANO.setEnabled(false);
        propertyLSTCHG_PANO.setClickable(false);
        propertyLSTCHG_PANO.setText(panNoDetailResponse);

        prsentDetailResponse = b.getString("LSTCHG_PRSTNO_T");
        System.out.println(prsentDetailResponse);
        propertyLSTCHG_PRSTNO.setEnabled(false);
        propertyLSTCHG_PRSTNO.setClickable(false);
        propertyLSTCHG_PRSTNO.setText(prsentDetailResponse);

        TITLELINK = b.getString("TITLELINK_T");

        if (b.getString("PROPERTYCHARGED_T").equals("Y"))
            QryGroup13.setChecked(true);
        if (b.getString("PROPERTYCHARGED_T").equals("N"))
            QryGroup13.setChecked(false);

    }
    try {
        // Dropdown function title type
        dropdownPorjectTitleType();
        // Dropdown function project
        dropdownPorject();

        dropdownState();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // Dropdown BankDeveloperSolicitor function
    dropdownBankDeveloperSolicitor();
}

From source file:dentex.youtube.downloader.DashboardActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BugSenseHandler.leaveBreadcrumb("DashboardActivity_onCreate");
    //Utils.logger("v", "TotalRxBeforeTest: " + TotalRxBeforeTest, DEBUG_TAG);

    // Theme init
    Utils.themeInit(this);

    setContentView(R.layout.activity_dashboard);

    // Language init
    Utils.langInit(this);

    // Detect screen orientation
    int or = this.getResources().getConfiguration().orientation;
    isLandscape = (or == 2) ? true : false;

    sDashboard = DashboardActivity.this;

    if (da != null) {
        clearAdapterAndLists();// ww  w  .  j  av  a 2  s.c  om
    }

    countdown = 10;

    parseJson(this);
    updateProgressBars();
    buildList();

    lv = (ListView) findViewById(R.id.dashboard_list);

    da = new DashboardAdapter(itemsList, this);

    if (da.isEmpty()) {
        showEmptyListInfo(this);
    } else {
        lv.setAdapter(da);
    }

    /*Log.i(DEBUG_TAG, "ADML Maps:" +
     "\ndtMap:                 " + Maps.dtMap +
     "\nmDownloadPercentMap:   " + Maps.mDownloadPercentMap +
     "\nmDownloadSizeMap:      " + Maps.mDownloadSizeMap + 
     "\nmTotalSizeMap:         " + Maps.mTotalSizeMap);*/

    lv.setTextFilterEnabled(true);

    lv.setClickable(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (!isAnyAsyncInProgress) {
                currentItem = da.getItem(position); // in order to refer to the filtered item
                newClick = true;

                final boolean ffmpegEnabled = YTD.settings.getBoolean("enable_advanced_features", false);

                AlertDialog.Builder builder = new AlertDialog.Builder(boxThemeContextWrapper);
                builder.setTitle(currentItem.getFilename());

                if (currentItem.getStatus().equals(getString(R.string.json_status_completed))
                        || currentItem.getStatus().equals(getString(R.string.json_status_imported))) {

                    final boolean audioIsSupported = !currentItem.getAudioExt().equals("unsupported");
                    final File in = new File(currentItem.getPath(), currentItem.getFilename());

                    if (currentItem.getType().equals(YTD.JSON_DATA_TYPE_V)) {

                        // handle click on a **VIDEO** file entry
                        builder.setItems(R.array.dashboard_click_entries,
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {

                                        switch (which) {
                                        case 0: // open
                                            BugSenseHandler.leaveBreadcrumb("video_open");
                                            Intent openIntent = new Intent(Intent.ACTION_VIEW);
                                            openIntent.setDataAndType(Uri.fromFile(in), "video/*");
                                            startActivity(Intent.createChooser(openIntent,
                                                    getString(R.string.open_chooser_title)));
                                            break;
                                        case 1: // extract audio only
                                            if (!isFfmpegRunning) {
                                                BugSenseHandler.leaveBreadcrumb("video_ffmpeg_extract");
                                                if (audioIsSupported) {
                                                    if (ffmpegEnabled) {
                                                        AlertDialog.Builder builder0 = new AlertDialog.Builder(
                                                                boxThemeContextWrapper);
                                                        LayoutInflater inflater0 = getLayoutInflater();
                                                        final View view0 = inflater0
                                                                .inflate(R.layout.dialog_audio_extr_only, null);

                                                        String type = null;
                                                        if (currentItem.getAudioExt().equals(".aac"))
                                                            type = aac;
                                                        if (currentItem.getAudioExt().equals(".ogg"))
                                                            type = ogg;
                                                        if (currentItem.getAudioExt().equals(".mp3"))
                                                            type = mp3;
                                                        //if (currentItem.getAudioExt().equals(".auto")) type = aac_mp3;

                                                        TextView info = (TextView) view0
                                                                .findViewById(R.id.audio_extr_info);
                                                        info.setText(getString(R.string.audio_extr_info)
                                                                + "\n\n" + type);

                                                        builder0.setView(view0).setPositiveButton("OK",
                                                                new DialogInterface.OnClickListener() {
                                                                    @Override
                                                                    public void onClick(DialogInterface dialog,
                                                                            int id) {

                                                                        CheckBox cb0 = (CheckBox) view0
                                                                                .findViewById(R.id.rem_video_0);
                                                                        removeVideo = cb0.isChecked();

                                                                        Utils.logger("v",
                                                                                "Launching FFmpeg on: " + in
                                                                                        + "\n-> mode: extraction only"
                                                                                        + "\n-> remove video: "
                                                                                        + removeVideo,
                                                                                DEBUG_TAG);

                                                                        ffmpegJob(in, null, null);
                                                                    }
                                                                }).setNegativeButton(R.string.dialogs_negative,
                                                                        new DialogInterface.OnClickListener() {
                                                                            public void onClick(
                                                                                    DialogInterface dialog,
                                                                                    int id) {
                                                                                // cancel
                                                                            }
                                                                        });

                                                        secureShowDialog(builder0);
                                                    } else {
                                                        notifyFfmpegNotInstalled();
                                                    }
                                                } else {
                                                    notifyOpsNotSupported();
                                                }
                                            } else {
                                                notifyFfmpegIsAlreadyRunning();
                                            }

                                            break;
                                        case 2: // extract audio and convert to mp3
                                            if (!isFfmpegRunning) {
                                                BugSenseHandler.leaveBreadcrumb("video_ffmpeg_mp3");
                                                if (audioIsSupported) {
                                                    if (ffmpegEnabled) {
                                                        AlertDialog.Builder builder1 = new AlertDialog.Builder(
                                                                boxThemeContextWrapper);
                                                        LayoutInflater inflater1 = getLayoutInflater();

                                                        final View view1 = inflater1.inflate(
                                                                R.layout.dialog_audio_extr_mp3_conv, null);

                                                        builder1.setView(view1).setPositiveButton("OK",
                                                                new DialogInterface.OnClickListener() {
                                                                    @Override
                                                                    public void onClick(DialogInterface dialog,
                                                                            int id) {

                                                                        final Spinner sp = (Spinner) view1
                                                                                .findViewById(R.id.mp3_spinner);
                                                                        String[] bitrateData = retrieveBitrateValueFromSpinner(
                                                                                sp);

                                                                        CheckBox cb1 = (CheckBox) view1
                                                                                .findViewById(R.id.rem_video_1);
                                                                        removeVideo = cb1.isChecked();

                                                                        Utils.logger("v",
                                                                                "Launching FFmpeg on: " + in
                                                                                        + "\n-> mode: conversion to mp3 from video file"
                                                                                        + "\n-> remove video: "
                                                                                        + removeVideo,
                                                                                DEBUG_TAG);

                                                                        ffmpegJob(in, bitrateData[0],
                                                                                bitrateData[1]);
                                                                    }
                                                                }).setNegativeButton(R.string.dialogs_negative,
                                                                        new DialogInterface.OnClickListener() {
                                                                            public void onClick(
                                                                                    DialogInterface dialog,
                                                                                    int id) {
                                                                                //
                                                                            }
                                                                        });

                                                        secureShowDialog(builder1);
                                                    } else {
                                                        notifyFfmpegNotInstalled();
                                                    }
                                                } else {
                                                    notifyOpsNotSupported();
                                                }
                                            } else {
                                                notifyFfmpegIsAlreadyRunning();
                                            }
                                        }
                                    }
                                });

                        secureShowDialog(builder);

                    } else if (currentItem.getType().equals(YTD.JSON_DATA_TYPE_A_E)
                            || currentItem.getType().equals(YTD.JSON_DATA_TYPE_A_M)) {

                        // handle click on a **AUDIO** file entry
                        builder.setItems(R.array.dashboard_click_entries_audio,
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {

                                        switch (which) {
                                        case 0: // open
                                            BugSenseHandler.leaveBreadcrumb("audio_open");
                                            Intent openIntent = new Intent(Intent.ACTION_VIEW);
                                            openIntent.setDataAndType(Uri.fromFile(in), "audio/*");
                                            startActivity(Intent.createChooser(openIntent,
                                                    getString(R.string.open_chooser_title)));
                                            break;
                                        case 1: // convert to mp3
                                            if (!isFfmpegRunning) {
                                                if (ffmpegEnabled) {
                                                    BugSenseHandler.leaveBreadcrumb("audio_ffmpeg_mp3");
                                                    AlertDialog.Builder builder0 = new AlertDialog.Builder(
                                                            boxThemeContextWrapper);
                                                    LayoutInflater inflater0 = getLayoutInflater();
                                                    final View view2 = inflater0
                                                            .inflate(R.layout.dialog_audio_mp3_conv, null);

                                                    builder0.setView(view2).setPositiveButton("OK",
                                                            new DialogInterface.OnClickListener() {
                                                                @Override
                                                                public void onClick(DialogInterface dialog,
                                                                        int id) {

                                                                    final Spinner sp = (Spinner) view2
                                                                            .findViewById(R.id.mp3_spinner_a);
                                                                    String[] bitrateData = retrieveBitrateValueFromSpinner(
                                                                            sp);

                                                                    CheckBox cb2 = (CheckBox) view2
                                                                            .findViewById(
                                                                                    R.id.rem_original_audio);
                                                                    removeAudio = cb2.isChecked();

                                                                    Utils.logger("v", "Launching FFmpeg on: "
                                                                            + in
                                                                            + "\n-> mode: conversion to mp3 from audio file"
                                                                            + "\n-> remove audio: "
                                                                            + removeAudio, DEBUG_TAG);

                                                                    ffmpegJob(in, bitrateData[0],
                                                                            bitrateData[1]);
                                                                }
                                                            }).setNegativeButton(R.string.dialogs_negative,
                                                                    new DialogInterface.OnClickListener() {
                                                                        public void onClick(
                                                                                DialogInterface dialog,
                                                                                int id) {
                                                                            //
                                                                        }
                                                                    });

                                                    secureShowDialog(builder0);
                                                } else {
                                                    notifyFfmpegNotInstalled();
                                                }
                                            } else {
                                                notifyFfmpegIsAlreadyRunning();
                                            }
                                        }
                                    }
                                });

                        secureShowDialog(builder);
                    }
                } /*else if (currentItem.getStatus().equals(getString(R.string.json_status_imported))) {
                   Utils.logger("v", "IMPORTED video clicked", DEBUG_TAG);
                           
                   // handle click on an  **IMPORTED VIDEO** entry
                   builder.setItems(R.array.dashboard_click_entries_imported, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                          
                   final File in = new File (currentItem.getPath(), currentItem.getFilename());
                           
                   switch (which) {
                   case 0: // open
                      Intent openIntent = new Intent(Intent.ACTION_VIEW);
                      openIntent.setDataAndType(Uri.fromFile(in), "video/*");
                      startActivity(Intent.createChooser(openIntent, getString(R.string.open_chooser_title)));
                      break;
                   }
                    }
                   });
                          
                   secureShowDialog(builder);
                  }*/
            }
        }
    });

    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {

            if (!isAnyAsyncInProgress) {
                currentItem = da.getItem(position); // in order to refer to the filtered item

                int COPY = 0;
                int MOVE = 1;
                int RENAME = 2;
                int REDOWNLOAD = 3;
                int REMOVE = 4;
                int DELETE = 5;
                int PAUSERESUME = 6;

                int[] disabledItems = null;

                if (currentItem.getStatus().equals(getString(R.string.json_status_in_progress))
                        || currentItem.getStatus().equals(getString(R.string.json_status_paused))) {
                    // show: DELETE and  PAUSERESUME
                    disabledItems = new int[] { COPY, MOVE, RENAME, REDOWNLOAD, REMOVE };
                } else if (currentItem.getStatus().equals(getString(R.string.json_status_failed))) {
                    // check if the item has a real YouTube ID, otherwise it's an imported video.
                    if (currentItem.getYtId().length() == 11) {
                        // show: REMOVE and REDOWNLOAD
                        disabledItems = new int[] { COPY, MOVE, RENAME, DELETE, PAUSERESUME };
                    } else {
                        // show: REMOVE only
                        disabledItems = new int[] { COPY, MOVE, RENAME, REDOWNLOAD, DELETE, PAUSERESUME };
                    }

                } else if (currentItem.getStatus().equals(getString(R.string.json_status_imported)) ||
                //case for audio entries _completed but from _imported
                (currentItem.getStatus().equals(getString(R.string.json_status_completed))
                        && !(currentItem.getYtId().length() == 11))) {
                    // show: COPY, MOVE, RENAME, REMOVE and DELETE
                    disabledItems = new int[] { REDOWNLOAD, PAUSERESUME };
                } else if (currentItem.getStatus().equals(getString(R.string.json_status_completed))) {
                    // show: all items except PAUSERESUME
                    disabledItems = new int[] { PAUSERESUME };
                }

                AlertDialog.Builder builder = new AlertDialog.Builder(boxThemeContextWrapper);
                builder.setTitle(currentItem.getFilename());

                final ArrayAdapter<CharSequence> cla = DashboardLongClickAdapter.createFromResource(
                        boxThemeContextWrapper, R.array.dashboard_long_click_entries,
                        android.R.layout.simple_list_item_1, disabledItems);

                builder.setAdapter(cla, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                        case 0:
                            BugSenseHandler.leaveBreadcrumb("copy");
                            copy(currentItem);
                            break;
                        case 1:
                            BugSenseHandler.leaveBreadcrumb("move");
                            move(currentItem);
                            break;
                        case 2:
                            BugSenseHandler.leaveBreadcrumb("rename");
                            rename(currentItem);
                            break;
                        case 3:
                            if (currentItem.getStatus().equals(getString(R.string.json_status_failed))) {
                                BugSenseHandler.leaveBreadcrumb("reDownload_RESTART");
                                reDownload(currentItem, "RESTART");
                            } else {
                                BugSenseHandler.leaveBreadcrumb("reDownload");
                                reDownload(currentItem, "-");
                            }
                            break;
                        case 4:
                            BugSenseHandler.leaveBreadcrumb("removeFromDashboard");
                            removeFromDashboard(currentItem);
                            break;
                        case 5:
                            BugSenseHandler.leaveBreadcrumb("delete");
                            delete(currentItem);
                            break;
                        case 6:
                            BugSenseHandler.leaveBreadcrumb("pauseresume");
                            pauseresume(currentItem);
                        }

                    }
                });

                secureShowDialog(builder);
            }

            return true;
        }
    });
}

From source file:com.android.gallery3d.app.PhotoPage.java

private void launchSimpleEditor() {
    MediaItem current = mModel.getMediaItem(0);
    if (current == null || (current.getSupportedOperations() & MediaObject.SUPPORT_EDIT) == 0) {
        return;//from  w  w  w. ja  v a2  s  . c o m
    }

    Intent intent = new Intent(ACTION_SIMPLE_EDIT);

    intent.setDataAndType(current.getContentUri(), current.getMimeType())
            .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    if (mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
            .size() == 0) {
        intent.setAction(Intent.ACTION_EDIT);
    }
    intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
    ((Activity) mActivity).startActivityForResult(Intent.createChooser(intent, null), REQUEST_EDIT);
    overrideTransitionToEditor();
}

From source file:com.android.gallery3d.app.PhotoPage.java

private void launchTinyPlanet() {
    // Deep link into tiny planet
    MediaItem current = mModel.getMediaItem(0);
    Intent intent = new Intent(FilterShowActivity.TINY_PLANET_ACTION);
    intent.setClass(mActivity, FilterShowActivity.class);
    intent.setDataAndType(current.getContentUri(), current.getMimeType())
            .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
    mActivity.startActivityForResult(intent, REQUEST_EDIT);
    overrideTransitionToEditor();//from  w  w  w.j  av a 2  s.co m
}

From source file:com.android.gallery3d.app.PhotoPage.java

@Override
protected boolean onItemSelected(MenuItem item) {
    if (mModel == null)
        return true;
    refreshHidingMessage();/*www .j a v a  2  s  .  co  m*/
    MediaItem current = mModel.getMediaItem(0);

    // This is a shield for monkey when it clicks the action bar
    // menu when transitioning from filmstrip to camera
    if (current instanceof SnailItem)
        return true;
    // TODO: We should check the current photo against the MediaItem
    // that the menu was initially created for. We need to fix this
    // after PhotoPage being refactored.
    if (current == null) {
        // item is not ready, ignore
        return true;
    }
    int currentIndex = mModel.getCurrentIndex();
    Path path = current.getPath();

    DataManager manager = mActivity.getDataManager();
    int action = item.getItemId();
    /// M: [BUG.ADD] show toast before PhotoDataAdapter finishing loading to avoid JE @{
    if (action != android.R.id.home && !mLoadingFinished && mSetPathString != null) {
        Toast.makeText(mActivity, mActivity.getString(R.string.please_wait), Toast.LENGTH_SHORT).show();
        return true;
    }
    /// @}
    String confirmMsg = null;
    switch (action) {
    case android.R.id.home: {
        onUpPressed();
        return true;
    }
    case R.id.action_slideshow: {
        Bundle data = new Bundle();
        /// M: [BUG.MODIFY] fix bug: slideshow doesn't play again
        // when finish playing the last picture @{
        String mediaSetPath = mMediaSet.getPath().toString();
        if (mSnailSetPath != null) {
            mediaSetPath = mediaSetPath.replace(mSnailSetPath + ",", "");
            Log.i(TAG, "<onItemSelected> action_slideshow | mediaSetPath: " + mediaSetPath);
        }
        /*data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString());*/
        data.putString(SlideshowPage.KEY_SET_PATH, mediaSetPath);
        /// @}
        data.putString(SlideshowPage.KEY_ITEM_PATH, path.toString());
        /// M: [BUG.ADD] currentIndex-- if it is in camera folder @{
        if (mHasCameraScreennailOrPlaceholder) {
            currentIndex--;
        }
        /// @}

        data.putInt(SlideshowPage.KEY_PHOTO_INDEX, currentIndex);
        data.putBoolean(SlideshowPage.KEY_REPEAT, true);
        mActivity.getStateManager().startStateForResult(SlideshowPage.class, REQUEST_SLIDESHOW, data);
        return true;
    }
    case R.id.action_crop: {
        /// M: [BUG.ADD] disable cropping photo when file not exists or sdcard is full. @{
        File srcFile = new File(current.getFilePath());
        if (!srcFile.exists()) {
            Log.i(TAG, "<onItemSelected> abort cropping photo when not exists!");
            return true;
        }
        if (!isSpaceEnough(srcFile)) {
            Log.i(TAG, "<onItemSelected> abort cropping photo when no enough space!");
            Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT)
                    .show();
            return true;
        }
        /// @}
        Activity activity = mActivity;
        Intent intent = new Intent(CropActivity.CROP_ACTION);
        intent.setClass(activity, CropActivity.class);
        intent.setDataAndType(manager.getContentUri(path), current.getMimeType())
                .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        activity.startActivityForResult(intent,
                PicasaSource.isPicasaImage(current) ? REQUEST_CROP_PICASA : REQUEST_CROP);
        return true;
    }
    case R.id.action_trim: {
        Intent intent = new Intent(mActivity, TrimVideo.class);
        intent.setData(manager.getContentUri(path));
        // We need the file path to wrap this into a RandomAccessFile.
        intent.putExtra(KEY_MEDIA_ITEM_PATH, current.getFilePath());
        /// M: [FEATURE.ADD] SlideVideo@{
        if (FeatureConfig.SUPPORT_SLIDE_VIDEO_PLAY) {
            intent.putExtra(TrimVideo.KEY_COME_FROM_GALLERY, true);
        }
        /// @}
        mActivity.startActivityForResult(intent, REQUEST_TRIM);
        return true;
    }
    case R.id.action_mute: {
        /// M: [BUG.ADD] disable muting video when file not exists or sdcard is full. @{
        File srcFile = new File(current.getFilePath());
        if (!srcFile.exists()) {
            Log.i(TAG, "<onItemSelected> abort muting video when not exists!");
            return true;
        }
        if (!isSpaceEnough(srcFile)) {
            Log.i(TAG, "<onItemSelected> abort muting video when no enough space!");
            Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT)
                    .show();
            return true;
        }
        /// @}
        mMuteVideo = new MuteVideo(current.getFilePath(), manager.getContentUri(path), mActivity);
        mMuteVideo.muteInBackground();
        /// M: [FEATURE.ADD] SlideVideo@{
        mMuteVideo.setMuteDoneListener(new MuteDoneListener() {
            public void onMuteDone(Uri uri) {
                redirectCurrentMedia(uri, false);
            }
        });
        /// @}
        return true;
    }
    case R.id.action_edit: {
        /// M: [BUG.ADD] disable editing photo when file not exists or sdcard is full. @{
        File srcFile = new File(current.getFilePath());
        if (!srcFile.exists()) {
            Log.i(TAG, "<onItemSelected> abort editing photo when not exists!");
            return true;
        }
        if (!isSpaceEnough(srcFile)) {
            Log.i(TAG, "<onItemSelected> abort editing photo when no enough space!");
            Toast.makeText(mActivity, mActivity.getString(R.string.storage_not_enough), Toast.LENGTH_SHORT)
                    .show();
            return true;
        }
        /// @}
        launchPhotoEditor();
        return true;
    }
    /// M: [FEATURE.ADD] @{
    case R.id.m_action_picture_quality: {
        Activity activity = (Activity) mActivity;
        Intent intent = new Intent(PictureQualityActivity.ACTION_PQ);
        intent.setClass(activity, PictureQualityActivity.class);
        intent.setData(manager.getContentUri(path));
        Bundle pqBundle = new Bundle();
        pqBundle.putString("PQUri", manager.getContentUri(path).toString());
        pqBundle.putString("PQMineType", current.getMimeType());
        pqBundle.putInt("PQViewWidth", mPhotoView.getWidth());
        pqBundle.putInt("PQViewHeight", mPhotoView.getHeight());
        intent.putExtras(pqBundle);
        Log.i(TAG, "<onItemSelected>startActivity PQ");
        activity.startActivityForResult(intent, REQUEST_PQ);
        return true;
    }
    case R.id.m_action_image_dc: {
        ImageDC.resetStatus((Context) mActivity);
        ImageDC.setMenuItemTile(item);
        path.clearObject();
        mActivity.getDataManager().forceRefreshAll();
        Log.d(TAG, "< onStateResult > forceRefreshAll~~");
        return true;
    }
    /// @}
    case R.id.action_simple_edit: {
        launchSimpleEditor();
        return true;
    }
    case R.id.action_details: {
        if (mShowDetails) {
            hideDetails();
        } else {
            showDetails();
        }
        return true;
    }
    case R.id.print: {
        mActivity.printSelectedImage(manager.getContentUri(path));
        return true;
    }
    case R.id.action_delete:
        confirmMsg = mActivity.getResources().getQuantityString(R.plurals.delete_selection, 1);
    case R.id.action_setas:
    case R.id.action_rotate_ccw:
    case R.id.action_rotate_cw:
    case R.id.action_show_on_map:
        mSelectionManager.deSelectAll();
        mSelectionManager.toggle(path);
        mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
        return true;
    /// M: [FEATURE.ADD] DRM & HotKnot @{
    case R.id.m_action_protect_info:
        Log.d(TAG, "<onItemSelected> ProtectionInfo: do action_protection_info");
        DrmHelper.showProtectionInfoDialog((Activity) mActivity, manager.getContentUri(path));
        return true;
    case R.id.action_hotknot:
        Log.d(TAG, "<onItemSelected> HotKnot: do action_hotknot");
        // for continuous shot, may share a group image, so getContentUris()
        Uri[] uris = null;
        ExtItem extItem = mCurrentPhoto.getExtItem();
        if (extItem != null) {
            uris = extItem.getContentUris();
        }
        if (uris != null) {
            mActivity.getHotKnot().sendZip(uris);
        } else {
            extHotKnot();
        }
        return true;
    /// @}
    /// M: [FEATURE.ADD] entry to export as video @{
    case R.id.action_export:
        mAnimatedContentSharer.exportCurrentPhoto();
        return true;
    /// @}
    /// M: [FEATURE.ADD] Support BlueTooth print feature.@{
    case R.id.action_print:
        mSelectionManager.deSelectAll();
        mSelectionManager.toggle(path);
        mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
        return true;
    /// @}
    default:
        /// M: [FEATURE.ADD] menu extension @{
        // return false;
        return mPhotoView.onOptionsItemSelected(item);
    /// @}
    }
}

From source file:com.android.gallery3d.app.PhotoPage.java

private void launchPhotoEditor() {
    /// M: [BUG.ADD] abort editing photo if loading fail @{
    if (mModel != null && mModel.getLoadingState(0) == PhotoView.Model.LOADING_FAIL) {
        Log.i(TAG, "<launchPhotoEditor> abort editing photo if loading fail!");
        Toast.makeText(mActivity, mActivity.getString(R.string.cannot_load_image), Toast.LENGTH_SHORT).show();
        return;/*from  w  w  w.  j a  va2s  .c om*/
    }
    /// @}
    MediaItem current = mModel.getMediaItem(0);
    if (current == null || (current.getSupportedOperations() & MediaObject.SUPPORT_EDIT) == 0) {
        return;
    }

    Intent intent = new Intent(ACTION_NEXTGEN_EDIT);

    /// M: [BUG.MODIFY] create new task when launch photo editor from camera
    // gallery and photo editor use same task stack @{
    /*
    intent.setDataAndType(current.getContentUri(), current.getMimeType())
          .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    */
    intent.setDataAndType(current.getContentUri(), current.getMimeType())
            .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_TOP
                    | Intent.FLAG_ACTIVITY_NEW_TASK);
    /// @}
    if (mActivity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
            .size() == 0) {
        intent.setAction(Intent.ACTION_EDIT);
    }
    intent.putExtra(FilterShowActivity.LAUNCH_FULLSCREEN, mActivity.isFullscreen());
    /// M: [FEATURE.ADD] @{
    // for special image, no need to delete origin image when save, such as continuous shot
    ExtItem extItem = current.getExtItem();
    if (extItem != null && !extItem.isDeleteOriginFileAfterEdit()) {
        // if current photo is last image in continuous shot group, not
        // set NEED_SAVE_AS as true
        if (mModel instanceof PhotoDataAdapter) {
            int size = ((PhotoDataAdapter) mModel).getTotalCount();
            MediaData md = current.getMediaData();
            if (size == 1 && md.mediaType == MediaData.MediaType.NORMAL
                    && md.subType == MediaData.SubType.CONSHOT) {
                intent.putExtra(FilterShowActivity.NEED_SAVE_AS, false);
                Log.i(TAG, "<launchPhotoEditor> edit the last image in continuous shot group,"
                        + " not set NEED_SAVE_AS as true");
            } else {
                intent.putExtra(FilterShowActivity.NEED_SAVE_AS, true);
            }
        } else {
            intent.putExtra(FilterShowActivity.NEED_SAVE_AS, true);
        }
    }
    /// @}

    /// M: [BUG.MODIFY] @{
    // Make ChooserActivity and GalleryActivity in different tasks.
    /*
     * ((Activity)mActivity).startActivityForResult(Intent.createChooser(intent
     * , null), REQUEST_EDIT);
     */
    ((Activity) mActivity).startActivityForResult(
            Intent.createChooser(intent, null).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), REQUEST_EDIT);
    /// @}

    overrideTransitionToEditor();
}

From source file:cm.aptoide.pt.MainActivity.java

private void doUpdateSelf() {
    Intent intent = new Intent();
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + TMP_UPDATE_FILE), "application/vnd.android.package-archive");
    startActivityForResult(intent, 99);/*from w w  w. j  a va  2  s .  c om*/
}

From source file:com.android.mms.ui.MessageUtils.java

public static void viewSimpleSlideshow(Context context, SlideshowModel slideshow) {
    if (!slideshow.isSimple()) {
        throw new IllegalArgumentException("viewSimpleSlideshow() called on a non-simple slideshow");
    }/*from w ww  . j a  v  a2 s .c  om*/
    SlideModel slide = slideshow.get(0);
    MediaModel mm = null;
    if (slide.hasImage()) {
        mm = slide.getImage();
    } else if (slide.hasVideo()) {
        mm = slide.getVideo();
    } else if (slide.hasAudio()) {
        mm = slide.getAudio();
    }

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.putExtra("SingleItemOnly", true); // So we don't see "surrounding" images in Gallery
    /// M: CanShare: false, Hide the videopalye's share option menu.
    /// M: CanShare: ture, Show the share option menu.
    /// M: Code analyze 010, For fix bug ALPS00244046, The "JE" pops up
    // after you tap the "messaging" icon. @{
    intent.putExtra("CanShare", false);
    /// @}
    /// M: for showing notification when view mms with video player in full screen model @{
    intent.putExtra(EXTRA_FULLSCREEN_NOTIFICATION, true);
    /// @}

    String contentType = "";
    if (mm != null) {
        contentType = mm.getContentType();
        MmsLog.e(TAG, "viewSimpleSildeshow. Uri:" + mm.getUri());
        MmsLog.e(TAG, "viewSimpleSildeshow. contentType:" + contentType);
        intent.setDataAndType(getPreviewFileUri(context, mm), contentType);
    }
    /// M: Code analyze 013, For fix bug ALPS00250939, Exception/Java(JE)-->com.android.mms.
    try {
        // M: change feature ALPS01751464
        if (mm != null && mm.hasDrmContent()) {
            DrmUtilsEx.showDrmAlertDialog(context);
            return;
        }

        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Message msg = Message.obtain(MmsApp.getToastHandler());
        msg.what = MmsApp.MSG_MMS_CAN_NOT_OPEN;
        msg.obj = contentType;
        msg.sendToTarget();
        /// M: after user click view, and the error toast is shown,
        /// we must make it can press again. tricky code
        if (context instanceof ComposeMessageActivity) {
            ((ComposeMessageActivity) context).mClickCanResponse = true;
        }
    }
    /// @}
}

From source file:cl.gisred.android.InspActivity.java

private void cerrarFormCrear(boolean bSave, View v, int idR) {
    if (bSave) {//from w  w w.j  a  v  a2 s .  c o m
        if (!validarForm(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {

            Resources res = getResources();
            InputStream in_s = res.openRawResource(R.raw.index);
            try {
                View vAction = getLayoutValidate(v);
                byte[] b = new byte[in_s.available()];
                in_s.read(b);
                String sHtml = new String(b);
                HtmlUtils oHtml = new HtmlUtils(getApplicationContext(), sHtml);

                String sValueNumMed = "null";

                for (View view : vAction.getTouchables()) {

                    if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
                        EditText oText = (EditText) view;
                        if (!oText.getText().toString().trim().isEmpty()) {
                            String sMapvalue = HtmlUtils.getMapvalue(oText.getId());
                            String sValorChr = oText.getText().toString();
                            oHtml.setValueById(sMapvalue, "txt", sValorChr);
                            if (oText.getId() == R.id.txtOT) {
                                sValueNumMed = sValorChr;
                            }

                            if (sMapvalue != null && sMapvalue.contains("txt_trabajo_cant")) {
                                try {
                                    double dValue = Double.valueOf(sValorChr);
                                    oHtml.sumHH += dValue;
                                } catch (Exception ex) {
                                    Log.e("Double Convert", "error: " + ex.getMessage());
                                }
                            }
                        }
                    } else if (view.getClass().getGenericSuperclass().equals(CheckBox.class)) {
                        CheckBox oCheck = (CheckBox) view;
                        String sCheck = HtmlUtils.getMapvalue(oCheck.getId());
                        sCheck += oCheck.isChecked() ? "si" : "no";
                        oHtml.setValueById(sCheck, "chk", "");
                    } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
                        Spinner oSpinner = (Spinner) view;
                        oHtml.setValueById(HtmlUtils.getMapvalue(oSpinner.getId()), "txt",
                                oSpinner.getSelectedItem().toString());
                    } else if (view.getClass().getGenericSuperclass().equals(RadioButton.class)) {
                        RadioButton oRadioButton = (RadioButton) view;
                        if (oRadioButton.isChecked()) {
                            String sRadio = HtmlUtils
                                    .getMapvalue(((RadioGroup) oRadioButton.getParent()).getId());
                            sRadio += oRadioButton.getText().toString().toLowerCase().replace(" ", "");
                            oHtml.setValueById(sRadio, "rad", "");
                        }
                    } else if (view.getClass().getGenericSuperclass().equals(ImageView.class)) {
                    }
                }

                //SUMA TOTAL HH
                oHtml.setValueById("txt_trabajo_cant_tot", "txt", "" + oHtml.sumHH);

                //VALIDAR FIRMAS
                if (valImage(vAction, R.id.imgFirmaIns))
                    oHtml.setValueById("firm_prop", "img", String.format("%s.jpg", R.id.imgFirmaIns));
                if (valImage(vAction, R.id.imgFirmaTec))
                    oHtml.setValueById("firm_tecn", "img", String.format("%s.jpg", R.id.imgFirmaTec));

                if (valImage(vAction, R.id.imgPhoto1))
                    oHtml.setValueById("foto_1", "img", "foto1.jpg");
                if (valImage(vAction, R.id.imgPhoto2))
                    oHtml.setValueById("foto_2", "img", "foto2.jpg");
                if (valImage(vAction, R.id.imgPhoto3))
                    oHtml.setValueById("foto_3", "img", "foto3.jpg");

                oHtml.setTitleHtml(sValueNumMed);

                String sHtmlFinal = oHtml.getHtmlFinal();

                //guardar en disco
                oHtml.createHtml(sHtmlFinal);

                //VIA CustomTabs
                /*String url = oHtml.getPathHtml();
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
                CustomTabsIntent customTabsIntent = builder.build();
                customTabsIntent.launchUrl(this, Uri.parse(url));*/

                //VIA CHROME scheme
                if (Util.isPackageExisted("com.android.chrome", this)) {
                    String url = oHtml.getPathHtml();

                    File f = new File(url);

                    MimeTypeMap mime = MimeTypeMap.getSingleton();
                    String ext = f.getName().substring(f.getName().lastIndexOf(".") + 1);
                    String type = mime.getMimeTypeFromExtension(ext);

                    Uri uri = Uri.parse("googlechrome://navigate?url=" + url);

                    Intent in = new Intent(Intent.ACTION_VIEW);
                    //in.setDataAndType(uri, "text/html");

                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    in.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

                    //Uri uriExternal = FileProvider.getUriForFile(getApplicationContext(), "cl.gisred.android", f);

                    in.setDataAndType(uri, type);

                    //startActivity(in);
                    startActivity(Intent.createChooser(in, "Escoja Chrome"));
                } else {
                    Toast.makeText(this, "Debe instalar Chrome, solo preview disponible", Toast.LENGTH_LONG)
                            .show();
                    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(oHtml.getPathHtml()));
                    startActivity(myIntent);
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    menuMultipleActions.setVisibility(View.VISIBLE);
    menuInspeccionActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();
}