-
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.
- Loading branch information
1 parent
f8dd6ca
commit 6b00497
Showing
15 changed files
with
392 additions
and
99 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
20 changes: 12 additions & 8 deletions
20
Summary/app/src/main/java/com/mitbbs/summary/MApplication.java
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 |
---|---|---|
@@ -1,37 +1,41 @@ | ||
package com.mitbbs.summary; | ||
|
||
import android.app.Application; | ||
import android.content.SharedPreferences; | ||
import android.preference.PreferenceManager; | ||
import android.util.DisplayMetrics; | ||
|
||
/** | ||
* Created by jc on 2017/4/21. | ||
*/ | ||
public class MApplication extends Application { | ||
public class MApplication extends Application { | ||
|
||
private static MApplication mInstance; | ||
|
||
SharedPreferences mPreferences; | ||
public static float DENSITY = 0; | ||
public static int WIDTH = 0; | ||
public static int HEIGHT = 0; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mInstance = this; | ||
// mPreferences = PreferenceManager.getDefaultSharedPreferences(this); | ||
mPreferences = PreferenceManager.getDefaultSharedPreferences(this); | ||
} | ||
|
||
public static MApplication getInstance(){ | ||
return mInstance; | ||
return mInstance; | ||
} | ||
|
||
public static void getMetrics(){ | ||
if(DENSITY != 0 && WIDTH != 0 && HEIGHT != 0)return; | ||
|
||
DisplayMetrics displayMetrics = new DisplayMetrics(); | ||
displayMetrics = getInstance().getResources().getDisplayMetrics(); | ||
DENSITY = displayMetrics.density; | ||
WIDTH = displayMetrics.widthPixels; | ||
HEIGHT = displayMetrics.heightPixels; | ||
displayMetrics = getInstance().getResources().getDisplayMetrics(); | ||
DENSITY = displayMetrics.density; | ||
WIDTH = displayMetrics.widthPixels; | ||
HEIGHT = displayMetrics.heightPixels; | ||
|
||
|
||
} | ||
} |
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
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
43 changes: 0 additions & 43 deletions
43
Summary/app/src/main/java/com/mitbbs/summary/activity/BaseActivity.java
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
Summary/app/src/main/java/com/mitbbs/summary/activity/MainActivity.java
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 |
---|---|---|
@@ -1,15 +1,65 @@ | ||
package com.mitbbs.summary.activity; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
|
||
import com.mitbbs.summary.OkHttpManeger; | ||
import com.mitbbs.summary.R; | ||
|
||
import org.json.JSONObject; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
private ListView listView; | ||
private OkHttpManeger maneger; | ||
private TextView textView; | ||
final String TAG = "MainActivity"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
textView = (TextView) findViewById(R.id.tv_test); | ||
if (maneger == null) maneger = OkHttpManeger.getInstance(); | ||
JSONObject jsonObject = maneger.obtainJson("reqType","search_job","occupation", "", | ||
"min_degree", "", "created_date", "","name", | ||
"","page",1+""); | ||
|
||
maneger.post(jsonObject, new OkHttpManeger.ResponseHandler() { | ||
@Override | ||
public void onStart() { | ||
Log.e(TAG,"onStart"); | ||
} | ||
|
||
@Override | ||
public void onSuccess(JSONObject object) { | ||
Log.e(TAG,"onSuccess.object = "+object.toString()); | ||
} | ||
|
||
@Override | ||
public void onFail(Exception e) { | ||
Log.e(TAG,"onFail"+((e == null)?"null":e.getCause())); | ||
|
||
} | ||
|
||
@Override | ||
public void onFinish() { | ||
Log.e(TAG,"onFinish"); | ||
} | ||
}); | ||
|
||
|
||
|
||
textView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
startActivity(new Intent(MainActivity.this,TestActivity.class)); | ||
} | ||
}); | ||
|
||
} | ||
} |
Oops, something went wrong.