|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package hunnu.sj.raise_money;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
|
|
@ -9,6 +11,9 @@ import com.google.android.material.snackbar.Snackbar;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
|
import androidx.fragment.app.ListFragment;
|
|
|
|
|
import androidx.navigation.NavController;
|
|
|
|
|
import androidx.navigation.Navigation;
|
|
|
|
|
import androidx.navigation.ui.AppBarConfiguration;
|
|
|
|
@ -22,13 +27,25 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
|
|
|
|
|
|
|
|
|
import android.view.Menu;
|
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
|
import android.widget.ListView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
|
|
|
private AppBarConfiguration mAppBarConfiguration;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener{
|
|
|
|
|
private AppBarConfiguration mAppBarConfiguration;
|
|
|
|
|
private Toolbar toolbar;
|
|
|
|
|
private ActionBarDrawerToggle mToggle;
|
|
|
|
|
private DrawerLayout mDrawerlayout;
|
|
|
|
|
private NavigationView navigationView;
|
|
|
|
|
private
|
|
|
|
|
TextView menu_name;
|
|
|
|
|
TextView menu_role;
|
|
|
|
|
ArrayList<News> list = new ArrayList<>();
|
|
|
|
|
Context mContext;
|
|
|
|
|
private NewsAdapter newsAdapter;
|
|
|
|
|
private ListView lv_news;
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
|
@ -37,9 +54,20 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
User user;
|
|
|
|
|
user = (User) intent.getSerializableExtra("user");
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
|
|
|
mContext = this;
|
|
|
|
|
newsAdapter = new NewsAdapter(this,list);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
if(navigationView.getHeaderCount() > 0) {//设置侧滑栏的显示的值
|
|
|
|
|
View header = navigationView.getHeaderView(0);
|
|
|
|
|
TextView menu_name = header.findViewById(R.id.user_name);
|
|
|
|
|
TextView menu_role = header.findViewById(R.id.user_role);
|
|
|
|
|
menu_name.setText(user.getName());
|
|
|
|
|
menu_role.setText(user.getRole());
|
|
|
|
|
}
|
|
|
|
|
/*Toolbar toolbar = findViewById(R.id.toolbar);
|
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
|
FloatingActionButton fab = findViewById(R.id.fab);
|
|
|
|
|
fab.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@ -62,13 +90,47 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
|
|
|
|
|
NavigationUI.setupWithNavController(navigationView, navController);
|
|
|
|
|
|
|
|
|
|
if(navigationView.getHeaderCount() > 0) {
|
|
|
|
|
if(navigationView.getHeaderCount() > 0) {//设置侧滑栏的显示的值
|
|
|
|
|
View header = navigationView.getHeaderView(0);
|
|
|
|
|
TextView menu_name = header.findViewById(R.id.user_name);
|
|
|
|
|
TextView menu_role = header.findViewById(R.id.user_role);
|
|
|
|
|
menu_name.setText(user.getName());
|
|
|
|
|
menu_role.setText(user.getRole());
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
//setContentView(R.layout.content_main);
|
|
|
|
|
//new UploadThread().start();
|
|
|
|
|
lv_news = findViewById(R.id.list);
|
|
|
|
|
lv_news.setAdapter(newsAdapter);
|
|
|
|
|
lv_news.setOnItemClickListener(this);
|
|
|
|
|
News news = new News();
|
|
|
|
|
news.setTitle("火箭发射成功");
|
|
|
|
|
news.setDes("地方上的房贷首付读书首付第三方的手房贷首付第三方的手负担");
|
|
|
|
|
news.setHead_icon(ContextCompat.getDrawable(this, R.drawable.ic_launcher_background));
|
|
|
|
|
list.add(news);
|
|
|
|
|
new UploadThread().start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void init(){
|
|
|
|
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
|
|
mDrawerlayout = (DrawerLayout)findViewById(R.id.drawer_layout);
|
|
|
|
|
toolbar.setTitle("");
|
|
|
|
|
mToggle = new ActionBarDrawerToggle(this, mDrawerlayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
|
|
|
|
mDrawerlayout.addDrawerListener(mToggle);
|
|
|
|
|
mToggle.syncState();
|
|
|
|
|
|
|
|
|
|
mDrawerlayout.setDrawerListener(mToggle);
|
|
|
|
|
navigationView = findViewById(R.id.nav_view);
|
|
|
|
|
}
|
|
|
|
|
@Override//点击条目时调用该方法,parent指listview,position指条目位置
|
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
News news = (News)parent.getItemAtPosition(position);
|
|
|
|
|
String url = "www.baidu.com";
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
intent.setAction(Intent.ACTION_VIEW);
|
|
|
|
|
intent.setData(Uri.parse(url));
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -78,15 +140,30 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class UploadThread extends Thread{
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onSupportNavigateUp() {
|
|
|
|
|
public void run() {
|
|
|
|
|
NewsUtils.getAllNews(mContext,list);
|
|
|
|
|
newsAdapter.notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*public boolean onSupportNavigateUp() {
|
|
|
|
|
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
|
|
|
|
|
return NavigationUI.navigateUp(navController, mAppBarConfiguration)
|
|
|
|
|
|| super.onSupportNavigateUp();
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
public void onNeedHelp(MenuItem item){
|
|
|
|
|
public void onNeedHelp(MenuItem item){//侧滑栏的item,用于提交信息
|
|
|
|
|
Intent intent = new Intent(this, UploadActivity.class);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}//ssds
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onBrowseDonateRecord(MenuItem item){
|
|
|
|
|
Intent intent = new Intent(this,BrowseRecordActivity.class);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|