Commit bebbeaf2f0d2f5624ffa0b0797c0b84d75f7d787

Authored by 谷俊
2 parents 9921f315 54453777

合并

Showing 100 changed files with 272 additions and 385 deletions

Too many changes to show.

To preserve performance only 100 of 234 files are displayed.

.idea/encodings.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <project version="4">
3   - <component name="Encoding">
  3 + <component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8">
4 4 <file url="PROJECT" charset="UTF-8" />
5 5 </component>
6 6 </project>
7 7 \ No newline at end of file
... ...
.idea/inspectionProfiles/Project_Default.xml
... ... @@ -2,6 +2,7 @@
2 2 <profile version="1.0">
3 3 <option name="myName" value="Project Default" />
4 4 <inspection_tool class="AndroidLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" />
  5 + <inspection_tool class="AndroidLintSetTextI18n" enabled="false" level="WARNING" enabled_by_default="false" />
5 6 <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
6 7 <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
7 8 <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
... ...
.idea/markdown-navigator.xml deleted 100644 → 0
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project version="4">
3   - <component name="MarkdownProjectSettings">
4   - <PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="true" showSelectionInPreview="true">
5   - <PanelProvider>
6   - <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
7   - </PanelProvider>
8   - </PreviewSettings>
9   - <ParserSettings gitHubSyntaxChange="false">
10   - <PegdownExtensions>
11   - <option name="ABBREVIATIONS" value="false" />
12   - <option name="ANCHORLINKS" value="true" />
13   - <option name="ASIDE" value="false" />
14   - <option name="ATXHEADERSPACE" value="true" />
15   - <option name="AUTOLINKS" value="true" />
16   - <option name="DEFINITIONS" value="false" />
17   - <option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
18   - <option name="FENCED_CODE_BLOCKS" value="true" />
19   - <option name="FOOTNOTES" value="false" />
20   - <option name="HARDWRAPS" value="false" />
21   - <option name="INSERTED" value="false" />
22   - <option name="QUOTES" value="false" />
23   - <option name="RELAXEDHRULES" value="true" />
24   - <option name="SMARTS" value="false" />
25   - <option name="STRIKETHROUGH" value="true" />
26   - <option name="SUBSCRIPT" value="false" />
27   - <option name="SUPERSCRIPT" value="false" />
28   - <option name="SUPPRESS_HTML_BLOCKS" value="false" />
29   - <option name="SUPPRESS_INLINE_HTML" value="false" />
30   - <option name="TABLES" value="true" />
31   - <option name="TASKLISTITEMS" value="true" />
32   - <option name="TOC" value="false" />
33   - <option name="WIKILINKS" value="true" />
34   - </PegdownExtensions>
35   - <ParserOptions>
36   - <option name="COMMONMARK_LISTS" value="false" />
37   - <option name="DUMMY" value="false" />
38   - <option name="EMOJI_SHORTCUTS" value="true" />
39   - <option name="FLEXMARK_FRONT_MATTER" value="false" />
40   - <option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="true" />
41   - <option name="GFM_TABLE_RENDERING" value="true" />
42   - <option name="GITBOOK_URL_ENCODING" value="false" />
43   - <option name="GITHUB_EMOJI_URL" value="false" />
44   - <option name="GITHUB_LISTS" value="true" />
45   - <option name="GITHUB_WIKI_LINKS" value="true" />
46   - <option name="JEKYLL_FRONT_MATTER" value="false" />
47   - <option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
48   - </ParserOptions>
49   - </ParserSettings>
50   - <HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
51   - <GeneratorProvider>
52   - <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
53   - </GeneratorProvider>
54   - <headerTop />
55   - <headerBottom />
56   - <bodyTop />
57   - <bodyBottom />
58   - </HtmlSettings>
59   - <CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
60   - <StylesheetProvider>
61   - <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
62   - </StylesheetProvider>
63   - <ScriptProviders />
64   - <cssText />
65   - </CssSettings>
66   - <HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
67   - <LinkMapSettings>
68   - <textMaps />
69   - </LinkMapSettings>
70   - </component>
71   -</project>
72 0 \ No newline at end of file
.idea/markdown-navigator/profiles_settings.xml deleted 100644 → 0
1   -<component name="MarkdownNavigator.ProfileManager">
2   - <settings default="" pdf-export="" />
3   -</component>
4 0 \ No newline at end of file
.idea/modules.xml
... ... @@ -3,7 +3,6 @@
3 3 <component name="ProjectModuleManager">
4 4 <modules>
5 5 <module fileurl="file://$PROJECT_DIR$/CNLiveApp.iml" filepath="$PROJECT_DIR$/CNLiveApp.iml" />
6   - <module fileurl="file://$PROJECT_DIR$/CNLiveApp5.iml" filepath="$PROJECT_DIR$/CNLiveApp5.iml" />
7 6 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
8 7 <module fileurl="file://$PROJECT_DIR$/user/user.iml" filepath="$PROJECT_DIR$/user/user.iml" />
9 8 </modules>
... ...
.idea/vcs.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <project version="4">
3 3 <component name="VcsDirectoryMappings">
4   - <mapping directory="$PROJECT_DIR$" vcs="Git" />
  4 + <mapping directory="" vcs="Git" />
5 5 </component>
6 6 </project>
7 7 \ No newline at end of file
... ...
app/src/main/AndroidManifest.xml
... ... @@ -53,6 +53,7 @@
53 53 android:launchMode="singleTop"
54 54 android:screenOrientation="portrait"
55 55 android:windowSoftInputMode="adjustResize" />
  56 +
56 57 <activity android:name=".user.activity.LoginActivity"/>
57 58  
58 59 <receiver
... ...
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
... ... @@ -9,13 +9,14 @@ import android.view.LayoutInflater;
9 9 import android.view.View;
10 10 import android.view.ViewGroup;
11 11  
  12 +import com.bumptech.glide.Glide;
12 13 import com.cnlive.gundam.R;
13 14 import com.cnlive.gundam.databinding.UserFragmentBinding;
14 15 import com.cnlive.gundam.user.activity.CommentActivity;
15 16 import com.cnlive.gundam.user.activity.LoginActivity;
16 17 import com.cnlive.gundam.user.activity.UserPersonalActivity;
17 18 import com.cnlive.gundam.user.auth.UserService;
18   -
  19 +import com.cnlive.gundam.user.model.User;
19 20  
20 21  
21 22 /**
... ... @@ -29,7 +30,6 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
29 30 @Override
30 31 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
31 32 binding = DataBindingUtil.inflate(inflater, R.layout.user_fragment, container, false);
32   -
33 33 return binding.getRoot();
34 34 }
35 35  
... ... @@ -40,24 +40,14 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
40 40 }
41 41  
42 42  
43   - /* public static Fragment newInstance() {
44   - UserFragment fragment = new UserFragment();
45   - return fragment;
46   - }*/
47   -
48 43 @Override
49 44 public void onActivityCreated(Bundle savedInstanceState) {
50 45 super.onActivityCreated(savedInstanceState);
51 46  
52   -
53   - /*initToolBar();
54   - init();
55   - MyHeadItem.getContent(getActivity());*/
56 47 }
57 48  
58 49 private void initUI() {
59 50 binding.configHeader.setOnClickListener(this);
60   - binding.live.setOnClickListener(this);
61 51 binding.message.setOnClickListener(this);
62 52 }
63 53  
... ... @@ -65,10 +55,11 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
65 55 @Override
66 56 public void onClick(View view) {
67 57 switch (view.getId()) {
68   -
69   -
70 58 case R.id.config_header:
71 59 int uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid();
  60 + if (uid != 0)
  61 + startActivity(new Intent(getActivity(), UserPersonalActivity.class));
  62 + else
72 63 if (uid != 0) {
73 64 //进入个人中心页面
74 65 Intent intent = new Intent(getActivity(), UserPersonalActivity.class);
... ... @@ -77,18 +68,25 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
77 68 } else {
78 69 //进入登录页面
79 70 startActivity(new Intent(getActivity(), LoginActivity.class));
80   - }
81   -
82 71 break;
83   - case R.id.live:
84 72  
85   - break;
86 73 case R.id.message:
87 74 startActivity(new Intent(getActivity(), CommentActivity.class));
88   -
89 75 break;
90 76  
91 77 }
92 78  
93 79 }
  80 +
  81 + @Override
  82 + public void onResume() {
  83 + super.onResume();
  84 + if (UserService.getInstance(getActivity()).getActiveAccountInfo().getUid() != 0) notifyUI();
  85 + }
  86 +
  87 + private void notifyUI() {
  88 + User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo();
  89 + Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg);
  90 + binding.tvNickname.setText(activeAccountInfo.getNickname());
  91 + }
94 92 }
... ...
app/src/main/java/com/cnlive/gundam/user/activity/LoginActivity.java
... ... @@ -34,9 +34,7 @@ public class LoginActivity extends AppCompatActivity {
34 34 // TODO Auto-generated method stub
35 35 if(ev.getAction()== MotionEvent.ACTION_DOWN){
36 36  
37   - // 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点)
38 37 View v=getCurrentFocus();
39   -
40 38 if(DevilUtil.isShouldHideInput(v,ev)){
41 39 InputMethodManager im=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
42 40 DevilUtil.hideSoftInput(v.getWindowToken(),im);
... ...
app/src/main/java/com/cnlive/gundam/user/fragment/FeedbackFragment.java
... ... @@ -67,7 +67,7 @@ public class FeedbackFragment extends Fragment implements View.OnClickListener {
67 67 public void onClick(View v) {
68 68 int i = v.getId();
69 69 if (i == R.id.back_selector) {//返回上一页面
70   - getFragmentManager().popBackStack();
  70 + getActivity().finish();
71 71  
72 72 } else if (i == R.id.feedback) {
73 73 /**
... ... @@ -94,7 +94,7 @@ public class FeedbackFragment extends Fragment implements View.OnClickListener {
94 94 switch (what) {
95 95 case IUserService.SUCCESS:
96 96 ToastUtil.show(getActivity(), "反馈成功");
97   - getFragmentManager().popBackStack();
  97 + getActivity().finish();
98 98 break;
99 99 case IUserService.ERROR_PARAM:
100 100 ToastUtil.show(getActivity(), IUserService.message_error_param);
... ...
app/src/main/java/com/cnlive/gundam/user/fragment/LoginFragment.java
... ... @@ -34,7 +34,6 @@ public class LoginFragment extends Fragment implements View.OnClickListener {
34 34 public static DataEntity data;
35 35  
36 36 private Account account;//密码登录的account
37   - private Account account1;//第三方登录的account
38 37  
39 38 //跳转页面的对话框
40 39 private ProgressDialog dialog;
... ... @@ -155,8 +154,9 @@ public class LoginFragment extends Fragment implements View.OnClickListener {
155 154 closeDialog();
156 155 UserData userData = (UserData) obj;
157 156 data = userData.getData();
  157 +
158 158 UserService userService = UserService.getInstance(getActivity());
159   - userService.setUserInfo(account, data);
  159 + userService.setUserInfo(account,data);
160 160 //userService.isAutoLogin();
161 161 userService.autoLogin(binding.edtLoginNumber.toString(), binding.edtInputPassward.getText().toString(), data);
162 162  
... ...
app/src/main/java/com/cnlive/gundam/user/model/ActiveInfo.java deleted 100644 → 0
1   -package com.cnlive.gundam.user.model;
2   -
3   -
4   -import java.io.Serializable;
5   -
6   -/**
7   - * Created by Lynn on 5/25/2017.
8   - */
9   -
10   -public class ActiveInfo implements Serializable {
11   - private int totalCount;
12   - private int nextCursor;
13   - private int preCursor;
14   - private String activityId;
15   - private String activityName;
16   - private int activityStatus;
17   - private int isHorizontalScreen;
18   - private String channelId;
19   - private String createTime;
20   - private String startTime;
21   - private String endTime;
22   - private String coverImgUrl;
23   - private String activityCategory;
24   - private Object extensions;
25   - private String rates;
26   -
27   - public ActiveInfo() {
28   - }
29   -
30   - public ActiveInfo(int totalCount, int nextCursor, int preCursor, String activityId, String activityName, int activityStatus, int isHorizontalScreen, String channelId, String createTime, String startTime, String endTime, String coverImgUrl, String activityCategory, Object extensions, String rates) {
31   - this.totalCount = totalCount;
32   - this.nextCursor = nextCursor;
33   - this.preCursor = preCursor;
34   - this.activityId = activityId;
35   - this.activityName = activityName;
36   - this.activityStatus = activityStatus;
37   - this.isHorizontalScreen = isHorizontalScreen;
38   - this.channelId = channelId;
39   - this.createTime = createTime;
40   - this.startTime = startTime;
41   - this.endTime = endTime;
42   - this.coverImgUrl = coverImgUrl;
43   - this.activityCategory = activityCategory;
44   - this.extensions = extensions;
45   - this.rates = rates;
46   - }
47   -
48   - public int getTotalCount() {
49   - return totalCount;
50   - }
51   -
52   - public void setTotalCount(int totalCount) {
53   - this.totalCount = totalCount;
54   - }
55   -
56   - public int getNextCursor() {
57   - return nextCursor;
58   - }
59   -
60   - public void setNextCursor(int nextCursor) {
61   - this.nextCursor = nextCursor;
62   - }
63   -
64   - public int getPreCursor() {
65   - return preCursor;
66   - }
67   -
68   - public void setPreCursor(int preCursor) {
69   - this.preCursor = preCursor;
70   - }
71   -
72   - public String getActivityId() {
73   - return activityId;
74   - }
75   -
76   - public void setActivityId(String activityId) {
77   - this.activityId = activityId;
78   - }
79   -
80   - public String getActivityName() {
81   - return activityName;
82   - }
83   -
84   - public void setActivityName(String activityName) {
85   - this.activityName = activityName;
86   - }
87   -
88   - public int getActivityStatus() {
89   - return activityStatus;
90   - }
91   -
92   - public void setActivityStatus(int activityStatus) {
93   - this.activityStatus = activityStatus;
94   - }
95   -
96   - public int getIsHorizontalScreen() {
97   - return isHorizontalScreen;
98   - }
99   -
100   - public void setIsHorizontalScreen(int isHorizontalScreen) {
101   - this.isHorizontalScreen = isHorizontalScreen;
102   - }
103   -
104   - public String getChannelId() {
105   - return channelId;
106   - }
107   -
108   - public void setChannelId(String channelId) {
109   - this.channelId = channelId;
110   - }
111   -
112   - public String getCreateTime() {
113   - return createTime;
114   - }
115   -
116   - public void setCreateTime(String createTime) {
117   - this.createTime = createTime;
118   - }
119   -
120   - public String getStartTime() {
121   - return startTime;
122   - }
123   -
124   - public void setStartTime(String startTime) {
125   - this.startTime = startTime;
126   - }
127   -
128   - public String getEndTime() {
129   - return endTime;
130   - }
131   -
132   - public void setEndTime(String endTime) {
133   - this.endTime = endTime;
134   - }
135   -
136   - public String getCoverImgUrl() {
137   - return coverImgUrl;
138   - }
139   -
140   - public void setCoverImgUrl(String coverImgUrl) {
141   - this.coverImgUrl = coverImgUrl;
142   - }
143   -
144   - public String getActivityCategory() {
145   - return activityCategory;
146   - }
147   -
148   - public void setActivityCategory(String activityCategory) {
149   - this.activityCategory = activityCategory;
150   - }
151   -
152   - public Object getExtensions() {
153   - return extensions;
154   - }
155   -
156   - public void setExtensions(Object extensions) {
157   - this.extensions = extensions;
158   - }
159   -
160   - public String getRates() {
161   - return rates;
162   - }
163   -
164   - public void setRates(String rates) {
165   - this.rates = rates;
166   - }
167   -
168   - @Override
169   - public String toString() {
170   - return "ActiveInfo{" +
171   - "totalCount=" + totalCount +
172   - ", nextCursor=" + nextCursor +
173   - ", preCursor=" + preCursor +
174   - ", activityId='" + activityId + '\'' +
175   - ", activityName='" + activityName + '\'' +
176   - ", activityStatus=" + activityStatus +
177   - ", isHorizontalScreen=" + isHorizontalScreen +
178   - ", channelId='" + channelId + '\'' +
179   - ", createTime='" + createTime + '\'' +
180   - ", startTime='" + startTime + '\'' +
181   - ", endTime='" + endTime + '\'' +
182   - ", coverImgUrl='" + coverImgUrl + '\'' +
183   - ", activityCategory='" + activityCategory + '\'' +
184   - ", extensions='" + extensions + '\'' +
185   - ", rates='" + rates + '\'' +
186   - '}';
187   - }
188   -}
app/src/main/java/com/cnlive/gundam/user/model/ChannelInfoModel.java deleted 100644 → 0
1   -package com.cnlive.gundam.user.model;
2   -
3   -
4   -import com.cnlive.gundam.user.model.base.ErrorMessage;
5   -
6   -import java.io.Serializable;
7   -
8   -/**
9   - * Created by Lynn on 5/26/2017.
10   - */
11   -
12   -public class ChannelInfoModel extends ErrorMessage {
13   - private ChannelInfo data;
14   -
15   - public ChannelInfoModel() {
16   - }
17   -
18   - public ChannelInfoModel(ChannelInfo data) {
19   - this.data = data;
20   - }
21   -
22   - public ChannelInfo getData() {
23   - return data;
24   - }
25   -
26   - public void setData(ChannelInfo data) {
27   - this.data = data;
28   - }
29   -
30   - public class ChannelInfo implements Serializable {
31   - private String coverImgUrl;
32   - private String channelId;
33   - private String channelName;
34   - private int status;
35   -
36   - public ChannelInfo() {
37   - }
38   -
39   - public ChannelInfo(String coverImgUrl, String channelId, String channelName, int status) {
40   - this.coverImgUrl = coverImgUrl;
41   - this.channelId = channelId;
42   - this.channelName = channelName;
43   - this.status = status;
44   - }
45   -
46   - public String getCoverImgUrl() {
47   - return coverImgUrl;
48   - }
49   -
50   - public void setCoverImgUrl(String coverImgUrl) {
51   - this.coverImgUrl = coverImgUrl;
52   - }
53   -
54   - public String getChannelId() {
55   - return channelId;
56   - }
57   -
58   - public void setChannelId(String channelId) {
59   - this.channelId = channelId;
60   - }
61   -
62   - public String getChannelName() {
63   - return channelName;
64   - }
65   -
66   - public void setChannelName(String channelName) {
67   - this.channelName = channelName;
68   - }
69   -
70   - public int getStatus() {
71   - return status;
72   - }
73   -
74   - public void setStatus(int status) {
75   - this.status = status;
76   - }
77   -
78   - @Override
79   - public String toString() {
80   - return "ChannelInfo{" +
81   - "coverImgUrl='" + coverImgUrl + '\'' +
82   - ", channelId='" + channelId + '\'' +
83   - ", channelName='" + channelName + '\'' +
84   - ", status=" + status +
85   - '}';
86   - }
87   - }
88   -
89   - @Override
90   - public String toString() {
91   - return "ChannelInfoModel{" +
92   - "data=" + data +
93   - '}';
94   - }
95   -}
app/src/main/java/com/cnlive/gundam/user/view/CircleImageView.java 0 → 100644
  1 +package com.cnlive.gundam.user.view;
  2 +
  3 +import android.annotation.SuppressLint;
  4 +import android.content.Context;
  5 +import android.content.res.TypedArray;
  6 +import android.graphics.Bitmap;
  7 +import android.graphics.BitmapShader;
  8 +import android.graphics.Canvas;
  9 +import android.graphics.Color;
  10 +import android.graphics.Matrix;
  11 +import android.graphics.Paint;
  12 +import android.graphics.RectF;
  13 +import android.graphics.Shader;
  14 +import android.graphics.drawable.BitmapDrawable;
  15 +import android.graphics.drawable.ColorDrawable;
  16 +import android.graphics.drawable.Drawable;
  17 +import android.util.AttributeSet;
  18 +import android.widget.ImageView;
  19 +
  20 +import com.cnlive.gundam.R;
  21 +
  22 +
  23 +/**
  24 + * @author 陈硕
  25 + * @time 2016/11/7 10:27
  26 + * @desc ${TODD}
  27 + */
  28 +@SuppressLint("AppCompatCustomView")
  29 +public class CircleImageView extends ImageView {
  30 +
  31 +
  32 + private static final ImageView.ScaleType SCALE_TYPE = ImageView.ScaleType.CENTER_CROP;
  33 +
  34 + private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
  35 + private static final int COLORDRAWABLE_DIMENSION = 1;
  36 +
  37 + private static final int DEFAULT_BORDER_WIDTH = 0;
  38 + private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
  39 +
  40 + private final RectF mDrawableRect = new RectF();
  41 + private final RectF mBorderRect = new RectF();
  42 +
  43 + private final Matrix mShaderMatrix = new Matrix();
  44 + private final Paint mBitmapPaint = new Paint();
  45 + private final Paint mBorderPaint = new Paint();
  46 +
  47 + private int mBorderColor = DEFAULT_BORDER_COLOR;
  48 + private int mBorderWidth = DEFAULT_BORDER_WIDTH;
  49 +
  50 + private Bitmap mBitmap;
  51 + private BitmapShader mBitmapShader;
  52 + private int mBitmapWidth;
  53 + private int mBitmapHeight;
  54 +
  55 + private float mDrawableRadius;
  56 + private float mBorderRadius;
  57 +
  58 + private boolean mReady;
  59 + private boolean mSetupPending;
  60 +
  61 + public CircleImageView(Context context) {
  62 + super(context);
  63 + }
  64 +
  65 + public CircleImageView(Context context, AttributeSet attrs) {
  66 + this(context, attrs, 0);
  67 + }
  68 +
  69 + public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
  70 + super(context, attrs, defStyle);
  71 + super.setScaleType(SCALE_TYPE);
  72 +
  73 + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
  74 +
  75 + mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_border_width, DEFAULT_BORDER_WIDTH);
  76 + mBorderColor = a.getColor(R.styleable.CircleImageView_border_color, DEFAULT_BORDER_COLOR);
  77 +
  78 + a.recycle();
  79 +
  80 + mReady = true;
  81 +
  82 + if (mSetupPending) {
  83 + setup();
  84 + mSetupPending = false;
  85 + }
  86 + }
  87 +
  88 + @Override
  89 + public ScaleType getScaleType() {
  90 + return SCALE_TYPE;
  91 + }
  92 +
  93 + @Override
  94 + public void setScaleType(ScaleType scaleType) {
  95 + if (scaleType != SCALE_TYPE) {
  96 + throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
  97 + }
  98 + }
  99 +
  100 + @Override
  101 + protected void onDraw(Canvas canvas) {
  102 + if (getDrawable() == null) {
  103 + return;
  104 + }
  105 +
  106 + canvas.drawCircle(getWidth() / 2, getHeight() / 2, mDrawableRadius, mBitmapPaint);
  107 + canvas.drawCircle(getWidth() / 2, getHeight() / 2, mBorderRadius, mBorderPaint);
  108 + }
  109 +
  110 + @Override
  111 + protected void onSizeChanged(int w, int h, int oldw, int oldh) {
  112 + super.onSizeChanged(w, h, oldw, oldh);
  113 + setup();
  114 + }
  115 +
  116 + public int getBorderColor() {
  117 + return mBorderColor;
  118 + }
  119 +
  120 + public void setBorderColor(int borderColor) {
  121 + if (borderColor == mBorderColor) {
  122 + return;
  123 + }
  124 +
  125 + mBorderColor = borderColor;
  126 + mBorderPaint.setColor(mBorderColor);
  127 + invalidate();
  128 + }
  129 +
  130 + public int getBorderWidth() {
  131 + return mBorderWidth;
  132 + }
  133 +
  134 + public void setBorderWidth(int borderWidth) {
  135 + if (borderWidth == mBorderWidth) {
  136 + return;
  137 + }
  138 +
  139 + mBorderWidth = borderWidth;
  140 + setup();
  141 + }
  142 +
  143 + @Override
  144 + public void setImageBitmap(Bitmap bm) {
  145 + super.setImageBitmap(bm);
  146 + mBitmap = bm;
  147 + setup();
  148 + }
  149 +
  150 + @Override
  151 + public void setImageDrawable(Drawable drawable) {
  152 + super.setImageDrawable(drawable);
  153 + mBitmap = getBitmapFromDrawable(drawable);
  154 + setup();
  155 + }
  156 +
  157 + @Override
  158 + public void setImageResource(int resId) {
  159 + super.setImageResource(resId);
  160 + mBitmap = getBitmapFromDrawable(getDrawable());
  161 + setup();
  162 + }
  163 +
  164 + private Bitmap getBitmapFromDrawable(Drawable drawable) {
  165 + if (drawable == null) {
  166 + return null;
  167 + }
  168 +
  169 + if (drawable instanceof BitmapDrawable) {
  170 + return ((BitmapDrawable) drawable).getBitmap();
  171 + }
  172 +
  173 + try {
  174 + Bitmap bitmap;
  175 +
  176 + if (drawable instanceof ColorDrawable) {
  177 + bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
  178 + } else {
  179 + bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
  180 + }
  181 +
  182 + Canvas canvas = new Canvas(bitmap);
  183 + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
  184 + drawable.draw(canvas);
  185 + return bitmap;
  186 + } catch (OutOfMemoryError e) {
  187 + return null;
  188 + }
  189 + }
  190 +
  191 + private void setup() {
  192 + if (!mReady) {
  193 + mSetupPending = true;
  194 + return;
  195 + }
  196 +
  197 + if (mBitmap == null) {
  198 + return;
  199 + }
  200 +
  201 + mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
  202 +
  203 + mBitmapPaint.setAntiAlias(true);
  204 + mBitmapPaint.setShader(mBitmapShader);
  205 +
  206 + mBorderPaint.setStyle(Paint.Style.STROKE);
  207 + mBorderPaint.setAntiAlias(true);
  208 + mBorderPaint.setColor(mBorderColor);
  209 + mBorderPaint.setStrokeWidth(mBorderWidth);
  210 +
  211 + mBitmapHeight = mBitmap.getHeight();
  212 + mBitmapWidth = mBitmap.getWidth();
  213 +
  214 + mBorderRect.set(0, 0, getWidth(), getHeight());
  215 + mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2, (mBorderRect.width() - mBorderWidth) / 2);
  216 +
  217 + mDrawableRect.set(mBorderWidth, mBorderWidth, mBorderRect.width() - mBorderWidth, mBorderRect.height() - mBorderWidth);
  218 + mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2);
  219 +
  220 + updateShaderMatrix();
  221 + invalidate();
  222 + }
  223 +
  224 + private void updateShaderMatrix() {
  225 + float scale;
  226 + float dx = 0;
  227 + float dy = 0;
  228 +
  229 + mShaderMatrix.set(null);
  230 +
  231 + if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
  232 + scale = mDrawableRect.height() / (float) mBitmapHeight;
  233 + dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  234 + } else {
  235 + scale = mDrawableRect.width() / (float) mBitmapWidth;
  236 + dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  237 + }
  238 +
  239 + mShaderMatrix.setScale(scale, scale);
  240 + mShaderMatrix.postTranslate((int) (dx + 0.5f) + mBorderWidth, (int) (dy + 0.5f) + mBorderWidth);
  241 +
  242 + mBitmapShader.setLocalMatrix(mShaderMatrix);
  243 + }
  244 +
  245 +}
  246 +
  247 +
... ...
app/src/main/res/drawable-hdpi/ic_bubble.png deleted 100644 → 0

4.46 KB

app/src/main/res/drawable-hdpi/ic_bubble_sel.png deleted 100644 → 0

4.12 KB

app/src/main/res/drawable-hdpi/ic_camera.png renamed to app/src/main/res/drawable-hdpi/main_camera.png

1.52 KB

app/src/main/res/drawable-hdpi/ic_camera_sel.png renamed to app/src/main/res/drawable-hdpi/main_camera_sel.png

2.3 KB

app/src/main/res/drawable-hdpi/ic_home.png renamed to app/src/main/res/drawable-hdpi/main_home.png

650 Bytes

app/src/main/res/drawable-hdpi/ic_home_sel.png renamed to app/src/main/res/drawable-hdpi/main_home_sel.png

883 Bytes

app/src/main/res/drawable-hdpi/ic_live_tv.png renamed to app/src/main/res/drawable-hdpi/main_live_tv.png

732 Bytes

app/src/main/res/drawable-hdpi/ic_live_tv_sel.png renamed to app/src/main/res/drawable-hdpi/main_live_tv_sel.png

999 Bytes

app/src/main/res/drawable-hdpi/ic_person.png renamed to app/src/main/res/drawable-hdpi/main_person.png

681 Bytes

app/src/main/res/drawable-hdpi/ic_person_sel.png renamed to app/src/main/res/drawable-hdpi/main_person_sel.png

931 Bytes

app/src/main/res/drawable-hdpi/ic_videocam.png renamed to app/src/main/res/drawable-hdpi/main_videocam.png

518 Bytes

app/src/main/res/drawable-hdpi/ic_videocam_sel.png renamed to app/src/main/res/drawable-hdpi/main_videocam_sel.png

692 Bytes

app/src/main/res/drawable-hdpi/player_back.png 0 → 100644

723 Bytes

app/src/main/res/drawable-hdpi/player_brightness.png 0 → 100644

1.89 KB

app/src/main/res/drawable-hdpi/player_full_screen.png 0 → 100644

849 Bytes

app/src/main/res/drawable-hdpi/player_pause.png 0 → 100644

2.01 KB

app/src/main/res/drawable-hdpi/player_play.png 0 → 100644

1.71 KB

app/src/main/res/drawable-hdpi/player_volume.png 0 → 100644

2.02 KB

app/src/main/res/drawable-hdpi/ic_close.png renamed to app/src/main/res/drawable-hdpi/stream_close.png

4.45 KB

app/src/main/res/drawable-hdpi/ic_close_on.png renamed to app/src/main/res/drawable-hdpi/stream_close_on.png

4.12 KB

app/src/main/res/drawable-hdpi/ic_flash_on.png renamed to app/src/main/res/drawable-hdpi/stream_flash_on.png

4.11 KB

app/src/main/res/drawable-hdpi/ic_flash_on_sel.png renamed to app/src/main/res/drawable-hdpi/stream_flash_on_sel.png

3.91 KB

app/src/main/res/drawable-hdpi/ic_meiyan.png renamed to app/src/main/res/drawable-hdpi/stream_meiyan.png

4.49 KB

app/src/main/res/drawable-hdpi/ic_meiyan_on.png renamed to app/src/main/res/drawable-hdpi/stream_meiyan_on.png

5.06 KB

app/src/main/res/drawable-hdpi/ic_meiyan_on_sel.png renamed to app/src/main/res/drawable-hdpi/stream_meiyan_on_sel.png

4.42 KB

app/src/main/res/drawable-hdpi/ic_meiyan_sel.png renamed to app/src/main/res/drawable-hdpi/stream_meiyan_sel.png

4.09 KB

app/src/main/res/drawable-hdpi/ic_switch_camera.png renamed to app/src/main/res/drawable-hdpi/stream_switch_camera.png

4.15 KB

app/src/main/res/drawable-hdpi/ic_switch_camera_sel.png renamed to app/src/main/res/drawable-hdpi/stream_switch_camera_sel.png

4.05 KB

app/src/main/res/drawable-hdpi/switch_thumb_dan_off.png 0 → 100644

2.83 KB

app/src/main/res/drawable-hdpi/switch_thumb_dan_on.png 0 → 100644

2.5 KB

app/src/main/res/drawable-mdpi/ic_bubble.png deleted 100644 → 0

2.49 KB

app/src/main/res/drawable-mdpi/ic_bubble_sel.png deleted 100644 → 0

2.29 KB

app/src/main/res/drawable-mdpi/ic_camera.png renamed to app/src/main/res/drawable-mdpi/main_camera.png

822 Bytes

app/src/main/res/drawable-mdpi/ic_camera_sel.png renamed to app/src/main/res/drawable-mdpi/main_camera_sel.png

1.18 KB

app/src/main/res/drawable-mdpi/ic_home.png renamed to app/src/main/res/drawable-mdpi/main_home.png

411 Bytes

app/src/main/res/drawable-mdpi/ic_home_sel.png renamed to app/src/main/res/drawable-mdpi/main_home_sel.png

564 Bytes

app/src/main/res/drawable-mdpi/ic_live_tv.png renamed to app/src/main/res/drawable-mdpi/main_live_tv.png

464 Bytes

app/src/main/res/drawable-mdpi/ic_live_tv_sel.png renamed to app/src/main/res/drawable-mdpi/main_live_tv_sel.png

632 Bytes

app/src/main/res/drawable-mdpi/ic_person.png renamed to app/src/main/res/drawable-mdpi/main_person.png

516 Bytes

app/src/main/res/drawable-mdpi/ic_person_sel.png renamed to app/src/main/res/drawable-mdpi/main_person_sel.png

717 Bytes

app/src/main/res/drawable-mdpi/ic_videocam.png renamed to app/src/main/res/drawable-mdpi/main_videocam.png

315 Bytes

app/src/main/res/drawable-mdpi/ic_videocam_sel.png renamed to app/src/main/res/drawable-mdpi/main_videocam_sel.png

425 Bytes

app/src/main/res/drawable-mdpi/player_back.png 0 → 100644

506 Bytes

app/src/main/res/drawable-mdpi/player_brightness.png 0 → 100644

1.3 KB

app/src/main/res/drawable-mdpi/player_full_screen.png 0 → 100644

588 Bytes

app/src/main/res/drawable-mdpi/player_pause.png 0 → 100644

1.16 KB

app/src/main/res/drawable-mdpi/player_play.png 0 → 100644

1.01 KB

app/src/main/res/drawable-mdpi/player_volume.png 0 → 100644

1.09 KB

app/src/main/res/drawable-mdpi/ic_close.png renamed to app/src/main/res/drawable-mdpi/stream_close.png

2.43 KB

app/src/main/res/drawable-mdpi/ic_close_on.png renamed to app/src/main/res/drawable-mdpi/stream_close_on.png

2.25 KB

app/src/main/res/drawable-mdpi/ic_flash_on.png renamed to app/src/main/res/drawable-mdpi/stream_flash_on.png

2.28 KB

app/src/main/res/drawable-mdpi/ic_flash_on_sel.png renamed to app/src/main/res/drawable-mdpi/stream_flash_on_sel.png

2.21 KB

app/src/main/res/drawable-mdpi/ic_meiyan.png renamed to app/src/main/res/drawable-mdpi/stream_meiyan.png

2.45 KB

app/src/main/res/drawable-mdpi/ic_meiyan_on.png renamed to app/src/main/res/drawable-mdpi/stream_meiyan_on.png

2.8 KB

app/src/main/res/drawable-mdpi/ic_meiyan_on_sel.png renamed to app/src/main/res/drawable-mdpi/stream_meiyan_on_sel.png

2.45 KB

app/src/main/res/drawable-mdpi/ic_meiyan_sel.png renamed to app/src/main/res/drawable-mdpi/stream_meiyan_sel.png

2.26 KB

app/src/main/res/drawable-mdpi/ic_switch_camera.png renamed to app/src/main/res/drawable-mdpi/stream_switch_camera.png

2.36 KB

app/src/main/res/drawable-mdpi/ic_switch_camera_sel.png renamed to app/src/main/res/drawable-mdpi/stream_switch_camera_sel.png

2.26 KB

app/src/main/res/drawable-mdpi/switch_thumb_dan_off.png 0 → 100644

1.54 KB

app/src/main/res/drawable-mdpi/switch_thumb_dan_on.png 0 → 100644

1.36 KB

app/src/main/res/drawable-xhdpi/ic_bubble.png deleted 100644 → 0

5.84 KB

app/src/main/res/drawable-xhdpi/ic_bubble_sel.png deleted 100644 → 0

5.52 KB

app/src/main/res/drawable-xhdpi/ic_camera.png renamed to app/src/main/res/drawable-xhdpi/main_camera.png

1.82 KB

app/src/main/res/drawable-xhdpi/ic_camera_sel.png renamed to app/src/main/res/drawable-xhdpi/main_camera_sel.png

2.63 KB

app/src/main/res/drawable-xhdpi/ic_home.png renamed to app/src/main/res/drawable-xhdpi/main_home.png

702 Bytes

app/src/main/res/drawable-xhdpi/ic_home_sel.png renamed to app/src/main/res/drawable-xhdpi/main_home_sel.png

910 Bytes

app/src/main/res/drawable-xhdpi/ic_live_tv.png renamed to app/src/main/res/drawable-xhdpi/main_live_tv.png

874 Bytes

app/src/main/res/drawable-xhdpi/ic_live_tv_sel.png renamed to app/src/main/res/drawable-xhdpi/main_live_tv_sel.png

1.16 KB

app/src/main/res/drawable-xhdpi/ic_person.png renamed to app/src/main/res/drawable-xhdpi/main_person.png

994 Bytes

app/src/main/res/drawable-xhdpi/ic_person_sel.png renamed to app/src/main/res/drawable-xhdpi/main_person_sel.png

1.3 KB

app/src/main/res/drawable-xhdpi/ic_videocam.png renamed to app/src/main/res/drawable-xhdpi/main_videocam.png

561 Bytes

app/src/main/res/drawable-xhdpi/ic_videocam_sel.png renamed to app/src/main/res/drawable-xhdpi/main_videocam_sel.png

729 Bytes

app/src/main/res/drawable-xhdpi/player_back.png 0 → 100644

1.06 KB

app/src/main/res/drawable-xhdpi/player_brightness.png 0 → 100644

2.92 KB

app/src/main/res/drawable-xhdpi/player_full_screen.png 0 → 100644

1.47 KB

app/src/main/res/drawable-xhdpi/player_pause.png 0 → 100644

3.38 KB

app/src/main/res/drawable-xhdpi/player_play.png 0 → 100644

2.83 KB

app/src/main/res/drawable-xhdpi/player_volume.png 0 → 100644

2.58 KB

app/src/main/res/drawable-xhdpi/ic_close.png renamed to app/src/main/res/drawable-xhdpi/stream_close.png

5.83 KB

app/src/main/res/drawable-xhdpi/ic_close_on.png renamed to app/src/main/res/drawable-xhdpi/stream_close_on.png

5.44 KB

app/src/main/res/drawable-xhdpi/ic_flash_on.png renamed to app/src/main/res/drawable-xhdpi/stream_flash_on.png

5.4 KB

app/src/main/res/drawable-xhdpi/ic_flash_on_sel.png renamed to app/src/main/res/drawable-xhdpi/stream_flash_on_sel.png

5.26 KB

app/src/main/res/drawable-xhdpi/ic_meiyan.png renamed to app/src/main/res/drawable-xhdpi/stream_meiyan.png

6.04 KB

app/src/main/res/drawable-xhdpi/ic_meiyan_on.png renamed to app/src/main/res/drawable-xhdpi/stream_meiyan_on.png

6.82 KB

app/src/main/res/drawable-xhdpi/ic_meiyan_on_sel.png renamed to app/src/main/res/drawable-xhdpi/stream_meiyan_on_sel.png

6.03 KB

app/src/main/res/drawable-xhdpi/ic_meiyan_sel.png renamed to app/src/main/res/drawable-xhdpi/stream_meiyan_sel.png

5.55 KB