首页 > 其他分享 >6.12

6.12

时间:2024-06-18 09:50:21浏览次数:19  
标签:return String 6.12 void private import public

Android 项目
package com.example.camera.pojo;

import java.util.Date;

public class Policy {
private Long id;
private String name;
private String type;
private String category;
private String range;
private String document;
private String form;
private String organ;
private Date viadata;
private Date pubdata;
private Date perdata;
private String field;
private String theme;
private String keyword;
private String superior;
private String precursor;
private String succeed;
private String state;
private String text;
private String pdf;
private String redundancy;
private String rank;
private String policykey;
private String newrank;
private String year;
private String newkey;
private String secondtheme;
private Integer allsum;

// Getters and Setters
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}

public String getRange() {
return range;
}

public void setRange(String range) {
this.range = range;
}

public String getDocument() {
return document;
}

public void setDocument(String document) {
this.document = document;
}

public String getForm() {
return form;
}

public void setForm(String form) {
this.form = form;
}

public String getOrgan() {
return organ;
}

public void setOrgan(String organ) {
this.organ = organ;
}

public Date getViadata() {
return viadata;
}

public void setViadata(Date viadata) {
this.viadata = viadata;
}

public Date getPubdata() {
return pubdata;
}

public void setPubdata(Date pubdata) {
this.pubdata = pubdata;
}

public Date getPerdata() {
return perdata;
}

public void setPerdata(Date perdata) {
this.perdata = perdata;
}

public String getField() {
return field;
}

public void setField(String field) {
this.field = field;
}

public String getTheme() {
return theme;
}

public void setTheme(String theme) {
this.theme = theme;
}

public String getKeyword() {
return keyword;
}

public void setKeyword(String keyword) {
this.keyword = keyword;
}

public String getSuperior() {
return superior;
}

public void setSuperior(String superior) {
this.superior = superior;
}

public String getPrecursor() {
return precursor;
}

public void setPrecursor(String precursor) {
this.precursor = precursor;
}

public String getSucceed() {
return succeed;
}

public void setSucceed(String succeed) {
this.succeed = succeed;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}

public String getPdf() {
return pdf;
}

public void setPdf(String pdf) {
this.pdf = pdf;
}

public String getRedundancy() {
return redundancy;
}

public void setRedundancy(String redundancy) {
this.redundancy = redundancy;
}

public String getRank() {
return rank;
}

public void setRank(String rank) {
this.rank = rank;
}

public String getPolicykey() {
return policykey;
}

public void setPolicykey(String policykey) {
this.policykey = policykey;
}

public String getNewrank() {
return newrank;
}

public void setNewrank(String newrank) {
this.newrank = newrank;
}

public String getYear() {
return year;
}

public void setYear(String year) {
this.year = year;
}

public String getNewkey() {
return newkey;
}

public void setNewkey(String newkey) {
this.newkey = newkey;
}

public String getSecondtheme() {
return secondtheme;
}

public void setSecondtheme(String secondtheme) {
this.secondtheme = secondtheme;
}

public Integer getAllsum() {
return allsum;
}

public void setAllsum(Integer allsum) {
this.allsum = allsum;
}
}
package com.example.camera.pojo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.camera.R;
import com.example.camera.pojo.Policy;

import java.util.List;

public class PolicyAdapter extends ArrayAdapter<Policy> {

private Context context;
private List<Policy> policies;

public PolicyAdapter(Context context, int resource, List<Policy> objects) {
super(context, resource, objects);
this.context = context;
this.policies = objects;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;

if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(R.layout.policy_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.nameTextView = convertView.findViewById(R.id.textView_policyName);
viewHolder.timeTextView = convertView.findViewById(R.id.textView_policyTime);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}

Policy policy = policies.get(position);
viewHolder.nameTextView.setText(policy.getName());
viewHolder.timeTextView.setText(policy.getPubdata().toString()); // 格式化日期

return convertView;
}

static class ViewHolder {
TextView nameTextView;
TextView timeTextView;
}
}
package com.example.camera;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class BlankFragment1 extends Fragment {
private View root;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (root == null) {
root = inflater.inflate(R.layout.fragment_blank1, container, false);
}
return root;
}
}
package com.example.camera;

import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

public class HtmlDisplayActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_html);

// 获取Intent传递过来的HTML内容
String Text = getIntent().getStringExtra("Text");
Log.d("HtmlDisplayActivity", "Received HTML Content: " + Text);

// 初始化WebView
WebView webView = findViewById(R.id.webView);

// 设置WebView客户端,允许打开新的窗口(比如链接)
webView.setWebViewClient(new WebViewClient());

// 配置WebView设置
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true); // 如果HTML中有JavaScript代码,需要启用
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);

// 加载HTML内容
webView.loadDataWithBaseURL(null, Text, "text/html", "utf-8", null);
}
}
package com.example.camera;

import android.content.Context;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.camera.placeholder.PlaceholderContent;

/**
* A fragment representing a list of Items.
*/
public class ItemFragment extends Fragment {

// TODO: Customize parameters
private int mColumnCount = 1;

// TODO: Customize parameter argument names
private static final String ARG_COLUMN_COUNT = "column-count";

// TODO: Customize parameter initialization
@SuppressWarnings("unused")
public static ItemFragment newInstance(int columnCount) {
ItemFragment fragment = new ItemFragment();
Bundle args = new Bundle();
args.putInt(ARG_COLUMN_COUNT, columnCount);
fragment.setArguments(args);
return fragment;
}

/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public ItemFragment() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (getArguments() != null) {
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_item_list, container, false);

// Set the adapter
if (view instanceof RecyclerView) {
Context context = view.getContext();
RecyclerView recyclerView = (RecyclerView) view;
if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
} else {
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
}
recyclerView.setAdapter(new MyItemRecyclerViewAdapter(PlaceholderContent.ITEMS));
}
return view;
}
}
package com.example.camera;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.example.camera.pojo.Policy;
import com.example.camera.pojo.PolicyAdapter;
import com.example.camera.tools.Okhttp3helper;
import com.google.android.material.button.MaterialButton;

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

public class MainActivity extends AppCompatActivity {
private Okhttp3helper OkHttpHelper =new Okhttp3helper();
private MaterialButton buttonSearch;

private EditText editText;

private ListView listView;
private PolicyAdapter adapter;
private List<Policy> policies;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
buttonSearch=findViewById(R.id.buttonSearch);
editText=findViewById(R.id.editText);
listView = findViewById(R.id.list);

policies = new ArrayList<>(); // 假设你已经有了政策数据列表
// 初始化policies列表,可以从网络、数据库等地方获取数据

adapter = new PolicyAdapter(this, R.layout.policy_item, policies);
listView.setAdapter(adapter);
// Button button=findViewById(R.id.btn1);
// Button button_2=findViewById(R.id.btn2);
// button.setOnClickListener(this);
// button_2.setOnClickListener(this);
fetchPolicies();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// 假设你的数据模型类为Policy,且其中有一个字段存储HTML内容
Policy policy = (Policy) parent.getItemAtPosition(position);

String Text = policy.getText(); // 获取HTML内容
Log.d("MainActivity", "Sending HTML Content: " + Text);
// 使用Intent传递HTML内容到新的Activity

Intent intent = new Intent(MainActivity.this, HtmlDisplayActivity.class);
intent.putExtra("Text", Text);
MainActivity.this.startActivity(intent);
}
});
buttonSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String query = editText.getText().toString().trim();
if (!query.isEmpty()) {
queryPolicies(query);
} else {
showToast("请输入查询内容");
}
}
});
}

private void queryPolicies(String query) {
OkHttpHelper.queryPolicy(query, new Okhttp3helper.QueryCallback() {
@Override
public void onPolicyReceived(List<Policy> policies) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// 更新数据并通知Adapter数据集变更
MainActivity.this.policies.clear();
MainActivity.this.policies.addAll(policies);
if (adapter != null) {
adapter.notifyDataSetChanged();
}
}
});
}

@Override
public void onPolicyFailure(String errorMessage) {
runOnUiThread(new Runnable() {
@Override
public void run() {
showToast("网络请求失败");
}
});

}
});
}


private void fetchPolicies() {
OkHttpHelper.getPolicy(new Okhttp3helper.DataListCallback() {
public void onPlanReceived(List<Policy> policies) {
// 确保在主线程更新UI
runOnUiThread(new Runnable() {
@Override
public void run() {
// 更新数据并通知Adapter数据集变更
MainActivity.this.policies.clear();
MainActivity.this.policies.addAll(policies);
if (adapter != null) {
adapter.notifyDataSetChanged();
}
}
});
}

@Override
public void onPlanFailure(String errorMessage) {
runOnUiThread(new Runnable() {
@Override
public void run() {
showToast("网络请求失败");
}
});
}
});
}

private void showToast(String message) {
Context context = getApplicationContext();
int duration = Toast.LENGTH_SHORT; // 持续时间,可选Toast.LENGTH_LONG
Toast toast = Toast.makeText(context, message, duration);
toast.show();
}




}
package com.example.camera;

import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.camera.placeholder.PlaceholderContent.PlaceholderItem;
import com.example.camera.databinding.FragmentItemBinding;

import java.util.List;

/**
* {@link RecyclerView.Adapter} that can display a {@link PlaceholderItem}.
* TODO: Replace the implementation with code for your data type.
*/
public class MyItemRecyclerViewAdapter extends RecyclerView.Adapter<MyItemRecyclerViewAdapter.ViewHolder> {

private final List<PlaceholderItem> mValues;

public MyItemRecyclerViewAdapter(List<PlaceholderItem> items) {
mValues = items;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

return new ViewHolder(FragmentItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));

}

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mIdView.setText(mValues.get(position).id);
holder.mContentView.setText(mValues.get(position).content);
}

@Override
public int getItemCount() {
return mValues.size();
}

public class ViewHolder extends RecyclerView.ViewHolder {
public final TextView mIdView;
public final TextView mContentView;
public PlaceholderItem mItem;

public ViewHolder(FragmentItemBinding binding) {
super(binding.getRoot());
mIdView = binding.itemNumber;
mContentView = binding.content;
}

@Override
public String toString() {
return super.toString() + " '" + mContentView.getText() + "'";
}
}
}


标签:return,String,6.12,void,private,import,public
From: https://www.cnblogs.com/wcy1111/p/18253705

相关文章

  • 6.12
    实验二 路由器动态路由的配置方法  一、实验目的:1.理解动态路由的工作原理;2.学习并掌握动态路由协议RIP的配置;3.学习并掌握动态路由协议OSPF的配置;4.进一步学习路由器的配置命令。二、实验原理: RIP:RoutingInformationProtocol,路由信息协议,是应用较早、使用较普遍的IGP......
  • 6.12
    今日学习总结学习时间1.5h代码如下packagecom.app.chapter04;importandroid.os.Bundle;importandroidx.activity.EdgeToEdge;importandroidx.appcompat.app.AppCompatActivity;importandroidx.core.graphics.Insets;importandroidx.core.view.ViewCompat;importandroidx......
  • 6.12安卓开发日记56
    再次深入《构建之法》,我仿佛踏上了一场对软件工程领域深度探索与自我反思的旅程。这本书不仅是一份实践指南,更像是一位智者,在我耳边低语,引导我理解软件开发的本质,以及如何在这个充满挑战与机遇的行业中稳健前行。以下是我在这次重读过程中获得的新见解和深化的感悟。###1.**软......
  • 6.12Web应用漏洞发现探针利用
    已知CMS、开发框架、思路:各个页面查看数据包(地址信息),查看框架,上fofa关键字搜索(查看其框架信息如thinkhphp),利用检测工具测试漏洞情况;网站根目录下的robots.txt文件信息;/data/admin/ver.txt网站升级时间;常见SQL注入、登录、逻辑越权支付逻辑绕过思路:#https://blog.csdn.ne......
  • 6.12
    后端server:port:7070spring:datasource:driver-class-name:com.mysql.cj.jdbc.Driverurl:jdbc:mysql://localhost:3306/k3?serverTimezone=GMT%2b8username:rootpassword:123456mybatis:mapper-locations:classpath*:mapper/*.xmlconfiguration:......
  • 6.12《构建之法》
    每一次翻开《构建之法》,都仿佛是在与一位智慧而经验丰富的导师进行对话,它不仅提供了构建高质量软件的实践框架,更是一次对个人成长和团队协作哲学的深刻探讨。这次重读,我又有了一些新的收获和感悟。最令我触动的是书中对“持续学习”文化的强调。在软件行业,技术日新月异,只有不断学......
  • 2024.6.12
    sparksql对json和csv文件的读取publicclassSparkSQL05_Source_JSON_1{publicstaticvoidmain(String[]args){//TODO构建环境对象//Spark在结构化数据的处理场景中对核心功能,环境进行了封装//构建SparkSQL的环境对象时,......
  • 2024.6.12(个人总结)
    在软件工程专业的大二下半学期中,我经历了许多学习和成长的过程,积累了宝贵的经验和知识。在这个学期里,我学习了诸多关于软件工程的理论知识和实践技能,参与了各种项目和实践活动,不断提升自己的能力和水平。以下是对这个学期的个人总结:首先,在本学期的学习中,我深刻理解了软件工程的重......
  • 6.12.双指针专题
    27.移除元素题意描述:给你一个数组nums和一个值val,你需要原地移除所有数值等于val的元素。元素的顺序可能发生改变。然后返回nums中与val不同的元素的数量。假设nums中不等于val的元素数量为k,要通过此题,您需要执行以下操作:更改nums数组,使nums的前k个......
  • 6.12高一高考集训欢乐赛
    前面是题解,后面是垃圾话T1Efim与奇怪的成绩贪心的找第一个可以四舍五入的,然后往上进位。T2BeautifulIPAddresses因为回文,所以\(n\ge7\)太长了,不合法,并且只用找一半,爆搜check即可。T3装饰结论题?发现两个上界:\(\frac{a+b+c}{3},a+b+c-\max(a,b,c)\),答案就是两者中较......