Example usage for android.widget EditText getText

List of usage examples for android.widget EditText getText

Introduction

In this page you can find the example usage for android.widget EditText getText.

Prototype

@Override
    public Editable getText() 

Source Link

Usage

From source file:com.edible.ocr.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    checkFirstLaunch();//from  ww w.j  a va  2  s . c om

    if (isFirstLaunch) {
        setDefaultPreferences();
    }
    currentContext = this;
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.capture);
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    cameraButtonView = findViewById(R.id.camera_button_view);
    resultView = findViewById(R.id.result_view);

    statusViewBottom = (TextView) findViewById(R.id.status_view_bottom);
    registerForContextMenu(statusViewBottom);
    statusViewTop = (TextView) findViewById(R.id.status_view_top);
    registerForContextMenu(statusViewTop);
    handler = null;
    lastResult = null;
    hasSurface = false;
    beepManager = new BeepManager(this);

    // Camera shutter button
    if (DISPLAY_SHUTTER_BUTTON) {
        shutterButton = (ShutterButton) findViewById(R.id.shutter_button);
        shutterButton.setOnShutterButtonListener(this);

    }
    settingButton = (Button) findViewById(R.id.setting_button);
    settingButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(currentContext, PreferencesActivity.class);
            startActivity(intent);
        }
    });

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

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(currentContext, HelpActivity.class);
            intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, HelpActivity.ABOUT_PAGE);
            startActivity(intent);
        }
    });
    final EditText editText = (EditText) findViewById(R.id.typed_result);
    editText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // add capture button function 
                Intent openDetail = new Intent(currentContext, DetailInfo.class);
                String req = editText.getText().toString();
                //             openDetail.putExtra("request", "Filet Steak");
                openDetail.putExtra("request", req);
                editText.setText("");
                startActivity(openDetail);
                handled = true;
            }
            return handled;
        }
    });
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    //DB_textview = (TextView)findViewById(R.id.DB_text_view);
    //new HttpAsyncTask().execute("https://www.googleapis.com/language/translate/v2?key=" + KEY + "&q=hello%20world&source=en&target=de");
    /* For Client Server Connection */
    getButton = (Button) findViewById(R.id.get_text_button);
    getButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent openDetail = new Intent(currentContext, DetailInfo.class);
            String req = (String) ocrResultView.getText();
            //         openDetail.putExtra("request", "Filet Steak");
            openDetail.putExtra("request", req);
            startActivity(openDetail);

        }

    });
    ocrResultView = (TextView) findViewById(R.id.ocr_result_text_view);
    registerForContextMenu(ocrResultView);
    translationView = (TextView) findViewById(R.id.translation_text_view);
    registerForContextMenu(translationView);

    progressView = (View) findViewById(R.id.indeterminate_progress_indicator_view);

    cameraManager = new CameraManager(getApplication());
    viewfinderView.setCameraManager(cameraManager);

    // Set listener to change the size of the viewfinder rectangle.
    viewfinderView.setOnTouchListener(new View.OnTouchListener() {
        int lastX = -1;
        int lastY = -1;

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                lastX = -1;
                lastY = -1;
                return true;
            case MotionEvent.ACTION_MOVE:
                int currentX = (int) event.getX();
                int currentY = (int) event.getY();

                try {
                    Rect rect = cameraManager.getFramingRect();

                    final int BUFFER = 50;
                    final int BIG_BUFFER = 60;
                    if (lastX >= 0) {
                        // Adjust the size of the viewfinder rectangle. Check if the touch event occurs in the corner areas first, because the regions overlap.
                        if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top left corner: adjust both top and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top right corner: adjust both top and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom left corner: adjust both bottom and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom right corner: adjust both bottom and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BUFFER && currentX <= rect.left + BUFFER)
                                || (lastX >= rect.left - BUFFER && lastX <= rect.left + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting left side: event falls within BUFFER pixels of left side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BUFFER && currentX <= rect.right + BUFFER)
                                || (lastX >= rect.right - BUFFER && lastX <= rect.right + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting right side: event falls within BUFFER pixels of right side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.top + BUFFER && currentY >= rect.top - BUFFER)
                                || (lastY <= rect.top + BUFFER && lastY >= rect.top - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting top side: event falls within BUFFER pixels of top side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.bottom + BUFFER && currentY >= rect.bottom - BUFFER)
                                || (lastY <= rect.bottom + BUFFER && lastY >= rect.bottom - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting bottom side: event falls within BUFFER pixels of bottom side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        }
                    }
                } catch (NullPointerException e) {
                    Log.e(TAG, "Framing rect not available", e);
                }
                v.invalidate();
                lastX = currentX;
                lastY = currentY;
                return true;
            case MotionEvent.ACTION_UP:
                lastX = -1;
                lastY = -1;
                return true;
            }
            return false;
        }
    });

    isEngineReady = false;

}

From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean retval = true;
    switch (item.getItemId()) {
    case R.id.action_create_dir: {
        EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.uploader_info_dirname), "", -1,
                -1, this);
        dialog.show(getSupportFragmentManager(), "createdirdialog");
        break;/*from   w  w w.j av a  2 s .com*/
    }
    case R.id.action_sync_account: {
        startSynchronization();
        break;
    }
    case R.id.action_upload: {
        showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE);
        break;
    }
    case R.id.action_settings: {
        Intent settingsIntent = new Intent(this, Preferences.class);
        startActivity(settingsIntent);
        break;
    }
    case R.id.action_create_file: {
        final String currentDir = getCurrentDir().getRemotePath();
        if (!currentDir.contains("Shared")) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle("Create new file ");
            alert.setMessage("Please enter the name of the file ");

            LayoutInflater factor = LayoutInflater.from(getApplicationContext());
            final View deleteDialogView = factor.inflate(R.layout.enter_filename_dialog, null);
            alert.setView(deleteDialogView);
            final EditText edittext = (EditText) deleteDialogView.findViewById(R.id.filename);

            //Log.d(TAG, getCurrentDir().getRemotePath());
            alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    value = edittext.getText().toString();
                    Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());

                    // Log.d(TAG, "you entre "+str+" "+value);
                    int flag = 0;
                    String[] fspl = value.toString().split("\\.");
                    String taskInput;
                    if (fspl.length == 1) {
                        value = value + ".txt";
                    } else if (!fspl[fspl.length - 1].equals("txt")) {
                        value = value + ".txt";
                    }
                    uri = "file:///sdcard/ownCloud/" + account.name + currentDir + value;
                    final File f2 = new File(Environment.getExternalStorageDirectory(),
                            "ownCloud/" + account.name + currentDir);
                    final File f1 = new File(Environment.getExternalStorageDirectory(),
                            "ownCloud/" + account.name + currentDir + value);
                    try {
                        if (!f2.exists()) {
                            f2.mkdirs();
                        }
                        if (f1.createNewFile()) {
                            Intent intent = new Intent(Intent.ACTION_EDIT);
                            intent.setDataAndType(Uri.parse(uri), "text/plain");
                            startActivity(intent);
                            flag = 1;
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    } finally {
                        if (flag == 1) {
                            taskInput = f1.getAbsolutePath() + "#" + currentDir + value;
                            new displayFileTask(taskInput).execute();
                        }
                    }
                }
            });
            alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });
            alert.show();
        } else {
            Toast.makeText(getApplicationContext(), "You cannot create files here ", Toast.LENGTH_SHORT).show();
        }

        break;
    }
    case R.id.action_friend: {
        Intent friendsIntent = new Intent(this, TabLayoutActivity.class);
        startActivity(friendsIntent);
        break;
    }

    case R.id.action_group: {
        Intent groupIntent = new Intent(this, GroupActivity.class);
        startActivity(groupIntent);
    }
        break;
    case android.R.id.home: {
        FileFragment second = getSecondFragment();
        OCFile currentDir = getCurrentDir();
        if ((currentDir != null && currentDir.getParentId() != 0)
                || (second != null && second.getFile() != null)) {
            onBackPressed();
        }
        break;
    }
    default:
        retval = super.onOptionsItemSelected(item);
    }
    return retval;
}

From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java

/**
 * setup a filter/*  w  ww .  j  a  v  a  2s.co m*/
 */
private void filter() {
    Log.v(TAG, "setting filter");
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(HciDebuggerActivity.this);

    LayoutInflater inflater = getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.filter_dialog, null);
    dialogBuilder.setView(dialogView);

    //packet type
    setupSpinnerAdapter(R.array.packet_type_array, dialogView, R.id.packet_type_filter,
            filters.getPacketTypeFilter());

    //event type
    setupSpinnerAdapter(R.array.event_type_array, dialogView, R.id.event_type_filter,
            filters.getEventTypeFilter());

    //ogf
    setupSpinnerAdapter(R.array.ogf_array, dialogView, R.id.cmd_ogf_filter, filters.getOgfFilter());

    //subevent_type_filter
    setupSpinnerAdapter(R.array.subevent_array, dialogView, R.id.subevent_type_filter,
            filters.getSubeventFilter());

    EditText addressText = (EditText) dialogView.findViewById(R.id.device_address_edit);
    addressText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

            filters.setAddress(s.toString());

            SharedPreferences.Editor editor = prefs.edit();
            editor.putString(Constants.PREFERENCES_ADVERTISING_ADDR, s.toString());
            editor.commit();
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
    addressText.setText(filters.getAdvertizingAddr());

    final AlertDialog alertDialog = dialogBuilder.create();

    final Button button_withdraw_filter = (Button) dialogView.findViewById(R.id.button_withdraw_filter);

    if (isFiltered)
        button_withdraw_filter.setVisibility(View.VISIBLE);
    else
        button_withdraw_filter.setVisibility(View.GONE);

    button_withdraw_filter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            isFiltered = false;
            packetAdapter.setPacketList(packetList);
            notifyAdapter();

            alertDialog.cancel();
            alertDialog.dismiss();
            packetFilteredList.clear();
        }
    });

    Button button_apply = (Button) dialogView.findViewById(R.id.button_apply_filter);

    button_apply.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Spinner packet_type_filter = (Spinner) dialogView.findViewById(R.id.packet_type_filter);
            Spinner ogf_filter = (Spinner) dialogView.findViewById(R.id.cmd_ogf_filter);
            Spinner event_type_filter = (Spinner) dialogView.findViewById(R.id.event_type_filter);
            Spinner subevent_type_filter = (Spinner) dialogView.findViewById(R.id.subevent_type_filter);
            EditText device_address_edit = (EditText) dialogView.findViewById(R.id.device_address_edit);

            filters = new Filters(HciDebuggerActivity.this, packet_type_filter.getSelectedItem().toString(),
                    event_type_filter.getSelectedItem().toString(), ogf_filter.getSelectedItem().toString(),
                    subevent_type_filter.getSelectedItem().toString(),
                    device_address_edit.getText().toString());

            packetFilteredList = new ArrayList<Packet>();
            for (int i = 0; i < packetList.size(); i++) {

                if (matchFilter(packetList.get(i))) {
                    packetFilteredList.add(packetList.get(i));
                }
            }

            isFiltered = true;

            packetAdapter.setPacketList(packetFilteredList);
            notifyAdapter();

            alertDialog.cancel();
            alertDialog.dismiss();
        }
    });

    Button button_cancel = (Button) dialogView.findViewById(R.id.button_cancel_filter);

    button_cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.cancel();
            alertDialog.dismiss();
        }
    });

    alertDialog.show();
}

From source file:net.phase.wallet.Currency.java

protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder;/*ww w .  j  a  v  a2 s  .co m*/
    AlertDialog alertDialog;
    builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = null;
    final WalletActivity parentActivity = this;

    switch (id) {
    case DIALOG_URL:
        layout = inflater.inflate(R.layout.urlfetch_dialog, null);

        TextView tv = (TextView) layout.findViewById(R.id.pasteBinHelpText);
        tv.setMovementMethod(LinkMovementMethod.getInstance());

        final EditText hashEditText = (EditText) layout.findViewById(R.id.hashEditText);
        final EditText nameEditText = (EditText) layout.findViewById(R.id.nameEditText);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                String hash = hashEditText.getText().toString();
                String name = nameEditText.getText().toString();

                if (!hash.startsWith("http")) {
                    hash = "http://pastebin.com/raw.php?i=" + hash;
                }

                try {
                    Wallet w = new Wallet(name, new URI(hash), parentActivity);
                    addWallet(w);
                } catch (Exception e) {
                    toastMessage(e.getMessage());
                }
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        break;
    case DIALOG_FILE:
        layout = inflater.inflate(R.layout.file_dialog, null);

        TextView tvhelp = (TextView) layout.findViewById(R.id.helpText);
        tvhelp.setMovementMethod(LinkMovementMethod.getInstance());

        final Spinner fileSpinner = (Spinner) layout.findViewById(R.id.fileInput);
        final EditText nameEditText2 = (EditText) layout.findViewById(R.id.nameEditText);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                File filename = (File) fileSpinner.getSelectedItem();
                String name = nameEditText2.getText().toString();
                boolean alreadyexists = false;

                if (name.length() > 0) {
                    if (wallets != null && wallets.length > 0) {
                        for (Wallet w : wallets) {
                            if (w.name.equals(name)) {
                                alreadyexists = true;
                            }
                        }
                    }

                    if (!alreadyexists) {
                        try {
                            Wallet w = new Wallet(name, filename, parentActivity);
                            addWallet(w);
                        } catch (Exception e) {
                            toastMessage(e.getMessage());
                        }
                    } else {
                        toastMessage("Wallet already exists");
                    }
                } else {
                    toastMessage("Invalid Name");
                }
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            }
        });
        break;
    case DIALOG_PASTE:
        layout = inflater.inflate(R.layout.paste_dialog, null);

        final EditText keysText = (EditText) layout.findViewById(R.id.keysText);
        final EditText nameEditText3 = (EditText) layout.findViewById(R.id.walletNameText);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                String keys = keysText.getText().toString();
                String name = nameEditText3.getText().toString();
                boolean alreadyexists = false;

                if (name.length() > 0) {
                    if (wallets != null && wallets.length > 0) {
                        for (Wallet w : wallets) {
                            if (w.name.equals(name)) {
                                alreadyexists = true;
                            }
                        }
                    }

                    if (!alreadyexists) {
                        try {
                            Wallet w = new Wallet(name, keys, parentActivity);
                            addWallet(w);
                        } catch (Exception e) {
                            toastMessage(e.getMessage());
                        }
                    } else {
                        toastMessage("Wallet already exists");
                    }
                } else {
                    toastMessage("Invalid Name");
                }
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            }
        });
        break;
    case DIALOG_OPTIONS:
        layout = inflater.inflate(R.layout.options_dialog, null);

        final Spinner currencySpinner = (Spinner) layout.findViewById(R.id.currencySpinner);
        final EditText reqText = (EditText) layout.findViewById(R.id.reqText);
        final Spinner decpointSpinner = (Spinner) layout.findViewById(R.id.decpointSpinner);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                String currency = (String) currencySpinner.getSelectedItem();
                decimalpoints = ((Integer) decpointSpinner.getSelectedItem()).intValue();
                setActiveCurrency(currency);
                try {
                    maxlength = Integer.parseInt(reqText.getText().toString());
                } catch (RuntimeException e) {
                    toastMessage("Invalid number");
                }
                savePreferences();
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        break;

    }

    alertDialog = builder.create();

    return alertDialog;
}

From source file:com.aware.ui.ESM_UI.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    //      getActivity().getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE);
    //      getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    //        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    //        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    builder = new AlertDialog.Builder(getActivity());
    inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);

    TAG = Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0
            ? Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG)
            : TAG;/*from   w  ww. j  a v  a  2s .c  o  m*/

    Cursor visible_esm = getActivity().getContentResolver().query(ESM_Data.CONTENT_URI, null,
            ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1");
    if (visible_esm != null && visible_esm.moveToFirst()) {
        esm_id = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data._ID));

        //Fixed: set the esm as not new anymore, to avoid displaying the same ESM twice due to changes in orientation
        ContentValues update_state = new ContentValues();
        update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE);
        getActivity().getContentResolver().update(ESM_Data.CONTENT_URI, update_state,
                ESM_Data._ID + "=" + esm_id, null);

        esm_type = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.TYPE));
        expires_seconds = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.EXPIRATION_THREASHOLD));

        builder.setTitle(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.TITLE)));

        View ui = null;
        switch (esm_type) {
        case ESM.TYPE_ESM_TEXT:
            ui = inflater.inflate(R.layout.esm_text, null);
            break;
        case ESM.TYPE_ESM_RADIO:
            ui = inflater.inflate(R.layout.esm_radio, null);
            break;
        case ESM.TYPE_ESM_CHECKBOX:
            ui = inflater.inflate(R.layout.esm_checkbox, null);
            break;
        case ESM.TYPE_ESM_LIKERT:
            ui = inflater.inflate(R.layout.esm_likert, null);
            break;
        case ESM.TYPE_ESM_QUICK_ANSWERS:
            ui = inflater.inflate(R.layout.esm_quick, null);
            break;
        }

        final View layout = ui;
        builder.setView(layout);
        current_dialog = builder.create();
        sContext = current_dialog.getContext();

        TextView esm_instructions = (TextView) layout.findViewById(R.id.esm_instructions);
        esm_instructions.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.INSTRUCTIONS)));

        switch (esm_type) {
        case ESM.TYPE_ESM_TEXT:
            final EditText feedback = (EditText) layout.findViewById(R.id.esm_feedback);
            Button cancel_text = (Button) layout.findViewById(R.id.esm_cancel);
            cancel_text.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0);
                    current_dialog.cancel();
                }
            });
            Button submit_text = (Button) layout.findViewById(R.id.esm_submit);
            submit_text.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
            submit_text.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0);

                    if (expires_seconds > 0 && expire_monitor != null)
                        expire_monitor.cancel(true);

                    ContentValues rowData = new ContentValues();
                    rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
                    rowData.put(ESM_Data.ANSWER, feedback.getText().toString());
                    rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                    sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                            ESM_Data._ID + "=" + esm_id, null);

                    Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                    getActivity().sendBroadcast(answer);

                    if (Aware.DEBUG)
                        Log.d(TAG, "Answer:" + rowData.toString());

                    current_dialog.dismiss();
                }
            });
            break;
        case ESM.TYPE_ESM_RADIO:
            try {
                final RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio);
                final JSONArray radios = new JSONArray(
                        visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.RADIOS)));

                for (int i = 0; i < radios.length(); i++) {
                    final RadioButton radioOption = new RadioButton(getActivity());
                    radioOption.setId(i);
                    radioOption.setText(radios.getString(i));
                    radioOptions.addView(radioOption);

                    if (radios.getString(i).equals("Other")) {
                        radioOption.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                final Dialog editOther = new Dialog(getActivity());
                                editOther.setTitle("Can you be more specific, please?");
                                editOther.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                                editOther.getWindow().setGravity(Gravity.TOP);
                                editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT,
                                        LayoutParams.WRAP_CONTENT);

                                LinearLayout editor = new LinearLayout(getActivity());
                                editor.setOrientation(LinearLayout.VERTICAL);

                                editOther.setContentView(editor);
                                editOther.show();

                                final EditText otherText = new EditText(getActivity());
                                editor.addView(otherText);

                                Button confirm = new Button(getActivity());
                                confirm.setText("OK");
                                confirm.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        if (otherText.length() > 0)
                                            radioOption.setText(otherText.getText());
                                        inputManager.hideSoftInputFromWindow(otherText.getWindowToken(), 0);
                                        editOther.dismiss();
                                    }
                                });
                                editor.addView(confirm);
                            }
                        });
                    }
                }
                Button cancel_radio = (Button) layout.findViewById(R.id.esm_cancel);
                cancel_radio.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        current_dialog.cancel();
                    }
                });
                Button submit_radio = (Button) layout.findViewById(R.id.esm_submit);
                submit_radio.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
                submit_radio.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        if (expires_seconds > 0 && expire_monitor != null)
                            expire_monitor.cancel(true);

                        ContentValues rowData = new ContentValues();
                        rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());

                        RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio);
                        if (radioOptions.getCheckedRadioButtonId() != -1) {
                            RadioButton selected = (RadioButton) radioOptions
                                    .getChildAt(radioOptions.getCheckedRadioButtonId());
                            rowData.put(ESM_Data.ANSWER, selected.getText().toString());
                        }
                        rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                        sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                                ESM_Data._ID + "=" + esm_id, null);

                        Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                        getActivity().sendBroadcast(answer);

                        if (Aware.DEBUG)
                            Log.d(TAG, "Answer:" + rowData.toString());

                        current_dialog.dismiss();
                    }
                });
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        case ESM.TYPE_ESM_CHECKBOX:
            try {
                final LinearLayout checkboxes = (LinearLayout) layout.findViewById(R.id.esm_checkboxes);
                final JSONArray checks = new JSONArray(
                        visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.CHECKBOXES)));

                for (int i = 0; i < checks.length(); i++) {
                    final CheckBox checked = new CheckBox(getActivity());
                    checked.setText(checks.getString(i));
                    checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                        @Override
                        public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
                            if (isChecked) {
                                if (buttonView.getText().equals("Other")) {
                                    checked.setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            final Dialog editOther = new Dialog(getActivity());
                                            editOther.setTitle("Can you be more specific, please?");
                                            editOther.getWindow()
                                                    .setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                                            editOther.getWindow().setGravity(Gravity.TOP);
                                            editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT,
                                                    LayoutParams.WRAP_CONTENT);

                                            LinearLayout editor = new LinearLayout(getActivity());
                                            editor.setOrientation(LinearLayout.VERTICAL);
                                            editOther.setContentView(editor);
                                            editOther.show();

                                            final EditText otherText = new EditText(getActivity());
                                            editor.addView(otherText);

                                            Button confirm = new Button(getActivity());
                                            confirm.setText("OK");
                                            confirm.setOnClickListener(new View.OnClickListener() {
                                                @Override
                                                public void onClick(View v) {
                                                    if (otherText.length() > 0) {
                                                        inputManager.hideSoftInputFromWindow(
                                                                otherText.getWindowToken(), 0);
                                                        selected_options
                                                                .remove(buttonView.getText().toString());
                                                        checked.setText(otherText.getText());
                                                        selected_options.add(otherText.getText().toString());
                                                    }
                                                    editOther.dismiss();
                                                }
                                            });
                                            editor.addView(confirm);
                                        }
                                    });
                                } else {
                                    selected_options.add(buttonView.getText().toString());
                                }
                            } else {
                                selected_options.remove(buttonView.getText().toString());
                            }
                        }
                    });
                    checkboxes.addView(checked);
                }
                Button cancel_checkbox = (Button) layout.findViewById(R.id.esm_cancel);
                cancel_checkbox.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        current_dialog.cancel();
                    }
                });
                Button submit_checkbox = (Button) layout.findViewById(R.id.esm_submit);
                submit_checkbox.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
                submit_checkbox.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        if (expires_seconds > 0 && expire_monitor != null)
                            expire_monitor.cancel(true);

                        ContentValues rowData = new ContentValues();
                        rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());

                        if (selected_options.size() > 0) {
                            rowData.put(ESM_Data.ANSWER, selected_options.toString());
                        }

                        rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                        sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                                ESM_Data._ID + "=" + esm_id, null);

                        Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                        getActivity().sendBroadcast(answer);

                        if (Aware.DEBUG)
                            Log.d(TAG, "Answer:" + rowData.toString());

                        current_dialog.dismiss();
                    }
                });
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        case ESM.TYPE_ESM_LIKERT:
            final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.esm_likert);
            ratingBar.setMax(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX)));
            ratingBar.setStepSize(
                    (float) visible_esm.getDouble(visible_esm.getColumnIndex(ESM_Data.LIKERT_STEP)));
            ratingBar.setNumStars(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX)));

            TextView min_label = (TextView) layout.findViewById(R.id.esm_min);
            min_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MIN_LABEL)));

            TextView max_label = (TextView) layout.findViewById(R.id.esm_max);
            max_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX_LABEL)));

            Button cancel = (Button) layout.findViewById(R.id.esm_cancel);
            cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    current_dialog.cancel();
                }
            });
            Button submit = (Button) layout.findViewById(R.id.esm_submit);
            submit.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
            submit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (expires_seconds > 0 && expire_monitor != null)
                        expire_monitor.cancel(true);

                    ContentValues rowData = new ContentValues();
                    rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
                    rowData.put(ESM_Data.ANSWER, ratingBar.getRating());
                    rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                    sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                            ESM_Data._ID + "=" + esm_id, null);

                    Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                    getActivity().sendBroadcast(answer);

                    if (Aware.DEBUG)
                        Log.d(TAG, "Answer:" + rowData.toString());

                    current_dialog.dismiss();
                }
            });
            break;
        case ESM.TYPE_ESM_QUICK_ANSWERS:
            try {
                final JSONArray answers = new JSONArray(
                        visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.QUICK_ANSWERS)));
                final LinearLayout answersHolder = (LinearLayout) layout.findViewById(R.id.esm_answers);

                //If we have more than 3 possibilities, better that the UI is vertical for UX
                if (answers.length() > 3) {
                    answersHolder.setOrientation(LinearLayout.VERTICAL);
                }

                for (int i = 0; i < answers.length(); i++) {
                    final Button answer = new Button(getActivity());
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                            LayoutParams.WRAP_CONTENT, 1.0f);
                    answer.setLayoutParams(params);
                    answer.setText(answers.getString(i));
                    answer.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                            if (expires_seconds > 0 && expire_monitor != null)
                                expire_monitor.cancel(true);

                            ContentValues rowData = new ContentValues();
                            rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
                            rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);
                            rowData.put(ESM_Data.ANSWER, (String) answer.getText());

                            sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                                    ESM_Data._ID + "=" + esm_id, null);

                            Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                            getActivity().sendBroadcast(answer);

                            if (Aware.DEBUG)
                                Log.d(TAG, "Answer:" + rowData.toString());

                            current_dialog.dismiss();
                        }
                    });
                    answersHolder.addView(answer);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        }
    }
    if (visible_esm != null && !visible_esm.isClosed())
        visible_esm.close();

    //Start dialog visibility threshold
    if (expires_seconds > 0) {
        expire_monitor = new ESMExpireMonitor(System.currentTimeMillis(), expires_seconds, esm_id);
        expire_monitor.execute();
    }

    //Fixed: doesn't dismiss the dialog if touched outside or ghost touches
    current_dialog.setCanceledOnTouchOutside(false);

    return current_dialog;
}

From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java

private void showMultiRenameDialog(final String multiPath) {
    AlertDialog.Builder builder = new AlertDialog.Builder(SubredditSelectActivity.this);
    final EditText nameInput = new EditText(SubredditSelectActivity.this);
    nameInput.setHint("new multi name");
    builder.setTitle("Rename Multi").setView(nameInput)
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override//from  ww  w  . j ava 2  s  .c om
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            }).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                    new SubscriptionEditTask(SubscriptionEditTask.ACTION_MULTI_RENAME).execute(multiPath,
                            nameInput.getText().toString().replaceAll("\\s+", ""));
                }
            }).show();
}

From source file:eu.operando.operandoapp.OperandoProxyStatus.java

private void CheckPhoneNumber() {
    if (new RequestFilterUtil(MainActivity.this).getPhoneNumber().equals("")) {
        try {//from   w w  w  .  ja  va2  s  .com
            final EditText phoneInput = new EditText(MainActivity.this);
            phoneInput.setInputType(InputType.TYPE_CLASS_NUMBER);
            final File phoneFile = new File(getFilesDir(), "phonenumber.conf");
            if (!phoneFile.exists()) {
                new AlertDialog.Builder(MainActivity.this).setIcon(R.drawable.logo_bevel)
                        .setTitle("Input phone number")
                        .setMessage(
                                "The phone number could not be fetched automatically. Please input it below for automated exfiltration checks.")
                        .setView(phoneInput).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                try {
                                    FileOutputStream stream = null;
                                    try {
                                        stream = new FileOutputStream(phoneFile);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    stream.write(phoneInput.getText().toString().getBytes());
                                    stream.close();
                                    Toast.makeText(getApplicationContext(), "Phone number saved successfully",
                                            Toast.LENGTH_SHORT).show();
                                } catch (Exception e) {
                                    Toast.makeText(getApplicationContext(), "Something went wrong",
                                            Toast.LENGTH_SHORT).show();
                                }
                                //after phone parsing, load download initial settings
                                DownloadInitialSettings();
                            }
                        }).setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //nothing
                            }
                        }).show();
            }
        } catch (Exception e) {
            Log.d("ERROR", e.getMessage());
        }
    }
}

From source file:com.seatgeek.placesautocompletedemo.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    mapActivity = getActivity();//from  w  ww.j a v a 2s  .c o m
    dataProvider = new DataProvider(mapActivity);
    placePickerGoogle(placePickerIntent);

    tinydb = new TinyDB(getContext());

    arrayListBookmark = tinydb.getListString("BOOKMARK");

    recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_cmt);
    scrollView = (NestedScrollView) rootView.findViewById(R.id.scrollView);

    mAdapter = new MessagesAdapter(getContext(), messages, this);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL));
    recyclerView.setAdapter(mAdapter);
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setFocusable(false);

    scrollView.scrollTo(0, 0);

    //        mListView = (LockableRecyclerView) rootView.findViewById(android.R.id.list);
    //        mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER);

    searchLocation = (CardView) rootView.findViewById(R.id.search_bar);
    searchLocation.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
            startActivityForResult(placePickerIntent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
        }
    });

    final LayoutInflater inflatera = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    customView = inflatera.inflate(R.layout.review, null);

    dialogReview = new MaterialStyledDialog.Builder(getActivity()).setHeaderDrawable(R.drawable.header_2)
            .setCustomView(customView, 20, 20, 20, 0).build();

    btn_Rate = (Button) rootView.findViewById(R.id.btn_rate);
    btn_book = (Button) rootView.findViewById(R.id.btn_book);

    btn_Rate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //                if (customView != null) {
            //                    ViewGroup parent = (ViewGroup) customView.getParent();
            //                    if (parent != null) {
            //                        parent.removeView(customView);
            //                    }
            //                }
            //                try {
            //                    customView = inflatera.inflate(R.layout.review,null);
            //                } catch (InflateException e) {
            //
            //                }
            //                dialogHeader_4.getBuilder().setCustomView(customView,20,20,20,0);
            dialogReview.show();

        }
    });

    btn_book.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (arrayListBookmark.contains(currentPos)) {
                btn_book.setBackgroundResource(R.drawable.star_off);
                arrayListBookmark.remove(currentPos);
            } else {
                btn_book.setBackgroundResource(R.drawable.star_on);
                arrayListBookmark.add(currentPos);
            }
            tinydb.putListString("BOOKMARK", arrayListBookmark);
            //                btn_book.setBackgroundResource(R.drawable.star_on);
        }
    });

    rating = (SmileRating) customView.findViewById(R.id.ratingsBar);

    final EditText ed_review = (EditText) customView.findViewById(R.id.reviewED);
    final EditText ed_title = (EditText) customView.findViewById(R.id.titleED);
    Button cancelDialog = (Button) customView.findViewById(R.id.cancelD);
    cancelDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogReview.dismiss();
        }
    });
    Button submitDialog = (Button) customView.findViewById(R.id.submitD);
    submitDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //            Toast.makeText(getActivity().getApplicationContext(),""+rating.getRating(),Toast.LENGTH_SHORT).show();
            sendComment(10, ed_review.getText().toString().trim(), ed_title.getText().toString().trim(),
                    rating.getRating(), new ParkingCar());
        }
    });

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mapActivity);
    latitude = sharedPreferences.getString("LATITUDE", null);
    longitude = sharedPreferences.getString("LONGITUDE", null);
    RADIUS = sharedPreferences.getString("RADIUS", "1000");

    ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager);
    pager.setAdapter(new ImageAdapter(getActivity()));
    pager.setCurrentItem(getArguments().getInt(Constants.Extra.IMAGE_POSITION, 0));
    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            for (int i = 0; i < dotsCount; i++) {
                dots[i].setTextColor(getResources().getColor(android.R.color.black));
            }
            dots[position].setTextColor(Color.GREEN);
        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    setUiPageViewController(rootView);

    mLayout = (SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout);
    mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
    mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
    mLayout.setAnchorPoint(0.68f);
    mLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            Log.i("", "onPanelSlide, offset " + slideOffset);
        }

        @Override
        public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState,
                SlidingUpPanelLayout.PanelState newState) {
            Log.i("", "onPanelStateChanged " + newState);
            if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
                scrollView.scrollTo(0, 0);
            }
        }
    });
    mLayout.setFadeOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
        }
    });

    txt_Adress = (TextView) rootView.findViewById(R.id.name);
    txt_Scale = (TextView) rootView.findViewById(R.id.txt_Scale);
    txt_Add = (TextView) rootView.findViewById(R.id.textView3);
    txt_Type = (TextView) rootView.findViewById(R.id.textView4);
    txt_Rate = (TextView) rootView.findViewById(R.id.textView5);
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "font/UTM Avo.ttf");
    Typeface tf1 = Typeface.createFromAsset(getActivity().getAssets(), "font/UTM Dax.ttf");
    txt_Adress.setTypeface(tf, Typeface.BOLD);
    txt_Scale.setTypeface(tf1, Typeface.BOLD);
    txt_Add.setTypeface(tf1, Typeface.BOLD);
    txt_Type.setTypeface(tf1, Typeface.BOLD);
    txt_Rate.setTypeface(tf1, Typeface.BOLD);

    collapseMap();
    return rootView;
}