List of usage examples for android.view.animation TranslateAnimation setDuration
public void setDuration(long durationMillis)
From source file:com.ywesee.amiko.MainActivity.java
/** * Sets currently visible view//from w w w . j av a2s .c om * @param newCurrentView * @param withAnimation */ private void setCurrentView(View newCurrentView, boolean withAnimation) { if (mCurrentView == newCurrentView) return; // It's important to perform sanity checks on views and viewgroup if (mViewHolder != null) { // Set direction of transitation old view to new view int direction = -1; if (mCurrentView == mShowView) { direction = 1; } // Remove current view if (mCurrentView != null) { if (withAnimation == true) { TranslateAnimation animate = new TranslateAnimation(0, direction * mCurrentView.getWidth(), 0, 0); animate.setDuration(200); animate.setFillAfter(false); mCurrentView.startAnimation(animate); } mCurrentView.setVisibility(View.GONE); } // Add new view if (newCurrentView != null) { if (withAnimation == true) { TranslateAnimation animate = new TranslateAnimation(-direction * newCurrentView.getWidth(), 0, 0, 0); animate.setDuration(200); animate.setFillAfter(false); newCurrentView.startAnimation(animate); } newCurrentView.setVisibility(View.VISIBLE); } // Update currently visible view mCurrentView = newCurrentView; // Hide keyboard if (mCurrentView == mShowView) { hideSoftKeyboard(300); removeTabNavigation(); // getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } else if (mCurrentView == mSuggestView) { restoreTabNavigation(); // getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } } }
From source file:xj.property.activity.HXBaseActivity.ChatActivity.java
private void showPopWindow2() { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View mMenuView = inflater.inflate(R.layout.unservice_time, null); ((TextView) mMenuView.findViewById(R.id.tv_unservicetime)).setText("?" + MainActivity.startTime + "-" + MainActivity.endTime + "????"); ((TextView) mMenuView.findViewById(R.id.tv_unservicetime)) .setTextSize(getResources().getDimension(R.dimen.tv_unservicetime)); final PopupWindow popupWindow = new PopupWindow(); // ?// ww w. ja v a 2 s . c om // SelectPicPopupWindowView popupWindow.setContentView(mMenuView); // SelectPicPopupWindow popupWindow.setWidth(LinearLayout.LayoutParams.MATCH_PARENT); // SelectPicPopupWindow popupWindow.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); // SelectPicPopupWindow? // this.setFocusable(true); // SelectPicPopupWindow // popupWindow.setAnimationStyle(R.style.AnimTop); TranslateAnimation translateAnimation = new TranslateAnimation(0, 0.0f, 0, 200f); translateAnimation.setDuration(2000); translateAnimation.setFillAfter(true); ((TextView) mMenuView.findViewById(R.id.tv_unservicetime)).setAnimation(translateAnimation); translateAnimation.start(); // ColorDrawable?? ColorDrawable dw = new ColorDrawable(0xb0000000); // SelectPicPopupWindow // mMenuViewOnTouchListener?????? new Handler().postDelayed(new Runnable() { @Override public void run() { // ,Animation.RELATIVE_TO_SELF,10f,Animation.RELATIVE_TO_SELF,10f popupWindow.showAsDropDown(findViewById(R.id.top_bar)); //popupWindow.showAtLocation(findViewById(R.id.list),Gravity.NO_GRAVITY,0,0); } }, 200); }
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
/** * Method to display the menu of the app. *//* w w w . jav a 2 s .c o m*/ private void displaySideMenu() { TranslateAnimation animation = null; // If it's a tablet in landscape, the menu is always displayed, else // it's activated by the user if (!isTablet || (isTablet && screenOrientation == Orientation.PORTRAIT)) { if (!showingMenu) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainRL.getLayoutParams(); animation = new TranslateAnimation(0, listRL.getMeasuredWidth() - layoutParams.leftMargin, 0, 0); animation.setDuration(animationDuration); animation.setFillEnabled(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // At the end, set the final position as the current one RelativeLayout.LayoutParams lpList = (LayoutParams) mainRL.getLayoutParams(); lpList.setMargins(listRL.getMeasuredWidth(), 0, -listRL.getMeasuredWidth(), 0); mainRL.setLayoutParams(lpList); showingMenu = true; } }); } else { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainRL.getLayoutParams(); animation = new TranslateAnimation(0, -layoutParams.leftMargin, 0, 0); animation.setDuration(animationDuration); animation.setFillEnabled(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // At the end, set the final position as the current one RelativeLayout.LayoutParams mainContenrLP = (LayoutParams) mainRL.getLayoutParams(); mainContenrLP.setMargins(0, 0, 0, 0); mainRL.setLayoutParams(mainContenrLP); showingMenu = false; } }); } mainRL.startAnimation(animation); } else { // Showing the menu since the tablet is in landscape orientation RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainRL.getLayoutParams(); animation = new TranslateAnimation(0, listRL.getMeasuredWidth() - layoutParams.leftMargin, 0, 0); animation.setDuration(animationDuration); animation.setFillEnabled(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // At the end, set the final position as the current one RelativeLayout.LayoutParams lpList = (LayoutParams) mainRL.getLayoutParams(); lpList.setMargins(listRL.getMeasuredWidth(), 0, -listRL.getMeasuredWidth(), 0); mainRL.setLayoutParams(lpList); showingMenu = true; } }); mainRL.startAnimation(animation); } }
From source file:foam.starwisp.StarwispBuilder.java
public void Update(final StarwispActivity ctx, final String ctxname, JSONArray arr) { String type = ""; Integer tid = 0;/*from w w w . ja va 2 s . co 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:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private View switchViews(boolean forward, float xOffSet, float width, float velocity) { mAnimationDistance = width - xOffSet; float progress = Math.abs(xOffSet) / width; if (progress > 1.0f) { progress = 1.0f;/*from w w w.j a v a 2s .c o m*/ } float inFromXValue, inToXValue; float outFromXValue, outToXValue; if (forward) { inFromXValue = 1.0f - progress; inToXValue = 0.0f; outFromXValue = -progress; outToXValue = -1.0f; } else { inFromXValue = progress - 1.0f; inToXValue = 0.0f; outFromXValue = progress; outToXValue = 1.0f; } final Time start = new Time(mBaseDate.timezone); start.set(mController.getTime()); if (forward) { start.monthDay += mNumDays; } else { start.monthDay -= mNumDays; } mController.setTime(start.normalize(true)); Time newSelected = start; if (mNumDays == 7) { newSelected = new Time(start); adjustToBeginningOfWeek(start); } final Time end = new Time(start); end.monthDay += mNumDays - 1; // We have to allocate these animation objects each time we switch views // because that is the only way to set the animation parameters. TranslateAnimation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, inFromXValue, Animation.RELATIVE_TO_SELF, inToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f); TranslateAnimation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, outFromXValue, Animation.RELATIVE_TO_SELF, outToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f); long duration = calculateDuration(width - Math.abs(xOffSet), width, velocity); inAnimation.setDuration(duration); inAnimation.setInterpolator(mHScrollInterpolator); outAnimation.setInterpolator(mHScrollInterpolator); outAnimation.setDuration(duration); outAnimation.setAnimationListener(new GotoBroadcaster(start, end)); mViewSwitcher.setInAnimation(inAnimation); mViewSwitcher.setOutAnimation(outAnimation); DayView view = (DayView) mViewSwitcher.getCurrentView(); view.cleanup(); mViewSwitcher.showNext(); view = (DayView) mViewSwitcher.getCurrentView(); view.setSelected(newSelected, true, false); view.requestFocus(); view.reloadEvents(); view.updateTitle(); view.restartCurrentTimeUpdates(); return view; }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
public void menuToggle(int motionin, int motionout, int fragment) { /*/*from w w w .j av a2s . c o m*/ * final Dialog settingdialog = new Dialog(CarCheckListActivity.this, * R.style.backgrounddialog); settingdialog.dismiss(); */ new Dialog(CarCheckListActivity.this, R.style.backgrounddialog).dismiss(); headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468); slideoutheadsetting.setDuration(500); slideoutheadsetting.setFillAfter(true); headsetting.startAnimation(slideoutheadsetting); int prefer = getSharedPreferences("mysettings", MODE_PRIVATE).getInt("already", 1); if (prefer == 1) { getSharedPreferences("mysettings", MODE_PRIVATE).edit().putInt("already", 0).commit(); FragmentTransaction ft = getFragmentManager().beginTransaction().setCustomAnimations(motionin, motionout); FragmentManager fm = getFragmentManager(); Fragment fmTarget = fm.findFragmentById(fragment); ft.show(fmTarget); ft.commit(); } else { getSharedPreferences("mysettings", MODE_PRIVATE).edit().putInt("already", 1).commit(); FragmentTransaction ft = getFragmentManager().beginTransaction().setCustomAnimations(motionin, motionout); FragmentManager fm = getFragmentManager(); final Fragment fmTarget = fm.findFragmentById(fragment); ft.hide(fmTarget); ft.commit(); } }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideExteriorLayout() { final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog exteriordialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); exteriordialog.requestWindowFeature(Window.FEATURE_NO_TITLE); exteriordialog.setContentView(R.layout.exteriordialoglayout); exteriordialog.getWindow().getAttributes().windowAnimations = R.style.ExteriorDialogAnimation; exteriordialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = exteriordialog.getWindow().getAttributes(); lp.dimAmount = 0f;//from w ww . j a v a2 s . co m final CheckBox chkoutside_color = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_color); final CheckBox chkoutside_window = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_window); final CheckBox chkoutside_doorHood = (CheckBox) exteriordialog.getWindow() .findViewById(R.id.outside_doorHood); final CheckBox chkoutside_jack = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_jack); final CheckBox chkoutside_wrench = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_wrench); final CheckBox chkoutside_tires = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_tires); final CheckBox chkoutside_light = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_light); final CheckBox chkoutside_seal = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_seal); final CheckBox chkoutside_tirePart = (CheckBox) exteriordialog.getWindow() .findViewById(R.id.outside_tirePart); // Change font chkoutside_color.setTypeface(type); chkoutside_window.setTypeface(type); chkoutside_doorHood.setTypeface(type); chkoutside_jack.setTypeface(type); chkoutside_wrench.setTypeface(type); chkoutside_tires.setTypeface(type); chkoutside_light.setTypeface(type); chkoutside_seal.setTypeface(type); chkoutside_tirePart.setTypeface(type); exteriordialog.setCanceledOnTouchOutside(true); exteriordialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400); slideoutheadexterior.setDuration(500); slideoutheadexterior.setFillAfter(true); headexterior.startAnimation(slideoutheadexterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("outside_color", chkoutside_color.isChecked()); mp.put("outside_window", chkoutside_window.isChecked()); mp.put("outside_doorHood", chkoutside_doorHood.isChecked()); mp.put("outside_jack", chkoutside_jack.isChecked()); mp.put("outside_wrench", chkoutside_wrench.isChecked()); mp.put("outside_tires", chkoutside_tires.isChecked()); mp.put("outside_light", chkoutside_light.isChecked()); mp.put("outside_seal", chkoutside_seal.isChecked()); mp.put("outside_tirePart", chkoutside_tirePart.isChecked()); filterStore("exterior", mp); save(mp); } }); TextView exterior = (TextView) exteriordialog.getWindow().findViewById(R.id.Exterior); exterior.setTypeface(type); Button exteriorback = (Button) exteriordialog.getWindow().findViewById(R.id.Exteriorback); exteriorback.setTypeface(type); exteriorback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { exteriordialog.dismiss(); headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400); slideoutheadexterior.setDuration(500); slideoutheadexterior.setFillAfter(true); headexterior.startAnimation(slideoutheadexterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("outside_color", chkoutside_color.isChecked()); mp.put("outside_window", chkoutside_window.isChecked()); mp.put("outside_doorHood", chkoutside_doorHood.isChecked()); mp.put("outside_jack", chkoutside_jack.isChecked()); mp.put("outside_wrench", chkoutside_wrench.isChecked()); mp.put("outside_tires", chkoutside_tires.isChecked()); mp.put("outside_light", chkoutside_light.isChecked()); mp.put("outside_seal", chkoutside_seal.isChecked()); mp.put("outside_tirePart", chkoutside_tirePart.isChecked()); filterStore("exterior", mp); save(mp); } }); chkoutside_color.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_window.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_doorHood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_jack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_wrench.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_tires.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_light.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_seal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_tirePart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadexterior = new TranslateAnimation(0, 0, 0, 380); slideheadexterior.setDuration(500); slideheadexterior.setFillAfter(true); headexterior.startAnimation(slideheadexterior); exteriordialog.show(); WindowManager.LayoutParams params = exteriordialog.getWindow().getAttributes(); params.y = 0; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; exteriordialog.getWindow().setAttributes(params); chkoutside_color.setChecked(load("outside_color")); chkoutside_window.setChecked(load("outside_window")); chkoutside_doorHood.setChecked(load("outside_doorHood")); chkoutside_jack.setChecked(load("outside_jack")); chkoutside_wrench.setChecked(load("outside_wrench")); chkoutside_tires.setChecked(load("outside_tires")); chkoutside_light.setChecked(load("outside_light")); chkoutside_seal.setChecked(load("outside_seal")); chkoutside_tirePart.setChecked(load("outside_tirePart")); }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideDocumentLayout() { final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog documentdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); documentdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); documentdialog.setContentView(R.layout.documentdialoglayout); documentdialog.getWindow().getAttributes().windowAnimations = R.style.DocumentDialogAnimation; documentdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = documentdialog.getWindow().getAttributes(); lp.dimAmount = 0f;//ww w.j a v a 2 s.c om final CheckBox chkinsurance = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_insurance); final CheckBox chkactTaxLabel = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_actTaxLabel); final CheckBox chkbill = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_bill); final CheckBox chklicensePlate = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_licensePlate); final CheckBox chklicenseManual = (CheckBox) documentdialog.getWindow() .findViewById(R.id.doc_licenseManual); final CheckBox chkcarPartPaper = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_carPartPaper); final CheckBox chkcarManual = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_carManual); final CheckBox chklicenseRegister = (CheckBox) documentdialog.getWindow() .findViewById(R.id.doc_licenseRegister); final CheckBox chkgift = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_gift); // Change font chkinsurance.setTypeface(type); chkactTaxLabel.setTypeface(type); chkbill.setTypeface(type); chklicensePlate.setTypeface(type); chklicenseManual.setTypeface(type); chkcarPartPaper.setTypeface(type); chkcarManual.setTypeface(type); chklicenseRegister.setTypeface(type); chkgift.setTypeface(type); documentdialog.setCanceledOnTouchOutside(true); documentdialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headdocument.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheaddocument = new TranslateAnimation(0, 0, 350, 800); slideoutheaddocument.setDuration(500); slideoutheaddocument.setFillAfter(true); headdocument.startAnimation(slideoutheaddocument); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("doc_insurance", chkinsurance.isChecked()); mp.put("doc_actTaxLabel", chkactTaxLabel.isChecked()); mp.put("doc_bill", chkbill.isChecked()); mp.put("doc_licensePlate", chklicensePlate.isChecked()); mp.put("doc_licenseManual", chklicenseManual.isChecked()); mp.put("doc_carPartPaper", chkcarPartPaper.isChecked()); mp.put("doc_carManual", chkcarManual.isChecked()); mp.put("doc_licenseRegister", chklicenseRegister.isChecked()); mp.put("doc_gift", chkgift.isChecked()); filterStore("document", mp); save(mp); } }); TextView document = (TextView) documentdialog.getWindow().findViewById(R.id.Document); document.setTypeface(type); Button documentback = (Button) documentdialog.getWindow().findViewById(R.id.Documentback); documentback.setTypeface(type); documentback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { documentdialog.dismiss(); headdocument.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheaddocument = new TranslateAnimation(0, 0, 350, 800); slideoutheaddocument.setDuration(500); slideoutheaddocument.setFillAfter(true); headdocument.startAnimation(slideoutheaddocument); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("doc_insurance", chkinsurance.isChecked()); mp.put("doc_actTaxLabel", chkactTaxLabel.isChecked()); mp.put("doc_bill", chkbill.isChecked()); mp.put("doc_licensePlate", chklicensePlate.isChecked()); mp.put("doc_licenseManual", chklicenseManual.isChecked()); mp.put("doc_carPartPaper", chkcarPartPaper.isChecked()); mp.put("doc_carManual", chkcarManual.isChecked()); mp.put("doc_licenseRegister", chklicenseRegister.isChecked()); mp.put("doc_gift", chkgift.isChecked()); filterStore("document", mp); save(mp); } }); chkinsurance.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkactTaxLabel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkbill.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chklicensePlate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chklicenseManual.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkcarPartPaper.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkcarManual.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chklicenseRegister.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkgift.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalDocument(increment); } else { increment = false; getTotalDocument(increment); } DocumentProgress.setProgress(PercenDocument); percendocument.setText("" + PercenDocument + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headdocument.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheaddocument = new TranslateAnimation(0, 0, 800, 350); slideheaddocument.setDuration(500); slideheaddocument.setFillAfter(true); headdocument.startAnimation(slideheaddocument); documentdialog.show(); WindowManager.LayoutParams params = documentdialog.getWindow().getAttributes(); params.y = 350; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; documentdialog.getWindow().setAttributes(params); chkinsurance.setChecked(load("doc_insurance")); chkactTaxLabel.setChecked(load("doc_actTaxLabel")); chkbill.setChecked(load("doc_bill")); chklicensePlate.setChecked(load("doc_licensePlate")); chklicenseManual.setChecked(load("doc_licenseManual")); chkcarPartPaper.setChecked(load("doc_carPartPaper")); chkcarManual.setChecked(load("doc_carManual")); chklicenseRegister.setChecked(load("doc_licenseRegister")); chkgift.setChecked(load("doc_gift")); }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideEngineLayout() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float height = metrics.heightPixels; float width = metrics.widthPixels; int left840 = (int) ((width / 100) * 65.625); final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog enginedialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); enginedialog.requestWindowFeature(Window.FEATURE_NO_TITLE); enginedialog.setContentView(R.layout.enginedialoglayout); enginedialog.getWindow().getAttributes().windowAnimations = R.style.EngineDialogAnimation; enginedialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = enginedialog.getWindow().getAttributes(); lp.dimAmount = 0f;/*from ww w.jav a 2 s . co m*/ final CheckBox chkengine_hood = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_hood); final CheckBox chkengine_backHood = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_backHood); final CheckBox chkengine_underEngine = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_underEngine); final CheckBox chkengine_brakeOil = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_brakeOil); final CheckBox chkengine_engineOil = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_engineOil); final CheckBox chkengine_waterCoolant = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_waterCoolant); final CheckBox chkengine_belt = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_belt); final CheckBox chkengine_gear = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_gear); final CheckBox chkengine_liquidLevel = (CheckBox) enginedialog.getWindow() .findViewById(R.id.engine_liquidLevel); final CheckBox chkengine_soundOut = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_soundOut); final CheckBox chkengine_soundIn = (CheckBox) enginedialog.getWindow().findViewById(R.id.engine_soundIn); // Change font chkengine_hood.setTypeface(type); chkengine_backHood.setTypeface(type); chkengine_underEngine.setTypeface(type); chkengine_brakeOil.setTypeface(type); chkengine_engineOil.setTypeface(type); chkengine_waterCoolant.setTypeface(type); chkengine_belt.setTypeface(type); chkengine_gear.setTypeface(type); chkengine_liquidLevel.setTypeface(type); chkengine_soundOut.setTypeface(type); chkengine_soundIn.setTypeface(type); enginedialog.setCanceledOnTouchOutside(true); enginedialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headengine.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadengine = new TranslateAnimation(0, 0, 490, -500); slideoutheadengine.setDuration(300); slideoutheadengine.setFillAfter(true); headengine.startAnimation(slideoutheadengine); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("engine_hood", chkengine_hood.isChecked()); mp.put("engine_backHood", chkengine_backHood.isChecked()); mp.put("engine_underEngine", chkengine_underEngine.isChecked()); mp.put("engine_brakeOil", chkengine_brakeOil.isChecked()); mp.put("engine_engineOil", chkengine_engineOil.isChecked()); mp.put("engine_waterCoolant", chkengine_waterCoolant.isChecked()); mp.put("engine_belt", chkengine_belt.isChecked()); mp.put("engine_gear", chkengine_gear.isChecked()); mp.put("engine_liquidLevel", chkengine_liquidLevel.isChecked()); mp.put("engine_soundOut", chkengine_soundOut.isChecked()); mp.put("engine_soundIn", chkengine_soundIn.isChecked()); filterStore("engine", mp); save(mp); } }); TextView engine = (TextView) enginedialog.getWindow().findViewById(R.id.Engine); engine.setTypeface(type); Button engineback = (Button) enginedialog.getWindow().findViewById(R.id.Engineback); engineback.setTypeface(type); engineback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { enginedialog.dismiss(); headengine.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadengine = new TranslateAnimation(0, 0, 490, -500); slideoutheadengine.setDuration(300); slideoutheadengine.setFillAfter(true); headengine.startAnimation(slideoutheadengine); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("engine_hood", chkengine_hood.isChecked()); mp.put("engine_backHood", chkengine_backHood.isChecked()); mp.put("engine_underEngine", chkengine_underEngine.isChecked()); mp.put("engine_brakeOil", chkengine_brakeOil.isChecked()); mp.put("engine_engineOil", chkengine_engineOil.isChecked()); mp.put("engine_waterCoolant", chkengine_waterCoolant.isChecked()); mp.put("engine_belt", chkengine_belt.isChecked()); mp.put("engine_gear", chkengine_gear.isChecked()); mp.put("engine_liquidLevel", chkengine_liquidLevel.isChecked()); mp.put("engine_soundOut", chkengine_soundOut.isChecked()); mp.put("engine_soundIn", chkengine_soundIn.isChecked()); filterStore("engine", mp); save(mp); } }); chkengine_hood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_backHood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_underEngine.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_brakeOil.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_engineOil.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_waterCoolant.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_belt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_gear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_liquidLevel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_soundOut.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkengine_soundIn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalEngine(increment); } else { increment = false; getTotalEngine(increment); } EngineProgress.setProgress(PercenEngine); percenengine.setText("" + PercenEngine + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headengine.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadengine = new TranslateAnimation(0, 0, 0, 490); slideheadengine.setDuration(300); slideheadengine.setFillAfter(true); headengine.startAnimation(slideheadengine); enginedialog.show(); WindowManager.LayoutParams params = enginedialog.getWindow().getAttributes(); params.y = 1; params.x = left840; params.gravity = Gravity.TOP | Gravity.LEFT; enginedialog.getWindow().setAttributes(params); chkengine_hood.setChecked(load("engine_hood")); chkengine_backHood.setChecked(load("engine_backHood")); chkengine_underEngine.setChecked(load("engine_underEngine")); chkengine_brakeOil.setChecked(load("engine_brakeOil")); chkengine_engineOil.setChecked(load("engine_engineOil")); chkengine_waterCoolant.setChecked(load("engine_waterCoolant")); chkengine_belt.setChecked(load("engine_belt")); chkengine_gear.setChecked(load("engine_gear")); chkengine_liquidLevel.setChecked(load("engine_liquidLevel")); chkengine_soundOut.setChecked(load("engine_soundOut")); chkengine_soundIn.setChecked(load("engine_soundIn")); }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideSettingLayout() { SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE); // Bundle seek = getIntent().getExtras(); final Dialog settingdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); settingdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); settingdialog.setContentView(R.layout.settingdialoglayout); final SeekBar powerseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Powerbar); final SeekBar engineseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Enginebar); final SeekBar exteriorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Exteriorbar); // exteriorseekbar.setIndeterminate(false); final SeekBar interiorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Interiorbar); final SeekBar documentseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Documentbar); // seekbar.putInt("Powerbar", powerseekbarValue).commit(); // if(seek != null){ Log.i("insettings", "seekbar : power-> " + mSharedPrefs.getInt("Powerbar", 0)); Log.i("insettings", "seekbar : engine->" + mSharedPrefs.getInt("Enginebar", 0)); Log.i("insettings", "seekbar : exterior->" + mSharedPrefs.getInt("Exteriorbar", 0)); Log.i("insettings", "seekbar : interior->" + mSharedPrefs.getInt("Interiorbar", 0)); Log.i("insettings", "seekbar : document->" + mSharedPrefs.getInt("Documentbar", 0)); powerseekbar.setProgress(mSharedPrefs.getInt("Powerbar", 0)); engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0)); exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0)); interiorseekbar.setProgress(mSharedPrefs.getInt("Interiorbar", 0)); documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0)); /*// w w w .j ava 2s .c o m * for(Map.Entry<String, Integer> entry : mapSetting.entrySet()){ * if("interior".equals(entry.getKey())) edit.putInt("Interiorbar", * entry.getValue()); else if("power".equals(entry.getKey())) * edit.putInt("Powerbar", entry.getValue()); else * if("engine".equals(entry.getKey())) edit.putInt("Enginebar", * entry.getValue()); else if("exterior".equals(entry.getKey())) * edit.putInt("Exteriorbar", entry.getValue()); else * edit.putInt("Documentbar", entry.getValue()); * * //Log.i("checkSettingsName", "checkSettingsName : " + * entry.getKey()); } */ // ****************************************************check exist // current setting int powerBar = mSharedPrefs.getInt("Powerbar", 0); int engineBar = mSharedPrefs.getInt("Enginebar", 0); int exteriorBar = mSharedPrefs.getInt("Exteriorbar", 0); int interiorBar = mSharedPrefs.getInt("Interiorbar", 0); int documentBar = mSharedPrefs.getInt("Documentbar", 0); Log.i("power_setting", "*****in setting******power setting : " + powerBar); Log.i("engine_setting", "engine setting : " + engineBar); Log.i("exterior_setting", "exterior setting : " + exteriorBar); Log.i("interior_setting", "interior setting : " + interiorBar); Log.i("document_setting", "document setting : " + documentBar); // } TextView setting = (TextView) settingdialog.getWindow().findViewById(R.id.Setting); TextView priority = (TextView) settingdialog.getWindow().findViewById(R.id.Priority); TextView low = (TextView) settingdialog.getWindow().findViewById(R.id.Low); TextView high = (TextView) settingdialog.getWindow().findViewById(R.id.High); TextView textexterior = (TextView) settingdialog.getWindow().findViewById(R.id.textexterior); TextView textinterior = (TextView) settingdialog.getWindow().findViewById(R.id.textinterior); TextView textpower = (TextView) settingdialog.getWindow().findViewById(R.id.textpower); TextView textengine = (TextView) settingdialog.getWindow().findViewById(R.id.textengine); TextView textdocument = (TextView) settingdialog.getWindow().findViewById(R.id.textdocument); TextView one = (TextView) settingdialog.getWindow().findViewById(R.id.one); TextView two = (TextView) settingdialog.getWindow().findViewById(R.id.two); TextView three = (TextView) settingdialog.getWindow().findViewById(R.id.three); TextView four = (TextView) settingdialog.getWindow().findViewById(R.id.four); TextView five = (TextView) settingdialog.getWindow().findViewById(R.id.five); setting.setTypeface(type); priority.setTypeface(type); low.setTypeface(type); high.setTypeface(type); textexterior.setTypeface(type); textinterior.setTypeface(type); textpower.setTypeface(type); textengine.setTypeface(type); textdocument.setTypeface(type); one.setTypeface(type); two.setTypeface(type); three.setTypeface(type); four.setTypeface(type); five.setTypeface(type); settingdialog.getWindow().getAttributes().windowAnimations = R.style.SettingDialogAnimation; settingdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = settingdialog.getWindow().getAttributes(); lp.dimAmount = 0f; settingdialog.setCanceledOnTouchOutside(true); settingdialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468); slideoutheadsetting.setDuration(500); slideoutheadsetting.setFillAfter(true); headsetting.startAnimation(slideoutheadsetting); } }); Button btnsave = (Button) settingdialog.getWindow().findViewById(R.id.save); btnsave.setTypeface(type); btnsave.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { settingdialog.dismiss(); headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468); slideoutheadsetting.setDuration(500); slideoutheadsetting.setFillAfter(true); headsetting.startAnimation(slideoutheadsetting); powerseekbarValue = powerseekbar.getProgress(); engineseekbarValue = engineseekbar.getProgress(); exteriorseekbarValue = exteriorseekbar.getProgress(); interiorseekbarValue = interiorseekbar.getProgress(); documentseekbarValue = documentseekbar.getProgress(); Priority(); SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE); Editor seekbar = mSharedPrefs.edit(); seekbar.putInt("Powerbar", powerseekbarValue); seekbar.putInt("Enginebar", engineseekbarValue); seekbar.putInt("Exteriorbar", exteriorseekbarValue); seekbar.putInt("Interiorbar", interiorseekbarValue); seekbar.putInt("Documentbar", documentseekbarValue); seekbar.commit(); /* * int powerBar = shared2.getInt("Powerbar", 0); int engineBar = * shared2.getInt("Enginebar", 0); int exteriorBar = * shared2.getInt("Exteriorbar", 0); int interiorBar = * shared2.getInt("Interiorbar", 0); int documentBar = * shared2.getInt("Documentbar", 0); */ RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); Button btnreset = (Button) settingdialog.getWindow().findViewById(R.id.reset); btnreset.setTypeface(type); btnreset.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog alertDialog = new AlertDialog.Builder(CarCheckListActivity.this).setTitle("Reset") .setMessage("Do you really want to clear data?") .setPositiveButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = getIntent(); SharedPreferences sharedPreferences = getSharedPreferences("mysettings", Context.MODE_PRIVATE); sharedPreferences.edit().clear().commit(); /* * int CheckDocumentTotal, * CheckPowerTotal, CheckEngineTotal, * CheckExteriorTotal, * CheckInteriorTotal, PercenDocument, * PercenPower, PercenEngine, * PercenExterior, PercenInterior, * PercenRatio, Checknum, * powerseekbarValue, * engineseekbarValue, * exteriorseekbarValue, * interiorseekbarValue, * documentseekbarValue, sumPriority, * PowerPriority, EnginePriority, * ExteriorPriority, InteriorPriority, * DocumentPriority, * documentprogressValue; */ /* * Log.i("checkreset", * "BEFORE CLEAR -> CheckDocumentTotal : " * + CheckDocumentTotal); * Log.i("checkreset", * "CheckPowerTotal : " + * CheckPowerTotal); Log.i("checkreset", * "CheckEngineTotal : " + * CheckEngineTotal); * Log.i("checkreset", * "CheckExteriorTotal : " + * CheckExteriorTotal); * Log.i("checkreset", * "CheckInteriorTotal : " + * CheckInteriorTotal); * Log.i("checkreset", * "PercenDocument : " + * PercenDocument); Log.i("checkreset", * "PercenPower : " + PercenPower); * Log.i("checkreset", "PercenEngine : " * + PercenEngine); Log.i("checkreset", * "PercenExterior : " + * PercenExterior); Log.i("checkreset", * "PercenInterior : " + * PercenInterior); Log.i("checkreset", * "PercenRatio : " + PercenRatio); * Log.i("checkreset", "Checknum : " + * Checknum); Log.i("checkreset", * "powerseekbarValue : " + * powerseekbarValue); * Log.i("checkreset", * "engineseekbarValue : " + * engineseekbarValue); * Log.i("checkreset", * "interiorseekbarValue : " + * interiorseekbarValue); * Log.i("checkreset", * "exteriorseekbarValue : " + * exteriorseekbarValue); * Log.i("checkreset", * "documentseekbarValue : " + * documentseekbarValue); * Log.i("checkreset", "sumPriority : " * + sumPriority); Log.i("checkreset", * "PowerPriority : " + PowerPriority); * Log.i("checkreset", * "EnginePriority : " + * EnginePriority); Log.i("checkreset", * "ExteriorPriority : " + * ExteriorPriority); * Log.i("checkreset", * "InteriorPriority : " + * InteriorPriority); * Log.i("checkreset", * "DocumentPriority : " + * DocumentPriority); */ getIntent().removeExtra("power"); getIntent().removeExtra("engine"); getIntent().removeExtra("exterior"); getIntent().removeExtra("interior"); getIntent().removeExtra("document"); //startActivity(intent); Intent ii = new Intent(getApplicationContext(), CarCheckListActivity.class); startActivity(ii); finish(); } }).show(); } }); Button btnChangeLanguage = (Button) settingdialog.getWindow().findViewById(R.id.change_language); btnChangeLanguage.setTypeface(type); btnChangeLanguage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(CarCheckListActivity.this, ChangeLanguage.class); // th myIntent.putExtra("power", PercenPower); myIntent.putExtra("engine", PercenEngine); myIntent.putExtra("exterior", PercenExterior); myIntent.putExtra("interior", PercenInterior); myIntent.putExtra("document", PercenDocument); myIntent.putExtra("numpower", CheckPowerTotal); myIntent.putExtra("numengine", CheckEngineTotal); myIntent.putExtra("numexterior", CheckExteriorTotal); myIntent.putExtra("numinterior", CheckInteriorTotal); myIntent.putExtra("numdocument", CheckDocumentTotal); SharedPreferences shared = getSharedPreferences("mysettings", Context.MODE_PRIVATE); Editor editor = shared.edit(); int powerBar = shared.getInt("Powerbar", 0); int engineBar = shared.getInt("Enginebar", 0); int exteriorBar = shared.getInt("Exteriorbar", 0); int interiorBar = shared.getInt("Interiorbar", 0); int documentBar = shared.getInt("Documentbar", 0); Log.i("power_setting", "power setting : " + powerBar); Log.i("engine_setting", "engine setting : " + engineBar); Log.i("exterior_setting", "exterior setting : " + exteriorBar); Log.i("interior_setting", "interior setting : " + interiorBar); Log.i("document_setting", "document setting : " + documentBar); Log.i("checkInList", "Check in List : " + shared.getInt("checknum", 0)); CarCheckListActivity.this.startActivity(myIntent); finish(); } }); Button btnRecord = (Button) settingdialog.getWindow().findViewById(R.id.record); btnRecord.setTypeface(type); btnRecord.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.i("record", "record onClick"); final AlertDialog.Builder adb = new AlertDialog.Builder(getApplicationContext()); adb.setTitle("Warning Dialog"); adb.setMessage("you must select more than one checklist."); adb.setPositiveButton("Ok", null); SharedPreferences shared = getSharedPreferences("mysettings", MODE_PRIVATE); powerWeight = shared.getInt("Powerbar", 0); engineWeight = shared.getInt("Enginebar", 0); exteriorWeight = shared.getInt("Exteriorbar", 0); interiorWeight = shared.getInt("Interiorbar", 0); documentWeight = shared.getInt("Documentbar", 0); String display = "before record activity >> " + powerWeight + "|" + engineWeight + "|" + exteriorWeight + "|" + interiorWeight + "|" + documentWeight; Log.i("display", display); Log.i("checklist", "" + PercenPower); Log.i("checklist", "" + PercenEngine); Log.i("checklist", "" + PercenExterior); Log.i("checklist", "" + PercenInterior); Log.i("checklist", "" + PercenDocument); // checking scope isSaveCheckBox(); // progressCheckListLog(); // checking scope CarCheckListActivity.this.startActivity(intent); finish(); } }); Button btnList = (Button) settingdialog.getWindow().findViewById(R.id.list); btnList.setTypeface(type); btnList.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Checknumcheckbox(); Intent listSaving = new Intent(getApplicationContext(), ListSaveActivity.class); startActivity(listSaving); finish(); } }); headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadsetting = new TranslateAnimation(0, 0, -468, 0); slideheadsetting.setDuration(500); slideheadsetting.setFillAfter(true); headsetting.startAnimation(slideheadsetting); settingdialog.show(); WindowManager.LayoutParams params = settingdialog.getWindow().getAttributes(); params.y = 0; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; settingdialog.getWindow().setAttributes(params); powerseekbarValue = mSharedPrefs.getInt("Powerbar", 0); engineseekbarValue = mSharedPrefs.getInt("Enginebar", 0); exteriorseekbarValue = mSharedPrefs.getInt("Exteriorbar", 0); interiorseekbarValue = mSharedPrefs.getInt("Interiorbar", 0); documentseekbarValue = mSharedPrefs.getInt("Documentbar", 0); PowerPriority = powerseekbarValue + 1; EnginePriority = engineseekbarValue + 1; ExteriorPriority = exteriorseekbarValue + 1; InteriorPriority = interiorseekbarValue + 1; DocumentPriority = documentseekbarValue + 1; /* * powerseekbar.setProgress(mSharedPrefs.getInt("Powerbar", 0)); * engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0)); * exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0)); * interiorseekbar.setProgress(mSharedPrefs.getInt("Interior", 0)); * documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0)); */ powerseekbar.setProgress(powerseekbarValue); engineseekbar.setProgress(engineseekbarValue); exteriorseekbar.setProgress(exteriorseekbarValue); interiorseekbar.setProgress(interiorseekbarValue); documentseekbar.setProgress(documentseekbarValue); }