List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.facebook.android.friendsmash.ScoreboardFragment.java
private void populateScoreboard() { // Ensure all components are firstly removed from scoreboardContainer scoreboardContainer.removeAllViews(); // Ensure the progress spinner is hidden progressContainer.setVisibility(View.INVISIBLE); // Ensure scoreboardEntriesList is not null and not empty first if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) { closeAndShowError(getResources().getString(R.string.error_no_scores)); } else {/*w ww. j a v a 2 s . com*/ // Iterate through scoreboardEntriesList, creating new UI elements for each entry int index = 0; Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator(); while (scoreboardEntriesIterator.hasNext()) { // Get the current scoreboard entry final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next(); // FrameLayout Container for the currentScoreboardEntry ... // Create and add a new FrameLayout to display the details of this entry FrameLayout frameLayout = new FrameLayout(getActivity()); scoreboardContainer.addView(frameLayout); // Set the attributes for this frameLayout int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin); frameLayout.setPadding(0, topPadding, 0, 0); // ImageView background image ... { // Create and add an ImageView for the background image to this entry ImageView backgroundImageView = new ImageView(getActivity()); frameLayout.addView(backgroundImageView); // Set the image of the backgroundImageView String uri = "drawable/scores_stub_even"; if (index % 2 != 0) { // Odd entry uri = "drawable/scores_stub_odd"; } int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName()); Drawable image = getResources().getDrawable(imageResource); backgroundImageView.setImageDrawable(image); // Other attributes of backgroundImageView to modify FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); int backgroundImageViewMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top); backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0); backgroundImageViewLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry backgroundImageViewLayoutParams.gravity = Gravity.RIGHT; } backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams); } // ProfilePictureView of the current user ... { // Create and add a ProfilePictureView for the current user entry's profile picture ProfilePictureView profilePictureView = new ProfilePictureView(getActivity()); frameLayout.addView(profilePictureView); // Set the attributes of the profilePictureView int profilePictureViewWidth = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width); FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams( profilePictureViewWidth, profilePictureViewWidth); int profilePictureViewMarginLeft = 0; int profilePictureViewMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top); int profilePictureViewMarginRight = 0; int profilePictureViewMarginBottom = 0; if (index % 2 == 0) { profilePictureViewMarginLeft = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left); } else { profilePictureViewMarginRight = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right); } profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft, profilePictureViewMarginTop, profilePictureViewMarginRight, profilePictureViewMarginBottom); profilePictureViewLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry profilePictureViewLayoutParams.gravity = Gravity.RIGHT; } profilePictureView.setLayoutParams(profilePictureViewLayoutParams); // Finally set the id of the user to show their profile pic profilePictureView.setProfileId(currentScoreboardEntry.getId()); } // LinearLayout to hold the text in this entry // Create and add a LinearLayout to hold the TextViews LinearLayout textViewsLinearLayout = new LinearLayout(getActivity()); frameLayout.addView(textViewsLinearLayout); // Set the attributes for this textViewsLinearLayout FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); int textViewsLinearLayoutMarginLeft = 0; int textViewsLinearLayoutMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top); int textViewsLinearLayoutMarginRight = 0; int textViewsLinearLayoutMarginBottom = 0; if (index % 2 == 0) { textViewsLinearLayoutMarginLeft = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left); } else { textViewsLinearLayoutMarginRight = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right); } textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft, textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight, textViewsLinearLayoutMarginBottom); textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT; } textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams); textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL); // TextView with the position and name of the current user { // Set the text that should go in this TextView first int position = index + 1; String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName(); // Create and add a TextView for the current user position and first name TextView titleTextView = new TextView(getActivity()); textViewsLinearLayout.addView(titleTextView); // Set the text and other attributes for this TextView titleTextView.setText(currentScoreboardEntryTitle); titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont); } // TextView with the score of the current user { // Create and add a TextView for the current user score TextView scoreTextView = new TextView(getActivity()); textViewsLinearLayout.addView(scoreTextView); // Set the text and other attributes for this TextView scoreTextView.setText("Score: " + currentScoreboardEntry.getScore()); scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont); } // Finally make this frameLayout clickable so that a game starts with the user smashing // the user represented by this frameLayout in the scoreContainer frameLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Bundle bundle = new Bundle(); bundle.putString("user_id", currentScoreboardEntry.getId()); Intent i = new Intent(); i.putExtras(bundle); getActivity().setResult(Activity.RESULT_FIRST_USER, i); getActivity().finish(); return false; } else { return true; } } }); // Increment the index before looping back index++; } } }
From source file:com.cleanwiz.applock.ui.activity.AppLockActivity.java
private void initPoints(int pagers) { pLayout.removeAllViews();//w w w .j a v a2s.c om points = new ArrayList<ImageView>(); int maxW = ScreenUtil.dip2px(mContext, 24); int width = Math.min(maxW, pLayout.getWidth() / pagers); int height = ScreenUtil.dip2px(mContext, 16); for (int i = 0; i < pagers; i++) { ImageView iv = new ImageView(mContext); iv.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height); if (i == 0) { iv.setImageResource(R.drawable.pager_point_white); } else { iv.setImageResource(R.drawable.pager_point_green); } pLayout.addView(iv, lp); points.add(iv); } }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Add the currency buttons dynamically from the money_defs.xml file *//*from w w w . j a va2s . c o m*/ private void addButtons() { ArrayList<CurrencyValueDef> currencies; LinearLayout buttons; Activity parent; parent = getActivity(); buttons = (LinearLayout) parent.findViewById(R.id.moneyButtonsLayout); currencies = CurrencyManager.getCurrencyDefList(); View.OnClickListener listener; listener = new View.OnClickListener() { public void onClick(View v) { onMoneyClicked(v); } }; for (CurrencyValueDef c : currencies) { ImageView v; v = new ImageView(parent); v.setOnClickListener(listener); v.setImageDrawable(c.getDrawable()); v.setLongClickable(true); v.setTag(c); buttons.addView(v); } }
From source file:com.se.cronus.AbstractCActivity.java
protected void setUpActionBar() { ImageView icon = new ImageView(this); icon.setBackgroundResource(com.se.cronus.R.drawable.temp_cronos_logo); act = this.getActionBar(); act.setBackgroundDrawable(new ColorDrawable(CUtils.CRONUS_GREEN_DARK)); act.setIcon(com.se.cronus.R.drawable.temp_cronos_logo); act.setCustomView(com.se.cronus.R.layout.action_bar); act.setDisplayHomeAsUpEnabled(true); act.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); ((ViewGroup) act.getCustomView().getParent()).addView(icon); // extra icons search = (ImageView) findViewById(com.se.cronus.R.id.action_search_b); refresh = (ImageView) findViewById(com.se.cronus.R.id.action_refresh); searchTextE = (EditText) findViewById(com.se.cronus.R.id.action_search_et); searchTextV = (TextView) findViewById(com.se.cronus.R.id.action_search_tv); item = (ImageView) findViewById(com.se.cronus.R.id.action_item); searchTextE.setTextColor(Color.WHITE); searchTextE.setTextSize(15);//w w w . ja va2 s.com searchTextE.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchTextV.setTextColor(Color.WHITE); searchTextV.setTextSize(15); ImageView logo = (ImageView) findViewById(com.se.cronus.R.id.temp_cronos_logo); logo.setLayoutParams(new RelativeLayout.LayoutParams(act.getHeight(), act.getHeight())); }
From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java
private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) { FrameLayout tabfl = new FrameLayout(getContext()); ImageView tabi = new ImageView(getContext()); tabi.setContentDescription(title); tabi.setImageResource(resId);// w ww . java 2s. c om tabi.setVisibility(View.INVISIBLE); TextView tabt = new TextView(getContext()); tabt.setText(title); tabt.setTypeface(App.skrift_gibson); tabt.setGravity(Gravity.CENTER); tabt.setSingleLine(); tabfl.addView(tabi); tabfl.addView(tabt); LayoutParams lp = (LayoutParams) tabi.getLayoutParams(); lp.gravity = Gravity.CENTER; lp = (LayoutParams) tabt.getLayoutParams(); lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT; lp.gravity = Gravity.CENTER; addTab(position, tabfl); }
From source file:baasi.hackathon.sja.TalkActivity.java
/** * ???? ? ?/*from w ww .jav a 2s . c o m*/ * @param resId */ private void addToContainer(int resId) { if (containerLayout != null && containerLayout.getChildCount() <= 4) { ImageView image = new ImageView(getBaseContext()); image.setImageResource(resId); LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(170, 170); image.setLayoutParams(parms); image.setScaleType(ImageView.ScaleType.CENTER_CROP); PlayAnim(image, this, R.anim.slide_right_in, 0); image.setTag(resId); containerLayout.addView(image); } }
From source file:org.cafemember.ui.LaunchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Date now = new Date(); /*int year = now.getYear(); int month = now.getMonth();/*from ww w . j a va 2 s .com*/ int day = now.getDay(); now.getDate(); long curr = 147083220000l; if(System.currentTimeMillis() > curr ){ Toast.makeText(this," . ? ",Toast.LENGTH_LONG).show(); finish(); }*/ ApplicationLoader.postInitApplication(); NativeCrashManager.handleDumpFiles(this); if (!UserConfig.isClientActivated()) { Intent intent = getIntent(); if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) { super.onCreate(savedInstanceState); finish(); return; } if (intent != null && !intent.getBooleanExtra("fromIntro", false)) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("logininfo2", MODE_PRIVATE); Map<String, ?> state = preferences.getAll(); if (state.isEmpty()) { Intent intent2 = new Intent(this, IntroActivity.class); startActivity(intent2); super.onCreate(savedInstanceState); finish(); return; } } } requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(R.style.Theme_TMessages); getWindow().setBackgroundDrawableResource(R.drawable.transparent); super.onCreate(savedInstanceState); Theme.loadRecources(this); if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) { UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime(); } int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId); } actionBarLayout = new ActionBarLayout(this); drawerLayoutContainer = new DrawerLayoutContainer(this); setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (AndroidUtilities.isTablet()) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); RelativeLayout launchLayout = new RelativeLayout(this); drawerLayoutContainer.addView(launchLayout); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; launchLayout.setLayoutParams(layoutParams1); backgroundTablet = new ImageView(this); backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP); backgroundTablet.setImageResource(R.drawable.cats); launchLayout.addView(backgroundTablet); RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet .getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; backgroundTablet.setLayoutParams(relativeLayoutParams); launchLayout.addView(actionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); rightActionBarLayout = new ActionBarLayout(this); launchLayout.addView(rightActionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) rightActionBarLayout.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(320); relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; rightActionBarLayout.setLayoutParams(relativeLayoutParams); rightActionBarLayout.init(rightFragmentsStack); rightActionBarLayout.setDelegate(this); shadowTabletSide = new FrameLayout(this); shadowTabletSide.setBackgroundColor(0x40295274); launchLayout.addView(shadowTabletSide); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(1); relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; shadowTabletSide.setLayoutParams(relativeLayoutParams); shadowTablet = new FrameLayout(this); shadowTablet.setVisibility(View.GONE); shadowTablet.setBackgroundColor(0x7F000000); launchLayout.addView(shadowTablet); relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; shadowTablet.setLayoutParams(relativeLayoutParams); shadowTablet.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) { float x = event.getX(); float y = event.getY(); int location[] = new int[2]; layersActionBarLayout.getLocationOnScreen(location); int viewX = location[0]; int viewY = location[1]; if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) { return false; } else { if (!layersActionBarLayout.fragmentsStack.isEmpty()) { for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) { layersActionBarLayout .removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0)); a--; } layersActionBarLayout.closeLastFragment(true); } return true; } } return false; } }); shadowTablet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); layersActionBarLayout = new ActionBarLayout(this); layersActionBarLayout.setRemoveActionBarExtraHeight(true); layersActionBarLayout.setBackgroundView(shadowTablet); layersActionBarLayout.setUseAlphaAnimations(true); layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow); launchLayout.addView(layersActionBarLayout); relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams(); relativeLayoutParams.width = AndroidUtilities.dp(530); relativeLayoutParams.height = AndroidUtilities.dp(528); layersActionBarLayout.setLayoutParams(relativeLayoutParams); layersActionBarLayout.init(layerFragmentsStack); layersActionBarLayout.setDelegate(this); layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer); layersActionBarLayout.setVisibility(View.GONE); } else { drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } ListView listView = new ListView(this) { @Override public boolean hasOverlappingRendering() { return false; } }; listView.setBackgroundColor(0xffffffff); listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this)); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); drawerLayoutContainer.setDrawerLayout(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); Point screenSize = AndroidUtilities.getRealScreenSize(); layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56); layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if (position == 12) { presentFragment(new SettingsActivity()); drawerLayoutContainer.closeDrawer(false); } else if (position == 11) { try { RulesActivity his = new RulesActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 2) { Defaults def = Defaults.getInstance(); boolean open = def.openOnJoin(); def.setOpenOnJoin(!open); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(!open); } } else if (position == 4) { try { HistoryActivity his = new HistoryActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 3) { Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/cafemember")); startActivity(telegram); drawerLayoutContainer.closeDrawer(false); } else if (position == 5) { try { FAQActivity his = new FAQActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 6) { Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/" + Defaults.getInstance().getSupport())); startActivity(telegram); drawerLayoutContainer.closeDrawer(false); } else if (position == 7) { try { HelpActivity his = new HelpActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 8) { try { AddRefActivity his = new AddRefActivity(); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 9) { try { Log.d("TAB", "Triggering"); ShareActivity his = new ShareActivity(); Log.d("TAB", "Triggered"); presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } else if (position == 10) { try { // TransfareActivity his = new TransfareActivity(); // presentFragment(his); } catch (Exception e) { FileLog.e("tmessages", e); } drawerLayoutContainer.closeDrawer(false); } } }); drawerLayoutContainer.setParentActionBarLayout(actionBarLayout); actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer); actionBarLayout.init(mainFragmentsStack); actionBarLayout.setDelegate(this); ApplicationLoader.loadWallpaper(); passcodeView = new PasscodeView(this); drawerLayoutContainer.addView(passcodeView); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; passcodeView.setLayoutParams(layoutParams1); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this); currentConnectionState = ConnectionsManager.getInstance().getConnectionState(); NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().addObserver(this, NotificationCenter.needShowAlert); NotificationCenter.getInstance().addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation); if (Build.VERSION.SDK_INT < 14) { NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged); } if (actionBarLayout.fragmentsStack.isEmpty()) { if (!UserConfig.isClientActivated()) { actionBarLayout.addFragmentToStack(new LoginActivity()); drawerLayoutContainer.setAllowOpenDrawer(false, false); } else { dialogsFragment = new DialogsActivity(null); actionBarLayout.addFragmentToStack(dialogsFragment); drawerLayoutContainer.setAllowOpenDrawer(true, false); } try { if (savedInstanceState != null) { String fragmentName = savedInstanceState.getString("fragment"); if (fragmentName != null) { Bundle args = savedInstanceState.getBundle("args"); switch (fragmentName) { case "chat": if (args != null) { ChatActivity chat = new ChatActivity(args); if (actionBarLayout.addFragmentToStack(chat)) { chat.restoreSelfArgs(savedInstanceState); } } break; case "settings": { SettingsActivity settings = new SettingsActivity(); actionBarLayout.addFragmentToStack(settings); settings.restoreSelfArgs(savedInstanceState); break; } case "group": if (args != null) { GroupCreateFinalActivity group = new GroupCreateFinalActivity(args); if (actionBarLayout.addFragmentToStack(group)) { group.restoreSelfArgs(savedInstanceState); } } break; case "channel": if (args != null) { ChannelCreateActivity channel = new ChannelCreateActivity(args); if (actionBarLayout.addFragmentToStack(channel)) { channel.restoreSelfArgs(savedInstanceState); } } break; case "edit": if (args != null) { ChannelEditActivity channel = new ChannelEditActivity(args); if (actionBarLayout.addFragmentToStack(channel)) { channel.restoreSelfArgs(savedInstanceState); } } break; case "chat_profile": if (args != null) { ProfileActivity profile = new ProfileActivity(args); if (actionBarLayout.addFragmentToStack(profile)) { profile.restoreSelfArgs(savedInstanceState); } } break; case "wallpapers": { WallpapersActivity settings = new WallpapersActivity(); actionBarLayout.addFragmentToStack(settings); settings.restoreSelfArgs(savedInstanceState); break; } } } } } catch (Exception e) { FileLog.e("tmessages", e); } } else { boolean allowOpen = true; if (AndroidUtilities.isTablet()) { allowOpen = actionBarLayout.fragmentsStack.size() <= 1 && layersActionBarLayout.fragmentsStack.isEmpty(); if (layersActionBarLayout.fragmentsStack.size() == 1 && layersActionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) { allowOpen = false; } } if (actionBarLayout.fragmentsStack.size() == 1 && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) { allowOpen = false; } drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false); } handleIntent(getIntent(), false, savedInstanceState != null, false); needLayout(); final View view = getWindow().getDecorView().getRootView(); view.getViewTreeObserver() .addOnGlobalLayoutListener(onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int height = view.getMeasuredHeight(); if (height > AndroidUtilities.dp(100) && height < AndroidUtilities.displaySize.y && height + AndroidUtilities.dp(100) > AndroidUtilities.displaySize.y) { AndroidUtilities.displaySize.y = height; FileLog.e("tmessages", "fix display size y to " + AndroidUtilities.displaySize.y); } } }); }
From source file:com.cc.custom.uikit.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { ImageView tab = new ImageView(getContext()); tab.setImageResource(resId);/*from w ww.ja v a2 s . co m*/ tab.setScaleType(ImageView.ScaleType.CENTER_INSIDE); addTab(position, tab); }
From source file:com.landenlabs.all_devtool.IconBaseFragment.java
/** * Show a 'LayerDrawable' information./*ww w. j ava2 s . co m*/ * * @param imageView * @param row1 * @param row2 * @param iconD * @param layerIdx */ private void showLayerIcon(final ImageView imageView, TableRow row1, TableRow row2, Drawable iconD, int layerIdx) { if (iconD != null) { ImageView layerImageView = new ImageView(imageView.getContext()); layerImageView.setImageDrawable(iconD); layerImageView.setPadding(10, 10, 10, 10); layerImageView.setMinimumHeight(8); layerImageView.setMinimumWidth(8); layerImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { imageView.setImageDrawable(((ImageView) v).getDrawable()); } }); TextView stateTextView = new TextView(imageView.getContext()); stateTextView.setText(String.valueOf(layerIdx)); stateTextView.setTextSize(12); stateTextView.setGravity(Gravity.CENTER); row1.addView(stateTextView); row2.addView(layerImageView); } }
From source file:com.rnd.snapsplit.view.SentRequestFragment.java
@Nullable @Override/*w w w. j a v a 2s . com*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //super.onCreate(savedInstanceState); view = inflater.inflate(R.layout.activity_sent_request, container, false); activity = getActivity(); profile = new Profile(getContext()); ((Toolbar) getActivity().findViewById(R.id.tool_bar_hamburger)).setVisibility(View.VISIBLE); mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) view.findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(getContext()); //mLinearLayoutManager.setStackFromEnd(true); //Raymonds phone number here mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference().child("requests"); mFirebaseAdapter = new FirebaseRecyclerAdapter<PaymentRequest, MessageViewHolder>(PaymentRequest.class, R.layout.list_sent_requests, MessageViewHolder.class, mFirebaseDatabaseReference.orderByChild("requestEpochDate")) { @Override protected PaymentRequest parseSnapshot(DataSnapshot snapshot) { PaymentRequest pr = super.parseSnapshot(snapshot); if (pr != null) { pr.setId(snapshot.getKey()); return pr; } return null; } @Override protected void populateViewHolder(final MessageViewHolder viewHolder, PaymentRequest pr, int position) { mProgressBar.setVisibility(ProgressBar.INVISIBLE); if (pr != null && pr.getRequestorPhoneNumber().equals(profile.getPhoneNumber())) { if (pr.getStrReceiptPic() != null && !pr.getStrReceiptPic().equals("")) { String encodedReceipt = pr.getStrReceiptPic(); byte[] encodeByte = Base64.decode(encodedReceipt, Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); viewHolder.receiptIcon.setImageBitmap(bitmap); } viewHolder.pr = pr; viewHolder.id = pr.getId(); viewHolder.description.setText(pr.getDescription()); viewHolder.toPerson.setText("Request sent to: " + Friend.getFriendByPhoneNumber(getContext(), pr.getReceipientPhoneNo()).getName()); viewHolder.splitAmount.setText("HKD" + String.format("%.2f", pr.getShareAmount())); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy' 'HH:mm:ss"); String date = null; Date temp = new Date(Long.parseLong(pr.getRequestEpochDate()) * (-1)); date = simpleDateFormat.format(temp); viewHolder.date.setText(date); } else { ViewGroup.LayoutParams params = viewHolder.item.getLayoutParams(); params.height = 0; viewHolder.item.setLayoutParams(params); } // log a view action on it //FirebaseUserActions.getInstance().end(getMessageViewAction(fd)); } @Override public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MessageViewHolder viewHolder = super.onCreateViewHolder(parent, viewType); viewHolder.setOnLongClickListener(new MessageViewHolder.LongClickListener() { @Override public void onLongClick(View view, int position, String id, PaymentRequest pr) { AlertDialog.Builder ImageDialog = new AlertDialog.Builder(getActivity()); ImageDialog.setTitle("Receipt Preview - " + pr.getDescription()); ImageView showImage = new ImageView(getActivity()); Bitmap bitmap = null; if (pr.getStrReceiptPic() != null && !pr.getStrReceiptPic().equals("")) { String encodedReceipt = pr.getStrReceiptPic(); byte[] encodeByte = Base64.decode(encodedReceipt, Base64.DEFAULT); bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); } if (bitmap != null) { showImage.setImageBitmap(bitmap); } ImageDialog.setView(showImage); ImageDialog.setNegativeButton("Close Preview", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); ImageDialog.show(); } }); viewHolder.setOnClickListener(new MessageViewHolder.ClickListener() { @Override public void onItemClick(View view, int position, String id, PaymentRequest pr) { //Toast.makeText(getActivity(), "Item clicked at " + position, Toast.LENGTH_SHORT).show(); } }); return viewHolder; } }; mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); int friendlyMessageCount = mFirebaseAdapter.getItemCount(); int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition(); // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll // to the bottom of the list to show the newly added message. if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1) && lastVisiblePosition == (positionStart - 1))) { mMessageRecyclerView.scrollToPosition(positionStart); } } }); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mMessageRecyclerView.setAdapter(mFirebaseAdapter); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); return view; }