Skip to content

Commit

Permalink
修改部分UI相关
Browse files Browse the repository at this point in the history
  • Loading branch information
bradywang committed Nov 27, 2015
1 parent 9bb4b8e commit 7b33a06
Show file tree
Hide file tree
Showing 32 changed files with 254 additions and 30 deletions.
Binary file added app/11.27 v1.1.2 debug.apk
Binary file not shown.
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<orderEntry type="library" exported="" name="apache-httpcomponents-httpcore" level="project" />
<orderEntry type="library" exported="" name="umeng-update-v2.6.0.1" level="project" />
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
<orderEntry type="library" exported="" name="httpclient-4.5.1" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.8" level="project" />
<orderEntry type="library" exported="" name="umeng-analytics-v5.6.1" level="project" />
<orderEntry type="library" exported="" name="fastjson-1.1.43.android" level="project" />
Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.brady.jlulife"
minSdkVersion 15
targetSdkVersion 23
versionCode 3
versionName "1.1.1"
versionCode 4
versionName "1.1.2"
}
buildTypes {
release {
Expand Down Expand Up @@ -39,4 +39,5 @@ dependencies {
compile files('libs/umeng-update-v2.6.0.1.jar')
compile files('libs/fastjson-1.1.15.jar')
compile files('libs/fastjson-1.1.43.android.jar')
compile files('libs/httpclient-4.5.1.jar')
}
Binary file added app/libs/httpclient-4.5.1.jar
Binary file not shown.
11 changes: 10 additions & 1 deletion app/src/main/java/com/brady/jlulife/Entities/CourseSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Created by brady on 15-11-8.
*/
public class CourseSpec {
private int id;
private String courseName;
private String classRoom;
private String teacherName;
Expand All @@ -29,7 +30,7 @@ public CourseSpec(String courseName, String classRoom, String teacherName, int w
}
@Override
public String toString() {
return courseName + '@'+classRoom + '@'+ teacherName ;
return courseName + '@'+classRoom ;
}

public String getString() {
Expand Down Expand Up @@ -129,4 +130,12 @@ public void setIsDoubleWeek(int isDoubleWeek) {

public CourseSpec() {
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ public class CourseListFragment extends BaseFragment {
private ScrollView scrollView;
private float x_tmp1;
private float x_tmp2;
private float oldx;
private float oldy;
private float newx;
private float newy;
private static CourseListFragment mfragment;

GridView head;
GridView courseNum;

public CourseListFragment() {
mfragment = this;
Expand All @@ -62,6 +67,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
dbManager = new DBManager(getActivity());
int currentWeek = getCurrentWeek();
showCourses(currentWeek);
initScrollMethod(view);
return view;
}

Expand All @@ -70,10 +76,11 @@ public void onViewCreated(final View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mContext = getActivity().getApplicationContext();
initActionBar();
}

private void initScrollMethod(final View view){
horizontalScrollView = (HorizontalScrollView) view.findViewById(R.id.horizon_scrollview);
scrollView = (ScrollView) view.findViewById(R.id.scrollview);
scrollView.scrollTo(0, 0);
horizontalScrollView.scrollTo(0,0);
horizontalScrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Expand All @@ -97,36 +104,31 @@ public boolean onTouch(View v, MotionEvent event) {
return false;
}
});


}

@Override
public void onResume() {
super.onResume();

}

private int getCurrentWeek(){
return 0;
return 1;
}

private void initBaseComponents(View view){
view.scrollTo(0, 0);
GridView head = (GridView) view.findViewById(R.id.gridWeek);
head = (GridView) view.findViewById(R.id.gridWeek);
String[] weeks = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };
ArrayAdapter<String> headAdap = new ArrayAdapter<String>(getActivity(),
R.layout.weekstyle, weeks);
head.setAdapter(headAdap);

// 第几节课
GridView courseNum = (GridView) view.findViewById(R.id.gridCourseNum);
courseNum = (GridView) view.findViewById(R.id.gridCourseNum);
String[] courseNums = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11" };
ArrayAdapter<String> leftAdap = new ArrayAdapter<String>(getActivity(),
R.layout.coursenumstyle, courseNums);
courseNum.setAdapter(leftAdap);

mCourseContent = (RelativeLayout) view.findViewById(R.id.relativeCourseContent);
// addCourse(new CourseSpec("毛概","f9","张三",3,3,4,1,8,false));
}
Expand Down Expand Up @@ -164,10 +166,10 @@ private void addCourse(CourseSpec spec){
course.setGravity(Gravity.CENTER);
course.setWidth(courseWidth);
course.setHeight(courseLength);
course.setBackgroundColor(getResources().getColor(R.color.courseColor));
course.setPadding(8, 8, 8, 8);
course.setBackgroundColor(getCourseBackground(spec.getId()));
course.setPadding(8, 5, 8, 5);
course.setText(spec.toString());
course.setTextSize(15);
course.setTextSize(getResources().getDimension(R.dimen.coursespec_font_size));
course.setTextColor(Color.WHITE);
mCourseContent.addView(course);
}
Expand All @@ -177,12 +179,12 @@ public void showCourses(int currentWeek){
List<CourseSpec> courseSpecs = dbManager.queryAllCourses();
Log.i("size",courseSpecs.size()+"");
for (CourseSpec spec :courseSpecs){
Log.i("courses","name:"+spec.getCourseName()+"begin:"+spec.getBeginWeek()+"end"+spec.getEndWeek()+"double"+spec.getIsDoubleWeek()+"single"+spec.getIsSingleWeek());
Log.i("courses",spec.getId()+"name:"+spec.getCourseName()+"begin:"+spec.getBeginWeek()+"end"+spec.getEndWeek()+"double"+spec.getIsDoubleWeek()+"single"+spec.getIsSingleWeek());
if((currentWeek>=spec.getBeginWeek()&&currentWeek<=spec.getEndWeek())||(spec.getBeginWeek()==0&&spec.getEndWeek()==0)) {
Log.i("aaaa","name:"+spec.getCourseName()+"begin:"+spec.getBeginWeek()+"end"+spec.getEndWeek()+"double"+spec.getIsDoubleWeek()+"single"+spec.getIsSingleWeek());
if((spec.getIsDoubleWeek()==1&&currentWeek%2==1)||(spec.getIsSingleWeek()==1&&currentWeek%2==0))
continue;
addCourse(new CourseSpec(spec.getCourseName(), spec.getClassRoom(), spec.getTeacherName(), spec.getWeek(), spec.getStartTime(), spec.getEndTime(), spec.getBeginWeek(), spec.getEndWeek(), spec.getIsSingleWeek(), spec.getIsDoubleWeek()));
addCourse(spec);
}
}
}
Expand All @@ -201,11 +203,55 @@ public void initActionBar(){
actionBar.setListNavigationCallbacks(adapter, new ActionBar.OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
Log.i("position", String.valueOf(itemPosition));
showCourses(itemPosition+1);
return true;
}
});
actionBar.setSelectedNavigationItem(4);
}





private int getCourseBackground(int courseId){
int backId = courseId%8;
Log.i("id","id="+courseId+"backId="+backId);
int result = getResources().getColor(R.color.class_value_1);
switch (backId){
case 0:{
result = getResources().getColor(R.color.class_value_1);
break;
}
case 1:{
result = getResources().getColor(R.color.class_value_2);
break;
}
case 2:{
result = getResources().getColor(R.color.class_value_3);
break;
}
case 3:{
result = getResources().getColor(R.color.class_value_4);
break;
}
case 4:{
result = getResources().getColor(R.color.class_value_5);
break;
}
case 5:{
result = getResources().getColor(R.color.class_value_6);
break;
}
case 6:{
result = getResources().getColor(R.color.class_value_7);
break;
}
case 7:{
result = getResources().getColor(R.color.class_value_8);
break;
}

}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.brady.jlulife.Fragments;


import android.os.Bundle;
import android.app.Fragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import com.brady.jlulife.R;
import com.brady.jlulife.Utils.ConstValue;

/**
* A simple {@link Fragment} subclass.
*/
public class LibrarySearchFragment extends BaseFragment {
private static LibrarySearchFragment instance;
WebView webView;

public static LibrarySearchFragment getInstance() {
if (instance == null)
instance = new LibrarySearchFragment();
return instance;
}


public LibrarySearchFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_library_search, container, false);
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
webView = (WebView) view.findViewById(R.id.lib_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.loadUrl(ConstValue.LIBRARY_SEARCH_URI);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);// 使用当前WebView处理跳转
return true;//true表示此事件在此处被处理,不需要再广播
}

@Override //转向错误时的处理
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
}
});
}

public void preformBack() {
webView.goBack();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
}
closeMenu();
break;
}case 5:{
repleceFragment(R.id.main_container, LibrarySearchFragment.getInstance());
closeMenu();
break;
}
default:{
Toast.makeText(mContext,"The function is commit soon",Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.os.Bundle;
import android.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -77,6 +78,7 @@ private void initComponents(View view){
mLvScore = (ListView) view.findViewById(R.id.lv_scoreList);
}
public void getSemesters(){
Log.i("loginMethod",String.valueOf(uimsModel.getmLoginMethod()));
uimsModel.getSemesters(new OnListinfoGetListener() {
@Override
public void onGetInfoSuccess(List list) {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/com/brady/jlulife/Models/UIMSModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.loopj.android.http.TextHttpResponseHandler;

import org.apache.http.Header;
import org.apache.http.HttpClientConnection;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.entity.StringEntity;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -63,6 +65,7 @@ public class UIMSModel {

private UIMSModel() {
client = new AsyncHttpClient();
client.getHttpClient().getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
}

public static UIMSModel getInstance(Context context) {
Expand All @@ -74,10 +77,9 @@ public static UIMSModel getInstance(Context context) {
return model;
}

public void login(int loginMethod,String uname, String pwd, final LoginListener listener) {
public void login(final int loginMethod,String uname, String pwd, final LoginListener listener) {
mLoginListener = listener;
mUId = uname;
mLoginMethod = loginMethod;
String convertPwd = Utils.getMD5Str("UIMS" + uname + pwd);
Log.i(getClass().getSimpleName(), "uname" + uname + "pwd:" + convertPwd);
RequestParams params = new RequestParams();
Expand Down Expand Up @@ -116,6 +118,7 @@ public void onGetInfoFail() {
listener.onLoginFailure("获取用户信息失败,请重试");
}
});
mLoginMethod = loginMethod;
mLoginListener.onLoginSuccess();
isLogin = true;
}
Expand All @@ -128,6 +131,10 @@ public void logout() {

}

public int getmLoginMethod() {
return mLoginMethod;
}

public void getSemesters(final OnListinfoGetListener listener) {
StringEntity entity = null;
String resourceURI = null;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/brady/jlulife/Models/db/DBManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public List<CourseSpec> queryAllCourses(){
Cursor c = db.query("course",null,null,null,null,null,null);
while (c.moveToNext()){
courseSpec = new CourseSpec();
courseSpec.setId(c.getInt(c.getColumnIndex("id")));
courseSpec.setBeginWeek(c.getInt(c.getColumnIndex("beginWeek")));
courseSpec.setClassRoom(c.getString(c.getColumnIndex("classroom")));
courseSpec.setCourseName(c.getString(c.getColumnIndex("coursename")));
Expand All @@ -52,6 +53,7 @@ public List<CourseSpec> queryAllCourses(){
courseSpec.setTeacherName(c.getString(c.getColumnIndex("teachername")));
courseSpec.setWeek(c.getInt(c.getColumnIndex("week")));
courseSpecs.add(courseSpec);
Log.i("DBManager","id:query from db:"+courseSpec.getId());
}
c.close();
return courseSpecs;
Expand Down
Loading

0 comments on commit 7b33a06

Please sign in to comment.