public MapView(Context ctx, boolean allowNetAccess, int mode) { super(ctx); Display display; this.allowNetAccess = allowNetAccess; geoUtils = new GeoUtils(mode); setBackgroundColor(0xFF555570); display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); scrWidth = display.getWidth(); scrHeight = display.getHeight(); setMinimumHeight(scrWidth); setMinimumWidth(scrHeight); tileWidth = (int) Math.ceil(scrWidth / 256.0) + 1; tileHeight = (int) Math.ceil(scrHeight / 256.0) + 1; gestureDetector = new GestureDetector(ctx, new GestureListener()); zoomOutButton = new Button(ctx); zoomOutButton.setText(" - "); zoomOutButton.setOnClickListener(this); zoomInButton = new Button(ctx); zoomInButton.setText(" + "); zoomInButton.setOnClickListener(this); updateUI(true); addView(zoomOutButton); addView(zoomInButton); }
public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case 1: mBtn.setTextColor(Color.RED); return true; case 2: mBtn.setTextColor(Color.GREEN); return true; case 3: mBtn.setTextColor(Color.BLUE); return true; case 4: Toast.makeText(this, "번역했다.", Toast.LENGTH_SHORT).show(); return true; case 5: Toast.makeText(this, "필기 인식했다.", Toast.LENGTH_SHORT).show(); return true; case 100: Toast.makeText(this, "회전했다 치고.", Toast.LENGTH_SHORT).show(); return true; case 101: Toast.makeText(this, "크기 변경 했다 치고.", Toast.LENGTH_SHORT).show(); return true; } return true; }
@Override public void onClick(View inButton) { boolean isErr = false; if (mTitle.getText().toString().length() == 0) { mTitle.setError("Required"); mTitle.setEms(10); isErr = true; } if (mDesc.getText().toString().length() == 0) { mDesc.setActivated(true); mDesc.setError("Required"); isErr = true; } if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE); else if (inButton.getId() == mAvail.getId()) startActivity(new Intent(this, CheckActivity.class)); else if (inButton.getId() == mBack.getId()) finish(); else if (inButton.getId() == mSub.getId()) { AlertDialog.Builder al = new AlertDialog.Builder(this); if (isErr) return; else al.setTitle("Continue?") .setIcon(R.drawable.ornament) .setMessage("Your listing is going to be submitted to your chosen category.") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int x) { payment = new ArrayList<String>(); if (mCard.isChecked()) payment.add("Card"); if (mCheck.isChecked()) payment.add("Check"); if (mOnline.isChecked()) payment.add("Online"); if (mCash.isChecked()) payment.add("Cash"); // Toast.makeText(getApplicationContext(), payment.toString(), // Toast.LENGTH_LONG).show(); Intent intent = new Intent(getApplicationContext(), StartActivity.class); intent.putExtra("Payment", payment); intent.putExtra("Category", mChosenCategory); intent.putExtra("Title", mTitle.getText().toString()); intent.putExtra("Price", mPrice.getText().toString()); intent.putExtra("Description", mDesc.getText().toString()); intent.putExtra("Location", mLocation.getText().toString()); intent.putExtra("Photo", jpegData); startActivity(intent); } }) .setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int x) {} }) .show(); } else startActivityForResult( new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ); }
public void showDetails(Equipment equipment) { equip = equipment; View view; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { view = getActivity().findViewById(R.id.detail_frag); } else { view = getActivity().findViewById(R.id.main_frame); Button button = (Button) view.findViewById(R.id.closeButton); button.setVisibility(View.VISIBLE); } TextView textIt_no = (TextView) view.findViewById(R.id.it_no2); TextView textType = (TextView) view.findViewById(R.id.type2); TextView textBrand = (TextView) view.findViewById(R.id.brand2); TextView textModel = (TextView) view.findViewById(R.id.model2); TextView textE_id = (TextView) view.findViewById(R.id.e_id); TextView textDescription = (TextView) view.findViewById(R.id.description); TextView textAquired = (TextView) view.findViewById(R.id.aquired); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape); } else { textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait); } textIt_no.setText("Item nr: \t\t\t\t" + equipment.getIt_no()); textType.setText("Type: \t\t\t\t\t" + equipment.getType()); textBrand.setText("Brand: \t\t\t\t" + equipment.getBrand()); textModel.setText("Model: \t\t\t\t" + equipment.getModel()); textE_id.setText("Equipment ID: \t" + equipment.getE_id()); textDescription.setText("Description: \t" + equipment.getDescription()); textAquired.setText("Aquired: \t\t\t" + equipment.getAquired()); downloadImageThread(); ImageView image = (ImageView) view.findViewById(R.id.equipment_image); image.setImageBitmap(bitmap); }
private void updateUI(boolean enabled) { if (useOverlay.m_zoom >= 17) { zoomInButton.setEnabled(false); zoomOutButton.setEnabled(true & enabled); } else if (useOverlay.m_zoom <= 3) { zoomInButton.setEnabled(true & enabled); zoomOutButton.setEnabled(false); } else { zoomInButton.setEnabled(enabled); zoomOutButton.setEnabled(enabled); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile); findViews(); /*Select Category work */ final String[] categories = getIntent().getStringArrayExtra("Options"); ArrayAdapter<String> catadapt; catadapt = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); mCatSpin.setAdapter(catadapt); mCatSpin.setOnItemSelectedListener( new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { mChosenCategory = categories[pos]; } public void onNothingSelected(AdapterView<?> parent) {} }); /*Availability selection work*/ mAvail = (Button) findViewById(R.id.editavail); mAvail.setOnClickListener(this); /*Submit/Back button work*/ mSub = (Button) findViewById(R.id.submitbutton); mSub.setOnClickListener(this); mBack.setOnClickListener(this); /*Web View & Camera uploader work*/ openCam.setOnClickListener(this); openWeb.setOnClickListener(this); web.getSettings().setJavaScriptEnabled(true); web.loadUrl("http://www.monkbananas.com/uploader/index.php"); // ------Everything below this line was found on StackOverflow-------------------- web.setWebChromeClient( new WebChromeClient() { @Override public boolean shouldOverrideUrlLoading(WebView v, String url) { web.loadUrl(url); return true; } // The undocumented magic method override // Eclipse will swear at you if you try to put @Override here // For Android 3.0+ public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } // For Android 4.1 public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); final String ID = intent.getStringExtra("ID"); final String name = intent.getStringExtra("Name"); final ActionBar actionBar = getSupportActionBar(); setContentView(R.layout.individual_colour_change_layout); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); ColH = settings.getInt("houCol" + ID, getResources().getColor(R.color.clokH)); ColM = settings.getInt("minCol" + ID, getResources().getColor(R.color.clokM)); ColS = settings.getInt("secCol" + ID, getResources().getColor(R.color.clokS)); String currentTitle = name + ": " + getString(R.string.chsColour); if (actionBar != null) { actionBar.setTitle(currentTitle); actionBar.setDisplayUseLogoEnabled(false); } draw(); Button reset = (Button) findViewById(R.id.reset); reset.setOnClickListener( v -> { Editor editor = settings.edit(); ColH = IndividualColourChange.this.getResources().getColor(R.color.clokH); ColM = IndividualColourChange.this.getResources().getColor(R.color.clokM); ColS = IndividualColourChange.this.getResources().getColor(R.color.clokS); editor.putInt("houCol" + ID, ColH); editor.putInt("minCol" + ID, ColM); editor.putInt("secCol" + ID, ColS); editor.apply(); IndividualColourChange.this.draw(); }); ImageView colPickH = (ImageView) findViewById(R.id.colorHou); colPickH.setClickable(true); colPickH.setOnClickListener( v -> { ColorSelectorDialog dlg = new ColorSelectorDialog( context, color -> { ColH = color; Editor editor = settings.edit(); editor.putInt("houCol" + ID, ColH); editor.apply(); draw(); }, ColH); dlg.setTitle(IndividualColourChange.this.getString(R.string.hHandCol)); dlg.show(); }); ImageView colPickM = (ImageView) findViewById(R.id.colorMin); colPickM.setClickable(true); colPickM.setOnClickListener( v -> { ColorSelectorDialog dlg = new ColorSelectorDialog( context, color -> { ColM = color; Editor editor = settings.edit(); editor.putInt("minCol" + ID, ColM); editor.apply(); draw(); }, ColM); dlg.setTitle(IndividualColourChange.this.getString(R.string.mHandCol)); dlg.show(); }); ImageView colPickS = (ImageView) findViewById(R.id.colorSec); colPickS.setClickable(true); colPickS.setOnClickListener( v -> { ColorSelectorDialog dlg = new ColorSelectorDialog( context, color -> { ColS = color; Editor editor = settings.edit(); editor.putInt("minCol" + ID, ColS); editor.apply(); draw(); }, ColS); dlg.setTitle(IndividualColourChange.this.getString(R.string.sHandCol)); dlg.show(); }); }
@Override public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.content_list_item, null); } TextView titleTextView = (TextView) view.findViewById(R.id.list_item_title); TextView stateTextView = (TextView) view.findViewById(R.id.list_item_state); TextView downTextView = (TextView) view.findViewById(R.id.list_item_downbar); Button downloadButton = (Button) view.findViewById(R.id.list_item_download_button); Button uploadButton = (Button) view.findViewById(R.id.list_item_upload_button); LocationInfo info = mInfoList.get(position); String titleText = info.title; String stateText = ""; if (titleText.length() > 30) titleText = titleText.substring(0, 28) + "..."; synchronized (mLoaderMap) { if (mLoaderMap.containsKey(info.title)) { LoaderState loader = mLoaderMap.get(info.title); if (loader.state < 100) stateText = String.format(Locale.ENGLISH, "%d%%", loader.state); else if (loader.state == 100) stateText = String.format(Locale.ENGLISH, "Done!"); else stateText = String.format(Locale.ENGLISH, "Failed!"); } } if (info.localVersion < 0) titleText += " (?)"; else { if (info.localModified) titleText += String.format(Locale.ENGLISH, " (v. %d+)", info.localVersion); else titleText += String.format(Locale.ENGLISH, " (v. %d)", info.localVersion); } String mapFile = NavigineApp.Settings.getString("map_file", ""); if (mapFile.equals(info.archiveFile)) { titleTextView.setTypeface(null, Typeface.BOLD); view.setBackgroundColor(Color.parseColor("#590E0E")); } else { titleTextView.setTypeface(null, Typeface.NORMAL); view.setBackgroundColor(Color.BLACK); } titleTextView.setText(titleText); stateTextView.setText(stateText); if (info.localModified) { downloadButton.setVisibility(View.GONE); uploadButton.setVisibility(View.VISIBLE); downTextView.setText("Version is modified. Upload?"); } else if (info.serverVersion > info.localVersion) { downloadButton.setVisibility(View.VISIBLE); uploadButton.setVisibility(View.GONE); String downText = String.format(Locale.ENGLISH, "Version available: %d", info.serverVersion); downTextView.setText(downText); } else { downloadButton.setVisibility(View.INVISIBLE); uploadButton.setVisibility(View.GONE); downTextView.setText("Version is up to date"); } downloadButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { startDownload(position); } }); uploadButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { startUpload(position); } }); return view; }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); adpt = new GalleryAdapter(this); pics = new Vector<Image>(); previews = (Gallery) findViewById(R.id.gallery1); Main = (ImageView) findViewById(R.id.PictureView); hist = (Histogram) findViewById(R.id.histogram); saturation = (SeekBar) findViewById(R.id.saturation); contrast = (SeekBar) findViewById(R.id.contrast); exposure = (SeekBar) findViewById(R.id.exposure); saveButton = (Button) findViewById(R.id.save); contrast.setProgress(50); exposure.setProgress(50); saturation.setProgress(100); handler = new UIHandler(Main, hist); tm = new ThreadManager(handler); save = new Save(); save.setContainer(Main); PinchyZoomy pz = new PinchyZoomy(); Main.setOnTouchListener(pz); Main.setDrawingCacheEnabled(true); Main.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); File folder = new File("/sdcard"); for (int i = 0; i < folder.listFiles().length; i++) { String name = folder.listFiles()[i].getName(); if (folder.listFiles()[i].isFile()) { String extension = name.substring(name.length() - 3); if (extension.equals("NEF") || extension.equals("dng")) { Image temp = new Image(folder.listFiles()[i].getAbsolutePath()); pics.add(temp); } } } for (int i = 0; i < pics.size(); i++) { System.out.println("Pulling thumb for: " + pics.elementAt(i).path); adpt.addImage(pics.elementAt(i).getThumb()); } previews.setAdapter(adpt); previews.setSpacing(3); previews.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Main.setImageBitmap(adpt.getItemAt(position)); Main.setAlpha(100); if (current != null) current.free(); current = pics.elementAt(position); handler.setImage(current); tm.pic = current; save.setImage(current); contrast.setProgress(50); exposure.setProgress(50); saturation.setProgress(100); LoadImageThread t = new LoadImageThread(current, handler); t.start(); } }); saturation.setOnSeekBarChangeListener( new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) { if (current.colors != null) tm.setSaturation(saturation.getProgress()); } @Override public void onStartTrackingTouch(SeekBar arg0) {} @Override public void onStopTrackingTouch(SeekBar arg0) {} }); contrast.setOnSeekBarChangeListener( new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (current.colors != null) tm.setContrast(contrast.getProgress()); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }); exposure.setOnSeekBarChangeListener( new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (current.colors != null) tm.setExposure(exposure.getProgress()); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }); saveButton.setOnClickListener(save); }