Skip to content

Instantly share code, notes, and snippets.

@ataulm
ataulm / gist:0f359f8ae836908dca50
Last active August 29, 2015 14:01
look Antonio, no hands!
package com.ataulm.mijur.view;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class MatchParentWidthImageView extends ImageView {
public MatchParentWidthImageView(Context context, AttributeSet attrs) {
username=buzzlightyear
password=notachildsplaything
public interface AppBarExpander {
void expandAppBar();
void collapseAppBar();
}
public class SeasonsActivity extends AppCompatActivity implements AppBarExpander {
...
@Override
AppBarExpander appBarExpander;
...
final RecyclerView view = (RecyclerView) layoutInflater.inflate(R.layout.view_season_page, container, false);
view.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
view.setLayoutManager(new LinearLayoutManager(container.getContext()) {
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/beginning"
android:layout_width="wrap_content"
beginning.text = "A Short Story"
middle.text = "This is a short story"
end.text = "fin."
/**
* Handles the splitting of {@link URLSpan}s into multiple
* {@link FeedbackFragment}s.
*
* @param fragment The fragment containing the spannable text to process.
* @param span The individual {@link StyleSpan} that represents the span
*/
private static void handleStyleSpan(FeedbackFragment fragment, StyleSpan span) {
final int style = span.getStyle();
/**
* Handles {@link FeedbackFragment} with {@link ClickableSpan} (including {@link URLSpan]}). Adds
* earcon and pitch information to the fragment.
*
* @param fragment The fragment containing {@link ClickableSpan}.
*/
private static void handleClickableSpan(FeedbackFragment fragment) {
final Bundle speechParams = new Bundle(Bundle.EMPTY);
speechParams.putFloat(SpeechParam.PITCH, PITCH_CHANGE_HYPERLINK);
fragment.setSpeechParams(speechParams);
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_my)
story.text = writeFormattedStory()
}
private fun writeFormattedStory(): CharSequence {
return SpannableStringBuilder()
.append(createWithSpans("A Short Story", StyleSpan(Typeface.BOLD)))
.append("\n")
@ataulm
ataulm / adb-demo.sh
Last active May 1, 2019 07:35
Clean status bar for Android
#!/bin/sh
# source: https://android.jlelse.eu/clean-your-status-bar-like-a-pro-76c89a1e2c2f
# Add these aliases to your `~/.profile`
# alias demoOn='sh /Users/<username>/scripts/adb-demo.sh on'
# alias demoOff='sh /Users/<username>/scripts/adb-demo.sh off'
CMD=$1
if [[ $CMD != "on" && $CMD != "off" ]]; then