GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 测试数据 · tmexcept/AndroidCustomView@7bc468f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .idea
    • compiler.xml
    • gradle.xml
    • misc.xml
    • modules.xml
  • app/src/main
    • java/com/allen/androidcustomview
      • activity
        • TranslateRotateCanvasActivity.java
      • utils
        • ScreenTools.java
      • widget
        • UserStarChangeView.java
    • res
      • layout
        • activity_tranlate_rotate.xml
      • mipmap-xxhdpi
        • user_level_3_1.png
        • user_level_4_1.png
        • user_level_5_1.png
        • user_level_fail.png
        • user_level_start.png
        • user_level_start_.png
        • user_level_win.png
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.idea/compiler.xml‎

Copy file name to clipboardExpand all lines: .idea/compiler.xml
+1-17Lines changed: 1 addition & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎.idea/gradle.xml‎

Copy file name to clipboardExpand all lines: .idea/gradle.xml
+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎.idea/misc.xml‎

Copy file name to clipboardExpand all lines: .idea/misc.xml
+9-3Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎.idea/modules.xml‎

Copy file name to clipboardExpand all lines: .idea/modules.xml
+2-4Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎app/src/main/java/com/allen/androidcustomview/activity/TranslateRotateCanvasActivity.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/activity/TranslateRotateCanvasActivity.java
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,41 @@
33
import android.os.Bundle;
44
import android.support.annotation.Nullable;
55
import android.support.v7.app.AppCompatActivity;
6+
import android.view.View;
67

78
import com.allen.androidcustomview.R;
9+
import com.allen.androidcustomview.widget.UserStarChangeView;
810

911
public class TranslateRotateCanvasActivity extends AppCompatActivity {
1012

13+
UserStarChangeView userStarChangeView;
1114
@Override
1215
protected void onCreate(@Nullable Bundle savedInstanceState) {
1316
super.onCreate(savedInstanceState);
1417
setContentView(R.layout.activity_tranlate_rotate);
18+
19+
userStarChangeView = findViewById(R.id.userStarChangeView);
20+
}
21+
22+
23+
int leveStar = 0;
24+
public void StarUp(View view) {
25+
leveStar += 1;
26+
userStarChangeView.showUserLevelImg(5, 1, leveStar, UserStarChangeView.LEVEL_STAR_ADD);
27+
}
28+
public void starDown(View view) {
29+
if(leveStar == 0){
30+
leveStar = 5;
31+
}
32+
leveStar -= 1;
33+
userStarChangeView.showUserLevelImg(5, 1, leveStar, UserStarChangeView.LEVEL_STAR_REDUCE);
34+
}
35+
36+
public void levelUp(View view) {
37+
userStarChangeView.showUserLevelImg(5, 1, leveStar, UserStarChangeView.LEVEL_ADD);
38+
}
39+
40+
public void levelDown(View view) {
41+
userStarChangeView.showUserLevelImg(5, 1, leveStar, UserStarChangeView.LEVEL_REDUCE);
1542
}
1643
}
Collapse file

‎app/src/main/java/com/allen/androidcustomview/utils/ScreenTools.java‎

Copy file name to clipboard
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
package com.allen.androidcustomview.utils;
3+
4+
import android.app.Activity;
5+
import android.content.Context;
6+
import android.content.res.Resources;
7+
import android.graphics.Point;
8+
import android.graphics.Rect;
9+
import android.graphics.drawable.Drawable;
10+
import android.os.Build;
11+
import android.support.v7.widget.StaggeredGridLayoutManager;
12+
import android.util.DisplayMetrics;
13+
import android.view.Display;
14+
import android.view.ViewGroup;
15+
import android.view.WindowManager;
16+
import android.widget.TextView;
17+
18+
public class ScreenTools {
19+
20+
public static int dip2px(int f) {
21+
final float scale = Resources.getSystem().getDisplayMetrics().density;
22+
return (int) (f * scale + 0.5f);
23+
}
24+
public static int dip2px(float f) {
25+
final float scale = Resources.getSystem().getDisplayMetrics().density;
26+
return (int) (f * scale + 0.5f);
27+
}
28+
29+
private static int getScreenHeight(Context context) {
30+
return context.getResources().getDisplayMetrics().heightPixels;
31+
}
32+
public static int getScreenWidth(Context context) {
33+
return context.getResources().getDisplayMetrics().widthPixels;
34+
}
35+
/**
36+
* 获取屏幕区域
37+
*/
38+
private static Rect getScreenRect() {
39+
DisplayMetrics displayMetric = Resources.getSystem().getDisplayMetrics();
40+
return new Rect(0, 0, displayMetric.widthPixels, displayMetric.heightPixels);
41+
}
42+
43+
/**
44+
* 获取屏幕宽度
45+
*
46+
*/
47+
public static int getScreenWidth() {
48+
return getScreenRect().width();
49+
}
50+
51+
public static Point getScreenSize(Context context) {
52+
WindowManager wm = (WindowManager) context
53+
.getSystemService(Context.WINDOW_SERVICE);
54+
return new Point(wm.getDefaultDisplay().getWidth(), wm.getDefaultDisplay().getHeight());
55+
}
56+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.