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();
|
}
|
|
}
|