Java Code Examples for android.widget.TextView#setShadowLayer()

The following examples show how to use android.widget.TextView#setShadowLayer() . 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: MyDetailsOverviewRowPresenter.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for ViewHolder.
 *
 * @param rootView The View bound to the Row.
 */
public ViewHolder(View rootView) {
    super(rootView);
    mTitle = (TextView) rootView.findViewById(R.id.fdTitle);
    mTitle.setShadowLayer(5, 5, 5, Color.BLACK);
    mInfoTitle1 = (TextView) rootView.findViewById(R.id.infoTitle1);
    mInfoTitle2 = (TextView) rootView.findViewById(R.id.infoTitle2);
    mInfoTitle3 = (TextView) rootView.findViewById(R.id.infoTitle3);
    mInfoValue1 = (TextView) rootView.findViewById(R.id.infoValue1);
    mInfoValue2 = (TextView) rootView.findViewById(R.id.infoValue2);
    mInfoValue3 = (TextView) rootView.findViewById(R.id.infoValue3);

    mLeftFrame = (RelativeLayout) rootView.findViewById(R.id.leftFrame);

    mGenreRow = (FlexboxLayout) rootView.findViewById(R.id.fdGenreRow);
    mInfoRow =  (LinearLayout)rootView.findViewById(R.id.fdMainInfoRow);
    mPoster = (ImageView) rootView.findViewById(R.id.mainImage);
    //mStudioImage = (ImageView) rootView.findViewById(R.id.studioImage);
    mButtonRow = (LinearLayout) rootView.findViewById(R.id.fdButtonRow);
    mSummary = (TextView) rootView.findViewById(R.id.fdSummaryText);

}
 
Example 2
Source File: BluetoothHidEmuActivity.java    From BluetoothHidEmu with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize UI elements
 * 
 */
private void setupApp() {
       setContentView(R.layout.main);
        
        if (!mSpoofer.requirementsCheck()) {
            Toast.makeText(getApplicationContext(), mSpoofer.getSetupErrorMsg(), Toast.LENGTH_LONG).show();
            finish();
        }

        mSocketManager = SocketManager.getInstance(mSpoofer);

        mMainLayout = (LinearLayout) findViewById(R.id.MainLayout);
        mDeviceSpinner = (Spinner) findViewById(R.id.DeviceSpinner);
        mStatusTextView = (TextView) findViewById(R.id.StatusTextView);
        mStatusTextView.setShadowLayer(6, 0f, 0f, Color.BLACK);
        
}
 
Example 3
Source File: NewFeatureActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
public void updateUI() {
    this.recoAppName.setText(this.mrecoApp.getName());
    String[] split = this.mrecoApp.getDesc().split("/");
    if (split.length == 2) {
        this.reco_desp.setPadding(0, 0, 0, 60);
    }
    for (CharSequence text : split) {
        TextView tv = new TextView(this);
        tv.setLayoutParams(new LayoutParams(-1, -1, 1.0f));
        tv.setShadowLayer(3.0f, 3.0f, 1.0f, 2131493090);
        tv.setTextColor(-1);
        tv.setGravity(1);
        tv.setText(text);
        tv.setTextSize(18.0f);
        this.reco_desp.addView(tv);
    }
}
 
Example 4
Source File: GridAdapter.java    From DistroHopper with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View getView (int position, View view, ViewGroup parent)
{
	LensSearchResult result = this.getItem (position);

	if (view == null)
		view = LayoutInflater.from (this.getContext ()).inflate (R.layout.widget_dash_lens_result, parent, false);

	TextView tvLabel = (TextView) view.findViewById (R.id.tvLabel);
	ImageView imgIcon = (ImageView) view.findViewById (R.id.imgIcon);

	tvLabel.setText (result.getName ());
	tvLabel.setTextColor (view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_colour));
	tvLabel.setShadowLayer (5, 2, 2, view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_shadow_colour));
	imgIcon.setImageDrawable (result.getIcon ());

	final int width = this.iconWidth;
	final int height = width;
	view.setLayoutParams(new LinearLayout.LayoutParams(width, height));

	view.setTag (result);

	return view;
}
 
Example 5
Source File: D.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void a()
{
    b = new TextView(TaskGuide.m(a));
    b.setTextColor(Color.rgb(255, 255, 255));
    b.setTextSize(15F);
    b.setShadowLayer(1.0F, 1.0F, 1.0F, Color.rgb(242, 211, 199));
    b.setGravity(3);
    b.setEllipsize(android.text.TextUtils.TruncateAt.END);
    b.setIncludeFontPadding(false);
    b.setSingleLine(true);
    android.widget.LinearLayout.LayoutParams layoutparams = new android.widget.LinearLayout.LayoutParams(0, -2);
    layoutparams.weight = 1.0F;
    layoutparams.leftMargin = TaskGuide.d(a, 4);
    addView(b, layoutparams);
    c = new Button(TaskGuide.n(a));
    c.setPadding(0, 0, 0, 0);
    c.setTextSize(16F);
    c.setTextColor(Color.rgb(255, 255, 255));
    c.setShadowLayer(1.0F, 1.0F, 1.0F, Color.rgb(242, 211, 199));
    c.setIncludeFontPadding(false);
    c.setOnClickListener(new B(a, d.a));
    android.widget.LinearLayout.LayoutParams layoutparams1 = new android.widget.LinearLayout.LayoutParams(TaskGuide.d(a, TaskGuide.a()), TaskGuide.d(a, TaskGuide.c()));
    layoutparams1.leftMargin = TaskGuide.d(a, 2);
    layoutparams1.rightMargin = TaskGuide.d(a, 8);
    addView(c, layoutparams1);
}
 
Example 6
Source File: LocationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private TextView getAttributionOverlay(Context context) {
    attributionOverlay = new TextView(context);
    attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
    attributionOverlay.setShadowLayer(1,-1,-1, Color.WHITE);
    attributionOverlay.setLinksClickable(true);
    attributionOverlay.setMovementMethod(LinkMovementMethod.getInstance());
    return attributionOverlay;
}
 
Example 7
Source File: MenuWidget.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public boolean onHover(View view, MotionEvent event) {
    int position = (int)view.getTag(R.string.position_tag);
    if (!isEnabled(position)) {
        return false;
    }

    if (mItems.size() <= position) {
        return false;
    }

    MenuItem item = mItems.get(position);
    if (item.mCallback == null) {
        return false;
    }

    TextView label = view.findViewById(R.id.listItemText);
    switch (event.getActionMasked()) {
        case MotionEvent.ACTION_HOVER_ENTER:
            label.setShadowLayer(label.getShadowRadius(), label.getShadowDx(), label.getShadowDy(), mContext.getColor(R.color.text_shadow_light));
            return false;

        case MotionEvent.ACTION_HOVER_EXIT:
            label.setShadowLayer(label.getShadowRadius(), label.getShadowDx(), label.getShadowDy(), mContext.getColor(R.color.text_shadow));
            return false;
    }

    return false;
}
 
Example 8
Source File: CardboardOverlayView.java    From Cardboard with Apache License 2.0 5 votes vote down vote up
public CardboardOverlayEyeView(Context context, AttributeSet attrs) {
    super(context, attrs);
    imageView = new ImageView(context, attrs);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imageView.setAdjustViewBounds(true);  // Preserve aspect ratio.
    addView(imageView);

    textView = new TextView(context, attrs);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14.0f);
    textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
    textView.setGravity(Gravity.CENTER);
    textView.setShadowLayer(3.0f, 0.0f, 0.0f, Color.DKGRAY);
    addView(textView);
}
 
Example 9
Source File: Crouton.java    From TiCrouton with MIT License 5 votes vote down vote up
private void initializeTextViewShadow(final Resources resources, final TextView text) {
  int textShadowColor = resources.getColor(this.style.textShadowColorResId);
  float textShadowRadius = this.style.textShadowRadius;
  float textShadowDx = this.style.textShadowDx;
  float textShadowDy = this.style.textShadowDy;
  text.setShadowLayer(textShadowRadius, textShadowDx, textShadowDy, textShadowColor);
}
 
Example 10
Source File: ListItemUtils.java    From mytracks with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a text view.
 * 
 * @param context the context
 * @param textView the text view
 * @param value the value for the text view
 * @param addShadow true to add shadow
 */
public static void setTextView(
    Context context, TextView textView, String value, boolean addShadow) {
  if (value == null || value.length() == 0) {
    textView.setVisibility(View.GONE);
  } else {
    textView.setVisibility(View.VISIBLE);
    textView.setText(value);
    if (addShadow) {
      textView.setShadowLayer(5, 0, 2, context.getResources().getColor(android.R.color.black));
    } else {
      textView.setShadowLayer(0, 0, 0, 0);
    }
  }
}
 
Example 11
Source File: SplashActivity.java    From Ecommerce-Morningmist-Android with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE); 
	this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.activity_splash);
	
	Timer timer = new Timer();
	timer.schedule(new TimerTask() {
		
		@Override
		public void run() {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(SplashActivity.this, MainActivity.class);
			startActivity(intent);
			finish();
			
		}
	}, MainActivity.SPLASH_DURATION);

	tvZonCon = (TextView)findViewById(R.id.tv_zoncon);
	tvZonCon.setShadowLayer(2, 1, 1, getResources().getColor(R.color.black));
	tvZonCon.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
	tvZonCon.setVisibility(RelativeLayout.GONE);
	
}
 
Example 12
Source File: HomeActivityDelegate.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private View inflateDesktopIcon(ViewGroup parent, AppEntry entry) {
    SharedPreferences pref = U.getSharedPreferences(this);
    View icon = LayoutInflater.from(this).inflate(R.layout.tb_row_alt, parent, false);

    TextView textView = icon.findViewById(R.id.name);
    textView.setText(pref.getBoolean(PREF_HIDE_ICON_LABELS, false) ? "" : entry.getLabel());
    textView.setTextColor(ContextCompat.getColor(this, R.color.tb_desktop_icon_text));
    textView.setShadowLayer(10, 0, 0, R.color.tb_desktop_icon_shadow);

    ImageView imageView = icon.findViewById(R.id.icon);
    imageView.setImageDrawable(entry.getIcon(this));

    icon.setOnTouchListener(new DesktopIconTouchListener());
    return icon;
}
 
Example 13
Source File: SplashActivity.java    From Ecommerce-Retronight-Android with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE); 
	this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.activity_splash);
	
	Timer timer = new Timer();
	timer.schedule(new TimerTask() {
		
		@Override
		public void run() {
			// TODO Auto-generated method stub
			
			Intent intent = new Intent(SplashActivity.this, MainActivity.class);
			startActivity(intent);
			finish();
			
		}
	}, MainActivity.SPLASH_DURATION);

	tvZonCon = (TextView)findViewById(R.id.tv_zoncon);
	tvZonCon.setShadowLayer(2, 1, 1, getResources().getColor(R.color.black));
	tvZonCon.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
	tvZonCon.setVisibility(RelativeLayout.GONE);
	
}
 
Example 14
Source File: PinkToast.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public static Toast makeText(Context context, int id, int duration) {
    Toast result = Toast.makeText(context, id, duration);
    result.getView().setBackgroundResource(R.drawable.tt_waterfall_refresh_bg);
    result.setGravity(Gravity.CENTER, 0, 0);
    TextView tv = (TextView) ((ViewGroup) result.getView()).getChildAt(0);
    ScreenTools tools = ScreenTools.instance(context);

    tv.setPadding(tools.dip2px(5), tools.dip2px(8), tools.dip2px(5),
            tools.dip2px(8));
    tv.setShadowLayer(0, 0, 0, Color.TRANSPARENT);
    tv.setMinWidth(tools.dip2px(180));
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(context.getResources().getColor(android.R.color.white));
    return result;
}
 
Example 15
Source File: PinkToast.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public static Toast makeText(Context context, CharSequence text, int duration) {
    Toast result = Toast.makeText(context, text, duration);
    result.getView().setBackgroundResource(R.drawable.tt_waterfall_refresh_bg);
    result.setGravity(Gravity.CENTER, 0, 0);
    TextView tv = (TextView) ((ViewGroup) result.getView()).getChildAt(0);
    ScreenTools tools = ScreenTools.instance(context);

    tv.setPadding(tools.dip2px(5), tools.dip2px(8), tools.dip2px(5),
            tools.dip2px(8));
    tv.setShadowLayer(0, 0, 0, Color.TRANSPARENT);
    tv.setMinWidth(tools.dip2px(180));
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(context.getResources().getColor(android.R.color.white));
    return result;
}
 
Example 16
Source File: ChatAttachAlertLocationLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private TextView getAttributionOverlay(Context context) {
    attributionOverlay = new TextView(context);
    attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
    attributionOverlay.setShadowLayer(1, -1, -1, Color.WHITE);
    attributionOverlay.setLinksClickable(true);
    attributionOverlay.setMovementMethod(LinkMovementMethod.getInstance());
    return attributionOverlay;
}
 
Example 17
Source File: ViewUtil.java    From material with Apache License 2.0 4 votes vote down vote up
public static void applyTextAppearance(TextView v, int resId){
    if(resId == 0)
        return;

    String fontFamily = null;
    int typefaceIndex = -1;
    int styleIndex = -1;
    int shadowColor = 0;
    float dx = 0, dy = 0, r = 0;

    TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (appearance != null) {
        int n = appearance.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = appearance.getIndex(i);

            if (attr == R.styleable.TextAppearance_android_textColorHighlight) {
                v.setHighlightColor(appearance.getColor(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_textColor) {
                v.setTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorHint) {
                v.setHintTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorLink) {
                v.setLinkTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textSize) {
                v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_typeface) {
                typefaceIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_tv_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_android_textStyle) {
                styleIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    v.setAllCaps(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_shadowColor) {
                shadowColor = appearance.getInt(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDx) {
                dx = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDy) {
                dy = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowRadius) {
                r = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setElegantTextHeight(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_letterSpacing) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setLetterSpacing(appearance.getFloat(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setFontFeatureSettings(appearance.getString(attr));

            }
        }

        appearance.recycle();
    }

    if (shadowColor != 0)
        v.setShadowLayer(r, dx, dy, shadowColor);

    Typeface tf = null;
    if (fontFamily != null) {
        tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex);
        if (tf != null)
            v.setTypeface(tf);
    }
    if(tf != null) {
        switch (typefaceIndex) {
            case 1:
                tf = Typeface.SANS_SERIF;
                break;
            case 2:
                tf = Typeface.SERIF;
                break;
            case 3:
                tf = Typeface.MONOSPACE;
                break;
        }
        v.setTypeface(tf, styleIndex);
    }
}
 
Example 18
Source File: ViewUtil.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
public static void applyTextAppearance(TextView v, int resId){
    if(resId == 0)
        return;

    String fontFamily = null;
    int typefaceIndex = -1;
    int styleIndex = -1;
    int shadowColor = 0;
    float dx = 0, dy = 0, r = 0;

    TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (appearance != null) {
        int n = appearance.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = appearance.getIndex(i);

            if (attr == R.styleable.TextAppearance_android_textColorHighlight) {
                v.setHighlightColor(appearance.getColor(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_textColor) {
                v.setTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorHint) {
                v.setHintTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorLink) {
                v.setLinkTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textSize) {
                v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_typeface) {
                typefaceIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_tv_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_android_textStyle) {
                styleIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    v.setAllCaps(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_shadowColor) {
                shadowColor = appearance.getInt(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDx) {
                dx = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDy) {
                dy = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowRadius) {
                r = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setElegantTextHeight(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_letterSpacing) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setLetterSpacing(appearance.getFloat(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setFontFeatureSettings(appearance.getString(attr));

            }
        }

        appearance.recycle();
    }

    if (shadowColor != 0)
        v.setShadowLayer(r, dx, dy, shadowColor);

    Typeface tf = null;
    if (fontFamily != null) {
        tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex);
        if (tf != null)
            v.setTypeface(tf);
    }
    if(tf != null) {
        switch (typefaceIndex) {
            case 1:
                tf = Typeface.SANS_SERIF;
                break;
            case 2:
                tf = Typeface.SERIF;
                break;
            case 3:
                tf = Typeface.MONOSPACE;
                break;
        }
        v.setTypeface(tf, styleIndex);
    }
}
 
Example 19
Source File: AdpArtists.java    From freemp with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup parent) {

    if (view == null) {
        final RelativeLayout rl = new RelativeLayout(activity);
        rl.setLayoutParams(layoutParams);

        final ImageView img = new ImageView(activity);
        RelativeLayout.LayoutParams imglp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);

        img.setPadding(10, 10, 0, 0);
        img.setId(imgid);
        //img.setLayoutParams(layoutParams);
        rl.addView(img,imglp);

        TextView tv = new TextView(activity);
        //tv.setSingleLine();
        tv.setPadding(16,0,40,0);
        RelativeLayout.LayoutParams lptv = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        lptv.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, img.getId());
        tv.setShadowLayer(1,-2,-2, Color.BLACK);
        tv.setId(tvid);

        rl.addView(tv,lptv);
        view = rl;
    }

    AQuery aq = listAq.recycle(view);


    final ClsTrack track = data.get(position);
    if (aq.shouldDelay(position, view, parent, "" + track.getArtist())) {
        aq.id(imgid).image(R.drawable.row_bgr);
    } else {
        aq.id(imgid).image(MediaUtils.getArtistQuick(activity, track, 300, 300)).animate(fadeIn);
    }
    aq.id(tvid).getTextView().setText((""+track.getArtist()));
    return view;
}
 
Example 20
Source File: CollectionGridAdapter.java    From DistroHopper with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View getView (int position, View view, ViewGroup parent)
{
	LensSearchResultCollection coll = this.getItem (position);
	boolean show = true;

	if (view == null)
		view = LayoutInflater.from (this.getContext ()).inflate (R.layout.widget_dash_lens_result_collection, parent, false);

	TextView tvLabel = (TextView) view.findViewById (R.id.tvLabel);
	GridView gvResults = (GridView) view.findViewById (R.id.gvResults);
	gvResults.setColumnWidth(Math.round((80 // 80 is the minimum
			+ this.dashIconWidth)
			* this.displayDensity)); // Adjust for the screen's pixel density

	tvLabel.setText (coll.getLens ().getName ());
	tvLabel.setTextColor (view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_colour));
	tvLabel.setShadowLayer (5, 2, 2, view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_shadow_colour));

	List<LensSearchResult> results = coll.getResults ();
	if (results == null)
	{
		results = new ArrayList<LensSearchResult> ();
		Exception ex = coll.getException ();

		if (ex != null)
		{
			if (ex instanceof UnknownHostException || ex instanceof SocketException)
			{
				ConnectivityManager connectivityManager = (ConnectivityManager) this.getContext ().getSystemService (Context.CONNECTIVITY_SERVICE);
				NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo ();

				if (! (networkInfo != null && networkInfo.isConnected ()))
					show = false;
			}

			LensSearchResult error = new LensSearchResult (this.getContext (), ex.getClass ().getSimpleName (), "error://" + ex.getMessage (), this.getContext ().getResources ().getDrawable (R.drawable.dash_search_lens_error));

			results.add (error);
		}
	}

	if (show)
	{
		gvResults.setAdapter (new GridAdapter (this.getContext (), results, this.displayDensity, this.dashIconWidth));
		gvResults.setOnItemClickListener (new LensSearchResultClickListener (coll.getLens ()));
		gvResults.setOnItemLongClickListener (new LensSearchResultLongClickListener (coll.getLens ()));

		view.setVisibility (View.VISIBLE);
	}
	else
	{
		view.setVisibility (View.GONE);
	}

	view.setTag (coll);

	return view;
}