forked from libilu61BB/iKnow_RefuseStayUpLate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request libilu61BB#1 from libilu61BB/maziyuan150-patch-1
Add files via upload
- Loading branch information
Showing
41 changed files
with
1,164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.test"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".PublicPage" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".SearchPage" | ||
android:label="@string/title_activity_search_page" | ||
android:theme="@style/AppTheme" | ||
android:windowSoftInputMode="adjustPan"> | ||
|
||
|
||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.example.test; | ||
|
||
public class Activity { | ||
private int activityId; | ||
private String startTime; | ||
private String endTime; | ||
private String introduction; | ||
private String classification; | ||
private String place; | ||
private String host; | ||
|
||
public Activity(int activityId, String startTime, String endTime, String introduction, String classification, String place, String host) { | ||
this.activityId = activityId; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
this.introduction = introduction; | ||
this.classification = classification; | ||
this.place = place; | ||
this.host = host; | ||
} | ||
|
||
public int getActivityId() { | ||
return activityId; | ||
} | ||
|
||
public void setActivityId(int activityId) { | ||
this.activityId = activityId; | ||
} | ||
|
||
public String getStartTime() { | ||
return startTime; | ||
} | ||
|
||
public void setStartTime(String startTime) { | ||
this.startTime = startTime; | ||
} | ||
|
||
public String getEndTime() { | ||
return endTime; | ||
} | ||
|
||
public void setEndTime(String endTime) { | ||
this.endTime = endTime; | ||
} | ||
|
||
public String getIntroduction() { | ||
return introduction; | ||
} | ||
|
||
public void setIntroduction(String introduction) { | ||
this.introduction = introduction; | ||
} | ||
|
||
public String getClassification() { | ||
return classification; | ||
} | ||
|
||
public void setClassification(String classification) { | ||
this.classification = classification; | ||
} | ||
|
||
public String getPlace() { | ||
return place; | ||
} | ||
|
||
public void setPlace(String place) { | ||
this.place = place; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
public void setHost(String host) { | ||
this.host = host; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
package com.example.test; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.WindowManager; | ||
import android.widget.Button; | ||
import android.widget.LinearLayout; | ||
|
||
import java.util.List; | ||
|
||
|
||
public class PublicPage extends AppCompatActivity { | ||
|
||
Button browser; | ||
Button[] dateBtns = new Button[14]; | ||
static int[] date={2018,11,11}; | ||
private List<Activity> activities; | ||
Activity activity1 = new Activity(1,"8:00","10:00","智能车大赛真好玩啊哈哈哈哈哈哈哈啊哈哈","科创","六教6A214","汽车系科协"); | ||
Activity activity2 = new Activity(2,"0:00","24:00","编程序真TM好玩啊哈水电费的说法呢发送到哈","计算机","没啥地点","拒绝熬夜组"); | ||
Activity activity3 = new Activity(3,"16:00","20:00","生命学院学生节欢迎大家一起来看很好看的","社工","大礼堂","生命学院学生会"); | ||
Activity activity4 = new Activity(4,"12:00","20:00","赶紧去学习吧哈哈哈哈哈哈哈哈哈哈哈哈","学习","#10 618","我"); | ||
private LinearLayout dateColumn; | ||
private LinearLayout publicActivity; | ||
int shuttle = 0; | ||
|
||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_public_page); | ||
browser = findViewById(R.id.BrowserButton); | ||
browser.setOnClickListener(pageChangeListener); | ||
dateColumn = findViewById(R.id.dateColumn); | ||
initDateColumn(0); | ||
publicActivity = findViewById(R.id.publicActivity); | ||
initPublicActivity(activity1); | ||
shuttle = 1; | ||
} | ||
private void initDateColumn(int a){ | ||
LinearLayout dateCase = dateColumn; | ||
int Size = 14; | ||
String item = ""; | ||
int day = (date[2]+2*date[1]+3*(date[1]+1)/5+date[0]+date[0]/4-date[0]/100+date[0]/400)%7; | ||
|
||
for(int i = 0; i < Size; i++){ | ||
switch((day+i)%7) { | ||
case 0: item = "一\n\n"; break; | ||
case 1: item = "二\n\n"; break; | ||
case 2: item = "三\n\n"; break; | ||
case 3: item = "四\n\n"; break; | ||
case 4: item = "五\n\n"; break; | ||
case 5: item = "六\n\n"; break; | ||
case 6: item = "日\n\n"; break; | ||
} | ||
item += String.valueOf(date[2]+i); | ||
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); | ||
int width = wm.getDefaultDisplay().getWidth(); | ||
|
||
LinearLayout.LayoutParams itemParams = new LinearLayout.LayoutParams(width/7, LinearLayout.LayoutParams.MATCH_PARENT); | ||
itemParams.setMargins(0, 5, 0, 5); | ||
dateBtns[i] = (Button) LayoutInflater.from(this).inflate(R.layout.date_button, null); | ||
dateBtns[i].setText(item); | ||
dateBtns[i].setTag(item); | ||
dateBtns[i].setId(i); | ||
dateBtns[i].setLayoutParams(itemParams); | ||
dateBtns[i].setOnClickListener(dateChangeListener); | ||
dateBtns[a].setBackgroundColor(android.graphics.Color.rgb(237,189,101)); | ||
dateCase.addView(dateBtns[i]); | ||
item = ""; | ||
} | ||
} | ||
private void initPublicActivity(Activity activity){ | ||
LinearLayout activityList = publicActivity; | ||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // 每行的水平LinearLayout | ||
layoutParams.setMargins(0, 0, 0, 0); | ||
String circleButtonText = ""; | ||
String barButtonText = ""; | ||
for(int i = 0; i < 14; i++) { | ||
circleButtonText = activity.getStartTime() + "\n————\n" + activity.getEndTime(); | ||
barButtonText = activity.getIntroduction().substring(0,14) + "...|" + activity.getClassification() + "\n\n" + activity.getHost() + "\t\t" + activity.getPlace(); | ||
|
||
LinearLayout.LayoutParams circleButtonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); | ||
circleButtonParams.setMargins(0, 0, 0, 0); | ||
circleButtonParams.weight = 5; | ||
LinearLayout.LayoutParams barButtonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | ||
barButtonParams.setMargins(0, 0, 0, 0); | ||
barButtonParams.weight = 1; | ||
Button circleBtn = (Button) LayoutInflater.from(this).inflate(R.layout.circle_button, null); | ||
Button barBtn = (Button) LayoutInflater.from(this).inflate(R.layout.bar_button, null); | ||
circleBtn.setText(circleButtonText); | ||
barBtn.setText(barButtonText); | ||
circleBtn.setLayoutParams(circleButtonParams); | ||
barBtn.setLayoutParams(barButtonParams); | ||
LinearLayout activityCase = new LinearLayout(this); | ||
activityCase.setOrientation(LinearLayout.HORIZONTAL); | ||
activityCase.setLayoutParams(layoutParams); | ||
activityCase.addView(circleBtn); | ||
activityCase.addView(barBtn); | ||
activityList.addView(activityCase); | ||
} | ||
} | ||
Button.OnClickListener pageChangeListener = new Button.OnClickListener() { | ||
public void onClick(View v) { | ||
Intent intent = new Intent(PublicPage.this, SearchPage.class); | ||
startActivity(intent); | ||
PublicPage.this.finish(); | ||
} | ||
}; | ||
Button.OnClickListener dateChangeListener = new Button.OnClickListener() { | ||
public void onClick(View v){ | ||
int n = v.getId(); | ||
if(shuttle == 1) { | ||
publicActivity.removeAllViews(); | ||
initPublicActivity(activity2); | ||
shuttle = 2; | ||
} | ||
else if(shuttle == 2){ | ||
publicActivity.removeAllViews(); | ||
initPublicActivity(activity3); | ||
shuttle = 3; | ||
} | ||
else if(shuttle == 3){ | ||
publicActivity.removeAllViews(); | ||
initPublicActivity(activity4); | ||
shuttle = 4; | ||
} | ||
else if(shuttle == 4){ | ||
publicActivity.removeAllViews(); | ||
initPublicActivity(activity1); | ||
shuttle = 1; | ||
} | ||
dateColumn.removeAllViews(); | ||
initDateColumn(n); | ||
} | ||
}; | ||
} | ||
|
||
|
||
|
Oops, something went wrong.