-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
574 additions
and
645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
402 changes: 92 additions & 310 deletions
402
qmui/src/main/java/com/qmuiteam/qmui/widget/dialog/QMUIBottomSheet.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
qmui/src/main/java/com/qmuiteam/qmui/widget/dialog/QMUIBottomSheetGridItemModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making QMUI_Android available. | ||
* | ||
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.qmuiteam.qmui.widget.dialog; | ||
|
||
import android.graphics.Typeface; | ||
import android.graphics.drawable.Drawable; | ||
|
||
public class QMUIBottomSheetGridItemModel { | ||
Drawable image = null; | ||
int imageRes = 0; | ||
int imageSkinTintColorAttr = 0; | ||
int imageSkinSrcAttr = 0; | ||
int textSkinColorAttr = 0; | ||
CharSequence text; | ||
Object tag = ""; | ||
Drawable subscript = null; | ||
int subscriptRes = 0; | ||
int subscriptSkinTintColorAttr = 0; | ||
int subscriptSkinSrcAttr = 0; | ||
Typeface typeface; | ||
|
||
public QMUIBottomSheetGridItemModel(CharSequence text, Object tag) { | ||
this.text = text; | ||
this.tag = tag; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel image(Drawable image) { | ||
this.image = image; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel image(int imageRes) { | ||
this.imageRes = imageRes; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel subscript(Drawable image) { | ||
this.subscript = image; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel subscript(int imageRes) { | ||
this.subscriptRes = imageRes; | ||
return this; | ||
} | ||
|
||
|
||
public QMUIBottomSheetGridItemModel skinTextColorAttr(int attr) { | ||
this.textSkinColorAttr = attr; | ||
return this; | ||
} | ||
|
||
|
||
public QMUIBottomSheetGridItemModel skinImageTintColorAttr(int attr) { | ||
this.imageSkinTintColorAttr = attr; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel skinImageSrcAttr(int attr) { | ||
this.imageSkinSrcAttr = attr; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel skinSubscriptTintColorAttr(int attr) { | ||
this.subscriptSkinTintColorAttr = attr; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel skinSubscriptSrcAttr(int attr) { | ||
this.subscriptSkinSrcAttr = attr; | ||
return this; | ||
} | ||
|
||
public QMUIBottomSheetGridItemModel typeface(Typeface typeface) { | ||
this.typeface = typeface; | ||
return this; | ||
} | ||
|
||
} |
163 changes: 163 additions & 0 deletions
163
qmui/src/main/java/com/qmuiteam/qmui/widget/dialog/QMUIBottomSheetGridItemView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making QMUI_Android available. | ||
* | ||
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.qmuiteam.qmui.widget.dialog; | ||
|
||
import android.content.Context; | ||
import android.graphics.drawable.Drawable; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.qmuiteam.qmui.R; | ||
import com.qmuiteam.qmui.layout.QMUIConstraintLayout; | ||
import com.qmuiteam.qmui.skin.QMUISkinHelper; | ||
import com.qmuiteam.qmui.skin.QMUISkinManager; | ||
import com.qmuiteam.qmui.skin.QMUISkinValueBuilder; | ||
import com.qmuiteam.qmui.skin.defaultAttr.QMUISkinSimpleDefaultAttrProvider; | ||
import com.qmuiteam.qmui.util.QMUIResHelper; | ||
import com.qmuiteam.qmui.widget.textview.QMUISpanTouchFixTextView; | ||
|
||
import androidx.appcompat.widget.AppCompatImageView; | ||
import androidx.core.content.ContextCompat; | ||
|
||
|
||
public class QMUIBottomSheetGridItemView extends QMUIConstraintLayout { | ||
|
||
private AppCompatImageView mIconIv; | ||
private AppCompatImageView mSubscriptIv; | ||
private TextView mTitleTv; | ||
|
||
|
||
public QMUIBottomSheetGridItemView(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public QMUIBottomSheetGridItemView(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public QMUIBottomSheetGridItemView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
setChangeAlphaWhenPress(true); | ||
int paddingVer = QMUIResHelper.getAttrDimen(context, R.attr.qmui_bottom_sheet_grid_item_padding_ver); | ||
setPadding(0, paddingVer, 0, paddingVer); | ||
mIconIv = new AppCompatImageView(context); | ||
mIconIv.setId(View.generateViewId()); | ||
mIconIv.setScaleType(ImageView.ScaleType.CENTER_INSIDE); | ||
|
||
int iconSize = QMUIResHelper.getAttrDimen(context, R.attr.qmui_bottom_sheet_grid_item_icon_size); | ||
LayoutParams iconLp = new LayoutParams(iconSize, iconSize); | ||
iconLp.leftToLeft = LayoutParams.PARENT_ID; | ||
iconLp.rightToRight = LayoutParams.PARENT_ID; | ||
iconLp.topToTop = LayoutParams.PARENT_ID; | ||
addView(mIconIv, iconLp); | ||
|
||
mTitleTv = new QMUISpanTouchFixTextView(context); | ||
mTitleTv.setId(View.generateViewId()); | ||
QMUISkinSimpleDefaultAttrProvider provider = new QMUISkinSimpleDefaultAttrProvider(); | ||
provider.setDefaultSkinAttr(QMUISkinValueBuilder.TEXT_COLOR, | ||
R.attr.qmui_skin_support_bottom_sheet_grid_item_text_color); | ||
QMUIResHelper.assignTextViewWithAttr(mTitleTv, R.attr.qmui_bottom_sheet_grid_item_text_style); | ||
QMUISkinHelper.setSkinDefaultProvider(mTitleTv, provider); | ||
|
||
LayoutParams titleLp = new LayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); | ||
titleLp.leftToLeft = LayoutParams.PARENT_ID; | ||
titleLp.rightToRight = LayoutParams.PARENT_ID; | ||
titleLp.topToBottom = mIconIv.getId(); | ||
titleLp.topMargin = QMUIResHelper.getAttrDimen( | ||
context, R.attr.qmui_bottom_sheet_grid_item_text_margin_top); | ||
addView(mTitleTv, titleLp); | ||
} | ||
|
||
public void render(QMUIBottomSheetGridItemModel model) { | ||
QMUISkinValueBuilder builder = QMUISkinValueBuilder.acquire(); | ||
if (model.imageSkinSrcAttr != 0) { | ||
builder.src(model.imageSkinSrcAttr); | ||
QMUISkinHelper.setSkinValue(mIconIv, builder); | ||
Drawable drawable = QMUISkinHelper.getSkinDrawable(mIconIv, model.imageSkinSrcAttr); | ||
mIconIv.setImageDrawable(drawable); | ||
} else { | ||
Drawable drawable = model.image; | ||
if (drawable == null && model.imageRes != 0) { | ||
drawable = ContextCompat.getDrawable(getContext(), model.imageRes); | ||
} | ||
if (drawable != null) { | ||
drawable.mutate(); | ||
} | ||
mIconIv.setImageDrawable(drawable); | ||
if (model.imageSkinTintColorAttr != 0) { | ||
builder.tintColor(model.imageSkinTintColorAttr); | ||
QMUISkinHelper.setSkinValue(mIconIv, builder); | ||
QMUISkinManager.defaultInstance(getContext()).refreshTheme(mIconIv); | ||
} else { | ||
QMUISkinHelper.setSkinValue(mIconIv, ""); | ||
} | ||
} | ||
builder.clear(); | ||
mTitleTv.setText(model.text); | ||
if (model.textSkinColorAttr != 0) { | ||
builder.textColor(model.textSkinColorAttr); | ||
} | ||
QMUISkinHelper.setSkinValue(mTitleTv, builder); | ||
QMUISkinManager.defaultInstance(getContext()).refreshTheme(mTitleTv); | ||
if(model.typeface != null){ | ||
mTitleTv.setTypeface(model.typeface); | ||
} | ||
builder.clear(); | ||
|
||
if (model.subscriptRes != 0 || model.subscript != null || model.subscriptSkinSrcAttr != 0) { | ||
if (mSubscriptIv == null) { | ||
mSubscriptIv = new AppCompatImageView(getContext()); | ||
mSubscriptIv.setScaleType(ImageView.ScaleType.CENTER_INSIDE); | ||
LayoutParams lp = new LayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); | ||
lp.rightToRight = mIconIv.getId(); | ||
lp.topToTop = mIconIv.getId(); | ||
addView(mSubscriptIv, lp); | ||
} | ||
mSubscriptIv.setVisibility(View.VISIBLE); | ||
if (model.subscriptSkinSrcAttr != 0) { | ||
builder.src(model.subscriptSkinSrcAttr); | ||
QMUISkinHelper.setSkinValue(mSubscriptIv, builder); | ||
Drawable drawable = QMUISkinHelper.getSkinDrawable(mSubscriptIv, model.subscriptSkinSrcAttr); | ||
mIconIv.setImageDrawable(drawable); | ||
} else { | ||
Drawable drawable = model.subscript; | ||
if (drawable == null && model.subscriptRes != 0) { | ||
drawable = ContextCompat.getDrawable(getContext(), model.subscriptRes); | ||
} | ||
if (drawable != null) { | ||
drawable.mutate(); | ||
} | ||
mSubscriptIv.setImageDrawable(drawable); | ||
if (model.subscriptSkinTintColorAttr != 0) { | ||
builder.tintColor(model.subscriptSkinTintColorAttr); | ||
QMUISkinHelper.setSkinValue(mSubscriptIv, builder); | ||
QMUISkinManager.defaultInstance(getContext()).refreshTheme(mSubscriptIv); | ||
} else { | ||
QMUISkinHelper.setSkinValue(mSubscriptIv, ""); | ||
} | ||
} | ||
} else if (mSubscriptIv != null) { | ||
mSubscriptIv.setVisibility(View.GONE); | ||
} | ||
builder.release(); | ||
} | ||
} |
Oops, something went wrong.