Skip to content

Commit

Permalink
增加首页,修改部分也页面
Browse files Browse the repository at this point in the history
  • Loading branch information
846425567 committed Aug 5, 2015
1 parent e90e9d7 commit 26f6201
Show file tree
Hide file tree
Showing 35 changed files with 432 additions and 165 deletions.
5 changes: 4 additions & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".activity.StartActivity"
android:name=".activity.OriginActivity"
android:theme="@style/NoActionBar_trans">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -66,6 +66,9 @@
android:name=".activity.ChatActivity"
android:theme="@style/trans_style"
android:windowSoftInputMode="adjustResize|stateHidden" />

<activity android:name=".activity.StartActivity"
android:theme="@style/NoActionBar_trans"/>
</application>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
55 changes: 37 additions & 18 deletions src/main/java/cn/sdu/online/findteam/activity/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.util.ArrayList;
import java.util.List;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -13,6 +15,7 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import android.widget.ActionMenuView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
Expand All @@ -26,7 +29,7 @@
import cn.sdu.online.findteam.mob.ChatActivityListItem;
import cn.sdu.online.findteam.resource.RoundImageView;

public class ChatActivity extends Activity implements View.OnClickListener {
public class ChatActivity extends Activity implements View.OnClickListener,View.OnTouchListener {
private ListView mListView;
private List<ChatActivityListItem> list;
private int TYPE_COUNT = 2;
Expand All @@ -35,12 +38,16 @@ public class ChatActivity extends Activity implements View.OnClickListener {
private LayoutInflater mInflater;
private MyAdapter adapter;
private EditText editText;
private Button button;
private Button button,backBtn;
private RelativeLayout linearLayout;
private TextView chatPerson;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActionBarLayout(R.layout.chatactivity_actionbar);
chatPerson = (TextView) findViewById(R.id.chat_person);
chatPerson.setText(getIntent().getExtras().getString("chatperson"));
setContentView(R.layout.chat_layout);
initView();

Expand All @@ -55,23 +62,11 @@ private void initView() {
editText = (EditText) findViewById(R.id.write_chatmsg);
button = (Button) findViewById(R.id.push_chatmsg);
linearLayout = (RelativeLayout) findViewById(R.id.chatactivity_layout);
editText.setOnClickListener(this);
backBtn = (Button) findViewById(R.id.chat_back_btn);
backBtn.setOnClickListener(this);
button.setOnClickListener(this);
linearLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
});

mListView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
});
linearLayout.setOnTouchListener(this);
mListView.setOnTouchListener(this);
}

private void initData() {
Expand Down Expand Up @@ -105,11 +100,20 @@ public void onClick(View v) {
editText.setText("");
break;

case R.id.chat_back_btn:
finish();

default:
break;
}
}

@Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}

private class MyAdapter extends BaseAdapter {

@Override
Expand Down Expand Up @@ -181,4 +185,19 @@ private class ViewHolder {
ImageView arrow;
}
}

/**
* @param layoutId 布局Id
*/
public void setActionBarLayout(int layoutId) {
ActionBar actionBar = getActionBar();
if (null != actionBar) {
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflator.inflate(layoutId, null);
ActionBar.LayoutParams layout = new ActionBar.LayoutParams(ActionMenuView.LayoutParams.FILL_PARENT, ActionMenuView.LayoutParams.FILL_PARENT);
actionBar.setCustomView(v, layout);
}
}
}
30 changes: 22 additions & 8 deletions src/main/java/cn/sdu/online/findteam/activity/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
Expand Down Expand Up @@ -32,6 +33,11 @@ public class LoginActivity extends Activity implements View.OnClickListener {
private Button register;
private Dialog dialog;

User user;

SharedPreferences preferences;
SharedPreferences.Editor editor;

public static LoginActivity loginActivity;

@Override
Expand All @@ -46,6 +52,10 @@ protected void onCreate(Bundle savedInstanceState) {
private void initView() {
loginname = (EditText) findViewById(R.id.login_name);
loginpassword = (EditText) findViewById(R.id.login_password);
if (getIntent().getExtras() != null) {
loginname.setText(getIntent().getExtras().getString("loginName"));
loginpassword.setText(getIntent().getExtras().getString("loginPassword"));
}
login = (Button) findViewById(R.id.loginac_login_btn);
register = (Button) findViewById(R.id.loginac_register_btn);

Expand Down Expand Up @@ -97,7 +107,7 @@ public void run() {
}

private Bundle startLogin(String name, String password) {
User user = new User();
user = new User();
user.setName(name);
user.setPassword(password);
String jsonResult = new NetCore().Login(user);
Expand Down Expand Up @@ -128,19 +138,22 @@ public void handleMessage(Message message) {
Toast.makeText(LoginActivity.this,
bundle.getString("msg"), Toast.LENGTH_SHORT)
.show();
}

else if (bundle.getInt("code") > NetCore.LOGIN_ERROR) {
} else if (bundle.getInt("code") > NetCore.LOGIN_ERROR) {
// 登录成功
if (dialog != null) {
dialog.dismiss();
}

if (bundle.getString("msg").trim().length() == 0){
Toast.makeText(LoginActivity.this, "网络错误!",Toast.LENGTH_SHORT).show();
if (bundle.getString("msg").trim().length() == 0) {
Toast.makeText(LoginActivity.this, "网络错误!", Toast.LENGTH_SHORT).show();
return;
}

preferences = getSharedPreferences("loginmessage", Activity.MODE_PRIVATE);
editor = preferences.edit();
editor.putString("loginName", user.getName()).apply();
editor.putString("loginPassword", user.getPassword()).apply();

Toast.makeText(LoginActivity.this,
bundle.getString("msg"), Toast.LENGTH_SHORT).show();

Expand All @@ -154,10 +167,11 @@ public void run() {
Intent intent = new Intent();
intent.setClass(LoginActivity.this, MainActivity.class);
intent.putExtra("loginIdentity", "<##用户##>" + loginname.getText().toString());
intent.putExtra("loginID", bundle.getInt("code"));
startActivity(intent);
LoginActivity.this.finish();
StartActivity.startActivity.finish();
if (StartActivity.startActivity != null) {
StartActivity.startActivity.finish();
}
}
};
timer.schedule(timerTask, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen
private View view_actionbar;

private LinearLayout mVisitorDrawerLayout;
// 获取intent传入的字符串和Id号
// 获取intent传入的字符串
private String intentString;
private int Id;
// 侧边栏用户名
private TextView tv_text;

Expand Down Expand Up @@ -436,11 +435,6 @@ public void run() {

}

@Override
public void finish() {
super.finish();
}

/**
* 双击退出函数
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ public void onPageScrollStateChanged(int arg0) {
chat.addView(badgeView);
badgeView.setVisibility(View.GONE);
}
/*
public static int getCount(){
return badgeView.getBadgeCount();
}
*/

protected void resetTextView() {
mChatTextView.setTextColor(Color.BLACK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public class MyTeamActivity extends FragmentActivity {
*/
private Button join;

/**
* 包含参加别人队伍按钮的Layout
*/
private RelativeLayout relativeLayout;

/**
* 队伍设置按钮
*/
Expand All @@ -100,7 +95,6 @@ private void findById() {
mPageVp = (ViewPager) this.findViewById(R.id.id_page_vp);
backimg = (ImageView) this.findViewById(R.id.otherteam_back_img);
join = (Button) this.findViewById(R.id.join_otherteam);
relativeLayout = (RelativeLayout) this.findViewById(R.id.join_otherteam_layout);
teamsetting = (Button) this.findViewById(R.id.team_setting_bt);
}

Expand Down Expand Up @@ -255,7 +249,6 @@ public static Context getContext() {

private void setVisible(){
join.setVisibility(View.GONE);
relativeLayout.setVisibility(View.GONE);
teamsetting.setVisibility(View.VISIBLE);
}
}
Loading

0 comments on commit 26f6201

Please sign in to comment.