Skip to content

Commit

Permalink
add icon and rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
javaeryang committed Jul 22, 2018
1 parent b7065e0 commit 3f02e12
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 3 deletions.
15 changes: 15 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,18 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-repackageclass ""
-allowaccessmodification
-keepattributes SourceFile,LineNumberTable

-optimizationpasses 5
-allowaccessmodification
-dontpreverify
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-keep public class xposed.Main
-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.** { *;}
-dontwarn okio.**
6 changes: 3 additions & 3 deletions app/src/main/java/aweme/CustomButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ public CustomButton(Context context) {
private void init() {
int strokeWidth = 2;
int roundRadius = 12;
int strokeColor = Color.parseColor("#606066");
int strokeColor = Color.parseColor("#606060");

GradientDrawable drawable = new GradientDrawable();
drawable.setAlpha(80);
drawable.setAlpha(90);
drawable.setCornerRadius(roundRadius);
drawable.setStroke(strokeWidth, strokeColor);
ColorStateList colorStateList = createColorStateList(0xffffffff, 0xffffff00, 0xff0000ff, 0xffff0000);
drawable.setColor(colorStateList);
this.setBackground(drawable);
}

private ColorStateList createColorStateList(int normal, int pressed, int focused, int unable) {
public static ColorStateList createColorStateList(int normal, int pressed, int focused, int unable) {
int[] colors = new int[]{pressed, focused, normal, focused, unable, normal};
int[][] states = new int[6][];
states[0] = new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled};
Expand Down
62 changes: 62 additions & 0 deletions app/src/main/java/aweme/ui/adapter/InfoAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package aweme.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;

import aweme.ui.base.BaseListAdapter;
import data.Info;

/**
* Created by Administrator on 2018/7/22.
*/
@SuppressWarnings("ResourceType")
public class InfoAdapter extends BaseListAdapter<Info>{

public InfoAdapter(Context context) {
super(context);
}

@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
RelativeLayout layout = new RelativeLayout(getContext());
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

TextView title = new TextView(getContext());
LayoutParams title_params = new LayoutParams(LayoutParams.WRAP_CONTENT, dp2px(40));
title_params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
title_params.setMargins(dp2px(10), 0, 0, 0);
title.setLayoutParams(title_params);

TextView subTitle = new TextView(getContext());
LayoutParams subTitle_params = new LayoutParams(LayoutParams.WRAP_CONTENT, dp2px(40));
subTitle_params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
subTitle_params.setMargins(0, 0, 0, dp2px(10));
subTitle.setLayoutParams(subTitle_params);

layout.addView(title);
layout.addView(subTitle);
return layout;
}

@Override
public ViewHolder<Info> onCreateViewHolder(View view, int viewType) {
return new InfoHolder(view, this);
}

public final class InfoHolder extends ViewHolder<Info>{

public InfoHolder(View view, BaseListAdapter<Info> baseListAdapter) {
super(view, baseListAdapter);
}

@Override
public void onBind(int position, int viewType) {

}
}
}
150 changes: 150 additions & 0 deletions app/src/main/java/aweme/ui/base/BaseListAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package aweme.ui.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
* Created by Administrator on 2018/7/22.
*/

public abstract class BaseListAdapter<T> extends BaseAdapter{
private Context mContext;
private List<T> mItems;
private LayoutInflater mLayoutInflater;

public BaseListAdapter(Context context) {
mContext = context;
mLayoutInflater = LayoutInflater.from(context);
}

public List<T> getmItems(){
return mItems;
}

public Context getContext(){
return mContext;
}

public void setItems(List<T> items){
mItems = items;
}

@Override
public int getCount() {
return mItems == null ? 0 : mItems.size();
}

@Override
public T getItem(int position) {
return mItems == null ? null : mItems.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

int viewType = getItemViewType(position);

if (convertView == null){

//创建View
convertView = onCreateView(mLayoutInflater, parent, viewType);

//创建ViewHolder
ViewHolder<T> viewHolder = onCreateViewHolder(convertView, viewType);

//初始化操作
if (viewHolder != null) viewHolder.onInitialize();

//保存
convertView.setTag(viewHolder);
}

ViewHolder<T> viewHolder = (ViewHolder<T>) convertView.getTag();

if (viewHolder != null){
//进行绑定
viewHolder.mPosition = position;
viewHolder.onBind(position,viewType);
}

return convertView;
}

/**
* 实例显示的View
* @param layoutInflater
* @param parent
* @param viewType
* @return
*/
public abstract View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType);

/**
* 初始化View
* @param view
* @param viewType
* @return
*/
public abstract ViewHolder<T> onCreateViewHolder(View view, int viewType);

public abstract class ViewHolder<T>{

protected int mPosition;
protected View mItemView;
private BaseListAdapter<T> mBaseListAdapter;

public ViewHolder(View view, BaseListAdapter<T> baseListAdapter) {
this.mItemView = view;
this.mBaseListAdapter = baseListAdapter;
}

public void onInitialize(){

}

public View getItemView(){
return mItemView;
}

/**
* 绑定View, 用于数据跟View进行绑定
* @param position
* @param viewType
*/
public abstract void onBind(int position, int viewType);

/**
* 获取指定索引id的内容信息
* @param position 索引id
* @return 指定id的内容信息
*/
public T getItem(int position){
return mBaseListAdapter.getItem(position);
}

/**
* 获取适配器中数据下标
* @return
*/
public int getAdapterPosition() {
return mPosition;
}
}

protected int dp2px(float dp){
final float scale = getContext().getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);

}

}
40 changes: 40 additions & 0 deletions app/src/main/java/data/Info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package data;

/**
* Created by Administrator on 2018/7/22.
*/

public class Info {

//normal 0
//with subTitle 1
//update info 2

int type;
String title;
String subTitle;

public int getType() {
return type;
}

public String getTitle() {
return title;
}

public String getSubTitle() {
return subTitle;
}

public void setType(int type) {
this.type = type;
}

public void setTitle(String title) {
this.title = title;
}

public void setSubTitle(String subTitle) {
this.subTitle = subTitle;
}
}

0 comments on commit 3f02e12

Please sign in to comment.