Skip to content

Instantly share code, notes, and snippets.

View goodev's full-sized avatar

Goodev goodev

View GitHub Profile
@goodev
goodev / MainActivity.java
Created July 21, 2012 08:09 — forked from romannurik/SwipeDismissListViewTouchListener.java
**BETA** Android 4.0-style "Swipe to Dismiss" sample code
// THIS IS A BETA! I DON'T RECOMMEND USING IT IN PRODUCTION CODE JUST YET
/*
* Copyright 2012 Roman Nurik
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@goodev
goodev / L.java
Created October 31, 2013 05:55
Convenience class for logging. Logs the given parameters plus the calling class and line as a tag and the calling method's name modified from : https://github.com/ANDLABS-Git/AndlabsAndroidUtils/blob/master/library/src/com/andlabs/androidutils/logging/L.java
package org.goodev;
import android.util.Log;
import org.goodev.BuildConfig;
/**
* https://github.com/ANDLABS-Git/AndlabsAndroidUtils/blob/master/library/src/com/andlabs/androidutils/logging/L.java
*
* <pre>
@goodev
goodev / NotificationLayoutItem.java
Last active December 29, 2015 01:59
HolerView 模式示例
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@goodev
goodev / styles.xml
Created November 27, 2013 05:26
Overlay 模式 和 透明 ActionBar
<resources>
<style name="TransparentTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:windowBackground">@null</item>
<item name="android:actionBarStyle">@style/ActionBarStyle.Transparent</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<style name="ActionBarStyle.Transparent" parent="@android:Widget.ActionBar">
<item name="android:background">@null</item>
@goodev
goodev / main.xml
Created November 27, 2013 05:50
布局
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NoBoringActionBarActivity">
<ListView
android:id="@+id/listview"
@goodev
goodev / view_header_placeholder.xml
Created November 27, 2013 05:50
ListView 的 header
<?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="@dimen/header_height"
android:orientation="vertical">
</LinearLayout>
@goodev
goodev / main.java
Created November 27, 2013 05:52
添加虚拟的 ListView header
mFakeHeader = getLayoutInflater().inflate(R.layout.fake_header, mListView, false);
mListView.addHeaderView(mFakeHeader);
@goodev
goodev / main.java
Created November 27, 2013 05:53
获取 ListView 的滚动位置
public int getScrollY() {
View c = mListView.getChildAt(0);
if (c == null) {
return 0;
}
int firstVisiblePosition = mListView.getFirstVisiblePosition();
int top = c.getTop();
int headerHeight = 0;
@goodev
goodev / main.java
Created November 27, 2013 05:54
移动 header view
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int scrollY = getScrollY();
//sticky actionbar
mHeader.setTranslationY(Math.max(-scrollY, mMinHeaderTranslation));
@goodev
goodev / main.java
Last active December 29, 2015 12:29
获取 ActionBar 的 title view 并设置 初始 Alpha 值
private TextView getActionBarTitleView() {
int id = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
return (TextView) findViewById(id);
}
getActionBarTitleView().setAlpha(0f);