List of usage examples for android.widget Button Button
public Button(Context context)
From source file:com.skytree.epubtest.BookViewActivity.java
public View makeResultItem(SearchResult sr, int mode) { int inlineColor = Color.rgb(133, 105, 75); int headColor = Color.rgb(94, 61, 34); int textColor = Color.rgb(50, 40, 40); SkyLayout view = new SkyLayout(this); int itemWidth = ps(370); int itemHeight = ps(190); this.setFrame(view, 0, 0, itemWidth, itemHeight); TextView chapterLabel = null;/*www . java 2 s .c o m*/ TextView positionLabel = null; TextView textLabel = null; Button itemButton = null; itemButton = new Button(this); itemButton.setBackgroundColor(Color.TRANSPARENT); itemButton.setOnClickListener(listener); this.setFrame(itemButton, 0, 0, itemWidth, itemHeight); if (mode == 0) { // Normal case int ci = sr.chapterIndex; String chapterText = ""; chapterText = sr.chapterTitle; String positionText = String.format("%d/%d", sr.pageIndex + 1, sr.numberOfPagesInChapter); if (chapterText == null || chapterText.isEmpty()) { chapterText = "Chapter " + ci; } if (sr.pageIndex < 0 || sr.numberOfPagesInChapter < 0) { positionText = ""; } chapterLabel = this.makeLabel(3090, chapterText, Gravity.LEFT, 15, headColor); positionLabel = this.makeLabel(3091, positionText, Gravity.LEFT, 15, headColor); textLabel = this.makeLabel(3092, sr.text, Gravity.LEFT, 15, textColor); itemButton.setId(100000 + searchResults.size()); } else if (mode == 1) { // Paused chapterLabel = this.makeLabel(3090, getString(R.string.searchmore) + "....", Gravity.CENTER, 18, headColor); // positionLabel = this.makeLabel(3091, String.format("%d/%d",sr.pageIndex+1,sr.numberOfPagesInChapter), Gravity.LEFT, 15, headColor); textLabel = this.makeLabel(3092, sr.numberOfSearched + " " + getString(R.string.searchfound) + ".", Gravity.CENTER, 16, textColor); itemButton.setId(3093); } else if (mode == 2) { // finished chapterLabel = this.makeLabel(3090, getString(R.string.searchfinished), Gravity.CENTER, 18, headColor); // positionLabel = this.makeLabel(3091, String.format("%d/%d",sr.pageIndex+1,sr.numberOfPagesInChapter), Gravity.LEFT, 15, headColor); textLabel = this.makeLabel(3092, sr.numberOfSearched + " " + getString(R.string.searchfound) + ".", Gravity.CENTER, 16, textColor); itemButton.setId(3094); } textLabel.setMaxLines(3); if (mode == 0) { this.setFrame(chapterLabel, ps(20), ps(20), ps(270), ps(30)); this.setFrame(positionLabel, itemWidth - ps(85), ps(20), ps(70), ps(30)); this.setFrame(textLabel, ps(20), ps(80), itemWidth - ps(40), itemHeight - ps(80 + 20)); } else { this.setFrame(chapterLabel, ps(20), ps(20), ps(350), ps(40)); // this.setFrame(positionLabel, itemWidth-ps(80), ps(20),ps(70),ps(30)); this.setFrame(textLabel, ps(20), ps(80), itemWidth - ps(40), itemHeight - ps(80 + 20)); } view.addView(chapterLabel); if (mode == 0) view.addView(positionLabel); view.addView(textLabel); view.addView(itemButton); RectShape crs = new RectShape(); SkyDrawable cd = new SkyDrawable(crs, Color.TRANSPARENT, inlineColor, 1); view.setBackgroundDrawable(cd); return view; }
From source file:foam.starwisp.StarwispBuilder.java
public void Update(final StarwispActivity ctx, final String ctxname, JSONArray arr) { String type = ""; Integer tid = 0;/* w w w.jav a 2s . c o m*/ String token = ""; try { type = arr.getString(0); tid = arr.getInt(1); token = arr.getString(2); } catch (JSONException e) { Log.e("starwisp", "Error parsing update arguments for " + ctxname + " " + arr.toString() + e.toString()); } final Integer id = tid; //Log.i("starwisp", "Update: "+type+" "+id+" "+token); try { // non widget commands if (token.equals("toast")) { Toast msg = Toast.makeText(ctx.getBaseContext(), arr.getString(3), Toast.LENGTH_SHORT); LinearLayout linearLayout = (LinearLayout) msg.getView(); View child = linearLayout.getChildAt(0); TextView messageTextView = (TextView) child; messageTextView.setTextSize(arr.getInt(4)); msg.show(); return; } if (token.equals("play-sound")) { String name = arr.getString(3); if (name.equals("ping")) { MediaPlayer mp = MediaPlayer.create(ctx, R.raw.ping); mp.start(); } if (name.equals("active")) { MediaPlayer mp = MediaPlayer.create(ctx, R.raw.active); mp.start(); } } if (token.equals("soundfile-start-recording")) { String filename = arr.getString(3); m_SoundManager.StartRecording(filename); } if (token.equals("soundfile-stop-recording")) { m_SoundManager.StopRecording(); } if (token.equals("soundfile-start-playback")) { String filename = arr.getString(3); m_SoundManager.StartPlaying(filename); } if (token.equals("soundfile-stop-playback")) { m_SoundManager.StopPlaying(); } if (token.equals("vibrate")) { Vibrator v = (Vibrator) ctx.getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(arr.getInt(3)); } if (type.equals("replace-fragment")) { int ID = arr.getInt(1); String name = arr.getString(2); Fragment fragment = ActivityManager.GetFragment(name); FragmentTransaction ft = ctx.getSupportFragmentManager().beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); //ft.setCustomAnimations( R.animator.fragment_slide_left_enter, // R.animator.fragment_slide_right_exit); //ft.setCustomAnimations( // R.animator.card_flip_right_in, R.animator.card_flip_right_out, // R.animator.card_flip_left_in, R.animator.card_flip_left_out); ft.replace(ID, fragment); ft.addToBackStack(null); ft.commit(); return; } if (token.equals("dialog-fragment")) { FragmentManager fm = ctx.getSupportFragmentManager(); final int ID = arr.getInt(3); final JSONArray lp = arr.getJSONArray(4); final String name = arr.getString(5); final Dialog dialog = new Dialog(ctx); dialog.setTitle("Title..."); LinearLayout inner = new LinearLayout(ctx); inner.setId(ID); inner.setLayoutParams(BuildLayoutParams(lp)); dialog.setContentView(inner); // Fragment fragment = ActivityManager.GetFragment(name); // FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); // fragmentTransaction.add(ID,fragment); // fragmentTransaction.commit(); dialog.show(); /* DialogFragment df = new DialogFragment() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout inner = new LinearLayout(ctx); inner.setId(ID); inner.setLayoutParams(BuildLayoutParams(lp)); return inner; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog ret = super.onCreateDialog(savedInstanceState); Log.i("starwisp","MAKINGDAMNFRAGMENT"); Fragment fragment = ActivityManager.GetFragment(name); FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(1,fragment); fragmentTransaction.commit(); return ret; } }; df.show(ctx.getFragmentManager(), "foo"); */ } if (token.equals("time-picker-dialog")) { final Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); // Create a new instance of TimePickerDialog and return it TimePickerDialog d = new TimePickerDialog(ctx, null, hour, minute, true); d.show(); return; } ; if (token.equals("view")) { //ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse())); File f = new File(arr.getString(3)); Uri fileUri = Uri.fromFile(f); Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(arr.getString(3)); String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); myIntent.setDataAndType(fileUri, mimetype); ctx.startActivity(myIntent); return; } if (token.equals("make-directory")) { File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(3)); file.mkdirs(); return; } if (token.equals("list-files")) { final String name = arr.getString(3); File file = new File(((StarwispActivity) ctx).m_AppDir + arr.getString(5)); // todo, should probably call callback with empty list if (file != null) { File list[] = file.listFiles(); if (list != null) { String code = "("; for (int i = 0; i < list.length; i++) { code += " \"" + list[i].getName() + "\""; } code += ")"; DialogCallback(ctx, ctxname, name, code); } } return; } if (token.equals("gps-start")) { final String name = arr.getString(3); if (m_LocationManager == null) { m_LocationManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); m_GPS = new DorisLocationListener(m_LocationManager); } m_GPS.Start((StarwispActivity) ctx, name, this, arr.getInt(5), arr.getInt(6)); return; } if (token.equals("sensors-get")) { final String name = arr.getString(3); if (m_SensorHandler == null) { m_SensorHandler = new SensorHandler((StarwispActivity) ctx, this); } m_SensorHandler.GetSensors((StarwispActivity) ctx, name, this); return; } if (token.equals("sensors-start")) { final String name = arr.getString(3); final JSONArray requested_json = arr.getJSONArray(5); ArrayList<Integer> requested = new ArrayList<Integer>(); try { for (int i = 0; i < requested_json.length(); i++) { requested.add(requested_json.getInt(i)); } } catch (JSONException e) { Log.e("starwisp", "Error parsing data in sensors start " + e.toString()); } // start it up... if (m_SensorHandler == null) { m_SensorHandler = new SensorHandler((StarwispActivity) ctx, this); } m_SensorHandler.StartSensors((StarwispActivity) ctx, name, this, requested); return; } if (token.equals("sensors-stop")) { if (m_SensorHandler != null) { m_SensorHandler.StopSensors(); } return; } if (token.equals("walk-draggable")) { final String name = arr.getString(3); int iid = arr.getInt(5); DialogCallback(ctx, ctxname, name, WalkDraggable(ctx, name, ctxname, iid).replace("\\", "")); return; } if (token.equals("delayed")) { final String name = arr.getString(3); final int d = arr.getInt(5); Runnable timerThread = new Runnable() { public void run() { DialogCallback(ctx, ctxname, name, ""); } }; m_Handler.removeCallbacksAndMessages(null); m_Handler.postDelayed(timerThread, d); return; } if (token.equals("network-connect")) { final String name = arr.getString(3); final String ssid = arr.getString(5); m_NetworkManager.Start(ssid, (StarwispActivity) ctx, name, this); return; } if (token.equals("http-request")) { Log.i("starwisp", "http-request called"); if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http request"); final String name = arr.getString(3); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "normal", "", name); } return; } if (token.equals("http-post")) { Log.i("starwisp", "http-post called"); if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http request"); final String name = arr.getString(3); final String url = arr.getString(5); final String data = arr.getString(6); m_NetworkManager.StartRequestThread(url, "post", data, name); } return; } if (token.equals("http-upload")) { if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http ul request"); final String filename = arr.getString(4); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "upload", "", filename); } return; } if (token.equals("http-download")) { if (m_NetworkManager.state == NetworkManager.State.CONNECTED) { Log.i("starwisp", "attempting http dl request"); final String filename = arr.getString(4); final String url = arr.getString(5); m_NetworkManager.StartRequestThread(url, "download", "", filename); } return; } if (token.equals("take-photo")) { photo(ctx, arr.getString(3), arr.getInt(4)); } if (token.equals("bluetooth")) { final String name = arr.getString(3); m_Bluetooth.Start((StarwispActivity) ctx, name, this); return; } if (token.equals("bluetooth-send")) { m_Bluetooth.Write(arr.getString(3)); } if (token.equals("process-image-in-place")) { BitmapCache.ProcessInPlace(arr.getString(3)); } if (token.equals("send-mail")) { final String to[] = new String[1]; to[0] = arr.getString(3); final String subject = arr.getString(4); final String body = arr.getString(5); JSONArray attach = arr.getJSONArray(6); ArrayList<String> paths = new ArrayList<String>(); for (int a = 0; a < attach.length(); a++) { Log.i("starwisp", attach.getString(a)); paths.add(attach.getString(a)); } email(ctx, to[0], "", subject, body, paths); } if (token.equals("date-picker-dialog")) { final Calendar c = Calendar.getInstance(); int day = c.get(Calendar.DAY_OF_MONTH); int month = c.get(Calendar.MONTH); int year = c.get(Calendar.YEAR); final String name = arr.getString(3); // Create a new instance of TimePickerDialog and return it DatePickerDialog d = new DatePickerDialog(ctx, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int month, int day) { DialogCallback(ctx, ctxname, name, day + " " + month + " " + year); } }, year, month, day); d.show(); return; } ; if (token.equals("alert-dialog")) { final String name = arr.getString(3); final String msg = arr.getString(5); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int result = 0; if (which == DialogInterface.BUTTON_POSITIVE) result = 1; DialogCallback(ctx, ctxname, name, "" + result); } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(msg).setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); return; } if (token.equals("ok-dialog")) { final String name = arr.getString(3); final String msg = arr.getString(5); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int result = 0; if (which == DialogInterface.BUTTON_POSITIVE) result = 1; DialogCallback(ctx, ctxname, name, "" + result); } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(msg).setPositiveButton("Ok", dialogClickListener).show(); return; } if (token.equals("start-activity")) { ActivityManager.StartActivity(ctx, arr.getString(3), arr.getInt(4), arr.getString(5)); return; } if (token.equals("start-activity-goto")) { ActivityManager.StartActivityGoto(ctx, arr.getString(3), arr.getString(4)); return; } if (token.equals("finish-activity")) { ctx.setResult(arr.getInt(3)); ctx.finish(); return; } /////////////////////////////////////////////////////////// if (id == 0) { Log.i("starwisp", "Zero ID, aborting..."); return; } // now try and find the widget final View vv = ctx.findViewById(id); if (vv == null) { Log.i("starwisp", "Can't find widget : " + id); return; } // tokens that work on everything if (token.equals("hide")) { vv.setVisibility(View.GONE); return; } if (token.equals("show")) { vv.setVisibility(View.VISIBLE); return; } // only tested on spinners if (token.equals("disabled")) { vv.setAlpha(0.3f); //vv.getSelectedView().setEnabled(false); vv.setEnabled(false); return; } if (token.equals("enabled")) { vv.setAlpha(1.0f); //vv.getSelectedView().setEnabled(true); vv.setEnabled(true); return; } if (token.equals("animate")) { JSONArray trans = arr.getJSONArray(3); final TranslateAnimation animation = new TranslateAnimation(getPixelsFromDp(ctx, trans.getInt(0)), getPixelsFromDp(ctx, trans.getInt(1)), getPixelsFromDp(ctx, trans.getInt(2)), getPixelsFromDp(ctx, trans.getInt(3))); animation.setDuration(1000); animation.setFillAfter(false); animation.setInterpolator(new AnticipateOvershootInterpolator(1.0f)); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { vv.clearAnimation(); Log.i("starwisp", "animation end"); ((ViewManager) vv.getParent()).removeView(vv); //LayoutParams lp = new LayoutParams(imageView.getWidth(), imageView.getHeight()); //lp.setMargins(50, 100, 0, 0); //imageView.setLayoutParams(lp); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { Log.i("starwisp", "animation start"); } }); vv.startAnimation(animation); return; } // tokens that work on everything if (token.equals("set-enabled")) { Log.i("starwisp", "set-enabled called..."); vv.setEnabled(arr.getInt(3) == 1); vv.setClickable(arr.getInt(3) == 1); if (vv.getBackground() != null) { if (arr.getInt(3) == 0) { //vv.setBackgroundColor(0x00000000); vv.getBackground().setColorFilter(0x20000000, PorterDuff.Mode.MULTIPLY); } else { vv.getBackground().setColorFilter(null); } } return; } if (token.equals("background-colour")) { JSONArray col = arr.getJSONArray(3); if (type.equals("linear-layout")) { vv.setBackgroundColor(Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2))); } else { //vv.setBackgroundColor(); vv.getBackground().setColorFilter( Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2)), PorterDuff.Mode.MULTIPLY); } vv.invalidate(); return; } // special cases if (type.equals("linear-layout")) { //Log.i("starwisp","linear-layout update id: "+id); StarwispLinearLayout.Update(this, (LinearLayout) vv, token, ctx, ctxname, arr); return; } if (type.equals("relative-layout")) { StarwispRelativeLayout.Update(this, (RelativeLayout) vv, token, ctx, ctxname, arr); return; } if (type.equals("draggable")) { LinearLayout v = (LinearLayout) vv; if (token.equals("contents")) { v.removeAllViews(); JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } } if (token.equals("contents-add")) { JSONArray children = arr.getJSONArray(3); for (int i = 0; i < children.length(); i++) { Build(ctx, ctxname, new JSONArray(children.getString(i)), v); } } } if (type.equals("button-grid")) { LinearLayout horiz = (LinearLayout) vv; if (token.equals("grid-buttons")) { horiz.removeAllViews(); JSONArray params = arr.getJSONArray(3); String buttontype = params.getString(0); int height = params.getInt(1); int textsize = params.getInt(2); LayoutParams lp = BuildLayoutParams(params.getJSONArray(3)); final JSONArray buttons = params.getJSONArray(4); final int count = buttons.length(); int vertcount = 0; LinearLayout vert = null; for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); if (vertcount == 0) { vert = new LinearLayout(ctx); vert.setId(0); vert.setOrientation(LinearLayout.VERTICAL); horiz.addView(vert); } vertcount = (vertcount + 1) % height; if (buttontype.equals("button")) { Button b = new Button(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } else if (buttontype.equals("toggle")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String arg = "#f"; if (((ToggleButton) v).isChecked()) arg = "#t"; CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg); } }); vert.addView(b); } else if (buttontype.equals("single")) { ToggleButton b = new ToggleButton(ctx); b.setId(button.getInt(0)); b.setText(button.getString(1)); b.setTextSize(textsize); b.setLayoutParams(lp); b.setTypeface(((StarwispActivity) ctx).m_Typeface); final String fn = params.getString(5); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { for (int i = 0; i < count; i++) { JSONArray button = buttons.getJSONArray(i); int bid = button.getInt(0); if (bid != v.getId()) { ToggleButton tb = (ToggleButton) ctx.findViewById(bid); tb.setChecked(false); } } } catch (JSONException e) { Log.e("starwisp", "Error parsing on click data " + e.toString()); } CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t"); } }); vert.addView(b); } } } } /* if (type.equals("grid-layout")) { GridLayout v = (GridLayout)vv; if (token.equals("contents")) { v.removeAllViews(); JSONArray children = arr.getJSONArray(3); for (int i=0; i<children.length(); i++) { Build(ctx,ctxname,new JSONArray(children.getString(i)), v); } } } */ if (type.equals("view-pager")) { ViewPager v = (ViewPager) vv; if (token.equals("switch")) { v.setCurrentItem(arr.getInt(3)); } if (token.equals("pages")) { final JSONArray items = arr.getJSONArray(3); v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) { @Override public int getCount() { return items.length(); } @Override public Fragment getItem(int position) { try { String fragname = items.getString(position); return ActivityManager.GetFragment(fragname); } catch (JSONException e) { Log.e("starwisp", "Error parsing pages data " + e.toString()); } return null; } }); } } if (type.equals("image-view")) { ImageView v = (ImageView) vv; if (token.equals("image")) { int iid = ctx.getResources().getIdentifier(arr.getString(3), "drawable", ctx.getPackageName()); v.setImageResource(iid); } if (token.equals("external-image")) { v.setImageBitmap(BitmapCache.Load(arr.getString(3))); } return; } if (type.equals("text-view") || type.equals("debug-text-view")) { TextView v = (TextView) vv; if (token.equals("text")) { if (type.equals("debug-text-view")) { //v.setMovementMethod(new ScrollingMovementMethod()); } v.setText(Html.fromHtml(arr.getString(3)), BufferType.SPANNABLE); // v.invalidate(); } if (token.equals("file")) { v.setText(LoadData(arr.getString(3))); } return; } if (type.equals("edit-text")) { EditText v = (EditText) vv; if (token.equals("text")) { v.setText(arr.getString(3)); } if (token.equals("request-focus")) { v.requestFocus(); InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); } return; } if (type.equals("button")) { Button v = (Button) vv; if (token.equals("text")) { v.setText(arr.getString(3)); } if (token.equals("listener")) { final String fn = arr.getString(3); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { m_Scheme.eval("(" + fn + ")"); } }); } return; } if (type.equals("toggle-button")) { ToggleButton v = (ToggleButton) vv; if (token.equals("text")) { v.setText(arr.getString(3)); return; } if (token.equals("checked")) { if (arr.getInt(3) == 0) v.setChecked(false); else v.setChecked(true); return; } if (token.equals("listener")) { final String fn = arr.getString(3); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { m_Scheme.eval("(" + fn + ")"); } }); } return; } if (type.equals("canvas")) { StarwispCanvas v = (StarwispCanvas) vv; if (token.equals("drawlist")) { v.SetDrawList(arr.getJSONArray(3)); } return; } if (type.equals("camera-preview")) { final CameraPreview v = (CameraPreview) vv; if (token.equals("take-picture")) { final String path = ((StarwispActivity) ctx).m_AppDir + arr.getString(3); v.TakePicture(new PictureCallback() { public void onPictureTaken(byte[] input, Camera camera) { Bitmap original = BitmapFactory.decodeByteArray(input, 0, input.length); Bitmap resized = Bitmap.createScaledBitmap(original, PHOTO_WIDTH, PHOTO_HEIGHT, true); ByteArrayOutputStream blob = new ByteArrayOutputStream(); resized.compress(Bitmap.CompressFormat.JPEG, 100, blob); String datetime = getDateTime(); String filename = path + datetime + ".jpg"; SaveData(filename, blob.toByteArray()); v.Shutdown(); ctx.finish(); } }); } // don't shut the activity down and use provided path if (token.equals("take-picture-cont")) { final String path = ((StarwispActivity) ctx).m_AppDir + arr.getString(3); Log.i("starwisp", "take-picture-cont fired"); v.TakePicture(new PictureCallback() { public void onPictureTaken(byte[] input, Camera camera) { Log.i("starwisp", "on picture taken..."); // the version used by the uav app Bitmap original = BitmapFactory.decodeByteArray(input, 0, input.length); //Bitmap resized = Bitmap.createScaledBitmap(original, PHOTO_WIDTH, PHOTO_HEIGHT, true); ByteArrayOutputStream blob = new ByteArrayOutputStream(); original.compress(Bitmap.CompressFormat.JPEG, 95, blob); original.recycle(); String filename = path; Log.i("starwisp", path); SaveData(filename, blob.toByteArray()); // burn gps into exif data if (m_GPS.currentLocation != null) { double latitude = m_GPS.currentLocation.getLatitude(); double longitude = m_GPS.currentLocation.getLongitude(); try { ExifInterface exif = new ExifInterface(filename); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, GPS.convert(latitude)); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, GPS.latitudeRef(latitude)); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, GPS.convert(longitude)); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, GPS.longitudeRef(longitude)); exif.saveAttributes(); } catch (IOException e) { Log.i("starwisp", "Couldn't open " + filename + " to add exif data: ioexception caught."); } } v.TakenPicture(); } }); } if (token.equals("shutdown")) { v.Shutdown(); } return; } if (type.equals("seek-bar")) { SeekBar v = new SeekBar(ctx); if (token.equals("max")) { // android seekbar bug workaround int p = v.getProgress(); v.setMax(0); v.setProgress(0); v.setMax(arr.getInt(3)); v.setProgress(1000); // not working.... :( } } if (type.equals("spinner")) { Spinner v = (Spinner) vv; if (token.equals("selection")) { v.setSelection(arr.getInt(3)); } if (token.equals("array")) { final JSONArray items = arr.getJSONArray(3); ArrayList<String> spinnerArray = new ArrayList<String>(); for (int i = 0; i < items.length(); i++) { spinnerArray.add(items.getString(i)); } ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, R.layout.spinner_item, spinnerArray) { public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface); return v; } }; spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout); v.setAdapter(spinnerArrayAdapter); final int wid = id; // need to update for new values v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> a, View v, int pos, long id) { CallbackArgs(ctx, ctxname, wid, "" + pos); } public void onNothingSelected(AdapterView<?> v) { } }); } return; } if (type.equals("draw-map")) { DrawableMap v = m_DMaps.get(id); if (v != null) { if (token.equals("polygons")) { v.UpdateFromJSON(arr.getJSONArray(3)); } if (token.equals("centre")) { JSONArray tokens = arr.getJSONArray(3); v.Centre(tokens.getDouble(0), tokens.getDouble(1), tokens.getInt(2)); } if (token.equals("layout")) { v.m_parent.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3))); } } else { Log.e("starwisp", "Asked to update a drawmap which doesn't exist"); } } } catch (JSONException e) { Log.e("starwisp", "Error parsing builder data " + e.toString()); Log.e("starwisp", "type:" + type + " id:" + id + " token:" + token); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
public void bbar(final Main main) { final String text = main.CURRENT_PATH; try {// ww w .j a v a2 s . co m buttons.removeAllViews(); buttons.setMinimumHeight(pathbar.getHeight()); Drawable arrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_holo_dark); Bundle b = utils.getPaths(text, this); ArrayList<String> names = b.getStringArrayList("names"); ArrayList<String> rnames = new ArrayList<String>(); for (int i = names.size() - 1; i >= 0; i--) { rnames.add(names.get(i)); } ArrayList<String> paths = b.getStringArrayList("paths"); final ArrayList<String> rpaths = new ArrayList<String>(); for (int i = paths.size() - 1; i >= 0; i--) { rpaths.add(paths.get(i)); } View view = new View(this); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(toolbar.getContentInsetLeft(), LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(params1); buttons.addView(view); for (int i = 0; i < names.size(); i++) { final int k = i; ImageView v = new ImageView(this); v.setImageDrawable(arrow); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; v.setLayoutParams(params); final int index = i; if (rpaths.get(i).equals("/")) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getRootDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist(("/"), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else if (isStorage(rpaths.get(i))) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getSdDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else { Button button = new Button(this); button.setText(rnames.get(index)); button.setTextColor(getResources().getColor(android.R.color.white)); button.setTextSize(13); button.setLayoutParams(params); button.setBackgroundResource(0); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); button.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { File file1 = new File(rpaths.get(index)); copyToClipboard(MainActivity.this, file1.getPath()); Toast.makeText(MainActivity.this, getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT).show(); return false; } }); buttons.addView(button); if (names.size() - i != 1) buttons.addView(v); } } scroll.post(new Runnable() { @Override public void run() { sendScroll(scroll); sendScroll(scroll1); } }); if (buttons.getVisibility() == View.VISIBLE) { timer.cancel(); timer.start(); } } catch (Exception e) { e.printStackTrace(); System.out.println("button view not available"); } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeFontBox() { int boxColor = Color.rgb(241, 238, 229); int innerBoxColor = Color.rgb(246, 244, 239); int inlineColor = Color.rgb(133, 105, 75); int width = 450; int height = 500; fontBox = new SkyBox(this); fontBox.setBoxColor(boxColor);//from ww w.ja v a 2 s .c om fontBox.setArrowHeight(ps(25)); fontBox.setArrowDirection(false); setFrame(fontBox, ps(50), ps(200), ps(width), ps(height)); ScrollView fontBoxScrollView = new ScrollView(this); this.setFrame(fontBoxScrollView, ps(5), ps(10), ps(440), ps(height - 50)); fontBox.contentView.addView(fontBoxScrollView); // NEW SkyLayout contentLayout = new SkyLayout(this); fontBoxScrollView.addView(contentLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // #1 first make brightness controller // brView is the box containing the bright slider. int FY = 10; View brView = new View(this); RoundRectShape rrs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable srd = new SkyDrawable(rrs, innerBoxColor, inlineColor, 1); brView.setBackgroundDrawable(srd); setFrame(brView, ps(20), ps(FY), ps(width - 40), ps(53)); contentLayout.addView(brView); // darker and brighter icons int SBS = 60; ImageButton sbb = this.makeImageButton(9005, R.drawable.brightness2x, ps(SBS), ps(SBS)); setFrame(sbb, ps(50), ps(FY), ps(SBS), ps(SBS)); sbb.setAlpha(200); int BBS = 70; ImageButton bbb = this.makeImageButton(9006, R.drawable.brightness2x, ps(BBS), ps(BBS)); setFrame(bbb, ps(width - 110), ps(FY - 5), ps(BBS), ps(BBS)); bbb.setAlpha(200); contentLayout.addView(sbb); contentLayout.addView(bbb); // making bright slider brightBar = new SeekBar(this); brightBar.setMax(999); brightBar.setId(997); brightBar.setBackgroundColor(Color.TRANSPARENT); brightBar.setOnSeekBarChangeListener(new SeekBarDelegate()); brightBar.setProgressDrawable(new LineDrawable(Color.rgb(160, 160, 160), ps(10))); brightBar.setThumbOffset(-1); setFrame(brightBar, ps(100), ps(FY + 4), ps(width - 210), ps(50)); contentLayout.addView(brightBar); // #2 second make decrese/increse font size buttons // decrease font size Button int FBY = 80; decreaseButton = new Button(this); setFrame(decreaseButton, ps(20), ps(FBY), ps(width - 40 - 20) / 2, ps(60)); decreaseButton.setText(getString(R.string.chara)); decreaseButton.setGravity(Gravity.CENTER); decreaseButton.setTextSize(14); decreaseButton.setId(5000); RoundRectShape drs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable drd = new SkyDrawable(drs, innerBoxColor, inlineColor, 1); decreaseButton.setBackgroundDrawable(drd); decreaseButton.setOnClickListener(listener); decreaseButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(decreaseButton)); contentLayout.addView(decreaseButton); // inccrease font size Button increaseButton = new Button(this); setFrame(increaseButton, ps(10 + width / 2), ps(FBY), ps(width - 40 - 20) / 2, ps(60)); increaseButton.setText(getString(R.string.chara)); increaseButton.setTextSize(18); increaseButton.setGravity(Gravity.CENTER); increaseButton.setId(5001); RoundRectShape irs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable ird = new SkyDrawable(irs, innerBoxColor, inlineColor, 1); increaseButton.setBackgroundDrawable(ird); increaseButton.setOnClickListener(listener); increaseButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(increaseButton)); contentLayout.addView(increaseButton); // # 3 make the button to increase/decrese line spacing. int LBY = 145; // deccrease line space Button decreaseLineSpaceButton = this.makeImageButton(9005, R.drawable.decline2x, ps(30), ps(30)); setFrame(decreaseLineSpaceButton, ps(20), ps(LBY), ps(width - 40 - 20) / 2, ps(60)); decreaseLineSpaceButton.setId(4000); drs = new RoundRectShape(new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); drd = new SkyDrawable(drs, innerBoxColor, inlineColor, 1); decreaseLineSpaceButton.setBackgroundDrawable(drd); decreaseLineSpaceButton.setOnClickListener(listener); decreaseLineSpaceButton .setOnTouchListener(new ImageButtonHighlighterOnTouchListener(decreaseLineSpaceButton)); contentLayout.addView(decreaseLineSpaceButton); // inccrease line space Button increaseLineSpaceButton = this.makeImageButton(9005, R.drawable.incline2x, ps(30), ps(30)); setFrame(increaseLineSpaceButton, ps(10 + width / 2), ps(LBY), ps(width - 40 - 20) / 2, ps(60)); increaseLineSpaceButton.setId(4001); irs = new RoundRectShape(new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); ird = new SkyDrawable(irs, innerBoxColor, inlineColor, 1); increaseLineSpaceButton.setBackgroundDrawable(ird); increaseLineSpaceButton.setOnClickListener(listener); increaseLineSpaceButton .setOnTouchListener(new ImageButtonHighlighterOnTouchListener(increaseLineSpaceButton)); contentLayout.addView(increaseLineSpaceButton); // #4 make themes selector. int TY = 220; int TH = 70; int TW = (width - 40 - 20) / 3; HorizontalScrollView themeScrollView = new HorizontalScrollView(this); themesView = new LinearLayout(this); themesView.setOrientation(LinearLayout.HORIZONTAL); themeScrollView.addView(themesView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); for (int i = 0; i < this.themes.size(); i++) { Theme theme = themes.get(i); Button themeButton = new Button(this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ps(TW), ps(TH)); layoutParams.setMargins(0, 0, 24, 0); themesView.addView(themeButton, layoutParams); RoundRectShape rs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable brd = new SkyDrawable(rs, theme.backgroundColor, Color.BLACK, 1); themeButton.setBackgroundDrawable(brd); themeButton.setText(theme.name); themeButton.setTextColor(theme.foregroundColor); themeButton.setId(7000 + i); themeButton.setOnClickListener(listener); } this.setFrame(themeScrollView, ps(20), ps(TY), ps(width - 40), ps(90)); contentLayout.addView(themeScrollView); // #5 font list box int SY = 310; int fontButtonHeight = 80; int fontListHeight; fontListHeight = fontButtonHeight * fonts.size(); fontListView = new LinearLayout(this); fontListView.setOrientation(LinearLayout.VERTICAL); contentLayout.addView(fontListView); this.setFrame(fontListView, ps(20), ps(SY), ps(width - 40), ps(fontListHeight)); int inlineColor2 = Color.argb(140, 133, 105, 75); for (int i = 0; i < fonts.size(); i++) { CustomFont customFont = fonts.get(i); Button fontButton = new Button(this); fontButton.setText(customFont.fontFaceName); fontButton.setTextSize(20); Typeface tf = null; if (customFont.fontFileName == null || customFont.fontFileName.isEmpty()) { tf = this.getTypeface(customFont.fontFaceName, Typeface.BOLD); } else { tf = Typeface.createFromAsset(getAssets(), "fonts/" + customFont.fontFileName); } if (tf != null) fontButton.setTypeface(tf); fontButton.setId(5100 + i); RoundRectShape rs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable brd = new SkyDrawable(rs, innerBoxColor, inlineColor2, 1); fontButton.setBackgroundDrawable(brd); this.setFrame(fontButton, ps(0), ps(0), ps(width - 40), ps(fontButtonHeight)); fontListView.addView(fontButton); fontButton.setOnClickListener(listener); fontButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(fontButton)); } this.ePubView.addView(fontBox); this.hideFontBox(); }
From source file:org.smilec.smile.student.CourseList.java
private void createScoreTable(Vector<Integer> _myscore, String username) { int num_right = countrightquestion(_myscore); int total_question = LAST_SCENE_NUM; TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutSeeR); TextView text1 = (TextView) findViewById(R.id.Header01); text1.setText(getString(R.string.name) + ": " + username); TextView text2 = (TextView) findViewById(R.id.Header11); text2.setText(getString(R.string.t_score) + ":" + num_right + "/" + total_question); for (int i = 0; i < _myscore.size(); i++) { TableRow tr = new TableRow(getApplicationContext()); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); int number = 0; number = i + 1;/* w ww .j a va2 s . co m*/ int score = _myscore.get(i); Button b = new Button(getApplicationContext()); b.setText("(" + number + ")"); b.setTextSize(resultSize1); // b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); params.setMargins(returnPixels(30.0f), 0, returnPixels(30.0f), 0); b.setLayoutParams(params); b.setOnClickListener(new MyButtonListener(number)); /* Add Button to row. */ tr.addView(b); TextView text = new TextView(getApplicationContext()); if (score == 1) { // right text.setText("0"); } else { // wrong text.setText("X"); } text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); text.setTextColor(Color.BLACK); text.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); text.setTextSize(resultSize2); tr.addView(text); //tr.setBackgroundResource(R.drawable.sf_gradient_03); tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); } return; }
From source file:com.filemanager.free.activities.MainActivity.java
public void bbar(final Main main) { final String text = main.CURRENT_PATH; try {/*ww w . j a va 2 s. com*/ buttons.removeAllViews(); buttons.setMinimumHeight(pathbar.getHeight()); Drawable arrow = ContextCompat.getDrawable(con, R.drawable.abc_ic_ab_back_holo_dark); Bundle b = utils.getPaths(text, this); ArrayList<String> names = b.getStringArrayList("names"); ArrayList<String> rnames = new ArrayList<String>(); assert names != null; for (int i = names.size() - 1; i >= 0; i--) { rnames.add(names.get(i)); } ArrayList<String> paths = b.getStringArrayList("paths"); final ArrayList<String> rpaths = new ArrayList<String>(); assert paths != null; for (int i = paths.size() - 1; i >= 0; i--) { rpaths.add(paths.get(i)); } View view = new View(this); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(toolbar.getContentInsetLeft(), LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(params1); buttons.addView(view); for (int i = 0; i < names.size(); i++) { final int k = i; ImageView v = new ImageView(this); v.setImageDrawable(arrow); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; v.setLayoutParams(params); final int index = i; if (rpaths.get(i).equals("/")) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getRootDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist(("/"), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else if (isStorage(rpaths.get(i))) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getSdDrawable()); ib.setBackgroundColor(Color.parseColor("#00ffffff")); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else { Button button = new Button(this); button.setText(rnames.get(index)); button.setTextColor(ContextCompat.getColor(con, android.R.color.white)); button.setTextSize(13); button.setLayoutParams(params); button.setBackgroundResource(0); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View p1) { main.loadlist((rpaths.get(k)), false, main.openMode); main.loadlist((rpaths.get(k)), false, main.openMode); timer.cancel(); timer.start(); } }); button.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { File file1 = new File(rpaths.get(index)); copyToClipboard(MainActivity.this, file1.getPath()); Toast.makeText(MainActivity.this, getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT).show(); return false; } }); buttons.addView(button); if (names.size() - i != 1) buttons.addView(v); } } scroll.post(new Runnable() { @Override public void run() { sendScroll(scroll); sendScroll(scroll1); } }); if (buttons.getVisibility() == View.VISIBLE) { timer.cancel(); timer.start(); } } catch (Exception e) { e.printStackTrace(); System.out.println("button view not available"); } }
From source file:com.mdlive.sav.MDLiveProviderDetails.java
private void setHorizontalScrollviewTimeslots(LinearLayout layout, String str_timeslot, int position, String physId) {/*from ww w . j a v a2s .c o m*/ final int density = (int) getBaseContext().getResources().getDisplayMetrics().density; final Button myText = new Button(MDLiveProviderDetails.this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { myText.setElevation(0f); } horizontalscrollview.setContentDescription("Horizontal ScrollView"); myText.setTextColor(Color.GRAY); myText.setTextSize(16); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(4 * density, 4 * density, 4 * density, 4 * density); myText.setLayoutParams(params); myText.setGravity(Gravity.CENTER); myText.setBackgroundResource(R.drawable.timeslot_white_rounded_corner); myText.setClickable(true); myText.setTag(timeSlotListMap.get(position).get("appointment_type")); myText.setPadding(8 * density, 4 * density, 8 * density, 4 * density); myText.setText(TimeZoneUtils.getTimeFromTimestamp(str_timeslot, this)); layout.addView(myText); if (str_appointmenttype.equalsIgnoreCase("video") || str_appointmenttype.equalsIgnoreCase("video or phone") && str_timeslot != null && !str_timeslot.equals("0")) { videoList.add(myText); } if (str_appointmenttype.equalsIgnoreCase("phone") || str_appointmenttype.equalsIgnoreCase("video or phone") && str_timeslot != null && !str_timeslot.equals("0")) { phoneList.add(myText); } clickForVideoOrPhoneTapReqFutureAction(); clickEventForHorizontalText(myText, str_timeslot, physId); }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeListBox() { this.listBox = new SkyLayout(this); listBox.setBackgroundColor(Color.TRANSPARENT); // listBox.setBackgroundColor(this.themes.get(this.themeIndex).backgroundColor | 0xD0000000); listTopButton = new Button(this); listTopButton.setId(9009);//w ww. ja va 2s . com listTopButton.setOnClickListener(listener); listTopButton.setBackgroundColor(Color.TRANSPARENT); GradientDrawable gradForChecked = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xff407ee6, 0xff6ca2f9 }); GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { 0xfff4f4f4, 0xffcdcdcd }); this.contentListButton = new Button(this); this.contentListButton.setId(2700); this.contentListButton.setOnClickListener(listener); this.contentListButton.setText(getString(R.string.contents)); this.contentListButton.setTextSize(13); this.bookmarkListButton = new Button(this); this.bookmarkListButton.setId(2701); this.bookmarkListButton.setOnClickListener(listener); this.bookmarkListButton.setText(getString(R.string.bookmark)); this.bookmarkListButton.setTextSize(13); this.highlightListButton = new Button(this); this.highlightListButton.setId(2702); this.highlightListButton.setOnClickListener(listener); this.highlightListButton.setText(getString(R.string.highlight)); this.highlightListButton.setTextSize(13); this.listScrollView = new ScrollView(this); this.listView = new LinearLayout(this); listView.setOrientation(LinearLayout.VERTICAL); this.listBox.addView(listTopButton); this.listBox.addView(contentListButton); this.listBox.addView(bookmarkListButton); this.listBox.addView(highlightListButton); this.listBox.addView(listScrollView); this.listScrollView.addView(listView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.ePubView.addView(this.listBox); this.hideListBox(); }
From source file:com.skytree.epubtest.BookViewActivity.java
public void fillContentsList() { this.listView.removeAllViews(); NavPoints nps = rv.getNavPoints();/* w w w.j ava 2s .c o m*/ for (int i = 0; i < nps.getSize(); i++) { NavPoint np = nps.getNavPoint(i); Button contentButton = new Button(this); contentButton.setBackgroundColor(Color.TRANSPARENT); contentButton.setText(np.text); Theme theme = getCurrentTheme(); contentButton.setTextColor(theme.foregroundColor); contentButton.setTextSize(14); contentButton.setGravity(Gravity.LEFT); contentButton.setId(i); contentButton.setOnClickListener(contentDelegate); listView.addView(contentButton); debug("" + i + ":" + np.text); } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void bbar(final MainFragment mainFrag) { final String path = mainFrag.CURRENT_PATH; try {/*from w w w .j a v a2s.c o m*/ buttons.removeAllViews(); buttons.setMinimumHeight(pathbar.getHeight()); Drawable arrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_holo_dark); Bundle bundle = utils.getPaths(path, this); ArrayList<String> names = bundle.getStringArrayList("names"); ArrayList<String> rnames = bundle.getStringArrayList("names"); Collections.reverse(rnames); ArrayList<String> paths = bundle.getStringArrayList("paths"); final ArrayList<String> rpaths = bundle.getStringArrayList("paths"); Collections.reverse(rpaths); View view = new View(this); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(toolbar.getContentInsetLeft(), LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(params1); buttons.addView(view); for (int i = 0; i < names.size(); i++) { final int k = i; ImageView v = new ImageView(this); v.setImageDrawable(arrow); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; v.setLayoutParams(params); final int index = i; if (rpaths.get(i).equals("/")) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getRootDrawable()); ib.setBackgroundColor(Color.TRANSPARENT); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { mainFrag.loadlist(("/"), false, mainFrag.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else if (isStorage(rpaths.get(i))) { ImageButton ib = new ImageButton(this); ib.setImageDrawable(icons.getSdDrawable()); ib.setBackgroundColor(Color.TRANSPARENT); ib.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { mainFrag.loadlist((rpaths.get(k)), false, mainFrag.openMode); timer.cancel(); timer.start(); } }); ib.setLayoutParams(params); buttons.addView(ib); if (names.size() - i != 1) buttons.addView(v); } else { Button b = new Button(this); b.setText(rnames.get(index)); b.setTextColor(Utils.getColor(this, android.R.color.white)); b.setTextSize(13); b.setLayoutParams(params); b.setBackgroundResource(0); b.setOnClickListener(new Button.OnClickListener() { public void onClick(View p1) { mainFrag.loadlist((rpaths.get(k)), false, mainFrag.openMode); mainFrag.loadlist((rpaths.get(k)), false, mainFrag.openMode); timer.cancel(); timer.start(); } }); b.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { File file1 = new File(rpaths.get(index)); copyToClipboard(MainActivity.this, file1.getPath()); Toast.makeText(MainActivity.this, getResources().getString(R.string.pathcopied), Toast.LENGTH_SHORT).show(); return false; } }); buttons.addView(b); if (names.size() - i != 1) buttons.addView(v); } } scroll.post(new Runnable() { @Override public void run() { sendScroll(scroll); sendScroll(scroll1); } }); if (buttons.getVisibility() == View.VISIBLE) { timer.cancel(); timer.start(); } } catch (Exception e) { e.printStackTrace(); Log.d("BBar", "button view not available"); } }