Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bingoogolapple committed Sep 12, 2016
1 parent 2e21173 commit ce0eb11
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 78 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ proguard/
# Mac system files
.DS_Store

*.keystore
*.keystore

captures
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

Version 1.0.2 *(2016-9-12)*
----------------------------

- 当 Drawable 为 null 并且对应的文本也为空时,隐藏对应的控件

Version 1.0.1 *(2014-7-14)*
----------------------------

Expand All @@ -9,4 +14,4 @@ Version 1.0.1 *(2014-7-14)*
Version 1.0.0 *(2014-7-5)*
----------------------------

Initial release.
Initial release.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
:running:BGATitlebar-Android:running:
============

[ ![Download](https://api.bintray.com/packages/bingoogolapple/maven/bga-titlebar/images/download.svg) ](https://bintray.com/bingoogolapple/maven/bga-titlebar/_latestVersion)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-titlebar/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-titlebar)

工作以来公司UI设计师出的Android效果图都是iOS风格的Titlebar,新项目还是用原来那一套,不想重复造轮子,所以趁着这次练习 [仿新浪微博Android客户端](https://github.com/bingoogolapple/BGAWeiBo-Android)抽取一个通用的iOS风格的Titlebar
工作以来公司 UI 设计师出的 Android 效果图都是 iOS 风格的 Titlebar,新项目还是用原来那一套,不想重复造轮子,所以趁着这次练习 [仿新浪微博 Android 客户端](https://github.com/bingoogolapple/BGAWeiBo-Android)抽取一个通用的 iOS 风格的 Titlebar

>但是作为Android开发者,平时学习练手时还是得紧跟Google的步伐,说不定哪天公司的UI射击狮们就出一套MD风格的效果图
>但是作为 Android 开发者,平时学习练手时还是得紧跟 Google 的步伐,说不定哪天公司的 UI 射击狮们就出一套 MD 风格的效果图
demo中演示了各种情况的标题和新浪微博首页选择微博分类案例
demo 中演示了各种情况的标题和新浪微博首页选择微博分类案例

### 效果图
## 效果图
![bgatitlebar](https://cloud.githubusercontent.com/assets/8949716/17476247/99c19a10-5d91-11e6-85b1-55764481686e.gif)

### 基本使用
## 基本使用

#### 1.添加Gradle依赖
### 1.添加 Gradle 依赖

```groovy
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:latestVersion'
compile 'cn.bingoogolapple:bga-titlebar:latestVersion@aar'
}
```

#### 2.在布局文件中添加BGATitlebar
### 2.在布局文件中添加 BGATitlebar

```xml
<cn.bingoogolapple.titlebar.BGATitlebar
Expand All @@ -36,7 +36,7 @@ dependencies {
app:bgatitlebar_titleText="bingoogolapple" />
```

#### 3.在Activity或者Fragment中配置BGATitlebar
### 3.在 Activity 或者 Fragment中 配置 BGATitlebar

```java
mTitlebar = (BGATitlebar) findViewById(R.id.titlebar);
Expand All @@ -58,17 +58,17 @@ mTitlebar.setDelegate(new BGATitlebar.BGATitlebarDelegate() {
});
```

### 自定义属性说明
## 自定义属性说明

>建议在项目中把下面这五项定义在styles.xml里
>建议在项目中把下面这五项定义在 styles.xml 里
* bgatitlebar_leftAndRightTextColor 左右按钮文字颜色
* bgatitlebar_titleTextColor 中间标题文字颜色
* bgatitlebar_leftAndRightTextSize 左右按钮文字大小
* bgatitlebar_titleTextSize 中间标题文字大小
* bgatitlebar_leftAndRightPadding 左右按钮在水平方向上的padding

>下面这几项根据每个页面的业务写在layout中(可以把带有返回按钮的titlebar也单独抽取一个style
>下面这几项根据每个页面的业务写在 layout 中(可以把带有返回按钮的 titlebar 也单独抽取一个 style
* bgatitlebar_leftText 左边按钮的文字
* bgatitlebar_rightText 右边按钮的文字
Expand All @@ -92,7 +92,7 @@ mTitlebar.setDelegate(new BGATitlebar.BGATitlebarDelegate() {
* bgatitlebar_isLeftTextBold 左边文字是否为粗体,默认为false
* bgatitlebar_isRightTextBold 右边文字是否为粗体,默认为false

### 代码是最好的老师,更多详细用法请查看[demo](https://github.com/bingoogolapple/BGATitlebar-Android/tree/master/demo):feet:
### 代码是最好的老师,更多详细用法请查看 [demo](https://github.com/bingoogolapple/BGATitlebar-Android/tree/master/demo):feet:

## 关于我

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.android.tools.build:gradle:2.1.3'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
10 changes: 5 additions & 5 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:appcompat-v7:24.2.0'

// compile project(':library')
compile 'cn.bingoogolapple:bga-titlebar:1.0.1@aar'
compile 'cn.bingoogolapple:bga-titlebar:1.0.2@aar'


// 以下三个库只是为了演示微博分类窗口
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'cn.bingoogolapple:bga-adapter:1.0.9@aar'
compile 'cn.bingoogolapple:bga-badgeview:1.1.1@aar'
compile 'cn.bingoogolapple:bga-adapter:1.1.0@aar'
compile 'cn.bingoogolapple:bga-badgeview:1.1.3@aar'
}
13 changes: 8 additions & 5 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.bingoogolapple.titlebar.demo">
xmlns:tools="http://schemas.android.com/tools"
package="cn.bingoogolapple.titlebar.demo">

<uses-sdk tools:overrideLibrary="cn.bingoogolapple.badgeview"/>

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name=".App">
android:theme="@style/AppTheme">
<activity
android:name=".ui.activity.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void testTitleText1() {
// 取消默认的单行
titlebar3.getTitleCtv().setSingleLine(false);
// 设置行间距
titlebar3.getTitleCtv().setLineSpacing(3,1);
titlebar3.getTitleCtv().setLineSpacing(3, 1);

String sendWeiBo = "发微博";
String username = "bingoogolapple";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onClick(View v) {

public void setCategorys(List<HomeCategory> homeCategories) {
mHomeCategories = homeCategories;
mCategoryAdapter.setDatas(mHomeCategories);
mCategoryAdapter.setData(mHomeCategories);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ANDROID_BUILD_MIN_SDK_VERSION=10
ANDROID_BUILD_TARGET_SDK_VERSION=24
ANDROID_BUILD_SDK_VERSION=24
ANDROID_BUILD_TOOLS_VERSION=24.0.0
ANDROID_BUILD_TOOLS_VERSION=24.0.2

VERSION_NAME=1.0.1
VERSION_CODE=101
VERSION_NAME=1.0.2
VERSION_CODE=102
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun May 29 03:07:47 CST 2016
#Mon Sep 12 17:56:00 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
9 changes: 3 additions & 6 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:24.0.0'
provided 'com.android.support:appcompat-v7:24.2.0'
}

//apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/project/library/android-artifacts.gradle'
// 上传到Maven中央仓库 gradle -q uploadArchives
//apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/project/library/central-publish.gradle'
// 上传到jCenter gradle bintrayUpload
//apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/project/library/bintray-publish.gradle'
// gradle uploadArchives
//apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/central-publish.gradle'
25 changes: 3 additions & 22 deletions library/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
GROUP=cn.bingoogolapple
POM_NAME=Android Common Titlebar Library
POM_ARTIFACT_ID=bga-titlebar
POM_PACKAGING=aar

POM_DESCRIPTION=Android Common Titlebar Library
POM_URL=https://github.com/bingoogolapple/BGATitlebar-Android
POM_SCM_URL=scm:[email protected]:bingoogolapple/BGATitlebar-Android.git
POM_SCM_CONNECTION=scm:[email protected]:bingoogolapple/BGATitlebar-Android.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:bingoogolapple/BGATitlebar-Android.git

POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=bingoogolapple
POM_DEVELOPER_NAME=bingoogolapple
POM_DEVELOPER_EMAIL[email protected]
POM_DEVELOPER_URL=bingoogolapple.cn

ISSUE_URL=https://github.com/bingoogolapple/BGATitlebar-Android/issues
GIT_URL=https://github.com/bingoogolapple/BGATitlebar-Android.git
PUBLISH_AAR_ARTIFACT_ID=bga-titlebar
PUBLISH_AAR_DESCRIPTION=Android Common Titlebar Library
PUBLISH_AAR_GITHUB_REPOSITORIES_NAME=BGATitlebar-Android
73 changes: 58 additions & 15 deletions library/src/main/java/cn/bingoogolapple/titlebar/BGATitlebar.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.annotation.IdRes;
import android.support.annotation.StringRes;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
Expand Down Expand Up @@ -133,14 +134,28 @@ public void setLeftText(@StringRes int resid) {
}

public void setLeftText(CharSequence text) {
mLeftCtv.setText(text);
showLeftCtv();
if (TextUtils.isEmpty(text)) {
mLeftCtv.setText("");
if (mLeftCtv.getCompoundDrawables()[0] == null) {
hiddenLeftCtv();
}
} else {
mLeftCtv.setText(text);
showLeftCtv();
}
}

public void setLeftDrawable(Drawable drawable) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mLeftCtv.setCompoundDrawables(drawable, null, null, null);
showLeftCtv();
if (drawable == null) {
mLeftCtv.setCompoundDrawables(null, null, null, null);
if (TextUtils.isEmpty(mLeftCtv.getText())) {
hiddenLeftCtv();
}
} else {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mLeftCtv.setCompoundDrawables(drawable, null, null, null);
showLeftCtv();
}
}

public void hiddenTitleCtv() {
Expand All @@ -152,18 +167,32 @@ public void showTitleCtv() {
}

public void setTitleText(CharSequence text) {
mTitleCtv.setText(text);
showTitleCtv();
if (TextUtils.isEmpty(text)) {
mTitleCtv.setText("");
if (mTitleCtv.getCompoundDrawables()[2] == null) {
hiddenTitleCtv();
}
} else {
mTitleCtv.setText(text);
showTitleCtv();
}
}

public void setTitleText(@StringRes int resid) {
setTitleText(getResources().getString(resid));
}

public void setTitleDrawable(Drawable drawable) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mTitleCtv.setCompoundDrawables(null, null, drawable, null);
showTitleCtv();
if (drawable == null) {
mTitleCtv.setCompoundDrawables(null, null, null, null);
if (TextUtils.isEmpty(mTitleCtv.getText())) {
hiddenTitleCtv();
}
} else {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mTitleCtv.setCompoundDrawables(null, null, drawable, null);
showTitleCtv();
}
}

public void hiddenRightCtv() {
Expand All @@ -175,18 +204,32 @@ public void showRightCtv() {
}

public void setRightText(CharSequence text) {
mRightCtv.setText(text);
showRightCtv();
if (TextUtils.isEmpty(text)) {
mRightCtv.setText("");
if (mRightCtv.getCompoundDrawables()[2] == null) {
hiddenRightCtv();
}
} else {
mRightCtv.setText(text);
showRightCtv();
}
}

public void setRightText(@StringRes int resid) {
setRightText(getResources().getString(resid));
}

public void setRightDrawable(Drawable drawable) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mRightCtv.setCompoundDrawables(null, null, drawable, null);
showRightCtv();
if (drawable == null) {
mRightCtv.setCompoundDrawables(null, null, null, null);
if (TextUtils.isEmpty(mRightCtv.getText())) {
hiddenRightCtv();
}
} else {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mRightCtv.setCompoundDrawables(null, null, drawable, null);
showRightCtv();
}
}

public void setLeftCtvChecked(boolean checked) {
Expand Down

0 comments on commit ce0eb11

Please sign in to comment.