Example usage for android.text.method ScrollingMovementMethod ScrollingMovementMethod

List of usage examples for android.text.method ScrollingMovementMethod ScrollingMovementMethod

Introduction

In this page you can find the example usage for android.text.method ScrollingMovementMethod ScrollingMovementMethod.

Prototype

ScrollingMovementMethod

Source Link

Usage

From source file:jupiter.broadcasting.live.holo.JBPlayer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context ct = this;
    String ns = NOTIFICATION_SERVICE;
    mNotificationManager = (NotificationManager) getSystemService(ns);
    nReceiver = new BroadcastReceiver() {
        @Override//from  w w  w.j  av  a2s  . c o  m
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action != null) {
                if (action.equalsIgnoreCase("PLAY_PAUSE")) {
                    if (mp.isPlaying()) {
                        mp.pause();
                        unregisterReceiver(nReceiver);
                        putNotificationUp(mp.isPlaying());
                    } else {
                        mp.start();
                        unregisterReceiver(nReceiver);
                        putNotificationUp(mp.isPlaying());
                    }
                } else if (action.equalsIgnoreCase("STOP")) {
                    unregisterReceiver(nReceiver);
                    mNotificationManager.cancel(NOTIFICATION_ID);
                    mp.stop();
                    start = false;
                }
            }
        }
    };

    //check if network notification is disabled in settings
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    notify = sharedPref.getBoolean("pref_sync_audio", false);

    mVideoCastManager = JBApplication.getVideoCastManager(this);
    mVideoCastManager.reconnectSessionIfPossible(this, true);

    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.mediaplayer);

    type = getIntent().getIntExtra("type", 3);
    title = getIntent().getStringExtra("title");
    pic = "http://jb4.cdn.scaleengine.net/wp-content/themes/jb2014/images/logo.png";
    hasit = HasIt(title, av);
    getSupportActionBar().setTitle(title);
    mDecorView = getWindow().getDecorView();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        mDecorView.setOnSystemUiVisibilityChangeListener(this);

    // going on different routes if coming from Catalogue/Home/EpisodeList
    offline = getIntent().getBooleanExtra("offline", false);
    String help = getIntent().getStringExtra("loc");
    live = ((help != null) && help.equalsIgnoreCase("-1"));
    if (!offline && !hasit) {
        pic = getIntent().getStringExtra("pic");
        aLink = getIntent().getStringExtra("aLink");
        vLink = getIntent().getStringExtra("vLink");
        theLink = aLink;
        GetSize newSize = new GetSize();
        newSize.execute();
    } else if (!live) {
        theLink = getIntent().getStringExtra("loc");
    } else {
        aLink = getIntent().getStringExtra("aLink");
        vLink = getIntent().getStringExtra("vLink");
        theLink = aLink;
    }

    iView = (FadeImageView) findViewById(R.id.thumb);
    RequestQueue mReqQue = Volley.newRequestQueue(getApplicationContext());
    ImageLoader mImageLoader = new ImageLoader(mReqQue, new BitmapLruCache());

    if (!offline) {
        iView.setImageUrl(pic, mImageLoader);
    }
    if (offline && !live) {
        switch (type) {
        case 0:
            SpinnerArray.add(getString(R.string.audio));
            break;
        case 1:
            SpinnerArray.add(getString(R.string.video));
            break;
        }
    } else {
        SpinnerArray.add(getString(R.string.audio));
        SpinnerArray.add(getString(R.string.video));
    }
    spinner = (Spinner) findViewById(R.id.AV);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            SpinnerArray);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    tw = (TextView) findViewById(R.id.summary);
    tw.setMovementMethod(new ScrollingMovementMethod());
    tw.setText(getIntent().getStringExtra("sum"));

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

        public void onClick(View v) {
            ConnectivityManager connectivity = (ConnectivityManager) getSystemService(
                    Context.CONNECTIVITY_SERVICE);
            wifiInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            if ((wifiInfo == null || wifiInfo.getState() != NetworkInfo.State.CONNECTED) && !hasit && notify) {
                AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(ct);
                myAlertDialog.setTitle(R.string.alert);
                myAlertDialog.setMessage(R.string.areyousure2);
                myAlertDialog.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface arg0, int arg1) {
                        if (av == 1) //video
                            StartPlay(theLink);
                        else //audio
                            try {
                                StartPlayBackground(theLink);
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                    }
                });
                myAlertDialog.setNegativeButton(getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface arg0, int arg1) {
                            }
                        });
                myAlertDialog.show();
            } else {
                if (av == 1) //video
                    StartPlay(theLink);
                else //audio
                    try {
                        StartPlayBackground(theLink);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
            }

        }
    });

    down = (Button) findViewById(R.id.downer);
    if (offline || hasit) {
        down.setVisibility(View.INVISIBLE);
    }
    down.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            final String url = theLink;
            //if wifi not connected, ask to make sure
            ConnectivityManager connectivity = (ConnectivityManager) getSystemService(
                    Context.CONNECTIVITY_SERVICE);
            wifiInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            if ((wifiInfo == null || wifiInfo.getState() != NetworkInfo.State.CONNECTED) && notify) {
                AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(ct);
                myAlertDialog.setTitle(R.string.alert);
                myAlertDialog.setMessage(R.string.areyousure2);
                myAlertDialog.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface arg0, int arg1) {
                        DownLoad(url);
                    }
                });
                myAlertDialog.setNegativeButton(getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface arg0, int arg1) {
                            }
                        });
                myAlertDialog.show();
            } else {
                DownLoad(url);
            }

        }
    });
}

From source file:org.torproject.android.Orbot.java

private void doLayout() {
    setContentView(R.layout.layout_main);

    mViewMain = findViewById(R.id.viewMain);
    lblStatus = (TextView) findViewById(R.id.lblStatus);
    lblStatus.setOnLongClickListener(this);
    imgStatus = (ImageProgressView) findViewById(R.id.imgStatus);
    imgStatus.setOnLongClickListener(this);
    imgStatus.setOnTouchListener(this);

    lblStatus.setText("Initializing the application...");

    downloadText = (TextView) findViewById(R.id.trafficDown);
    uploadText = (TextView) findViewById(R.id.trafficUp);
    mTxtOrbotLog = (TextView) findViewById(R.id.orbotLog);

    mDrawer = ((SlidingDrawer) findViewById(R.id.SlidingDrawer));
    Button slideButton = (Button) findViewById(R.id.slideButton);
    if (slideButton != null) {
        slideButton.setOnTouchListener(new OnTouchListener() {

            @Override//  w  ww.  j ava  2  s .  c o  m
            public boolean onTouch(View v, MotionEvent event) {

                if (event.equals(MotionEvent.ACTION_DOWN)) {
                    mDrawerOpen = !mDrawerOpen;
                    mTxtOrbotLog.setEnabled(mDrawerOpen);
                }
                return false;
            }

        });
    }

    ScrollingMovementMethod smm = new ScrollingMovementMethod();

    mTxtOrbotLog.setMovementMethod(smm);
    mTxtOrbotLog.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setText(mTxtOrbotLog.getText());
            Toast.makeText(Orbot.this, "LOG COPIED TO CLIPBOARD", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    downloadText.setText(formatCount(0) + " / " + formatTotal(0));
    uploadText.setText(formatCount(0) + " / " + formatTotal(0));

    // Gesture detection
    mGestureDetector = new GestureDetector(this, new MyGestureDetector());

}

From source file:org.chromium.latency.walt.AccelerometerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    logger = SimpleLogger.getInstance(getContext());
    waltDevice = WaltDevice.getInstance(getContext());

    // Inflate the layout for this fragment
    final View view = inflater.inflate(R.layout.fragment_accelerometer, container, false);
    logTextView = (TextView) view.findViewById(R.id.txt_log);
    startButton = view.findViewById(R.id.button_start);
    latencyChart = (ScatterChart) view.findViewById(R.id.latency_chart);
    latencyChartLayout = view.findViewById(R.id.latency_chart_layout);
    logTextView.setMovementMethod(new ScrollingMovementMethod());
    view.findViewById(R.id.button_close_chart).setOnClickListener(this);
    sensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
    accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (accelerometer == null) {
        logger.log("ERROR! Accelerometer sensor not found");
    }/* w  w  w. j  a  v a  2 s  .c  om*/
    return view;
}

From source file:eu.intermodalics.tango_ros_streamer.RunningActivity.java

private void setupUI() {
    setContentView(R.layout.running_activity);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    getFragmentManager().beginTransaction().replace(R.id.preferencesFrame, new PrefsFragment()).commit();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   www . j  a v a 2 s .c om*/
    mUriTextView = (TextView) findViewById(R.id.master_uri);
    mUriTextView.setText(mMasterUri);
    mRosLightImageView = (ImageView) findViewById(R.id.is_ros_ok_image);
    mTangoLightImageView = (ImageView) findViewById(R.id.is_tango_ok_image);
    mlogSwitch = (Switch) findViewById(R.id.log_switch);
    mlogSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            mDisplayLog = isChecked;
            mLogTextView.setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
        }
    });
    mLogTextView = (TextView) findViewById(R.id.log_view);
    mLogTextView.setMovementMethod(new ScrollingMovementMethod());
}

From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_folder, container, false);
    final AbsListView mListView = (AbsListView) view.findViewById(android.R.id.list);
    mListView.setAdapter(mAdapter);/*from   w w w.  j  a  v a2  s  .  c o  m*/
    mListView.setOnItemClickListener(this);

    ((RadioButton) view.findViewById(android.R.id.button1))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
                    if (isChecked) {
                        setFocus(ItemFocus.Visualization, getView());
                    }
                }
            });

    ((RadioButton) view.findViewById(android.R.id.button2))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
                    if (isChecked) {
                        setFocus(ItemFocus.Json, getView());
                    }
                }
            });

    ((TextView) view.findViewById(R.id.json)).setMovementMethod(new ScrollingMovementMethod());

    refresh();

    return view;
}

From source file:org.kaaproject.kaa.demo.powerplant.fragment.DashboardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_dashboard, container, false);

    androidKaaPlatformContext = new AndroidKaaPlatformContext(getActivity());
    kaaClient = Kaa.newClient(androidKaaPlatformContext);

    endpoint = DataEndpointFactory.createEndpoint(kaaClient.getConfiguration(), getActivity());
    Log.i(TAG, "Default configuration: " + kaaClient.getConfiguration().toString());

    kaaClient.addConfigurationListener(new ConfigurationListener() {
        @Override/*from  w  w  w .  java 2s  .c o  m*/
        public void onConfigurationUpdate(PowerPlantEndpointConfiguration config) {
            endpoint.stop();
            endpoint = DataEndpointFactory.createEndpoint(config, getActivity());
            Log.i(TAG, "Updating configuration: " + config.toString());
        }
    });

    kaaClient.start();

    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart11));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart12));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart13));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart21));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart22));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart23));
    logBox = (TextView) rootView.findViewById(R.id.logBox);
    logBox.setMovementMethod(new ScrollingMovementMethod());

    updateThread = new Thread(new Runnable() {

        @Override
        public void run() {

            Log.i(TAG, "generating history data ");

            final List<DataReport> reports = endpoint.getHistoryData(0);
            if (reports == null) {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(mActivity, "No Data!", Toast.LENGTH_LONG).show();
                        try {
                            Thread.sleep(3000);
                        } catch (InterruptedException e) {
                        }
                        mActivity.finish();
                    }
                });
            } else {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Log.i(TAG, "populating charts with data " + reports.size());
                        prepareLineChart(rootView, reports);
                        Log.i(TAG, "populated line chart with data ");
                        if (!reports.isEmpty()) {
                            preparePieChart(rootView, reports.get(reports.size() - 1));
                        } else {
                            preparePieChart(rootView, INITIAL_REPORT);
                        }
                        Log.i(TAG, "populated pie chart with data ");
                    }
                });

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }

                DataReport previousReport = INITIAL_REPORT;
                long previousUpdate = 0l;
                while (true) {
                    try {
                        Thread.sleep(UPDATE_CHECK_PERIOD);
                        long updateDelta = System.currentTimeMillis() - previousUpdate;
                        if (updateDelta < UPDATE_PERIOD) {
                            continue;
                        } else {
                            Log.i(TAG, "Updating since -" + (updateDelta / 1000.) + " s.");
                        }
                        DataReport latestDataCandidate = endpoint.getLatestData();
                        latestDataCandidate = (latestDataCandidate == null ? previousReport
                                : latestDataCandidate);
                        Log.i(TAG, "Latest data: " + latestDataCandidate.toString());
                        Log.i(TAG, "Previous data: " + previousReport.toString());
                        previousReport = latestDataCandidate;
                        previousUpdate = System.currentTimeMillis();
                    } catch (InterruptedException e) {
                        Log.e(TAG, "Failed to fetch data", e);
                    }

                    final DataReport latestData = previousReport;
                    Log.i(TAG, "latest data: " + latestData.toString());

                    mActivity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            float maxValue = Float.MIN_VALUE;
                            float minValue = Float.MAX_VALUE;

                            PieChartData data = pieChart.getPieChartData();
                            float plantVoltage = 0.0f;

                            int counter = 0;
                            for (DataPoint dp : latestData.getDataPoints()) {
                                float curVoltage = convertVoltage(dp.getVoltage());
                                plantVoltage += curVoltage;
                                SliceValue sliceValue = data.getValues().get(dp.getPanelId());
                                sliceValue.setTarget(curVoltage);
                                gaugeCharts.get(counter).setValue(dp.getAverageVoltage());
                                showLogIfNeeded(counter, curVoltage * 1000);
                                counter++;
                                Log.i(TAG, dp.toString());
                            }

                            float gridVoltage = (latestData.getPowerConsumption() - plantVoltage * 1000) / 1000;
                            pieChart.startDataAnimation(UPDATE_PERIOD / 2);
                            updateLabels(plantVoltage * 1000, gridVoltage);

                            // Actual point update
                            int curPointIndex = line.getValues().size() - FUTURE_POINTS_COUNT;
                            PointValue curPoint = line.getValues().get(curPointIndex);
                            curPoint.set(curPoint.getX(), plantVoltage);
                            for (PointValue point : line.getValues()) {
                                point.setTarget(point.getX() - 1, point.getY());
                                minValue = Math.min(minValue, point.getY());
                                maxValue = Math.max(maxValue, point.getY());
                            }
                            if (line.getValues()
                                    .size() == (POINTS_COUNT + PAST_POINTS_COUNT + FUTURE_POINTS_COUNT)) {
                                line.getValues().remove(0);
                            }
                            // Adding one dot to the end;
                            line.getValues()
                                    .add(new PointValue(POINTS_COUNT + FUTURE_POINTS_COUNT, plantVoltage));

                            lineChart.startDataAnimation(UPDATE_PERIOD / 2);

                            lineChart.getChartRenderer().setMinViewportYValue(MIN_VOLTAGE);
                            lineChart.getChartRenderer().setMaxViewportYValue(
                                    (MAX_VOLTAGE * MAX_PANEL_PER_ZONE * NUM_ZONES) / 1000);
                        }
                    });
                }
            }
        }
    });

    updateThread.start();

    return rootView;
}

From source file:nl.hnogames.domoticz.app.DomoticzFragment.java

private void showDebugLayout() {
    try {/*from  w  ww . j a  v  a 2s  . c o  m*/
        if (root != null) {
            LinearLayout debugLayout = (LinearLayout) root.findViewById(R.id.debugLayout);
            if (debugLayout != null) {
                debugLayout.setVisibility(View.VISIBLE);

                debugText = (TextView) root.findViewById(R.id.debugText);
                if (debugText != null) {
                    debugText.setMovementMethod(new ScrollingMovementMethod());
                    debugText.setOnLongClickListener(new View.OnLongClickListener() {
                        @Override
                        public boolean onLongClick(View view) {
                            mDomoticz.debugTextToClipboard(debugText);
                            return false;
                        }
                    });
                }
            }
        }
    } catch (Exception ex) {
    }
}

From source file:hr.abunicic.angular.CameraActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ApplicationContext.getInstance().init(getApplicationContext());
    setContentView(R.layout.activity_camera);

    //Left drawer
    drawerLayout = (DrawerLayout) findViewById(R.id.camera_activity_drawer_layout);

    //Binding the RecyclerView
    recyclerView = (RecyclerView) findViewById(R.id.r_list);
    recyclerView.setHasFixedSize(true);/*  w w w . ja v a  2 s .c  o  m*/

    //Informative text when database is empty
    infoNothingSaved = (TextView) findViewById(R.id.infoNothing);

    //Getting all saved shaped from the database and populating the RecyclerView
    db = new DatabaseHandler(CameraActivity.this);
    historyItems = (ArrayList) db.getAllShapes();
    setHistoryItems();

    //Card at the bottom
    cardBottom = (CardView) findViewById(R.id.cardBottom);
    cardBottom.bringToFront();
    //Elements inside the CardView
    tvShape = (TextView) findViewById(R.id.tvGeomLik);
    tvCardTitle = (TextView) findViewById(R.id.titleText);
    tvShape.setMovementMethod(new ScrollingMovementMethod());
    final ImageButton imgSave = (ImageButton) findViewById(R.id.imgSave);

    //Getting instance of the sensor service
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);

    //Initializing the camera and setting up screen size
    initCamera();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    screenHeight = displayMetrics.heightPixels;
    screenWidth = displayMetrics.widthPixels;

    //Flash button
    final ImageButton imgFlash = (ImageButton) findViewById(R.id.imgFlash);
    if (this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
        imgFlash.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (params.getFlashMode().equals(Camera.Parameters.FLASH_MODE_TORCH)) {
                    params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        imgFlash.setBackground(getResources().getDrawable(R.drawable.ic_flash_on_white_36dp));
                    }
                } else {
                    params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        imgFlash.setBackground(getResources().getDrawable(R.drawable.ic_flash_off_white_36dp));
                    }
                }
                mCamera.setParameters(params);
            }
        });
    } else {
        imgFlash.setVisibility(View.GONE);
    }

    //Delete all button in the drawer view
    ImageButton imgDeleteAll = (ImageButton) findViewById(R.id.imgDeleteAll);
    imgDeleteAll.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            db.deleteAllShapes();
            historyItems.clear();

            setHistoryItems();
        }
    });

    //Menu icon for opening the drawer
    ImageButton imgMenu = (ImageButton) findViewById(R.id.imgMenu);
    imgMenu.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            drawerLayout.openDrawer(Gravity.LEFT);
        }
    });

    //Fab button functionality
    fabCapture = (FloatingActionButton) findViewById(R.id.fab);
    fabCapture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startDetection();
            fabCapture.setClickable(false);
            FabTransformation.with(fabCapture).transformTo(cardBottom);

            imgSave.setVisibility(View.VISIBLE);

            imgSave.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Animation animation = AnimationUtils.loadAnimation(CameraActivity.this, R.anim.anim);
                    mCameraView.startAnimation(animation);

                    Toast toast = Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.toast_saved), Toast.LENGTH_LONG); //Dodati u strings i u engl verziju
                    toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                    toast.show();

                    ShapeInDatabase shapeToAdd = new ShapeInDatabase(mCameraView.getBitmap(),
                            tvCardTitle.getText().toString(), tvShape.getText().toString());
                    db.addShape(shapeToAdd);
                    historyItems.add(0, shapeToAdd);

                    setHistoryItems();

                }
            });

            if (rp != null) {
                Shape shape = ShapeHeuristic.getShape(rp);
                if (shape != null) {
                    tvCardTitle.setText(shape.getName());
                    tvShape.setText(shape.toString());
                    if (shape instanceof DefaultPolygon && ((DefaultPolygon) shape).getN() == 5) {
                        tvCardTitle.setText("Pravilni peterokut");
                        tvShape.setText(
                                "Sve stranice pravilnog peterokuta su jednake duljine. \n     a = 5 cm \n     P = 43.01 \n     O = 25");
                    }
                }
            }

        }
    });

    //Button inside the card for going back
    Button buttonBack = (Button) findViewById(R.id.buttonBack);
    buttonBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startDetection();

            FabTransformation.with(fabCapture).transformFrom(cardBottom);
            fabCapture.setClickable(true);

            imgSave.setVisibility(View.INVISIBLE);
        }
    });

    //Button inside the card for opening the ResultActivity with more info about the shape
    Button buttonMore = (Button) findViewById(R.id.buttonMore);
    buttonMore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Shape shape = ShapeHeuristic.getShape(rp);
            if (shape instanceof DefaultPolygon && ((DefaultPolygon) shape).getN() == 5) {
                Intent intentPeterokut = new Intent(CameraActivity.this, PeterokutActivity.class);
                startActivity(intentPeterokut);
            } else {
                Intent intent = new Intent(CameraActivity.this, ResultActivity.class);
                intent.putExtra("RESULT_TITLE", tvCardTitle.getText().toString());
                intent.putExtra("RESULT_INFO", tvShape.getText().toString());

                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                mCameraView.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, bos);
                byte[] byteArray = bos.toByteArray();

                intent.putExtra("RESULT_IMAGE", byteArray);
                startActivity(intent);
            }

        }
    });

    //Corners View
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    cornersView = (CornersView) findViewById(R.id.cornersView);
    shadow = (FrameLayout) findViewById(R.id.shadowLayout);
    cornersView.setShadow(shadow);

    //Starting the detection process
    startDetection();

    //Microblink OCR
    try {
        mRecognizer = Recognizer.getSingletonInstance();
    } catch (FeatureNotSupportedException e) {
        Toast.makeText(CameraActivity.this, "Feature not supported! Reason: " + e.getReason().getDescription(),
                Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    try {
        // set license key
        mRecognizer.setLicenseKey(CameraActivity.this,
                "Y5352CQ5-A7KVPD26-UOAUEX4P-D2GQM63S-J6TCRGNH-T5WFKI24-QQZJRAXL-AT55KX4N");
    } catch (InvalidLicenceKeyException exc) {
        finish();
        return;
    }
    RecognitionSettings settings = new RecognitionSettings();
    // setupSettingsArray method is described in chapter "Recognition settings and results")
    settings.setRecognizerSettingsArray(setupSettingsArray());
    mRecognizer.initialize(CameraActivity.this, settings, new DirectApiErrorListener() {
        @Override
        public void onRecognizerError(Throwable t) {
            Toast.makeText(CameraActivity.this,
                    "There was an error in initialization of Recognizer: " + t.getMessage(), Toast.LENGTH_SHORT)
                    .show();
            finish();
        }
    });

}

From source file:com.greatspeeches.slides.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.description_layout, container, false);

    final android.support.v4.app.FragmentManager fragmentManager = myContext.getSupportFragmentManager();
    fragmentManager.addOnBackStackChangedListener(new OnBackStackChangedListener() {
        @Override/*w  ww .j  a  v a 2s  .  com*/
        public void onBackStackChanged() {
            if (fragmentManager.getBackStackEntryCount() == 0) {
                closeYVplayer();
            }
        }
    });

    scroll = (StickyScrollView) rootView.findViewById(R.id.topScroll);
    scroll.setTouchListener(touchHandler);
    fragmentsLayout = (FrameLayout) rootView.findViewById(R.id.video_container);
    // Set the title view to show the page number.
    infoData = ((TextView) rootView.findViewById(R.id.person_info));
    infoData.setMaxLines(Integer.MAX_VALUE);
    infoData.setMovementMethod(new ScrollingMovementMethod());
    infoData.setText("\t\t\t" + mPersonObj.getInfo());
    personImg = (ImageView) rootView.findViewById(R.id.person_image);
    personImg.setBackgroundResource(GreateSpeechesUtil.getResId(mPersonObj.getImageId(), R.drawable.class));
    cVideoView = (CustomVideoView) rootView.findViewById(R.id.surface_video);
    closeImg = (ImageView) rootView.findViewById(R.id.closeBtn);
    videoRel = (RelativeLayout) rootView.findViewById(R.id.forVideo);
    videoRel.setOnTouchListener(customTouchListener);
    fragmentsLayout.setOnTouchListener(customTouchListener);

    if (null != mPersonObj.getdDate() && mPersonObj.getdDate().length() == 0) {
        RelativeLayout dRel = (RelativeLayout) rootView.findViewById(R.id.dDateRel);
        dRel.setVisibility(View.GONE);
    }

    TextView bDateTxt = (TextView) rootView.findViewById(R.id.bDate);
    bDateTxt.setText("" + mPersonObj.getbDate());
    TextView bachievementTxt = (TextView) rootView.findViewById(R.id.C_info);
    bachievementTxt.setText("" + mPersonObj.getAchievement());
    //        TextView pNameTxt = (TextView)rootView.findViewById(R.id.acTitleTxt);
    //        pNameTxt.setText(""+getResources().getString(R.string.achievement, mPersonObj.getName()));
    TextView dDateTxt = (TextView) rootView.findViewById(R.id.dDate);
    dDateTxt.setText("" + mPersonObj.getdDate());

    closeImg.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            closeVplayer();
        }
    });

    return rootView;
}

From source file:devicroft.burnboy.Activities.MainActivity.java

private void dispatchLicenseDialog() {
    Log.d(LOG_TAG, "dispatchLicenseDialog");
    AlertDialog d = new AlertDialog.Builder(this).setTitle("Licenses")
            .setMessage(Html.fromHtml(getString(R.string.license_fab) + "<br><br>"
                    + getString(R.string.license_mpandroidchart) + getString(R.string.app_name))) //https://stackoverflow.com/questions/3235131/set-textview-text-from-html-formatted-string-resource-in-xml
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();//  w  w  w.java2  s .  c om
                }
            }).show();
    TextView textView = (TextView) d.findViewById(android.R.id.message);
    textView.setScroller(new Scroller(this));
    textView.setVerticalScrollBarEnabled(true);
    textView.setAllCaps(false);
    textView.setMovementMethod(new ScrollingMovementMethod());
}