Commit 4392346d19a241cb26a075536d7e554fecc1c0d5
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/CNLiveApp
Showing
26 changed files
with
1027 additions
and
93 deletions
app/src/main/AndroidManifest.xml
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | 3 | xmlns:tools="http://schemas.android.com/tools" |
| 4 | 4 | package="com.cnlive.gundam"> |
| 5 | + | |
| 5 | 6 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
| 6 | 7 | <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> |
| 7 | 8 | <uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
| ... | ... | @@ -54,10 +55,16 @@ |
| 54 | 55 | android:screenOrientation="portrait" |
| 55 | 56 | android:windowSoftInputMode="adjustResize" /> |
| 56 | 57 | |
| 57 | - <activity android:name=".user.activity.LoginActivity"/> | |
| 58 | + <activity | |
| 59 | + android:name=".main.ui.activity.WebViewActivity" | |
| 60 | + android:configChanges="keyboardHidden|screenSize|orientation" | |
| 61 | + android:launchMode="singleTop" | |
| 62 | + android:screenOrientation="portrait" | |
| 63 | + android:windowSoftInputMode="adjustResize" /> | |
| 64 | + | |
| 65 | + <activity android:name=".user.activity.LoginActivity" /> | |
| 58 | 66 | |
| 59 | - <receiver | |
| 60 | - android:name=".video.utils.NetworkChangeReceive"> | |
| 67 | + <receiver android:name=".video.utils.NetworkChangeReceive"> | |
| 61 | 68 | <intent-filter> |
| 62 | 69 | <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> |
| 63 | 70 | </intent-filter> |
| ... | ... | @@ -79,7 +86,6 @@ |
| 79 | 86 | <activity |
| 80 | 87 | android:name=".user.activity.UserPersonalActivity" |
| 81 | 88 | android:configChanges="orientation|keyboardHidden|screenSize" |
| 82 | - android:launchMode="singleTop" | |
| 83 | 89 | android:screenOrientation="portrait" |
| 84 | 90 | android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> |
| 85 | 91 | </application> | ... | ... |
app/src/main/java/com/cnlive/gundam/main/application/CNLiveApplication.java
| ... | ... | @@ -13,6 +13,8 @@ public class CNLiveApplication extends Application { |
| 13 | 13 | @Override |
| 14 | 14 | public void onCreate() { |
| 15 | 15 | super.onCreate(); |
| 16 | - Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9",true); | |
| 16 | + //TODO 测试ID 在正式与测试环境均可通过,正式ID则不行~! | |
| 17 | +// Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9",true); | |
| 18 | + Config.init(getApplicationContext(), "60_j4faozoq85", "7b6da5a6e2955aaf7f73a06b5bdc6d50e6d5bfda3da86b"); | |
| 17 | 19 | } |
| 18 | 20 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/main/network/ApiService.java
| ... | ... | @@ -3,6 +3,7 @@ package com.cnlive.gundam.main.network; |
| 3 | 3 | import com.cnlive.gundam.main.model.ActiveListModel; |
| 4 | 4 | import com.cnlive.gundam.main.model.ActivePlayInfo; |
| 5 | 5 | import com.cnlive.gundam.main.model.VodListPage; |
| 6 | +import com.cnlive.gundam.user.model.ChannelInfoModel; | |
| 6 | 7 | |
| 7 | 8 | import java.util.Map; |
| 8 | 9 | |
| ... | ... | @@ -27,4 +28,8 @@ public interface ApiService { |
| 27 | 28 | //判断活动的状态 |
| 28 | 29 | @GET("vod_epg/getVodInfo4App") |
| 29 | 30 | Call<VodListPage> getVodInfoList(@QueryMap Map<String, String> options); |
| 31 | + | |
| 32 | + //主播信息接口 | |
| 33 | + @GET("live_epg/channel/info4App") | |
| 34 | + Call<ChannelInfoModel> getChannelInfo(@QueryMap Map<String, String> params); | |
| 30 | 35 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/main/network/util/SignUtil.java
| ... | ... | @@ -3,19 +3,13 @@ package com.cnlive.gundam.main.network.util; |
| 3 | 3 | import android.content.Context; |
| 4 | 4 | import android.util.Log; |
| 5 | 5 | |
| 6 | -import com.cnlive.gundam.main.network.util.SHA1; | |
| 7 | 6 | import com.cnlive.libs.util.Config; |
| 8 | -import com.cnlive.libs.util.data.okhttp3.Headers; | |
| 9 | -import com.cnlive.libs.util.data.okhttp3.OkHttpClient; | |
| 10 | -import com.cnlive.libs.util.data.okhttp3.Request; | |
| 11 | -import com.cnlive.libs.util.data.okhttp3.Response; | |
| 12 | 7 | |
| 13 | 8 | import java.io.UnsupportedEncodingException; |
| 14 | 9 | import java.net.URLEncoder; |
| 15 | 10 | import java.util.ArrayList; |
| 16 | 11 | import java.util.Collections; |
| 17 | 12 | import java.util.Comparator; |
| 18 | -import java.util.Date; | |
| 19 | 13 | import java.util.HashMap; |
| 20 | 14 | import java.util.LinkedHashMap; |
| 21 | 15 | import java.util.List; |
| ... | ... | @@ -66,17 +60,17 @@ public class SignUtil { |
| 66 | 60 | } |
| 67 | 61 | |
| 68 | 62 | private static long getTime() { |
| 69 | - OkHttpClient okHttpClient = new OkHttpClient(); | |
| 70 | - try { | |
| 71 | - Request request = new Request.Builder().url(URL_TIME_SERVICE).build(); | |
| 72 | - Response response = okHttpClient.newCall(request).execute(); | |
| 73 | - Headers headers = response.headers(); | |
| 74 | - | |
| 75 | - Date date = headers.getDate("Date"); | |
| 76 | - return date == null ? System.currentTimeMillis() : date.getTime(); | |
| 77 | - } catch (Exception e) { | |
| 78 | - e.printStackTrace(); | |
| 79 | - } | |
| 63 | +// OkHttpClient okHttpClient = new OkHttpClient(); | |
| 64 | +// try { | |
| 65 | +// Request request = new Request.Builder().url(URL_TIME_SERVICE).build(); | |
| 66 | +// Response response = okHttpClient.newCall(request).execute(); | |
| 67 | +// Headers headers = response.headers(); | |
| 68 | +// | |
| 69 | +// Date date = headers.getDate("Date"); | |
| 70 | +// return date == null ? System.currentTimeMillis() : date.getTime(); | |
| 71 | +// } catch (Exception e) { | |
| 72 | +// e.printStackTrace(); | |
| 73 | +// } | |
| 80 | 74 | |
| 81 | 75 | return System.currentTimeMillis(); |
| 82 | 76 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/main/presenter/AnchorInfoPresenter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.gundam.main.network.RetrofitUtil; | |
| 6 | +import com.cnlive.gundam.main.network.util.SignUtil; | |
| 7 | +import com.cnlive.gundam.main.presenter.view.AnchorInfoView; | |
| 8 | +import com.cnlive.gundam.user.model.ChannelInfoModel; | |
| 9 | +import com.cnlive.libs.util.Config; | |
| 10 | + | |
| 11 | +import java.util.HashMap; | |
| 12 | +import java.util.Map; | |
| 13 | + | |
| 14 | +import retrofit2.Call; | |
| 15 | +import retrofit2.Callback; | |
| 16 | +import retrofit2.Response; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * Created by xiansong on 2017/6/28. | |
| 20 | + */ | |
| 21 | + | |
| 22 | +public class AnchorInfoPresenter { | |
| 23 | + | |
| 24 | + private AnchorInfoView mView; | |
| 25 | + | |
| 26 | + public AnchorInfoPresenter(AnchorInfoView view) { | |
| 27 | + this.mView = view; | |
| 28 | + } | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 查询主播信息 | |
| 32 | + * | |
| 33 | + * @param context Context | |
| 34 | + * @param channelId 主播ID | |
| 35 | + */ | |
| 36 | + public void checkAnchorInfo(Context context, String channelId) { | |
| 37 | + Map<String, String> params = new HashMap<>(); | |
| 38 | + params.put("appId", Config.getAppId()); | |
| 39 | + params.put("channelId", channelId); | |
| 40 | + RetrofitUtil.getApiService().getChannelInfo(SignUtil.getSignParamM(context, params)).enqueue(new Callback<ChannelInfoModel>() { | |
| 41 | + @Override | |
| 42 | + public void onResponse(Call<ChannelInfoModel> call, Response<ChannelInfoModel> response) { | |
| 43 | + if (response.isSuccessful()) { | |
| 44 | + ChannelInfoModel info = response.body(); | |
| 45 | + if (info != null && "0".equals(info.getErrorCode())) { | |
| 46 | + if (mView != null) mView.onAnchorInfo(info); | |
| 47 | + } else { | |
| 48 | + if (mView != null) mView.getAnchorFailure(); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + public void onFailure(Call<ChannelInfoModel> call, Throwable t) { | |
| 55 | + if (mView != null) mView.getAnchorFailure(); | |
| 56 | + } | |
| 57 | + }); | |
| 58 | + } | |
| 59 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/presenter/view/AnchorInfoView.java
0 → 100644
app/src/main/java/com/cnlive/gundam/main/ui/activity/BackBaseActivity.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.activity; | |
| 2 | + | |
| 3 | +import android.support.v7.app.AppCompatActivity; | |
| 4 | +import android.support.v7.widget.Toolbar; | |
| 5 | +import android.view.MenuItem; | |
| 6 | +import android.view.View; | |
| 7 | +import android.widget.TextView; | |
| 8 | + | |
| 9 | +import com.cnlive.gundam.R; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Created by gujun on 2017/5/31. | |
| 13 | + */ | |
| 14 | + | |
| 15 | +public class BackBaseActivity extends AppCompatActivity { | |
| 16 | + | |
| 17 | + private Toolbar toolbar; | |
| 18 | + | |
| 19 | + protected void setupToolBar(String title) { | |
| 20 | + toolbar = (Toolbar) findViewById(R.id.toolbar); | |
| 21 | + toolbar.setTitle(""); | |
| 22 | + TextView toolbarTitle = (TextView) findViewById(R.id.toolbarTitle); | |
| 23 | + toolbarTitle.setText(title); | |
| 24 | + toolbar.setVisibility(View.VISIBLE); | |
| 25 | + toolbar.setNavigationIcon(R.drawable.btn_cancel); | |
| 26 | + setSupportActionBar(toolbar); | |
| 27 | + | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setToolBarVisible(boolean show) { | |
| 31 | + if (toolbar == null) return; | |
| 32 | + toolbar.setVisibility(show ? View.VISIBLE : View.GONE); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public boolean onOptionsItemSelected(MenuItem item) { | |
| 37 | + if (item.getItemId() == android.R.id.home) { | |
| 38 | + this.onBackPressed(); | |
| 39 | + } | |
| 40 | + return super.onOptionsItemSelected(item); | |
| 41 | + } | |
| 42 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
| 1 | 1 | package com.cnlive.gundam.main.ui.activity; |
| 2 | 2 | |
| 3 | +import android.app.AlertDialog; | |
| 4 | +import android.app.Dialog; | |
| 5 | +import android.content.DialogInterface; | |
| 6 | +import android.content.Intent; | |
| 3 | 7 | import android.databinding.DataBindingUtil; |
| 4 | 8 | import android.os.Bundle; |
| 5 | 9 | import android.support.v7.app.AppCompatActivity; |
| 10 | +import android.widget.Toast; | |
| 6 | 11 | |
| 7 | 12 | import com.cnlive.gundam.R; |
| 8 | 13 | import com.cnlive.gundam.databinding.ActivityMainBinding; |
| 14 | +import com.cnlive.gundam.main.presenter.AnchorInfoPresenter; | |
| 15 | +import com.cnlive.gundam.main.presenter.view.AnchorInfoView; | |
| 9 | 16 | import com.cnlive.gundam.main.ui.fragment.ConfigFragment; |
| 10 | 17 | import com.cnlive.gundam.main.ui.fragment.HomeFragment; |
| 11 | 18 | import com.cnlive.gundam.main.ui.fragment.LiveFragment; |
| 12 | 19 | import com.cnlive.gundam.main.ui.fragment.UGCListFragment; |
| 13 | 20 | import com.cnlive.gundam.main.ui.widget.FragmentTabHost; |
| 21 | +import com.cnlive.gundam.stream.ui.activity.StreamActivity; | |
| 22 | +import com.cnlive.gundam.user.activity.LoginActivity; | |
| 23 | +import com.cnlive.gundam.user.auth.UserService; | |
| 24 | +import com.cnlive.gundam.user.model.ChannelInfoModel; | |
| 25 | +import com.cnlive.gundam.user.model.User; | |
| 26 | +import com.cnlive.libs.util.Config; | |
| 14 | 27 | |
| 15 | 28 | import java.util.Arrays; |
| 16 | 29 | |
| ... | ... | @@ -18,7 +31,11 @@ import java.util.Arrays; |
| 18 | 31 | * Created by xiansong on 2017/6/27. |
| 19 | 32 | */ |
| 20 | 33 | |
| 21 | -public class MainActivity extends AppCompatActivity implements FragmentTabHost.OnSetCurrentTabListener { | |
| 34 | +public class MainActivity extends AppCompatActivity implements FragmentTabHost.OnSetCurrentTabListener, AnchorInfoView { | |
| 35 | + | |
| 36 | + private Dialog verifiedDialog; | |
| 37 | + | |
| 38 | + private AnchorInfoPresenter mAnchorInfoPresenter; | |
| 22 | 39 | |
| 23 | 40 | @Override |
| 24 | 41 | protected void onCreate(Bundle savedInstanceState) { |
| ... | ... | @@ -33,6 +50,8 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O |
| 33 | 50 | FragmentTabHost.newTab("live", R.layout.indicator_main_live, UGCListFragment.class), |
| 34 | 51 | FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class) |
| 35 | 52 | )); |
| 53 | + | |
| 54 | + mAnchorInfoPresenter = new AnchorInfoPresenter(this); | |
| 36 | 55 | } |
| 37 | 56 | |
| 38 | 57 | @Override |
| ... | ... | @@ -45,8 +64,72 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O |
| 45 | 64 | return false; |
| 46 | 65 | } |
| 47 | 66 | |
| 48 | - private void onSetStreamTab(){ | |
| 67 | + /** | |
| 68 | + * 直播按钮点击 | |
| 69 | + */ | |
| 70 | + private void onSetStreamTab() { | |
| 71 | + User user = UserService.getInstance(this).getActiveAccountInfo(); | |
| 72 | + if (user.getUid() == 0) { | |
| 73 | + startActivity(new Intent(this, LoginActivity.class)); | |
| 74 | + } else { | |
| 75 | + mAnchorInfoPresenter.checkAnchorInfo(this, user.getUid() + ""); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 49 | 79 | |
| 80 | + @Override | |
| 81 | + public void onAnchorInfo(ChannelInfoModel model) { | |
| 82 | + switch (model.getData().getStatus()) { | |
| 83 | + case -1: | |
| 84 | + Toast.makeText(this, "主播不存在", Toast.LENGTH_SHORT).show(); | |
| 85 | + showVerifiedDialog(); | |
| 86 | + break; | |
| 87 | + case 1: | |
| 88 | + Toast.makeText(this, "审核中,请耐心等待", Toast.LENGTH_SHORT).show(); | |
| 89 | + break; | |
| 90 | + case 2: | |
| 91 | + Toast.makeText(this, "审核失败", Toast.LENGTH_SHORT).show(); | |
| 92 | + break; | |
| 93 | + case 3: | |
| 94 | + Toast.makeText(this, "开启直播", Toast.LENGTH_SHORT).show(); | |
| 95 | + String activityId = System.currentTimeMillis() + ""; | |
| 96 | + String channelId = model.getData().getChannelId(); | |
| 97 | + String channelName = model.getData().getChannelName(); | |
| 98 | + String coverImgUrl = model.getData().getCoverImgUrl(); | |
| 99 | + StreamActivity.start(this, activityId, channelId, channelName, coverImgUrl, false); | |
| 100 | + break; | |
| 101 | + case 4: | |
| 102 | + Toast.makeText(this, "主播被禁用", Toast.LENGTH_SHORT).show(); | |
| 103 | + break; | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + @Override | |
| 108 | + public void getAnchorFailure() { | |
| 109 | + Toast.makeText(this, getString(R.string.request_state_error), Toast.LENGTH_LONG).show(); | |
| 50 | 110 | } |
| 51 | 111 | |
| 112 | + private void showVerifiedDialog() { | |
| 113 | + verifiedDialog = new AlertDialog.Builder(this) | |
| 114 | + .setMessage("亲,完成实名认证就可以开播啦,现在就去认证吧?") | |
| 115 | + .setPositiveButton("去认证", new DialogInterface.OnClickListener() { | |
| 116 | + @Override | |
| 117 | + public void onClick(DialogInterface dialogInterface, int i) { | |
| 118 | + verifiedDialog.dismiss(); | |
| 119 | + String channelId = UserService.getInstance(MainActivity.this).getActiveAccountInfo().getUid() + ""; | |
| 120 | + String url = String.format(getString(R.string.verified_url), channelId, Config.getAppId()); | |
| 121 | + Intent intent = new Intent(MainActivity.this, WebViewActivity.class); | |
| 122 | + intent.putExtra("url", url); | |
| 123 | + intent.putExtra("title", "主播认证"); | |
| 124 | + startActivity(intent); | |
| 125 | + } | |
| 126 | + }) | |
| 127 | + .setNegativeButton("取消", new DialogInterface.OnClickListener() { | |
| 128 | + @Override | |
| 129 | + public void onClick(DialogInterface dialogInterface, int i) { | |
| 130 | + verifiedDialog.dismiss(); | |
| 131 | + } | |
| 132 | + }) | |
| 133 | + .show(); | |
| 134 | + } | |
| 52 | 135 | } |
| 53 | 136 | \ No newline at end of file | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/activity/WebViewActivity.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.activity; | |
| 2 | + | |
| 3 | +import android.databinding.DataBindingUtil; | |
| 4 | +import android.os.Bundle; | |
| 5 | +import android.support.v7.app.AppCompatActivity; | |
| 6 | +import android.view.View; | |
| 7 | +import android.webkit.WebChromeClient; | |
| 8 | +import android.webkit.WebSettings; | |
| 9 | +import android.webkit.WebView; | |
| 10 | +import android.webkit.WebViewClient; | |
| 11 | + | |
| 12 | +import com.cnlive.gundam.R; | |
| 13 | +import com.cnlive.gundam.databinding.ActivityWebviewBinding; | |
| 14 | + | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Created by Administrator on 2017/1/12. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +public class WebViewActivity extends AppCompatActivity { | |
| 21 | + | |
| 22 | + | |
| 23 | + private String path; | |
| 24 | + private String title; | |
| 25 | + private ActivityWebviewBinding binding; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + protected void onCreate(Bundle savedInstanceState) { | |
| 29 | + super.onCreate(savedInstanceState); | |
| 30 | + setContentView(R.layout.activity_webview); | |
| 31 | + getBundle(); | |
| 32 | + | |
| 33 | + binding = DataBindingUtil.setContentView(this, R.layout.activity_webview); | |
| 34 | + binding.setTitle(title); | |
| 35 | + binding.webview.loadUrl(path); | |
| 36 | + | |
| 37 | + WebSettings s = binding.webview.getSettings(); | |
| 38 | + | |
| 39 | + s.setBuiltInZoomControls(false); | |
| 40 | + s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); | |
| 41 | + | |
| 42 | + // Default zoom is deprecated in Android 4.4 | |
| 43 | + s.setUseWideViewPort(true); | |
| 44 | + s.setLoadWithOverviewMode(true); | |
| 45 | + | |
| 46 | + s.setAllowFileAccess(true); | |
| 47 | + s.setJavaScriptEnabled(true); | |
| 48 | + | |
| 49 | +// s.setUserAgentString(s.getUserAgentString() + "/" + Probe.appid); | |
| 50 | + | |
| 51 | + binding.webview.setWebViewClient(new WebViewClient() { | |
| 52 | + @Override | |
| 53 | + public boolean shouldOverrideUrlLoading(WebView view, String url) { | |
| 54 | + view.loadUrl(url); | |
| 55 | + return true; | |
| 56 | + } | |
| 57 | + }); | |
| 58 | + | |
| 59 | + binding.webview.setWebChromeClient(webChromeClient); | |
| 60 | + } | |
| 61 | + | |
| 62 | + private void getBundle() { | |
| 63 | + if (getIntent().hasExtra("url")) path = getIntent().getStringExtra("url"); | |
| 64 | + if (getIntent().hasExtra("title")) title = getIntent().getStringExtra("title"); | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void onWebViewClick(View view) { | |
| 68 | + onBackPressed(); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public void onBackPressed() { | |
| 73 | + if (binding.webview.canGoBack()) { | |
| 74 | + binding.webview.goBack(); | |
| 75 | + }else super.onBackPressed(); | |
| 76 | + } | |
| 77 | + | |
| 78 | + private WebChromeClient webChromeClient = new WebChromeClient() { | |
| 79 | + @Override | |
| 80 | + public void onProgressChanged(WebView view, int newProgress) { | |
| 81 | + if (newProgress >= 100) { | |
| 82 | + if (binding.webviewProgressbar != null) { | |
| 83 | + binding.webviewProgressbar.setVisibility(View.GONE); | |
| 84 | + } | |
| 85 | + } else { | |
| 86 | + if (binding.webviewProgressbar != null) { | |
| 87 | + binding.webviewProgressbar.setVisibility(View.VISIBLE); | |
| 88 | + binding.webviewProgressbar.setProgress(newProgress); | |
| 89 | + } | |
| 90 | + } | |
| 91 | + } | |
| 92 | + }; | |
| 93 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/DataBindingAdapter.java
| ... | ... | @@ -17,11 +17,11 @@ import com.cnlive.gundam.main.ui.adapter.holder.DataBindingViewHolder; |
| 17 | 17 | |
| 18 | 18 | public class DataBindingAdapter<T> extends BaseRecyclerAdapter<T> { |
| 19 | 19 | private int layoutId; |
| 20 | - private int itemBRId; | |
| 20 | + protected int itemBRId; | |
| 21 | 21 | private int imageHeightBRId = -1; |
| 22 | 22 | private int imageHeight; |
| 23 | 23 | |
| 24 | - private OnAdapterViewClickListener<T> l; | |
| 24 | + protected OnAdapterViewClickListener<T> l; | |
| 25 | 25 | private OnAdapterViewLoadMoreListener loadMoreListener; |
| 26 | 26 | |
| 27 | 27 | public DataBindingAdapter(Context context, int layoutId, int itemBRId) { | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
| ... | ... | @@ -57,10 +57,15 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 57 | 57 | switch (view.getId()) { |
| 58 | 58 | case R.id.config_header: |
| 59 | 59 | int uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid(); |
| 60 | - if (uid != 0) | |
| 61 | - startActivity(new Intent(getActivity(), UserPersonalActivity.class)); | |
| 62 | - else | |
| 60 | + if (uid != 0) { | |
| 61 | + //进入个人中心页面 | |
| 62 | + Intent intent = new Intent(getActivity(), UserPersonalActivity.class); | |
| 63 | + intent.putExtra("isEdit",false); | |
| 64 | + startActivity(intent); | |
| 65 | + } else { | |
| 66 | + //进入登录页面 | |
| 63 | 67 | startActivity(new Intent(getActivity(), LoginActivity.class)); |
| 68 | + } | |
| 64 | 69 | break; |
| 65 | 70 | |
| 66 | 71 | case R.id.message: | ... | ... |
app/src/main/java/com/cnlive/gundam/user/activity/UserPersonalActivity.java
| 1 | 1 | package com.cnlive.gundam.user.activity; |
| 2 | 2 | |
| 3 | +import android.content.Intent; | |
| 3 | 4 | import android.databinding.DataBindingUtil; |
| 4 | 5 | import android.os.Bundle; |
| 5 | 6 | import android.support.annotation.Nullable; |
| 6 | -import android.support.v7.app.AppCompatActivity; | |
| 7 | 7 | |
| 8 | 8 | import com.cnlive.gundam.R; |
| 9 | +import com.cnlive.gundam.main.ui.activity.BackBaseActivity; | |
| 10 | +import com.cnlive.gundam.user.fragment.UserPersonalEditFragment; | |
| 9 | 11 | import com.cnlive.gundam.user.fragment.UserPersonalFragment; |
| 10 | 12 | |
| 11 | 13 | /** |
| ... | ... | @@ -13,11 +15,24 @@ import com.cnlive.gundam.user.fragment.UserPersonalFragment; |
| 13 | 15 | * @time 2017/6/28 12:56 |
| 14 | 16 | * @desc ${TODD} |
| 15 | 17 | */ |
| 16 | -public class UserPersonalActivity extends AppCompatActivity { | |
| 18 | +public class UserPersonalActivity extends BackBaseActivity { | |
| 17 | 19 | @Override |
| 18 | 20 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| 19 | 21 | super.onCreate(savedInstanceState); |
| 20 | - DataBindingUtil.setContentView(this, R.layout.activity_setting); | |
| 21 | - getSupportFragmentManager().beginTransaction().replace(R.id.setting_fragment, UserPersonalFragment.newInstance()).commit(); | |
| 22 | + DataBindingUtil.setContentView(this, R.layout.activity_user_personal); | |
| 23 | + addFragment(getIntent()); | |
| 24 | + } | |
| 25 | + | |
| 26 | + private void addFragment(Intent intent ){ | |
| 27 | + if (intent.hasExtra("isEdit")) { | |
| 28 | + getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, | |
| 29 | + intent.getBooleanExtra("isEdit",false) ? | |
| 30 | + UserPersonalEditFragment.newInstance(intent.getIntExtra("type", 0)) : | |
| 31 | + UserPersonalFragment.newInstance()).commit(); | |
| 32 | + } | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setTitle(String title){ | |
| 36 | + setupToolBar(title); | |
| 22 | 37 | } |
| 23 | 38 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/user/adapter/PersonalAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.adapter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.databinding.ViewDataBinding; | |
| 6 | +import android.support.v7.widget.RecyclerView; | |
| 7 | +import android.view.LayoutInflater; | |
| 8 | +import android.view.ViewGroup; | |
| 9 | + | |
| 10 | +import com.cnlive.gundam.BR; | |
| 11 | +import com.cnlive.gundam.R; | |
| 12 | +import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter; | |
| 13 | +import com.cnlive.gundam.main.ui.adapter.holder.DataBindingViewHolder; | |
| 14 | +import com.cnlive.gundam.user.model.PersonalData; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Created by gujun on 2017/6/28. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +public class PersonalAdapter extends DataBindingAdapter<PersonalData>{ | |
| 21 | + | |
| 22 | + public PersonalAdapter(Context context, int layoutId, int itemBRId) { | |
| 23 | + super(context, layoutId, itemBRId); | |
| 24 | + } | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
| 28 | + if(viewType == PersonalData.TYPE_HEADER){ | |
| 29 | + ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.layout_personal_header_item, parent, false); | |
| 30 | + DataBindingViewHolder viewHolder = new DataBindingViewHolder(binding.getRoot()); | |
| 31 | + viewHolder.setBinding(binding); | |
| 32 | + return viewHolder; | |
| 33 | + }else{ | |
| 34 | + return super.onCreateViewHolder(parent, viewType); | |
| 35 | + } | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | |
| 40 | + if(getItem(position).getItemType() == PersonalData.TYPE_HEADER){ | |
| 41 | + DataBindingViewHolder videoListViewHolder = (DataBindingViewHolder) holder; | |
| 42 | + videoListViewHolder.getBinding().setVariable(itemBRId, getItem(position)); | |
| 43 | + if (l != null) | |
| 44 | + videoListViewHolder.getBinding().setVariable(BR.viewClickListner, l); | |
| 45 | + videoListViewHolder.getBinding().executePendingBindings(); | |
| 46 | + }else{ | |
| 47 | + super.onBindViewHolder(holder, position); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public int getItemViewType(int position) { | |
| 53 | + return getItem(position).getItemType(); | |
| 54 | + } | |
| 55 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalEditFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.fragment; | |
| 2 | + | |
| 3 | +import android.databinding.DataBindingUtil; | |
| 4 | +import android.os.Bundle; | |
| 5 | +import android.support.annotation.Nullable; | |
| 6 | +import android.support.v4.app.Fragment; | |
| 7 | +import android.view.LayoutInflater; | |
| 8 | +import android.view.View; | |
| 9 | +import android.view.ViewGroup; | |
| 10 | +import android.widget.Toast; | |
| 11 | + | |
| 12 | +import com.cnlive.gundam.R; | |
| 13 | +import com.cnlive.gundam.databinding.FragmentPersonalEditBinding; | |
| 14 | +import com.cnlive.gundam.user.activity.UserPersonalActivity; | |
| 15 | +import com.cnlive.gundam.user.auth.UserService; | |
| 16 | +import com.cnlive.gundam.user.model.User; | |
| 17 | +import com.cnlive.libs.user.IUserService; | |
| 18 | +import com.cnlive.libs.user.UserUtil; | |
| 19 | +import com.cnlive.libs.util.data.network.Callback; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Created by gujun on 2017/6/28. | |
| 23 | + */ | |
| 24 | + | |
| 25 | +public class UserPersonalEditFragment extends Fragment implements Callback, View.OnClickListener { | |
| 26 | + | |
| 27 | + public static final int TYPE_NICK = 0x1001; | |
| 28 | + public static final int TYPE_MOBILE = 0x1002; | |
| 29 | + public static final int TYPE_EMAIL = 0x1003; | |
| 30 | + public static final int TYPE_ADDRESS = 0x1004; | |
| 31 | + | |
| 32 | + private FragmentPersonalEditBinding binding; | |
| 33 | + private int type; | |
| 34 | + private User user; | |
| 35 | + | |
| 36 | + public static UserPersonalEditFragment newInstance(int type) { | |
| 37 | + | |
| 38 | + Bundle args = new Bundle(); | |
| 39 | + args.putInt("type", type); | |
| 40 | + UserPersonalEditFragment fragment = new UserPersonalEditFragment(); | |
| 41 | + fragment.setArguments(args); | |
| 42 | + return fragment; | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Nullable | |
| 46 | + @Override | |
| 47 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| 48 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_personal_edit, container, false); | |
| 49 | + return binding.getRoot(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 54 | + super.onViewCreated(view, savedInstanceState); | |
| 55 | + init(); | |
| 56 | + } | |
| 57 | + | |
| 58 | + private void init() { | |
| 59 | + binding.setUserPersonalEditFragment(this); | |
| 60 | + type = getArguments().getInt("type"); | |
| 61 | + UserService userService = UserService.getInstance(getActivity()); | |
| 62 | + user = userService.getActiveAccountInfo(); | |
| 63 | + String title = ""; | |
| 64 | + switch (type) { | |
| 65 | + case TYPE_NICK: | |
| 66 | + binding.editText.setText(user.getNickname()); | |
| 67 | + binding.editText.setVisibility(View.VISIBLE); | |
| 68 | + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.GONE); | |
| 69 | + title = "修改昵称"; | |
| 70 | + break; | |
| 71 | + case TYPE_MOBILE: | |
| 72 | + binding.editText.setVisibility(View.GONE); | |
| 73 | + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.VISIBLE); | |
| 74 | + binding.includeMobileLayout.edtLoginNumber.setText(user.getMobile()); | |
| 75 | + binding.includeMobileLayout.getVerify.setOnClickListener(this); | |
| 76 | + title = "修改手机号"; | |
| 77 | + break; | |
| 78 | + case TYPE_EMAIL: | |
| 79 | + binding.editText.setText(user.getEmail()); | |
| 80 | + binding.editText.setVisibility(View.VISIBLE); | |
| 81 | + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.GONE); | |
| 82 | + title = "修改邮箱"; | |
| 83 | + break; | |
| 84 | + case TYPE_ADDRESS: | |
| 85 | + binding.editText.setText(user.getLocation()); | |
| 86 | + binding.editText.setVisibility(View.VISIBLE); | |
| 87 | + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.GONE); | |
| 88 | + title = "修改地址"; | |
| 89 | + break; | |
| 90 | + } | |
| 91 | + ((UserPersonalActivity)getActivity()).setTitle(title); | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + public void onClick(View v) { | |
| 96 | + if (v.getId() == R.id.submit) { | |
| 97 | + switch (type) { | |
| 98 | + case TYPE_NICK: | |
| 99 | + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "nickName", binding.editText.getText().toString(), this); | |
| 100 | + break; | |
| 101 | + case TYPE_MOBILE: | |
| 102 | + UserUtil.updateMobile(String.valueOf(user.getUid()), binding.includeMobileLayout.edtLoginNumber.getText().toString(), binding.includeMobileLayout.edtVerify.getText().toString(), this); | |
| 103 | + break; | |
| 104 | + case TYPE_EMAIL: | |
| 105 | + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "email", binding.editText.getText().toString(), this); | |
| 106 | + break; | |
| 107 | + case TYPE_ADDRESS: | |
| 108 | + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "location", binding.editText.getText().toString(), this); | |
| 109 | + break; | |
| 110 | + } | |
| 111 | + } else if (v.getId() == R.id.get_verify) { | |
| 112 | + //TODO 获取验证码 | |
| 113 | + UserUtil.sendMessage(IUserService.REGISTER_OR_MODIFY_MOBILE, binding.includeMobileLayout.edtLoginNumber.getText().toString(), new Callback() { | |
| 114 | + @Override | |
| 115 | + public void onState(int i, String s, Object o) { | |
| 116 | + if (i == IUserService.SUCCESS) { | |
| 117 | + Toast.makeText(getActivity(), "验证码已发送", Toast.LENGTH_LONG).show(); | |
| 118 | + } else { | |
| 119 | + Toast.makeText(getActivity(), "获取验证码失败" + s, Toast.LENGTH_LONG).show(); | |
| 120 | + } | |
| 121 | + | |
| 122 | + } | |
| 123 | + }); | |
| 124 | + } | |
| 125 | + } | |
| 126 | + | |
| 127 | + @Override | |
| 128 | + public void onState(int i, String s, Object o) { | |
| 129 | + if (i == IUserService.SUCCESS) { | |
| 130 | + Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); | |
| 131 | + } else { | |
| 132 | + Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); | |
| 133 | + } | |
| 134 | + | |
| 135 | + //TODO 更新一下本地数据 | |
| 136 | + } | |
| 137 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalFragment.java
| 1 | 1 | package com.cnlive.gundam.user.fragment; |
| 2 | 2 | |
| 3 | +import android.content.Intent; | |
| 3 | 4 | import android.databinding.DataBindingUtil; |
| 4 | 5 | import android.os.Bundle; |
| 5 | 6 | import android.support.annotation.Nullable; |
| 6 | 7 | import android.support.v4.app.Fragment; |
| 8 | +import android.support.v7.widget.LinearLayoutManager; | |
| 7 | 9 | import android.view.LayoutInflater; |
| 8 | 10 | import android.view.View; |
| 9 | 11 | import android.view.ViewGroup; |
| 12 | +import android.widget.Toast; | |
| 10 | 13 | |
| 14 | +import com.cnlive.gundam.BR; | |
| 11 | 15 | import com.cnlive.gundam.R; |
| 12 | 16 | import com.cnlive.gundam.databinding.FragmentUserPersonalBinding; |
| 17 | +import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter; | |
| 18 | +import com.cnlive.gundam.user.activity.UserPersonalActivity; | |
| 19 | +import com.cnlive.gundam.user.adapter.PersonalAdapter; | |
| 20 | +import com.cnlive.gundam.user.auth.UserService; | |
| 21 | +import com.cnlive.gundam.user.model.PersonalData; | |
| 22 | +import com.cnlive.gundam.user.model.User; | |
| 13 | 23 | |
| 24 | +import java.util.ArrayList; | |
| 25 | +import java.util.List; | |
| 14 | 26 | |
| 15 | 27 | |
| 16 | 28 | /** |
| ... | ... | @@ -18,38 +30,93 @@ import com.cnlive.gundam.databinding.FragmentUserPersonalBinding; |
| 18 | 30 | * @time 2017/6/28 13:06 |
| 19 | 31 | * @desc ${TODD} |
| 20 | 32 | */ |
| 21 | -public class UserPersonalFragment extends Fragment{ | |
| 33 | +public class UserPersonalFragment extends Fragment implements DataBindingAdapter.OnAdapterViewClickListener<PersonalData> { | |
| 22 | 34 | |
| 23 | 35 | private FragmentUserPersonalBinding binding; |
| 24 | 36 | |
| 37 | + private PersonalAdapter adapter; | |
| 25 | 38 | |
| 26 | - @Nullable | |
| 27 | - @Override | |
| 28 | - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
| 29 | - binding = DataBindingUtil.inflate(inflater, R.layout.fragment_user_personal, container, false); | |
| 30 | - return binding.getRoot(); | |
| 31 | - } | |
| 39 | + private List<PersonalData> personalData; | |
| 32 | 40 | |
| 33 | 41 | public static UserPersonalFragment newInstance() { |
| 42 | + | |
| 43 | + Bundle args = new Bundle(); | |
| 44 | + | |
| 34 | 45 | UserPersonalFragment fragment = new UserPersonalFragment(); |
| 46 | + fragment.setArguments(args); | |
| 35 | 47 | return fragment; |
| 36 | 48 | } |
| 37 | 49 | |
| 50 | + @Nullable | |
| 38 | 51 | @Override |
| 39 | - public void onActivityCreated(Bundle savedInstanceState) { | |
| 40 | - super.onActivityCreated(savedInstanceState); | |
| 41 | - initToolBar(); | |
| 42 | - /*init(); | |
| 43 | - PersonalHeadItem.getContent(getActivity()); | |
| 44 | - PersonalItem.getContent(getActivity());*/ | |
| 45 | - } | |
| 46 | - private void initToolBar() { | |
| 47 | - binding.personalIncludeLayout.toolbarTitle.setText("个人资料"); | |
| 52 | + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
| 53 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_user_personal, container, false); | |
| 54 | + return binding.getRoot(); | |
| 48 | 55 | } |
| 49 | 56 | |
| 57 | + @Override | |
| 58 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 59 | + super.onViewCreated(view, savedInstanceState); | |
| 60 | + initData(); | |
| 61 | + init(); | |
| 62 | + } | |
| 50 | 63 | |
| 64 | + private void initData() { | |
| 65 | + UserService userService = UserService.getInstance(getActivity()); | |
| 66 | + User user = userService.getActiveAccountInfo(); | |
| 67 | + personalData = new ArrayList<>(); | |
| 68 | + personalData.add(new PersonalData("头像", user.getFaceurl(), PersonalData.TYPE_HEADER)); | |
| 69 | + personalData.add(new PersonalData("昵称", user.getNickname(), PersonalData.TYPE_NICK)); | |
| 70 | + personalData.add(new PersonalData("性别", user.getGender(), PersonalData.TYPE_GENDER)); | |
| 71 | + personalData.add(new PersonalData("手机号", user.getMobile(), PersonalData.TYPE_MOBILE)); | |
| 72 | + personalData.add(new PersonalData("邮箱", user.getEmail(), PersonalData.TYPE_EMAIL)); | |
| 73 | + personalData.add(new PersonalData("联系地址", user.getLocation(), PersonalData.TYPE_ADDRESS)); | |
| 74 | + } | |
| 51 | 75 | |
| 76 | + private void init() { | |
| 77 | + ((UserPersonalActivity)getActivity()).setTitle("个人资料"); | |
| 78 | + binding.setListAdapter(adapter = new PersonalAdapter(getActivity(), R.layout.layout_personal_item, BR.data)); | |
| 79 | + binding.setLayoutManager(new LinearLayoutManager(getActivity())); | |
| 80 | + adapter.updateItems(personalData); | |
| 81 | + adapter.setOnViewClickListener(this); | |
| 82 | + } | |
| 52 | 83 | |
| 53 | - | |
| 54 | - | |
| 84 | + @Override | |
| 85 | + public void onViewClick(View v, PersonalData program) { | |
| 86 | + if (v.getId() == R.id.itemLayout) { | |
| 87 | + Intent intent = null; | |
| 88 | + switch (program.getItemType()) { | |
| 89 | + case PersonalData.TYPE_HEADER: | |
| 90 | + Toast.makeText(getActivity(), "头像点击", Toast.LENGTH_LONG).show(); | |
| 91 | + break; | |
| 92 | + case PersonalData.TYPE_NICK: | |
| 93 | + intent = new Intent(getActivity(), UserPersonalActivity.class); | |
| 94 | + intent.putExtra("isEdit",true); | |
| 95 | + intent.putExtra("type", UserPersonalEditFragment.TYPE_NICK); | |
| 96 | + startActivity(intent); | |
| 97 | + break; | |
| 98 | + case PersonalData.TYPE_GENDER: | |
| 99 | + Toast.makeText(getActivity(), "性别点击", Toast.LENGTH_LONG).show(); | |
| 100 | + break; | |
| 101 | + case PersonalData.TYPE_MOBILE: | |
| 102 | + intent = new Intent(getActivity(), UserPersonalActivity.class); | |
| 103 | + intent.putExtra("isEdit",true); | |
| 104 | + intent.putExtra("type", UserPersonalEditFragment.TYPE_MOBILE); | |
| 105 | + startActivity(intent); | |
| 106 | + break; | |
| 107 | + case PersonalData.TYPE_EMAIL: | |
| 108 | + intent = new Intent(getActivity(), UserPersonalActivity.class); | |
| 109 | + intent.putExtra("isEdit",true); | |
| 110 | + intent.putExtra("type", UserPersonalEditFragment.TYPE_EMAIL); | |
| 111 | + startActivity(intent); | |
| 112 | + break; | |
| 113 | + case PersonalData.TYPE_ADDRESS: | |
| 114 | + intent = new Intent(getActivity(), UserPersonalActivity.class); | |
| 115 | + intent.putExtra("isEdit",true); | |
| 116 | + intent.putExtra("type", UserPersonalEditFragment.TYPE_ADDRESS); | |
| 117 | + startActivity(intent); | |
| 118 | + break; | |
| 119 | + } | |
| 120 | + } | |
| 121 | + } | |
| 55 | 122 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/user/model/PersonalData.java
0 → 100644
| 1 | +package com.cnlive.gundam.user.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * @author 陈硕 | |
| 5 | + * @time 2017/6/28 13:55 | |
| 6 | + * @desc ${TODD} | |
| 7 | + */ | |
| 8 | +public class PersonalData { | |
| 9 | + | |
| 10 | + private String itemName; | |
| 11 | + private String itemMessage; | |
| 12 | + private int itemType; | |
| 13 | + | |
| 14 | + public static final int TYPE_HEADER = 0x1001; | |
| 15 | + public static final int TYPE_NICK = 0x1002; | |
| 16 | + public static final int TYPE_GENDER = 0x1003; | |
| 17 | + public static final int TYPE_MOBILE = 0x1004; | |
| 18 | + public static final int TYPE_EMAIL = 0x1005; | |
| 19 | + public static final int TYPE_ADDRESS = 0x1006; | |
| 20 | + | |
| 21 | + public PersonalData(String itemName, String itemMessage, int itemType) { | |
| 22 | + this.itemName = itemName; | |
| 23 | + this.itemMessage = itemMessage; | |
| 24 | + this.itemType = itemType; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public String getItemName() { | |
| 28 | + return itemName; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setItemName(String itemName) { | |
| 32 | + this.itemName = itemName; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public String getItemMessage() { | |
| 36 | + return itemMessage; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setItemMessage(String itemMessage) { | |
| 40 | + this.itemMessage = itemMessage; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public int getItemType() { | |
| 44 | + return itemType; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setItemType(int itemType) { | |
| 48 | + this.itemType = itemType; | |
| 49 | + } | |
| 50 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/video/test.java deleted
100644 → 0
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/layout/activity_user_personal.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + | |
| 4 | + <data> | |
| 5 | + | |
| 6 | + </data> | |
| 7 | + | |
| 8 | + <LinearLayout | |
| 9 | + android:layout_width="match_parent" | |
| 10 | + android:layout_height="match_parent" | |
| 11 | + android:orientation="vertical"> | |
| 12 | + | |
| 13 | + <include | |
| 14 | + layout="@layout/layout_actionbar_back"/> | |
| 15 | + | |
| 16 | + <RelativeLayout | |
| 17 | + android:id="@+id/contentLayout" | |
| 18 | + android:layout_width="match_parent" | |
| 19 | + android:layout_height="match_parent"/> | |
| 20 | + | |
| 21 | + </LinearLayout> | |
| 22 | + | |
| 23 | +</layout> | |
| 0 | 24 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/activity_webview.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | + | |
| 3 | + | |
| 4 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + xmlns:tools="http://schemas.android.com/tools"> | |
| 6 | + | |
| 7 | + <data> | |
| 8 | + | |
| 9 | + <variable | |
| 10 | + name="title" | |
| 11 | + type="String" /> | |
| 12 | + | |
| 13 | + </data> | |
| 14 | + | |
| 15 | + <RelativeLayout | |
| 16 | + | |
| 17 | + android:id="@+id/linear_web" | |
| 18 | + android:layout_width="match_parent" | |
| 19 | + android:layout_height="match_parent" | |
| 20 | + android:orientation="vertical"> | |
| 21 | + | |
| 22 | + <RelativeLayout | |
| 23 | + android:id="@+id/toobar" | |
| 24 | + android:layout_width="match_parent" | |
| 25 | + android:layout_height="48dp" | |
| 26 | + android:background="@android:color/white"> | |
| 27 | + | |
| 28 | + <ImageButton | |
| 29 | + android:layout_width="32dp" | |
| 30 | + android:layout_height="32dp" | |
| 31 | + android:layout_centerVertical="true" | |
| 32 | + android:layout_marginLeft="10dp" | |
| 33 | + android:background="@null" | |
| 34 | + android:onClick="onWebViewClick" | |
| 35 | + android:scaleType="centerCrop" | |
| 36 | + android:src="@drawable/btn_return" /> | |
| 37 | + | |
| 38 | + | |
| 39 | + <TextView | |
| 40 | + android:id="@+id/title" | |
| 41 | + android:layout_width="wrap_content" | |
| 42 | + android:layout_height="wrap_content" | |
| 43 | + android:layout_centerInParent="true" | |
| 44 | + android:gravity="center" | |
| 45 | + android:text="@{title}" | |
| 46 | + android:textSize="20sp" | |
| 47 | + tools:text="标题" /> | |
| 48 | + </RelativeLayout> | |
| 49 | + | |
| 50 | + <View android:id="@+id/line" | |
| 51 | + android:layout_width="match_parent" | |
| 52 | + android:layout_height="1dp" | |
| 53 | + android:layout_below="@+id/toobar" | |
| 54 | + android:background="@android:color/black" /> | |
| 55 | + | |
| 56 | + <ProgressBar | |
| 57 | + android:id="@+id/webview_progressbar" | |
| 58 | + style="?android:attr/progressBarStyleHorizontal" | |
| 59 | + android:layout_width="match_parent" | |
| 60 | + android:layout_height="1dp" | |
| 61 | + android:layout_below="@+id/toobar" | |
| 62 | + android:focusable="false" | |
| 63 | + android:max="100" | |
| 64 | + android:progress="100" | |
| 65 | + android:progressDrawable="@drawable/downloading_progress_bar" /> | |
| 66 | + | |
| 67 | + <WebView | |
| 68 | + android:id="@+id/webview" | |
| 69 | + android:layout_width="match_parent" | |
| 70 | + android:layout_height="match_parent" | |
| 71 | + android:layout_below="@+id/line" | |
| 72 | + android:background="@android:color/white" /> | |
| 73 | + | |
| 74 | + </RelativeLayout> | |
| 75 | +</layout> | |
| 0 | 76 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/fragment_personal_edit.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + | |
| 4 | + <data> | |
| 5 | + | |
| 6 | + <import type="com.cnlive.gundam.user.fragment.UserPersonalEditFragment" /> | |
| 7 | + | |
| 8 | + <variable | |
| 9 | + name="userPersonalEditFragment" | |
| 10 | + type="UserPersonalEditFragment" /> | |
| 11 | + | |
| 12 | + </data> | |
| 13 | + | |
| 14 | + <RelativeLayout | |
| 15 | + android:layout_width="match_parent" | |
| 16 | + android:layout_height="match_parent"> | |
| 17 | + | |
| 18 | + <EditText | |
| 19 | + android:id="@+id/editText" | |
| 20 | + android:layout_width="match_parent" | |
| 21 | + android:layout_height="50dp" | |
| 22 | + android:visibility="gone"/> | |
| 23 | + | |
| 24 | + <include | |
| 25 | + android:id="@+id/includeMobileLayout" | |
| 26 | + layout="@layout/mobile_keycode_layout"/> | |
| 27 | + | |
| 28 | + <Button | |
| 29 | + android:id="@+id/submit" | |
| 30 | + android:layout_width="match_parent" | |
| 31 | + android:layout_height="50dp" | |
| 32 | + android:layout_alignParentBottom="true" | |
| 33 | + android:layout_marginBottom="200dp" | |
| 34 | + android:onClick="@{userPersonalEditFragment.onClick}" | |
| 35 | + android:text="提交" /> | |
| 36 | + | |
| 37 | + </RelativeLayout> | |
| 38 | + | |
| 39 | +</layout> | |
| 0 | 40 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/fragment_user_personal.xml
| ... | ... | @@ -2,47 +2,34 @@ |
| 2 | 2 | <layout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | 3 | xmlns:app="http://schemas.android.com/apk/res-auto"> |
| 4 | 4 | |
| 5 | - <!--<data> | |
| 5 | + <data> | |
| 6 | + | |
| 7 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter"/> | |
| 8 | + <import type="android.support.v7.widget.LinearLayoutManager"/> | |
| 9 | + | |
| 10 | + <variable | |
| 11 | + name="listAdapter" | |
| 12 | + type="DataBindingAdapter"/> | |
| 6 | 13 | |
| 7 | 14 | <variable |
| 8 | - name="liLayoutManager" | |
| 9 | - type="android.support.v7.widget.LinearLayoutManager" /> | |
| 15 | + name="layoutManager" | |
| 16 | + type="LinearLayoutManager"/> | |
| 10 | 17 | </data> |
| 11 | ---> | |
| 18 | + | |
| 12 | 19 | <RelativeLayout |
| 13 | - android:id="@+id/main_view" | |
| 14 | 20 | android:layout_width="match_parent" |
| 15 | 21 | android:layout_height="match_parent"> |
| 16 | 22 | |
| 17 | - <LinearLayout | |
| 18 | - android:id="@+id/persion_layout" | |
| 23 | + <android.support.v7.widget.RecyclerView | |
| 24 | + android:id="@+id/recyclerView" | |
| 19 | 25 | android:layout_width="match_parent" |
| 20 | 26 | android:layout_height="match_parent" |
| 21 | - android:orientation="vertical"> | |
| 22 | - | |
| 23 | - <include | |
| 24 | - android:id="@+id/personalIncludeLayout" | |
| 25 | - layout="@layout/user_toolbar_title" /> | |
| 26 | - | |
| 27 | - | |
| 28 | - <android.support.v7.widget.RecyclerView | |
| 29 | - android:id="@+id/lv_personal" | |
| 30 | - android:layout_width="match_parent" | |
| 31 | - android:layout_height="match_parent" | |
| 32 | - android:divider="@null" | |
| 33 | - android:fastScrollEnabled="true" | |
| 34 | - android:scrollbars="none" | |
| 35 | - /> | |
| 36 | - | |
| 37 | - </LinearLayout> | |
| 38 | - | |
| 39 | - <ImageView | |
| 40 | - android:id="@+id/back_selector" | |
| 41 | - android:layout_width="30dp" | |
| 42 | - android:layout_height="30dp" | |
| 43 | - android:layout_marginLeft="@dimen/_20px" | |
| 44 | - android:layout_marginTop="@dimen/_28px" | |
| 45 | - android:src="@drawable/btn_return" /> | |
| 27 | + android:clipToPadding="true" | |
| 28 | + android:clipChildren="true" | |
| 29 | + android:paddingTop="5dp" | |
| 30 | + android:background="@color/list_divider" | |
| 31 | + app:adapter="@{listAdapter}" | |
| 32 | + app:layoutManager="@{layoutManager}"/> | |
| 46 | 33 | |
| 47 | 34 | </RelativeLayout> |
| 48 | 35 | </layout> |
| 49 | 36 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_actionbar_back.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | + | |
| 3 | +<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | + android:id="@+id/toolbar" | |
| 5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 6 | + xmlns:tools="http://schemas.android.com/tools" | |
| 7 | + android:layout_width="match_parent" | |
| 8 | + android:layout_height="?attr/actionBarSize" | |
| 9 | + android:theme="@style/ThemeOverlay.AppCompat.Light" | |
| 10 | + app:contentInsetEnd="?attr/actionBarSize" | |
| 11 | + android:visibility="gone" | |
| 12 | + tools:visibility="visible"> | |
| 13 | + | |
| 14 | + | |
| 15 | + <TextView | |
| 16 | + android:id="@+id/toolbarTitle" | |
| 17 | + style="@style/ActionbarTitleStyle" | |
| 18 | + android:layout_width="wrap_content" | |
| 19 | + android:layout_height="wrap_content" | |
| 20 | + android:layout_gravity="center" | |
| 21 | + android:lines="1" | |
| 22 | + tools:text="here is title"/> | |
| 23 | + | |
| 24 | +</android.support.v7.widget.Toolbar> | |
| 0 | 25 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_personal_header_item.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | |
| 4 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | |
| 5 | + | |
| 6 | + <data> | |
| 7 | + | |
| 8 | + <import type="com.cnlive.gundam.user.model.PersonalData" /> | |
| 9 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/> | |
| 10 | + | |
| 11 | + <variable | |
| 12 | + name="data" | |
| 13 | + type="PersonalData" /> | |
| 14 | + | |
| 15 | + <variable | |
| 16 | + name="viewClickListner" | |
| 17 | + type="OnAdapterViewClickListener<PersonalData>"/> | |
| 18 | + | |
| 19 | + </data> | |
| 20 | + | |
| 21 | + <RelativeLayout | |
| 22 | + android:id="@+id/itemLayout" | |
| 23 | + android:layout_width="match_parent" | |
| 24 | + android:layout_height="80dp" | |
| 25 | + android:onClick="@{(view)->viewClickListner.onViewClick(view,data)}"> | |
| 26 | + | |
| 27 | + <RelativeLayout | |
| 28 | + android:layout_width="match_parent" | |
| 29 | + android:layout_height="match_parent" | |
| 30 | + android:layout_above="@+id/divider" | |
| 31 | + android:background="@android:color/white"> | |
| 32 | + | |
| 33 | + <TextView | |
| 34 | + android:id="@+id/itemName" | |
| 35 | + android:layout_width="wrap_content" | |
| 36 | + android:layout_height="match_parent" | |
| 37 | + android:gravity="center_vertical" | |
| 38 | + android:text="@{data.getItemName()}" | |
| 39 | + android:textColor="@color/black" | |
| 40 | + android:textSize="18sp" | |
| 41 | + tools:text="nick" /> | |
| 42 | + | |
| 43 | + <ImageView | |
| 44 | + android:layout_width="50dp" | |
| 45 | + android:layout_height="50dp" | |
| 46 | + android:layout_marginRight="50dp" | |
| 47 | + android:layout_alignParentRight="true" | |
| 48 | + android:layout_centerVertical="true" | |
| 49 | + android:scaleType="centerCrop" | |
| 50 | + app:error="@{@drawable/image_error}" | |
| 51 | + app:imageUrl="@{data.getItemMessage()}"/> | |
| 52 | + | |
| 53 | + <ImageView | |
| 54 | + android:layout_width="wrap_content" | |
| 55 | + android:layout_height="wrap_content" | |
| 56 | + android:layout_alignParentRight="true" | |
| 57 | + android:layout_centerVertical="true"/> | |
| 58 | + | |
| 59 | + </RelativeLayout> | |
| 60 | + | |
| 61 | + <View | |
| 62 | + android:id="@+id/divider" | |
| 63 | + android:layout_width="match_parent" | |
| 64 | + android:layout_height="5dp" | |
| 65 | + android:layout_alignParentBottom="true"/> | |
| 66 | + | |
| 67 | + </RelativeLayout> | |
| 68 | + | |
| 69 | +</layout> | |
| 0 | 70 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_personal_item.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools"> | |
| 4 | + | |
| 5 | + <data> | |
| 6 | + | |
| 7 | + <import type="com.cnlive.gundam.user.model.PersonalData" /> | |
| 8 | + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/> | |
| 9 | + | |
| 10 | + <variable | |
| 11 | + name="data" | |
| 12 | + type="PersonalData" /> | |
| 13 | + | |
| 14 | + <variable | |
| 15 | + name="viewClickListner" | |
| 16 | + type="OnAdapterViewClickListener<PersonalData>"/> | |
| 17 | + | |
| 18 | + </data> | |
| 19 | + | |
| 20 | + <RelativeLayout | |
| 21 | + android:id="@+id/itemLayout" | |
| 22 | + android:layout_width="match_parent" | |
| 23 | + android:layout_height="60dp" | |
| 24 | + android:onClick="@{(view)->viewClickListner.onViewClick(view,data)}"> | |
| 25 | + | |
| 26 | + <RelativeLayout | |
| 27 | + android:layout_width="match_parent" | |
| 28 | + android:layout_height="match_parent" | |
| 29 | + android:layout_above="@+id/divider" | |
| 30 | + android:background="@android:color/white"> | |
| 31 | + | |
| 32 | + <TextView | |
| 33 | + android:id="@+id/itemName" | |
| 34 | + android:layout_width="wrap_content" | |
| 35 | + android:layout_height="match_parent" | |
| 36 | + android:gravity="center_vertical" | |
| 37 | + android:text="@{data.getItemName()}" | |
| 38 | + android:textColor="@color/black" | |
| 39 | + android:textSize="18sp" | |
| 40 | + tools:text="nick" /> | |
| 41 | + | |
| 42 | + <TextView | |
| 43 | + android:id="@+id/itemMsg" | |
| 44 | + android:layout_width="wrap_content" | |
| 45 | + android:layout_height="match_parent" | |
| 46 | + android:layout_alignParentRight="true" | |
| 47 | + android:layout_marginRight="50dp" | |
| 48 | + android:layout_toRightOf="@+id/itemName" | |
| 49 | + android:gravity="center_vertical|right" | |
| 50 | + android:text="@{data.getItemMessage()}" | |
| 51 | + android:textColor="@color/black" | |
| 52 | + android:textSize="18sp" | |
| 53 | + tools:text="haha" /> | |
| 54 | + | |
| 55 | + <ImageView | |
| 56 | + android:layout_width="wrap_content" | |
| 57 | + android:layout_height="wrap_content" | |
| 58 | + android:layout_alignParentRight="true" | |
| 59 | + android:layout_centerVertical="true"/> | |
| 60 | + | |
| 61 | + </RelativeLayout> | |
| 62 | + | |
| 63 | + <View | |
| 64 | + android:id="@+id/divider" | |
| 65 | + android:layout_width="match_parent" | |
| 66 | + android:layout_height="5dp" | |
| 67 | + android:layout_alignParentBottom="true"/> | |
| 68 | + | |
| 69 | + </RelativeLayout> | |
| 70 | + | |
| 71 | +</layout> | |
| 0 | 72 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/mobile_keycode_layout.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | - > | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + | |
| 4 | + <data> | |
| 5 | + | |
| 6 | + </data> | |
| 7 | + | |
| 4 | 8 | <LinearLayout |
| 5 | 9 | android:id="@+id/mobile_keycode_layout" |
| 6 | 10 | android:layout_width="match_parent" | ... | ... |