备份,含修复插件
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.yutou.jianr_mg.plugins.Activitys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import Interfaces.BaseActivityInterface;
|
||||
|
||||
public class MainActivity implements BaseActivityInterface {
|
||||
public static String name="adlist";
|
||||
public static String title="恰饭时刻";
|
||||
public static String appId="abcdefg";
|
||||
public static String url="#";
|
||||
public static String image="#";
|
||||
public static String mainFunction="com.yutou.jianr_mg.plugs.test.app1.MainActivity#localActivity";
|
||||
public static Integer permission=0;
|
||||
|
||||
public MainActivity() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState, LinearLayout layout, final Context context, Intent intent) {
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRestart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIntent(Intent intent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data getData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yutou.jianr_mg.plugins.Activitys.Utils;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.ConnectException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.yutou.jianr_mg.plugins.Interfaces.PluginHttpInterface;
|
||||
|
||||
|
||||
public class PluginHttpTools {
|
||||
private static final String TAG = PluginHttpTools.class.getName();
|
||||
private static PluginHttpTools network;
|
||||
|
||||
private PluginHttpTools() {
|
||||
}
|
||||
|
||||
public static PluginHttpTools init() {
|
||||
if (network == null) {
|
||||
network = new PluginHttpTools();
|
||||
}
|
||||
return network;
|
||||
}
|
||||
|
||||
public void httpGet(final String url, final PluginHttpInterface networkInterface) {
|
||||
System.out.println("HTTP>>>>"+url);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
connection.connect();
|
||||
String tmp, str = "";
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str += tmp;
|
||||
}
|
||||
reader.close();
|
||||
networkInterface.httpGetData(str, connection.getResponseCode());
|
||||
Log.i(TAG + "[" + url + "]", "body:" + str + " (" + connection.getResponseCode() + ")");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
networkInterface.httpError(e);
|
||||
Log.e(TAG, url + "\n" + e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
public static void post(final String url, final JSONObject body, final PluginHttpInterface networkInterface) throws Exception{
|
||||
System.out.println(1);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(2);
|
||||
String tmp, str = "";
|
||||
try {
|
||||
System.out.println(3);
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.connect();
|
||||
System.out.println(4);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str += tmp;
|
||||
}
|
||||
Log.i(TAG, "[域名]" + url + " = [body]" + body.toString() + " -> [接收] " + str);
|
||||
|
||||
// Log.i(TAG + "[" + url + "?" + toGetSplice(body) + "]", "body:" + str + " (" + connection.getResponseCode() + ")");
|
||||
if (networkInterface != null)
|
||||
networkInterface.httpGetData(str, connection.getResponseCode());
|
||||
|
||||
} catch (Exception e) {
|
||||
if (networkInterface != null)
|
||||
networkInterface.httpError(e);
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String toGetSplice(JSONObject json) {
|
||||
if (json == null || json.toString().equals("{}")) {
|
||||
return "";
|
||||
}
|
||||
String string = "";
|
||||
Iterator<String> keys = json.keys();
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
try {
|
||||
string += "&" + key + "=" + json.getString(key);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
string += "&" + URLEncoder.encode(key, "UTF-8") + "=";
|
||||
// string += "&" + key + "=";
|
||||
} catch (Exception e1) {
|
||||
string += "&" + key + "=";
|
||||
}
|
||||
}
|
||||
}
|
||||
string = string.substring(1, string.length()).replaceAll(" ", "");
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
private static int reindex = 0;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.yutou.jianr_mg.plugins.Activitys.Utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.yutou.jianr_mg.plugins.Activitys.MainActivity;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.yutou.jianr_mg.plugins.Interfaces.PluginHttpInterface;
|
||||
|
||||
public class PlugsAdTools {
|
||||
public static int req=0,show=1,click=2;
|
||||
public static int Open=1,Inter=2,Banner=3,Native=4;
|
||||
private static Context context;
|
||||
public static void upload(final Context context, int adType, int uType){
|
||||
try {
|
||||
PlugsAdTools.context=context;
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("adtype",adType);
|
||||
json.put("utype",uType);
|
||||
json.put("imei",getIMEI());
|
||||
PluginHttpTools.init().httpGet( MainActivity.homeurl+"android/ad/user.do?adtype="+adType+"&utype="+uType+"&imei="+getIMEI(), new PluginHttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(Object string, int state) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string.toString());
|
||||
if(json.getInt("code")==100){
|
||||
JSONObject data=json.getJSONObject("data");
|
||||
final String msg=data.getString("msg");
|
||||
System.out.println("服务器回调:"+msg);
|
||||
if(data.getInt("code")==100){
|
||||
MainActivity.handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(context,msg,Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
/*if(!data.isNull("user")){
|
||||
AppData.userdata= JSON.parseObject(data.getJSONObject("user").getJSONObject("data").getJSONObject("userdata").toString(), UUserdata.class);
|
||||
}*/
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private static String getIMEI() {
|
||||
String imei="-1";
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (telephonyManager != null && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
|
||||
imei = telephonyManager.getDeviceId();
|
||||
}
|
||||
return imei;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.yutou.jianr_mg.plugins;
|
||||
|
||||
public class Data {
|
||||
public static String name="test";
|
||||
public static String title="测试插件";
|
||||
public static String appId="abcdefg";
|
||||
public static String url="#";
|
||||
public static String image="#";
|
||||
public static String mainFunction="com.yutou.jianr_mg.plugs.test.app1.MainActivity#localActivity";
|
||||
public static Integer permission=0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.yutou.jianr_mg.plugins.Interfaces;
|
||||
|
||||
public interface PluginHttpInterface {
|
||||
void httpGetData(Object data, int state);
|
||||
void httpError(Exception e);
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.yutou.jianr_mg.plugs.test.app1;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
|
||||
import Interfaces.BaseActivityInterface;
|
||||
|
||||
public class MainActivity implements BaseActivityInterface {
|
||||
public MainActivity() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent) {
|
||||
Toast.makeText(context,"已装载插件",Toast.LENGTH_LONG).show();
|
||||
TextView textView=new TextView(context);
|
||||
textView.setText("测试");
|
||||
layout.addView(textView);
|
||||
final KProgressHUD hud=showLoading(context,null,null);
|
||||
hud.show();
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hud.dismiss();
|
||||
}
|
||||
},3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIntent(Intent intent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data getData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static KProgressHUD showLoading(Context context, String title, String text) {
|
||||
if (text == null) {
|
||||
text = "载入中";
|
||||
}
|
||||
if (title == null) {
|
||||
title = "请稍后";
|
||||
}
|
||||
KProgressHUD hud = KProgressHUD.create(context)
|
||||
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
|
||||
.setLabel(title)
|
||||
.setDetailsLabel(text)
|
||||
.setCancellable(false)
|
||||
.setAnimationSpeed(2)
|
||||
.setDimAmount(0.5f);
|
||||
return hud;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.yutou.jianr_mg.plugs.test.app1;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
public interface SDKActivity {
|
||||
void onCreate(Activity activity, Bundle savedInstanceState);
|
||||
void onResume();
|
||||
void onPause();
|
||||
void onRestart();
|
||||
void finish();
|
||||
void onStop();
|
||||
Activity getActivity();
|
||||
View createView(Activity sdkActivity);
|
||||
}
|
||||
Reference in New Issue
Block a user