android 比赛 数字翻页效果,日历翻页效果
篮球比分(Basketball scores)又名篮球即时比分,鸟利用当前发达的网络技术,通过各类渠道为篮球爱好者提供即时比分服务,力求客观、精准,以前首先于网络技术的限制,会出现延迟10s左右,优秀的篮球即时比分服务可以控制在1s左右,大大的提高了用户体验度。请下载代码资源包 ,免费的。
·
篮球比分(Basketball scores)又名篮球即时比分,鸟利用当前发达的网络技术,通过各类渠道为篮球爱好者提供即时比分服务,力求客观、精准,以前首先于网络技术的限制,会出现延迟10s左右,优秀的篮球即时比分服务可以控制在1s左右,大大的提高了用户体验度。
device-2023-05-09-152553
package com.sbas.tiyuzhan;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.LocaleList;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sbas.tiyuzhan.R;
import java.util.Locale;
public class MainActivity extends Activity {
public static String deviceCode ="123456";
SharedPreferences sharedPreferences = null;
public static final String shareFileName = "sbas_huaqianji";
int jinqiu_count = 0;
String jinqiu_count_s="0";
IntentFilter intentFilter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
intentFilter = new IntentFilter("com.sbas.android.xlchannel");
intentFilter.addAction("com.sbas.android.xlchannel");
intentFilter.addAction("com.sbas.android.xlchannel2");
setContentView(R.layout.activity_main);
FlipLayout flipclockview1 = findViewById(R.id.flipclockview1);
FlipLayout flipclockview2 = findViewById(R.id.flipclockview2);
FlipLayout flipclockview3 = findViewById(R.id.flipclockview3);
FlipLayout flipclockview4 = findViewById(R.id.flipclockview4);
FlipLayout flipclockview5 = findViewById(R.id.flipclockview5);
jinqiu_count_s=""+jinqiu_count;
int bu_0 = 5-jinqiu_count_s.length();
for(int i=0;i<bu_0;i++){
jinqiu_count_s = "0"+jinqiu_count_s;
}
//设置可见控件 初始值。
flipclockview1.mVisibleTextView.setText("0");
flipclockview2.mVisibleTextView.setText("0");
flipclockview3.mVisibleTextView.setText("0");
flipclockview4.mVisibleTextView.setText("0");
flipclockview5.mVisibleTextView.setText("0");
TextView leiji_textview = findViewById(R.id.leiji_textview);
leiji_textview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
jinqiu_count ++;
Log.i("tag",jinqiu_count+"------jinqiu_count-----");
jinqiu_count_s=""+jinqiu_count;
int bu_0 = 5-jinqiu_count_s.length();
//数字前面不够5位补0、
for(int i=0;i<bu_0;i++){
jinqiu_count_s = "0"+jinqiu_count_s;
}
//截取每一位 给不可见 控件。翻页的时候 显示不可见控件。
flipclockview1.smoothFlip(Integer.parseInt(jinqiu_count_s.substring(0,1)), false);
flipclockview2.smoothFlip(Integer.parseInt(jinqiu_count_s.substring(1,2)), false);
flipclockview3.smoothFlip(Integer.parseInt(jinqiu_count_s.substring(2,3)), false);
flipclockview4.smoothFlip(Integer.parseInt(jinqiu_count_s.substring(3,4)), false);
flipclockview5.smoothFlip(Integer.parseInt(jinqiu_count_s.substring(4,5)), false);
}
});
// registerReceiver(mBroadcastReceiver, intentFilter);
// MyMqtt_And485Service.startService(this);
}
/**
* 此方法先于 onCreate()方法执行
* @param newBase
*/
@Override
protected void attachBaseContext(Context newBase) {
sharedPreferences = newBase.getSharedPreferences(shareFileName, Context.MODE_PRIVATE);
//获取我们存储的语言环境 比如 "en","zh",等等
String language = sharedPreferences.getString("LANGUAGE", Locale.SIMPLIFIED_CHINESE.toString());
//attach 对应语言环境下的context
super.attachBaseContext(attachBaseContext(newBase, language));
}
public static Context attachBaseContext(Context context, String language) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return updateResources(context, language);
} else {
return context;
}
}
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) //onReceive函数不能做耗时的事情,参考值:10s以内
{
if (intent.getAction().equals("com.sbas.android.xlchannel")) {
byte[] data = intent.getByteArrayExtra("data");
if (data[6] == 0x05 && data[7] == 0x1F) {
fa_qiu_ok();
}
//篮球进球
if (data[6] == 0x05 && data[7] == 0x1B) {
jin_qiu_ok();
}
} else if (intent.getAction().equals("com.sbas.android.xlchannel2")) {
byte[] data = intent.getByteArrayExtra("data");
if (data[6] == 0x05 && data[7] == 0x1F) {
fa_qiu_ok();
}
//篮球进球
if (data[6] == 0x05 && data[7] == 0x1B) {
jin_qiu_ok();
}
}
}
};
private void jin_qiu_ok() {
}
private void fa_qiu_ok() {
}
/**
* 如果是7.0以下,我们需要调用changeAppLanguage方法,
* 如果是7.0及以上系统,直接把我们想要切换的语言类型保存在SharedPreferences中,然后重新启动MainActivity即可
* @param language
*/
private void changeLanguage(String language) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
changeAppLanguage(getApplicationContext(), language);
}
sharedPreferences.edit().putString("LANGUAGE", language).commit();
finish();
Intent intent = new Intent(this, MainActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
/**
* @param context
* @param newLanguage 想要切换的语言类型 比如 "en" ,"zh"
*/
@SuppressWarnings("deprecation")
public static void changeAppLanguage(Context context, String newLanguage) {
if (TextUtils.isEmpty(newLanguage)) {
return;
}
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
//获取想要切换的语言类型
Locale locale = getLocaleByLanguage(newLanguage);
configuration.setLocale(locale);
// updateConfiguration
DisplayMetrics dm = resources.getDisplayMetrics();
resources.updateConfiguration(configuration, dm);
}
@TargetApi(Build.VERSION_CODES.N)
private static Context updateResources(Context context, String language) {
Resources resources = context.getResources();
Locale locale = getLocaleByLanguage(language);
Configuration configuration = resources.getConfiguration();
configuration.setLocale(locale);
configuration.setLocales(new LocaleList(locale));
return context.createConfigurationContext(configuration);
}
public static Locale getLocaleByLanguage(String language) {
Locale locale = Locale.SIMPLIFIED_CHINESE;
if (language.equals(Locale.SIMPLIFIED_CHINESE.toString())) {
locale = Locale.SIMPLIFIED_CHINESE;
} else if (language.equals( Locale.ENGLISH.toString())) {
locale = Locale.ENGLISH;
}
return locale;
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mBroadcastReceiver);
}
}
请下载代码资源包 ,免费的。免积分。
https://download.csdn.net/download/sun6223508/87767150
请下载代码资源包 ,免费的。免积分。
//----------API-------------
/**
* 带动画翻动
* 需要翻动几次
*
* @param value 需要翻动的次数
* @param isMinus 方向标识 true: 往上翻 - , false: 往下翻 +
*/
public void smoothFlip(int value, boolean isMinus) {
// Log.e(TAG,"翻动的次数: " + value);
//数字没变化,不执行动效。
if(value == Integer.parseInt(mVisibleTextView.getText().toString())){
return;
}
flipTimes = value;
this.isUp = isMinus;
initTextView(value);
isFlipping = true;
//500毫秒 执行完毕。
mScroller.startScroll(0, 0, 0, layoutHeight, 500);
timesCount = 1;
postInvalidate();
}
更多推荐
已为社区贡献18条内容
所有评论(0)