|
|
@ -8,9 +8,12 @@ import android.os.Bundle;
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
|
|
import android.os.Message;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
|
|
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.fragment.app.ListFragment;
|
|
|
|
import androidx.fragment.app.ListFragment;
|
|
|
@ -46,6 +49,15 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
|
|
|
Context mContext;
|
|
|
|
Context mContext;
|
|
|
|
private NewsAdapter newsAdapter;
|
|
|
|
private NewsAdapter newsAdapter;
|
|
|
|
private ListView lv_news;
|
|
|
|
private ListView lv_news;
|
|
|
|
|
|
|
|
private Handler mhandler = new Handler(){
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handleMessage(@NonNull Message msg) {
|
|
|
|
|
|
|
|
super.handleMessage(msg);
|
|
|
|
|
|
|
|
if(msg.what==1){
|
|
|
|
|
|
|
|
newsAdapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
|
|
|
@ -143,8 +155,11 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
|
|
|
private class UploadThread extends Thread{
|
|
|
|
private class UploadThread extends Thread{
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
NewsUtils.getAllNews(mContext,list);
|
|
|
|
Message message = mhandler.obtainMessage();
|
|
|
|
newsAdapter.notifyDataSetChanged();
|
|
|
|
int isload = NewsUtils.getAllNews(mContext,list);
|
|
|
|
|
|
|
|
message.what = isload;
|
|
|
|
|
|
|
|
mhandler.sendMessage(message);
|
|
|
|
|
|
|
|
//newsAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|