Commit f79818f5d2c3d41ce29763d9b02fbe4b6f7bff62
合并
Showing
140 changed files
with
5496 additions
and
14 deletions
.idea/inspectionProfiles/Project_Default.xml
0 → 100644
| 1 | +<component name="InspectionProjectProfileManager"> | ||
| 2 | + <profile version="1.0"> | ||
| 3 | + <option name="myName" value="Project Default" /> | ||
| 4 | + <inspection_tool class="AndroidLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" /> | ||
| 5 | + <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> | ||
| 6 | + <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> | ||
| 7 | + <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> | ||
| 8 | + </inspection_tool> | ||
| 9 | + </profile> | ||
| 10 | +</component> | ||
| 0 | \ No newline at end of file | 11 | \ No newline at end of file |
.idea/inspectionProfiles/profiles_settings.xml
0 → 100644
| 1 | +<component name="InspectionProjectProfileManager"> | ||
| 2 | + <settings> | ||
| 3 | + <option name="PROJECT_PROFILE" value="Project Default" /> | ||
| 4 | + <option name="USE_PROJECT_PROFILE" value="true" /> | ||
| 5 | + <version value="1.0" /> | ||
| 6 | + </settings> | ||
| 7 | +</component> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/build.gradle
| @@ -23,10 +23,9 @@ android { | @@ -23,10 +23,9 @@ android { | ||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | dependencies { | 25 | dependencies { |
| 26 | - compile fileTree(dir: 'libs', include: ['*.jar']) | 26 | + compile fileTree(include: ['*.jar'], dir: 'libs') |
| 27 | compile 'com.android.support:appcompat-v7:26.+' | 27 | compile 'com.android.support:appcompat-v7:26.+' |
| 28 | compile 'com.android.support:recyclerview-v7:26.+' | 28 | compile 'com.android.support:recyclerview-v7:26.+' |
| 29 | - | ||
| 30 | compile 'com.google.code.gson:gson:2.7' | 29 | compile 'com.google.code.gson:gson:2.7' |
| 31 | compile 'com.android.support.constraint:constraint-layout:1.0.2' | 30 | compile 'com.android.support.constraint:constraint-layout:1.0.2' |
| 32 | compile 'com.github.bumptech.glide:glide:3.7.0' | 31 | compile 'com.github.bumptech.glide:glide:3.7.0' |
app/libs/libcnliveuser.jar
0 → 100644
No preview for this file type
app/src/main/AndroidManifest.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 3 | package="com.cnlive.gundam"> | 4 | package="com.cnlive.gundam"> |
| 4 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 5 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
| 5 | <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> | 6 | <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> |
| @@ -25,6 +26,11 @@ | @@ -25,6 +26,11 @@ | ||
| 25 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 26 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 26 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | 27 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
| 27 | 28 | ||
| 29 | + <!-- account start --> | ||
| 30 | + <uses-permission | ||
| 31 | + android:name="android.permission.ACCOUNT_MANAGER" | ||
| 32 | + tools:ignore="ProtectedPermissions" /> | ||
| 33 | + | ||
| 28 | <application | 34 | <application |
| 29 | android:name=".main.application.CNLiveApplication" | 35 | android:name=".main.application.CNLiveApplication" |
| 30 | android:allowBackup="true" | 36 | android:allowBackup="true" |
| @@ -47,6 +53,7 @@ | @@ -47,6 +53,7 @@ | ||
| 47 | android:launchMode="singleTop" | 53 | android:launchMode="singleTop" |
| 48 | android:screenOrientation="portrait" | 54 | android:screenOrientation="portrait" |
| 49 | android:windowSoftInputMode="adjustResize" /> | 55 | android:windowSoftInputMode="adjustResize" /> |
| 56 | + <activity android:name=".user.activity.LoginActivity"/> | ||
| 50 | 57 | ||
| 51 | <receiver | 58 | <receiver |
| 52 | android:name=".video.utils.NetworkChangeReceive"> | 59 | android:name=".video.utils.NetworkChangeReceive"> |
app/src/main/java/com/cnlive/gundam/main/application/CNLiveApplication.java
| @@ -13,6 +13,6 @@ public class CNLiveApplication extends Application { | @@ -13,6 +13,6 @@ public class CNLiveApplication extends Application { | ||
| 13 | @Override | 13 | @Override |
| 14 | public void onCreate() { | 14 | public void onCreate() { |
| 15 | super.onCreate(); | 15 | super.onCreate(); |
| 16 | - Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9", true); | 16 | + Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9",true); |
| 17 | } | 17 | } |
| 18 | } | 18 | } |
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
| 1 | package com.cnlive.gundam.main.ui.activity; | 1 | package com.cnlive.gundam.main.ui.activity; |
| 2 | 2 | ||
| 3 | -import android.content.Intent; | ||
| 4 | import android.databinding.DataBindingUtil; | 3 | import android.databinding.DataBindingUtil; |
| 5 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 6 | import android.support.v7.app.AppCompatActivity; | 5 | import android.support.v7.app.AppCompatActivity; |
| @@ -12,7 +11,6 @@ import com.cnlive.gundam.main.ui.fragment.HomeFragment; | @@ -12,7 +11,6 @@ import com.cnlive.gundam.main.ui.fragment.HomeFragment; | ||
| 12 | import com.cnlive.gundam.main.ui.fragment.LiveFragment; | 11 | import com.cnlive.gundam.main.ui.fragment.LiveFragment; |
| 13 | import com.cnlive.gundam.main.ui.fragment.UGCListFragment; | 12 | import com.cnlive.gundam.main.ui.fragment.UGCListFragment; |
| 14 | import com.cnlive.gundam.main.ui.widget.FragmentTabHost; | 13 | import com.cnlive.gundam.main.ui.widget.FragmentTabHost; |
| 15 | -import com.cnlive.gundam.stream.ui.activity.StreamActivity; | ||
| 16 | 14 | ||
| 17 | import java.util.Arrays; | 15 | import java.util.Arrays; |
| 18 | 16 | ||
| @@ -41,16 +39,14 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | @@ -41,16 +39,14 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | ||
| 41 | public boolean onSetCurrentTab(String tag) { | 39 | public boolean onSetCurrentTab(String tag) { |
| 42 | switch (tag) { | 40 | switch (tag) { |
| 43 | case "stream": | 41 | case "stream": |
| 44 | - Intent intent = new Intent(this, StreamActivity.class); | ||
| 45 | - intent.putExtra("activityId", ""+System.currentTimeMillis()); | ||
| 46 | - intent.putExtra("channelId", "androidtest"); | ||
| 47 | - intent.putExtra("channelName", "androidTest"); | ||
| 48 | - intent.putExtra("coverImgUrl", ""); | ||
| 49 | - intent.putExtra("landscape", false); | ||
| 50 | - startActivity(intent); | 42 | + onSetStreamTab(); |
| 51 | return true; | 43 | return true; |
| 52 | } | 44 | } |
| 53 | return false; | 45 | return false; |
| 54 | } | 46 | } |
| 55 | 47 | ||
| 48 | + private void onSetStreamTab(){ | ||
| 49 | + | ||
| 50 | + } | ||
| 51 | + | ||
| 56 | } | 52 | } |
| 57 | \ No newline at end of file | 53 | \ No newline at end of file |
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
| 1 | package com.cnlive.gundam.main.ui.fragment; | 1 | package com.cnlive.gundam.main.ui.fragment; |
| 2 | 2 | ||
| 3 | +import android.content.Intent; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.support.annotation.Nullable; | ||
| 3 | import android.support.v4.app.Fragment; | 7 | import android.support.v4.app.Fragment; |
| 8 | +import android.util.Log; | ||
| 9 | +import android.view.LayoutInflater; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.ViewGroup; | ||
| 12 | + | ||
| 13 | +import com.cnlive.gundam.R; | ||
| 14 | +import com.cnlive.gundam.databinding.UserFragmentBinding; | ||
| 15 | +import com.cnlive.gundam.user.activity.LoginActivity; | ||
| 16 | +import com.cnlive.gundam.user.auth.UserService; | ||
| 4 | 17 | ||
| 5 | /** | 18 | /** |
| 6 | * Created by xiansong on 2017/6/27. | 19 | * Created by xiansong on 2017/6/27. |
| 7 | */ | 20 | */ |
| 8 | 21 | ||
| 9 | -public class ConfigFragment extends Fragment { | 22 | +public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 23 | + private UserFragmentBinding binding; | ||
| 24 | + | ||
| 25 | + @Nullable | ||
| 26 | + @Override | ||
| 27 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
| 28 | + binding = DataBindingUtil.inflate(inflater, R.layout.user_fragment, container, false); | ||
| 29 | + | ||
| 30 | + return binding.getRoot(); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 35 | + super.onViewCreated(view, savedInstanceState); | ||
| 36 | + initUI(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + /* public static Fragment newInstance() { | ||
| 41 | + UserFragment fragment = new UserFragment(); | ||
| 42 | + return fragment; | ||
| 43 | + }*/ | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void onActivityCreated(Bundle savedInstanceState) { | ||
| 47 | + super.onActivityCreated(savedInstanceState); | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + /*initToolBar(); | ||
| 51 | + init(); | ||
| 52 | + MyHeadItem.getContent(getActivity());*/ | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + private void initUI() { | ||
| 56 | + binding.configHeader.setOnClickListener(this); | ||
| 57 | + binding.live.setOnClickListener(this); | ||
| 58 | + binding.message.setOnClickListener(this); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void onClick(View view) { | ||
| 64 | + switch (view.getId()) { | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + case R.id.config_header: | ||
| 68 | + int uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid(); | ||
| 69 | + if (uid != 0) { | ||
| 70 | + //进入个人中心页面 | ||
| 71 | + //startActivity(new Intent(getActivity(), UserPersonalActivity.class)); | ||
| 72 | + } else { | ||
| 73 | + //进入登录页面 | ||
| 74 | + startActivity(new Intent(getActivity(), LoginActivity.class)); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + break; | ||
| 78 | + case R.id.live: | ||
| 79 | + | ||
| 80 | + break; | ||
| 81 | + case R.id.message: | ||
| 82 | + | ||
| 83 | + break; | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + } | ||
| 10 | } | 88 | } |
app/src/main/java/com/cnlive/gundam/stream/ui/activity/StreamActivity.java
| @@ -2,7 +2,9 @@ package com.cnlive.gundam.stream.ui.activity; | @@ -2,7 +2,9 @@ package com.cnlive.gundam.stream.ui.activity; | ||
| 2 | 2 | ||
| 3 | import android.app.AlertDialog; | 3 | import android.app.AlertDialog; |
| 4 | import android.app.Dialog; | 4 | import android.app.Dialog; |
| 5 | +import android.content.Context; | ||
| 5 | import android.content.DialogInterface; | 6 | import android.content.DialogInterface; |
| 7 | +import android.content.Intent; | ||
| 6 | import android.databinding.DataBindingUtil; | 8 | import android.databinding.DataBindingUtil; |
| 7 | import android.os.Bundle; | 9 | import android.os.Bundle; |
| 8 | import android.os.Handler; | 10 | import android.os.Handler; |
| @@ -70,6 +72,16 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch | @@ -70,6 +72,16 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch | ||
| 70 | private TimerUtil timerUtil; | 72 | private TimerUtil timerUtil; |
| 71 | private String extensions; | 73 | private String extensions; |
| 72 | 74 | ||
| 75 | + public static void start(Context context, String activityId, String channelId, String channelName, String coverImgUrl, boolean landscage) { | ||
| 76 | + Intent intent = new Intent(context, StreamActivity.class); | ||
| 77 | + intent.putExtra("activityId", activityId); | ||
| 78 | + intent.putExtra("channelId", channelId); | ||
| 79 | + intent.putExtra("channelName", channelName); | ||
| 80 | + intent.putExtra("coverImgUrl", coverImgUrl); | ||
| 81 | + intent.putExtra("landscape", landscage); | ||
| 82 | + context.startActivity(intent); | ||
| 83 | + } | ||
| 84 | + | ||
| 73 | @Override | 85 | @Override |
| 74 | protected void onCreate(Bundle savedInstanceState) { | 86 | protected void onCreate(Bundle savedInstanceState) { |
| 75 | super.onCreate(savedInstanceState); | 87 | super.onCreate(savedInstanceState); |
app/src/main/java/com/cnlive/gundam/user/activity/LoginActivity.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.activity; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.support.v7.app.AppCompatActivity; | ||
| 7 | +import android.view.MotionEvent; | ||
| 8 | +import android.view.View; | ||
| 9 | +import android.view.inputmethod.InputMethodManager; | ||
| 10 | + | ||
| 11 | +import com.cnlive.gundam.R; | ||
| 12 | +import com.cnlive.gundam.user.fragment.LoginFragment; | ||
| 13 | +import com.cnlive.gundam.user.util.DevilUtil; | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * Created by luxiaoman on 2017/6/2. | ||
| 18 | + */ | ||
| 19 | + | ||
| 20 | +public class LoginActivity extends AppCompatActivity { | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + protected void onCreate(Bundle savedInstanceState) { | ||
| 24 | + super.onCreate(savedInstanceState); | ||
| 25 | + DataBindingUtil.setContentView(this, R.layout.activity_login); | ||
| 26 | + getSupportFragmentManager().beginTransaction().replace(R.id.login_fragment, LoginFragment.newInstance()).commit(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 隐藏软键盘 | ||
| 31 | + */ | ||
| 32 | + @Override | ||
| 33 | + public boolean dispatchTouchEvent(MotionEvent ev){ | ||
| 34 | + // TODO Auto-generated method stub | ||
| 35 | + if(ev.getAction()== MotionEvent.ACTION_DOWN){ | ||
| 36 | + | ||
| 37 | + // 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点) | ||
| 38 | + View v=getCurrentFocus(); | ||
| 39 | + | ||
| 40 | + if(DevilUtil.isShouldHideInput(v,ev)){ | ||
| 41 | + InputMethodManager im=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); | ||
| 42 | + DevilUtil.hideSoftInput(v.getWindowToken(),im); | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + return super.dispatchTouchEvent(ev); | ||
| 46 | + } | ||
| 47 | +} |
app/src/main/java/com/cnlive/gundam/user/auth/UserService.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.auth; | ||
| 2 | + | ||
| 3 | +import android.accounts.Account; | ||
| 4 | +import android.accounts.AccountManager; | ||
| 5 | +import android.content.Context; | ||
| 6 | + | ||
| 7 | +import com.cnlive.gundam.R; | ||
| 8 | +import com.cnlive.gundam.user.model.User; | ||
| 9 | +import com.cnlive.libs.user.model.DataEntity; | ||
| 10 | +import com.cnlive.libs.util.SharedPreferencesHelper; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 用户管理类 | ||
| 16 | + */ | ||
| 17 | +public class UserService { | ||
| 18 | + private final String KEY_DEFAULT_ACCOUNT = "defaultaccount";//用户默认账户 | ||
| 19 | + private final String KEY_USER_DATA_USER_ID = "uid"; //用户uid | ||
| 20 | + private final String KEY_USER_DATA_NICKNAME = "nickname"; //用户昵称 | ||
| 21 | + private final String KEY_USER_DATA_FACEURL = "faceurl"; //用户头像 | ||
| 22 | + private final String KEY_USER_DATA_GENDER = "gender"; //用户性别 | ||
| 23 | + private final String KEY_USER_DATA_MOBILE = "mobile"; //用户手机号 | ||
| 24 | + private final String KEY_USER_DATA_EMAIL = "email"; //用户邮箱 | ||
| 25 | + private final String KEY_USER_DATA_LOCATION = "location"; //用户地址 | ||
| 26 | + private final String KEY_USER_TOKEN = "token"; //用户token | ||
| 27 | + private Context mContext; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + private SharedPreferencesHelper sharedPrefs; | ||
| 31 | + | ||
| 32 | + public static UserService mInstance; | ||
| 33 | + private AccountManager mAccountManager; | ||
| 34 | + private Account activeAccount; | ||
| 35 | + | ||
| 36 | + private UserService(Context context) { | ||
| 37 | + mContext = context; | ||
| 38 | + sharedPrefs = SharedPreferencesHelper.getInstance(context); | ||
| 39 | + mAccountManager = AccountManager.get(context); | ||
| 40 | + getDefaultAccount(); | ||
| 41 | + //AppApplication.userID=getActiveAccountInfo().getUid(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public static synchronized UserService getInstance(Context context) { | ||
| 45 | + if (mInstance == null) | ||
| 46 | + mInstance = new UserService(context.getApplicationContext()); | ||
| 47 | + return mInstance; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + private boolean hasDefaultAccount() { | ||
| 51 | + return getDefaultAccount() != null; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + private Account getDefaultAccount() { | ||
| 55 | + String accountName = sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT); | ||
| 56 | + | ||
| 57 | + return activeAccount = findAccountByUsername(accountName); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + private void setDefaultAccount(Account defaultAccount) { | ||
| 61 | + sharedPrefs.setValue(KEY_DEFAULT_ACCOUNT, defaultAccount.name); | ||
| 62 | + | ||
| 63 | + boolean foundAccount = false; | ||
| 64 | + Account[] accounts = mAccountManager.getAccounts(); | ||
| 65 | + for (int i = 0; i < accounts.length && !foundAccount; i++) { | ||
| 66 | + if (accounts[i].name.equals(defaultAccount.name)) { | ||
| 67 | + foundAccount = true; | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + if (!foundAccount) { | ||
| 72 | + // 默认账户被注销了? | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public User getActiveAccountInfo() { | ||
| 77 | + if (hasDefaultAccount()) | ||
| 78 | + return getUserInfo(activeAccount); | ||
| 79 | + else | ||
| 80 | + return new User(); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + private Account setActiveAccount(String username, String password) { | ||
| 84 | + Account account = findAccountByUsername(username); | ||
| 85 | + if (account == null) { | ||
| 86 | + account = new Account(username, mContext.getString(R.string.ACCOUNT_TYPE)); | ||
| 87 | + mAccountManager.addAccountExplicitly(account, password, null); | ||
| 88 | + } | ||
| 89 | + this.activeAccount = account; | ||
| 90 | + | ||
| 91 | + return account; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public boolean autoLogin(String username, String password, DataEntity user) { | ||
| 95 | + | ||
| 96 | + if (user == null) { | ||
| 97 | + return false; | ||
| 98 | + } | ||
| 99 | + Account account = setActiveAccount(username, password); | ||
| 100 | + setDefaultAccount(account); | ||
| 101 | + | ||
| 102 | + setUserInfo(account, user); | ||
| 103 | + | ||
| 104 | + return true; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + public void updateNickName(String nickname){ //修改昵称 | ||
| 108 | + mAccountManager.setUserData(activeAccount,KEY_USER_DATA_NICKNAME, nickname); | ||
| 109 | + } | ||
| 110 | + public void updateFaceUrl(String faceurl){ //修改头像 | ||
| 111 | + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_FACEURL, faceurl); | ||
| 112 | + } | ||
| 113 | + public void updateGender(String gender){ //修改性别 | ||
| 114 | + mAccountManager.setUserData(activeAccount,KEY_USER_DATA_GENDER, gender); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public void updateEmail(String email){ //修改邮箱 | ||
| 118 | + mAccountManager.setUserData(activeAccount,KEY_USER_DATA_EMAIL, email); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setActiveAccountInfo( DataEntity user) {//更新 保存用户信息 | ||
| 122 | + setUserInfo(activeAccount, user); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public void setUserInfo(Account account, DataEntity user){//更新 保存用户信息 | ||
| 126 | + mAccountManager.setUserData(account,KEY_USER_DATA_USER_ID, String.valueOf(user.getUid())); | ||
| 127 | + mAccountManager.setUserData(account,KEY_USER_DATA_NICKNAME, user.getNickName()); | ||
| 128 | + mAccountManager.setUserData(account,KEY_USER_DATA_FACEURL, user.getFaceUrl()); | ||
| 129 | + mAccountManager.setUserData(account,KEY_USER_DATA_GENDER, user.getGender()); | ||
| 130 | + mAccountManager.setUserData(account,KEY_USER_DATA_MOBILE, user.getMobile()); | ||
| 131 | + mAccountManager.setUserData(account,KEY_USER_DATA_EMAIL, user.getEmail()); | ||
| 132 | + mAccountManager.setUserData(account,KEY_USER_DATA_LOCATION, user.getLocation()); | ||
| 133 | + mAccountManager.setUserData(account,KEY_USER_TOKEN, user.getToken()); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public User getUserInfo(Account account){//获取用户信息 | ||
| 137 | + User user = new User(); | ||
| 138 | + user.setUid(Integer.parseInt(mAccountManager.getUserData(account, KEY_USER_DATA_USER_ID))); | ||
| 139 | + user.setNickname(mAccountManager.getUserData(account, KEY_USER_DATA_NICKNAME)); | ||
| 140 | + user.setFaceurl(mAccountManager.getUserData(account, KEY_USER_DATA_FACEURL)); | ||
| 141 | + user.setGender(mAccountManager.getUserData(account, KEY_USER_DATA_GENDER)); | ||
| 142 | + user.setMobile(mAccountManager.getUserData(account, KEY_USER_DATA_MOBILE)); | ||
| 143 | + user.setEmail(mAccountManager.getUserData(account, KEY_USER_DATA_EMAIL)); | ||
| 144 | + user.setLocation(mAccountManager.getUserData(account, KEY_USER_DATA_LOCATION)); | ||
| 145 | + user.setToken(mAccountManager.getUserData(account,KEY_USER_TOKEN)); | ||
| 146 | + return user; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + private Account findAccountByUsername(String username) { | ||
| 150 | + if (username.length() > 0) { | ||
| 151 | + for (Account account : mAccountManager.getAccountsByType(mContext.getString(R.string.ACCOUNT_TYPE))) { | ||
| 152 | + if (account.name.equals(username)) { | ||
| 153 | + return account; | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + //AppApplication.userID = 0; | ||
| 158 | + return null; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public void clearUser(){//清空用户信息/退出登录 | ||
| 162 | + Account account = getDefaultAccount(); | ||
| 163 | + if (account != null) { | ||
| 164 | + mAccountManager.removeAccount(account, null, null); | ||
| 165 | + sharedPrefs.remove(KEY_DEFAULT_ACCOUNT); | ||
| 166 | + activeAccount = null; | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | +} |
app/src/main/java/com/cnlive/gundam/user/fragment/LoginFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.fragment; | ||
| 2 | + | ||
| 3 | +import android.accounts.Account; | ||
| 4 | +import android.app.ProgressDialog; | ||
| 5 | +import android.databinding.DataBindingUtil; | ||
| 6 | +import android.os.Bundle; | ||
| 7 | +import android.support.annotation.Nullable; | ||
| 8 | +import android.support.v4.app.Fragment; | ||
| 9 | +import android.util.Log; | ||
| 10 | +import android.view.LayoutInflater; | ||
| 11 | +import android.view.View; | ||
| 12 | +import android.view.ViewGroup; | ||
| 13 | + | ||
| 14 | +import com.cnlive.gundam.R; | ||
| 15 | +import com.cnlive.gundam.databinding.FragmentLoginBinding; | ||
| 16 | +import com.cnlive.gundam.user.auth.UserService; | ||
| 17 | +import com.cnlive.gundam.user.model.User; | ||
| 18 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 19 | +import com.cnlive.libs.user.IUserService; | ||
| 20 | +import com.cnlive.libs.user.UserUtil; | ||
| 21 | +import com.cnlive.libs.user.model.DataEntity; | ||
| 22 | +import com.cnlive.libs.user.model.UserData; | ||
| 23 | +import com.cnlive.libs.util.data.network.Callback; | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * Created by luxiaoman on 2017/5/25. | ||
| 28 | + */ | ||
| 29 | + | ||
| 30 | +public class LoginFragment extends Fragment implements View.OnClickListener { | ||
| 31 | + private FragmentLoginBinding binding; | ||
| 32 | + | ||
| 33 | + //用户数据信息 | ||
| 34 | + public static DataEntity data; | ||
| 35 | + | ||
| 36 | + private Account account;//密码登录的account | ||
| 37 | + private Account account1;//第三方登录的account | ||
| 38 | + | ||
| 39 | + //跳转页面的对话框 | ||
| 40 | + private ProgressDialog dialog; | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + @Nullable | ||
| 47 | + @Override | ||
| 48 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
| 49 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_login, container, false); | ||
| 50 | + return binding.getRoot(); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public static Fragment newInstance() { | ||
| 54 | + LoginFragment fragment = new LoginFragment(); | ||
| 55 | + return fragment; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public void onActivityCreated(Bundle savedInstanceState) { | ||
| 60 | + super.onActivityCreated(savedInstanceState); | ||
| 61 | + initView(); | ||
| 62 | + initToolBar(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + private void initToolBar() { | ||
| 66 | + //整个页面的大标题 | ||
| 67 | + binding.loginIncludeLayout.toolbarTitle.setText("登录"); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + private void initView() { | ||
| 71 | + //登录 | ||
| 72 | + binding.btnLogin.setOnClickListener(this); | ||
| 73 | + //返回键 | ||
| 74 | + binding.backSelector.setOnClickListener(this); | ||
| 75 | + //注册 | ||
| 76 | + binding.register.setOnClickListener(this); | ||
| 77 | + //短信验证登录 | ||
| 78 | + binding.btnQucikLogin.setOnClickListener(this); | ||
| 79 | + //忘记密码 | ||
| 80 | + binding.tvForgotPwd.setOnClickListener(this); | ||
| 81 | + | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public void onClick(View v) { | ||
| 86 | + int i = v.getId(); | ||
| 87 | + if (i == R.id.back_selector) {//返回上一页面 | ||
| 88 | + getActivity().finish(); | ||
| 89 | + | ||
| 90 | + } else if (i == R.id.btn_login) {//登录 | ||
| 91 | + if (0 == binding.edtLoginNumber.getText().length()) { | ||
| 92 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 93 | + return; | ||
| 94 | + } else if (0 == binding.edtInputPassward.getText().length()) { | ||
| 95 | + ToastUtil.show(getActivity(), "请输入密码"); | ||
| 96 | + return; | ||
| 97 | + } | ||
| 98 | + /** | ||
| 99 | + * 用户名&密码登录 | ||
| 100 | + * | ||
| 101 | + * @param userName 手机邮箱或ID | ||
| 102 | + * @param pwd 密码 | ||
| 103 | + * @param frmId 渠道ID(非必传参数,可以传"") | ||
| 104 | + * @param callback 回调 | ||
| 105 | + */ | ||
| 106 | + //显示对话框 | ||
| 107 | + showDialog(); | ||
| 108 | + | ||
| 109 | + //可以请求服务器获取token | ||
| 110 | + account = new Account(binding.edtLoginNumber.getText().toString(), User.ACCOUNT_TYPE); | ||
| 111 | + Log.v("chinaUserInfoLogin1", String.valueOf(account)); | ||
| 112 | + | ||
| 113 | + | ||
| 114 | + //调用sdk的密码登录的方法 | ||
| 115 | + UserUtil.login(binding.edtLoginNumber.getText().toString(), binding.edtInputPassward.getText().toString(), "frmId", userdatacall); | ||
| 116 | + | ||
| 117 | + } else if (i == R.id.register) {//进入注册页面 | ||
| 118 | + getFragmentManager() | ||
| 119 | + .beginTransaction() | ||
| 120 | + .addToBackStack(null) | ||
| 121 | + .replace(R.id.login_fragment, RegisterFragment.newInstance()).commit(); | ||
| 122 | + | ||
| 123 | + } else if (i == R.id.btn_qucik_login) {//进入短信验证登录页面 | ||
| 124 | + getFragmentManager() | ||
| 125 | + .beginTransaction() | ||
| 126 | + .addToBackStack(null) | ||
| 127 | + .replace(R.id.login_fragment, QuickLoginFragment.newInstance()).commit(); | ||
| 128 | + | ||
| 129 | + } else if (i == R.id.tv_forgot_pwd) {//进入忘记密码页面 | ||
| 130 | + getFragmentManager() | ||
| 131 | + .beginTransaction() | ||
| 132 | + .addToBackStack(null) | ||
| 133 | + .replace(R.id.login_fragment, UserFindPasswardFragment.newInstance()).commit(); | ||
| 134 | + | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + | ||
| 139 | + | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * *密码登录的回调 | ||
| 145 | + */ | ||
| 146 | + protected UserDataCall userdatacall = new UserDataCall(); | ||
| 147 | + | ||
| 148 | + private class UserDataCall implements Callback { | ||
| 149 | + @Override | ||
| 150 | + public void onState(int what, String extra, Object obj) { | ||
| 151 | + Log.v("onState",extra); | ||
| 152 | + switch (what) { | ||
| 153 | + case IUserService.SUCCESS: | ||
| 154 | + ToastUtil.show(getActivity(), "密码登录成功"); | ||
| 155 | + closeDialog(); | ||
| 156 | + UserData userData = (UserData) obj; | ||
| 157 | + data = userData.getData(); | ||
| 158 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 159 | + userService.setUserInfo(account, data); | ||
| 160 | + //userService.isAutoLogin(); | ||
| 161 | + userService.autoLogin(binding.edtLoginNumber.toString(), binding.edtInputPassward.getText().toString(), data); | ||
| 162 | + | ||
| 163 | + if (null != data.toString()) { | ||
| 164 | + //getFragmentManager().popBackStack(); | ||
| 165 | + getActivity().finish(); | ||
| 166 | + } | ||
| 167 | + break; | ||
| 168 | + case IUserService.ERROR_PARAM: | ||
| 169 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 170 | + break; | ||
| 171 | + case IUserService.ERROR_USER_NOT_FOUND: | ||
| 172 | + ToastUtil.show(getActivity(), IUserService.message_error_user_not_found); | ||
| 173 | + break; | ||
| 174 | + case IUserService.ERROR_USERNAME_OR_PASSWORD: | ||
| 175 | + ToastUtil.show(getActivity(), IUserService.message_error_username_or_password); | ||
| 176 | + break; | ||
| 177 | + case IUserService.ERROR_PASSWORD: | ||
| 178 | + ToastUtil.show(getActivity(), IUserService.message_error_password); | ||
| 179 | + break; | ||
| 180 | + } | ||
| 181 | + closeDialog(); | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + /** | ||
| 186 | + * 显示对话框 | ||
| 187 | + */ | ||
| 188 | + public void showDialog() { | ||
| 189 | + if (dialog == null) { | ||
| 190 | + dialog = new ProgressDialog(getActivity()); | ||
| 191 | + dialog.setMessage("正在登录,请稍等..."); | ||
| 192 | + } | ||
| 193 | + if (!dialog.isShowing()) { | ||
| 194 | + dialog.show(); | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * 关闭对话框 | ||
| 200 | + */ | ||
| 201 | + public void closeDialog() { | ||
| 202 | + if (dialog != null && dialog.isShowing()) { | ||
| 203 | + dialog.dismiss(); | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | +} |
app/src/main/java/com/cnlive/gundam/user/fragment/QuickLoginFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.fragment; | ||
| 2 | + | ||
| 3 | +import android.accounts.Account; | ||
| 4 | +import android.app.ProgressDialog; | ||
| 5 | +import android.databinding.DataBindingUtil; | ||
| 6 | +import android.os.Bundle; | ||
| 7 | +import android.support.annotation.Nullable; | ||
| 8 | +import android.support.v4.app.Fragment; | ||
| 9 | +import android.util.Log; | ||
| 10 | +import android.view.LayoutInflater; | ||
| 11 | +import android.view.View; | ||
| 12 | +import android.view.ViewGroup; | ||
| 13 | + | ||
| 14 | +import com.cnlive.gundam.R; | ||
| 15 | +import com.cnlive.gundam.databinding.FragmentQuickLoginBinding; | ||
| 16 | +import com.cnlive.gundam.user.auth.UserService; | ||
| 17 | +import com.cnlive.gundam.user.model.User; | ||
| 18 | +import com.cnlive.gundam.user.util.DownTimer; | ||
| 19 | +import com.cnlive.gundam.user.util.ShowTimeUtil; | ||
| 20 | +import com.cnlive.gundam.user.util.SystemTools; | ||
| 21 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 22 | +import com.cnlive.libs.user.IUserService; | ||
| 23 | +import com.cnlive.libs.user.UserUtil; | ||
| 24 | +import com.cnlive.libs.user.model.DataEntity; | ||
| 25 | +import com.cnlive.libs.user.model.UserData; | ||
| 26 | +import com.cnlive.libs.util.data.network.Callback; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * Created by luxiaoman on 2017/5/31. | ||
| 30 | + */ | ||
| 31 | + | ||
| 32 | +public class QuickLoginFragment extends Fragment implements View.OnClickListener { | ||
| 33 | + private FragmentQuickLoginBinding binding; | ||
| 34 | + | ||
| 35 | + //用户数据信息 | ||
| 36 | + public static DataEntity data; | ||
| 37 | + | ||
| 38 | + //跳转页面的对话框 | ||
| 39 | + private ProgressDialog dialog; | ||
| 40 | + | ||
| 41 | + //倒计时控件 | ||
| 42 | + private DownTimer mDownTimer; | ||
| 43 | + | ||
| 44 | + //显示时间的字符串 | ||
| 45 | + private String showTimer; | ||
| 46 | + | ||
| 47 | + //管理用户 | ||
| 48 | + private Account account; | ||
| 49 | + | ||
| 50 | + public static Fragment newInstance() { | ||
| 51 | + QuickLoginFragment fragment = new QuickLoginFragment(); | ||
| 52 | + return fragment; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Nullable | ||
| 56 | + @Override | ||
| 57 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
| 58 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_quick_login, container, false); | ||
| 59 | + return binding.getRoot() ; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void onActivityCreated(Bundle savedInstanceState) { | ||
| 64 | + super.onActivityCreated(savedInstanceState); | ||
| 65 | + initToolBar(); | ||
| 66 | + initView(); | ||
| 67 | + | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + private void initView() { | ||
| 71 | + //返回键 | ||
| 72 | + binding.backSelector.setOnClickListener(this); | ||
| 73 | + //快捷登录 | ||
| 74 | + binding.btnLogin.setOnClickListener(this); | ||
| 75 | + //获取验证码 | ||
| 76 | + binding.quickLoginLayout.getVerify.setOnClickListener(this); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + private void initToolBar() { | ||
| 80 | + //整个页面的大标题 | ||
| 81 | + binding.quickLoginIncludeLayout.toolbarTitle.setText("短信验证登录"); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public void onClick(View view) { | ||
| 86 | + int i = view.getId(); | ||
| 87 | + if (i == R.id.get_verify) {//获取验证码 | ||
| 88 | + if (0 == binding.quickLoginLayout.edtLoginNumber.getText().length()) { | ||
| 89 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 90 | + return; | ||
| 91 | + } else if (!SystemTools.isMobileNO(binding.quickLoginLayout.edtLoginNumber.getText().toString())) { | ||
| 92 | + ToastUtil.show(getActivity(), "请输入正确的手机号"); | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + //调用sdk的发送短信验证码的方法 | ||
| 96 | + UserUtil.sendMessage(IUserService.QUICK_LOGIN, binding.quickLoginLayout.edtLoginNumber.getText().toString(), mobilecall); | ||
| 97 | + //初始化倒计时 | ||
| 98 | + mDownTimer = new DownTimer(); | ||
| 99 | + //开始倒计时 | ||
| 100 | + startTimer(ShowTimeUtil.mSetTotalTime); | ||
| 101 | + } else if (i == R.id.btn_login) {//快捷登录 | ||
| 102 | + if (0 == binding.quickLoginLayout.edtLoginNumber.getText().length()) { | ||
| 103 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 104 | + return; | ||
| 105 | + } else if (0 != binding.quickLoginLayout.edtLoginNumber.getText().length() && 0 == binding.quickLoginLayout.edtVerify.getText().length()) { | ||
| 106 | + ToastUtil.show(getActivity(), "请输入验证码"); | ||
| 107 | + return; | ||
| 108 | + } | ||
| 109 | + /** | ||
| 110 | + * 快捷登录 | ||
| 111 | + * @param userName 手机号 | ||
| 112 | + * @param verificationCode 验证码 | ||
| 113 | + * @param frmId 渠道ID(非必传参数,可传"") | ||
| 114 | + * @param callback 回调 | ||
| 115 | + */ | ||
| 116 | + //显示对话框 | ||
| 117 | + showDialog(); | ||
| 118 | + //可以连接服务器进行快捷登录 | ||
| 119 | + account = new Account(binding.quickLoginLayout.edtLoginNumber.getText().toString(), User.ACCOUNT_TYPE); | ||
| 120 | + //调用sdk的快捷登录的方法 | ||
| 121 | + UserUtil.quickLogin(String.valueOf(binding.quickLoginLayout.edtLoginNumber.getText()), String.valueOf(binding.quickLoginLayout.edtVerify.getText()), "frmId", userdatacall); | ||
| 122 | + | ||
| 123 | + } else if (i == R.id.back_selector) {//返回上一页面 | ||
| 124 | + getFragmentManager().popBackStack(); | ||
| 125 | + | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * 发送短信验证码的回调 | ||
| 131 | + */ | ||
| 132 | + protected MobileCall mobilecall = new MobileCall(); | ||
| 133 | + private class MobileCall implements Callback { | ||
| 134 | + @Override | ||
| 135 | + public void onState(int what, String extra, Object obj) { | ||
| 136 | + Log.v("MobileCall",extra); | ||
| 137 | + switch (what){ | ||
| 138 | + case IUserService.SUCCESS: | ||
| 139 | + ToastUtil.show(getActivity(), "验证码已发送"); | ||
| 140 | + break; | ||
| 141 | + case IUserService.ERROR_PARAM: | ||
| 142 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 143 | + break; | ||
| 144 | + case IUserService.ERROR_MOBILE: | ||
| 145 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile); | ||
| 146 | + break; | ||
| 147 | + case IUserService.ERROR_CLIENT_PLAT: | ||
| 148 | + ToastUtil.show(getActivity(), IUserService.message_error_client_plat); | ||
| 149 | + break; | ||
| 150 | + case IUserService.ERROR_MOBILE_NOT_REGISTER: | ||
| 151 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile_not_register); | ||
| 152 | + break; | ||
| 153 | + case IUserService.ERROR_MESSAGE_SERVER: | ||
| 154 | + ToastUtil.show(getActivity(), IUserService.message_error_server); | ||
| 155 | + break; | ||
| 156 | + case IUserService.ERROR_MESSAGE_SERVER_ANALYSIS: | ||
| 157 | + ToastUtil.show(getActivity(), IUserService.message_error_message_server_analysis); | ||
| 158 | + break; | ||
| 159 | + case IUserService.ERROR_OTHER: | ||
| 160 | + ToastUtil.show(getActivity(), IUserService.message_error_other); | ||
| 161 | + break; | ||
| 162 | + case IUserService.ERROR_SEND_MESSAGE_TO_MUCH: | ||
| 163 | + ToastUtil.show(getActivity(), IUserService.message_error_send_message_to_much); | ||
| 164 | + break; | ||
| 165 | + case IUserService.ERROR_SEND_MESSAGE_FAILED: | ||
| 166 | + ToastUtil.show(getActivity(), IUserService.message_error_send_message_failed); | ||
| 167 | + break; | ||
| 168 | + case IUserService.ERROR_MESSAGE_OTHER: | ||
| 169 | + ToastUtil.show(getActivity(), IUserService.message_error_message_other); | ||
| 170 | + break; | ||
| 171 | + } | ||
| 172 | + if (what != 0) { | ||
| 173 | + //获取验证码按钮取消倒计时 | ||
| 174 | + mDownTimer.cancel(); | ||
| 175 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 176 | + binding.quickLoginLayout.getVerify.setText("获取验证码"); | ||
| 177 | + //将获取验证码按钮设置为可点击 | ||
| 178 | + binding.quickLoginLayout.getVerify.setEnabled(true); | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * 快捷登录的回调 | ||
| 185 | + */ | ||
| 186 | + protected UserDataCall userdatacall = new UserDataCall(); | ||
| 187 | + private class UserDataCall implements Callback { | ||
| 188 | + @Override | ||
| 189 | + public void onState(int what, String extra, Object obj) { | ||
| 190 | + switch (what) { | ||
| 191 | + case IUserService.SUCCESS: | ||
| 192 | + ToastUtil.show(getActivity(), "快捷登录成功"); | ||
| 193 | + UserData userData = (UserData) obj; | ||
| 194 | + data = userData.getData(); | ||
| 195 | + if (getActivity() != null) { | ||
| 196 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 197 | + userService.setUserInfo(account,data); | ||
| 198 | + userService.autoLogin(binding.quickLoginLayout.edtLoginNumber.getText().toString(),"userutil",data); | ||
| 199 | + //userService.isAutoLogin(); | ||
| 200 | + if (null != data.toString()) { | ||
| 201 | + getActivity().finish(); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + break; | ||
| 205 | + case IUserService.ERROR_PARAM: | ||
| 206 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 207 | + break; | ||
| 208 | + case IUserService.ERROR_CLIENT_PLAT: | ||
| 209 | + ToastUtil.show(getActivity(), IUserService.message_error_client_plat); | ||
| 210 | + break; | ||
| 211 | + case IUserService.ERROR_MOBILE: | ||
| 212 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile); | ||
| 213 | + break; | ||
| 214 | + case IUserService.ERROR_VERIFICATION_CODE_LENGTH: | ||
| 215 | + ToastUtil.show(getActivity(), IUserService.message_error_verfication_code_length); | ||
| 216 | + break; | ||
| 217 | + case IUserService.ERROR_VERIFICATION_CODE: | ||
| 218 | + ToastUtil.show(getActivity(), IUserService.message_error_verfication_code); | ||
| 219 | + break; | ||
| 220 | + case IUserService.ERROR_MOBILE_EXIST: | ||
| 221 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile_exist); | ||
| 222 | + break; | ||
| 223 | + case IUserService.ERROR_NICK_NAME_EXIST: | ||
| 224 | + ToastUtil.show(getActivity(), IUserService.message_error_nick_name_exist); | ||
| 225 | + break; | ||
| 226 | + case IUserService.ERROR_OTHER: | ||
| 227 | + ToastUtil.show(getActivity(), IUserService.message_error_other); | ||
| 228 | + break; | ||
| 229 | + } | ||
| 230 | + if (what!=0){ | ||
| 231 | + //获取验证码按钮取消倒计时 | ||
| 232 | + mDownTimer.cancel(); | ||
| 233 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 234 | + binding.quickLoginLayout.getVerify.setText("获取验证码"); | ||
| 235 | + //将获取验证码按钮设置为可点击 | ||
| 236 | + binding.quickLoginLayout.getVerify.setEnabled(true); | ||
| 237 | + } | ||
| 238 | + closeDialog(); | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + /** | ||
| 243 | + * 显示对话框 | ||
| 244 | + */ | ||
| 245 | + public void showDialog() { | ||
| 246 | + if (dialog == null) { | ||
| 247 | + dialog = new ProgressDialog(getActivity()); | ||
| 248 | + dialog.setMessage("正在登录,请稍等..."); | ||
| 249 | + } | ||
| 250 | + if (!dialog.isShowing()) { | ||
| 251 | + dialog.show(); | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + /** | ||
| 256 | + * 关闭对话框 | ||
| 257 | + */ | ||
| 258 | + public void closeDialog() { | ||
| 259 | + if (dialog != null && dialog.isShowing()) { | ||
| 260 | + dialog.dismiss(); | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + /** | ||
| 265 | + * 开始倒计时 | ||
| 266 | + * | ||
| 267 | + * @param totalTime 剩余时长 | ||
| 268 | + */ | ||
| 269 | + private void startTimer(long totalTime) { | ||
| 270 | + mDownTimer.cancel();//获取验证码按钮取消倒计时 | ||
| 271 | + mDownTimer.setTotalTime(totalTime);//设置毫秒数 | ||
| 272 | + mDownTimer.setIntervalTime(1000);//设置间隔数 | ||
| 273 | + mDownTimer.setTimerLiener(new DownTimer.TimeListener() { | ||
| 274 | + @Override | ||
| 275 | + public void onFinish() { | ||
| 276 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 277 | + binding.quickLoginLayout.getVerify.setText("获取验证码"); | ||
| 278 | + //将获取验证码按钮设置为可点击 | ||
| 279 | + binding.quickLoginLayout.getVerify.setEnabled(true); | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + @Override | ||
| 283 | + public void onInterval(long remainTime) { | ||
| 284 | + showTimer= ShowTimeUtil.changeTimerFormat(remainTime); | ||
| 285 | + //将获取验证码按钮的字样设置为显示时间 | ||
| 286 | + binding.quickLoginLayout.getVerify.setText(showTimer); | ||
| 287 | + //将获取验证码按钮设置为不可点击 | ||
| 288 | + binding.quickLoginLayout.getVerify.setEnabled(false); | ||
| 289 | + } | ||
| 290 | + }); | ||
| 291 | + //获取验证码按钮开始倒计时 | ||
| 292 | + mDownTimer.start(); | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | +} | ||
| 296 | + | ||
| 297 | + | ||
| 298 | + |
app/src/main/java/com/cnlive/gundam/user/fragment/RegisterFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.fragment; | ||
| 2 | + | ||
| 3 | +import android.accounts.Account; | ||
| 4 | +import android.accounts.AccountManager; | ||
| 5 | +import android.app.ProgressDialog; | ||
| 6 | +import android.databinding.DataBindingUtil; | ||
| 7 | +import android.os.Bundle; | ||
| 8 | +import android.support.annotation.Nullable; | ||
| 9 | +import android.support.v4.app.Fragment; | ||
| 10 | +import android.view.LayoutInflater; | ||
| 11 | +import android.view.View; | ||
| 12 | +import android.view.ViewGroup; | ||
| 13 | + | ||
| 14 | +import com.cnlive.gundam.R; | ||
| 15 | +import com.cnlive.gundam.databinding.UserFragmentRegisterBinding; | ||
| 16 | +import com.cnlive.gundam.user.auth.UserService; | ||
| 17 | +import com.cnlive.gundam.user.model.User; | ||
| 18 | +import com.cnlive.gundam.user.util.DownTimer; | ||
| 19 | +import com.cnlive.gundam.user.util.ShowTimeUtil; | ||
| 20 | +import com.cnlive.gundam.user.util.SystemTools; | ||
| 21 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 22 | +import com.cnlive.libs.user.IUserService; | ||
| 23 | +import com.cnlive.libs.user.UserUtil; | ||
| 24 | +import com.cnlive.libs.user.model.DataEntity; | ||
| 25 | +import com.cnlive.libs.user.model.UserData; | ||
| 26 | +import com.cnlive.libs.util.data.network.Callback; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * Created by luxiaoman on 2017/5/31. | ||
| 31 | + */ | ||
| 32 | + | ||
| 33 | +public class RegisterFragment extends Fragment implements View.OnClickListener { | ||
| 34 | + private UserFragmentRegisterBinding binding; | ||
| 35 | + | ||
| 36 | + //用户数据信息 | ||
| 37 | + public static DataEntity data; | ||
| 38 | + | ||
| 39 | + //跳转页面的对话框 | ||
| 40 | + private ProgressDialog dialog; | ||
| 41 | + | ||
| 42 | + //倒计时控件 | ||
| 43 | + private DownTimer mDownTimer; | ||
| 44 | + | ||
| 45 | + //显示时间的字符串 | ||
| 46 | + private String showTimer; | ||
| 47 | + | ||
| 48 | + //管理用户 | ||
| 49 | + private Account account; | ||
| 50 | + | ||
| 51 | + public static Fragment newInstance() { | ||
| 52 | + RegisterFragment fragment = new RegisterFragment(); | ||
| 53 | + return fragment; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Nullable | ||
| 57 | + @Override | ||
| 58 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
| 59 | + binding = DataBindingUtil.inflate(inflater, R.layout.user_fragment_register, container, false); | ||
| 60 | + return binding.getRoot(); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public void onActivityCreated(Bundle savedInstanceState) { | ||
| 65 | + super.onActivityCreated(savedInstanceState); | ||
| 66 | + initToolBar(); | ||
| 67 | + initView(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + private void initToolBar() { | ||
| 71 | + //整个页面的大标题 | ||
| 72 | + binding.registerIncludeLayout.toolbarTitle.setText("注册"); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + private void initView() { | ||
| 76 | + //返回键 | ||
| 77 | + binding.backSelector.setOnClickListener(this); | ||
| 78 | + //注册 | ||
| 79 | + binding.btnRegister.setOnClickListener(this); | ||
| 80 | + //获取验证码 | ||
| 81 | + binding.mobileKeycodeLayout.getVerify.setOnClickListener(this); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public void onClick(View view) { | ||
| 86 | + int i = view.getId(); | ||
| 87 | + if (i == R.id.btn_register) {//注册 | ||
| 88 | + if (0 == binding.mobileKeycodeLayout.edtLoginNumber.getText().length()) { | ||
| 89 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 90 | + return; | ||
| 91 | + } else if (0 != binding.mobileKeycodeLayout.edtLoginNumber.getText().length() && 0 == binding.mobileKeycodeLayout.edtVerify.getText().length()) { | ||
| 92 | + ToastUtil.show(getActivity(), "请输入验证码"); | ||
| 93 | + return; | ||
| 94 | + } else if (0 == binding.edtInputPassward.getText().length()) { | ||
| 95 | + ToastUtil.show(getActivity(), "请输入密码"); | ||
| 96 | + return; | ||
| 97 | + } | ||
| 98 | + /** | ||
| 99 | + * 注册 | ||
| 100 | + * | ||
| 101 | + * @param userName 邮箱或手机 | ||
| 102 | + * @param pwd 密码 | ||
| 103 | + * @param verificationCode 手机验证码(手机号注册时必填) | ||
| 104 | + * @param invitationCode 邀请码(非必传参数,可以传"") | ||
| 105 | + * @param frmId 渠道ID(非必传参数,可传入"") | ||
| 106 | + * @param callback 回调 | ||
| 107 | + */ | ||
| 108 | + if (!("").equals(binding.edtInputPassward.getText().toString())) { | ||
| 109 | + showDialog(); | ||
| 110 | + //可以连接服务器进行注册,这里为了简单略过 | ||
| 111 | + account = new Account(binding.mobileKeycodeLayout.edtLoginNumber.getText().toString(), User.ACCOUNT_TYPE); | ||
| 112 | + AccountManager am = AccountManager.get(view.getContext()); | ||
| 113 | + am.addAccountExplicitly(account, binding.edtInputPassward.getText().toString(), null); | ||
| 114 | + //调用sdk的注册的方法 | ||
| 115 | + UserUtil.register(binding.mobileKeycodeLayout.edtLoginNumber.getText().toString(), binding.edtInputPassward.getText().toString(), binding.mobileKeycodeLayout.edtVerify.getText().toString(), "invitationCode", "frmId", userdatacall); | ||
| 116 | + } else { | ||
| 117 | + ToastUtil.show(getActivity(), "密码不一致"); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + } else if (i == R.id.get_verify) {//获取验证码 | ||
| 121 | + if (0 == binding.mobileKeycodeLayout.edtLoginNumber.getText().length()) { | ||
| 122 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 123 | + return; | ||
| 124 | + } else if (!SystemTools.isMobileNO(binding.mobileKeycodeLayout.edtLoginNumber.getText().toString())) { | ||
| 125 | + ToastUtil.show(getActivity(), "请输入正确的手机号码"); | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + //调用sdk的发送短信验证码的方法 | ||
| 129 | + UserUtil.sendMessage(IUserService.REGISTER_OR_MODIFY_MOBILE, binding.mobileKeycodeLayout.edtLoginNumber.getText().toString(), mobilecall); | ||
| 130 | + //初始化倒计时 | ||
| 131 | + mDownTimer = new DownTimer(); | ||
| 132 | + //开始倒计时 | ||
| 133 | + startTimer(ShowTimeUtil.mSetTotalTime); | ||
| 134 | + | ||
| 135 | + } else if (i == R.id.back_selector) {//返回上一页面 | ||
| 136 | + getFragmentManager().popBackStack(); | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * 发送短信验证码的回调 | ||
| 143 | + */ | ||
| 144 | + protected MobileCall mobilecall = new MobileCall(); | ||
| 145 | + private class MobileCall implements Callback { | ||
| 146 | + @Override | ||
| 147 | + public void onState(int what, String extra, Object obj) { | ||
| 148 | + switch (what){ | ||
| 149 | + case IUserService.SUCCESS: | ||
| 150 | + ToastUtil.show(getActivity(), "验证码已发送"); | ||
| 151 | + break; | ||
| 152 | + case IUserService.ERROR_PARAM: | ||
| 153 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 154 | + break; | ||
| 155 | + case IUserService.ERROR_MOBILE: | ||
| 156 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile); | ||
| 157 | + break; | ||
| 158 | + case IUserService.ERROR_CLIENT_PLAT: | ||
| 159 | + ToastUtil.show(getActivity(), IUserService.message_error_client_plat); | ||
| 160 | + break; | ||
| 161 | + case IUserService.ERROR_MOBILE_NOT_REGISTER: | ||
| 162 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile_not_register); | ||
| 163 | + break; | ||
| 164 | + case IUserService.ERROR_MESSAGE_SERVER: | ||
| 165 | + ToastUtil.show(getActivity(), IUserService.message_error_server); | ||
| 166 | + break; | ||
| 167 | + case IUserService.ERROR_MESSAGE_SERVER_ANALYSIS: | ||
| 168 | + ToastUtil.show(getActivity(), IUserService.message_error_message_server_analysis); | ||
| 169 | + break; | ||
| 170 | + case IUserService.ERROR_OTHER: | ||
| 171 | + ToastUtil.show(getActivity(), IUserService.message_error_other); | ||
| 172 | + break; | ||
| 173 | + case IUserService.ERROR_SEND_MESSAGE_TO_MUCH: | ||
| 174 | + ToastUtil.show(getActivity(), IUserService.message_error_send_message_to_much); | ||
| 175 | + break; | ||
| 176 | + case IUserService.ERROR_SEND_MESSAGE_FAILED: | ||
| 177 | + ToastUtil.show(getActivity(), IUserService.message_error_send_message_failed); | ||
| 178 | + break; | ||
| 179 | + case IUserService.ERROR_MESSAGE_OTHER: | ||
| 180 | + ToastUtil.show(getActivity(), IUserService.message_error_message_other); | ||
| 181 | + break; | ||
| 182 | + } | ||
| 183 | + if (what != 0) { | ||
| 184 | + //获取验证码按钮取消倒计时 | ||
| 185 | + mDownTimer.cancel(); | ||
| 186 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 187 | + binding.mobileKeycodeLayout.getVerify.setText("获取验证码"); | ||
| 188 | + //将获取验证码按钮设置为可点击 | ||
| 189 | + binding.mobileKeycodeLayout.getVerify.setEnabled(true); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + /** | ||
| 195 | + * 注册的回调 | ||
| 196 | + */ | ||
| 197 | + protected UserDataCall userdatacall = new UserDataCall(); | ||
| 198 | + private class UserDataCall implements Callback { | ||
| 199 | + @Override | ||
| 200 | + public void onState(int what, String extra, Object obj) { | ||
| 201 | + switch (what) { | ||
| 202 | + case IUserService.SUCCESS: | ||
| 203 | + ToastUtil.show(getActivity(), "注册成功"); | ||
| 204 | + UserData userData = (UserData) obj; | ||
| 205 | + data = userData.getData(); | ||
| 206 | + if (getActivity() != null) { | ||
| 207 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 208 | + userService.setUserInfo(account,data); | ||
| 209 | + //userService.isAutoLogin(); | ||
| 210 | + userService.autoLogin(binding.mobileKeycodeLayout.edtLoginNumber.getText().toString(),binding.edtInputPassward.getText().toString(),data); | ||
| 211 | + if (null != data.toString()) { | ||
| 212 | + getActivity().finish(); | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + break; | ||
| 216 | + case IUserService.ERROR_PARAM: | ||
| 217 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 218 | + break; | ||
| 219 | + case IUserService.ERROR_USER_NAME: | ||
| 220 | + ToastUtil.show(getActivity(), IUserService.message_error_user_name); | ||
| 221 | + break; | ||
| 222 | + case IUserService.ERROR_VERIFICATION_CODE_LENGTH: | ||
| 223 | + ToastUtil.show(getActivity(), IUserService.message_error_verfication_code_length); | ||
| 224 | + break; | ||
| 225 | + case IUserService.ERROR_MAIL: | ||
| 226 | + ToastUtil.show(getActivity(), IUserService.message_error_mail); | ||
| 227 | + break; | ||
| 228 | + case IUserService.ERROR_PASSWORD_CONTENT: | ||
| 229 | + ToastUtil.show(getActivity(), IUserService.message_error_password_content); | ||
| 230 | + break; | ||
| 231 | + case IUserService.ERROR_PASSWORD_EQUAL_USERNAME: | ||
| 232 | + ToastUtil.show(getActivity(), IUserService.message_error_password_equal_username); | ||
| 233 | + break; | ||
| 234 | + case IUserService.ERROR_PASSWORD_CANNOT_CONTIGUOUS: | ||
| 235 | + ToastUtil.show(getActivity(), IUserService.message_error_password_cannot_be_contiguous); | ||
| 236 | + break; | ||
| 237 | + case IUserService.ERROR_PASSWORD_CANNOT_CONTIGUOUS_SAME: | ||
| 238 | + ToastUtil.show(getActivity(), IUserService.message_error_password_cannot_be_contiguous_same); | ||
| 239 | + break; | ||
| 240 | + case IUserService.ERROR_CLIENT_PLAT: | ||
| 241 | + ToastUtil.show(getActivity(), IUserService.message_error_client_plat); | ||
| 242 | + break; | ||
| 243 | + case IUserService.ERROR_MOBILE_EXIST: | ||
| 244 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile_exist); | ||
| 245 | + break; | ||
| 246 | + case IUserService.ERROR_MAIL_EXIST: | ||
| 247 | + ToastUtil.show(getActivity(), IUserService.message_error_mail_exist); | ||
| 248 | + break; | ||
| 249 | + case IUserService.ERROR_NICK_NAME_EXIST: | ||
| 250 | + ToastUtil.show(getActivity(), IUserService.message_error_nick_name_exist); | ||
| 251 | + break; | ||
| 252 | + case IUserService.ERROR_VERIFICATION_CODE: | ||
| 253 | + ToastUtil.show(getActivity(), IUserService.message_error_verfication_code); | ||
| 254 | + break; | ||
| 255 | + case IUserService.ERROR_OTHER: | ||
| 256 | + ToastUtil.show(getActivity(), IUserService.message_error_other); | ||
| 257 | + break; | ||
| 258 | + } | ||
| 259 | + if (what!=0){ | ||
| 260 | + //获取验证码按钮取消倒计时 | ||
| 261 | + mDownTimer.cancel(); | ||
| 262 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 263 | + binding.mobileKeycodeLayout.getVerify.setText("获取验证码"); | ||
| 264 | + //将获取验证码按钮设置为可点击 | ||
| 265 | + binding.mobileKeycodeLayout.getVerify.setEnabled(true); | ||
| 266 | + } | ||
| 267 | + closeDialog(); | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * 开始倒计时 | ||
| 273 | + * | ||
| 274 | + * @param totalTime 剩余时长 | ||
| 275 | + */ | ||
| 276 | + private void startTimer(long totalTime) { | ||
| 277 | + mDownTimer.cancel();//获取验证码按钮取消倒计时 | ||
| 278 | + mDownTimer.setTotalTime(totalTime);//设置毫秒数 | ||
| 279 | + mDownTimer.setIntervalTime(1000);//设置间隔数 | ||
| 280 | + mDownTimer.setTimerLiener(new DownTimer.TimeListener() { | ||
| 281 | + @Override | ||
| 282 | + public void onFinish() { | ||
| 283 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 284 | + binding.mobileKeycodeLayout.getVerify.setText("获取验证码"); | ||
| 285 | + //将获取验证码按钮设置为可点击 | ||
| 286 | + binding.mobileKeycodeLayout.getVerify.setEnabled(true); | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + @Override | ||
| 290 | + public void onInterval(long remainTime) { | ||
| 291 | + showTimer= ShowTimeUtil.changeTimerFormat(remainTime); | ||
| 292 | + //将获取验证码按钮的字样设置为显示时间 | ||
| 293 | + binding.mobileKeycodeLayout.getVerify.setText(showTimer); | ||
| 294 | + //将获取验证码按钮设置为不可点击 | ||
| 295 | + binding.mobileKeycodeLayout.getVerify.setEnabled(false); | ||
| 296 | + } | ||
| 297 | + }); | ||
| 298 | + //获取验证码按钮开始倒计时 | ||
| 299 | + mDownTimer.start(); | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + /** | ||
| 303 | + * 显示对话框 | ||
| 304 | + */ | ||
| 305 | + public void showDialog() { | ||
| 306 | + if (dialog == null) { | ||
| 307 | + dialog = new ProgressDialog(getActivity()); | ||
| 308 | + dialog.setMessage("正在注册,请稍等..."); | ||
| 309 | + } | ||
| 310 | + if (!dialog.isShowing()) { | ||
| 311 | + dialog.show(); | ||
| 312 | + } | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + /** | ||
| 316 | + * 关闭对话框 | ||
| 317 | + */ | ||
| 318 | + public void closeDialog() { | ||
| 319 | + if (dialog != null && dialog.isShowing()) { | ||
| 320 | + dialog.dismiss(); | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | +} |
app/src/main/java/com/cnlive/gundam/user/fragment/UserFindPasswardFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.fragment; | ||
| 2 | + | ||
| 3 | +import android.app.ProgressDialog; | ||
| 4 | +import android.databinding.DataBindingUtil; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | +import android.support.annotation.Nullable; | ||
| 7 | +import android.support.v4.app.Fragment; | ||
| 8 | +import android.view.LayoutInflater; | ||
| 9 | +import android.view.View; | ||
| 10 | +import android.view.ViewGroup; | ||
| 11 | + | ||
| 12 | +import com.cnlive.gundam.R; | ||
| 13 | +import com.cnlive.gundam.databinding.UserFragmentFindPasswordBinding; | ||
| 14 | +import com.cnlive.gundam.user.util.DownTimer; | ||
| 15 | +import com.cnlive.gundam.user.util.ShowTimeUtil; | ||
| 16 | +import com.cnlive.gundam.user.util.SystemTools; | ||
| 17 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 18 | +import com.cnlive.libs.user.IUserService; | ||
| 19 | +import com.cnlive.libs.user.UserUtil; | ||
| 20 | +import com.cnlive.libs.user.model.DataEntity; | ||
| 21 | +import com.cnlive.libs.util.data.network.Callback; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Created by luxiaoman on 2017/5/26. | ||
| 26 | + */ | ||
| 27 | + | ||
| 28 | +public class UserFindPasswardFragment extends Fragment implements View.OnClickListener{ | ||
| 29 | + private UserFragmentFindPasswordBinding binding; | ||
| 30 | + | ||
| 31 | + //用户数据信息 | ||
| 32 | + public static DataEntity data; | ||
| 33 | + | ||
| 34 | + //跳转页面的对话框 | ||
| 35 | + private ProgressDialog dialog; | ||
| 36 | + | ||
| 37 | + //倒计时控件 | ||
| 38 | + private DownTimer mDownTimer; | ||
| 39 | + | ||
| 40 | + //显示时间的字符串 | ||
| 41 | + private String showTimer; | ||
| 42 | + | ||
| 43 | + @Nullable | ||
| 44 | + @Override | ||
| 45 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
| 46 | + binding = DataBindingUtil.inflate(inflater, R.layout.user_fragment_find_password, container, false); | ||
| 47 | + return binding.getRoot(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public static Fragment newInstance() { | ||
| 51 | + UserFindPasswardFragment fragment = new UserFindPasswardFragment(); | ||
| 52 | + return fragment; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + public void onActivityCreated(Bundle savedInstanceState) { | ||
| 57 | + super.onActivityCreated(savedInstanceState); | ||
| 58 | + initView(); | ||
| 59 | + initToolBar(); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + private void initView() { | ||
| 63 | + //返回键 | ||
| 64 | + binding.backSelector.setOnClickListener(this); | ||
| 65 | + //找回密码 | ||
| 66 | + binding.btnFindPassword.setOnClickListener(this); | ||
| 67 | + //获取验证码 | ||
| 68 | + binding.findPasswordLayout.getVerify.setOnClickListener(this); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + private void initToolBar() { | ||
| 72 | + //整个页面的大标题 | ||
| 73 | + binding.findPasswordIncludeLayout.toolbarTitle.setText("找回密码"); | ||
| 74 | + //mTitle.setText("找回密码"); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public void onClick(View view) { | ||
| 79 | + int i = view.getId(); | ||
| 80 | + if (i == R.id.btn_find_password) {//确定 | ||
| 81 | + if (0 == binding.findPasswordLayout.edtLoginNumber.getText().length()) { | ||
| 82 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 83 | + return; | ||
| 84 | + } else if (0 != binding.findPasswordLayout.edtLoginNumber.getText().length() && 0 == binding.findPasswordLayout.edtVerify.getText().length()) { | ||
| 85 | + ToastUtil.show(getActivity(), "请输入验证码"); | ||
| 86 | + return; | ||
| 87 | + } else if (0 == binding.edtInputPassward.getText().length()) { | ||
| 88 | + ToastUtil.show(getActivity(), "请输入密码"); | ||
| 89 | + return; | ||
| 90 | + } else if (0 == binding.edtConfirmPassward.getText().length()) { | ||
| 91 | + ToastUtil.show(getActivity(), "请再次输入密码"); | ||
| 92 | + return; | ||
| 93 | + } | ||
| 94 | + /** | ||
| 95 | + * 找回密码 | ||
| 96 | + * @param mobile 手机号 | ||
| 97 | + * @param verificationCode 手机验证码 | ||
| 98 | + * @param newPwd 新密码 | ||
| 99 | + * @param callback 回调 | ||
| 100 | + * | ||
| 101 | + */ | ||
| 102 | + if (binding.edtInputPassward.getText().toString().equals(binding.edtConfirmPassward.getText().toString())) { | ||
| 103 | + showDialog(); | ||
| 104 | + UserUtil.modifyPwdWithMob(binding.findPasswordLayout.edtLoginNumber.getText().toString(), binding.findPasswordLayout.edtVerify.getText().toString(), binding.edtConfirmPassward.getText().toString(), userdatacall); | ||
| 105 | + } else { | ||
| 106 | + ToastUtil.show(getActivity(), "亲,您两次输入的密码不一致哦"); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + } else if (i == R.id.get_verify) {//获取验证码 | ||
| 110 | + if (0 == binding.findPasswordLayout.edtLoginNumber.getText().length()) { | ||
| 111 | + ToastUtil.show(getActivity(), "请输入手机号"); | ||
| 112 | + return; | ||
| 113 | + } else if (!SystemTools.isMobileNO(binding.findPasswordLayout.edtLoginNumber.getText().toString())) { | ||
| 114 | + ToastUtil.show(getActivity(), "请输入正确的手机号"); | ||
| 115 | + return; | ||
| 116 | + } | ||
| 117 | + /** | ||
| 118 | + * 找回或修改密码前发手机验证码 | ||
| 119 | + * | ||
| 120 | + * @param type | ||
| 121 | + * @param mobile 手机号 | ||
| 122 | + * @param callback 回调 | ||
| 123 | + * | ||
| 124 | + * 发送手机验证码需要传入一个type值用来区分发送的验证码是用来做什么的 | ||
| 125 | + * QUICK_LOGIN--->快捷登陆前发送手机验证码 | ||
| 126 | + * REGISTER_OR_MODIFY_MOBILE---> 注册或修改手机号前发手机验证码 | ||
| 127 | + * RETRIEVE_OR_MODIFY_PASSWORD---> 找回或修改密码前发手机验证码 | ||
| 128 | + */ | ||
| 129 | + //调用sdk的发送短信验证码的方法 | ||
| 130 | + UserUtil.sendMessage(IUserService.RETRIEVE_OR_MODIFY_PASSWORD, binding.findPasswordLayout.edtLoginNumber.getText().toString(), mobilecall); | ||
| 131 | + //初始化倒计时 | ||
| 132 | + mDownTimer = new DownTimer(); | ||
| 133 | + //开始倒计时 | ||
| 134 | + startTimer(ShowTimeUtil.mSetTotalTime); | ||
| 135 | + | ||
| 136 | + } else if (i == R.id.back_selector) {//返回上一页面 | ||
| 137 | + getFragmentManager().popBackStack(); | ||
| 138 | + | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 发送短信验证码的回调 | ||
| 144 | + */ | ||
| 145 | + protected MobileCall mobilecall = new MobileCall(); | ||
| 146 | + private class MobileCall implements Callback { | ||
| 147 | + @Override | ||
| 148 | + public void onState(int what, String extra, Object obj) { | ||
| 149 | + switch (what){ | ||
| 150 | + case IUserService.SUCCESS: | ||
| 151 | + ToastUtil.show(getActivity(), "验证码已发送"); | ||
| 152 | + break; | ||
| 153 | + case IUserService.ERROR_PARAM: | ||
| 154 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 155 | + break; | ||
| 156 | + case IUserService.ERROR_MOBILE: | ||
| 157 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile); | ||
| 158 | + break; | ||
| 159 | + case IUserService.ERROR_CLIENT_PLAT: | ||
| 160 | + ToastUtil.show(getActivity(), IUserService.message_error_client_plat); | ||
| 161 | + break; | ||
| 162 | + case IUserService.ERROR_MOBILE_NOT_REGISTER: | ||
| 163 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile_not_register); | ||
| 164 | + break; | ||
| 165 | + case IUserService.ERROR_MESSAGE_SERVER: | ||
| 166 | + ToastUtil.show(getActivity(), IUserService.message_error_server); | ||
| 167 | + break; | ||
| 168 | + case IUserService.ERROR_MESSAGE_SERVER_ANALYSIS: | ||
| 169 | + ToastUtil.show(getActivity(), IUserService.message_error_message_server_analysis); | ||
| 170 | + break; | ||
| 171 | + case IUserService.ERROR_OTHER: | ||
| 172 | + ToastUtil.show(getActivity(), IUserService.message_error_other); | ||
| 173 | + break; | ||
| 174 | + case IUserService.ERROR_SEND_MESSAGE_TO_MUCH: | ||
| 175 | + ToastUtil.show(getActivity(), IUserService.message_error_send_message_to_much); | ||
| 176 | + break; | ||
| 177 | + case IUserService.ERROR_SEND_MESSAGE_FAILED: | ||
| 178 | + ToastUtil.show(getActivity(), IUserService.message_error_send_message_failed); | ||
| 179 | + break; | ||
| 180 | + case IUserService.ERROR_MESSAGE_OTHER: | ||
| 181 | + ToastUtil.show(getActivity(), IUserService.message_error_message_other); | ||
| 182 | + break; | ||
| 183 | + } | ||
| 184 | + if (what != 0) { | ||
| 185 | + //获取验证码按钮取消倒计时 | ||
| 186 | + mDownTimer.cancel(); | ||
| 187 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 188 | + binding.findPasswordLayout.getVerify.setText("获取验证码"); | ||
| 189 | + //将获取验证码按钮设置为可点击 | ||
| 190 | + binding.findPasswordLayout.getVerify.setEnabled(true); | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * 找回密码的回调 | ||
| 197 | + */ | ||
| 198 | + protected UserDataCall userdatacall = new UserDataCall(); | ||
| 199 | + private class UserDataCall implements Callback { | ||
| 200 | + @Override | ||
| 201 | + public void onState(int what, String extra, Object obj) { | ||
| 202 | + switch (what) { | ||
| 203 | + case IUserService.SUCCESS: | ||
| 204 | + ToastUtil.show(getActivity(), "找回密码成功"); | ||
| 205 | + getFragmentManager().popBackStack(); | ||
| 206 | + break; | ||
| 207 | + case IUserService.ERROR_PARAM: | ||
| 208 | + ToastUtil.show(getActivity(), IUserService.message_error_param); | ||
| 209 | + break; | ||
| 210 | + case IUserService.ERROR_MOBILE: | ||
| 211 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile); | ||
| 212 | + break; | ||
| 213 | + case IUserService.ERROR_VERIFICATION_CODE_LENGTH: | ||
| 214 | + ToastUtil.show(getActivity(), IUserService.message_error_verfication_code_length); | ||
| 215 | + break; | ||
| 216 | + case IUserService.ERROR_PASSWORD_CONTENT: | ||
| 217 | + ToastUtil.show(getActivity(), IUserService.message_error_password_content); | ||
| 218 | + break; | ||
| 219 | + case IUserService.ERROR_PASSWORD_EQUAL_USERNAME: | ||
| 220 | + ToastUtil.show(getActivity(), IUserService.message_error_password_equal_username); | ||
| 221 | + break; | ||
| 222 | + case IUserService.ERROR_PASSWORD_CANNOT_CONTIGUOUS: | ||
| 223 | + ToastUtil.show(getActivity(), IUserService.message_error_password_cannot_be_contiguous); | ||
| 224 | + break; | ||
| 225 | + case IUserService.ERROR_PASSWORD_CANNOT_CONTIGUOUS_SAME: | ||
| 226 | + ToastUtil.show(getActivity(), IUserService.message_error_password_cannot_be_contiguous_same); | ||
| 227 | + break; | ||
| 228 | + case IUserService.ERROR_VERIFICATION_CODE: | ||
| 229 | + ToastUtil.show(getActivity(), IUserService.message_error_verfication_code); | ||
| 230 | + break; | ||
| 231 | + case IUserService.ERROR_MOBILE_NOT_REGISTER: | ||
| 232 | + ToastUtil.show(getActivity(), IUserService.message_error_mobile_not_register); | ||
| 233 | + break; | ||
| 234 | + case IUserService.ERROR_OTHER: | ||
| 235 | + ToastUtil.show(getActivity(), IUserService.message_error_other); | ||
| 236 | + break; | ||
| 237 | + } | ||
| 238 | + if (what!=0) { | ||
| 239 | + //获取验证码按钮取消倒计时 | ||
| 240 | + mDownTimer.cancel(); | ||
| 241 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 242 | + binding.findPasswordLayout.getVerify.setText("获取验证码"); | ||
| 243 | + //将获取验证码按钮设置为可点击 | ||
| 244 | + binding.findPasswordLayout.getVerify.setEnabled(true); | ||
| 245 | + } | ||
| 246 | + closeDialog(); | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * 显示对话框 | ||
| 252 | + */ | ||
| 253 | + public void showDialog() { | ||
| 254 | + if (dialog == null) { | ||
| 255 | + dialog = new ProgressDialog(getActivity()); | ||
| 256 | + dialog.setMessage("正在提交,请稍等!"); | ||
| 257 | + } | ||
| 258 | + if (!dialog.isShowing()) { | ||
| 259 | + dialog.show(); | ||
| 260 | + } | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + /** | ||
| 264 | + * 关闭对话框 | ||
| 265 | + */ | ||
| 266 | + public void closeDialog() { | ||
| 267 | + if (dialog != null && dialog.isShowing()) { | ||
| 268 | + dialog.dismiss(); | ||
| 269 | + } | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + /** | ||
| 273 | + * 开始倒计时 | ||
| 274 | + * | ||
| 275 | + * @param totalTime 剩余时长 | ||
| 276 | + */ | ||
| 277 | + private void startTimer(long totalTime) { | ||
| 278 | + mDownTimer.cancel();//获取验证码按钮取消倒计时 | ||
| 279 | + mDownTimer.setTotalTime(totalTime);//设置毫秒数 | ||
| 280 | + mDownTimer.setIntervalTime(1000);//设置间隔数 | ||
| 281 | + mDownTimer.setTimerLiener(new DownTimer.TimeListener() { | ||
| 282 | + @Override | ||
| 283 | + public void onFinish() { | ||
| 284 | + //将获取验证码按钮的字样设置为"获取验证码" | ||
| 285 | + binding.findPasswordLayout.getVerify.setText("获取验证码"); | ||
| 286 | + //将获取验证码按钮设置为可点击 | ||
| 287 | + binding.findPasswordLayout.getVerify.setEnabled(true); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + @Override | ||
| 291 | + public void onInterval(long remainTime) { | ||
| 292 | + showTimer= ShowTimeUtil.changeTimerFormat(remainTime); | ||
| 293 | + //将获取验证码按钮的字样设置为显示时间 | ||
| 294 | + binding.findPasswordLayout.getVerify.setText(showTimer); | ||
| 295 | + //将获取验证码按钮设置为不可点击 | ||
| 296 | + binding.findPasswordLayout.getVerify.setEnabled(false); | ||
| 297 | + } | ||
| 298 | + }); | ||
| 299 | + //获取验证码按钮开始倒计时 | ||
| 300 | + mDownTimer.start(); | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | +} | ||
| 0 | \ No newline at end of file | 304 | \ No newline at end of file |
app/src/main/java/com/cnlive/gundam/user/model/ActiveInfo.java
0 → 100644
| 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
0 → 100644
| 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/model/Title.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by luxiaoman on 2017/5/27. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +public class Title { | ||
| 8 | + private String title; | ||
| 9 | + | ||
| 10 | + public Title() { | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + public Title(String title) { | ||
| 14 | + this.title = title; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public String getTitle() { | ||
| 18 | + return title; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public void setTitle(String title) { | ||
| 22 | + this.title = title; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String toString() { | ||
| 27 | + return "Title{" + | ||
| 28 | + "title='" + title + '\'' + | ||
| 29 | + '}'; | ||
| 30 | + } | ||
| 31 | +} |
app/src/main/java/com/cnlive/gundam/user/model/User.java
0 → 100644
| 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 | +public class User extends ErrorMessage implements Serializable { | ||
| 9 | + public static final String ACCOUNT_TYPE="com.cnlive.libs.AccountType"; | ||
| 10 | + | ||
| 11 | + /** | ||
| 12 | + * uid : 201601211717200000000000002308 | ||
| 13 | + * nickname : abc123 | ||
| 14 | + * nickname : | ||
| 15 | + * gender : 0 | ||
| 16 | + * mobile : | ||
| 17 | + * faceurl : | ||
| 18 | + * email : | ||
| 19 | + * location: | ||
| 20 | + */ | ||
| 21 | + private int uid; | ||
| 22 | + private String nickname; | ||
| 23 | + private String gender; | ||
| 24 | + private String mobile; | ||
| 25 | + private String faceurl; | ||
| 26 | + private String email; | ||
| 27 | + private String location; | ||
| 28 | + | ||
| 29 | + /*用户token*/ | ||
| 30 | + private String token; | ||
| 31 | + | ||
| 32 | + public String getToken() { | ||
| 33 | + return token; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public void setToken(String token) { | ||
| 37 | + this.token = token; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public int getUid() { | ||
| 41 | + return uid; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public void setUid(int uid) { | ||
| 45 | + this.uid = uid; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public String getNickname() { | ||
| 49 | + return nickname; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public String getGender() { | ||
| 53 | + return gender; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public void setGender(String gender) { | ||
| 57 | + this.gender = gender; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setNickname(String nickname) { | ||
| 61 | + this.nickname = nickname; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public String getMobile() { | ||
| 65 | + return mobile; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setMobile(String mobile) { | ||
| 69 | + this.mobile = mobile; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public String getFaceurl() { | ||
| 73 | + return faceurl; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setFaceurl(String faceurl) { | ||
| 77 | + this.faceurl = faceurl; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public String getEmail() { | ||
| 81 | + return email; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public void setEmail(String email) { | ||
| 85 | + this.email = email; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public String getLocation() { | ||
| 89 | + return location; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public void setLocation(String location) { | ||
| 93 | + this.location = location; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + @Override | ||
| 97 | + public String toString() { | ||
| 98 | + return "User{" + | ||
| 99 | + "uid='" + uid + '\'' + | ||
| 100 | + ", nickname='" + nickname + '\'' + | ||
| 101 | + ", gender='" + gender + '\'' + | ||
| 102 | + ", mobile='" + mobile + '\'' + | ||
| 103 | + ", faceurl='" + faceurl + '\'' + | ||
| 104 | + ", token='" + token + '\'' + | ||
| 105 | + ", email='" + email + '\'' + | ||
| 106 | + ", location='" + location + '\'' + | ||
| 107 | + '}'; | ||
| 108 | + } | ||
| 109 | +} |
app/src/main/java/com/cnlive/gundam/user/model/UserContent.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.model; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by luxiaoman on 2017/2/24. | ||
| 5 | + */ | ||
| 6 | +public class UserContent { | ||
| 7 | + | ||
| 8 | + public final static int HEADER = 0; //header类型的条目 | ||
| 9 | + public final static int ITEM = 1; //item类型的条目 | ||
| 10 | + public final static int ITEM_NOTIFICATION = 2; //item类型中通知列表的条目 | ||
| 11 | + public final static int ITEM_CACHE = 3; //item类型中清除缓存的条目 | ||
| 12 | + public final static int ITEM_PERSONAL_HEADER = 4; //item类型中个人资料中头像类型的条目 | ||
| 13 | + public final static int ITEM_PERSONAL = 5; //item类型中个人资料中除编辑类型的条目 | ||
| 14 | + public final static int BOTTOM = 6; //item类型中个人资料中注销类型的条目 | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + private String itemLetter; | ||
| 18 | + private int itemType; | ||
| 19 | + private String itemName; | ||
| 20 | + private String itemContent; | ||
| 21 | + private int itemIcon; | ||
| 22 | + | ||
| 23 | + public String getItemLetter() { | ||
| 24 | + return itemLetter; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void setItemLetter(String itemLetter) { | ||
| 28 | + this.itemLetter = itemLetter; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public int getItemType() { | ||
| 32 | + return itemType; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setItemType(int itemType) { | ||
| 36 | + this.itemType = itemType; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public String getItemName() { | ||
| 40 | + return itemName; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public void setItemName(String itemName) { | ||
| 44 | + this.itemName = itemName; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public String getItemContent() { | ||
| 48 | + return itemContent; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public void setItemContent(String itemContent) { | ||
| 52 | + this.itemContent = itemContent; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public int getItemIcon() { | ||
| 56 | + return itemIcon; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setItemIcon(int itemIcon) { | ||
| 60 | + this.itemIcon = itemIcon; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + public UserContent(String itemLetter, int itemType, String itemName, String itemContent, int itemIcon) { | ||
| 65 | + this.itemLetter = itemLetter; | ||
| 66 | + this.itemType = itemType; | ||
| 67 | + this.itemName = itemName; | ||
| 68 | + this.itemContent = itemContent; | ||
| 69 | + this.itemIcon = itemIcon; | ||
| 70 | + } | ||
| 71 | +} |
app/src/main/java/com/cnlive/gundam/user/model/base/CNUserCall.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.model.base; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.util.Log; | ||
| 5 | +import android.widget.Toast; | ||
| 6 | + | ||
| 7 | +import com.cnlive.libs.user.IUserService; | ||
| 8 | +import com.cnlive.libs.util.data.network.Callback; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by luxiaoman on 2017/2/14. | ||
| 12 | + * 处理错误信息 | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | +public abstract class CNUserCall implements Callback { | ||
| 16 | + private String TAG = "CinemaOnlineCall"; | ||
| 17 | + Context applicationContext = null; | ||
| 18 | + | ||
| 19 | + protected abstract void dowork(int what, String extra, Object obj); | ||
| 20 | + | ||
| 21 | + protected abstract void onError(int what, String extra, Object obj); | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public void onState(int what, String extra, Object obj) { | ||
| 25 | + /*if (null == applicationContext) { | ||
| 26 | + applicationContext = CNLiveApplication.sInstance.getApplicationContext(); | ||
| 27 | + }*/ | ||
| 28 | + switch (what) { | ||
| 29 | + case IUserService.ERROR_NETWORK: | ||
| 30 | + //网络连接失败 | ||
| 31 | + Toast.makeText(applicationContext, "网络连接失败", Toast.LENGTH_SHORT).show(); | ||
| 32 | + break; | ||
| 33 | + case IUserService.ERROR_SERVER: | ||
| 34 | + //内部错误 | ||
| 35 | + Toast.makeText(applicationContext, "内部错误", Toast.LENGTH_SHORT).show(); | ||
| 36 | + break; | ||
| 37 | + case IUserService.ERROR_THIRD_PLAT_ID: | ||
| 38 | + //第三方平台编号无效 | ||
| 39 | + Log.e(TAG, IUserService.message_error_third_plat_id); | ||
| 40 | + Toast.makeText(applicationContext, "第三方平台编号无效", Toast.LENGTH_SHORT).show(); | ||
| 41 | + break; | ||
| 42 | + case IUserService.ERROR_CLIENT_PLAT: | ||
| 43 | + //ClientPlat无效 | ||
| 44 | + Toast.makeText(applicationContext, "ClientPlat无效", Toast.LENGTH_SHORT).show(); | ||
| 45 | + Log.e(TAG, IUserService.message_error_client_plat); | ||
| 46 | + break; | ||
| 47 | + case IUserService.ERROR_GENDER: | ||
| 48 | + //性别无效 | ||
| 49 | + Toast.makeText(applicationContext, "性别无效", Toast.LENGTH_SHORT).show(); | ||
| 50 | + Log.e(TAG, IUserService.message_error_gender); | ||
| 51 | + break; | ||
| 52 | + case IUserService.ERROR_ADDRESS: | ||
| 53 | + //地址不能超过120个汉字 | ||
| 54 | + Toast.makeText(applicationContext, "地址不能超过120个汉字", Toast.LENGTH_SHORT).show(); | ||
| 55 | + Log.e(TAG, IUserService.message_error_address); | ||
| 56 | + break; | ||
| 57 | + case IUserService.ERROR_FACE_URL: | ||
| 58 | + //头像不能超过255位 | ||
| 59 | + Toast.makeText(applicationContext, "头像不能超过255位", Toast.LENGTH_SHORT).show(); | ||
| 60 | + Log.e(TAG, IUserService.message_error_face_url); | ||
| 61 | + break; | ||
| 62 | + case IUserService.ERROR_NICK_NAME_EXIST: | ||
| 63 | + //该昵称已存在 | ||
| 64 | + Toast.makeText(applicationContext, "该昵称已存在", Toast.LENGTH_SHORT).show(); | ||
| 65 | + Log.e(TAG, IUserService.message_error_nick_name_exist); | ||
| 66 | + break; | ||
| 67 | + case IUserService.ERROR_OTHER: | ||
| 68 | + //其他错误 | ||
| 69 | + Toast.makeText(applicationContext, "其他错误", Toast.LENGTH_SHORT).show(); | ||
| 70 | + Log.e(TAG, IUserService.message_error_other); | ||
| 71 | + break; | ||
| 72 | + case IUserService.ERROR_MOBILE: | ||
| 73 | + //手机号无效 | ||
| 74 | + Toast.makeText(applicationContext, "手机号无效", Toast.LENGTH_SHORT).show(); | ||
| 75 | + | ||
| 76 | + Log.e(TAG, IUserService.message_error_mobile); | ||
| 77 | + break; | ||
| 78 | + case IUserService.ERROR_MESSAGE_SERVER: | ||
| 79 | + //短信服务异常 | ||
| 80 | + Toast.makeText(applicationContext, "短信服务异常", Toast.LENGTH_SHORT).show(); | ||
| 81 | + | ||
| 82 | + Log.e(TAG, IUserService.message_error_message_server); | ||
| 83 | + break; | ||
| 84 | + case IUserService.ERROR_MESSAGE_SERVER_ANALYSIS: | ||
| 85 | + //短信服务解析异常 | ||
| 86 | + Toast.makeText(applicationContext, "短信服务解析异常", Toast.LENGTH_SHORT).show(); | ||
| 87 | + Log.e(TAG, IUserService.message_error_message_server_analysis); | ||
| 88 | + break; | ||
| 89 | + case IUserService.ERROR_SEND_MESSAGE_TO_MUCH: | ||
| 90 | + //短信发送次数过多 | ||
| 91 | + Toast.makeText(applicationContext, "短信发送次数过多", Toast.LENGTH_SHORT).show(); | ||
| 92 | + | ||
| 93 | + Log.e(TAG, IUserService.message_error_send_message_to_much); | ||
| 94 | + break; | ||
| 95 | + case IUserService.ERROR_SEND_MESSAGE_FAILED: | ||
| 96 | + //短信发送失败 | ||
| 97 | + Toast.makeText(applicationContext, "短信发送失败", Toast.LENGTH_SHORT).show(); | ||
| 98 | + | ||
| 99 | + Log.e(TAG, IUserService.message_error_send_message_failed); | ||
| 100 | + break; | ||
| 101 | + case IUserService.ERROR_MESSAGE_OTHER: | ||
| 102 | + //消息其他错误 | ||
| 103 | + Toast.makeText(applicationContext, "消息其他错误", Toast.LENGTH_SHORT).show(); | ||
| 104 | + | ||
| 105 | + Log.e(TAG, IUserService.message_error_message_other); | ||
| 106 | + break; | ||
| 107 | + case IUserService.ERROR_VERIFICATION_CODE_LENGTH: | ||
| 108 | + //验证码为6位数字 | ||
| 109 | + Toast.makeText(applicationContext, "验证码为6位数字", Toast.LENGTH_SHORT).show(); | ||
| 110 | + | ||
| 111 | + Log.e(TAG, IUserService.message_error_verfication_code_length); | ||
| 112 | + break; | ||
| 113 | + case IUserService.ERROR_VERIFICATION_CODE: | ||
| 114 | + //验证码错误 | ||
| 115 | + Toast.makeText(applicationContext, "验证码错误", Toast.LENGTH_SHORT).show(); | ||
| 116 | + Log.e(TAG, IUserService.message_error_verfication_code); | ||
| 117 | + break; | ||
| 118 | + case IUserService.ERROR_MOBILE_EXIST: | ||
| 119 | + //手机号已存在 | ||
| 120 | + Toast.makeText(applicationContext, "手机号已存在", Toast.LENGTH_SHORT).show(); | ||
| 121 | + | ||
| 122 | + Log.e(TAG, IUserService.message_error_mobile_exist); | ||
| 123 | + break; | ||
| 124 | + case IUserService.ERROR_USER_NAME: | ||
| 125 | + //用户名为手机或或邮箱 | ||
| 126 | + Toast.makeText(applicationContext, "用户名为手机或或邮箱", Toast.LENGTH_SHORT).show(); | ||
| 127 | + | ||
| 128 | + Log.e(TAG, IUserService.message_error_user_name); | ||
| 129 | + break; | ||
| 130 | + case IUserService.ERROR_MAIL: | ||
| 131 | + //邮箱不能超过50位 | ||
| 132 | + Toast.makeText(applicationContext, "邮箱不能超过50位", Toast.LENGTH_SHORT).show(); | ||
| 133 | + Log.e(TAG, IUserService.message_error_mail); | ||
| 134 | + break; | ||
| 135 | + case IUserService.ERROR_PASSWORD_CONTENT: | ||
| 136 | + //密码为6-20位字母或数字 | ||
| 137 | + Toast.makeText(applicationContext, "6-20位字母或数字", Toast.LENGTH_SHORT).show(); | ||
| 138 | + Log.e(TAG, IUserService.message_error_password_content); | ||
| 139 | + break; | ||
| 140 | + case IUserService.ERROR_MAIL_EXIST: | ||
| 141 | + //该邮箱已存在 | ||
| 142 | + Toast.makeText(applicationContext, "该邮箱已存在", Toast.LENGTH_SHORT).show(); | ||
| 143 | + Log.e(TAG, IUserService.message_error_mail_exist); | ||
| 144 | + break; | ||
| 145 | + case IUserService.ERROR_USER_NOT_FOUND: | ||
| 146 | + //未发现此用户 | ||
| 147 | + Toast.makeText(applicationContext, "未发现此用户", Toast.LENGTH_SHORT).show(); | ||
| 148 | + Log.e(TAG, IUserService.message_error_user_not_found); | ||
| 149 | + break; | ||
| 150 | + case IUserService.ERROR_USERNAME_OR_PASSWORD: | ||
| 151 | + //用户名或密码错误 | ||
| 152 | + Toast.makeText(applicationContext, "用户名或密码错误", Toast.LENGTH_SHORT).show(); | ||
| 153 | + Log.e(TAG, IUserService.message_error_username_or_password); | ||
| 154 | + break; | ||
| 155 | + case IUserService.ERROR_PASSWORD: | ||
| 156 | + //密码错误 | ||
| 157 | + Toast.makeText(applicationContext, "密码错误", Toast.LENGTH_SHORT).show(); | ||
| 158 | + Log.e(TAG, IUserService.message_error_password); | ||
| 159 | + break; | ||
| 160 | + case IUserService.ERROR_MOBILE_NOT_REGISTER: | ||
| 161 | + //该手机号未注册 | ||
| 162 | + Toast.makeText(applicationContext, "该手机号未注册", Toast.LENGTH_SHORT).show(); | ||
| 163 | + Log.e(TAG, IUserService.message_error_mobile_not_register); | ||
| 164 | + break; | ||
| 165 | + case IUserService.ERROR_TOKEN_INVALID: | ||
| 166 | + //token已失效 | ||
| 167 | + Toast.makeText(applicationContext, "token已失效", Toast.LENGTH_SHORT).show(); | ||
| 168 | + Log.e(TAG, IUserService.message_error_token_invalid); | ||
| 169 | + break; | ||
| 170 | + case IUserService.ERROR_TOKEN_CHECKING: | ||
| 171 | + //token验证失败 | ||
| 172 | + Toast.makeText(applicationContext, "token验证失败", Toast.LENGTH_SHORT).show(); | ||
| 173 | + Log.e(TAG, IUserService.message_error_token_checking); | ||
| 174 | + break; | ||
| 175 | + case IUserService.ERROR_OPERATE: | ||
| 176 | + //操作失败 | ||
| 177 | + Toast.makeText(applicationContext, "操作失败", Toast.LENGTH_SHORT).show(); | ||
| 178 | + Log.e(TAG, IUserService.message_error_operate); | ||
| 179 | + break; | ||
| 180 | + case IUserService.ERROR_CHANGE_NICKNAME_FAILED: | ||
| 181 | + //昵称更改失败 | ||
| 182 | + Toast.makeText(applicationContext, "昵称更改失败", Toast.LENGTH_SHORT).show(); | ||
| 183 | + Log.e(TAG, IUserService.message_error_change_nickname_failed); | ||
| 184 | + break; | ||
| 185 | + case IUserService.ERROR_UPLOAD_FILE_FAILED: | ||
| 186 | + //文件上传失败 | ||
| 187 | + Toast.makeText(applicationContext, "文件上传失败", Toast.LENGTH_SHORT).show(); | ||
| 188 | + Log.e(TAG, IUserService.message_error_upload_file_failed); | ||
| 189 | + break; | ||
| 190 | + case IUserService.ERROR_UPDATE_FACE: | ||
| 191 | + //头像更新失败 | ||
| 192 | + Toast.makeText(applicationContext, "头像更新失败", Toast.LENGTH_SHORT).show(); | ||
| 193 | + Log.e(TAG, IUserService.message_error_update_face); | ||
| 194 | + break; | ||
| 195 | + case IUserService.ERROR_NOT_FOUND_RECORD: | ||
| 196 | + //未发现记录 | ||
| 197 | + Toast.makeText(applicationContext, "未发现记录", Toast.LENGTH_SHORT).show(); | ||
| 198 | + Log.e(TAG, IUserService.message_error_not_found_record); | ||
| 199 | + break; | ||
| 200 | + case IUserService.ERROR_NICK_NAME_LENGTH: | ||
| 201 | + //昵称不能超过15个汉字 | ||
| 202 | + Toast.makeText(applicationContext, "昵称不能超过15个汉字", Toast.LENGTH_SHORT).show(); | ||
| 203 | + Log.e(TAG, IUserService.message_error_nick_name_length); | ||
| 204 | + break; | ||
| 205 | + case IUserService.ERROR_MAIL_FORMAT: | ||
| 206 | + //邮箱格式错误 | ||
| 207 | + Toast.makeText(applicationContext, "邮箱格式错误", Toast.LENGTH_SHORT).show(); | ||
| 208 | + Log.e(TAG, IUserService.message_error_mail_format); | ||
| 209 | + break; | ||
| 210 | + case IUserService.ERROR_CHANGE_USERNAME_FAILED: | ||
| 211 | + //用户名更改失败 | ||
| 212 | + Toast.makeText(applicationContext, "用户名更改失败", Toast.LENGTH_SHORT).show(); | ||
| 213 | + Log.e(TAG, IUserService.message_error_change_username_failed); | ||
| 214 | + break; | ||
| 215 | + case IUserService.ERROR_TYPE_INVALID: | ||
| 216 | + //type无效 | ||
| 217 | + Toast.makeText(applicationContext, "type无效", Toast.LENGTH_SHORT).show(); | ||
| 218 | + Log.e(TAG, IUserService.message_error_type_invalid); | ||
| 219 | + break; | ||
| 220 | + case IUserService.ERROR_FEEDBACK_INSERT_FAILED: | ||
| 221 | + //用户反馈插入失败 | ||
| 222 | + Toast.makeText(applicationContext, "用户反馈插入失败", Toast.LENGTH_SHORT).show(); | ||
| 223 | + Log.e(TAG, IUserService.message_feedback_insert_failed); | ||
| 224 | + break; | ||
| 225 | + case IUserService.ERROR_FEEDBACK_LENGTH: | ||
| 226 | + //内容请控制在1200个字以内 | ||
| 227 | + Toast.makeText(applicationContext, "内容请控制在1200个字以内", Toast.LENGTH_SHORT).show(); | ||
| 228 | + Log.e(TAG, IUserService.message_feedback_length); | ||
| 229 | + break; | ||
| 230 | + case IUserService.ERROR_THIRDPLAT_BINDED: | ||
| 231 | + //第三方账号已绑定,不允许重复绑定 | ||
| 232 | + Toast.makeText(applicationContext, "第三方账号已绑定,不允许重复绑定", Toast.LENGTH_SHORT).show(); | ||
| 233 | + Log.e(TAG, IUserService.message_error_thirdplat_binded); | ||
| 234 | + break; | ||
| 235 | + case IUserService.ERROR_BIND_FAILED: | ||
| 236 | + //第三方账号绑定失败 | ||
| 237 | + Toast.makeText(applicationContext, "第三方账号绑定失败", Toast.LENGTH_SHORT).show(); | ||
| 238 | + Log.e(TAG, IUserService.message_error_bind_failed); | ||
| 239 | + break; | ||
| 240 | + case IUserService.SUCCESS: | ||
| 241 | + //成功 | ||
| 242 | + dowork(what, extra, obj); | ||
| 243 | + break; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + if(what !=0 ) onError(what, extra, obj); | ||
| 247 | + | ||
| 248 | + } | ||
| 249 | +} |
app/src/main/java/com/cnlive/gundam/user/model/base/ErrorMessage.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.model.base; | ||
| 2 | + | ||
| 3 | +import java.io.Serializable; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +public class ErrorMessage implements Serializable { | ||
| 7 | + | ||
| 8 | + private String errorCode = "0"; | ||
| 9 | + private String errorMessage = ""; | ||
| 10 | + | ||
| 11 | + public String getErrorCode() { | ||
| 12 | + return errorCode; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + public void setErrorCode(String errorCode) { | ||
| 16 | + this.errorCode = errorCode; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public String getErrorMessage() { | ||
| 20 | + return errorMessage; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setErrorMessage(String errorMessage) { | ||
| 24 | + this.errorMessage = errorMessage; | ||
| 25 | + } | ||
| 26 | +} |
app/src/main/java/com/cnlive/gundam/user/util/DataCleanManager.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.os.Environment; | ||
| 5 | + | ||
| 6 | +import java.io.File; | ||
| 7 | +import java.math.BigDecimal; | ||
| 8 | + | ||
| 9 | +public class DataCleanManager { | ||
| 10 | + | ||
| 11 | + public static String getTotalCacheSize(Context context) throws Exception { | ||
| 12 | + long cacheSize = getFolderSize(context.getCacheDir()); | ||
| 13 | + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { | ||
| 14 | + cacheSize += getFolderSize(context.getExternalCacheDir()); | ||
| 15 | + } | ||
| 16 | + return getFormatSize(cacheSize); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + public static void clearAllCache(Context context) { | ||
| 21 | + deleteDir(context.getCacheDir()); | ||
| 22 | + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { | ||
| 23 | + deleteDir(context.getExternalCacheDir()); | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + private static boolean deleteDir(File dir) { | ||
| 28 | + if (dir != null && dir.isDirectory()) { | ||
| 29 | + String[] children = dir.list(); | ||
| 30 | + for (int i = 0; i < children.length; i++) { | ||
| 31 | + boolean success = deleteDir(new File(dir, children[i])); | ||
| 32 | + if (!success) { | ||
| 33 | + return false; | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + return dir.delete(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + // 获取文件 | ||
| 41 | + //Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/ 目录,一般放一些长时间保存的数据 | ||
| 42 | + //Context.getExternalCacheDir() --> SDCard/Android/data/你的应用包名/cache/目录,一般存放临时缓存数据 | ||
| 43 | + public static long getFolderSize(File file) throws Exception { | ||
| 44 | + long size = 0; | ||
| 45 | + try { | ||
| 46 | + File[] fileList = file.listFiles(); | ||
| 47 | + for (int i = 0; i < fileList.length; i++) { | ||
| 48 | + // 如果下面还有文件 | ||
| 49 | + if (fileList[i].isDirectory()) { | ||
| 50 | + size = size + getFolderSize(fileList[i]); | ||
| 51 | + } else { | ||
| 52 | + size = size + fileList[i].length(); | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + } catch (Exception e) { | ||
| 56 | + e.printStackTrace(); | ||
| 57 | + } | ||
| 58 | + return size; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 格式化单位 | ||
| 63 | + * | ||
| 64 | + * @param size | ||
| 65 | + * @return | ||
| 66 | + */ | ||
| 67 | + public static String getFormatSize(double size) { | ||
| 68 | + double kiloByte = size / 1024; | ||
| 69 | + if (kiloByte < 1) { | ||
| 70 | +// return size + "Byte"; | ||
| 71 | + return "0K"; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + double megaByte = kiloByte / 1024; | ||
| 75 | + if (megaByte < 1) { | ||
| 76 | + BigDecimal result1 = new BigDecimal(Double.toString(kiloByte)); | ||
| 77 | + return result1.setScale(2, BigDecimal.ROUND_HALF_UP) | ||
| 78 | + .toPlainString() + "KB"; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + double gigaByte = megaByte / 1024; | ||
| 82 | + if (gigaByte < 1) { | ||
| 83 | + BigDecimal result2 = new BigDecimal(Double.toString(megaByte)); | ||
| 84 | + return result2.setScale(2, BigDecimal.ROUND_HALF_UP) | ||
| 85 | + .toPlainString() + "MB"; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + double teraBytes = gigaByte / 1024; | ||
| 89 | + if (teraBytes < 1) { | ||
| 90 | + BigDecimal result3 = new BigDecimal(Double.toString(gigaByte)); | ||
| 91 | + return result3.setScale(2, BigDecimal.ROUND_HALF_UP) | ||
| 92 | + .toPlainString() + "GB"; | ||
| 93 | + } | ||
| 94 | + BigDecimal result4 = new BigDecimal(teraBytes); | ||
| 95 | + return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() | ||
| 96 | + + "TB"; | ||
| 97 | + } | ||
| 98 | +} |
app/src/main/java/com/cnlive/gundam/user/util/DevilUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.os.IBinder; | ||
| 4 | +import android.view.MotionEvent; | ||
| 5 | +import android.view.View; | ||
| 6 | +import android.view.inputmethod.InputMethodManager; | ||
| 7 | +import android.widget.EditText; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Created by luxiaoman on 2017/2/16. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +public class DevilUtil { | ||
| 14 | + /** | ||
| 15 | + * 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时没必要隐藏 | ||
| 16 | + * | ||
| 17 | + * @param v | ||
| 18 | + * @param event | ||
| 19 | + * @return | ||
| 20 | + */ | ||
| 21 | + public static boolean isShouldHideInput(View v, MotionEvent event){ | ||
| 22 | + if(v !=null&&(v instanceof EditText)){ | ||
| 23 | + int[] l ={0,0}; | ||
| 24 | + v.getLocationInWindow(l); | ||
| 25 | + int left=l[0],top=l[1],bottom=top+v.getHeight(),right=left | ||
| 26 | + +v.getWidth(); | ||
| 27 | + if(event.getX()>left&&event.getX()<right | ||
| 28 | + &&event.getY()>top&&event.getY()<bottom){ | ||
| 29 | + // 点击EditText的事件,忽略它。 | ||
| 30 | + return false; | ||
| 31 | + }else{ | ||
| 32 | + // hideSoftInput(v.getWindowToken()); | ||
| 33 | + return true; | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + // 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditView上,和用户用轨迹球选择其他的焦点 | ||
| 37 | + return false; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 多种隐藏软件盘方法的其中一种 | ||
| 42 | + * | ||
| 43 | + * @param token | ||
| 44 | + */ | ||
| 45 | + public static void hideSoftInput(IBinder token, InputMethodManager im){ | ||
| 46 | + if(token!=null){ | ||
| 47 | + im.hideSoftInputFromWindow(token, | ||
| 48 | + InputMethodManager.HIDE_NOT_ALWAYS); | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | +} |
app/src/main/java/com/cnlive/gundam/user/util/DownTimer.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.os.Handler; | ||
| 4 | +import android.os.Message; | ||
| 5 | +import android.os.SystemClock; | ||
| 6 | + | ||
| 7 | +import java.lang.ref.WeakReference; | ||
| 8 | + | ||
| 9 | +public class DownTimer { | ||
| 10 | + private long totalTime = -1; | ||
| 11 | + private long intervalTime = 0; | ||
| 12 | + private long remainTime; | ||
| 13 | + private long systemAddTotalTime; | ||
| 14 | + private static final int TIME = 1; | ||
| 15 | + private TimeListener listener; | ||
| 16 | + private long curReminTime; | ||
| 17 | + private boolean isPause = false; | ||
| 18 | + | ||
| 19 | + public DownTimer() { | ||
| 20 | + mHandler = new MyHandler(this); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + private static class MyHandler extends Handler { | ||
| 24 | + WeakReference<DownTimer> mActivity; | ||
| 25 | + | ||
| 26 | + MyHandler(DownTimer activity) { | ||
| 27 | + mActivity = new WeakReference<>(activity); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public void handleMessage(Message msg) { | ||
| 32 | + DownTimer theActivity = mActivity.get(); | ||
| 33 | + switch (msg.what) { | ||
| 34 | + case TIME: | ||
| 35 | + if (!theActivity.isPause) | ||
| 36 | + theActivity.soloveTime(); | ||
| 37 | + break; | ||
| 38 | + case 2: | ||
| 39 | + theActivity.isPause = true; | ||
| 40 | + break; | ||
| 41 | + default: | ||
| 42 | + break; | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + public void setIntervalTime(long intervalTime) { | ||
| 49 | + this.intervalTime = intervalTime; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setTotalTime(long totalTime) { | ||
| 53 | + this.totalTime = totalTime; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public long getIntervalTime() { | ||
| 57 | + return intervalTime; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public long getTotalTime() { | ||
| 61 | + return totalTime; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public void start() { | ||
| 65 | + if (totalTime <= 0 && intervalTime <= 0) { | ||
| 66 | + throw new RuntimeException("you must set the totalTime > 0 or intervalTime >0"); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + systemAddTotalTime = SystemClock.elapsedRealtime() + totalTime; | ||
| 70 | + | ||
| 71 | + if (null != mHandler) | ||
| 72 | + mHandler.sendEmptyMessage(TIME); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void cancel() { | ||
| 76 | + if (mHandler != null) { | ||
| 77 | + mHandler.removeMessages(TIME); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void release(){ | ||
| 82 | + if(mHandler != null){ | ||
| 83 | + mHandler.removeMessages(0); | ||
| 84 | + mHandler.removeCallbacks(null); | ||
| 85 | + mHandler = null; | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void pause() { | ||
| 90 | + if (mHandler != null) { | ||
| 91 | + mHandler.removeMessages(TIME); | ||
| 92 | + isPause = true; | ||
| 93 | + curReminTime = remainTime; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void resume() { | ||
| 98 | + if (isPause) { | ||
| 99 | + isPause = false; | ||
| 100 | + totalTime = curReminTime; | ||
| 101 | + start(); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + private MyHandler mHandler; | ||
| 106 | + | ||
| 107 | + | ||
| 108 | + private void soloveTime() { | ||
| 109 | + remainTime = systemAddTotalTime - SystemClock.elapsedRealtime(); | ||
| 110 | + if (remainTime <= 0) { | ||
| 111 | + if (listener != null) { | ||
| 112 | + listener.onFinish(); | ||
| 113 | + cancel(); | ||
| 114 | + } | ||
| 115 | + } else if (remainTime < intervalTime) { | ||
| 116 | + if (null != mHandler) | ||
| 117 | + mHandler.sendEmptyMessageDelayed(TIME, remainTime); | ||
| 118 | + } else { | ||
| 119 | + long curSystemTime = SystemClock.elapsedRealtime(); | ||
| 120 | + if (listener != null) { | ||
| 121 | + listener.onInterval(remainTime); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + long delay = curSystemTime + intervalTime - SystemClock.elapsedRealtime(); | ||
| 125 | + | ||
| 126 | + while (delay < 0) delay += intervalTime; | ||
| 127 | + | ||
| 128 | + if (null != mHandler) { | ||
| 129 | + mHandler.sendEmptyMessageDelayed(TIME, delay); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public interface TimeListener { | ||
| 135 | + public void onFinish(); | ||
| 136 | + | ||
| 137 | + public void onInterval(long remainTime); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public void setTimerLiener(TimeListener listener) { | ||
| 141 | + this.listener = listener; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | +} | ||
| 0 | \ No newline at end of file | 145 | \ No newline at end of file |
app/src/main/java/com/cnlive/gundam/user/util/FileUtils.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.annotation.SuppressLint; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.os.Environment; | ||
| 6 | +import android.os.StatFs; | ||
| 7 | +import android.os.storage.StorageManager; | ||
| 8 | +import android.text.TextUtils; | ||
| 9 | +import android.text.format.Formatter; | ||
| 10 | + | ||
| 11 | +import com.cnlive.libs.util.SharedPreferencesHelper; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +import java.io.File; | ||
| 15 | +import java.io.IOException; | ||
| 16 | +import java.lang.reflect.Array; | ||
| 17 | +import java.lang.reflect.Method; | ||
| 18 | +import java.util.Arrays; | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.HashSet; | ||
| 21 | +import java.util.Locale; | ||
| 22 | +import java.util.Map; | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +public class FileUtils { | ||
| 26 | + // http://www.fileinfo.com/filetypes/video , "dat" , "bin" , "rms" | ||
| 27 | + public static final String[] VIDEO_EXTENSIONS = {"264", "3g2", "3gp", | ||
| 28 | + "3gp2", "3gpp", "3gpp2", "3mm", "3p2", "60d", "aep", "ajp", "amv", | ||
| 29 | + "amx", "arf", "asf", "asx", "avb", "avd", "avi", "avs", "avs", | ||
| 30 | + "axm", "bdm", "bdmv", "bik", "bix", "bmk", "box", "bs4", "bsf", | ||
| 31 | + "byu", "camre", "clpi", "cpi", "cvc", "d2v", "d3v", "dav", "dce", | ||
| 32 | + "dck", "ddat", "dif", "dir", "divx", "dlx", "dmb", "dmsm", "dmss", | ||
| 33 | + "dnc", "dpg", "dream", "dsy", "dv", "dv-avi", "dv4", "dvdmedia", | ||
| 34 | + "dvr-ms", "dvx", "dxr", "dzm", "dzp", "dzt", "evo", "eye", "f4p", | ||
| 35 | + "f4v", "fbr", "fbr", "fbz", "fcp", "flc", "flh", "fli", "flv", | ||
| 36 | + "flx", "gl", "grasp", "gts", "gvi", "gvp", "hdmov", "hkm", "ifo", | ||
| 37 | + "imovi", "imovi", "iva", "ivf", "ivr", "ivs", "izz", "izzy", "jts", | ||
| 38 | + "lsf", "lsx", "m15", "m1pg", "m1v", "m21", "m21", "m2a", "m2p", | ||
| 39 | + "m2t", "m2ts", "m2v", "m4e", "m4u", "m4v", "m75", "meta", "mgv", | ||
| 40 | + "mj2", "mjp", "mjpg", "mkv", "mmv", "mnv", "mod", "modd", "moff", | ||
| 41 | + "moi", "moov", "mov", "movie", "mp21", "mp21", "mp2v", "mp4", | ||
| 42 | + "mp4v", "mpe", "mpeg", "mpeg4", "mpf", "mpg", "mpg2", "mpgin", | ||
| 43 | + "mpl", "mpls", "mpv", "mpv2", "mqv", "msdvd", "msh", "mswmm", | ||
| 44 | + "mts", "mtv", "mvb", "mvc", "mvd", "mve", "mvp", "mxf", "mys", | ||
| 45 | + "ncor", "nsv", "nvc", "ogm", "ogv", "ogx", "osp", "par", "pds", | ||
| 46 | + "pgi", "piv", "playlist", "pmf", "prel", "pro", "prproj", "psh", | ||
| 47 | + "pva", "pvr", "pxv", "qt", "qtch", "qtl", "qtm", "qtz", | ||
| 48 | + "rcproject", "rdb", "rec", "rm", "rmd", "rmp", "rmvb", "roq", "rp", | ||
| 49 | + "rts", "rts", "rum", "rv", "sbk", "sbt", "scm", "scm", "scn", | ||
| 50 | + "sec", "seq", "sfvidcap", "smil", "smk", "sml", "smv", "spl", | ||
| 51 | + "ssm", "str", "stx", "svi", "swf", "swi", "swt", "tda3mt", "tivo", | ||
| 52 | + "tix", "tod", "tp", "tp0", "tpd", "tpr", "trp", "ts", "tvs", "vc1", | ||
| 53 | + "vcr", "vcv", "vdo", "vdr", "veg", "vem", "vf", "vfw", "vfz", | ||
| 54 | + "vgz", "vid", "viewlet", "viv", "vivo", "vlab", "vob", "vp3", | ||
| 55 | + "vp6", "vp7", "vpj", "vro", "vsp", "w32", "wcp", "webm", "wm", | ||
| 56 | + "wmd", "wmmp", "wmv", "wmx", "wp3", "wpl", "wtv", "wvx", "xfl", | ||
| 57 | + "xvid", "yuv", "zm1", "zm2", "zm3", "zmv"}; | ||
| 58 | + // http://www.fileinfo.com/filetypes/audio , "spx" , "mid" , "sf" | ||
| 59 | + public static final String[] AUDIO_EXTENSIONS = {"4mp", "669", "6cm", | ||
| 60 | + "8cm", "8med", "8svx", "a2m", "aa", "aa3", "aac", "aax", "abc", | ||
| 61 | + "abm", "ac3", "acd", "acd-bak", "acd-zip", "acm", "act", "adg", | ||
| 62 | + "afc", "agm", "ahx", "aif", "aifc", "aiff", "ais", "akp", "al", | ||
| 63 | + "alaw", "all", "amf", "amr", "ams", "ams", "aob", "ape", "apf", | ||
| 64 | + "apl", "ase", "at3", "atrac", "au", "aud", "aup", "avr", "awb", | ||
| 65 | + "band", "bap", "bdd", "box", "bun", "bwf", "c01", "caf", "cda", | ||
| 66 | + "cdda", "cdr", "cel", "cfa", "cidb", "cmf", "copy", "cpr", "cpt", | ||
| 67 | + "csh", "cwp", "d00", "d01", "dcf", "dcm", "dct", "ddt", "dewf", | ||
| 68 | + "df2", "dfc", "dig", "dig", "dls", "dm", "dmf", "dmsa", "dmse", | ||
| 69 | + "drg", "dsf", "dsm", "dsp", "dss", "dtm", "dts", "dtshd", "dvf", | ||
| 70 | + "dwd", "ear", "efa", "efe", "efk", "efq", "efs", "efv", "emd", | ||
| 71 | + "emp", "emx", "esps", "f2r", "f32", "f3r", "f4a", "f64", "far", | ||
| 72 | + "fff", "flac", "flp", "fls", "frg", "fsm", "fzb", "fzf", "fzv", | ||
| 73 | + "g721", "g723", "g726", "gig", "gp5", "gpk", "gsm", "gsm", "h0", | ||
| 74 | + "hdp", "hma", "hsb", "ics", "iff", "imf", "imp", "ins", "ins", | ||
| 75 | + "it", "iti", "its", "jam", "k25", "k26", "kar", "kin", "kit", | ||
| 76 | + "kmp", "koz", "koz", "kpl", "krz", "ksc", "ksf", "kt2", "kt3", | ||
| 77 | + "ktp", "l", "la", "lqt", "lso", "lvp", "lwv", "m1a", "m3u", "m4a", | ||
| 78 | + "m4b", "m4p", "m4r", "ma1", "mdl", "med", "mgv", "midi", "miniusf", | ||
| 79 | + "mka", "mlp", "mmf", "mmm", "mmp", "mo3", "mod", "mp1", "mp2", | ||
| 80 | + "mp3", "mpa", "mpc", "mpga", "mpu", "mp_", "mscx", "mscz", "msv", | ||
| 81 | + "mt2", "mt9", "mte", "mti", "mtm", "mtp", "mts", "mus", "mws", | ||
| 82 | + "mxl", "mzp", "nap", "nki", "nra", "nrt", "nsa", "nsf", "nst", | ||
| 83 | + "ntn", "nvf", "nwc", "odm", "oga", "ogg", "okt", "oma", "omf", | ||
| 84 | + "omg", "omx", "ots", "ove", "ovw", "pac", "pat", "pbf", "pca", | ||
| 85 | + "pcast", "pcg", "pcm", "peak", "phy", "pk", "pla", "pls", "pna", | ||
| 86 | + "ppc", "ppcx", "prg", "prg", "psf", "psm", "ptf", "ptm", "pts", | ||
| 87 | + "pvc", "qcp", "r", "r1m", "ra", "ram", "raw", "rax", "rbs", "rcy", | ||
| 88 | + "rex", "rfl", "rmf", "rmi", "rmj", "rmm", "rmx", "rng", "rns", | ||
| 89 | + "rol", "rsn", "rso", "rti", "rtm", "rts", "rvx", "rx2", "s3i", | ||
| 90 | + "s3m", "s3z", "saf", "sam", "sb", "sbg", "sbi", "sbk", "sc2", "sd", | ||
| 91 | + "sd", "sd2", "sd2f", "sdat", "sdii", "sds", "sdt", "sdx", "seg", | ||
| 92 | + "seq", "ses", "sf2", "sfk", "sfl", "shn", "sib", "sid", "sid", | ||
| 93 | + "smf", "smp", "snd", "snd", "snd", "sng", "sng", "sou", "sppack", | ||
| 94 | + "sprg", "sseq", "sseq", "ssnd", "stm", "stx", "sty", "svx", "sw", | ||
| 95 | + "swa", "syh", "syw", "syx", "td0", "tfmx", "thx", "toc", "tsp", | ||
| 96 | + "txw", "u", "ub", "ulaw", "ult", "ulw", "uni", "usf", "usflib", | ||
| 97 | + "uw", "uwf", "vag", "val", "vc3", "vmd", "vmf", "vmf", "voc", | ||
| 98 | + "voi", "vox", "vpm", "vqf", "vrf", "vyf", "w01", "wav", "wav", | ||
| 99 | + "wave", "wax", "wfb", "wfd", "wfp", "wma", "wow", "wpk", "wproj", | ||
| 100 | + "wrk", "wus", "wut", "wv", "wvc", "wve", "wwu", "xa", "xa", "xfs", | ||
| 101 | + "xi", "xm", "xmf", "xmi", "xmz", "xp", "xrns", "xsb", "xspf", "xt", | ||
| 102 | + "xwb", "ym", "zvd", "zvr"}; | ||
| 103 | + | ||
| 104 | + private static final HashSet<String> mHashVideo; | ||
| 105 | + private static final HashSet<String> mHashAudio; | ||
| 106 | + private static final double KB = 1024.0; | ||
| 107 | + private static final double MB = KB * KB; | ||
| 108 | + private static final double GB = KB * KB * KB; | ||
| 109 | + | ||
| 110 | + static { | ||
| 111 | + mHashVideo = new HashSet<String>(Arrays.asList(VIDEO_EXTENSIONS)); | ||
| 112 | + mHashAudio = new HashSet<String>(Arrays.asList(AUDIO_EXTENSIONS)); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + private static HashMap<String, String> mMimeType = new HashMap<String, String>(); | ||
| 116 | + | ||
| 117 | + static { | ||
| 118 | + mMimeType.put("M1V", "video/mpeg"); | ||
| 119 | + mMimeType.put("MP2", "video/mpeg"); | ||
| 120 | + mMimeType.put("MPE", "video/mpeg"); | ||
| 121 | + mMimeType.put("MPG", "video/mpeg"); | ||
| 122 | + mMimeType.put("MPEG", "video/mpeg"); | ||
| 123 | + mMimeType.put("MP4", "video/mp4"); | ||
| 124 | + mMimeType.put("M4V", "video/mp4"); | ||
| 125 | + mMimeType.put("3GP", "video/3gpp"); | ||
| 126 | + mMimeType.put("3GPP", "video/3gpp"); | ||
| 127 | + mMimeType.put("3G2", "video/3gpp2"); | ||
| 128 | + mMimeType.put("3GPP2", "video/3gpp2"); | ||
| 129 | + mMimeType.put("MKV", "video/x-matroska"); | ||
| 130 | + mMimeType.put("WEBM", "video/x-matroska"); | ||
| 131 | + mMimeType.put("MTS", "video/mp2ts"); | ||
| 132 | + mMimeType.put("TS", "video/mp2ts"); | ||
| 133 | + mMimeType.put("TP", "video/mp2ts"); | ||
| 134 | + mMimeType.put("WMV", "video/x-ms-wmv"); | ||
| 135 | + mMimeType.put("ASF", "video/x-ms-asf"); | ||
| 136 | + mMimeType.put("ASX", "video/x-ms-asf"); | ||
| 137 | + mMimeType.put("FLV", "video/x-flv"); | ||
| 138 | + mMimeType.put("MOV", "video/quicktime"); | ||
| 139 | + mMimeType.put("QT", "video/quicktime"); | ||
| 140 | + mMimeType.put("RM", "video/x-pn-realvideo"); | ||
| 141 | + mMimeType.put("RMVB", "video/x-pn-realvideo"); | ||
| 142 | + mMimeType.put("VOB", "video/dvd"); | ||
| 143 | + mMimeType.put("DAT", "video/dvd"); | ||
| 144 | + mMimeType.put("AVI", "video/x-divx"); | ||
| 145 | + mMimeType.put("OGV", "video/ogg"); | ||
| 146 | + mMimeType.put("OGG", "video/ogg"); | ||
| 147 | + mMimeType.put("VIV", "video/vnd.vivo"); | ||
| 148 | + mMimeType.put("VIVO", "video/vnd.vivo"); | ||
| 149 | + mMimeType.put("WTV", "video/wtv"); | ||
| 150 | + mMimeType.put("AVS", "video/avs-video"); | ||
| 151 | + mMimeType.put("SWF", "video/x-shockwave-flash"); | ||
| 152 | + mMimeType.put("YUV", "video/x-raw-yuv"); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + /** | ||
| 156 | + * 是否是音频或者视频 | ||
| 157 | + */ | ||
| 158 | + public static boolean isVideoOrAudio(File f) { | ||
| 159 | + final String ext = getFileExtension(f); | ||
| 160 | + return mHashVideo.contains(ext) || mHashAudio.contains(ext); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + public static boolean isVideoOrAudio(String f) { | ||
| 164 | + final String ext = getUrlExtension(f); | ||
| 165 | + return mHashVideo.contains(ext) || mHashAudio.contains(ext); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + public static boolean isVideo(File f) { | ||
| 169 | + final String ext = getFileExtension(f); | ||
| 170 | + return mHashVideo.contains(ext); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * 获取文件后缀 | ||
| 175 | + */ | ||
| 176 | + public static String getFileExtension(File f) { | ||
| 177 | + if (f != null) { | ||
| 178 | + String filename = f.getName(); | ||
| 179 | + int i = filename.lastIndexOf('.'); | ||
| 180 | + if (i > 0 && i < filename.length() - 1) { | ||
| 181 | + return filename.substring(i + 1).toLowerCase(Locale.SIMPLIFIED_CHINESE); | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + return null; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + public static String getUrlFileExtensionName(String url) { | ||
| 188 | + if(TextUtils.isEmpty(url)) return ""; | ||
| 189 | + int slashIndex = url.lastIndexOf('/'); | ||
| 190 | + String filenameWithoutExtension; | ||
| 191 | + filenameWithoutExtension = url.substring(slashIndex + 1); | ||
| 192 | + return filenameWithoutExtension; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + public static String getUrlFileName(String url) { | ||
| 196 | + int slashIndex = url.lastIndexOf('/'); | ||
| 197 | + int dotIndex = url.lastIndexOf('.'); | ||
| 198 | + String filenameWithoutExtension; | ||
| 199 | + if (dotIndex == -1) { | ||
| 200 | + filenameWithoutExtension = url.substring(slashIndex + 1); | ||
| 201 | + } else { | ||
| 202 | + filenameWithoutExtension = url.substring(slashIndex + 1, dotIndex); | ||
| 203 | + } | ||
| 204 | + return filenameWithoutExtension; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + public static String getUrlExtension(String url) { | ||
| 208 | + if (!TextUtils.isEmpty(url)) { | ||
| 209 | + int i = url.lastIndexOf('.'); | ||
| 210 | + if (i > 0 && i < url.length() - 1) { | ||
| 211 | + return url.substring(i + 1).toLowerCase(Locale.getDefault()); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + return ""; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + public static String getFileNameNoEx(String filename) { | ||
| 218 | + if ((filename != null) && (filename.length() > 0)) { | ||
| 219 | + int dot = filename.lastIndexOf('.'); | ||
| 220 | + if ((dot > -1) && (dot < (filename.length()))) { | ||
| 221 | + return filename.substring(0, dot); | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + return filename; | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + public static String showFileSize(long size) { | ||
| 228 | + String fileSize; | ||
| 229 | + if (size < KB) | ||
| 230 | + fileSize = size + "B"; | ||
| 231 | + else if (size < MB) | ||
| 232 | + fileSize = String.format("%.1f", size / KB) + "KB"; | ||
| 233 | + else if (size < GB) | ||
| 234 | + fileSize = String.format("%.1f", size / MB) + "MB"; | ||
| 235 | + else | ||
| 236 | + fileSize = String.format("%.1f", size / GB) + "GB"; | ||
| 237 | + | ||
| 238 | + return fileSize; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + /** | ||
| 242 | + * 显示SD卡剩余空间 | ||
| 243 | + */ | ||
| 244 | + public static String showFileAvailable() { | ||
| 245 | + String result = ""; | ||
| 246 | + if (Environment.MEDIA_MOUNTED.equals(Environment | ||
| 247 | + .getExternalStorageState())) { | ||
| 248 | + StatFs sf = new StatFs(Environment.getExternalStorageDirectory() | ||
| 249 | + .getPath()); | ||
| 250 | + long blockSize = sf.getBlockSize(); | ||
| 251 | + long blockCount = sf.getBlockCount(); | ||
| 252 | + long availCount = sf.getAvailableBlocks(); | ||
| 253 | + return showFileSize(availCount * blockSize) + " / " | ||
| 254 | + + showFileSize(blockSize * blockCount); | ||
| 255 | + } | ||
| 256 | + return result; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + /** | ||
| 260 | + * 如果不存在就创建 | ||
| 261 | + */ | ||
| 262 | + public static boolean createIfNoExists(String path) { | ||
| 263 | + File file = new File(path); | ||
| 264 | + boolean mk = false; | ||
| 265 | + if (!file.exists()) { | ||
| 266 | + mk = file.mkdirs(); | ||
| 267 | + } | ||
| 268 | + return mk; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * 获取MIME | ||
| 273 | + */ | ||
| 274 | + public static String getMimeType(String path) { | ||
| 275 | + int lastDot = path.lastIndexOf("."); | ||
| 276 | + if (lastDot < 0) | ||
| 277 | + return null; | ||
| 278 | + | ||
| 279 | + return mMimeType.get(path.substring(lastDot + 1).toUpperCase(Locale.getDefault())); | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + /** | ||
| 283 | + * 多个SD卡时 取外置SD卡 | ||
| 284 | + */ | ||
| 285 | + public static String getExternalStorageDirectory() { | ||
| 286 | + // 参考文章 | ||
| 287 | + // http://blog.csdn.net/bbmiku/article/details/7937745 | ||
| 288 | + Map<String, String> map = System.getenv(); | ||
| 289 | + String[] values = new String[map.values().size()]; | ||
| 290 | + map.values().toArray(values); | ||
| 291 | + String path = values[values.length - 1]; | ||
| 292 | + if (path.startsWith("/mnt/") | ||
| 293 | + && !Environment.getExternalStorageDirectory().getAbsolutePath() | ||
| 294 | + .equals(path)) | ||
| 295 | + return path; | ||
| 296 | + else | ||
| 297 | + return null; | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + public static String getCanonical(File f) { | ||
| 301 | + if (f == null) | ||
| 302 | + return null; | ||
| 303 | + | ||
| 304 | + try { | ||
| 305 | + return f.getCanonicalPath(); | ||
| 306 | + } catch (IOException e) { | ||
| 307 | + return f.getAbsolutePath(); | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + public static boolean sdAvailable() { | ||
| 312 | + return Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment | ||
| 313 | + .getExternalStorageState()) | ||
| 314 | + || Environment.MEDIA_MOUNTED.equals(Environment | ||
| 315 | + .getExternalStorageState()); | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + //将SD卡文件删除 | ||
| 319 | + public static void deleteFile(File file) { | ||
| 320 | + String sdState = Environment.getExternalStorageState(); | ||
| 321 | + if (sdState.equals(Environment.MEDIA_MOUNTED)) { | ||
| 322 | + if (file.exists()) { | ||
| 323 | + if (file.isFile()) { | ||
| 324 | + file.delete(); | ||
| 325 | + } | ||
| 326 | + // 如果它是一个目录 | ||
| 327 | + else if (file.isDirectory()) { | ||
| 328 | + // 声明目录下所有的文件 files[]; | ||
| 329 | + File files[] = file.listFiles(); | ||
| 330 | + for (File file1 : files) { // 遍历目录下所有的文件 | ||
| 331 | + deleteFile(file1); // 把每个文件 用这个方法进行迭代 | ||
| 332 | + } | ||
| 333 | + } | ||
| 334 | + file.delete(); | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + public static long getFileSize(String pathToFile) { | ||
| 340 | + File f = new File(pathToFile); | ||
| 341 | + return f.length(); | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + @SuppressLint("DefaultLocale") | ||
| 345 | + public static String humanReadableByteCount(long bytes, boolean si) { | ||
| 346 | + int unit = si ? 1024 : 1000; | ||
| 347 | + if (bytes < unit) return bytes + " B"; | ||
| 348 | + int exp = (int) (Math.log(bytes) / Math.log(unit)); | ||
| 349 | + String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i"); | ||
| 350 | + return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + public static String getHumanReadableFileSize(String pathToFile) { | ||
| 354 | + return humanReadableByteCount(getFileSize(pathToFile), true); | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + public static String getDownloadSavePath(Context mContext){ | ||
| 358 | + String path; | ||
| 359 | + SharedPreferencesHelper sph = SharedPreferencesHelper.getInstance(mContext); | ||
| 360 | + String downLoadPath = sph.getValue("download_path"); | ||
| 361 | + if (downLoadPath != null && !downLoadPath.equals("extra")) { | ||
| 362 | + path = FileUtils.getInnerSDCardPath(mContext); | ||
| 363 | + } else { | ||
| 364 | + path = FileUtils.getExtSDCardPath(mContext); | ||
| 365 | + if(TextUtils.isEmpty(path)){//如果外部存储被拔出,自动转换至内部存储 | ||
| 366 | + sph.setValue("download_path","inner"); | ||
| 367 | + path = FileUtils.getInnerSDCardPath(mContext); | ||
| 368 | + } | ||
| 369 | + } | ||
| 370 | + return path; | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + public static String readSystem(Context context) { | ||
| 374 | + StatFs stat = new StatFs(getDownloadSavePath(context)); | ||
| 375 | + long blockSize = stat.getBlockSize(); | ||
| 376 | + long totalBlocks = stat.getBlockCount(); | ||
| 377 | + long availableBlocks = stat.getAvailableBlocks(); | ||
| 378 | + | ||
| 379 | + long totalSize = totalBlocks * blockSize; | ||
| 380 | + long availSize = availableBlocks * blockSize; | ||
| 381 | + | ||
| 382 | + return "可用大小:" + Formatter.formatFileSize(context, availSize) + ",总大小:" + Formatter.formatFileSize(context, totalSize); | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + public static String readExtraSystem(Context context, String path) { | ||
| 386 | + if(TextUtils.isEmpty(path)) return null; | ||
| 387 | + StatFs stat = new StatFs(path); | ||
| 388 | + long blockSize = stat.getBlockSize(); | ||
| 389 | + long totalBlocks = stat.getBlockCount(); | ||
| 390 | + long availableBlocks = stat.getAvailableBlocks(); | ||
| 391 | + | ||
| 392 | + long totalSize = totalBlocks * blockSize; | ||
| 393 | + long availSize = availableBlocks * blockSize; | ||
| 394 | + | ||
| 395 | + return "可用大小:" + Formatter.formatFileSize(context, availSize); | ||
| 396 | + } | ||
| 397 | + | ||
| 398 | + public static String readInnerSystem(Context context) { | ||
| 399 | + String pathStr = ""; | ||
| 400 | + if(TextUtils.isEmpty(pathStr = getInnerSDCardPath(context))) return null; | ||
| 401 | + StatFs stat = new StatFs(pathStr); | ||
| 402 | + long blockSize = stat.getBlockSize(); | ||
| 403 | + long totalBlocks = stat.getBlockCount(); | ||
| 404 | + long availableBlocks = stat.getAvailableBlocks(); | ||
| 405 | + | ||
| 406 | + long totalSize = totalBlocks * blockSize; | ||
| 407 | + long availSize = availableBlocks * blockSize; | ||
| 408 | + | ||
| 409 | + return "可用大小:" + Formatter.formatFileSize(context, availSize); | ||
| 410 | + } | ||
| 411 | + /** | ||
| 412 | + * 获取内置SD卡路径 | ||
| 413 | + * @return | ||
| 414 | + */ | ||
| 415 | + public static String getInnerSDCardPath(Context context) { | ||
| 416 | + return getStoragePath(context,false); | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + /** | ||
| 420 | + * 获取外置SD卡路径 | ||
| 421 | + * | ||
| 422 | + * @return 应该就一条记录或空 | ||
| 423 | + */ | ||
| 424 | + public static String getExtSDCardPath(Context context) { | ||
| 425 | + return getStoragePath(context,true); | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + private static String getStoragePath(Context mContext, boolean is_removale) { | ||
| 429 | + StorageManager mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); | ||
| 430 | + Class<?> storageVolumeClazz = null; | ||
| 431 | + try { | ||
| 432 | + storageVolumeClazz = Class.forName("android.os.storage.StorageVolume"); | ||
| 433 | + Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList"); | ||
| 434 | + Method getPath = storageVolumeClazz.getMethod("getPath"); | ||
| 435 | + Method isRemovable = storageVolumeClazz.getMethod("isRemovable"); | ||
| 436 | + Object result = getVolumeList.invoke(mStorageManager); | ||
| 437 | + final int length = Array.getLength(result); | ||
| 438 | + for (int i = 0; i < length; i++) { | ||
| 439 | + Object storageVolumeElement = Array.get(result, i); | ||
| 440 | + String path = (String) getPath.invoke(storageVolumeElement); | ||
| 441 | + boolean removable = (Boolean) isRemovable.invoke(storageVolumeElement); | ||
| 442 | + if (is_removale == removable) { | ||
| 443 | + StatFs stat = new StatFs(path); | ||
| 444 | + long blockSize = stat.getBlockSize(); | ||
| 445 | + long totalBlocks = stat.getBlockCount(); | ||
| 446 | + if(totalBlocks * blockSize <= 0) return null; | ||
| 447 | + return path; | ||
| 448 | + } | ||
| 449 | + } | ||
| 450 | + } catch (Exception e) { | ||
| 451 | + e.printStackTrace(); | ||
| 452 | + } | ||
| 453 | + return null; | ||
| 454 | + } | ||
| 455 | +} |
app/src/main/java/com/cnlive/gundam/user/util/NetworkUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.ConnectivityManager; | ||
| 5 | +import android.net.NetworkInfo; | ||
| 6 | + | ||
| 7 | +public class NetworkUtil { | ||
| 8 | + | ||
| 9 | + private static ConnectivityManager connectManager; | ||
| 10 | + | ||
| 11 | + private static void initConnectivityManager(Context context) { | ||
| 12 | + if (connectManager == null) connectManager = (ConnectivityManager) | ||
| 13 | + context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 检测网络是否连接 | ||
| 18 | + */ | ||
| 19 | + public static boolean isNetworkConnected(Context context) { | ||
| 20 | + initConnectivityManager(context); | ||
| 21 | + | ||
| 22 | + if (connectManager != null) { | ||
| 23 | + NetworkInfo activeNetwork = connectManager.getActiveNetworkInfo(); | ||
| 24 | + return activeNetwork != null && activeNetwork.isConnectedOrConnecting(); | ||
| 25 | + } | ||
| 26 | + return false; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 检测网络是否可用 | ||
| 31 | + */ | ||
| 32 | + public static boolean isConnectInternet(Context context) { | ||
| 33 | + initConnectivityManager(context); | ||
| 34 | + | ||
| 35 | + if (connectManager != null) { | ||
| 36 | + NetworkInfo networkinfo = connectManager.getActiveNetworkInfo(); | ||
| 37 | + return networkinfo != null && networkinfo.isAvailable(); | ||
| 38 | + } | ||
| 39 | + return false; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 检测Wifi是否可用 | ||
| 44 | + */ | ||
| 45 | + public static boolean isConnectWifi(Context context) { | ||
| 46 | + initConnectivityManager(context); | ||
| 47 | + | ||
| 48 | + if (connectManager != null) { | ||
| 49 | + NetworkInfo info = connectManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | ||
| 50 | + return info != null && !info.isConnectedOrConnecting(); | ||
| 51 | + } | ||
| 52 | + return false; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | +} | ||
| 0 | \ No newline at end of file | 56 | \ No newline at end of file |
app/src/main/java/com/cnlive/gundam/user/util/ShowTimeUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by luxiaoman on 2017/1/17. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +public class ShowTimeUtil { | ||
| 8 | + public static long mSetTotalTime = 59000;// 总的时间60000,60秒 | ||
| 9 | + public static long mSetDownValue = 1000;// 减少的值1000,1秒 | ||
| 10 | + | ||
| 11 | + public static final int UI_KAI_JIANG_DAO_JI_SHI_MSG = 1;//开始倒计时 | ||
| 12 | + public static final int UI_KAI_JIANG_ZHONG_MSG = 2;//停止倒计时 | ||
| 13 | + | ||
| 14 | + public static String showTimer;//显示时间 | ||
| 15 | + /** | ||
| 16 | + * 用于倒计时中处理时钟显示方式 | ||
| 17 | + * | ||
| 18 | + * @param paramLong | ||
| 19 | + * @return | ||
| 20 | + */ | ||
| 21 | + public static String changeTimerFormat(long paramLong) { | ||
| 22 | + long l1 = paramLong / 86400000L; | ||
| 23 | + long l2 = paramLong % 86400000L / 3600000L; | ||
| 24 | + long l3 = paramLong % 3600000L / 60000L; | ||
| 25 | + if ((l1 == 0L) && (l2 > 0L)) { | ||
| 26 | + return l2 + "小时"; | ||
| 27 | + } | ||
| 28 | + long l4 = paramLong % 60000L / 1000L; | ||
| 29 | + String str1 = String.valueOf(l3); | ||
| 30 | + String str2 = String.valueOf(l4); | ||
| 31 | + if (l3 < 10L) { | ||
| 32 | + str1 = "0" + l3; | ||
| 33 | + } | ||
| 34 | + if (l4 < 10L) { | ||
| 35 | + str2 = "0" + l4; | ||
| 36 | + } | ||
| 37 | + //return str1 + ":" + str2; | ||
| 38 | + return "还剩"+str2+"秒"; | ||
| 39 | + } | ||
| 40 | +} |
app/src/main/java/com/cnlive/gundam/user/util/SystemTools.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.annotation.TargetApi; | ||
| 4 | +import android.app.ActivityManager; | ||
| 5 | +import android.app.KeyguardManager; | ||
| 6 | +import android.content.Context; | ||
| 7 | +import android.content.Intent; | ||
| 8 | +import android.content.res.AssetManager; | ||
| 9 | +import android.graphics.Bitmap; | ||
| 10 | +import android.graphics.BitmapFactory; | ||
| 11 | +import android.graphics.Matrix; | ||
| 12 | +import android.graphics.drawable.Drawable; | ||
| 13 | +import android.net.Uri; | ||
| 14 | +import android.os.Environment; | ||
| 15 | +import android.os.StrictMode; | ||
| 16 | +import android.text.InputFilter; | ||
| 17 | +import android.text.Spanned; | ||
| 18 | +import android.text.format.Time; | ||
| 19 | +import android.util.Log; | ||
| 20 | +import android.view.Gravity; | ||
| 21 | +import android.widget.EditText; | ||
| 22 | +import android.widget.Toast; | ||
| 23 | + | ||
| 24 | +import com.cnlive.gundam.R; | ||
| 25 | + | ||
| 26 | +import java.io.ByteArrayOutputStream; | ||
| 27 | +import java.io.File; | ||
| 28 | +import java.io.FileNotFoundException; | ||
| 29 | +import java.io.FileOutputStream; | ||
| 30 | +import java.io.IOException; | ||
| 31 | +import java.io.InputStream; | ||
| 32 | +import java.io.RandomAccessFile; | ||
| 33 | +import java.net.HttpURLConnection; | ||
| 34 | +import java.net.URL; | ||
| 35 | +import java.net.URLConnection; | ||
| 36 | +import java.text.SimpleDateFormat; | ||
| 37 | +import java.util.Date; | ||
| 38 | +import java.util.List; | ||
| 39 | +import java.util.Locale; | ||
| 40 | +import java.util.regex.Matcher; | ||
| 41 | +import java.util.regex.Pattern; | ||
| 42 | + | ||
| 43 | +public class SystemTools { | ||
| 44 | + | ||
| 45 | + private static final String DOWNLOAD_PICTURE_PATH = "/com.cnlive.digitalcinema/picture/"; | ||
| 46 | + | ||
| 47 | + public final static boolean isScreenLocked(Context c) { | ||
| 48 | + KeyguardManager mKeyguardManager = (KeyguardManager) c | ||
| 49 | + .getSystemService(Context.KEYGUARD_SERVICE); | ||
| 50 | + return !mKeyguardManager.inKeyguardRestrictedInputMode(); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public static String saveDrawableToSdcard(Context context, int resID) { | ||
| 54 | + return saveBitmapToSdcard(context, BitmapFactory.decodeResource(context.getResources(), resID)); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public static String saveBitmapToSdcard(Context context, Bitmap bm) { | ||
| 58 | + File f = new File(context.getExternalCacheDir().getAbsolutePath() + "/", "sharePicName.png"); | ||
| 59 | + if (f.exists()) { | ||
| 60 | + f.delete(); | ||
| 61 | + } | ||
| 62 | + try { | ||
| 63 | + FileOutputStream out = new FileOutputStream(f); | ||
| 64 | + bm.compress(Bitmap.CompressFormat.PNG, 100, out); | ||
| 65 | + out.flush(); | ||
| 66 | + out.close(); | ||
| 67 | + } catch (FileNotFoundException e) { | ||
| 68 | + e.printStackTrace(); | ||
| 69 | + } catch (IOException e) { | ||
| 70 | + e.printStackTrace(); | ||
| 71 | + } | ||
| 72 | + return f.getAbsolutePath(); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + // 保存图片到sd卡 | ||
| 76 | + public static void saveToSdcard(Context context, Bitmap bm, String title) { | ||
| 77 | + File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + DOWNLOAD_PICTURE_PATH); | ||
| 78 | + if (!file.exists()) { | ||
| 79 | + file.mkdirs(); | ||
| 80 | + } | ||
| 81 | + try { | ||
| 82 | + String target = file.getAbsolutePath() + "/" + title + ".png"; | ||
| 83 | + File imageFile = new File(target); | ||
| 84 | + imageFile.createNewFile(); | ||
| 85 | + FileOutputStream out = new FileOutputStream(imageFile); | ||
| 86 | + bm.compress(Bitmap.CompressFormat.PNG, 100, out); | ||
| 87 | + out.flush(); | ||
| 88 | + out.close(); | ||
| 89 | + //发送广播,刷新相册 | ||
| 90 | + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); | ||
| 91 | + Uri uri = Uri.fromFile(imageFile); | ||
| 92 | + intent.setData(uri); | ||
| 93 | + if (context != null) | ||
| 94 | + context.sendBroadcast(intent); | ||
| 95 | + } catch (FileNotFoundException e) { | ||
| 96 | + e.printStackTrace(); | ||
| 97 | + } catch (IOException e) { | ||
| 98 | + e.printStackTrace(); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public static Drawable loadImageFromNetwork(String imageUrl) { | ||
| 103 | + Drawable drawable = null; | ||
| 104 | + try { | ||
| 105 | + // 可以在这里通过文件名来判断,是否本地有此图片 | ||
| 106 | + drawable = Drawable.createFromStream( | ||
| 107 | + new URL(imageUrl).openStream(), "image.jpg"); | ||
| 108 | + } catch (IOException e) { | ||
| 109 | + Log.d("test", e.getMessage()); | ||
| 110 | + } | ||
| 111 | + if (drawable == null) { | ||
| 112 | + Log.d("test", "null drawable"); | ||
| 113 | + } else { | ||
| 114 | + Log.d("test", "not null drawable"); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + return drawable; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public static final String getShowTime(Date date) { | ||
| 121 | + String show_time = ""; | ||
| 122 | + long difference = (new Date().getTime() - date.getTime()) / 1000; //分钟 | ||
| 123 | + | ||
| 124 | + if (difference < 30) { | ||
| 125 | + show_time = "刚刚"; | ||
| 126 | + } else if (difference >= 30 && difference < 60) { | ||
| 127 | + show_time = difference + "秒前"; | ||
| 128 | + } else if (difference >= 60 && difference < 3600) { | ||
| 129 | + show_time = difference / 60 + "分钟前"; | ||
| 130 | + } else if (difference >= 3600 && difference < 86400) { | ||
| 131 | + show_time = difference / 60 / 60 + "小时前"; | ||
| 132 | + } else if (difference >= 86400 && difference < 172800) { | ||
| 133 | + show_time = "昨天"; | ||
| 134 | + } else if (difference >= 172800 && difference < 230400) { | ||
| 135 | + show_time = "前天"; | ||
| 136 | + } else if (difference >= 230400 && difference < 259200) { | ||
| 137 | + show_time = "3天前"; | ||
| 138 | + } else if (difference >= 259200 && difference < 345600) { | ||
| 139 | + show_time = "4天前"; | ||
| 140 | + } else if (difference >= 345600 && difference < 432000) { | ||
| 141 | + show_time = "5天前"; | ||
| 142 | + } else if (difference >= 432000 && difference < 518000) { | ||
| 143 | + show_time = "6天前"; | ||
| 144 | + } else if (difference >= 518000 && difference < 604400) { | ||
| 145 | + show_time = "7天前"; | ||
| 146 | + } else if (difference >= 604400) { | ||
| 147 | + try { | ||
| 148 | + show_time = new SimpleDateFormat("yyyy年MM月dd日", Locale.getDefault()).format(date); | ||
| 149 | + } catch (Exception e) { | ||
| 150 | + Log.e("Date", "error ", e); | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + return show_time; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public static String getSystemDateTime() { | ||
| 157 | + return android.text.format.DateFormat.format("yyyy.MM.dd/kk:mm", | ||
| 158 | + new Date()).toString(); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public static int getCurrentTime() { | ||
| 162 | + Time localTime = new Time("Asia/Hong_Kong"); | ||
| 163 | + localTime.setToNow(); | ||
| 164 | + return Integer.valueOf(localTime.format("%H%M")); | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + public static int getCurrentDate() { | ||
| 168 | + Time localTime = new Time("Asia/Hong_Kong"); | ||
| 169 | + localTime.setToNow(); | ||
| 170 | + return Integer.valueOf(localTime.format("%Y%m%d")); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * @param err_msg | ||
| 175 | + * @return | ||
| 176 | + * @description 规定EditText输入长度 | ||
| 177 | + */ | ||
| 178 | + public static void lengthFilter(final Context context, | ||
| 179 | + final EditText editText, final int max_length, final String err_msg) { | ||
| 180 | + | ||
| 181 | + InputFilter[] filters = new InputFilter[1]; | ||
| 182 | + | ||
| 183 | + filters[0] = new InputFilter.LengthFilter(max_length) { | ||
| 184 | + @Override | ||
| 185 | + public CharSequence filter(CharSequence source, int start, int end, | ||
| 186 | + Spanned dest, int dstart, int dend) { | ||
| 187 | + int destLen = getCharacterNum(dest.toString()); // 获取字符个数(一个中文算2个字符) | ||
| 188 | + int sourceLen = getCharacterNum(source.toString()); | ||
| 189 | + if (destLen + sourceLen > max_length) { | ||
| 190 | + editText.setText(dest.toString()); | ||
| 191 | + Toast toast = Toast.makeText(context, err_msg, | ||
| 192 | + Toast.LENGTH_SHORT); | ||
| 193 | + toast.setGravity(Gravity.CENTER, 0, 0); | ||
| 194 | + toast.show(); | ||
| 195 | + return ""; | ||
| 196 | + } | ||
| 197 | + return source; | ||
| 198 | + } | ||
| 199 | + }; | ||
| 200 | + editText.setFilters(filters); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + /** | ||
| 204 | + * @param content | ||
| 205 | + * @return | ||
| 206 | + * @description 获取一段字符串的字符个数(包含中英文,一个中文算2个字符) | ||
| 207 | + */ | ||
| 208 | + public static int getCharacterNum(final String content) { | ||
| 209 | + if (null == content || "".equals(content)) { | ||
| 210 | + return 0; | ||
| 211 | + } else { | ||
| 212 | + return (content.length() + getChineseNum(content)); | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + /** | ||
| 217 | + * @param s | ||
| 218 | + * @return | ||
| 219 | + * @description 返回字符串里中文字或者全角字符的个数 | ||
| 220 | + */ | ||
| 221 | + public static int getChineseNum(String s) { | ||
| 222 | + | ||
| 223 | + int num = 0; | ||
| 224 | + char[] myChar = s.toCharArray(); | ||
| 225 | + for (int i = 0; i < myChar.length; i++) { | ||
| 226 | + if ((char) (byte) myChar[i] != myChar[i]) { | ||
| 227 | + num++; | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + return num; | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + public static InputStream readURLInputStream(String URL) throws Exception { | ||
| 234 | + java.net.URL sourceUrl; | ||
| 235 | + URLConnection conn; | ||
| 236 | + sourceUrl = new URL(URL); | ||
| 237 | + conn = sourceUrl.openConnection(); | ||
| 238 | + conn.setConnectTimeout(7000); | ||
| 239 | + return conn.getInputStream(); | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + /** | ||
| 243 | + * 获取网络文件长度 | ||
| 244 | + * | ||
| 245 | + * @param downloadUrl | ||
| 246 | + * @return | ||
| 247 | + * @throws IOException | ||
| 248 | + */ | ||
| 249 | + @TargetApi(9) | ||
| 250 | + public static int getNetFileLength(String downloadUrl) { | ||
| 251 | + int fileSize = 0; | ||
| 252 | + try { | ||
| 253 | + if (android.os.Build.VERSION.SDK_INT > 9) { | ||
| 254 | + StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() | ||
| 255 | + .permitAll().build(); | ||
| 256 | + StrictMode.setThreadPolicy(policy); | ||
| 257 | + } | ||
| 258 | + URL url = new URL(downloadUrl); | ||
| 259 | + HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 建立连接 | ||
| 260 | + conn.setConnectTimeout(6 * 1000); | ||
| 261 | + conn.setRequestMethod("GET"); | ||
| 262 | + conn.setRequestProperty("Accept-Language", "zh-CN"); | ||
| 263 | + conn.setRequestProperty("Referer", downloadUrl); | ||
| 264 | + conn.setRequestProperty("Charset", "UTF-8"); | ||
| 265 | + conn.setRequestProperty( | ||
| 266 | + "User-Agent", | ||
| 267 | + "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"); | ||
| 268 | + conn.connect(); | ||
| 269 | + if (conn.getResponseCode() == 200) { | ||
| 270 | + fileSize = conn.getContentLength(); | ||
| 271 | + } | ||
| 272 | + } catch (Exception e) { | ||
| 273 | + } | ||
| 274 | + return fileSize; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + public static final int LOCAL_FILE_VIDEO = 4; | ||
| 278 | + | ||
| 279 | + public static final int FILE_STREAM_VIDEO = 5; | ||
| 280 | + | ||
| 281 | + public static final int LIVE_STREAM_VIDEO = 6; | ||
| 282 | + | ||
| 283 | + public static Integer getMediaType(String videoPath) { | ||
| 284 | + if (videoPath.contains("/playlist")) { | ||
| 285 | + return SystemTools.LIVE_STREAM_VIDEO; | ||
| 286 | + } else if (videoPath.contains(".m3u8")) { | ||
| 287 | + return SystemTools.FILE_STREAM_VIDEO; | ||
| 288 | + } else { | ||
| 289 | + return SystemTools.LOCAL_FILE_VIDEO; | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + public static byte[] getBytes(InputStream is) throws IOException { | ||
| 294 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 295 | + byte[] b = new byte[1024]; | ||
| 296 | + int len = 0; | ||
| 297 | + while ((len = is.read(b, 0, 1024)) != -1) { | ||
| 298 | + baos.write(b, 0, len); | ||
| 299 | + baos.flush(); | ||
| 300 | + } | ||
| 301 | + byte[] bytes = baos.toByteArray(); | ||
| 302 | + return bytes; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + /** | ||
| 306 | + * 图片的缩放方法 | ||
| 307 | + * | ||
| 308 | + * @param bgimage :源图片资源 | ||
| 309 | + * @param newWidth :缩放后宽度 | ||
| 310 | + * @param newHeight :缩放后高度 | ||
| 311 | + * @return | ||
| 312 | + */ | ||
| 313 | + public static Bitmap zoomImage(Bitmap bgimage, double newWidth, | ||
| 314 | + double newHeight) { | ||
| 315 | + // 获取这个图片的宽和高 | ||
| 316 | + float width = bgimage.getWidth(); | ||
| 317 | + float height = bgimage.getHeight(); | ||
| 318 | + // 创建操作图片用的matrix对象 | ||
| 319 | + Matrix matrix = new Matrix(); | ||
| 320 | + // 计算宽高缩放率 | ||
| 321 | + float scaleWidth = ((float) newWidth) / width; | ||
| 322 | + float scaleHeight = ((float) newHeight) / height; | ||
| 323 | + // 缩放图片动作 | ||
| 324 | + matrix.postScale(scaleWidth, scaleHeight); | ||
| 325 | + Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width, | ||
| 326 | + (int) height, matrix, true); | ||
| 327 | + return bitmap; | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + public static String DownloadFile(String path, String string_url, String file_name) { | ||
| 331 | + // 未下载完成 | ||
| 332 | + int buffer_size = 1024; | ||
| 333 | + HttpURLConnection http = null; | ||
| 334 | + InputStream is = null; | ||
| 335 | + RandomAccessFile raf = null; | ||
| 336 | + try { | ||
| 337 | + File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + path); | ||
| 338 | + if (!dir.exists()) { | ||
| 339 | + dir.mkdirs(); | ||
| 340 | + } else if (!dir.isDirectory()) { | ||
| 341 | + dir.delete(); | ||
| 342 | + dir.mkdirs(); | ||
| 343 | + } | ||
| 344 | + String filePath = dir.getAbsolutePath() + "/" + file_name; | ||
| 345 | + File f = new File(filePath); | ||
| 346 | + if (f.exists()) { | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + URL url = new URL(string_url); | ||
| 350 | + http = (HttpURLConnection) url.openConnection(); // | ||
| 351 | + http.setConnectTimeout(5 * 1000); | ||
| 352 | + http.setRequestMethod("GET");// | ||
| 353 | + http.setRequestProperty( | ||
| 354 | + "Accept", | ||
| 355 | + "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"); | ||
| 356 | + http.setRequestProperty("Accept-Language", "zh-CN"); | ||
| 357 | + http.setRequestProperty("Referer", url.toString()); | ||
| 358 | + http.setRequestProperty("Charset", "UTF-8"); | ||
| 359 | + http.setRequestProperty( | ||
| 360 | + "User-Agent", | ||
| 361 | + "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"); | ||
| 362 | + http.setRequestProperty("Connection", "Keep-Alive"); | ||
| 363 | + | ||
| 364 | + is = http.getInputStream(); | ||
| 365 | + byte[] buffer = new byte[buffer_size]; | ||
| 366 | + int offset = 0; | ||
| 367 | + int tempLen = 0; | ||
| 368 | + | ||
| 369 | + raf = new RandomAccessFile(filePath, "rwd");// | ||
| 370 | + raf.seek(0); | ||
| 371 | + while ((offset = is.read(buffer, 0, buffer_size)) != -1) { | ||
| 372 | + raf.write(buffer, 0, offset); | ||
| 373 | + tempLen += offset; | ||
| 374 | + if (tempLen > buffer_size * 50) { | ||
| 375 | + tempLen = 0; | ||
| 376 | + } | ||
| 377 | + } | ||
| 378 | + is.close(); | ||
| 379 | + raf.close(); | ||
| 380 | + return filePath; | ||
| 381 | + } catch (Exception e) { | ||
| 382 | + return ""; | ||
| 383 | + } finally { | ||
| 384 | + if (http != null) | ||
| 385 | + http.disconnect(); | ||
| 386 | + if (is != null) | ||
| 387 | + is = null; | ||
| 388 | + if (raf != null) | ||
| 389 | + raf = null; | ||
| 390 | + } | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + public static String getTimeFromInt(int time) { | ||
| 394 | + if (time < 0) { | ||
| 395 | + return "00:00"; | ||
| 396 | + } | ||
| 397 | + | ||
| 398 | + int secondnd = time / 60; | ||
| 399 | + int minutesnd = time % 60; | ||
| 400 | + | ||
| 401 | + String f = secondnd >= 10 ? String.valueOf(secondnd) : "0" + String.valueOf(secondnd); | ||
| 402 | + String m = minutesnd >= 10 ? String.valueOf(minutesnd) : "0" + String.valueOf(minutesnd); | ||
| 403 | + | ||
| 404 | + return f + ":" + m; | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + public static String storeImageToFile(Context mContext, Bitmap bitmap, String headName) { | ||
| 408 | + if (bitmap == null) { | ||
| 409 | + return null; | ||
| 410 | + } | ||
| 411 | + File rootFile = null; | ||
| 412 | + File file = null; | ||
| 413 | + RandomAccessFile accessFile = null; | ||
| 414 | + String path = ""; | ||
| 415 | + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { | ||
| 416 | + path = Environment.getExternalStorageDirectory().getAbsolutePath().toString() + "/" + "com.cnlive.spring/image"; | ||
| 417 | + rootFile = new File(path); | ||
| 418 | + if (!rootFile.exists()) { | ||
| 419 | + rootFile.mkdirs(); | ||
| 420 | + } | ||
| 421 | + file = new File(path + "/" + headName); | ||
| 422 | + ByteArrayOutputStream steam = new ByteArrayOutputStream(); | ||
| 423 | + bitmap.compress(Bitmap.CompressFormat.PNG, 100, steam); | ||
| 424 | + byte[] buffer = steam.toByteArray(); | ||
| 425 | + | ||
| 426 | + try { | ||
| 427 | + accessFile = new RandomAccessFile(file, "rw"); | ||
| 428 | + accessFile.write(buffer); | ||
| 429 | + } catch (Exception e) { | ||
| 430 | + return null; | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + try { | ||
| 434 | + steam.close(); | ||
| 435 | + accessFile.close(); | ||
| 436 | + } catch (IOException e) { | ||
| 437 | + //Note: do nothing. | ||
| 438 | + } | ||
| 439 | + } else { | ||
| 440 | + ToastUtil.show(mContext, "请检查您的SD卡是否安装!"); | ||
| 441 | + } | ||
| 442 | + return path; | ||
| 443 | + } | ||
| 444 | + | ||
| 445 | + public static Bitmap getImageFromAssetsFile(Context context, String fileName) { | ||
| 446 | + Bitmap image = null; | ||
| 447 | + AssetManager am = context.getResources().getAssets(); | ||
| 448 | + try { | ||
| 449 | + InputStream is = am.open(fileName); | ||
| 450 | + image = BitmapFactory.decodeStream(is); | ||
| 451 | + is.close(); | ||
| 452 | + } catch (IOException e) { | ||
| 453 | + e.printStackTrace(); | ||
| 454 | + } | ||
| 455 | + | ||
| 456 | + return image; | ||
| 457 | + | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + /** | ||
| 461 | + * 验证手机号码 | ||
| 462 | + * | ||
| 463 | + * @param mobiles | ||
| 464 | + * @return [0-9]{5,9} | ||
| 465 | + */ | ||
| 466 | + public static boolean isMobileNO(String mobiles) { | ||
| 467 | + boolean flag = false; | ||
| 468 | + try { | ||
| 469 | + Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,2-3,5-9]))\\d{8}$"); | ||
| 470 | + Matcher m = p.matcher(mobiles); | ||
| 471 | + flag = m.matches(); | ||
| 472 | + } catch (Exception e) { | ||
| 473 | + flag = false; | ||
| 474 | + } | ||
| 475 | + return flag; | ||
| 476 | + } | ||
| 477 | + | ||
| 478 | + public static boolean isPwd(String pwd) { //只能是数字和字母 | ||
| 479 | + boolean flag = false; | ||
| 480 | + try { | ||
| 481 | + Pattern p = Pattern.compile("^[A-Za-z0-9]+$"); | ||
| 482 | + Matcher m = p.matcher(pwd); | ||
| 483 | + flag = m.matches(); | ||
| 484 | + } catch (Exception e) { | ||
| 485 | + flag = false; | ||
| 486 | + } | ||
| 487 | + return flag; | ||
| 488 | + } | ||
| 489 | + | ||
| 490 | + public static boolean isNickName(String nickName) { //只能是数字和字母 | ||
| 491 | + boolean flag = false; | ||
| 492 | + try { | ||
| 493 | + Pattern p = Pattern.compile("^[A-Za-z0-9\\u4E00-\\u9FA5]+$"); | ||
| 494 | + Matcher m = p.matcher(nickName); | ||
| 495 | + flag = m.matches(); | ||
| 496 | + } catch (Exception e) { | ||
| 497 | + flag = false; | ||
| 498 | + } | ||
| 499 | + return flag; | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + private static float density = 0; | ||
| 503 | + | ||
| 504 | + public static int dip2px(Context context, float dipValue) { | ||
| 505 | + if (density == 0) | ||
| 506 | + density = context.getResources().getDisplayMetrics().density; | ||
| 507 | + return (int) (dipValue * density + 0.5f); | ||
| 508 | + } | ||
| 509 | + | ||
| 510 | + public static String formatTime(int ms) { | ||
| 511 | + Integer ss = 1000; | ||
| 512 | + Integer mi = ss * 60; | ||
| 513 | + Integer hh = mi * 60; | ||
| 514 | + | ||
| 515 | + int hour = ms / hh; | ||
| 516 | + int minute = (ms - hour * hh) / mi; | ||
| 517 | + int second = (ms - hour * hh - minute * mi) / ss; | ||
| 518 | + int milliSecond = ms - hour * hh - minute * mi - second * ss; | ||
| 519 | + | ||
| 520 | + StringBuffer sb = new StringBuffer(); | ||
| 521 | + if (hour > 0 && hour < 10) { | ||
| 522 | + sb.append("0" + hour + ":"); | ||
| 523 | + } else if (hour >= 10) { | ||
| 524 | + sb.append(hour + ":"); | ||
| 525 | + } else { | ||
| 526 | + sb.append("00:"); | ||
| 527 | + } | ||
| 528 | + | ||
| 529 | + if (minute > 0 && minute < 10) { | ||
| 530 | + sb.append("0" + minute + ":"); | ||
| 531 | + } else if (minute >= 10) { | ||
| 532 | + sb.append(minute + ":"); | ||
| 533 | + } else { | ||
| 534 | + sb.append("00:"); | ||
| 535 | + } | ||
| 536 | + | ||
| 537 | + if (second > 0 && second < 10) { | ||
| 538 | + sb.append("0" + second); | ||
| 539 | + } else if (second >= 10) { | ||
| 540 | + sb.append(second); | ||
| 541 | + } else { | ||
| 542 | + sb.append("00"); | ||
| 543 | + } | ||
| 544 | + return sb.toString(); | ||
| 545 | + } | ||
| 546 | + | ||
| 547 | + /** | ||
| 548 | + * 程序是否在前台运行 | ||
| 549 | + * | ||
| 550 | + * @return | ||
| 551 | + */ | ||
| 552 | + public static boolean isAppOnForeground(Context context) { | ||
| 553 | + ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | ||
| 554 | + String packageName = context.getPackageName(); | ||
| 555 | + | ||
| 556 | + List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager | ||
| 557 | + .getRunningAppProcesses(); | ||
| 558 | + if (appProcesses == null) | ||
| 559 | + return false; | ||
| 560 | + | ||
| 561 | + for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { | ||
| 562 | + if (appProcess.processName.equals(packageName) | ||
| 563 | + && appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { | ||
| 564 | + return true; | ||
| 565 | + } | ||
| 566 | + } | ||
| 567 | + return false; | ||
| 568 | + } | ||
| 569 | + | ||
| 570 | + /** | ||
| 571 | + * 验证邮箱 return true 为有效地址 | ||
| 572 | + */ | ||
| 573 | + public static boolean isEmailValid(String url) { | ||
| 574 | + //Pattern p = Pattern.compile("\\w+@(\\w+.)+[a-z]{2,3}"); | ||
| 575 | + Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); | ||
| 576 | + Matcher m = p.matcher(url); | ||
| 577 | + boolean b = m.matches(); | ||
| 578 | + return b; | ||
| 579 | + } | ||
| 580 | + | ||
| 581 | + public static boolean checkNetwork(Context context) { | ||
| 582 | + if (context == null) return false; | ||
| 583 | + if (NetworkUtil.isConnectInternet(context.getApplicationContext())) { | ||
| 584 | + return true; | ||
| 585 | + } else { | ||
| 586 | + Toast.makeText(context.getApplicationContext(), context.getString(R.string.net_connect_toast), Toast.LENGTH_SHORT).show(); | ||
| 587 | + return false; | ||
| 588 | + } | ||
| 589 | + } | ||
| 590 | +} |
app/src/main/java/com/cnlive/gundam/user/util/ToastUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.view.LayoutInflater; | ||
| 6 | +import android.view.View; | ||
| 7 | +import android.widget.ImageView; | ||
| 8 | +import android.widget.TextView; | ||
| 9 | +import android.widget.Toast; | ||
| 10 | + | ||
| 11 | +import com.cnlive.gundam.R; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Created by xiansong on 2016/12/12. | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +public class ToastUtil { | ||
| 20 | + private static Toast toast; | ||
| 21 | + | ||
| 22 | + private static long back_pressed; | ||
| 23 | + private static String show_msg = ""; | ||
| 24 | + private static Toast current_toast; | ||
| 25 | + private static final int TOAST_LAYOUT_ID = R.layout.test_layout_toast; | ||
| 26 | + | ||
| 27 | + public static void hideToast() { | ||
| 28 | + if (current_toast != null) current_toast.cancel(); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public static Toast show(Context context, String msg) { | ||
| 32 | +// if (!ShockwaveApplication.appOnline) | ||
| 33 | +// return; | ||
| 34 | + hide(); | ||
| 35 | + if (null == context || TextUtils.isEmpty(msg)) | ||
| 36 | + return null; | ||
| 37 | + if (back_pressed + 2000 < System.currentTimeMillis() || !show_msg.equals(msg)) { | ||
| 38 | + hideToast(); | ||
| 39 | + show_msg = msg; | ||
| 40 | + toast = new Toast(context); | ||
| 41 | + View view = LayoutInflater.from(context).inflate(TOAST_LAYOUT_ID, null, false); | ||
| 42 | + ImageView imageView = (ImageView) view.findViewById(R.id.image); | ||
| 43 | + TextView textView = (TextView) view.findViewById(R.id.text); | ||
| 44 | + imageView.setVisibility(View.GONE); | ||
| 45 | + | ||
| 46 | + textView.setText(msg); | ||
| 47 | + toast.setDuration(Toast.LENGTH_SHORT); | ||
| 48 | + toast.setView(view); | ||
| 49 | + toast.show(); | ||
| 50 | + current_toast = toast; | ||
| 51 | + } | ||
| 52 | + back_pressed = System.currentTimeMillis(); | ||
| 53 | + return toast; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public static boolean checkNetwork(Context context) { | ||
| 57 | + if (context == null) return false; | ||
| 58 | + if (NetworkUtil.isConnectInternet(context.getApplicationContext())) { | ||
| 59 | + return true; | ||
| 60 | + } else { | ||
| 61 | + show(context.getApplicationContext(), context.getString(R.string.net_connect_toast)); | ||
| 62 | + return false; | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public static void showToast(Context context, String text) { | ||
| 67 | + show(context,text); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public static void hide() { | ||
| 71 | + if (toast != null) toast.cancel(); | ||
| 72 | + } | ||
| 73 | +} |
app/src/main/java/com/cnlive/gundam/user/util/UploadImageUtils.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.util; | ||
| 2 | + | ||
| 3 | +import android.annotation.TargetApi; | ||
| 4 | +import android.content.ContentUris; | ||
| 5 | +import android.content.Context; | ||
| 6 | +import android.database.Cursor; | ||
| 7 | +import android.graphics.Bitmap; | ||
| 8 | +import android.graphics.BitmapFactory; | ||
| 9 | +import android.net.Uri; | ||
| 10 | +import android.os.Build; | ||
| 11 | +import android.os.Environment; | ||
| 12 | +import android.provider.DocumentsContract; | ||
| 13 | +import android.provider.MediaStore; | ||
| 14 | +import android.text.TextUtils; | ||
| 15 | +import android.util.Log; | ||
| 16 | + | ||
| 17 | +import java.io.ByteArrayInputStream; | ||
| 18 | +import java.io.ByteArrayOutputStream; | ||
| 19 | +import java.io.File; | ||
| 20 | +import java.io.FileOutputStream; | ||
| 21 | +import java.io.IOException; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Created by gujun on 2015/5/19. | ||
| 26 | + */ | ||
| 27 | +public class UploadImageUtils { | ||
| 28 | + private static final String AVATAR_PATH = "/com.cnlive.goldenline/image/"; | ||
| 29 | + | ||
| 30 | + private static Bitmap getimage(Context context, String srcPath) { | ||
| 31 | + BitmapFactory.Options newOpts = new BitmapFactory.Options(); | ||
| 32 | + //开始读入图片,此时把options.inJustDecodeBounds 设回true了 | ||
| 33 | + newOpts.inJustDecodeBounds = true; | ||
| 34 | + Bitmap bitmap = BitmapFactory.decodeFile(srcPath,newOpts);//此时返回bm为空 | ||
| 35 | + newOpts.inJustDecodeBounds = false; | ||
| 36 | + int scale = (int) (newOpts.outHeight / (float) 400); | ||
| 37 | + if (scale <= 0) | ||
| 38 | + scale = 1; | ||
| 39 | + newOpts.inSampleSize = scale;//设置缩放比例 | ||
| 40 | + //重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了 | ||
| 41 | + bitmap = BitmapFactory.decodeFile(srcPath, newOpts); | ||
| 42 | + return compressImage(bitmap);//压缩好比例大小后再进行质量压缩 | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + private static Bitmap compressImage(Bitmap image) { | ||
| 46 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 47 | + if (image != null) { | ||
| 48 | + image.compress(Bitmap.CompressFormat.JPEG, 80, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中 | ||
| 49 | + } | ||
| 50 | + ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中 | ||
| 51 | + Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片 | ||
| 52 | + return bitmap; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + // 写到sdcard中 | ||
| 56 | + public static String writeUriToSDcard(Context context, Uri uriPath) throws IOException { | ||
| 57 | + Bitmap bitmap = getimage(context, getPath(context, uriPath)); | ||
| 58 | + return writhToSDcard(context,bitmap); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public static String writeStringToSDcard(Context context, String path) throws IOException { | ||
| 62 | + Bitmap bitmap = getimage(context, path); | ||
| 63 | + return writhToSDcard(context,bitmap); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + private static String writhToSDcard(Context context, Bitmap bitmap)throws IOException { | ||
| 67 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 68 | + if (bitmap != null) { | ||
| 69 | + bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);//png类型 | ||
| 70 | + } | ||
| 71 | + String path = getAvatarPath(context); | ||
| 72 | + if(!TextUtils.isEmpty(path)){ | ||
| 73 | + FileOutputStream out=new FileOutputStream(new File(path)); | ||
| 74 | + out.write(baos.toByteArray()); | ||
| 75 | + try { | ||
| 76 | + out.flush(); | ||
| 77 | + out.close(); | ||
| 78 | + }catch (Exception e){ | ||
| 79 | + | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + } | ||
| 83 | + return path; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public static String getAvatarPath(Context context){ | ||
| 87 | + String status = Environment.getExternalStorageState(); | ||
| 88 | + String path = ""; | ||
| 89 | + if (Environment.MEDIA_MOUNTED.equals(status)) { | ||
| 90 | + String rootPath = Environment.getExternalStorageDirectory().getAbsolutePath() + AVATAR_PATH; | ||
| 91 | + File file = new File(rootPath); | ||
| 92 | + if(!file.exists()){ | ||
| 93 | + file.mkdirs(); | ||
| 94 | + } | ||
| 95 | + path = rootPath+"avatar.png"; | ||
| 96 | + }else { | ||
| 97 | + ToastUtil.show(context, "未插入SD卡"); | ||
| 98 | + } | ||
| 99 | + return path; | ||
| 100 | + | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @TargetApi(Build.VERSION_CODES.KITKAT) | ||
| 104 | + private static String getPath(final Context context, final Uri uri) { | ||
| 105 | + | ||
| 106 | + final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; | ||
| 107 | + | ||
| 108 | + // DocumentProvider | ||
| 109 | + if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { | ||
| 110 | + // ExternalStorageProvider | ||
| 111 | + if (isExternalStorageDocument(uri)) { | ||
| 112 | + final String docId = DocumentsContract.getDocumentId(uri); | ||
| 113 | + final String[] split = docId.split(":"); | ||
| 114 | + final String type = split[0]; | ||
| 115 | + | ||
| 116 | + if ("primary".equalsIgnoreCase(type)) { | ||
| 117 | + return Environment.getExternalStorageDirectory() + "/" + split[1]; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + // TODO handle non-primary volumes | ||
| 121 | + } | ||
| 122 | + // DownloadsProvider | ||
| 123 | + else if (isDownloadsDocument(uri)) { | ||
| 124 | + | ||
| 125 | + final String id = DocumentsContract.getDocumentId(uri); | ||
| 126 | + final Uri contentUri = ContentUris.withAppendedId( | ||
| 127 | + Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); | ||
| 128 | + | ||
| 129 | + return getDataColumn(context, contentUri, null, null); | ||
| 130 | + } | ||
| 131 | + // MediaProvider | ||
| 132 | + else if (isMediaDocument(uri)) { | ||
| 133 | + final String docId = DocumentsContract.getDocumentId(uri); | ||
| 134 | + final String[] split = docId.split(":"); | ||
| 135 | + final String type = split[0]; | ||
| 136 | + | ||
| 137 | + Uri contentUri = null; | ||
| 138 | + if ("image".equals(type)) { | ||
| 139 | + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; | ||
| 140 | + } else if ("video".equals(type)) { | ||
| 141 | + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; | ||
| 142 | + } else if ("audio".equals(type)) { | ||
| 143 | + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + final String selection = "_id=?"; | ||
| 147 | + final String[] selectionArgs = new String[]{ | ||
| 148 | + split[1] | ||
| 149 | + }; | ||
| 150 | + | ||
| 151 | + return getDataColumn(context, contentUri, selection, selectionArgs); | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + // MediaStore (and general) | ||
| 155 | + else if ("content".equalsIgnoreCase(uri.getScheme())) { | ||
| 156 | + | ||
| 157 | + // Return the remote address | ||
| 158 | + if (isGooglePhotosUri(uri)) | ||
| 159 | + return uri.getLastPathSegment(); | ||
| 160 | + | ||
| 161 | + return getDataColumn(context, uri, null, null); | ||
| 162 | + } | ||
| 163 | + // File | ||
| 164 | + else if ("file".equalsIgnoreCase(uri.getScheme())) { | ||
| 165 | + return uri.getPath(); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + return null; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + /** | ||
| 172 | + * Get the value of the data column for this Uri. This is useful for | ||
| 173 | + * MediaStore Uris, and other file-based ContentProviders. | ||
| 174 | + * | ||
| 175 | + * @param context The context. | ||
| 176 | + * @param uri The Uri to query. | ||
| 177 | + * @param selection (Optional) Filter used in the query. | ||
| 178 | + * @param selectionArgs (Optional) Selection arguments used in the query. | ||
| 179 | + * @return The value of the _data column, which is typically a file path. | ||
| 180 | + */ | ||
| 181 | + public static String getDataColumn(Context context, Uri uri, String selection, | ||
| 182 | + String[] selectionArgs) { | ||
| 183 | + | ||
| 184 | + Cursor cursor = null; | ||
| 185 | + final String column = "_data"; | ||
| 186 | + final String[] projection = { | ||
| 187 | + column | ||
| 188 | + }; | ||
| 189 | + | ||
| 190 | + try { | ||
| 191 | + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, | ||
| 192 | + null); | ||
| 193 | + if (cursor != null && cursor.moveToFirst()) { | ||
| 194 | + final int index = cursor.getColumnIndexOrThrow(column); | ||
| 195 | + return cursor.getString(index); | ||
| 196 | + } | ||
| 197 | + }catch(Exception e){ | ||
| 198 | + Log.e("getDataColumn","cursor error : " + e.getMessage()); | ||
| 199 | + } finally { | ||
| 200 | + if (cursor != null) | ||
| 201 | + cursor.close(); | ||
| 202 | + } | ||
| 203 | + return null; | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + /** | ||
| 207 | + * @param uri The Uri to check. | ||
| 208 | + * @return Whether the Uri authority is ExternalStorageProvider. | ||
| 209 | + */ | ||
| 210 | + public static boolean isExternalStorageDocument(Uri uri) { | ||
| 211 | + return "com.android.externalstorage.documents".equals(uri.getAuthority()); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * @param uri The Uri to check. | ||
| 216 | + * @return Whether the Uri authority is DownloadsProvider. | ||
| 217 | + */ | ||
| 218 | + public static boolean isDownloadsDocument(Uri uri) { | ||
| 219 | + return "com.android.providers.downloads.documents".equals(uri.getAuthority()); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + /** | ||
| 223 | + * @param uri The Uri to check. | ||
| 224 | + * @return Whether the Uri authority is MediaProvider. | ||
| 225 | + */ | ||
| 226 | + public static boolean isMediaDocument(Uri uri) { | ||
| 227 | + return "com.android.providers.media.documents".equals(uri.getAuthority()); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + /** | ||
| 231 | + * @param uri The Uri to check. | ||
| 232 | + * @return Whether the Uri authority is Google Photos. | ||
| 233 | + */ | ||
| 234 | + public static boolean isGooglePhotosUri(Uri uri) { | ||
| 235 | + return "com.google.android.apps.photos.content".equals(uri.getAuthority()); | ||
| 236 | + } | ||
| 237 | +} |
app/src/main/res/anim/pop_enter_anim.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <translate | ||
| 4 | + android:duration="200" | ||
| 5 | + android:fromYDelta="100%p" | ||
| 6 | + android:toYDelta="0" /> | ||
| 7 | + <alpha | ||
| 8 | + android:duration="200" | ||
| 9 | + android:fromAlpha="0.0" | ||
| 10 | + android:toAlpha="1.0" /> | ||
| 11 | +</set> | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
app/src/main/res/anim/pop_exit_anim.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <translate | ||
| 4 | + android:duration="200" | ||
| 5 | + android:fromYDelta="0" | ||
| 6 | + android:toYDelta="50%p" /> | ||
| 7 | + <alpha | ||
| 8 | + android:duration="200" | ||
| 9 | + android:fromAlpha="1.0" | ||
| 10 | + android:toAlpha="0.0" /> | ||
| 11 | +</set> | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
app/src/main/res/color/keycode_text_color.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:state_selected="true" android:color="@color/text_white_color" /> | ||
| 4 | + <item android:state_pressed="true" android:color="@color/text_white_color" /> | ||
| 5 | + <item android:state_focused="true" android:color="@color/text_white_color" /> | ||
| 6 | + <item android:color="@color/ff4e51" /> | ||
| 7 | +</selector> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/src/main/res/drawable-hdpi/btn_cancel_nor.png
0 → 100644
1.63 KB
app/src/main/res/drawable-hdpi/btn_cancel_sel.png
0 → 100644
1.63 KB
app/src/main/res/drawable-hdpi/btn_list_arrows_nor.png
0 → 100644
1.32 KB
app/src/main/res/drawable-hdpi/btn_list_arrows_sel.png
0 → 100644
1.32 KB
app/src/main/res/drawable-hdpi/btn_return.png
0 → 100644
2.38 KB
app/src/main/res/drawable-hdpi/cnlive_user_header.png
0 → 100644
6.29 KB
app/src/main/res/drawable-hdpi/ic_header.png
0 → 100644
6.29 KB
app/src/main/res/drawable-hdpi/ic_meiyan.png
0 → 100644
4.49 KB
app/src/main/res/drawable-hdpi/ic_meiyan_on.png
0 → 100644
5.06 KB
app/src/main/res/drawable-hdpi/ic_meiyan_on_sel.png
0 → 100644
4.42 KB
app/src/main/res/drawable-hdpi/ic_meiyan_sel.png
0 → 100644
4.09 KB
app/src/main/res/drawable-hdpi/user_micro_blog.png
0 → 100644
4.43 KB
app/src/main/res/drawable-hdpi/user_micro_blog_click.png
0 → 100644
4.51 KB
app/src/main/res/drawable-hdpi/user_qq.png
0 → 100644
3.35 KB
app/src/main/res/drawable-hdpi/user_qq_click.png
0 → 100644
3.4 KB
app/src/main/res/drawable-hdpi/user_wechat.png
0 → 100644
3.85 KB
app/src/main/res/drawable-hdpi/user_wechat_click.png
0 → 100644
3.88 KB
app/src/main/res/drawable-mdpi/ic_meiyan.png
0 → 100644
2.45 KB
app/src/main/res/drawable-mdpi/ic_meiyan_on.png
0 → 100644
2.8 KB
app/src/main/res/drawable-mdpi/ic_meiyan_on_sel.png
0 → 100644
2.45 KB
app/src/main/res/drawable-mdpi/ic_meiyan_sel.png
0 → 100644
2.26 KB
app/src/main/res/drawable-xhdpi/btn_agree_nor.png
0 → 100644
2.17 KB
app/src/main/res/drawable-xhdpi/btn_agree_sel.png
0 → 100644
2.41 KB
app/src/main/res/drawable-xhdpi/ic_meiyan.png
0 → 100644
6.04 KB
app/src/main/res/drawable-xhdpi/ic_meiyan_on.png
0 → 100644
6.82 KB
app/src/main/res/drawable-xhdpi/ic_meiyan_on_sel.png
0 → 100644
6.03 KB
app/src/main/res/drawable-xhdpi/ic_meiyan_sel.png
0 → 100644
5.55 KB
app/src/main/res/drawable-xhdpi/ic_web_forward.png
0 → 100644
831 Bytes
app/src/main/res/drawable-xhdpi/ic_web_forward_pressed.png
0 → 100644
831 Bytes
app/src/main/res/drawable-xhdpi/list_item_image_load_fail.png
0 → 100644
1.68 KB
app/src/main/res/drawable-xxhdpi/about_us.9.png
0 → 100644
2.04 KB
app/src/main/res/drawable-xxhdpi/about_us_icon.png
0 → 100644
10.3 KB
app/src/main/res/drawable-xxhdpi/btn_share_pengyouquan_nor.png
0 → 100644
5.37 KB
app/src/main/res/drawable-xxhdpi/btn_share_pengyouquan_sel.png
0 → 100644
5.45 KB
app/src/main/res/drawable-xxhdpi/btn_share_sina_nor.png
0 → 100644
5.04 KB
app/src/main/res/drawable-xxhdpi/btn_share_sina_sel.png
0 → 100644
5.21 KB
app/src/main/res/drawable-xxhdpi/btn_share_tengxun_nor.png
0 → 100644
4.84 KB
app/src/main/res/drawable-xxhdpi/btn_share_tengxun_sel.png
0 → 100644
5.22 KB
app/src/main/res/drawable-xxhdpi/btn_share_weixin_nor.png
0 → 100644
4.54 KB
app/src/main/res/drawable-xxhdpi/btn_share_weixin_sel.png
0 → 100644
4.6 KB
app/src/main/res/drawable-xxhdpi/ic_config_download.png
0 → 100644
1.15 KB
app/src/main/res/drawable-xxhdpi/ic_config_favorite.png
0 → 100644
1.99 KB
app/src/main/res/drawable-xxhdpi/ic_config_history.png
0 → 100644
1.89 KB
app/src/main/res/drawable-xxhdpi/ic_config_setting.png
0 → 100644
2.21 KB
app/src/main/res/drawable-xxhdpi/ic_meiyan.png
0 → 100644
11.1 KB
app/src/main/res/drawable-xxhdpi/ic_meiyan_on.png
0 → 100644
12.5 KB
app/src/main/res/drawable-xxhdpi/ic_meiyan_on_sel.png
0 → 100644
11.1 KB
app/src/main/res/drawable-xxhdpi/ic_meiyan_sel.png
0 → 100644
10.1 KB
app/src/main/res/drawable-xxhdpi/ic_setting_about.png
0 → 100644
1.88 KB
app/src/main/res/drawable-xxhdpi/ic_setting_clear.png
0 → 100644
1.35 KB
app/src/main/res/drawable-xxhdpi/ic_setting_help.png
0 → 100644
2.21 KB
app/src/main/res/drawable-xxhdpi/ic_setting_opinion.png
0 → 100644
2.16 KB
app/src/main/res/drawable-xxhdpi/icon_record_meiyan_off.png deleted
100644 → 0
4.48 KB
app/src/main/res/drawable-xxhdpi/icon_record_meiyan_on.png deleted
100644 → 0
6.14 KB
app/src/main/res/drawable-xxhdpi/share_btn_qq_nor.png
0 → 100644
3.72 KB
app/src/main/res/drawable-xxhdpi/share_btn_qq_sel.png
0 → 100644
4.57 KB
app/src/main/res/drawable-xxhdpi/switch_close.png
0 → 100644
2.77 KB
app/src/main/res/drawable-xxhdpi/switch_open.png
0 → 100644
2.49 KB
app/src/main/res/drawable-xxhdpi/test_layout_tost_bg.9.png
0 → 100644
362 Bytes
app/src/main/res/drawable-xxxhdpi/ic_meiyan.png
0 → 100644
15.7 KB
app/src/main/res/drawable-xxxhdpi/ic_meiyan_on.png
0 → 100644
17.7 KB
app/src/main/res/drawable-xxxhdpi/ic_meiyan_on_sel.png
0 → 100644
15.8 KB
app/src/main/res/drawable-xxxhdpi/ic_meiyan_sel.png
0 → 100644
14.4 KB
app/src/main/res/drawable/agree_selector.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:state_checked="true" android:drawable="@drawable/btn_agree_sel" /> | ||
| 4 | + <item android:state_checked="false" android:drawable="@drawable/btn_agree_nor" /> | ||
| 5 | +</selector> |
app/src/main/res/drawable/btn_cancel.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:drawable="@drawable/btn_cancel_sel" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@drawable/btn_cancel_nor" android:state_pressed="false" /> | ||
| 6 | +</selector> | ||
| 0 | \ No newline at end of file | 7 | \ No newline at end of file |
app/src/main/res/drawable/btn_channel_more.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:state_pressed="true" android:drawable="@drawable/btn_list_arrows_sel" /> | ||
| 5 | + <item android:state_pressed="false" android:drawable="@drawable/btn_list_arrows_nor" /> | ||
| 6 | + | ||
| 7 | +</selector> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/src/main/res/drawable/downloading_progress_bar.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 5 | + | ||
| 6 | + <item android:id="@android:id/background"> | ||
| 7 | + <shape> | ||
| 8 | + <corners android:radius="5dip" /> | ||
| 9 | + <gradient | ||
| 10 | + android:startColor="#D5D5D5" | ||
| 11 | + android:centerColor="#D5D5D5" | ||
| 12 | + android:endColor="#D5D5D5" /> | ||
| 13 | + </shape> | ||
| 14 | + </item> | ||
| 15 | + | ||
| 16 | + <item android:id="@android:id/progress"> | ||
| 17 | + <clip> | ||
| 18 | + <shape> | ||
| 19 | + <corners android:radius="5dip" /> | ||
| 20 | + <gradient | ||
| 21 | + android:startColor="@color/ff4e51" | ||
| 22 | + android:centerColor="@color/ff4e51" | ||
| 23 | + android:endColor="@color/ff4e51" /> | ||
| 24 | + </shape> | ||
| 25 | + </clip> | ||
| 26 | + </item> | ||
| 27 | + | ||
| 28 | +</layer-list> |
app/src/main/res/drawable/icon_record_meiyan.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:drawable="@drawable/ic_meiyan_sel" android:state_pressed="true" /> | ||
| 4 | + <item android:drawable="@drawable/ic_meiyan" android:state_pressed="false" /> | ||
| 5 | +</selector> | ||
| 0 | \ No newline at end of file | 6 | \ No newline at end of file |
app/src/main/res/drawable/icon_record_meiyan_on.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:drawable="@drawable/ic_meiyan_on_sel" android:state_pressed="true" /> | ||
| 4 | + <item android:drawable="@drawable/ic_meiyan_on" android:state_pressed="false" /> | ||
| 5 | +</selector> | ||
| 0 | \ No newline at end of file | 6 | \ No newline at end of file |
app/src/main/res/drawable/list_item_selector.xml
0 → 100644
| 1 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 2 | + | ||
| 3 | + <item android:drawable="@color/gray_line_color" android:state_enabled="false" android:state_focused="true" /> | ||
| 4 | + <item android:drawable="@color/gray_line_color" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@color/gray_line_color" android:state_focused="true" /> | ||
| 6 | + <item android:drawable="@android:color/white" /> | ||
| 7 | + | ||
| 8 | +</selector> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/drawable/share_btn_qq.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:state_pressed="true" android:drawable="@drawable/btn_share_tengxun_sel" /> | ||
| 5 | + <item android:state_pressed="false" android:drawable="@drawable/btn_share_tengxun_nor" /> | ||
| 6 | +</selector> | ||
| 0 | \ No newline at end of file | 7 | \ No newline at end of file |
app/src/main/res/drawable/share_btn_sina.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:state_pressed="true" android:drawable="@drawable/btn_share_sina_sel" /> | ||
| 5 | + <item android:state_pressed="false" android:drawable="@drawable/btn_share_sina_nor" /> | ||
| 6 | +</selector> | ||
| 0 | \ No newline at end of file | 7 | \ No newline at end of file |
app/src/main/res/drawable/share_btn_tencent.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:drawable="@drawable/share_btn_qq_sel" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@drawable/share_btn_qq_nor" android:state_pressed="false" /> | ||
| 6 | +</selector> | ||
| 0 | \ No newline at end of file | 7 | \ No newline at end of file |
app/src/main/res/drawable/share_btn_weixin.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:state_pressed="true" android:drawable="@drawable/btn_share_weixin_sel" /> | ||
| 5 | + <item android:state_pressed="false" android:drawable="@drawable/btn_share_weixin_nor" /> | ||
| 6 | +</selector> | ||
| 0 | \ No newline at end of file | 7 | \ No newline at end of file |
app/src/main/res/drawable/toolbar_bg.9.png
0 → 100644
94 Bytes
app/src/main/res/drawable/user_btn_keycode_nor.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + | ||
| 7 | + <size | ||
| 8 | + android:height="30dp" /> | ||
| 9 | + | ||
| 10 | + <corners | ||
| 11 | + android:bottomLeftRadius="15dp" | ||
| 12 | + android:bottomRightRadius="15dp" | ||
| 13 | + android:topLeftRadius="15dp" | ||
| 14 | + android:topRightRadius="15dp" /> <!-- 设置四个角的半径 --> | ||
| 15 | + | ||
| 16 | + <stroke | ||
| 17 | + android:width="2dp" | ||
| 18 | + android:color="@color/ff4e51" /> <!-- 定义描边的宽度和描边的颜色值 --> | ||
| 19 | + | ||
| 20 | +</shape> | ||
| 0 | \ No newline at end of file | 21 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_keycode_sel.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="#ea002a" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:height="30dp" /> | ||
| 10 | + | ||
| 11 | + <corners | ||
| 12 | + android:bottomLeftRadius="15dp" | ||
| 13 | + android:bottomRightRadius="15dp" | ||
| 14 | + android:topLeftRadius="15dp" | ||
| 15 | + android:topRightRadius="15dp" /> <!-- 设置四个角的半径 --> | ||
| 16 | + | ||
| 17 | +</shape> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_login.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <item android:state_selected="true" android:drawable="@drawable/user_btn_login_sel" /> | ||
| 5 | + <item android:state_pressed="true" android:drawable="@drawable/user_btn_login_sel" /> | ||
| 6 | + <item android:state_focused="true" android:drawable="@drawable/user_btn_login_sel" /> | ||
| 7 | + <item android:state_checked="false" android:drawable="@drawable/user_btn_login_nor" /> | ||
| 8 | + | ||
| 9 | +</selector> | ||
| 0 | \ No newline at end of file | 10 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_login_nor.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="@color/ff4e51" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:height="40dp" /> | ||
| 10 | + | ||
| 11 | + <corners | ||
| 12 | + android:bottomLeftRadius="20dp" | ||
| 13 | + android:bottomRightRadius="20dp" | ||
| 14 | + android:topLeftRadius="20dp" | ||
| 15 | + android:topRightRadius="20dp" /> <!-- 设置四个角的半径 --> | ||
| 16 | + | ||
| 17 | +</shape> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_login_sel.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="#ea002a" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:height="40dp" /> | ||
| 10 | + | ||
| 11 | + <corners | ||
| 12 | + android:bottomLeftRadius="20dp" | ||
| 13 | + android:bottomRightRadius="20dp" | ||
| 14 | + android:topLeftRadius="20dp" | ||
| 15 | + android:topRightRadius="20dp" /> <!-- 设置四个角的半径 --> | ||
| 16 | + | ||
| 17 | +</shape> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_logout.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <item android:state_selected="true" android:drawable="@drawable/user_btn_logout_sel" /> | ||
| 5 | + <item android:state_pressed="true" android:drawable="@drawable/user_btn_logout_sel" /> | ||
| 6 | + <item android:state_focused="true" android:drawable="@drawable/user_btn_logout_sel" /> | ||
| 7 | + <item android:state_checked="false" android:drawable="@drawable/user_btn_logout_nor" /> | ||
| 8 | + | ||
| 9 | +</selector> | ||
| 0 | \ No newline at end of file | 10 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_logout_nor.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="@color/text_hint_color" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:height="40dp" /> | ||
| 10 | + | ||
| 11 | + <corners | ||
| 12 | + android:bottomLeftRadius="20dp" | ||
| 13 | + android:bottomRightRadius="20dp" | ||
| 14 | + android:topLeftRadius="20dp" | ||
| 15 | + android:topRightRadius="20dp" /> <!-- 设置四个角的半径 --> | ||
| 16 | + | ||
| 17 | +</shape> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_logout_sel.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="rectangle" | ||
| 5 | + android:useLevel="false"> | ||
| 6 | + <solid android:color="#6e6e6e" /> | ||
| 7 | + | ||
| 8 | + <size | ||
| 9 | + android:height="40dp" /> | ||
| 10 | + | ||
| 11 | + <corners | ||
| 12 | + android:bottomLeftRadius="20dp" | ||
| 13 | + android:bottomRightRadius="20dp" | ||
| 14 | + android:topLeftRadius="20dp" | ||
| 15 | + android:topRightRadius="20dp" /> <!-- 设置四个角的半径 --> | ||
| 16 | + | ||
| 17 | +</shape> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
app/src/main/res/drawable/user_btn_verification.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:state_selected="true" android:drawable="@drawable/user_btn_keycode_sel" /> | ||
| 4 | + <item android:state_pressed="true" android:drawable="@drawable/user_btn_keycode_sel" /> | ||
| 5 | + <item android:state_focused="true" android:drawable="@drawable/user_btn_keycode_sel" /> | ||
| 6 | + <item android:drawable="@drawable/user_btn_keycode_nor" /> | ||
| 7 | +</selector> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/src/main/res/drawable/user_micro_blog_selector.xml
0 → 100644
| 1 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 2 | + | ||
| 3 | + <item android:drawable="@drawable/user_micro_blog" android:state_enabled="false" android:state_focused="true" /> | ||
| 4 | + <item android:drawable="@drawable/user_micro_blog" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@drawable/user_micro_blog" android:state_focused="true" /> | ||
| 6 | + <item android:drawable="@drawable/user_micro_blog_click" /> | ||
| 7 | + | ||
| 8 | +</selector> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/drawable/user_qq_selector.xml
0 → 100644
| 1 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 2 | + | ||
| 3 | + <item android:drawable="@drawable/user_qq" android:state_enabled="false" android:state_focused="true" /> | ||
| 4 | + <item android:drawable="@drawable/user_qq" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@drawable/user_qq" android:state_focused="true" /> | ||
| 6 | + <item android:drawable="@drawable/user_qq_click" /> | ||
| 7 | + | ||
| 8 | +</selector> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/drawable/user_wechat_selector.xml
0 → 100644
| 1 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 2 | + | ||
| 3 | + <item android:drawable="@drawable/user_wechat" android:state_enabled="false" android:state_focused="true" /> | ||
| 4 | + <item android:drawable="@drawable/user_wechat" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@drawable/user_wechat" android:state_focused="true" /> | ||
| 6 | + <item android:drawable="@drawable/user_wechat_click" /> | ||
| 7 | + | ||
| 8 | +</selector> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/layout/activity_login.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | + android:id="@+id/login_fragment" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="match_parent" | ||
| 8 | + tools:context=".ui.activity.UserActivity"> | ||
| 9 | + | ||
| 10 | +</RelativeLayout> | ||
| 11 | +</layout> | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
app/src/main/res/layout/activity_stream_portrait.xml
| @@ -162,7 +162,7 @@ | @@ -162,7 +162,7 @@ | ||
| 162 | android:onClick="onClick" | 162 | android:onClick="onClick" |
| 163 | android:padding="5dp" | 163 | android:padding="5dp" |
| 164 | android:scaleType="fitCenter" | 164 | android:scaleType="fitCenter" |
| 165 | - android:src="@{isShow.beautifulBtn ? @drawable/icon_record_meiyan_on : @drawable/icon_record_meiyan_off}" /> | 165 | + android:src="@{isShow.beautifulBtn ? @drawable/icon_record_meiyan_on : @drawable/icon_record_meiyan}" /> |
| 166 | 166 | ||
| 167 | <ImageButton | 167 | <ImageButton |
| 168 | android:id="@+id/btn_flip" | 168 | android:id="@+id/btn_flip" |
app/src/main/res/layout/divider_head_line.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:id="@+id/catalog" | ||
| 4 | + android:layout_width="match_parent" | ||
| 5 | + android:layout_height="wrap_content" | ||
| 6 | + android:orientation="vertical"> | ||
| 7 | + | ||
| 8 | + <View | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="@dimen/divider_height"/> | ||
| 11 | + | ||
| 12 | + <ImageView | ||
| 13 | + android:id="@+id/bottom_line" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="1px" | ||
| 16 | + android:background="@color/gray_line_color" | ||
| 17 | + android:contentDescription="@null" /> | ||
| 18 | +</LinearLayout> | ||
| 0 | \ No newline at end of file | 19 | \ No newline at end of file |
app/src/main/res/layout/fragment_login.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | + <ScrollView | ||
| 5 | + android:id="@+id/detail_view" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="match_parent"> | ||
| 8 | + | ||
| 9 | + <RelativeLayout | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="match_parent"> | ||
| 12 | + | ||
| 13 | + <LinearLayout | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="wrap_content" | ||
| 16 | + android:orientation="vertical"> | ||
| 17 | + | ||
| 18 | + <include layout="@layout/user_toolbar_title" | ||
| 19 | + android:id="@+id/loginIncludeLayout"/> | ||
| 20 | + | ||
| 21 | + <View | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="1px" | ||
| 24 | + android:layout_marginTop="6dp" | ||
| 25 | + android:background="@color/gray_line_color" /> | ||
| 26 | + | ||
| 27 | + <LinearLayout | ||
| 28 | + android:layout_width="match_parent" | ||
| 29 | + android:layout_height="wrap_content" | ||
| 30 | + android:background="@android:color/white" | ||
| 31 | + android:orientation="vertical"> | ||
| 32 | + | ||
| 33 | + <LinearLayout | ||
| 34 | + android:layout_width="match_parent" | ||
| 35 | + android:layout_height="wrap_content" | ||
| 36 | + android:gravity="center_vertical" | ||
| 37 | + android:orientation="horizontal"> | ||
| 38 | + | ||
| 39 | + <TextView | ||
| 40 | + style="@style/LoginNameStyle" | ||
| 41 | + android:layout_width="wrap_content" | ||
| 42 | + android:layout_height="wrap_content" | ||
| 43 | + android:text="@string/user_login_account" /> | ||
| 44 | + | ||
| 45 | + <EditText | ||
| 46 | + android:id="@+id/edt_login_number" | ||
| 47 | + style="@style/LoginContentStyle" | ||
| 48 | + android:layout_width="match_parent" | ||
| 49 | + android:layout_height="match_parent" | ||
| 50 | + android:hint="@string/user_login_account_hint" | ||
| 51 | + /> | ||
| 52 | + </LinearLayout> | ||
| 53 | + | ||
| 54 | + <View | ||
| 55 | + android:layout_width="match_parent" | ||
| 56 | + android:layout_height="1px" | ||
| 57 | + android:layout_marginLeft="10dp" | ||
| 58 | + android:layout_marginRight="10dp" | ||
| 59 | + android:background="@color/gray_line_color" /> | ||
| 60 | + | ||
| 61 | + <LinearLayout | ||
| 62 | + android:layout_width="match_parent" | ||
| 63 | + android:layout_height="wrap_content" | ||
| 64 | + android:gravity="center_vertical" | ||
| 65 | + android:orientation="horizontal"> | ||
| 66 | + | ||
| 67 | + <TextView | ||
| 68 | + style="@style/LoginNameStyle" | ||
| 69 | + android:layout_width="wrap_content" | ||
| 70 | + android:layout_height="wrap_content" | ||
| 71 | + android:text="@string/user_login_code" /> | ||
| 72 | + | ||
| 73 | + <EditText | ||
| 74 | + android:id="@+id/edt_input_passward" | ||
| 75 | + style="@style/LoginContentStyle" | ||
| 76 | + android:layout_width="match_parent" | ||
| 77 | + android:layout_height="match_parent" | ||
| 78 | + android:hint="@string/user_login_code_hint" | ||
| 79 | + android:inputType="textPassword" | ||
| 80 | + /> | ||
| 81 | + </LinearLayout> | ||
| 82 | + </LinearLayout> | ||
| 83 | + | ||
| 84 | + <View | ||
| 85 | + android:layout_width="match_parent" | ||
| 86 | + android:layout_height="1px" | ||
| 87 | + android:background="@color/gray_line_color" /> | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + <RelativeLayout | ||
| 91 | + android:layout_width="match_parent" | ||
| 92 | + android:layout_height="wrap_content" | ||
| 93 | + android:layout_marginTop="24dp" | ||
| 94 | + android:orientation="horizontal" | ||
| 95 | + android:paddingLeft="10dp" | ||
| 96 | + android:paddingRight="10dp"> | ||
| 97 | + | ||
| 98 | + <TextView | ||
| 99 | + android:id="@+id/tv_forgot_pwd" | ||
| 100 | + android:layout_width="wrap_content" | ||
| 101 | + android:layout_height="wrap_content" | ||
| 102 | + android:gravity="center_vertical" | ||
| 103 | + android:paddingBottom="5dp" | ||
| 104 | + android:paddingTop="5dp" | ||
| 105 | + android:text="@string/user_login_recall_code" | ||
| 106 | + android:onClick="onClick" | ||
| 107 | + android:textColor="@color/text_hint_color" | ||
| 108 | + android:textSize="15sp" /> | ||
| 109 | + | ||
| 110 | + <TextView | ||
| 111 | + android:id="@+id/btn_qucik_login" | ||
| 112 | + android:layout_width="wrap_content" | ||
| 113 | + android:layout_height="wrap_content" | ||
| 114 | + android:layout_alignParentRight="true" | ||
| 115 | + android:gravity="center_vertical" | ||
| 116 | + android:paddingBottom="5dp" | ||
| 117 | + android:paddingTop="5dp" | ||
| 118 | + android:text="@string/string_fast_access" | ||
| 119 | + android:onClick="onClick" | ||
| 120 | + android:textColor="@color/ff4e51" | ||
| 121 | + android:textSize="15sp" /> | ||
| 122 | + </RelativeLayout> | ||
| 123 | + | ||
| 124 | + <Button | ||
| 125 | + android:id="@+id/btn_login" | ||
| 126 | + style="@style/LoginButtonStyle" | ||
| 127 | + android:layout_width="match_parent" | ||
| 128 | + android:layout_height="wrap_content" | ||
| 129 | + android:layout_marginTop="59dp" | ||
| 130 | + android:background="@drawable/user_btn_login" | ||
| 131 | + android:gravity="center" | ||
| 132 | + android:onClick="onClick" | ||
| 133 | + android:text="@string/user_login" /> | ||
| 134 | + | ||
| 135 | + | ||
| 136 | + <TextView | ||
| 137 | + android:id="@+id/login_text" | ||
| 138 | + android:layout_width="match_parent" | ||
| 139 | + android:layout_height="wrap_content" | ||
| 140 | + android:layout_marginTop="100dp" | ||
| 141 | + android:gravity="center_horizontal" | ||
| 142 | + android:text="@string/user_login_third_part_login" | ||
| 143 | + android:textColor="@color/text_hint_color" | ||
| 144 | + android:textSize="15sp" /> | ||
| 145 | + | ||
| 146 | + <LinearLayout | ||
| 147 | + android:layout_width="match_parent" | ||
| 148 | + android:layout_height="wrap_content" | ||
| 149 | + android:layout_marginBottom="37dp" | ||
| 150 | + android:layout_marginTop="15dp" | ||
| 151 | + android:orientation="horizontal"> | ||
| 152 | + | ||
| 153 | + <LinearLayout | ||
| 154 | + android:layout_width="0dp" | ||
| 155 | + android:layout_height="wrap_content" | ||
| 156 | + android:layout_weight="1" | ||
| 157 | + android:gravity="center" | ||
| 158 | + android:orientation="vertical"> | ||
| 159 | + | ||
| 160 | + <ImageView | ||
| 161 | + android:id="@+id/rbtn_login_wechat" | ||
| 162 | + android:layout_width="50dp" | ||
| 163 | + android:layout_height="50dp" | ||
| 164 | + android:src="@drawable/share_btn_weixin" | ||
| 165 | + android:onClick="onClick" | ||
| 166 | + android:layout_marginBottom="4dp"/> | ||
| 167 | + | ||
| 168 | + <TextView | ||
| 169 | + android:layout_width="wrap_content" | ||
| 170 | + android:layout_height="wrap_content" | ||
| 171 | + android:text="@string/third_login_weixin" | ||
| 172 | + android:textColor="@color/text_hint_color" | ||
| 173 | + android:textSize="12sp" /> | ||
| 174 | + | ||
| 175 | + </LinearLayout> | ||
| 176 | + | ||
| 177 | + <LinearLayout | ||
| 178 | + android:layout_width="0dp" | ||
| 179 | + android:layout_height="wrap_content" | ||
| 180 | + android:layout_weight="1" | ||
| 181 | + android:gravity="center" | ||
| 182 | + android:orientation="vertical"> | ||
| 183 | + | ||
| 184 | + <ImageView | ||
| 185 | + android:id="@+id/rbtn_login_qq" | ||
| 186 | + android:layout_width="50dp" | ||
| 187 | + android:layout_height="50dp" | ||
| 188 | + android:src="@drawable/share_btn_tencent" | ||
| 189 | + android:onClick="onClick" | ||
| 190 | + android:layout_marginBottom="4dp"/> | ||
| 191 | + | ||
| 192 | + <TextView | ||
| 193 | + android:layout_width="wrap_content" | ||
| 194 | + android:layout_height="wrap_content" | ||
| 195 | + android:text="@string/third_login_qq" | ||
| 196 | + android:textColor="@color/text_hint_color" | ||
| 197 | + android:textSize="12sp" /> | ||
| 198 | + | ||
| 199 | + </LinearLayout> | ||
| 200 | + | ||
| 201 | + <LinearLayout | ||
| 202 | + android:layout_width="0dp" | ||
| 203 | + android:layout_height="wrap_content" | ||
| 204 | + android:layout_weight="1" | ||
| 205 | + android:gravity="center" | ||
| 206 | + android:orientation="vertical"> | ||
| 207 | + | ||
| 208 | + <ImageView | ||
| 209 | + android:id="@+id/rbtn_login_micro_blog" | ||
| 210 | + android:layout_width="50dp" | ||
| 211 | + android:layout_height="50dp" | ||
| 212 | + android:src="@drawable/share_btn_sina" | ||
| 213 | + android:onClick="onClick" | ||
| 214 | + android:layout_marginBottom="4dp"/> | ||
| 215 | + | ||
| 216 | + <TextView | ||
| 217 | + android:layout_width="wrap_content" | ||
| 218 | + android:layout_height="wrap_content" | ||
| 219 | + android:text="@string/third_login_sina" | ||
| 220 | + android:textColor="@color/text_hint_color" | ||
| 221 | + android:textSize="12sp" /> | ||
| 222 | + | ||
| 223 | + </LinearLayout> | ||
| 224 | + | ||
| 225 | + </LinearLayout> | ||
| 226 | + | ||
| 227 | + </LinearLayout> | ||
| 228 | + | ||
| 229 | + <ImageView | ||
| 230 | + android:id="@+id/back_selector" | ||
| 231 | + android:layout_width="30dp" | ||
| 232 | + android:layout_height="30dp" | ||
| 233 | + android:layout_marginLeft="@dimen/_20px" | ||
| 234 | + android:layout_marginTop="@dimen/_28px" | ||
| 235 | + android:onClick="onClick" | ||
| 236 | + android:src="@drawable/btn_return" /> | ||
| 237 | + | ||
| 238 | + <TextView | ||
| 239 | + android:id="@+id/register" | ||
| 240 | + android:layout_width="wrap_content" | ||
| 241 | + android:layout_height="wrap_content" | ||
| 242 | + android:textSize="15sp" | ||
| 243 | + android:textColor="@color/config_black_color" | ||
| 244 | + android:layout_alignParentRight="true" | ||
| 245 | + android:layout_marginRight="@dimen/_20px" | ||
| 246 | + android:layout_marginTop="@dimen/_28px" | ||
| 247 | + android:onClick="onClick" | ||
| 248 | + android:text="注册"/> | ||
| 249 | + | ||
| 250 | + </RelativeLayout> | ||
| 251 | + | ||
| 252 | + </ScrollView> | ||
| 253 | + | ||
| 254 | +</layout> | ||
| 0 | \ No newline at end of file | 255 | \ No newline at end of file |
app/src/main/res/layout/fragment_quick_login.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + <RelativeLayout | ||
| 7 | + android:layout_width="match_parent" | ||
| 8 | + android:layout_height="match_parent"> | ||
| 9 | + | ||
| 10 | + <LinearLayout | ||
| 11 | + android:layout_width="match_parent" | ||
| 12 | + android:layout_height="match_parent" | ||
| 13 | + android:orientation="vertical"> | ||
| 14 | + | ||
| 15 | + <include layout="@layout/user_toolbar_title" | ||
| 16 | + | ||
| 17 | + android:id="@+id/quickLoginIncludeLayout"/> | ||
| 18 | + | ||
| 19 | + <View | ||
| 20 | + android:layout_width="match_parent" | ||
| 21 | + android:layout_height="1px" | ||
| 22 | + android:layout_marginTop="6dp" | ||
| 23 | + android:background="@color/gray_line_color" /> | ||
| 24 | + | ||
| 25 | + <LinearLayout | ||
| 26 | + android:layout_width="wrap_content" | ||
| 27 | + android:layout_height="wrap_content" | ||
| 28 | + android:background="@android:color/white" | ||
| 29 | + android:orientation="vertical"> | ||
| 30 | + | ||
| 31 | + <include layout="@layout/mobile_keycode_layout" | ||
| 32 | + | ||
| 33 | + android:id="@+id/quickLoginLayout"/> | ||
| 34 | + | ||
| 35 | + </LinearLayout> | ||
| 36 | + | ||
| 37 | + <View | ||
| 38 | + android:layout_width="match_parent" | ||
| 39 | + android:layout_height="1px" | ||
| 40 | + android:background="@color/gray_line_color" /> | ||
| 41 | + | ||
| 42 | + <Button | ||
| 43 | + android:id="@+id/btn_login" | ||
| 44 | + android:layout_width="match_parent" | ||
| 45 | + android:layout_height="wrap_content" | ||
| 46 | + android:layout_marginLeft="10dp" | ||
| 47 | + android:layout_marginRight="10dp" | ||
| 48 | + android:layout_marginTop="97dp" | ||
| 49 | + android:background="@drawable/user_btn_login" | ||
| 50 | + android:text="@string/user_login" | ||
| 51 | + android:gravity="center" | ||
| 52 | + style="@style/LoginButtonStyle" /> | ||
| 53 | + | ||
| 54 | + </LinearLayout> | ||
| 55 | + | ||
| 56 | + <ImageView | ||
| 57 | + android:id="@+id/back_selector" | ||
| 58 | + android:layout_width="30dp" | ||
| 59 | + android:layout_height="30dp" | ||
| 60 | + android:layout_marginLeft="@dimen/_20px" | ||
| 61 | + android:layout_marginTop="@dimen/_28px" | ||
| 62 | + android:onClick="onClick" | ||
| 63 | + android:src="@drawable/btn_return" /> | ||
| 64 | + | ||
| 65 | + </RelativeLayout> | ||
| 66 | + | ||
| 67 | +</layout> | ||
| 0 | \ No newline at end of file | 68 | \ No newline at end of file |
app/src/main/res/layout/list_item_config_header.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:orientation="vertical" android:layout_width="match_parent" | ||
| 4 | + android:layout_height="85dp"> | ||
| 5 | + | ||
| 6 | + <include layout="@layout/divider_head_line" /> | ||
| 7 | + | ||
| 8 | + <RelativeLayout | ||
| 9 | + android:id="@+id/item_layout" | ||
| 10 | + android:layout_width="fill_parent" | ||
| 11 | + android:layout_height="85dp" | ||
| 12 | + android:gravity="center_vertical" | ||
| 13 | + style="@style/list_item_style"> | ||
| 14 | + | ||
| 15 | + <ImageView | ||
| 16 | + android:id="@+id/head_img" | ||
| 17 | + android:layout_width="55dip" | ||
| 18 | + android:layout_height="55dip" | ||
| 19 | + android:layout_centerVertical="true" | ||
| 20 | + android:layout_marginLeft="11dp" | ||
| 21 | + android:layout_marginRight="16dp" /> | ||
| 22 | + | ||
| 23 | + <LinearLayout | ||
| 24 | + android:layout_width="wrap_content" | ||
| 25 | + android:layout_height="wrap_content" | ||
| 26 | + android:layout_centerVertical="true" | ||
| 27 | + android:layout_toRightOf="@+id/head_img" | ||
| 28 | + android:orientation="vertical" | ||
| 29 | + android:layout_toLeftOf="@+id/next"> | ||
| 30 | + | ||
| 31 | + <TextView | ||
| 32 | + android:id="@+id/tv_nickname" | ||
| 33 | + android:layout_width="wrap_content" | ||
| 34 | + android:layout_height="wrap_content" | ||
| 35 | + android:layout_margin="3dp" | ||
| 36 | + android:gravity="center_vertical" | ||
| 37 | + android:singleLine="true" | ||
| 38 | + android:text="@string/click_login" | ||
| 39 | + android:textColor="@color/config_black_color" | ||
| 40 | + android:textSize="17sp" /> | ||
| 41 | + <TextView | ||
| 42 | + android:id="@+id/point" | ||
| 43 | + android:layout_width="wrap_content" | ||
| 44 | + android:layout_height="wrap_content" | ||
| 45 | + android:layout_margin="3dp" | ||
| 46 | + android:text="@string/login_china_coin" | ||
| 47 | + android:textColor="@color/config_gray_color" | ||
| 48 | + android:textSize="12sp" /> | ||
| 49 | + </LinearLayout> | ||
| 50 | + | ||
| 51 | + <ImageView | ||
| 52 | + android:id="@+id/next" | ||
| 53 | + android:layout_width="@dimen/next_image_width" | ||
| 54 | + android:layout_height="@dimen/next_image_height" | ||
| 55 | + android:layout_alignParentRight="true" | ||
| 56 | + android:layout_centerVertical="true" | ||
| 57 | + android:layout_marginRight="@dimen/next_image_margin_right" | ||
| 58 | + android:contentDescription="@null" | ||
| 59 | + android:src="@drawable/btn_channel_more" /> | ||
| 60 | + </RelativeLayout> | ||
| 61 | + | ||
| 62 | + <View | ||
| 63 | + android:layout_width="match_parent" | ||
| 64 | + android:layout_height="1px" | ||
| 65 | + android:background="@color/gray_line_color" /> | ||
| 66 | + | ||
| 67 | +</LinearLayout> | ||
| 0 | \ No newline at end of file | 68 | \ No newline at end of file |
app/src/main/res/layout/mobile_keycode_layout.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | + <LinearLayout | ||
| 5 | + android:id="@+id/mobile_keycode_layout" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="wrap_content" | ||
| 8 | + android:orientation="vertical"> | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + <LinearLayout | ||
| 12 | + android:layout_width="match_parent" | ||
| 13 | + android:layout_height="51dp" | ||
| 14 | + android:gravity="center_vertical" | ||
| 15 | + android:orientation="horizontal"> | ||
| 16 | + | ||
| 17 | + <EditText | ||
| 18 | + android:id="@+id/edt_login_number" | ||
| 19 | + android:layout_width="0dp" | ||
| 20 | + android:layout_height="match_parent" | ||
| 21 | + android:layout_weight="1" | ||
| 22 | + android:hint="@string/register_mobile_hint" | ||
| 23 | + android:inputType="number" | ||
| 24 | + android:layout_marginLeft="11dp" | ||
| 25 | + style="@style/LoginContentStyle"/> | ||
| 26 | + | ||
| 27 | + <ImageButton | ||
| 28 | + android:id="@+id/delete_user_mobile" | ||
| 29 | + android:layout_width="wrap_content" | ||
| 30 | + android:layout_height="wrap_content" | ||
| 31 | + android:layout_gravity="right|center_vertical" | ||
| 32 | + android:background="@null" | ||
| 33 | + android:contentDescription="@null" | ||
| 34 | + android:src="@drawable/btn_cancel" | ||
| 35 | + android:visibility="gone" /> | ||
| 36 | + | ||
| 37 | + <TextView | ||
| 38 | + android:id="@+id/get_verify" | ||
| 39 | + android:layout_width="wrap_content" | ||
| 40 | + android:layout_height="wrap_content" | ||
| 41 | + android:layout_gravity="right|center_vertical" | ||
| 42 | + android:gravity="center" | ||
| 43 | + android:layout_marginRight="7dp" | ||
| 44 | + android:paddingLeft="10dp" | ||
| 45 | + android:paddingRight="10dp" | ||
| 46 | + android:background="@drawable/user_btn_verification" | ||
| 47 | + android:text="@string/getmobile_identify_code" | ||
| 48 | + android:textColor="@color/keycode_text_color" | ||
| 49 | + android:textSize="12sp" /> | ||
| 50 | + </LinearLayout> | ||
| 51 | + | ||
| 52 | + <View | ||
| 53 | + android:layout_width="match_parent" | ||
| 54 | + android:layout_height="1px" | ||
| 55 | + android:layout_marginLeft="10dp" | ||
| 56 | + android:layout_marginRight="10dp" | ||
| 57 | + android:background="@color/gray_line_color" /> | ||
| 58 | + | ||
| 59 | + <LinearLayout | ||
| 60 | + android:layout_width="match_parent" | ||
| 61 | + android:layout_height="51dp" | ||
| 62 | + android:gravity="center_vertical" | ||
| 63 | + android:orientation="horizontal"> | ||
| 64 | + | ||
| 65 | + <EditText | ||
| 66 | + android:id="@+id/edt_verify" | ||
| 67 | + android:layout_width="0dp" | ||
| 68 | + android:layout_height="match_parent" | ||
| 69 | + android:layout_weight="1" | ||
| 70 | + android:hint="@string/register_mobile_keycode_hint" | ||
| 71 | + android:inputType="number" | ||
| 72 | + android:layout_marginLeft="11dp" | ||
| 73 | + style="@style/LoginContentStyle"/> | ||
| 74 | + | ||
| 75 | + <ImageButton | ||
| 76 | + android:id="@+id/delete_keycode" | ||
| 77 | + android:layout_width="wrap_content" | ||
| 78 | + android:layout_height="wrap_content" | ||
| 79 | + android:layout_gravity="right|center_vertical" | ||
| 80 | + android:layout_marginRight="85dp" | ||
| 81 | + android:background="@null" | ||
| 82 | + android:contentDescription="@null" | ||
| 83 | + android:src="@drawable/btn_cancel" | ||
| 84 | + android:visibility="gone" /> | ||
| 85 | + </LinearLayout> | ||
| 86 | + | ||
| 87 | + | ||
| 88 | + </LinearLayout> | ||
| 89 | +</layout> | ||
| 0 | \ No newline at end of file | 90 | \ No newline at end of file |
app/src/main/res/layout/test_layout_toast.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent"> | ||
| 5 | + | ||
| 6 | + <RelativeLayout | ||
| 7 | + android:layout_width="wrap_content" | ||
| 8 | + android:layout_height="wrap_content" | ||
| 9 | + android:background="@drawable/test_layout_tost_bg"> | ||
| 10 | + | ||
| 11 | + <TextView | ||
| 12 | + android:id="@+id/text" | ||
| 13 | + android:layout_width="wrap_content" | ||
| 14 | + android:layout_height="wrap_content" | ||
| 15 | + android:gravity="center_vertical" | ||
| 16 | + android:layout_centerHorizontal="true" | ||
| 17 | + android:maxLines="2" | ||
| 18 | + android:paddingLeft="10dp" | ||
| 19 | + android:paddingRight="10dp" | ||
| 20 | + android:layout_marginBottom="7dp" | ||
| 21 | + android:layout_marginTop="7dp" | ||
| 22 | + android:textColor="@color/text_white_color" | ||
| 23 | + android:textSize="14sp"/> | ||
| 24 | + | ||
| 25 | + <ImageView | ||
| 26 | + android:id="@+id/image" | ||
| 27 | + android:layout_width="36dp" | ||
| 28 | + android:layout_height="36dp" | ||
| 29 | + android:layout_centerVertical="true" | ||
| 30 | + android:layout_toRightOf="@+id/text" | ||
| 31 | + android:contentDescription="@null" | ||
| 32 | + android:visibility="gone" /> | ||
| 33 | + | ||
| 34 | + </RelativeLayout> | ||
| 35 | + | ||
| 36 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
app/src/main/res/layout/user_fragment.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + > | ||
| 5 | + | ||
| 6 | + <LinearLayout | ||
| 7 | + android:layout_width="match_parent" | ||
| 8 | + android:layout_height="match_parent" | ||
| 9 | + android:orientation="vertical"> | ||
| 10 | + | ||
| 11 | + <RelativeLayout | ||
| 12 | + android:layout_width="match_parent" | ||
| 13 | + android:layout_height="100dp" | ||
| 14 | + > | ||
| 15 | + <TextView | ||
| 16 | + android:layout_width="wrap_content" | ||
| 17 | + android:layout_height="wrap_content" | ||
| 18 | + android:layout_centerInParent="true" | ||
| 19 | + android:text="我的" | ||
| 20 | + android:textSize="@dimen/_30px" | ||
| 21 | + /> | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + </RelativeLayout> | ||
| 25 | + <View | ||
| 26 | + android:layout_width="match_parent" | ||
| 27 | + android:layout_height="1px" | ||
| 28 | + android:background="@color/gray_line_color" /> | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + <RelativeLayout | ||
| 32 | + android:id="@+id/config_header" | ||
| 33 | + android:layout_width="fill_parent" | ||
| 34 | + android:layout_height="85dp" | ||
| 35 | + android:gravity="center_vertical" | ||
| 36 | + style="@style/list_item_style"> | ||
| 37 | + | ||
| 38 | + <ImageView | ||
| 39 | + android:id="@+id/head_img" | ||
| 40 | + android:layout_width="55dip" | ||
| 41 | + android:layout_height="55dip" | ||
| 42 | + android:layout_centerVertical="true" | ||
| 43 | + android:layout_marginLeft="11dp" | ||
| 44 | + android:layout_marginRight="16dp" /> | ||
| 45 | + | ||
| 46 | + <LinearLayout | ||
| 47 | + android:layout_width="wrap_content" | ||
| 48 | + android:layout_height="wrap_content" | ||
| 49 | + android:layout_centerVertical="true" | ||
| 50 | + android:layout_toRightOf="@+id/head_img" | ||
| 51 | + android:orientation="vertical" | ||
| 52 | + android:layout_toLeftOf="@+id/next"> | ||
| 53 | + | ||
| 54 | + <TextView | ||
| 55 | + android:id="@+id/tv_nickname" | ||
| 56 | + android:layout_width="wrap_content" | ||
| 57 | + android:layout_height="wrap_content" | ||
| 58 | + android:layout_margin="3dp" | ||
| 59 | + android:gravity="center_vertical" | ||
| 60 | + android:singleLine="true" | ||
| 61 | + android:text="@string/click_login" | ||
| 62 | + android:textColor="@color/config_black_color" | ||
| 63 | + android:textSize="17sp" /> | ||
| 64 | + <TextView | ||
| 65 | + android:id="@+id/point" | ||
| 66 | + android:layout_width="wrap_content" | ||
| 67 | + android:layout_height="wrap_content" | ||
| 68 | + android:layout_margin="3dp" | ||
| 69 | + android:text="@string/login_china_coin" | ||
| 70 | + android:textColor="@color/config_gray_color" | ||
| 71 | + android:textSize="12sp" /> | ||
| 72 | + </LinearLayout> | ||
| 73 | + | ||
| 74 | + <ImageView | ||
| 75 | + android:id="@+id/next" | ||
| 76 | + android:layout_width="@dimen/next_image_width" | ||
| 77 | + android:layout_height="@dimen/next_image_height" | ||
| 78 | + android:layout_alignParentRight="true" | ||
| 79 | + android:layout_centerVertical="true" | ||
| 80 | + android:layout_marginRight="@dimen/next_image_margin_right" | ||
| 81 | + android:contentDescription="@null" | ||
| 82 | + android:src="@drawable/btn_channel_more" /> | ||
| 83 | + </RelativeLayout> | ||
| 84 | + | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + | ||
| 88 | + | ||
| 89 | + <RelativeLayout | ||
| 90 | + android:layout_width="match_parent" | ||
| 91 | + android:layout_height="30dp" | ||
| 92 | + android:id="@+id/live" | ||
| 93 | + style="@style/list_item_style"> | ||
| 94 | + <ImageView | ||
| 95 | + android:layout_width="20dp" | ||
| 96 | + android:layout_height="20dp" | ||
| 97 | + android:id="@+id/ic_config_history" | ||
| 98 | + android:layout_centerVertical="true" | ||
| 99 | + android:src="@drawable/ic_config_history"/> | ||
| 100 | + <TextView | ||
| 101 | + android:layout_width="wrap_content" | ||
| 102 | + android:layout_height="wrap_content" | ||
| 103 | + android:layout_centerVertical="true" | ||
| 104 | + android:layout_toRightOf="@+id/ic_config_history" | ||
| 105 | + android:layout_marginLeft="20dp" | ||
| 106 | + android:text="我要直播"/> | ||
| 107 | + </RelativeLayout> | ||
| 108 | + <View | ||
| 109 | + android:layout_width="match_parent" | ||
| 110 | + android:layout_height="1px" | ||
| 111 | + android:background="@color/gray_line_color" /> | ||
| 112 | + <RelativeLayout | ||
| 113 | + android:layout_width="match_parent" | ||
| 114 | + android:layout_height="30dp" | ||
| 115 | + android:id="@+id/message" | ||
| 116 | + style="@style/list_item_style"> | ||
| 117 | + | ||
| 118 | + <ImageView | ||
| 119 | + android:layout_width="20dp" | ||
| 120 | + android:layout_height="20dp" | ||
| 121 | + android:layout_centerVertical="true" | ||
| 122 | + android:id="@+id/ic_setting_opinion" | ||
| 123 | + android:src="@drawable/ic_setting_opinion"/> | ||
| 124 | + <TextView | ||
| 125 | + android:layout_width="wrap_content" | ||
| 126 | + android:layout_height="wrap_content" | ||
| 127 | + android:layout_centerVertical="true" | ||
| 128 | + android:layout_toRightOf="@+id/ic_setting_opinion" | ||
| 129 | + android:layout_marginLeft="20dp" | ||
| 130 | + android:text="意见反馈"/> | ||
| 131 | + | ||
| 132 | + </RelativeLayout> | ||
| 133 | + | ||
| 134 | + | ||
| 135 | + </LinearLayout> | ||
| 136 | +</layout> | ||
| 137 | + |
app/src/main/res/layout/user_fragment_find.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | + <RelativeLayout | ||
| 5 | + android:id="@+id/detail_view" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="match_parent"> | ||
| 8 | + | ||
| 9 | + <LinearLayout | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:orientation="vertical"> | ||
| 13 | + | ||
| 14 | + <include layout="@layout/user_toolbar_title" | ||
| 15 | + android:id="@+id/findPasswordIncludeLayout"/> | ||
| 16 | + | ||
| 17 | + <include layout="@layout/divider_head_line" /> | ||
| 18 | + | ||
| 19 | + <LinearLayout | ||
| 20 | + android:layout_width="match_parent" | ||
| 21 | + android:layout_height="wrap_content" | ||
| 22 | + android:background="@android:color/white" | ||
| 23 | + android:orientation="vertical"> | ||
| 24 | + | ||
| 25 | + <include layout="@layout/mobile_keycode_layout" | ||
| 26 | + android:id="@+id/findPasswordLayout"/> | ||
| 27 | + | ||
| 28 | + <View | ||
| 29 | + android:layout_width="match_parent" | ||
| 30 | + android:layout_height="1px" | ||
| 31 | + android:layout_marginLeft="10dp" | ||
| 32 | + android:layout_marginRight="10dp" | ||
| 33 | + android:background="@color/gray_line_color" /> | ||
| 34 | + | ||
| 35 | + <LinearLayout | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="51dp" | ||
| 38 | + android:gravity="center_vertical" | ||
| 39 | + android:orientation="horizontal"> | ||
| 40 | + | ||
| 41 | + <EditText | ||
| 42 | + android:id="@+id/edt_input_passward" | ||
| 43 | + android:layout_width="match_parent" | ||
| 44 | + android:layout_height="match_parent" | ||
| 45 | + android:hint="@string/register_password_hint" | ||
| 46 | + android:inputType="textPassword" | ||
| 47 | + android:layout_marginLeft="11dp" | ||
| 48 | + style="@style/LoginContentStyle"/> | ||
| 49 | + </LinearLayout> | ||
| 50 | + | ||
| 51 | + <View | ||
| 52 | + android:layout_width="match_parent" | ||
| 53 | + android:layout_height="1px" | ||
| 54 | + android:background="@color/gray_line_color" /> | ||
| 55 | + | ||
| 56 | + <LinearLayout | ||
| 57 | + android:layout_width="match_parent" | ||
| 58 | + android:layout_height="51dp" | ||
| 59 | + android:gravity="center_vertical" | ||
| 60 | + android:orientation="horizontal"> | ||
| 61 | + | ||
| 62 | + <EditText | ||
| 63 | + android:id="@+id/edt_confirm_passward" | ||
| 64 | + android:layout_width="match_parent" | ||
| 65 | + android:layout_height="match_parent" | ||
| 66 | + android:hint="@string/find_password_hint" | ||
| 67 | + android:inputType="textPassword" | ||
| 68 | + android:layout_marginLeft="11dp" | ||
| 69 | + style="@style/LoginContentStyle"/> | ||
| 70 | + </LinearLayout> | ||
| 71 | + </LinearLayout> | ||
| 72 | + | ||
| 73 | + <CheckBox | ||
| 74 | + android:id="@+id/show_pwd" | ||
| 75 | + android:layout_width="wrap_content" | ||
| 76 | + android:layout_height="42dip" | ||
| 77 | + android:text="@string/register_show_password" | ||
| 78 | + android:textSize="16sp" | ||
| 79 | + android:visibility="gone" /> | ||
| 80 | + | ||
| 81 | + <Button | ||
| 82 | + android:id="@+id/btn_find_password" | ||
| 83 | + android:layout_width="match_parent" | ||
| 84 | + android:layout_height="wrap_content" | ||
| 85 | + android:layout_marginBottom="20dp" | ||
| 86 | + android:layout_marginLeft="10dp" | ||
| 87 | + android:layout_marginRight="10dp" | ||
| 88 | + android:background="@drawable/user_btn_logout_nor" | ||
| 89 | + android:text="@string/find_password_btn" | ||
| 90 | + android:gravity="center" | ||
| 91 | + style="@style/LoginButtonStyle"/> | ||
| 92 | + </LinearLayout> | ||
| 93 | + | ||
| 94 | + <ImageView | ||
| 95 | + android:id="@+id/back_selector" | ||
| 96 | + android:layout_width="30dp" | ||
| 97 | + android:layout_height="30dp" | ||
| 98 | + android:layout_marginLeft="@dimen/_20px" | ||
| 99 | + android:layout_marginTop="@dimen/_28px" | ||
| 100 | + android:onClick="onClick" | ||
| 101 | + android:src="@drawable/btn_return" /> | ||
| 102 | + | ||
| 103 | + </RelativeLayout> | ||
| 104 | +</layout> | ||
| 0 | \ No newline at end of file | 105 | \ No newline at end of file |
app/src/main/res/layout/user_fragment_find_password.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | + <RelativeLayout | ||
| 5 | + android:id="@+id/detail_view" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="match_parent"> | ||
| 8 | + | ||
| 9 | + <LinearLayout | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:orientation="vertical"> | ||
| 13 | + | ||
| 14 | + <include layout="@layout/user_toolbar_title" | ||
| 15 | + android:id="@+id/findPasswordIncludeLayout"/> | ||
| 16 | + | ||
| 17 | + <include layout="@layout/divider_head_line" /> | ||
| 18 | + | ||
| 19 | + <LinearLayout | ||
| 20 | + android:layout_width="match_parent" | ||
| 21 | + android:layout_height="wrap_content" | ||
| 22 | + android:background="@android:color/white" | ||
| 23 | + android:orientation="vertical"> | ||
| 24 | + | ||
| 25 | + <include layout="@layout/mobile_keycode_layout" | ||
| 26 | + android:id="@+id/findPasswordLayout"/> | ||
| 27 | + | ||
| 28 | + <View | ||
| 29 | + android:layout_width="match_parent" | ||
| 30 | + android:layout_height="1px" | ||
| 31 | + android:layout_marginLeft="10dp" | ||
| 32 | + android:layout_marginRight="10dp" | ||
| 33 | + android:background="@color/gray_line_color" /> | ||
| 34 | + | ||
| 35 | + <LinearLayout | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="51dp" | ||
| 38 | + android:gravity="center_vertical" | ||
| 39 | + android:orientation="horizontal"> | ||
| 40 | + | ||
| 41 | + <EditText | ||
| 42 | + android:id="@+id/edt_input_passward" | ||
| 43 | + android:layout_width="match_parent" | ||
| 44 | + android:layout_height="match_parent" | ||
| 45 | + android:hint="@string/register_password_hint" | ||
| 46 | + android:inputType="textPassword" | ||
| 47 | + android:layout_marginLeft="11dp" | ||
| 48 | + style="@style/LoginContentStyle"/> | ||
| 49 | + </LinearLayout> | ||
| 50 | + | ||
| 51 | + <View | ||
| 52 | + android:layout_width="match_parent" | ||
| 53 | + android:layout_height="1px" | ||
| 54 | + android:background="@color/gray_line_color" /> | ||
| 55 | + | ||
| 56 | + <LinearLayout | ||
| 57 | + android:layout_width="match_parent" | ||
| 58 | + android:layout_height="51dp" | ||
| 59 | + android:gravity="center_vertical" | ||
| 60 | + android:orientation="horizontal"> | ||
| 61 | + | ||
| 62 | + <EditText | ||
| 63 | + android:id="@+id/edt_confirm_passward" | ||
| 64 | + android:layout_width="match_parent" | ||
| 65 | + android:layout_height="match_parent" | ||
| 66 | + android:hint="@string/find_password_hint" | ||
| 67 | + android:inputType="textPassword" | ||
| 68 | + android:layout_marginLeft="11dp" | ||
| 69 | + style="@style/LoginContentStyle"/> | ||
| 70 | + </LinearLayout> | ||
| 71 | + </LinearLayout> | ||
| 72 | + | ||
| 73 | + <CheckBox | ||
| 74 | + android:id="@+id/show_pwd" | ||
| 75 | + android:layout_width="wrap_content" | ||
| 76 | + android:layout_height="42dip" | ||
| 77 | + android:text="@string/register_show_password" | ||
| 78 | + android:textSize="16sp" | ||
| 79 | + android:visibility="gone" /> | ||
| 80 | + | ||
| 81 | + <Button | ||
| 82 | + android:id="@+id/btn_find_password" | ||
| 83 | + android:layout_width="match_parent" | ||
| 84 | + android:layout_height="wrap_content" | ||
| 85 | + android:layout_marginBottom="20dp" | ||
| 86 | + android:layout_marginLeft="10dp" | ||
| 87 | + android:layout_marginRight="10dp" | ||
| 88 | + android:background="@drawable/user_btn_logout_nor" | ||
| 89 | + android:text="@string/find_password_btn" | ||
| 90 | + android:gravity="center" | ||
| 91 | + style="@style/LoginButtonStyle"/> | ||
| 92 | + </LinearLayout> | ||
| 93 | + | ||
| 94 | + <ImageView | ||
| 95 | + android:id="@+id/back_selector" | ||
| 96 | + android:layout_width="30dp" | ||
| 97 | + android:layout_height="30dp" | ||
| 98 | + android:layout_marginLeft="@dimen/_20px" | ||
| 99 | + android:layout_marginTop="@dimen/_28px" | ||
| 100 | + android:onClick="onClick" | ||
| 101 | + android:src="@drawable/btn_return" /> | ||
| 102 | + | ||
| 103 | + </RelativeLayout> | ||
| 104 | + | ||
| 105 | +</layout> | ||
| 0 | \ No newline at end of file | 106 | \ No newline at end of file |
app/src/main/res/layout/user_fragment_register.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | + <RelativeLayout | ||
| 5 | + android:id="@+id/detail_view" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="match_parent"> | ||
| 8 | + | ||
| 9 | + <LinearLayout | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:orientation="vertical"> | ||
| 13 | + | ||
| 14 | + <include layout="@layout/user_toolbar_title" | ||
| 15 | + android:id="@+id/registerIncludeLayout"/> | ||
| 16 | + | ||
| 17 | + <include layout="@layout/divider_head_line" /> | ||
| 18 | + | ||
| 19 | + <LinearLayout | ||
| 20 | + android:layout_width="match_parent" | ||
| 21 | + android:layout_height="wrap_content" | ||
| 22 | + android:background="@android:color/white" | ||
| 23 | + android:orientation="vertical"> | ||
| 24 | + | ||
| 25 | + <include layout="@layout/mobile_keycode_layout" | ||
| 26 | + | ||
| 27 | + android:id="@+id/mobileKeycodeLayout"/> | ||
| 28 | + | ||
| 29 | + <View | ||
| 30 | + android:layout_width="match_parent" | ||
| 31 | + android:layout_height="1px" | ||
| 32 | + android:layout_marginLeft="10dp" | ||
| 33 | + android:layout_marginRight="10dp" | ||
| 34 | + android:background="@color/gray_line_color" /> | ||
| 35 | + | ||
| 36 | + <LinearLayout | ||
| 37 | + android:layout_width="match_parent" | ||
| 38 | + android:layout_height="51dp" | ||
| 39 | + android:gravity="center_vertical" | ||
| 40 | + android:orientation="horizontal"> | ||
| 41 | + | ||
| 42 | + <EditText | ||
| 43 | + android:id="@+id/edt_input_passward" | ||
| 44 | + android:layout_width="match_parent" | ||
| 45 | + android:layout_height="match_parent" | ||
| 46 | + android:hint="@string/register_password_hint" | ||
| 47 | + android:inputType="textPassword" | ||
| 48 | + android:layout_marginLeft="11dp" | ||
| 49 | + style="@style/LoginContentStyle"/> | ||
| 50 | + </LinearLayout> | ||
| 51 | + | ||
| 52 | + <View | ||
| 53 | + android:layout_width="match_parent" | ||
| 54 | + android:layout_height="1px" | ||
| 55 | + android:background="@color/gray_line_color" /> | ||
| 56 | + </LinearLayout> | ||
| 57 | + | ||
| 58 | + <CheckBox | ||
| 59 | + android:id="@+id/show_pwd" | ||
| 60 | + android:layout_width="wrap_content" | ||
| 61 | + android:layout_height="42dip" | ||
| 62 | + android:text="@string/register_show_password" | ||
| 63 | + android:textSize="16sp" | ||
| 64 | + android:visibility="gone" /> | ||
| 65 | + | ||
| 66 | + <LinearLayout | ||
| 67 | + android:layout_width="match_parent" | ||
| 68 | + android:layout_height="wrap_content" | ||
| 69 | + android:layout_marginBottom="58dip" | ||
| 70 | + android:layout_marginLeft="9dp" | ||
| 71 | + android:layout_marginTop="11dp" | ||
| 72 | + android:orientation="horizontal"> | ||
| 73 | + | ||
| 74 | + <CheckBox | ||
| 75 | + android:id="@+id/checkbox" | ||
| 76 | + android:layout_width="wrap_content" | ||
| 77 | + android:layout_height="wrap_content" | ||
| 78 | + android:button="@drawable/agree_selector" | ||
| 79 | + android:checked="true" | ||
| 80 | + android:paddingLeft="7dp" | ||
| 81 | + android:text="@string/register_and_agree" | ||
| 82 | + android:textColor="@color/text_hint_color" | ||
| 83 | + android:textSize="15sp"/> | ||
| 84 | + | ||
| 85 | + <TextView | ||
| 86 | + android:id="@+id/click_text" | ||
| 87 | + android:layout_width="wrap_content" | ||
| 88 | + android:layout_height="match_parent" | ||
| 89 | + android:gravity="center_vertical" | ||
| 90 | + android:textColor="@color/text_hint_color" | ||
| 91 | + android:textSize="15sp"/> | ||
| 92 | + </LinearLayout> | ||
| 93 | + | ||
| 94 | + <Button | ||
| 95 | + android:id="@+id/btn_register" | ||
| 96 | + android:layout_width="match_parent" | ||
| 97 | + android:layout_height="wrap_content" | ||
| 98 | + android:layout_marginBottom="20dp" | ||
| 99 | + android:layout_marginLeft="10dp" | ||
| 100 | + android:layout_marginRight="10dp" | ||
| 101 | + android:background="@drawable/user_btn_logout_nor" | ||
| 102 | + android:text="@string/register_btn" | ||
| 103 | + android:gravity="center" | ||
| 104 | + style="@style/LoginButtonStyle"/> | ||
| 105 | + </LinearLayout> | ||
| 106 | + | ||
| 107 | + <ImageView | ||
| 108 | + android:id="@+id/back_selector" | ||
| 109 | + android:layout_width="30dp" | ||
| 110 | + android:layout_height="30dp" | ||
| 111 | + android:layout_marginLeft="@dimen/_20px" | ||
| 112 | + android:layout_marginTop="@dimen/_28px" | ||
| 113 | + android:onClick="onClick" | ||
| 114 | + android:src="@drawable/btn_return" /> | ||
| 115 | + | ||
| 116 | + </RelativeLayout> | ||
| 117 | +</layout> | ||
| 0 | \ No newline at end of file | 118 | \ No newline at end of file |
app/src/main/res/layout/user_toolbar_title.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + | ||
| 5 | + <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 6 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 7 | + android:id="@+id/toolbar" | ||
| 8 | + android:layout_width="match_parent" | ||
| 9 | + android:layout_height="?attr/actionBarSize" | ||
| 10 | + | ||
| 11 | + android:theme="@style/ThemeOverlay.AppCompat.Light"> | ||
| 12 | + | ||
| 13 | + <!-- <RelativeLayout | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="38dp" | ||
| 16 | + android:gravity="center_vertical" | ||
| 17 | + android:orientation="horizontal">--> | ||
| 18 | + | ||
| 19 | + <TextView | ||
| 20 | + android:id="@+id/toolbar_title" | ||
| 21 | + style="@style/ToolbarTitleStyle" | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="match_parent" | ||
| 24 | + android:layout_marginRight="15dp" | ||
| 25 | + android:gravity="center" | ||
| 26 | + android:maxLines="1" | ||
| 27 | + tools:text="here is title" /> | ||
| 28 | + | ||
| 29 | + <!--</RelativeLayout>--> | ||
| 30 | + | ||
| 31 | + </android.support.v7.widget.Toolbar> | ||
| 32 | +</layout> |
app/src/main/res/values/colors.xml
| @@ -8,4 +8,23 @@ | @@ -8,4 +8,23 @@ | ||
| 8 | 8 | ||
| 9 | <color name="rate_sel">#ff0000</color> | 9 | <color name="rate_sel">#ff0000</color> |
| 10 | <color name="rate_nor">#ffffff</color> | 10 | <color name="rate_nor">#ffffff</color> |
| 11 | + | ||
| 12 | + <color name="gray_line_color">#dcdcdc</color> | ||
| 13 | + <color name="config_black_color">#323333</color> | ||
| 14 | + <color name="config_gray_color">#969797</color> | ||
| 15 | + <color name="color_list_bg">#88615F5D</color> | ||
| 16 | + <color name="text_input_color">#323333</color> | ||
| 17 | + <color name="text_hint_color">#969797</color> | ||
| 18 | + | ||
| 19 | + //登录页面 | ||
| 20 | + <color name="ff4e51">#ff4e51</color> | ||
| 21 | + <color name="black">#000000</color> | ||
| 22 | + | ||
| 23 | + //注册页面 | ||
| 24 | + <color name="text_white_color">#FFFFFF</color> | ||
| 25 | + | ||
| 26 | + //关于我们页面 | ||
| 27 | + <color name="star_name_color">#323333</color> | ||
| 28 | + <color name="about_us_btn_text_color">#177bdf</color> | ||
| 29 | + <color name="about_us_company_name_color">#969797</color> | ||
| 11 | </resources> | 30 | </resources> |
app/src/main/res/values/dimens.xml
| @@ -2,4 +2,34 @@ | @@ -2,4 +2,34 @@ | ||
| 2 | <resources> | 2 | <resources> |
| 3 | <dimen name="volumeWidthDefault">0px</dimen> | 3 | <dimen name="volumeWidthDefault">0px</dimen> |
| 4 | <dimen name="videoPortraitHeight" format="integer">200dp</dimen> | 4 | <dimen name="videoPortraitHeight" format="integer">200dp</dimen> |
| 5 | + | ||
| 6 | + | ||
| 7 | + <dimen name="divider_height">6dip</dimen> | ||
| 8 | + <dimen name="config_image_height">28dip</dimen> | ||
| 9 | + <dimen name="config_image_width">29dip</dimen> | ||
| 10 | + <dimen name="config_item_height">54dip</dimen> | ||
| 11 | + | ||
| 12 | + <dimen name="next_image_width">13dp</dimen> | ||
| 13 | + <dimen name="next_image_height">21dp</dimen> | ||
| 14 | + <dimen name="next_image_margin_right">9dp</dimen> | ||
| 15 | + | ||
| 16 | + <dimen name="_20px">10dp</dimen> | ||
| 17 | + <dimen name="_28px">14dp</dimen> | ||
| 18 | + | ||
| 19 | + //个人中心 | ||
| 20 | + <dimen name="personal_item_height">44dp</dimen> | ||
| 21 | + <dimen name="personal_text_size">17sp</dimen> | ||
| 22 | + <dimen name="personal_text_size_14">14sp</dimen> | ||
| 23 | + <dimen name="personal_text_size_18">18sp</dimen> | ||
| 24 | + | ||
| 25 | + //关于我们 | ||
| 26 | + <dimen name="about_us_text_size">17sp</dimen> | ||
| 27 | + <dimen name="about_us_btn_size">13sp</dimen> | ||
| 28 | + <dimen name="about_us_company_name_size">12sp</dimen> | ||
| 29 | + | ||
| 30 | + //反馈意见 | ||
| 31 | + <dimen name="text_size_15">15sp</dimen> | ||
| 32 | + <dimen name="_10px">5dp</dimen> | ||
| 33 | + <dimen name="_30px">15dp</dimen> | ||
| 34 | + <dimen name="_100px">50dp</dimen> | ||
| 5 | </resources> | 35 | </resources> |
| 6 | \ No newline at end of file | 36 | \ No newline at end of file |
app/src/main/res/values/strings.xml
| @@ -36,4 +36,71 @@ | @@ -36,4 +36,71 @@ | ||
| 36 | <string name="request_null">暂无数据</string> | 36 | <string name="request_null">暂无数据</string> |
| 37 | <string name="request_state_error">获取活动状态失败</string> | 37 | <string name="request_state_error">获取活动状态失败</string> |
| 38 | <string name="request_state_play_error">此活动状态无法播放</string> | 38 | <string name="request_state_play_error">此活动状态无法播放</string> |
| 39 | + | ||
| 40 | + | ||
| 41 | + <string name="net_connect_toast">"你好像掉线了"</string> | ||
| 42 | + | ||
| 43 | + //我的 | ||
| 44 | + <string name="main_tab_config">我的</string> | ||
| 45 | + <string name="click_login">点击登录</string> | ||
| 46 | + <string name="login_china_coin">登录就送中国币哟</string> | ||
| 47 | + <string name="my_config_money_desc">中国币、兑换码、金额</string> | ||
| 48 | + <string name="logout">注销</string> | ||
| 49 | + | ||
| 50 | + //登录页面 | ||
| 51 | + <string name="user_login_account">账号:</string> | ||
| 52 | + <string name="user_login_account_hint">Email/手机号码</string> | ||
| 53 | + <string name="user_login_code">密码:</string> | ||
| 54 | + <string name="user_login_code_hint">6–20位字母或数字</string> | ||
| 55 | + <string name="user_login_recall_code">忘记密码?</string> | ||
| 56 | + <string name="string_fast_access">短信验证登录</string> | ||
| 57 | + <string name="user_login">登录</string> | ||
| 58 | + <string name="user_login_third_part_login">第三方账号登录</string> | ||
| 59 | + <string name="third_login_sina">微博</string> | ||
| 60 | + <string name="third_login_qq">QQ</string> | ||
| 61 | + <string name="third_login_weixin">微信</string> | ||
| 62 | + | ||
| 63 | + //注册页面 | ||
| 64 | + <string name="register_mobile_hint">请输入您的手机号</string> | ||
| 65 | + <string name="getmobile_identify_code">获取验证码</string> | ||
| 66 | + <string name="register_mobile_keycode_hint">请输入您收到的验证码</string> | ||
| 67 | + <string name="register_password_hint">请设置密码:6–20位字母或数字</string> | ||
| 68 | + <string name="register_show_password">显示密码</string> | ||
| 69 | + <string name="register_and_agree">我已阅读并同意</string> | ||
| 70 | + <string name="register_btn">注册</string> | ||
| 71 | + | ||
| 72 | + //找回密码页面 | ||
| 73 | + <string name="find_password_btn">找回密码</string> | ||
| 74 | + <string name="find_password_hint">请确认密码:6–20位字母或数字</string> | ||
| 75 | + <string name="save_btn">保存</string> | ||
| 76 | + | ||
| 77 | + //昵称修改页面 | ||
| 78 | + <string name="user_input_nickname">请输入昵称</string> | ||
| 79 | + | ||
| 80 | + //手机号修改页面 | ||
| 81 | + <string name="register_mobile">手机号:</string> | ||
| 82 | + <string name="user_personal_telephone_hint">手机号码</string> | ||
| 83 | + <string name="register_mobile_keycode">验证码:</string> | ||
| 84 | + <string name="hint_6_numbers_code">6位数字验证码</string> | ||
| 85 | + | ||
| 86 | + //邮箱修改页面 | ||
| 87 | + <string name="email_notify">修改后,您输入的邮箱将会收到确认邮件,请按邮件中的说明去完成验证,谢谢!</string> | ||
| 88 | + | ||
| 89 | + //关于我们页面 | ||
| 90 | + <string name="about_us_visit">访问视讯中国官网</string> | ||
| 91 | + <string name="about_us_call_phone">拨打客服电话</string> | ||
| 92 | + <string name="about_us_disclaimer">免责声明</string> | ||
| 93 | + <string name="about_us_company_name">北京中投视讯文化传媒股份有限公司</string> | ||
| 94 | + | ||
| 95 | + //分享 | ||
| 96 | + <string name="toast_msg_share_success">分享成功!</string> | ||
| 97 | + <string name="toast_msg_share_fail">分享失败,请再试一次</string> | ||
| 98 | + <string name="toast_msg_share_cancel">取消分享</string> | ||
| 99 | + <string name="share_program_download_targetUrl"> http://www.cnlive.com/web/guide.jsp</string> | ||
| 100 | + | ||
| 101 | + //AccountManager用户管理 | ||
| 102 | + <string name="ACCOUNT_TYPE">com.cnlive.libs.AccountType</string> | ||
| 103 | + <string name="ACCOUNT_LABEL">@string/app_name</string> | ||
| 104 | + | ||
| 105 | + <string name="verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&plat=a&appId=%s </string> | ||
| 39 | </resources> | 106 | </resources> |
app/src/main/res/values/styles.xml
| @@ -11,4 +11,85 @@ | @@ -11,4 +11,85 @@ | ||
| 11 | <declare-styleable name="FragmentTabHost"> | 11 | <declare-styleable name="FragmentTabHost"> |
| 12 | <attr name="dividerDrawable" format="reference" /> | 12 | <attr name="dividerDrawable" format="reference" /> |
| 13 | </declare-styleable> | 13 | </declare-styleable> |
| 14 | + | ||
| 15 | + <style name="ActionbarTitleStyle"> | ||
| 16 | + <item name="android:textSize">22sp</item> | ||
| 17 | + <item name="android:textColor">#000000</item> | ||
| 18 | + </style> | ||
| 19 | + | ||
| 20 | + <style name="list_item_style"> | ||
| 21 | + <item name="android:background">@drawable/list_item_selector</item> | ||
| 22 | + </style> | ||
| 23 | + | ||
| 24 | + <style name="ConfigItemImageStyle"> | ||
| 25 | + <item name="android:layout_marginLeft">18dp</item> | ||
| 26 | + <item name="android:layout_marginRight">10dp</item> | ||
| 27 | + </style> | ||
| 28 | + | ||
| 29 | + <style name="ConfigItemTitleStyle"> | ||
| 30 | + <item name="android:textColor">@color/config_black_color</item> | ||
| 31 | + <item name="android:textSize">15sp</item> | ||
| 32 | + <item name="android:layout_marginLeft">8dp</item> | ||
| 33 | + </style> | ||
| 34 | + | ||
| 35 | + <style name="ConfigItemDescStyle"> | ||
| 36 | + <item name="android:textColor">@color/config_gray_color</item> | ||
| 37 | + <item name="android:textSize">12sp</item> | ||
| 38 | + <item name="android:layout_marginRight">5dp</item> | ||
| 39 | + </style> | ||
| 40 | + | ||
| 41 | + <style name="ToolbarTitleStyle"> | ||
| 42 | + <item name="android:textSize">20sp</item> | ||
| 43 | + <item name="android:textColor">#000000</item> | ||
| 44 | + </style> | ||
| 45 | + | ||
| 46 | + <style name="LoginButtonStyle"> | ||
| 47 | + <item name="android:textColor">@android:color/white</item> | ||
| 48 | + <item name="android:textSize">17sp</item> | ||
| 49 | + <item name="android:layout_marginRight">10dp</item> | ||
| 50 | + <item name="android:layout_marginLeft">10dp</item> | ||
| 51 | + </style> | ||
| 52 | + | ||
| 53 | + <style name="LoginNameStyle"> | ||
| 54 | + <item name="android:textColor">@color/text_input_color</item> | ||
| 55 | + <item name="android:textSize">17sp</item> | ||
| 56 | + <item name="android:layout_marginRight">17dp</item> | ||
| 57 | + <item name="android:layout_marginLeft">18dp</item> | ||
| 58 | + <item name="android:layout_marginTop">20dp</item> | ||
| 59 | + <item name="android:layout_marginBottom">20dp</item> | ||
| 60 | + </style> | ||
| 61 | + | ||
| 62 | + <style name="LoginContentStyle"> | ||
| 63 | + <item name="android:textColor">@color/text_input_color</item> | ||
| 64 | + <item name="android:textColorHint">@color/text_hint_color</item> | ||
| 65 | + <item name="android:textSize">17sp</item> | ||
| 66 | + <item name="android:singleLine">true</item> | ||
| 67 | + <item name="android:textCursorDrawable">@null</item> | ||
| 68 | + <item name="android:background">@null</item> | ||
| 69 | + </style> | ||
| 70 | + | ||
| 71 | + <style name="take_photo_anim" parent="android:Animation"> | ||
| 72 | + <item name="android:windowEnterAnimation">@anim/pop_enter_anim</item> | ||
| 73 | + <item name="android:windowExitAnimation">@anim/pop_exit_anim</item> | ||
| 74 | + </style> | ||
| 75 | + | ||
| 76 | + <style name="CustomDialogStyle" parent="@android:style/Theme.Dialog"> | ||
| 77 | + <item name="android:windowFrame">@null</item> | ||
| 78 | + <item name="android:windowIsFloating">true</item> | ||
| 79 | + <item name="android:windowIsTranslucent">true</item> | ||
| 80 | + <item name="android:windowNoTitle">true</item> | ||
| 81 | + <item name="android:background">@android:color/transparent</item> | ||
| 82 | + <item name="android:windowBackground">@android:color/transparent</item> | ||
| 83 | + <item name="android:backgroundDimEnabled">true</item> | ||
| 84 | + <item name="android:backgroundDimAmount">0.6</item> | ||
| 85 | + <item name="android:windowCloseOnTouchOutside">true</item> | ||
| 86 | + </style> | ||
| 87 | + | ||
| 88 | + <style name="ActionBar" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
| 89 | + <!-- Customize your theme here. --> | ||
| 90 | + <item name="colorPrimary">@color/colorPrimary</item> | ||
| 91 | + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
| 92 | + <item name="colorAccent">@color/colorAccent</item> | ||
| 93 | + <item name="android:windowContentOverlay">@null</item> | ||
| 94 | + </style> | ||
| 14 | </resources> | 95 | </resources> |
app/src/main/res/xml/account_preferences.xml
0 → 100644
app/src/main/res/xml/authenticator.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:accountType="@string/ACCOUNT_TYPE" | ||
| 4 | + android:icon="@mipmap/ic_launcher" | ||
| 5 | + android:smallIcon="@mipmap/ic_launcher" | ||
| 6 | + android:label="@string/ACCOUNT_LABEL" | ||
| 7 | + android:accountPreferences="@xml/account_preferences" /> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |