Java Code Examples for android.widget.LinearLayout#setMinimumHeight()

The following examples show how to use android.widget.LinearLayout#setMinimumHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIAlertDialog.java    From UIWidget with Apache License 2.0 6 votes vote down vote up
private View createContentView() {
    mLLayoutRoot = new LinearLayout(mContext);
    mLLayoutRoot.setId(R.id.lLayout_rootAlertDialog);
    mLLayoutRoot.setOrientation(LinearLayout.VERTICAL);
    mLLayoutRoot.setMinimumWidth(mMinWidth);
    mLLayoutRoot.setMinimumHeight(mMinHeight);
    setRootView();
    if (createBeforeTitle() != null) {
        mLLayoutRoot.addView(createBeforeTitle());
    }
    createTitle();
    createMessage();
    createContainerView();
    mLLayoutRoot.setPadding(0, 0, 0, 0);
    for (View v : createButtons()) {
        if (v != null) {
            mLLayoutRoot.addView(v);
        }
    }
    return mLLayoutRoot;
}
 
Example 2
Source File: DrawerUtils.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * adds the shadow to the stickyFooter
 *
 * @param ctx
 * @param footerView
 */
private static void addStickyFooterDivider(Context ctx, ViewGroup footerView) {
    LinearLayout divider = new LinearLayout(ctx);
    LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    //remove bottomMargin --> See inbox it also has no margin here
    //dividerParams.bottomMargin = mActivity.getResources().getDimensionPixelSize(R.dimen.material_drawer_padding);
    divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, ctx));
    divider.setOrientation(LinearLayout.VERTICAL);
    divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
    footerView.addView(divider, dividerParams);
}
 
Example 3
Source File: CordovaActivity.java    From crosswalk-cordova-android with Apache License 2.0 5 votes vote down vote up
protected LinearLayout getSplashLayout() {
    // Get reference to display
    Display display = getWindowManager().getDefaultDisplay();

    LinearLayout root = new LinearLayout(getActivity());
    root.setMinimumHeight(display.getHeight());
    root.setMinimumWidth(display.getWidth());
    root.setOrientation(LinearLayout.VERTICAL);
    root.setBackgroundColor(getIntegerProperty("backgroundColor", Color.BLACK));
    root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
    root.setBackgroundResource(splashscreen);

    return root;
}
 
Example 4
Source File: ActivityDlgAttributes.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      ImageView iv = new ImageView(context);
      iv.setImageResource(attributes.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      TextView tv = new TextView(context);
      tv.setText(attributes.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 5
Source File: ActivityLogTabs.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * This function will be called once for every element in the listView control, when it needs to
 * draw itself. It should return a constructed view representing the data in the position
 * specified. Each element in the listView is a Log item, so we display the Log's icon and
 * title.
 * 
 * TODO: Use convertView when possible instead of always creating new views.
 */
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  // Icon of the log.
  ImageView iv = new ImageView(context);
  iv.setImageResource(logs.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  // Title of the log.
  TextView tv = new TextView(context);
  tv.setText(logs.get(position).getText());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);
  return ll;
}
 
Example 6
Source File: ActivityDlgActions.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      ImageView iv = new ImageView(context);
      iv.setImageResource(actions.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      TextView tv = new TextView(context);
      tv.setText(actions.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 7
Source File: FloatingToolbar.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private View createMenuItemButton(Context context, MenuItem menuItem, int iconTextSpacing) {
    LinearLayout menuItemButton = new LinearLayout(context);
    menuItemButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    menuItemButton.setOrientation(LinearLayout.HORIZONTAL);
    menuItemButton.setMinimumWidth(AndroidUtilities.dp(48));
    menuItemButton.setMinimumHeight(AndroidUtilities.dp(48));
    menuItemButton.setPaddingRelative(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);

    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setFocusable(false);
    textView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    textView.setFocusableInTouchMode(false);
    if (currentStyle == STYLE_DIALOG) {
        textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    } else if (currentStyle == STYLE_BLACK) {
        textView.setTextColor(0xfffafafa);
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(0x40ffffff, false));
    } else if (currentStyle == STYLE_THEME) {
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    }
    textView.setPaddingRelative(AndroidUtilities.dp(11), 0, 0, 0);
    menuItemButton.addView(textView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, AndroidUtilities.dp(48)));
    if (menuItem != null) {
        updateMenuItemButton(menuItemButton, menuItem, iconTextSpacing);
    }
    return menuItemButton;
}
 
Example 8
Source File: ActivityDlgApplications.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {

      LinearLayout ll = new LinearLayout(context);
      ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      ll.setMinimumHeight(50);
      ll.setOrientation(LinearLayout.HORIZONTAL);
      ll.setGravity(Gravity.CENTER_VERTICAL);

      ImageView iv = new ImageView(context);
      iv.setImageResource(applications.get(position).getIconResId());
      iv.setAdjustViewBounds(true);
      iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
          LayoutParams.WRAP_CONTENT));
      if (listView.getCheckedItemPosition() == position) {
        iv.setBackgroundResource(R.drawable.icon_hilight);
      }

      TextView tv = new TextView(context);
      tv.setText(applications.get(position).getDescriptionShort());
      tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
          LayoutParams.FILL_PARENT));
      tv.setGravity(Gravity.CENTER_VERTICAL);
      tv.setPadding(10, 0, 0, 0);
      tv.setTextSize(14.0f);
      tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
      tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
      tv.setMinHeight(46);

      ll.addView(iv);
      ll.addView(tv);

      return ll;
    }
 
Example 9
Source File: UtilUI.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * Force-inflates a dialog main linear-layout to take max available screen space even though
 * contents might not occupy full screen size.
 */
public static void inflateDialog(LinearLayout layout) {
  WindowManager wm = (WindowManager) layout.getContext().getSystemService(
    Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();
  layout.setMinimumWidth(display.getWidth() - 30);
  layout.setMinimumHeight(display.getHeight() - 40);
}
 
Example 10
Source File: FriendAdapter.java    From BaoKanAndroid with MIT License 4 votes vote down vote up
public View getFooterView() {
	LinearLayout footerView = new LinearLayout(getContext());
	footerView.setMinimumHeight(10);
	return footerView;
}
 
Example 11
Source File: FriendAdapter.java    From LQRWeChat with MIT License 4 votes vote down vote up
public View getFooterView() {
	LinearLayout footerView = new LinearLayout(getContext());
	footerView.setMinimumHeight(10);
	return footerView;
}
 
Example 12
Source File: FriendAdapter.java    From Mobike with Apache License 2.0 4 votes vote down vote up
public View getFooterView() {
	LinearLayout footerView = new LinearLayout(getContext());
	footerView.setMinimumHeight(10);
	return footerView;
}
 
Example 13
Source File: CordovaActivity.java    From phonegap-plugin-loading-spinner with Apache License 2.0 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 14
Source File: AdapterRule.java    From LibreTasks with Apache License 2.0 4 votes vote down vote up
/**
 * Generates a single item in the listview tree widget.
 */
public View getView(int position, View convertView, ViewGroup parent) {

  NodeWrapper it = getNodeWrapper(position);

  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  ImageView iv = new ImageView(context);
  iv.setImageResource(it.getNode().getItem().getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  TextView tv = new TextView(context);
  tv.setText(it.getNode().getItem().getDescriptionShort());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  // This is where we figure out which tree branch graphics to stack
  // to the left of a node to give the appearance of a real tree widget.
  ArrayList<Integer> branches = it.getBranches();
  for (int i = 0; i < branches.size(); i++) {
    int imageResourceId;
    if (i == branches.size() - 1) {
      // You are whatever I say you are.
      imageResourceId = branches.get(i).intValue();
    } else {
      // Here we do replacements.
      if (branches.get(i).intValue() == R.drawable.treebranch_child_end) {
        // empty png
        imageResourceId = R.drawable.treebranch_parent_empty;
      } else {
        // straight pipe png
        imageResourceId = R.drawable.treebranch_parent;
      }
    }

    ImageView ivBranch = new ImageView(context);
    ivBranch.setImageResource(imageResourceId);
    ivBranch.setAdjustViewBounds(true);
    ivBranch.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT));
    ll.addView(ivBranch);
  }

  ll.addView(iv);
  ll.addView(tv);
  return ll;
}
 
Example 15
Source File: FriendAdapter.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
public View getFooterView() {
	LinearLayout footerView = new LinearLayout(getContext());
	footerView.setMinimumHeight(10);
	return footerView;
}
 
Example 16
Source File: CordovaActivity.java    From CordovaYoutubeVideoPlayer with MIT License 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 17
Source File: CordovaActivity.java    From reader with MIT License 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 18
Source File: CordovaActivity.java    From wildfly-samples with MIT License 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 19
Source File: DialogUnit.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
public void showPostDescriptionDialog(Collection<IconData> icons, String chanName, final String emailToCopy) {
	Context context = uiManager.getContext();
	float density = ResourceUtils.obtainDensity(context);
	ImageLoader imageLoader = ImageLoader.getInstance();
	LinearLayout container = new LinearLayout(context);
	container.setOrientation(LinearLayout.VERTICAL);
	if (C.API_LOLLIPOP) {
		container.setPadding(0, (int) (12f * density), 0, 0);
	}
	HashMap<String, ImageView> taggedImageViews = new HashMap<>();
	ImageLoader.Observer observer = (key, bitmap, error) -> {
		ImageView taggedImageView = taggedImageViews.get(key);
		if (taggedImageView != null) {
			taggedImageView.setImageBitmap(bitmap);
		}
	};
	ImageLoader.getInstance().observable().register(observer);
	for (IconData icon : icons) {
		LinearLayout linearLayout = new LinearLayout(context);
		container.addView(linearLayout, LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		linearLayout.setOrientation(LinearLayout.HORIZONTAL);
		linearLayout.setGravity(Gravity.CENTER_VERTICAL);
		linearLayout.setMinimumHeight((int) (40f * density));
		linearLayout.setPadding((int) (18f * density), 0, (int) (8f * density), 0); // 18f = 16f + 2f
		ImageView imageView = new ImageView(context);
		linearLayout.addView(imageView, (int) (20f * density), (int) (20f * density));
		if (icon.uri != null) {
			ImageLoader.BitmapResult result = imageLoader.loadImage(icon.uri, chanName, null,
					key -> taggedImageViews.put(key, imageView), false);
			if (result != null && result.bitmap != null) {
				imageView.setImageBitmap(result.bitmap);
			}
		} else {
			imageView.setImageResource(ResourceUtils.getResourceId(context, icon.attrId, 0));
		}
		TextView textView = new TextView(context, null, android.R.attr.textAppearanceListItem);
		linearLayout.addView(textView, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
		textView.setSingleLine(true);
		textView.setText(icon.title);
		if (C.API_LOLLIPOP) {
			textView.setPadding((int) (26f * density), 0, 0, 0); // 26f = 24f + 2f
			textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
			textView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM);
		} else {
			textView.setPadding((int) (10f * density), 0, 0, 0); // 20f = 8f + 2f
			textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
			textView.setAllCaps(true);
		}
	}
	AlertDialog.Builder alertDialog = new AlertDialog.Builder(context).setPositiveButton(android.R.string.ok, null);
	if (!StringUtils.isEmpty(emailToCopy)) {
		alertDialog.setNeutralButton(R.string.action_copy_email,
				(dialog, which) -> StringUtils.copyToClipboard(uiManager.getContext(), emailToCopy));
	}
	alertDialog.setView(container).show().setOnDismissListener(dialogInterface ->
			ImageLoader.getInstance().observable().unregister(observer));
	notifySwitchBackground();
}
 
Example 20
Source File: CordovaActivity.java    From IoTgo_Android_App with MIT License 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}