admin
2022-05-07 4c7cde7ae5ed57335405459e47de4bbd2726c4ba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.yeshi.makemoney.video.app.utils.videos;
 
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
 
import com.demo.lib.common.util.common.DimenUtils;
import com.yeshi.makemoney.video.R;
 
public class VideoGoldCornUtil {
 
 
    /**
     * 增加视频播放圈数
     *
     * @param context
     * @param circle
     */
    public static void addVideoPlayCircle(Context context, int circle) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        int old = sharedPreferences.getInt("circle", 0);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt("circle", old + circle);
        editor.commit();
    }
 
    /**
     * 获取视频播放圈数
     *
     * @param context
     * @return
     */
    public static int getVideoPlayCircle(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        return sharedPreferences.getInt("circle", 0);
    }
 
 
    /**
     * 清除视频播放圈数
     *
     * @param context
     */
    public static void clearVideoPlayCircle(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.remove("circle");
        editor.commit();
    }
 
    public static void setVideoPlayCircle(int circle, Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt("circle", circle);
        editor.commit();
    }
 
    /**
     * 获取单价
     *
     * @param context
     * @return
     */
    public static Integer getPrice(Context context) {
 
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        //获取1分钟的钱
        int price = sharedPreferences.getInt("price", 1);
        //计算1圈的钱
        return (int) (price * DrawVideoGoldCornManager.CIRCLE_TIME / 1000 / (60.0f));
    }
 
    /**
     * 设置单价
     *
     * @param context
     * @param goldCorn
     */
    public static void setPrice(Context context, int goldCorn) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt("price", goldCorn);
        editor.commit();
    }
 
 
    /**
     * 入账提醒
     *
     * @param goldCorn
     */
    public static void showInComeToast(int goldCorn, Context context) {
        Toast result = new Toast(context);
        TextView v = new TextView(context);
        v.setTextColor(Color.parseColor("#F5EBA4"));
        v.setBackgroundResource(R.drawable.shape_goldcorn_toast_bg);
        v.setText(goldCorn + "金币已入账");
        int px = DimenUtils.dipToPixels(1, context);
        result.setView(v);
        result.setDuration(Toast.LENGTH_SHORT);
        result.setGravity(Gravity.BOTTOM, 0, px * 200);
        result.show();
    }
 
 
    /**
     * 是否加倍提醒
     *
     * @param context
     * @return
     */
    public static boolean isDoubleNotify(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        return sharedPreferences.getBoolean("double_notify", false);
    }
 
    public static void setDoubleNotify(boolean notify, Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putBoolean("double_notify", notify);
        editor.commit();
    }
 
}