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