Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.72 KB | None | 0 0
  1. public class ReceivedSMS extends ListFragment implements AbsListView.OnScrollListener {
  2.  
  3. public List<ReceiveFields> rows;
  4.  
  5. private int prevVisibleItem;
  6.  
  7. private TSMS tsms;
  8.  
  9. private String username;
  10.  
  11. private String password;
  12.  
  13. public Long getLastID;
  14.  
  15. private boolean isFirstTime;
  16.  
  17. private Context context;
  18.  
  19. private DatabaseHandler db;
  20.  
  21. private SQLiteDatabase dbHelper;
  22.  
  23. private ViewReceivedSMSDetailes receiveListView;
  24.  
  25.  
  26. public ReceivedSMS(Context context, String username, String password) {
  27.  
  28. this.username = username;
  29.  
  30. this.password = password;
  31.  
  32. this.context = context;
  33.  
  34. }
  35.  
  36. public ReceivedSMS(String username, String password, long start, long count, Context context) {
  37.  
  38. this.username = username;
  39.  
  40. this.password = password;
  41.  
  42. this.context = context;
  43.  
  44. tsms = new TSMS(context, new User(this.username, this.password));
  45.  
  46. try {
  47.  
  48. getReceivedSMS(start, count);
  49.  
  50. } catch (Exception e1) {
  51.  
  52. e1.printStackTrace();
  53.  
  54. Log.e("Error in getReceivedSMS(start, count); ", "");
  55. }
  56.  
  57. }
  58.  
  59. public List<ReceiveFields> getReceivedSMS(long start, long count) throws UnsupportedEncodingException {
  60.  
  61. tsms = new TSMS(context, new User(this.username, this.password));
  62.  
  63. try {
  64.  
  65. rows = tsms.getReceivedSMS(start, count);
  66.  
  67. saveRowsintoDatabase( rows );
  68.  
  69. } catch (TException e) {
  70.  
  71. e.printStackTrace();
  72.  
  73. Log.e(getClass().toString(), "ERROR IN Fetch SMS From WebService List<ReceiveFields> getReceivedSMS(long start, long count) "+ String.valueOf(e));
  74.  
  75. }
  76.  
  77. return rows;
  78. }
  79.  
  80.  
  81. @Override
  82. public void onCreate(Bundle savedInstanceState) {
  83.  
  84. super.onCreate(savedInstanceState);
  85.  
  86. db = new DatabaseHandler(context);
  87.  
  88. dbHelper = db.getWritableDatabase();
  89.  
  90. setReceivedSMSToListView();
  91.  
  92. }
  93.  
  94. }
  95.  
  96. private class AsyncCallWS extends AsyncTask<Void, Void, Void> {
  97. @Override
  98. protected Void doInBackground(Void... params) {
  99.  
  100. }
  101.  
  102. @Override
  103. protected void onPostExecute(Void result) {
  104.  
  105. }
  106.  
  107. @Override
  108. protected void onPreExecute() {
  109.  
  110. }
  111.  
  112. @Override
  113. protected void onProgressUpdate(Void... values) {
  114.  
  115. }
  116.  
  117. }
  118.  
  119. public ReceivedSMS(String username, String password, long start, long count, Context context) {
  120.  
  121. this.username = username;
  122.  
  123. this.password = password;
  124.  
  125. this.context = context;
  126.  
  127. tsms = new TSMS(context, new User(this.username, this.password));
  128.  
  129. try {
  130.  
  131. getReceivedSMS(start, count);
  132.  
  133. } catch (Exception e1) {
  134.  
  135. e1.printStackTrace();
  136.  
  137. Log.e("Error in getReceivedSMS(start, count); ", "");
  138. }
  139.  
  140. }
  141.  
  142. tsms = new TSMS(context, new User(this.username, this.password));
  143.  
  144. try {
  145.  
  146. getReceivedSMS(start, count);
  147.  
  148. } catch (Exception e1) {
  149.  
  150. e1.printStackTrace();
  151.  
  152. Log.e("Error in getReceivedSMS(start, count); ", "");
  153. }
  154.  
  155. public List<ReceiveFields> getReceivedSMS(long start, long count) throws UnsupportedEncodingException {
  156.  
  157. tsms = new TSMS(context, new User(this.username, this.password));
  158.  
  159. try {
  160.  
  161. rows = tsms.getReceivedSMS(start, count);
  162.  
  163. saveRowsintoDatabase( rows );
  164.  
  165. } catch (TException e) {
  166.  
  167. e.printStackTrace();
  168.  
  169. Log.e(getClass().toString(), "ERROR IN Fetch SMS From WebService "+ String.valueOf(e));
  170.  
  171. }
  172.  
  173. return rows;
  174. }
  175.  
  176. public class WSDLHelper {
  177. public static String call(SoapObject request){
  178. ProcessTask p =new ProcessTask(request);
  179. return p.execute();
  180. }
  181. }
  182. class ProcessTask extends AsyncTask<Void, Void, SoapObject > {
  183. SoapObject request;
  184.  
  185. public String ProcessTask(SoapObject rq){
  186.  
  187. request = rq;
  188.  
  189. }
  190.  
  191. @Override
  192. protected void onPreExecute() {
  193. super.onPreExecute();
  194. }
  195.  
  196. @Override
  197. protected String doInBackground(Void... params) {
  198. String result = null;
  199.  
  200. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
  201. envelope.setOutputSoapObject(request);
  202.  
  203. AndroidHttpTransport transport = new AndroidHttpTransport(Strings.URL_TSMS);
  204. transport.debug = true;
  205.  
  206. try {
  207. transport.call(Strings.URL_TSMS + request.getName(), envelope);
  208. result = envelope.getResponse().toString();
  209. } catch (IOException ex) {
  210. Log.e("" , ex.getMessage());
  211. } catch (XmlPullParserException ex) {
  212. Log.e("" , ex.getMessage());
  213. }
  214.  
  215. if (result.equals(String.valueOf(Integers.CODE_USER_PASS_FALSE)))
  216. return result;
  217. else
  218. return null;
  219. }
  220.  
  221. @Override
  222. protected void onPostExecute(String result) {
  223.  
  224. super.onPostExecute(result);
  225. }
  226.  
  227. }
  228.  
  229. public class ProcessTask extends AsyncTask<Void, Integer, String>{
  230. String s1, s2, s3, s4;
  231.  
  232. public ProcessTask(String str1, String str2, String str3, String str4) {
  233. // TODO Auto-generated constructor stub
  234. s1 = str1;
  235. s2 = str2;
  236. s3 = str3;
  237. s4 = str4;
  238. }
  239.  
  240. @Override
  241. protected void onPreExecute() {
  242. // TODO Auto-generated method stub
  243. //do something with strings
  244. super.onPreExecute();
  245. }
  246.  
  247. @Override
  248. protected String doInBackground(Void... params) {
  249. // TODO Auto-generated method stub
  250.  
  251. //your code of parsing
  252.  
  253. return null;
  254. }
  255.  
  256. @Override
  257. protected void onPostExecute(String result) {
  258. // TODO Auto-generated method stub
  259.  
  260. super.onPostExecute(result);
  261. }
  262. }
  263.  
  264. ProcessTask p = new ProcessTask(s1, s2, s3, s4);
  265. p.execute();
  266.  
  267. public class ProcessTask extends AsyncTask<Void, Integer, String>
  268.  
  269. public class ProcessTask extends AsyncTask<Void, Integer, List<ReceiveFields>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement