Skip to content

Commit

Permalink
v1.66 排行榜
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Oct 8, 2016
1 parent 7479984 commit 5950cc1
Show file tree
Hide file tree
Showing 16 changed files with 708 additions and 296 deletions.
668 changes: 383 additions & 285 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/jars" />
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.njzjz.chemicaltools"
minSdkVersion 15
targetSdkVersion 23
versionCode 22
versionName "1.64"
versionCode 23
versionName "1.66"
}
buildTypes {
release {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@

<meta-data
android:name="UMENG_APPKEY"
android:value="57f39f45e0f55a55be0043f3"></meta-data>
android:value="57f39f45e0f55a55be0043f3" />

<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login"></activity>
android:label="@string/title_activity_login" />
<activity android:name=".RankActivity" android:label="@string/button_rank"></activity>
</application>

</manifest>
10 changes: 9 additions & 1 deletion app/src/main/java/com/njzjz/chemicaltools/ExamActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.List;

public class ExamActivity extends AppCompatActivity {

private static final int action_rank = Menu.FIRST;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -283,6 +283,7 @@ protected void onPause() {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mainmenu, menu);
menu.add(0, action_rank, 100, getString(R.string.button_rank));
return super.onCreateOptionsMenu(menu);
}
@Override
Expand Down Expand Up @@ -327,6 +328,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_About:
new Libs.Builder().withActivityTitle(getString(R.string.button_About)).withFields(R.string.class.getFields()).start(ExamActivity.this);
return true;
case action_rank:
openrank();
return true;
default:
return super.onOptionsItemSelected(item);
}
Expand All @@ -335,6 +339,10 @@ public void openSettings(){
Intent intent =new Intent(this, SettingsActivity.class);
startActivityForResult(intent,1000);
}
public void openrank(){
Intent intent =new Intent(this, RankActivity.class);
startActivity(intent);
}
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data);
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/njzjz/chemicaltools/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ public void done(AVUser avUser, AVException e1) {
@Override
public void done(AVObject avObject, AVException e) {
// 调用 fetchIfNeededInBackground 和 refreshInBackground 效果是一样的。
String qqid=avObject.getString("qqid");
String qqname=avObject.getString("qqname");
//String wechatid=avObject.getString("wechatid");
//String wechatname=avObject.getString("wechatname");
String historyElementOutput=avObject.getString("historyElementOutput");
String historyElementOutputHtml=avObject.getString("historyElementOutputHtml");
String historyElementNumber=avObject.getString("historyElementNumber");
Expand All @@ -348,9 +352,12 @@ public void done(AVObject avObject, AVException e) {
String examMode=avObject.getString("examMode");
if(examMode==null)examMode="0";
Boolean setting_examOptionMode=avObject.getBoolean("setting_examOptionMode");
if(setting_examOptionMode==null)setting_examOptionMode=false;
String pKw=avObject.getString("pKw");
if(pKw==null)pKw="14";
PreferenceUtils.setPrefString(getApplicationContext(),"qqid",qqid);
PreferenceUtils.setPrefString(getApplicationContext(),"qqname",qqname);
//PreferenceUtils.setPrefString(getApplicationContext(),"wechatid",wechatid);
//PreferenceUtils.setPrefString(getApplicationContext(),"wechatname",wechatname);
PreferenceUtils.setPrefString(getApplicationContext(),"historyElementOutput",historyElementOutput);
PreferenceUtils.setPrefString(getApplicationContext(),"historyElementOutputHtml",historyElementOutputHtml);
PreferenceUtils.setPrefString(getApplicationContext(),"historyElementNumber",historyElementNumber);
Expand Down
98 changes: 98 additions & 0 deletions app/src/main/java/com/njzjz/chemicaltools/RankActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.njzjz.chemicaltools;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.FindCallback;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class RankActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rank);
ActionBar ab = getSupportActionBar();
ab.setDisplayShowHomeEnabled(true);
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);

AVQuery<AVUser> userQuery = new AVQuery<>("_User");
userQuery.findInBackground(new FindCallback<AVUser>() {
@Override
public void done(List<AVUser> list, AVException e) {
List<AVUser> userlist = list;// 符合 priority = 0 的 Todo 数组

//生成动态数组,并且转载数据
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
for(int i=0;i<userlist.size();i++)
{
HashMap<String, String> map = new HashMap<String, String>();
String score_str=userlist.get(i).getString("examCorrectNumber");
int score=Integer.parseInt(userlist.get(i).getString("examCorrectNumber"));
if(score>0) {
String name=userlist.get(i).getString("qqname");
if(name==null){
name=userlist.get(i).getUsername();
name=name.substring(0, name.indexOf("@"));
}
map.put("text1", name);
map.put("text2", score_str);
mylist.add(map);
}
}

//冒泡排序
int i, j, len = mylist.size();
HashMap<String, String> temp;
for (i = 0; i < len - 1; i++)
for (j = 0; j < len - 1 - i; j++)
if (Integer.parseInt(mylist.get(j).get("text2")) < Integer.parseInt(mylist.get(j+1).get("text2"))) {
temp = mylist.get(j);
mylist.set(j,mylist.get(j+1));
mylist.set(j+1, temp);
}
for(i=0;i<len;i++) mylist.get(i).put("number", String.valueOf(i + 1));

//生成适配器,数组===》ListItem
SimpleAdapter mSchedule = new SimpleAdapter(RankActivity.this, //没什么解释
mylist,//数据来源
R.layout.ranklist,//ListItem的XML实现

//动态数组与ListItem对应的子项
new String[] {"number","text1", "text2"},

//ListItem的XML文件里面的两个TextView ID
new int[] {R.id.list_item_card_number,R.id.list_item_card_text1,R.id.list_item_card_text2});
//添加并且显示
ListView rank_list = (ListView) findViewById(R.id.rank_list);
rank_list.setAdapter(mSchedule);
}
});
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
//菜单栏返回键功能
case android.R.id.home:
Intent intent = new Intent(this, TitleActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Loading

0 comments on commit 5950cc1

Please sign in to comment.