Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hwready.app;
- import android.app.*;
- import android.os.*;
- import android.view.*;
- import android.view.View.*;
- import android.widget.*;
- import android.content.*;
- import android.content.ClipboardManager;
- import android.graphics.*;
- import android.media.*;
- import android.net.*;
- import android.text.*;
- import android.util.*;
- import android.webkit.*;
- import java.util.*;
- import java.text.*;
- public class MainActivity extends Activity {
- private Intent webviewActivity = new Intent();
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- initialize();
- initializeLogic();
- }
- private void initialize() {
- }
- private void initializeLogic() {
- webviewActivity.setClass(getApplicationContext(), WebviewActivity.class);
- startActivity(webviewActivity);
- }
- // created automatically
- private void showMessage(String _s) {
- Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show();
- }
- private int getRandom(int _minValue ,int _maxValue){
- Random random = new Random();
- return random.nextInt(_maxValue - _minValue + 1) + _minValue;
- }
- public ArrayList<Double> getCheckedItemPositionsToArray(ListView _list) {
- ArrayList<Double> _result = new ArrayList<Double>();
- SparseBooleanArray _arr = _list.getCheckedItemPositions();
- for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
- if (_arr.valueAt(_iIdx))
- _result.add((double)_arr.keyAt(_iIdx));
- }
- return _result;
- }
- }
- package com.hwready.app;
- import android.app.*;
- import android.os.*;
- import android.view.*;
- import android.view.View.*;
- import android.widget.*;
- import android.content.*;
- import android.content.ClipboardManager;
- import android.graphics.*;
- import android.media.*;
- import android.net.*;
- import android.text.*;
- import android.util.*;
- import android.webkit.*;
- import java.util.*;
- import java.text.*;
- public class WebviewActivity extends Activity {
- private Switch switch1;
- private WebView webview2;
- private ArrayList<String> sites = new ArrayList<String>();
- private Intent calculator = new Intent();
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.webview);
- initialize();
- initializeLogic();
- }
- private void initialize() {
- switch1 = (Switch) findViewById(R.id.switch1);
- webview2 = (WebView) findViewById(R.id.webview2);
- webview2.getSettings().setJavaScriptEnabled(true);
- webview2.getSettings().setSupportZoom(true);
- webview2.setWebViewClient(new WebViewClient() {
- @Override
- public void onPageStarted(WebView _view,final String _url, Bitmap _favicon) {
- super.onPageStarted(_view, _url, _favicon);
- }
- @Override
- public void onPageFinished(WebView _view,final String _url) {
- super.onPageFinished(_view, _url);
- }
- });
- switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton _buttonView, final boolean _isChecked) {
- calculator.setClass(getApplicationContext(), CalculatorActivity.class);
- startActivity(calculator);
- }
- });
- }
- private void initializeLogic() {
- webview2.setVisibility(View.VISIBLE);
- sites.add("http://www.hwready.it");
- sites.add("https://www.amazon.it//ref=as_li_ss_tl?ie=UTF8&linkCode=ll2&tag=hwrandroid-21&linkId=9c2c07cbcd42df74096ca3a354d247e5");
- sites.add("https://www.facebook.com/hwready/");
- sites.add("https://m.youtube.com/channel/UCat_HI_nl3rQ8NQolhqnZiQ");
- switch1.setChecked(false);
- }
- @Override
- protected void onPostCreate(Bundle _savedInstanceState) {
- super.onPostCreate(_savedInstanceState);
- webview2.loadUrl("http://www.hwready.it");
- webview2.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
- }
- // created automatically
- private void showMessage(String _s) {
- Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show();
- }
- private int getRandom(int _minValue ,int _maxValue){
- Random random = new Random();
- return random.nextInt(_maxValue - _minValue + 1) + _minValue;
- }
- public ArrayList<Double> getCheckedItemPositionsToArray(ListView _list) {
- ArrayList<Double> _result = new ArrayList<Double>();
- SparseBooleanArray _arr = _list.getCheckedItemPositions();
- for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
- if (_arr.valueAt(_iIdx))
- _result.add((double)_arr.keyAt(_iIdx));
- }
- return _result;
- }
- }
- package com.hwready.app;
- import android.app.*;
- import android.os.*;
- import android.view.*;
- import android.view.View.*;
- import android.widget.*;
- import android.content.*;
- import android.content.ClipboardManager;
- import android.graphics.*;
- import android.media.*;
- import android.net.*;
- import android.text.*;
- import android.util.*;
- import android.webkit.*;
- import java.util.*;
- import java.text.*;
- public class CalculatorActivity extends Activity {
- private TextView textview2;
- private EditText edittext1;
- private TextView textview3;
- private CheckBox checkbox1;
- private CheckBox checkbox2;
- private CheckBox checkbox3;
- private CheckBox checkbox4;
- private Button button1;
- private TextView textview4;
- private TextView textview5;
- private String type = "";
- private double finaltext = 0;
- private Intent calculator = new Intent();
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.calculator);
- initialize();
- initializeLogic();
- }
- private void initialize() {
- textview2 = (TextView) findViewById(R.id.textview2);
- edittext1 = (EditText) findViewById(R.id.edittext1);
- textview3 = (TextView) findViewById(R.id.textview3);
- checkbox1 = (CheckBox) findViewById(R.id.checkbox1);
- checkbox2 = (CheckBox) findViewById(R.id.checkbox2);
- checkbox3 = (CheckBox) findViewById(R.id.checkbox3);
- checkbox4 = (CheckBox) findViewById(R.id.checkbox4);
- button1 = (Button) findViewById(R.id.button1);
- textview4 = (TextView) findViewById(R.id.textview4);
- textview5 = (TextView) findViewById(R.id.textview5);
- checkbox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton _buttonView, final boolean _isChecked) {
- checkbox1.setChecked(true);
- }
- });
- checkbox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton _buttonView, final boolean _isChecked) {
- checkbox2.setChecked(true);
- }
- });
- checkbox3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton _buttonView, final boolean _isChecked) {
- checkbox3.setChecked(true);
- }
- });
- checkbox4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton _buttonView, final boolean _isChecked) {
- checkbox4.setChecked(true);
- }
- });
- edittext1.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence _text, int _start, int _count, int _after) {
- }
- @Override
- public void onTextChanged(final CharSequence _charSeq, int _start, int _before, int _count) {
- type = edittext1.getText().toString();
- }
- @Override
- public void afterTextChanged(Editable _text) {
- }
- });
- button1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View _v) {
- if (checkbox1.isChecked()) {
- finaltext = Double.parseDouble(type) % 70;
- textview5.setText(String.valueOf(finaltext));
- if (checkbox2.isChecked()) {
- finaltext = Double.parseDouble(type) * 1.33d;
- textview5.setText(String.valueOf(finaltext));
- if (checkbox3.isChecked()) {
- finaltext = Double.parseDouble(type) * 1.20d;
- textview5.setText(String.valueOf(finaltext));
- if (checkbox4.isChecked()) {
- finaltext = Double.parseDouble(type) * 1.13d;
- textview5.setText(String.valueOf(finaltext));
- }
- }
- }
- }
- else {
- showMessage("Seleziona almeno una casella!");
- }
- }
- });
- }
- private void initializeLogic() {
- checkbox1.setChecked(false);
- checkbox2.setChecked(false);
- checkbox3.setChecked(false);
- checkbox4.setChecked(false);
- }
- @Override
- public void onBackPressed() {
- finish();
- }
- // created automatically
- private void showMessage(String _s) {
- Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show();
- }
- private int getRandom(int _minValue ,int _maxValue){
- Random random = new Random();
- return random.nextInt(_maxValue - _minValue + 1) + _minValue;
- }
- public ArrayList<Double> getCheckedItemPositionsToArray(ListView _list) {
- ArrayList<Double> _result = new ArrayList<Double>();
- SparseBooleanArray _arr = _list.getCheckedItemPositions();
- for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
- if (_arr.valueAt(_iIdx))
- _result.add((double)_arr.keyAt(_iIdx));
- }
- return _result;
- }
- }
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
- </LinearLayout>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
- <Switch
- android:id="@+id/switch1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:text="Switch to calc"
- android:textSize="12sp"
- android:textColor="#000000"
- />
- <WebView
- android:id="@+id/webview2"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- />
- </LinearLayout>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
- <TextView
- android:id="@+id/textview2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="50dp"
- android:padding="8dp"
- android:gravity="left|right|top|bottom"
- android:text="Calcolatrice per oggetti usati"
- android:textSize="20sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <EditText
- android:id="@+id/edittext1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:textSize="16sp"
- android:textColor="#000000"
- android:hint="Prezzo nuovo piú basso"
- android:textColorHint="#607D8B"
- android:lines="1"
- android:inputType="numberDecimal"
- android:layout_gravity="center_horizontal"
- />
- <TextView
- android:id="@+id/textview3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp"
- android:padding="8dp"
- android:text="Seleziona le caselle in base alla richiesta."
- android:textSize="14sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <CheckBox
- android:id="@+id/checkbox1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:text="È rotto\?"
- android:textSize="12sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <CheckBox
- android:id="@+id/checkbox2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:text="Ha la garanzia\?"
- android:textSize="12sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <CheckBox
- android:id="@+id/checkbox3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:text="Comprende il bundle\?"
- android:textSize="12sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <CheckBox
- android:id="@+id/checkbox4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:text="Ha segni d'usura\?"
- android:textSize="12sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:text="CALCOLA"
- android:textSize="12sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <TextView
- android:id="@+id/textview4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
- android:padding="8dp"
- android:text="Prezzo calcolato:"
- android:textSize="16sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- <TextView
- android:id="@+id/textview5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:textSize="16sp"
- android:textColor="#000000"
- android:layout_gravity="center_horizontal"
- />
- </LinearLayout>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.hwready.app">
- <uses-permission android:name="android.permission.INTERNET"/>
- <application android:allowBackup="true"
- android:label="HWReady App"
- android:icon="@drawable/app_icon"
- android:name=".SketchApplication"
- android:theme="@style/AppTheme">
- <activity
- android:name=".MainActivity"
- android:configChanges="orientation|screenSize"
- android:screenOrientation="portrait"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- <activity
- android:name=".WebviewActivity" android:configChanges="orientation|screenSize"
- android:screenOrientation="portrait" />
- <activity
- android:name=".CalculatorActivity" android:configChanges="orientation|screenSize"
- android:screenOrientation="portrait" />
- <activity android:name=".DebugActivity" android:screenOrientation="portrait"/>
- </application>
- </manifest>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement