List of usage examples for android.widget RelativeLayout ALIGN_PARENT_BOTTOM
int ALIGN_PARENT_BOTTOM
To view the source code for android.widget RelativeLayout ALIGN_PARENT_BOTTOM.
Click Source Link
From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java
private void setActionButtonPosition() { if (isTablet()) return;/* w ww . j a v a 2s . c o m*/ RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mActionButton.getLayoutParams(); if (null == mLap) { lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); } else { lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } mActionButton.setLayoutParams(lp); mActionButton.show(false); }
From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java
private void _showBannerAd_overlap(String position, String size) { //http://tigerwoods.tistory.com/11 //http://developer.android.com/reference/android/widget/RelativeLayout.html //http://stackoverflow.com/questions/24900725/admob-banner-poitioning-in-android-on-bottom-of-the-screen-using-no-xml-relative RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(AdView.LayoutParams.WRAP_CONTENT, AdView.LayoutParams.WRAP_CONTENT); if (position.equals("top-left")) { Log.d(LOG_TAG, "top-left"); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (position.equals("top-center")) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } else if (position.equals("top-right")) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else if (position.equals("left")) { params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("center")) { params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("right")) { params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("bottom-left")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (position.equals("bottom-center")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } else if (position.equals("bottom-right")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else {//w w w. j ava2 s. co m params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } //bannerViewLayout.addView(bannerView, params); bannerView.setLayoutParams(params); bannerViewLayout.addView(bannerView); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
@Override public void onGUICreate() { this.clearViews(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); // change shutter icon isRecording = false;/*from ww w . j a v a 2 s. c om*/ prefs.edit().putBoolean("videorecording", false).commit(); ApplicationScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START); onPreferenceCreate((PreferenceFragment) null); setupVideoSize(prefs); List<View> specialView = new ArrayList<View>(); RelativeLayout specialLayout = (RelativeLayout) ApplicationScreen.instance .findViewById(R.id.specialPluginsLayout2); for (int i = 0; i < specialLayout.getChildCount(); i++) specialView.add(specialLayout.getChildAt(i)); for (int j = 0; j < specialView.size(); j++) { View view = specialView.get(j); int view_id = view.getId(); if (view_id == this.mRecordingTimeView.getId() || view_id == this.modeSwitcher.getId()) { if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); specialLayout.removeView(view); } } { final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3)) .removeView(this.modeSwitcher); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3)) .addView(this.modeSwitcher, params); this.modeSwitcher.setLayoutParams(params); } // Calculate right sizes for plugin's controls DisplayMetrics metrics = new DisplayMetrics(); ApplicationScreen.instance.getWindowManager().getDefaultDisplay().getMetrics(metrics); float fScreenDensity = metrics.density; int iIndicatorSize = (int) (ApplicationScreen.getMainContext().getResources() .getInteger(R.integer.infoControlHeight) * fScreenDensity); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(iIndicatorSize, iIndicatorSize); int topMargin = ApplicationScreen.instance.findViewById(R.id.paramsLayout).getHeight() + (int) ApplicationScreen.getAppResources().getDimension(R.dimen.viewfinderViewsMarginTop); params.setMargins((int) (2 * ApplicationScreen.getGUIManager().getScreenDensity()), topMargin, 0, 0); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2)) .addView(this.mRecordingTimeView, params); this.mRecordingTimeView.setLayoutParams(params); LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater(); buttonsLayout = inflator.inflate(R.layout.plugin_capture_video_layout, null, false); buttonsLayout.setVisibility(View.VISIBLE); timeLapseButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonTimeLapse); pauseVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoPause); stopVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoStop); snapshotSupported = CameraController.isVideoSnapshotSupported(); takePictureButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonCaptureImage); timeLapseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TimeLapseDialog(); } }); pauseVideoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pauseVideoRecording(); } }); stopVideoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onShutterClick(); } }); if (snapshotSupported) { takePictureButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { takePicture(); } }); } for (int j = 0; j < specialView.size(); j++) { View view = specialView.get(j); int view_id = view.getId(); if (view_id == this.buttonsLayout.getId()) { if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); specialLayout.removeView(view); } } params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.videobuttons_size); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2)) .addView(this.buttonsLayout, params); this.buttonsLayout.setLayoutParams(params); if (snapshotSupported) { takePictureButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation()); takePictureButton.invalidate(); // takePictureButton.requestLayout(); displayTakePicture = true; } else { takePictureButton.setVisibility(View.GONE); displayTakePicture = false; } timeLapseButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation()); if (this.modeDRO() || CameraController.isRemoteCamera()) { takePictureButton.setVisibility(View.GONE); timeLapseButton.setVisibility(View.GONE); } if (prefs.getBoolean("videoStartStandardPref", false)) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: PluginManager.getInstance().onPause(true); Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); ApplicationScreen.instance.startActivity(intent); break; case DialogInterface.BUTTON_NEGATIVE: // No button clicked break; default: break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationScreen.instance); builder.setMessage("You selected to start standard camera. Start camera?") .setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener) .show(); } rotatorLayout = inflator.inflate(R.layout.plugin_capture_video_lanscaperotate_layout, null, false); rotatorLayout.setVisibility(View.VISIBLE); initRotateNotification(videoOrientation); List<View> specialViewRotator = new ArrayList<View>(); RelativeLayout specialLayoutRotator = (RelativeLayout) ApplicationScreen.instance .findViewById(R.id.specialPluginsLayout); for (int i = 0; i < specialLayoutRotator.getChildCount(); i++) specialViewRotator.add(specialLayoutRotator.getChildAt(i)); for (int j = 0; j < specialViewRotator.size(); j++) { View view = specialViewRotator.get(j); int view_id = view.getId(); int layout_id = this.rotatorLayout.getId(); if (view_id == layout_id) { if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); specialLayoutRotator.removeView(view); } } RelativeLayout.LayoutParams paramsRotator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsRotator.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size); paramsRotator.addRule(RelativeLayout.CENTER_IN_PARENT); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout)) .addView(this.rotatorLayout, paramsRotator); }
From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override/* ww w . java 2s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LOG_TAG, "onCreate() : " + savedInstanceState); setContentView(R.layout.activity_jet_pack_elf); // App Invites mInvitesFragment = AppInvitesFragment.getInstance(this); // App Measurement mMeasurement = FirebaseAnalytics.getInstance(this); MeasurementManager.recordScreenView(mMeasurement, getString(R.string.analytics_screen_rocket)); // [ANALYTICS SCREEN]: Rocket Sleigh AnalyticsManager.initializeAnalyticsTracker(this); AnalyticsManager.sendScreenView(R.string.analytics_screen_rocket); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ImmersiveModeHelper.setImmersiveSticky(getWindow()); ImmersiveModeHelper.installSystemUiVisibilityChangeListener(getWindow()); } mIntroVideo = (VideoView) findViewById(R.id.intro_view); mIntroControl = findViewById(R.id.intro_control_view); if (savedInstanceState == null) { String path = "android.resource://" + getPackageName() + "/" + R.raw.jp_background; mBackgroundPlayer = new MediaPlayer(); try { mBackgroundPlayer.setDataSource(this, Uri.parse(path)); mBackgroundPlayer.setLooping(true); mBackgroundPlayer.prepare(); mBackgroundPlayer.start(); } catch (IOException e) { e.printStackTrace(); } boolean nomovie = false; if (getIntent().getBooleanExtra("nomovie", false)) { nomovie = true; } else if (Build.MANUFACTURER.toUpperCase().contains("SAMSUNG")) { // nomovie = true; } if (!nomovie) { mIntroControl.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { endIntro(); } }); path = "android.resource://" + getPackageName() + "/" + R.raw.intro_wipe; mIntroVideo.setVideoURI(Uri.parse(path)); mIntroVideo.setOnCompletionListener(this); mIntroVideo.start(); mMoviePlaying = true; } else { mIntroControl.setOnClickListener(null); mIntroControl.setVisibility(View.GONE); mIntroVideo.setVisibility(View.GONE); } } else { mIntroControl.setOnClickListener(null); mIntroControl.setVisibility(View.GONE); mIntroVideo.setVisibility(View.GONE); } mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // For hit indication. mHandler = new Handler(); // Get the main UI handler for posting update events DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); Log.d(LOG_TAG, "Width: " + dm.widthPixels + " Height: " + dm.heightPixels + " Density: " + dm.density); mScreenHeight = dm.heightPixels; mScreenWidth = dm.widthPixels; mSlotWidth = mScreenWidth / SLOTS_PER_SCREEN; // Setup the random number generator mRandom = new Random(); mRandom.setSeed(System.currentTimeMillis()); // This is ok. We are not looking for cryptographically secure random here! mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Setup the background/foreground mBackgroundLayout = (LinearLayout) findViewById(R.id.background_layout); mBackgroundScroll = (HorizontalScrollView) findViewById(R.id.background_scroll); mForegroundLayout = (LinearLayout) findViewById(R.id.foreground_layout); mForegroundScroll = (HorizontalScrollView) findViewById(R.id.foreground_scroll); mBackgrounds = new Bitmap[6]; mBackgrounds2 = new Bitmap[6]; mExitTransitions = new Bitmap[6]; mEntryTransitions = new Bitmap[6]; // Need to vertically scale background to fit the screen. Checkthe image size // compared to screen size and scale appropriately. We will also use the matrix to translate // as we move through the level. Bitmap bmp = BitmapFactory.decodeResource(getResources(), BACKGROUNDS[0]); Log.d(LOG_TAG, "Bitmap Width: " + bmp.getWidth() + " Height: " + bmp.getHeight() + " Screen Width: " + dm.widthPixels + " Height: " + dm.heightPixels); mScaleY = (float) dm.heightPixels / (float) bmp.getHeight(); mScaleX = (float) (dm.widthPixels * 2) / (float) bmp.getWidth(); // Ensure that a single bitmap is 2 screens worth of time. (Stock xxhdpi image is 3840x1080) if ((mScaleX != 1.0f) || (mScaleY != 1.0f)) { Bitmap tmp = Bitmap.createScaledBitmap(bmp, mScreenWidth * 2, mScreenHeight, false); if (tmp != bmp) { bmp.recycle(); bmp = tmp; } } BackgroundLoadTask.createTwoBitmaps(bmp, mBackgrounds, mBackgrounds2, 0); // Load the initial background view addNextImages(0); addNextImages(0); mWoodObstacles = new TreeMap<Integer, Bitmap>(); mWoodObstacleList = new ArrayList<Integer>(); mWoodObstacleIndex = 0; // We need the bitmaps, so we do pre-load here synchronously. initObstaclesAndPreLoad(WOOD_OBSTACLES, 3, mWoodObstacles, mWoodObstacleList); mCaveObstacles = new TreeMap<Integer, Bitmap>(); mCaveObstacleList = new ArrayList<Integer>(); mCaveObstacleIndex = 0; initObstacles(CAVE_OBSTACLES, 2, mCaveObstacleList); mFactoryObstacles = new TreeMap<Integer, Bitmap>(); mFactoryObstacleList = new ArrayList<Integer>(); mFactoryObstacleIndex = 0; initObstacles(FACTORY_OBSTACLES, 2, mFactoryObstacleList); // Setup the elf mElf = (ImageView) findViewById(R.id.elf_image); mThrust = (ImageView) findViewById(R.id.thrust_image); mElfLayout = (LinearLayout) findViewById(R.id.elf_container); loadElfImages(); updateElf(false); // Elf should be the same height relative to the height of the screen on any platform. Matrix scaleMatrix = new Matrix(); mElfScale = ((float) dm.heightPixels * 0.123f) / (float) mElfBitmap.getHeight(); // On a 1920x1080 xxhdpi screen, this makes the elf 133 pixels which is the height of the drawable. scaleMatrix.preScale(mElfScale, mElfScale); mElf.setImageMatrix(scaleMatrix); mThrust.setImageMatrix(scaleMatrix); mElfPosX = (dm.widthPixels * 15) / 100; // 15% Into the screen mElfPosY = (dm.heightPixels - ((float) mElfBitmap.getHeight() * mElfScale)) / 2; // About 1/2 way down. mElfVelX = (float) dm.widthPixels / 3000.0f; // We start at 3 seconds for a full screen to scroll. mGravityAccelY = (float) (2 * dm.heightPixels) / (float) Math.pow((1.2 * 1000.0), 2.0); // a = 2*d/t^2 Where d = height in pixels and t = 1.2 seconds mThrustAccelY = (float) (2 * dm.heightPixels) / (float) Math.pow((0.7 * 1000.0), 2.0); // a = 2*d/t^2 Where d = height in pixels and t = 0.7 seconds // Setup the control view mControlView = findViewById(R.id.control_view); mGestureDetector = new GestureDetector(this, this); mGestureDetector.setIsLongpressEnabled(true); mGestureDetector.setOnDoubleTapListener(this); mScoreLabel = getString(R.string.score); mScoreText = (TextView) findViewById(R.id.score_text); mScoreText.setText("0"); mPlayPauseButton = (ImageView) findViewById(R.id.play_pause_button); mExit = (ImageView) findViewById(R.id.exit); // Is Tv? mIsTv = TvUtil.isTv(this); if (mIsTv) { mScoreText.setText(mScoreLabel + ": 0"); mPlayPauseButton.setVisibility(View.GONE); mExit.setVisibility(View.GONE); // move scoreLayout position to the Top-Right corner. View scoreLayout = findViewById(R.id.score_layout); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) scoreLayout.getLayoutParams(); params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); final int marginTop = getResources().getDimensionPixelOffset(R.dimen.overscan_margin_top); final int marginLeft = getResources().getDimensionPixelOffset(R.dimen.overscan_margin_left); params.setMargins(marginLeft, marginTop, 0, 0); scoreLayout.setLayoutParams(params); scoreLayout.setBackground(null); scoreLayout.findViewById(R.id.score_text_seperator).setVisibility(View.GONE); } else { mPlayPauseButton.setEnabled(false); mPlayPauseButton.setOnClickListener(this); mExit.setOnClickListener(this); } mBigPlayButtonLayout = findViewById(R.id.big_play_button_layout); mBigPlayButtonLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // No interaction with the screen below this one. return true; } }); mBigPlayButton = (ImageButton) findViewById(R.id.big_play_button); mBigPlayButton.setOnClickListener(this); // For showing points when getting presents. mPlus100 = (ImageView) findViewById(R.id.plus_100); m100Anim = new AlphaAnimation(1.0f, 0.0f); m100Anim.setDuration(1000); m100Anim.setFillBefore(true); m100Anim.setFillAfter(true); mPlus500 = (ImageView) findViewById(R.id.plus_500); m500Anim = new AlphaAnimation(1.0f, 0.0f); m500Anim.setDuration(1000); m500Anim.setFillBefore(true); m500Anim.setFillAfter(true); // Get the obstacle layouts ready. No obstacles on the first screen of a level. // Prime with a screen full of obstacles. mObstacleLayout = (LinearLayout) findViewById(R.id.obstacles_layout); mObstacleScroll = (HorizontalScrollView) findViewById(R.id.obstacles_scroll); // Initialize the present bitmaps. These are used repeatedly so we keep them loaded. mGiftBoxes = new Bitmap[GIFT_BOXES.length]; for (int i = 0; i < GIFT_BOXES.length; i++) { mGiftBoxes[i] = BitmapFactory.decodeResource(getResources(), GIFT_BOXES[i]); } // Add starting obstacles. First screen has presents. Next 3 get obstacles. addFirstScreenPresents(); // addFinalPresentRun(); // This adds 2 screens of presents // addNextObstacles(0, 1); addNextObstacles(0, 3); // Setup the sound pool mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); mSoundPool.setOnLoadCompleteListener(this); mCrashSound1 = mSoundPool.load(this, R.raw.jp_crash_1, 1); mCrashSound2 = mSoundPool.load(this, R.raw.jp_crash_2, 1); mCrashSound3 = mSoundPool.load(this, R.raw.jp_crash_3, 1); mGameOverSound = mSoundPool.load(this, R.raw.jp_game_over, 1); mJetThrustSound = mSoundPool.load(this, R.raw.jp_jet_thrust, 1); mLevelUpSound = mSoundPool.load(this, R.raw.jp_level_up, 1); mScoreBigSound = mSoundPool.load(this, R.raw.jp_score_big, 1); mScoreSmallSound = mSoundPool.load(this, R.raw.jp_score_small, 1); mJetThrustStream = 0; if (!mMoviePlaying) { doCountdown(); } }
From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); dialog = new ProgressDialog(this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentViewLayout = new RelativeLayout(ResourcePlayer.this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); token = prefsPrivate.getString("token", ""); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); Bundle extra = getIntent().getExtras(); if (extra != null) { value = extra.getInt("key"); gooruOID1 = extra.getStringArrayList("goor"); searchkeyword = extra.getString("searchkey"); limit = gooruOID1.size();/*from w w w .ja v a 2 s. c o m*/ gooruOID = gooruOID1.get(value); resourceGooruId = gooruOID; if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) { if (checkInternetConnection()) { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("Please wait while loading..."); dialog.setCancelable(false); dialog.show(); new getResourcesInfo().execute(); } else { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("No internet connection"); dialog.show(); } } } Editor prefsPrivateEditor = prefsPrivate.edit(); // Authentication details prefsPrivateEditor.putString("searchkeyword", searchkeyword); prefsPrivateEditor.commit(); wvPlayer = new WebView(ResourcePlayer.this); wvPlayer.resumeTimers(); wvPlayer.getSettings().setJavaScriptEnabled(true); wvPlayer.getSettings().setPluginState(PluginState.ON); wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); wvPlayer.setWebViewClient(new HelloWebViewClient()); wvPlayer.setWebChromeClient(new MyWebChromeClient() { }); wvPlayer.getSettings().setPluginsEnabled(true); new getResourcesInfo().execute(); RelativeLayout temp = new RelativeLayout(ResourcePlayer.this); temp.setId(668); temp.setBackgroundColor(getResources().getColor(android.R.color.transparent)); header = new RelativeLayout(ResourcePlayer.this); header.setId(1); header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, 53); headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1); ivCloseIcon = new ImageView(ResourcePlayer.this); ivCloseIcon.setId(130); ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50); ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); ivCloseIcon.setPadding(0, 0, 0, 0); ivCloseIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner)); header.addView(ivCloseIcon, ivCloseIconIconParams); ivmoveforward = new ImageView(ResourcePlayer.this); ivmoveforward.setId(222); if (value == limit - 1) { ivmoveforward.setVisibility(View.GONE); } ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0); imageshare = new ImageView(ResourcePlayer.this); imageshare.setId(440); imageshare.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50); imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); imageshareIconParams.setMargins(0, 10, 100, 0); tvDescriptionn = new TextView(ResourcePlayer.this); tvDescriptionn1 = new TextView(ResourcePlayer.this); edittext_copyurl = new EditText(ResourcePlayer.this); imageshare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (desc == 0) { new getShortUrl().execute(); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected)); subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); tvDescriptionn.setVisibility(View.VISIBLE); tvDescriptionn1.setVisibility(View.VISIBLE); edittext_copyurl.setVisibility(View.VISIBLE); tvDescriptionn.setText("Share this with other by copying and pasting these links"); tvDescriptionn.setId(221); tvDescriptionn.setTextSize(18); tvDescriptionn.setTypeface(null, Typeface.BOLD); tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); subheader.addView(tvDescriptionn, tvDescriptionParams); tvDescriptionn1.setText("Collections"); tvDescriptionn1.setId(226); tvDescriptionn1.setTextSize(18); tvDescriptionn1.setTypeface(null, Typeface.BOLD); tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams1.setMargins(20, 42, 0, 20); subheader.addView(tvDescriptionn1, tvDescriptionParams1); edittext_copyurl.setId(266); edittext_copyurl.setTextSize(18); edittext_copyurl.setTypeface(null, Typeface.BOLD); edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams11.setMargins(130, 35, 0, 20); subheader.addView(edittext_copyurl, tvDescriptionParams11); desc = 1; flag = 0; } else { imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); subheader.removeAllViews(); subheader.setVisibility(View.GONE); desc = 0; } } }); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); ivmoveforward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (value < limit - 1) { Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); // extras.putString("gooruOId",s); extras.putStringArrayList("goor", gooruOID1); value++; extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright)); ivmoveback = new ImageView(ResourcePlayer.this); ivmoveback.setId(220); if (value == 0) { ivmoveback.setVisibility(View.GONE); } ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmovebackIconIconParams.setMargins(55, 0, 0, 0); ivmoveback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!(value <= 0)) { value--; Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); extras.putStringArrayList("goor", gooruOID1); extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left)); webViewBack = new ImageView(ResourcePlayer.this); webViewBack.setId(323); webViewBack.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26); webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewBackIconParams.setMargins(175, 0, 0, 0); webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive)); webViewBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoBack()) { wvPlayer.goBack(); } } }); webViewRefresh = new ImageView(ResourcePlayer.this); webViewRefresh.setId(322); webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30); webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewRefreshIconParams.setMargins(305, 0, 0, 0); webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh)); webViewRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wvPlayer.reload(); } }); webViewForward = new ImageView(ResourcePlayer.this); webViewForward.setId(321); webViewForward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26); webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParams.setMargins(245, 0, 0, 0); webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive)); webViewForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoForward()) { wvPlayer.goForward(); } } }); ivResourceIcon = new ImageView(ResourcePlayer.this); ivResourceIcon.setId(30); ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25); ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130); ivResourceIcon.setPadding(50, 0, 0, 0); ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts)); header.addView(ivResourceIcon, ivResourceIconParams); tvLearn = new TextView(this); tvLearn.setText("Learn More"); tvLearn.setId(20); tvLearn.setPadding(100, 0, 0, 0); tvLearn.setTextSize(20); tvLearn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); tvAbout = new ImageView(ResourcePlayer.this); tvAbout.setId(21); tvAbout.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32); webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParamsa.setMargins(0, 0, 200, 0); tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info)); header.addView(tvAbout, webViewForwardIconParamsa); RelativeLayout fortvtitle = new RelativeLayout(this); RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322); tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21); header.addView(fortvtitle, tvTitleParams); tvTitle = new TextView(this); tvTitle.setText(""); tvTitle.setId(22); tvTitle.setPadding(0, 0, 0, 0); tvTitle.setTextSize(25); tvTitle.setSingleLine(true); tvTitle.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1); fortvtitle.addView(tvTitle, tvTitleParamstv); tvViewsNLikes = new TextView(this); tvViewsNLikes.setText(""); tvViewsNLikes.setId(23); tvViewsNLikes.setPadding(0, 0, 5, 5); tvViewsNLikes.setTextSize(18); tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); subheader = new RelativeLayout(ResourcePlayer.this); subheader.setId(100); subheader.setVisibility(View.GONE); subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, 100); subheaderParams.addRule(RelativeLayout.BELOW, 1); subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); wvPlayerParams.addRule(RelativeLayout.BELOW, 100); wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100); LinearLayout videoLayout = new LinearLayout(this); videoLayout.setVisibility(View.GONE); header.addView(webViewBack, webViewBackIconParams); header.addView(webViewRefresh, webViewRefreshIconParams); header.addView(webViewForward, webViewForwardIconParams); header.addView(ivmoveforward, ivmoveforwardIconIconParams); header.addView(imageshare, imageshareIconParams); header.addView(ivmoveback, ivmovebackIconIconParams); temp.addView(header, headerParams); temp.addView(subheader, subheaderParams); temp.addView(wvPlayer, wvPlayerParams); temp.addView(videoLayout, wvPlayerParams); setContentViewLayout.addView(temp, layoutParams); setContentView(setContentViewLayout); tvDescription = new TextView(ResourcePlayer.this); tvDescription1 = new TextView(ResourcePlayer.this); tvAbout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (flag == 0) { subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); // tvDescriptionn.setVisibility(View.INVISIBLE); tvDescription1.setVisibility(View.VISIBLE); tvDescription.setVisibility(View.VISIBLE); tvDescription.setText("Description"); tvDescription.setId(221); tvDescription.setTextSize(18); tvDescription.setTypeface(null, Typeface.BOLD); tvDescription.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); tvDescriptionParams.addRule(RelativeLayout.BELOW, 220); tvDescription1.setText(description); tvDescription1.setLines(3); tvDescription1.setId(321); tvDescription1.setTextSize(15); tvDescription1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100); tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1); tvDescription1.setPadding(100, 20, 100, 0); subheader.addView(tvDescription1, tvDescription1Params); desc = 0; flag = 1; flag1 = 0; } else { subheader.removeAllViews(); subheader.setVisibility(View.GONE); flag = 0; } } }); }
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
/** * Lays out the body using the back images. *//*from w ww . java 2 s . c o m*/ private void setMaleBack() { front = false; RelativeLayout.LayoutParams lp; lp = new RelativeLayout.LayoutParams(dipToPixels(42), dipToPixels(65)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(303); head.setLayoutParams(lp); head.setBackground(getResources().getDrawable(R.drawable.male_head_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(58), dipToPixels(102)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(205); torso.setLayoutParams(lp); torso.setBackground(getResources().getDrawable(R.drawable.male_torso_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(66), dipToPixels(34)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(174); shorts.setLayoutParams(lp); shorts.setBackground(getResources().getDrawable(R.drawable.male_butt_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(39), dipToPixels(73)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(108); lp.leftMargin = dipToPixels(141); r_top.setLayoutParams(lp); r_top.setBackground(getResources().getDrawable(R.drawable.male_leftthigh_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(22), dipToPixels(72)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(42); lp.leftMargin = dipToPixels(137); r_bot.setLayoutParams(lp); r_bot.setBackground(getResources().getDrawable(R.drawable.male_leftcalf_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(20), dipToPixels(41)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(3); lp.leftMargin = dipToPixels(129); r_foot.setLayoutParams(lp); r_foot.setBackground(getResources().getDrawable(R.drawable.male_leftfoot_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(39), dipToPixels(71)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(107); lp.leftMargin = dipToPixels(180); l_top.setLayoutParams(lp); l_top.setBackground(getResources().getDrawable(R.drawable.male_rightthigh_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(22), dipToPixels(72)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(41); lp.leftMargin = dipToPixels(201); l_bot.setLayoutParams(lp); l_bot.setBackground(getResources().getDrawable(R.drawable.male_rightcalf_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(20), dipToPixels(41)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(2); lp.leftMargin = dipToPixels(211); l_foot.setLayoutParams(lp); l_foot.setBackground(getResources().getDrawable(R.drawable.male_rightfoot_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(71), dipToPixels(91)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(215); lp.leftMargin = dipToPixels(87); r_arm.setLayoutParams(lp); r_arm.setBackground(getResources().getDrawable(R.drawable.male_leftarm_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(35), dipToPixels(35)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(186); lp.leftMargin = dipToPixels(61); r_hand.setLayoutParams(lp); r_hand.setBackground(getResources().getDrawable(R.drawable.male_lefthand_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(71), dipToPixels(91)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(215); lp.leftMargin = dipToPixels(200); l_arm.setLayoutParams(lp); l_arm.setBackground(getResources().getDrawable(R.drawable.male_rightarm_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(35), dipToPixels(35)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(185); lp.leftMargin = dipToPixels(263); l_hand.setLayoutParams(lp); l_hand.setBackground(getResources().getDrawable(R.drawable.male_righthand_back_3x)); bodyLayout.invalidate(); }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { getWindow().setBackgroundDrawableResource(R.drawable.chat_bg); // this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); recipientStkid = getIntent().getExtras().getString("recipientStkid"); chatRecipient = getIntent().getExtras().getString("chatRecipient"); chatRecipientUrl = getIntent().getExtras().getString("chatRecipientUrl"); senderToken = getIntent().getExtras().getString("senderToken"); recipientToken = getIntent().getExtras().getString("recipientToken"); noti = getIntent().getExtras().getBoolean("noti"); message = getIntent().getExtras().getString("message"); rows = getIntent().getExtras().getInt("rows"); flagChatting = true;/*from w w w . j a v a 2 s . co m*/ pref = PreferenceManager.getDefaultSharedPreferences(this); offerId = 0; offerStatus = 0; ws = new JsonWebService(); dbHelper = new DBHelper(this); dialog = new ProgressDialog(this); listChatContact = new ArrayList<>(); listChatContact = dbHelper.getChatContact(); Log.i(" Chat Contact ", " " + listChatContact.size()); metrics = this.getResources().getDisplayMetrics(); //to change font faceSemi_bold = Typeface.createFromAsset(getAssets(), fontOSSemi_bold); Typeface faceLight = Typeface.createFromAsset(getAssets(), fontOSLight); faceRegular = Typeface.createFromAsset(getAssets(), fontOSRegular); imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) { imageLoader.init(ImageLoaderConfiguration.createDefault(this)); } start = new Date(); SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm"); timeSend = oFormat.format(start); super.onCreate(savedInstanceState); setContentView(R.layout.chat); layoutTalk = (LinearLayout) findViewById(R.id.layoutTalk); txtUserName = (TextView) findViewById(R.id.txtChatName); edTxtMsg = (EditText) findViewById(R.id.edTxtMsg); imgViewProfile = (ImageView) findViewById(R.id.imgViewChat); imgViewAddCon = (ImageView) findViewById(R.id.imgAddContact); lv = (ListView) findViewById(R.id.listView1); layoutLabel = (LinearLayout) findViewById(R.id.layoutLabel); txtLabel1 = (TextView) findViewById(R.id.txtLabel1); txtLabel2 = (TextView) findViewById(R.id.txtLabel2); txtLabel3 = (TextView) findViewById(R.id.txtLabel3); txtLabel2.setText(" " + chatRecipient + " "); txtLabel1.setTypeface(faceLight); txtLabel2.setTypeface(faceRegular); txtLabel3.setTypeface(faceLight); for (ChatContact contact : listChatContact) { if (contact.getContactId().equals(recipientStkid)) { imgViewAddCon.setVisibility(View.INVISIBLE); layoutLabel.setVisibility(View.GONE); break; } } Log.i(TAG, " come back again"); adapter = new ChatArrayAdapter(this, R.layout.chatting_listview, faceSemi_bold, faceRegular, recipientStkid, senderToken, recipientToken); lv.setAdapter(adapter); // adapter.add(new StikyChat(chatRecipientUrl, "Hello", false, "12.10.2015", "12.1.2014")); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); // BEGIN_INCLUDE (change_colors) // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids swipeRefreshLayout.setColorScheme(R.color.swipe_color_1, R.color.swipe_color_2, R.color.swipe_color_3, R.color.swipe_color_4); limitMsg = 7; // END_INCLUDE (change_colors) swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.i(" Refresh Layout ", "onRefresh called from SwipeRefreshLayout"); if (limitMsg < rows) { Log.i("Limit Message ", " " + limitMsg); limitMsg *= 2; fetchRecords(); } else if ((!(rows <= 7)) && limitMsg > rows && (limitMsg - rows < 7)) { fetchRecords(); } else { Log.i("No data ", "to refresh"); swipeRefreshLayout.setRefreshing(false); Toast.makeText(getApplicationContext(), "No data to refresh!", Toast.LENGTH_SHORT).show(); } // initiateRefresh(); } }); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout headerLayout = (LinearLayout) findViewById(R.id.header); View header = inflator.inflate(R.layout.header, null); TextView textView = (TextView) header.findViewById(R.id.textView1); textView.setText("StikyChat"); textView.setTypeface(faceSemi_bold); textView.setVisibility(View.VISIBLE); headerLayout.addView(header); LinearLayout layoutRight = (LinearLayout) header.findViewById(R.id.layoutRight); layoutRight.setVisibility(View.GONE); txtUserName.setText(chatRecipient); Log.i(TAG, "Activity Name " + txtUserName.getText().toString()); txtUserName.setTypeface(faceSemi_bold); String url = ""; Log.i(TAG, " ^^^ " + chatRecipientUrl + " "); if (chatRecipientUrl != null) { if (chatRecipientUrl.contains("http")) { url = chatRecipientUrl; } else if (chatRecipientUrl != "null") { url = this.getResources().getString(R.string.url) + "/" + chatRecipientUrl; } } addAndroidUniversalImageLoader(imgViewProfile, url); // if (noti && (!message.equals(""))) { // adapter.add(new StikyChat(chatRecipientUrl, message, true, timeSend, "")); // lv.smoothScrollToPosition(adapter.getCount() - 1); // } //to show history chats between two users(sender & recipient) dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat2 = new SimpleDateFormat("dd MMM HH:mm"); listHistory = dbHelper.getStikyChat(); if (listHistory.size() > 0) { Collections.reverse(listHistory); for (final StikyChatTb chatTb : listHistory) { String getDate = chatTb.getSendDate(); String durationStr = null; String fromStikyBee = chatTb.getSender(); try { final String createDate = dateFormat2.format(dateFormat.parse(getDate)); if (chatTb.getFileName().contains("voice")) { MediaPlayer mPlayer = new MediaPlayer(); String voiceFileName = getResources().getString(R.string.url) + "/" + chatTb.getFileName(); try { mPlayer.setDataSource(voiceFileName); mPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); } //mPlayer.start(); int duration = mPlayer.getDuration(); mPlayer.release(); duration = (int) Math.ceil(duration / 1024); if (duration < 10) { durationStr = "00:0" + duration; } else { durationStr = "00:" + duration; } // Log.i(TAG, "Duration Srt " + durationStr); } if (fromStikyBee.equals(pref.getString("stkid", ""))) { //String url1 = getResources().getString(R.string.url) + "/" + chatTb.getFileName(); // Log.i(TAG, " Offer Id " + chatTb.getOfferId() + " Price " + chatTb.getPrice() + " Name " + chatTb.getName()); //first false = right, second false = Offer // Log.i(TAG, " Duration " + chatTb.getRate() + " File Name " + chatTb.getFileName()); if (!chatTb.getFileName().contains("voice")) { Log.i(TAG, " Voice is not "); adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(), chatTb.getPrice(), chatTb.getRate(), chatTb.getName(), null, chatTb.getOriFName())); } else { Log.i(TAG, " Voice is "); adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(), chatTb.getPrice(), chatTb.getRate(), durationStr, null, chatTb.getOriFName())); } } else { /* Bitmap bmImg = BitmapFactory.decodeFile(getResources().getString(R.string.url) + "/" + chatTb.getFileName()); Bitmap resBm = getResizedBitmap(bmImg, 500);*/ // String url1 = getResources().getString(R.string.url) + "/" + chatTb.getFileName(); if (!chatTb.getFileName().contains("voice")) { adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(), chatTb.getPrice(), chatTb.getRate(), chatTb.getName(), null, chatTb.getOriFName())); } else { adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(), chatTb.getPrice(), chatTb.getRate(), durationStr, null, chatTb.getOriFName())); } } lv.smoothScrollToPosition(adapter.getCount() - 1); } catch (ParseException e) { e.printStackTrace(); } } } mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); fileNameGCM = sharedPreferences.getString("fileName", ""); messageGCM = sharedPreferences.getString("message", ""); offerIdGCM = sharedPreferences.getInt("offerId", 0); offerStatusGCM = sharedPreferences.getInt("offerStatus", 0); priceGCM = sharedPreferences.getString("price", ""); rateGCM = sharedPreferences.getString("rate", ""); nameGCM = sharedPreferences.getString("name", ""); recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", ""); recipientNameGCM = sharedPreferences.getString("chatRecipientName", ""); recipientStkidGCM = sharedPreferences.getString("recipientStkid", ""); recipientTokenGCM = sharedPreferences.getString("recipientToken", ""); senderTokenGCM = sharedPreferences.getString("senderToken", ""); Log.i(TAG, " FileName GCM " + fileNameGCM + " " + " Name Rate Price &&&&& *** " + messageGCM + " " + priceGCM + " " + rateGCM); if (firstConnect) { if (recipientStkidGCM.trim() == recipientStkid.trim() || recipientStkidGCM.equals(recipientStkid)) { MyGcmListenerService.flagSendNoti = false; Log.i(TAG, " " + message); // (1) get today's date start = new Date(); SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm"); timeSend = oFormat.format(start); Log.i(TAG, "First connect " + firstConnect); Log.i(TAG, " File Name GCMMMMMM " + fileNameGCM); /*if (!fileNameGCM.equals("") && !fileNameGCM.equals("null") && !fileNameGCM.equals(null)) { oriFName = saveFileAndImage(fileNameGCM); }*/ /*if (fileNameGCM.contains("voice")) { String durationStr; MediaPlayer mPlayer = new MediaPlayer(); String voiceFileName = getResources().getString(R.string.url) + "/" + fileNameGCM; try { mPlayer.setDataSource(voiceFileName); mPlayer.prepare(); } catch (IOException e) { e.printStackTrace(); } //mPlayer.start(); int duration = mPlayer.getDuration(); mPlayer.release(); duration = (int) Math.ceil(duration / 1024); if (duration < 10) { durationStr = "00:0" + duration; } else { durationStr = "00:" + duration; } StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, fileNameGCM.trim(), offerIdGCM, offerStatusGCM, priceGCM, rateGCM, durationStr, null, oriFName); adapter.add(stikyChat); } else {*/ StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, fileNameGCM.trim(), offerIdGCM, offerStatusGCM, priceGCM, rateGCM, nameGCM, null, oriFName); adapter.add(stikyChat); // } Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend); Log.i(TAG, "User " + txtUserName.getText().toString()); adapter.notifyDataSetChanged(); lv.setSelection(adapter.getCount() - 1); new regTask2().execute("Obj "); } else { /* if (!fileNameGCM.equals("") && !fileNameGCM.equals("null") && !fileNameGCM.equals(null)) { saveFileAndImage(fileNameGCM); }*/ Log.i(TAG, "..." + recipientStkidGCM.trim()); Log.i(TAG, "&&&" + recipientStkid.trim()); Log.i(TAG, "else casee"); //notificaton send flagNotifi = true; new regTask2().execute("Notification"); } firstConnect = false; } lv.setSelection(adapter.getCount() - 1); } }; /*edTxtMsg.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutTalk.setLayoutParams(params); layoutTalk.setGravity(Gravity.CENTER); Toast.makeText(getBaseContext(), ((EditText) v).getId() + " has focus - " + hasFocus, Toast.LENGTH_LONG).show(); } });*/ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); edTxtMsg.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 0); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutTalk.setLayoutParams(params); layoutTalk.setGravity(Gravity.CENTER); flagRecord = false; /*getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE );*/ Toast.makeText(getBaseContext(), "Touch ...", Toast.LENGTH_LONG).show(); return false; } }); }
From source file:com.palmaplus.activity.MapDetailActivity.java
private void positionBaseContainer(int height) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mBaseBottomContainerHeight); params.bottomMargin = height;/* w w w .j a v a2 s. c om*/ params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mBaseBottomContainer.setLayoutParams(params); }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
/** * Aligns the Twitter icon the parent bottom right. Aligns the G+ icon to the left of the * Twitter icon if it is present. Otherwise, aligns the G+ icon to the parent bottom right. *///ww w . j av a2s .c om private void determineSocialIconPlacement(ImageView plusOneIcon, ImageView twitterIcon) { if (plusOneIcon.getVisibility() == View.VISIBLE) { // Set the dimensions of the G+ button. int socialIconDimension = getResources().getDimensionPixelSize(R.dimen.social_icon_box_size); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(socialIconDimension, socialIconDimension); params.addRule(RelativeLayout.BELOW, R.id.speaker_abstract); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); if (twitterIcon.getVisibility() == View.VISIBLE) { params.addRule(RelativeLayout.LEFT_OF, R.id.twitter_icon_box); } else { params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } plusOneIcon.setLayoutParams(params); } }
From source file:com.example.angel.parkpanda.MainActivity.java
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap;/*from w ww . j a v a2 s. c om*/ showTempLocation(googleMap); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } mMap.setMyLocationEnabled(true); mMap.setOnMarkerClickListener(this); mMap.getUiSettings().setZoomControlsEnabled(false); mMap.getUiSettings().setMapToolbarEnabled(false); View mapView = supportMapFragment.getView(); if (mapView != null && mapView.findViewById(1) != null) { // Get the button view View locationButton = ((View) mapView.findViewById(1).getParent()).findViewById(2); // and next place it, on bottom right (as Google Maps app) RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) locationButton .getLayoutParams(); // position on right bottom layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutParams.setMargins(0, 0, 30, 30); } mMap.setOnInfoWindowLongClickListener(new GoogleMap.OnInfoWindowLongClickListener() { @Override public void onInfoWindowLongClick(Marker marker) { initViewSetting(false); MyMarker myMarker = mMarkersHashMap.get(marker); Intent intent = new Intent(getApplicationContext(), paymentInterface.class); intent.putExtra("infokey", myMarker); startActivityForResult(intent, 35);// Activity is started with requestCode 2 } }); mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { initViewSetting(false); MyMarker myMarker = mMarkersHashMap.get(marker); Intent intent = new Intent(getApplicationContext(), paymentInterface.class); intent.putExtra("infokey", myMarker); startActivityForResult(intent, 35);// Activity is started with requestCode 2 } }); if (tempCameraPos != null) mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(tempCameraPos, 15.0f)); else { Location df = getLocation(); // df = mMap.getMyLocation(); if (df != null) mMap.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(df.getLatitude(), df.getLongitude()), 15.0f)); TRACKPOSITION.src_Pos = new LatLng(getLocation().getLatitude(), getLocation().getLongitude()); } }