List of usage examples for android.view Gravity FILL_HORIZONTAL
int FILL_HORIZONTAL
To view the source code for android.view Gravity FILL_HORIZONTAL.
Click Source Link
From source file:com.windnow.StationTextActivity.java
@SuppressLint("RtlHardcoded") private void printTableRow(String line) { TableLayout tl = (TableLayout) findViewById(R.id.tableLayout); String[] words = line.split("&/"); TableRow tr = new TableRow(this); TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from w w w .j av a 2 s . c om params.gravity = Gravity.FILL_HORIZONTAL; tr.setLayoutParams(params); TableRow.LayoutParams tvParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); tvParams.setMargins(0, 0, 6, 0); for (int i = words.length - 1; i >= 0; i--) { TextView txv = new TextView(this); txv.setLayoutParams(tvParams); txv.setText(words[i]); txv.setGravity(i == 0 ? Gravity.LEFT : Gravity.LEFT); tr.addView(txv, 0); } tl.addView(tr); }
From source file:de.baumann.hhsmoodle.helper.helper_main.java
public static void makeToast(Activity activity, String Text) { LayoutInflater inflater = activity.getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.toast, (ViewGroup) activity.findViewById(R.id.toast_root_view)); TextView header = (TextView) toastLayout.findViewById(R.id.toast_message); header.setText(Text);/*from w ww.j ava 2 s. c om*/ Toast toast = new Toast(activity.getApplicationContext()); toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(toastLayout); toast.show(); }
From source file:com.brookmanholmes.bma.wizard.ui.StepPagerStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (pageCount == 0) { return;//w ww. jav a2 s . c o m } float totalWidth = pageCount * (tabWidth + indicatorSpacing) - indicatorSpacing; float totalcx; float cy; boolean fillHorizontal = false; switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: totalcx = (getWidth() - totalWidth) / 2; break; case Gravity.RIGHT: totalcx = getWidth() - getPaddingRight() - totalWidth; break; case Gravity.FILL_HORIZONTAL: totalcx = getPaddingLeft(); fillHorizontal = true; break; default: totalcx = getPaddingLeft(); } switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.CENTER_VERTICAL: cy = (int) (getHeight() - tabHeight) / 2; break; case Gravity.BOTTOM: cy = getHeight() - getPaddingBottom() - tabHeight; break; default: cy = getPaddingTop(); } float center = cy + tabHeight / 2; float tabWidth = this.tabWidth; if (fillHorizontal) { tabWidth = (getWidth() - getPaddingRight() - getPaddingLeft() - (pageCount - 1) * indicatorSpacing) / pageCount; } for (int i = 0; i < pageCount; i++) { float cx = totalcx + (i * (tabWidth + indicatorSpacing)); Paint tempPaint; if (i < currentPage) tempPaint = prevTabPaint; else if (i > currentPage) tempPaint = nextTabPaint; else tempPaint = selectedTabPaint; canvas.drawCircle(cx, center, i == currentPage ? radius : nonCurrentRadius, tempPaint); } }
From source file:id.co.datascrip.dtswarehousesystem.custom.StepPagerStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mPageCount == 0) { return;/*from w w w. j av a 2s . c o m*/ } float totalWidth = mPageCount * (mTabWidth + mTabSpacing) - mTabSpacing; float totalLeft; boolean fillHorizontal = false; switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: totalLeft = (getWidth() - totalWidth) / 2; break; case Gravity.END: totalLeft = getWidth() - getPaddingRight() - totalWidth; break; case Gravity.FILL_HORIZONTAL: totalLeft = getPaddingLeft(); fillHorizontal = true; break; default: totalLeft = getPaddingLeft(); } switch (mGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.CENTER_VERTICAL: mTempRectF.top = (int) (getHeight() - mTabHeight) / 2; break; case Gravity.BOTTOM: mTempRectF.top = getHeight() - getPaddingBottom() - mTabHeight; break; default: mTempRectF.top = getPaddingTop(); } mTempRectF.bottom = mTempRectF.top + mTabHeight; float tabWidth = mTabWidth; if (fillHorizontal) { tabWidth = (getWidth() - getPaddingRight() - getPaddingLeft() - (mPageCount - 1) * mTabSpacing) / mPageCount; } for (int i = 0; i < mPageCount; i++) { mTempRectF.left = totalLeft + (i * (tabWidth + mTabSpacing)); mTempRectF.right = mTempRectF.left + tabWidth; canvas.drawRect(mTempRectF, i < mCurrentPage ? mPrevTabPaint : (i > mCurrentPage ? mNextTabPaint : (i == mPageCount - 1 ? mSelectedLastTabPaint : mSelectedTabPaint))); } }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*from w w w .ja v a2 s .c om*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bird_details_tab_layout); final String latinSpecies = getIntent().getExtras().getString(BirdListFragment.LATIN_SPECIES); final String englishSpecies = getIntent().getExtras().getString(BirdListFragment.ENGLISH_SPECIES); final String swedishFamily = getIntent().getExtras().getString(BirdListFragment.SWEDISH_FAMILY); Bundle bundle = new Bundle(1); bundle.putString(BirdSpeciesWebFragment.ENGLISH_SPECIES, englishSpecies); bundle.putString(BirdSpeciesXenoCantoPlayerFragment.LATIN_SPECIES, latinSpecies); tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); tabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout); tabHost.addTab(//from ww w . j a va 2 s . c o m tabHost.newTabSpec("Wikipedia").setIndicator(getText(R.string.tab_wikipedia), getResources().getDrawable(android.R.drawable.star_on)), BirdSpeciesWebFragment.class, bundle); tabHost.addTab( tabHost.newTabSpec("Flickr").setIndicator(getText(R.string.tab_photos), getResources().getDrawable(android.R.drawable.star_on)), BirdSpeciesFlickrGalleryFragment.class, bundle); tabHost.addTab( tabHost.newTabSpec("xeno-canto").setIndicator(getText(R.string.tab_sounds), getResources().getDrawable(android.R.drawable.star_on)), BirdSpeciesXenoCantoPlayerFragment.class, bundle); tabHost.addTab( tabHost.newTabSpec("Statistik").setIndicator(getText(R.string.tab_facts), getResources().getDrawable(android.R.drawable.star_on)), BirdSpeciesFactsFragment.class, bundle); tabHost.addTab(tabHost.newTabSpec("Karta").setIndicator(getText(R.string.tab_map), getResources().getDrawable(android.R.drawable.star_on)), MapFragment.class, bundle); TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs); LinearLayout linearLayout = (LinearLayout) tabWidget.getParent(); HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this); horizontalScrollView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); linearLayout.addView(horizontalScrollView, 0); linearLayout.removeView(tabWidget); horizontalScrollView.addView(tabWidget); horizontalScrollView.setHorizontalScrollBarEnabled(false); BirdListSpinnerAdapter birdListSpinnerAdapter = createAdapter(); birdListSpinnerAdapter.setFilterFamily(swedishFamily); birdListSpinnerAdapter.initialize(getSharedPreferences(Constants.BIRD_APP_SETTINGS, Context.MODE_PRIVATE)); if (BirdListAdapter.SortOption.PHYLOGENETIC.equals(birdListSpinnerAdapter.getSortOption())) { birdListSpinnerAdapter.setSortOption(BirdListAdapter.SortOption.SWEDISH); } birdListSpinnerAdapter.refresh(); birdListSpinnerAdapter.notifyDataSetChanged(); Spinner spinner = new Spinner(this); spinner.setId(R.id.birdspecies_spinner); spinner.setAdapter(birdListSpinnerAdapter); spinner.setGravity(Gravity.FILL_HORIZONTAL); spinner.setSelection(birdListSpinnerAdapter.getPosition(new Bird(latinSpecies))); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { BirdSpeciesFragment fragment = (BirdSpeciesFragment) getSupportFragmentManager() .findFragmentByTag(tabHost.getCurrentTabTag()); Spinner spinner = (Spinner) getActionBar().getCustomView().findViewById(R.id.birdspecies_spinner); fragment.loadBird((Bird) spinner.getSelectedItem()); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); getActionBar().setCustomView(spinner); getActionBar().setDisplayOptions( ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM); }
From source file:io.plaidapp.ui.DribbbleLogin.java
void showLoggedInUser() { final Call<User> authenticatedUser = dribbblePrefs.getApi().getAuthenticatedUser(); authenticatedUser.enqueue(new Callback<User>() { @Override/*from ww w .j av a2 s. c o m*/ public void onResponse(Call<User> call, Response<User> response) { final User user = response.body(); dribbblePrefs.setLoggedInUser(user); final Toast confirmLogin = new Toast(getApplicationContext()); final View v = LayoutInflater.from(DribbbleLogin.this) .inflate(R.layout.toast_logged_in_confirmation, null, false); ((TextView) v.findViewById(R.id.name)).setText(user.name.toLowerCase()); // need to use app context here as the activity will be destroyed shortly Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player) .transform(new CircleTransform(getApplicationContext())) .into((ImageView) v.findViewById(R.id.avatar)); v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable( ContextCompat.getColor(DribbbleLogin.this, R.color.scrim), 5, Gravity.BOTTOM)); confirmLogin.setView(v); confirmLogin.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0); confirmLogin.setDuration(Toast.LENGTH_LONG); confirmLogin.show(); } @Override public void onFailure(Call<User> call, Throwable t) { } }); }
From source file:org.mariotaku.twidere.util.TwidereActionModeForChildListener.java
ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) { if (mActionMode != null) { mActionMode.finish();//ww w . j a va 2s .co m } final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); if (mActionModeView == null) { if (mIsFloating && mUsePopup) { // Use the action bar theme. final Context actionBarContext; actionBarContext = ThemeUtils.getActionBarThemedContext(mActivity, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor()); mActionModeView = new ActionBarContextView(actionBarContext); mActionModePopup = new PopupWindow(actionBarContext, null, android.support.v7.appcompat.R.attr.actionModePopupWindowStyle); mActionModePopup.setContentView(mActionModeView); mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); final TypedValue outValue = new TypedValue(); actionBarContext.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, outValue, true); final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics()); mActionModeView.setContentHeight(height); ThemeUtils.setActionBarContextViewBackground(mActionModeView, mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor(), mThemed.getCurrentThemeBackgroundOption(), false); mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mShowActionModePopup = new Runnable() { @Override public void run() { mActionModePopup.showAtLocation(mWindow.getDecorView(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); } }; } else { mActionModeView = (ActionBarContextView) mWindow.findViewById(R.id.action_context_bar); } } if (mActionModeView != null) { mActionModeView.killMode(); ActionMode mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, wrappedCallback, mActionModePopup == null); if (callback.onCreateActionMode(mode, mode.getMenu())) { mode.invalidate(); mActionModeView.initForMode(mode); mActionModeView.setVisibility(View.VISIBLE); mActionMode = mode; if (mActionModePopup != null) { mWindow.getDecorView().post(mShowActionModePopup); } mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); if (mActionModeView.getParent() != null) { ViewCompat.requestApplyInsets((View) mActionModeView.getParent()); } } else { mActionMode = null; } } if (mActionMode != null && mAppCompatCallback != null) { mAppCompatCallback.onSupportActionModeStarted(mActionMode); } return mActionMode; }
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.SurveyFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (interaction == null) { getActivity().finish();//from w ww. j a va 2 s . co m } List<Question> questions = interaction.getQuestions(); answers = new LinkedHashMap<String, Object>(questions.size()); View v = inflater.inflate(R.layout.apptentive_survey, container, false); TextView description = (TextView) v.findViewById(R.id.description); description.setText(interaction.getDescription()); final Button send = (Button) v.findViewById(R.id.send); String sendText = interaction.getSubmitText(); if (!TextUtils.isEmpty(sendText)) { send.setText(sendText); } send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Util.hideSoftKeyboard(getActivity(), view); boolean valid = validateAndUpdateState(); if (valid) { if (interaction.isShowSuccessMessage() && !TextUtils.isEmpty(interaction.getSuccessMessage())) { Toast toast = new Toast(getContext()); toast.setGravity(Gravity.FILL, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); View toastView = inflater.inflate(R.layout.apptentive_survey_sent_toast, (LinearLayout) getView().findViewById(R.id.survey_sent_toast_root)); toast.setView(toastView); TextView actionTV = ((TextView) toastView.findViewById(R.id.survey_sent_action_text)); actionTV.setText(interaction.getSuccessMessage()); int actionColor = Util.getThemeColor(getContext(), R.attr.apptentiveSurveySentToastActionColor); if (actionColor != 0) { actionTV.setTextColor(actionColor); ImageView actionIcon = (ImageView) toastView.findViewById(R.id.survey_sent_action_icon); actionIcon.setColorFilter(actionColor); } toast.show(); } getActivity().finish(); EngagementModule.engageInternal(getActivity(), interaction, EVENT_SUBMIT); ApptentiveInternal.getInstance().getApptentiveTaskManager() .addPayload(new SurveyResponse(interaction, answers)); ApptentiveLog.d("Survey Submitted."); callListener(true); } else { Toast toast = new Toast(getContext()); toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); View toastView = inflater.inflate(R.layout.apptentive_survey_invalid_toast, (LinearLayout) getView().findViewById(R.id.survey_invalid_toast_root)); toast.setView(toastView); String validationText = interaction.getValidationError(); if (!TextUtils.isEmpty(validationText)) { ((TextView) toastView.findViewById(R.id.survey_invalid_toast_text)).setText(validationText); } toast.show(); } } }); questionsContainer = (LinearLayout) v.findViewById(R.id.questions); if (savedInstanceState == null) { questionsContainer.removeAllViews(); // Then render all the questions for (int i = 0; i < questions.size(); i++) { Question question = questions.get(i); BaseSurveyQuestionView surveyQuestionView; if (question.getType() == Question.QUESTION_TYPE_SINGLELINE) { surveyQuestionView = TextSurveyQuestionView.newInstance((SinglelineQuestion) question); } else if (question.getType() == Question.QUESTION_TYPE_MULTICHOICE) { surveyQuestionView = MultichoiceSurveyQuestionView.newInstance((MultichoiceQuestion) question); } else if (question.getType() == Question.QUESTION_TYPE_MULTISELECT) { surveyQuestionView = MultiselectSurveyQuestionView.newInstance((MultiselectQuestion) question); } else if (question.getType() == Question.QUESTION_TYPE_RANGE) { surveyQuestionView = RangeSurveyQuestionView.newInstance((RangeQuestion) question); } else { surveyQuestionView = null; } if (surveyQuestionView != null) { surveyQuestionView.setOnSurveyQuestionAnsweredListener(this); getRetainedChildFragmentManager().beginTransaction() .add(R.id.questions, surveyQuestionView, Integer.toString(i)).commit(); } } } else { List<Fragment> fragments = getRetainedChildFragmentManager().getFragments(); for (Fragment fragment : fragments) { BaseSurveyQuestionView questionFragment = (BaseSurveyQuestionView) fragment; questionFragment.setOnSurveyQuestionAnsweredListener(this); } } return v; }
From source file:com.brookmanholmes.bma.wizard.ui.StepPagerStrip.java
private int hitTest(float x) { if (pageCount == 0) { return -1; }//from w w w . ja va2s . c o m float totalWidth = pageCount * (tabWidth + indicatorSpacing) - indicatorSpacing; float totalLeft; boolean fillHorizontal = false; switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: totalLeft = (getWidth() - totalWidth) / 2; break; case Gravity.RIGHT: totalLeft = getWidth() - getPaddingRight() - totalWidth; break; case Gravity.FILL_HORIZONTAL: totalLeft = getPaddingLeft(); fillHorizontal = true; break; default: totalLeft = getPaddingLeft(); } float tabWidth = this.tabWidth; if (fillHorizontal) { tabWidth = (getWidth() - getPaddingRight() - getPaddingLeft() - (pageCount - 1) * indicatorSpacing) / pageCount; } float totalRight = totalLeft + (pageCount * (tabWidth + indicatorSpacing)); if (x >= totalLeft && x <= totalRight && totalRight > totalLeft) { return (int) (((x - totalLeft) / (totalRight - totalLeft)) * pageCount); } else { return -1; } }