lvDictionary.setOnItemClickListener(new OnItemClickListener() {
@Override public void onItemClick(AdapterView listView, View view,
int position, long id) {
// Get the cursor, positioned to the corresponding row in the result set
Cursor cursor = (Cursor) listView.getItemAtPosition(position);
// Get the state's capital from this row in the database.
String countryCode = cursor.getString(cursor.getColumnIndexOrThrow("code"));
Toast.makeText(getApplicationContext(), countryCode, Toast.LENGTH_SHORT).show();
}
});
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// get the file url
fileUri = savedInstanceState.getParcelable("file_uri");
}
private Cursor employees;
private MyDatabase db;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* db = new MyDatabase(this);
employees = db.getEmployees(); // you would not typically call this on the main thread
ListAdapter adapter = new SimpleCursorAdapter(this,
//android.R.layout.simple_list_item_1, //id xml
R.layout.read_more_activity, //+
employees,
new String[] {"word"},
new int[] {android.R.id.text1}); //id textView
getListView().setAdapter(adapter);
setTitle("Test - " + db.getUpgradeVersion());
}
@Override
protected void onDestroy() {
super.onDestroy();
employees.close();
db.close();*/
}
}
public class extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_rss);
// get button from layout.xml
Button fetchRss = (Button) findViewById(R.id.fetchRss);
// define the action that will be executed when the button is clicked.
fetchRss.setOnClickListener(new View.OnClickListener() {
//@Override
public void onClick(View v) {
feedUrl = getString(R.string.rss_url);
//TextView TVtitle=(TextView)findViewById(R.id.label);
//CharSequence cs="fetching";
//TVtitle.setText(cs);
aa.notifyDataSetChanged();
refressRssList();
//cs="Feed:";
//TVtitle.setText(cs);
}
});
// get the listview from layout.xml
rssListView = (ListView) findViewById(R.id.rssListView);
// here we specify what to execute when individual list items clicked
rssListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//@Override
public void onItemClick(AdapterView av, View view, int index,
long arg3) {
selectedRssItem = rssItems.get(index);
// we call the other activity that shows a single rss item in
// one page
Intent intent = new Intent(
"rembo.network.urss.displayRssItem");
startActivity(intent);
}
});
//adapters are used to populate list. they take a collection,
//a view (in our example R.layout.list_item
aa = new ArrayAdapter(this, R.layout.rss_list_item, rssItems);
//here we bind array adapter to the list
rssListView.setAdapter(aa);
feedUrl = getString(R.string.rss_url);
refressRssList();
}
private void refressRssList() {
ArrayList newItems = RssItem.getRssItems(feedUrl);
rssItems.clear();
rssItems.addAll(newItems);
//TextView TVtitle=(TextView)findViewById(R.id.label);
//CharSequence cs="0";
//if(newItems.size()>0) cs="is 1";
//if(newItems.size()>5) cs="is 5";
///TVtitle.setText(cs);
aa.notifyDataSetChanged();
}
} //android:layout_marginBottom="72dp" />
==============================
android:layout_span="2"
android:layout_weight="1"
=========================
keytool.exe -list -alias androiddebugkey -keystore "C:\users\combo\.android\debug.keystore" -storepass android -keypass android
<resources>
<style name="AppBaseTheme" >
<item name="android:colorPrimary">@color/indigo_500</item>
<item name="android:colorPrimaryDark">@color/indigo_700</item>
<item name="android:colorAccent">@color/cyan_500</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
styles
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
=====================
Theme.AppCompat.Light
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<!-- Material Designe! colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/indigo</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/pink</item>
<!-- colorAccent is used as the default value for colorControlActivated,
which is used to tint widgets -->
<item name="colorAccent">@color/teal</item>
/
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorPrimary"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="72dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Library Name"
android:text="MaterialEditText"
android:textCursorDrawable="@drawable/text_cursor_cyan"
android:textSize="34sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_maxCharacters="20"
app:met_primaryColor="?colorAccent"
app:met_singleLineEllipsis="true" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Description"
android:text="EditText in Material Design"
android:textCursorDrawable="@drawable/text_cursor_cyan"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_maxCharacters="20"
app:met_primaryColor="?colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Basic:"
android:textColor="#333333"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/basicEt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Basic"
android:textColor="@color/text_color"/>
<Button
android:id="@+id/enableBt"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="DISABLE" />
</LinearLayout>
[3]
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Floating Label:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_floatingLabel="normal""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Floating Label"
app:met_floatingLabel="normal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Highlight Floating Label:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_floatingLabel="highlight""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Highlight Floating Label"
app:met_floatingLabel="highlight"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Custom Floating Label Text:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_floatingLabel="normal"\napp:met_floatingLabelText="Label""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Custom Floating Label Text"
app:met_floatingLabel="normal"
app:met_floatingLabelText="Label" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Single Line Ellipsis:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_singleLineEllipsis="true"\n#singLineEllipsis will force android:singleLine to true#"
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/singleLineEllipsisEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Single Line Ellipsis"
android:text="Touch The Ellipsis And See What Happens. Touch The Ellipsis And See What Happens."
app:met_singleLineEllipsis="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Max/Min Characters:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_maxCharacters="5""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Max Characters"
app:met_maxCharacters="5" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_minCharacters="3""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Min Characters"
app:met_minCharacters="3" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_minCharacters="3"\napp:met_maxCharacters="5""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Min and Max"
app:met_maxCharacters="5"
app:met_minCharacters="3" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Helper/Error Text:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_helperText="helper is here" (in xml)\nsetError("Error!") (in java)"
android:textColor="#888888"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/bottomTextEt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Helper/Error Text"
app:met_helperText="helper is here" />
<Button
android:id="@+id/setErrorBt"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="1" />
<Button
android:id="@+id/setError2Bt"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="2" />
<Button
android:id="@+id/setError3Bt"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="3" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Validation:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="addValidator(new RegexValidator("Only Integer Valid!", "\\\\d+")); (in java)"
android:textColor="#888888"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/validationEt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Validation"
app:met_helperText="Integer" />
<Button
android:id="@+id/validateBt"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="VALIDATE" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Custom Colors:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_baseColor="#007688"\napp:met_primaryColor="#2196F3"\napp:met_textColor="@color/text_color"\napp:met_textColorHint="#33ff0000"\napp:met_errorColor="#ddaa00"\napp:met_helperTextColor="#795548"\napp:met_underlineColor="#003587"\napp:met_floatingLabelTextColor="#8805ad""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Custom Colors"
app:met_floatingLabel="normal"
app:met_helperText="Helper Text"
app:met_maxCharacters="5"
app:met_baseColor="#007688"
app:met_primaryColor="#2196F3"
app:met_textColor="@color/text_color"
app:met_textColorHint="#33ff0000"
app:met_errorColor="#ddaa00"
app:met_helperTextColor="#795548"
app:met_underlineColor="#003587"
app:met_floatingLabelTextColor="#8805ad"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Custom Typeface:"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_typeface="fonts/Roboto-LightItalic.ttf"\napp:met_accentTypeface="fonts/Roboto-LightItalic.ttf""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Custom Accent Typeface"
app:met_typeface="fonts/Roboto-LightItalic.ttf"
app:met_accentTypeface="fonts/Roboto-LightItalic.ttf"
app:met_floatingLabel="normal"
app:met_helperText="Helper Text"
app:met_maxCharacters="5" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Hide underline"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_hideUnderline="true""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hidden underline"
app:met_hideUnderline="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Clear Button"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_clearButton="true""
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Clear Button"
app:met_clearButton="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Material Design Icon"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="app:met_iconLeft="@drawable/ic_phone"\napp:met_iconPadding="0dp" (Note: 16dp by default, not 0)"
android:textColor="#888888"
android:textSize="14sp" />
<com.rengwuxian.materialedittext.MaterialEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Material Design Icon"
app:met_iconLeft="@drawable/ic_phone"
app:met_iconPadding="0dp"
app:met_maxCharacters="5" />
</LinearLayout>
</LinearLayout>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
android:drawableLeft="@drawable/ic_business_center"
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Город "
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etCity"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvStreet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Улица "
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etStreet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvHomeNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="№ дома "
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etHomeNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvFlatNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="№ кВ. "
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etFlatNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvTelNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Номер вашего телефона "
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etTelNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
</TableLayout>
</RelativeLayout>
package com.psyberia.luckyboxpro;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreProtocolPNames;
import org.json.JSONArray;
import org.json.JSONObject;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.psyberia.luckyboxpro.json.Category;
import com.psyberia.luckyboxpro.json.CategoryDeserializer;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment;
import android.support.v4.view.ViewPager.LayoutParams;
import android.util.Log;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.Menu;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FMTAllCategory extends ListFragment/* Activity */ {
private static FMTAllCategory instance = null;
private boolean paused = false;
//private Button buttonPlay;
private static String TAG = null;
//private TextView lblTop;
private TextView lblWeb;
private TextView tvBottom;
private View header1;
private ListView feedLv;
private SeekBar sBar;
private int sdkVersion = android.os.Build.VERSION.SDK_INT;
private MainActivity root = null;
private Context c = null;
private Activity a = null;
// Храним полученные категории, собранный JSON
Vector<Category> categoryNodes;
private Vector<String[]> feedNodes = new Vector<String[]>();
private View rootView = null; // View который будем отдавать
private FMTAllCategory(){
TAG = "->" + this.getClass().getSimpleName();
Log.e(TAG, "Constructor run...");
} //Constructor
@SuppressLint("NewApi")
private Runnable showProgressBar = new Runnable() {
@Override
public void run() {
root.progBar.setVisibility(View.VISIBLE);
//- buttonPlay.setEnabled(false);
if (sdkVersion < android.os.Build.VERSION_CODES.JELLY_BEAN) {
//- buttonPlay.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.logo_dark));
} else {
//- buttonPlay.setBackground(c.getResources().getDrawable(R.drawable.logo_dark));
}
}
};
public static FMTAllCategory getInstance() {
Log.e(TAG, "::getInstance()");
if(null == instance){
Log.e(TAG, "::getInstance() - new");
instance = new FMTAllCategory();
}
return instance;
}
//use this for save state of fragment on orientation.
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// keep the fragment and all its data across screen rotation
setRetainInstance(true);
Bundle bundle = getArguments();
Log.e(TAG, "::onCreate BUNDLE" + bundle + savedInstanceState);
if (savedInstanceState != null) {
Log.e(TAG, "::restore data 2");
//Restore the fragment's instance
//- Object mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
}
}
// Допишем, для работы с ListFragment !!!
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Log.e(TAG, "::onActivityCreated()" + savedInstanceState);
if (savedInstanceState != null) {
//Restore the fragment's state here
Log.e(TAG, "::restore data 1");
//someVarA = savedInstanceState.getInt("someVarA");
//someVarB = savedInstanceState.getString("someVarB");
}
}
//Data save
@Override
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
Log.e(TAG, "::onSaveInstanceState()");
//Save the fragment's state here
//outState.putSerializable("Vector", (Serializable) primeCategories);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
a = getActivity();
c = a;
root = (MainActivity) getActivity();
header1 = createHeader("header 1");
Log.e(TAG, "::onCreateView() -- instance " + savedInstanceState);
if (root.isNetworkAvailable()) {
//= if (buttonPlay == null) {
rootView = inflater.inflate(R.layout.categories_screen, null);
//
root.runOnUiThread(new Runnable() {
@Override
public void run() {
initializeUIElements();
}
});
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
loadCategory();
return null;
}
}.execute();
//= }
} else {
rootView = inflater.inflate(R.layout.no_network, null); // fix
// container,
// false
}
return rootView;
}
// Fixed navigation bug
@Override
public void onDestroyView() {
super.onDestroyView();
if (rootView != null) {
ViewGroup parentViewGroup = (ViewGroup) rootView.getParent();
if (parentViewGroup != null) {
parentViewGroup.removeAllViews();
}
}
}
private void initializeUIElements() {
//- buttonPlay = (Button) rootView.findViewById(R.id.button1);
lblWeb = (TextView) rootView.findViewById(R.id.textViewWeb);
tvBottom = (TextView) rootView.findViewById(R.id.tvBottom);
sBar = (SeekBar) rootView.findViewById(R.id.volumeControl1);
sBar.setMax(root.getStreamMaxVolume());
sBar.setProgress(root.getStreamVolume());
sBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {
root.setStreamVolume(progress);
}
});
/*- buttonPlay.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("TAG", "CLICK PLAY");
if (root.playing) {
root.stopPlaying();
playingStopped(); // Отключаем черную кнопку
}
else //enable play
{
Handler show_progress_h = new Handler();
show_progress_h.post(showProgressBar);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... arg0) {
root.startPlaying("http://kruljo.radiostudent.si:8000/hiq.m3u", "Metal");
return null;
}
}.execute();
}
}
});*/
//- lblTop = (TextView) rootView.findViewById(R.id.textView2);
/*
* ListView lv = (ListView) rootView.findViewById(R.id.feedListView);
* lv.setClickable(true);
*
*
* //Select station list lv.setOnItemClickListener(new
* AdapterView.OnItemClickListener() {
*
* @Override public void onItemClick(AdapterView<?> arg0, View arg1, int
* position, long arg3) { //String url =
* "http://radiostudent.si"+feedNodes.get(position)[4]; //Intent
* browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
* //startActivity(browserIntent);
*
* String grName = root.categoryNodes.get(position)[1]; String id =
* root.categoryNodes.get(position)[0]; root.getStation(grName, id); }
* });
*/
}
public void feedUpdateGUI() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
int arr_size = feedNodes.size();
ArrayList<HashMap<String, String>> arrList = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < arr_size; i++) {
HashMap<String, String> map = new HashMap<String, String>();
String[] node = feedNodes.get(i);
map.put("title", node[0]);
map.put("subtitle", node[5]);
// map.put("image", node[3]);
arrList.add(map);
}
ListView feedLv = (ListView) getActivity().findViewById(R.id.feedListView);
LazyAdapter adapter = new LazyAdapter(a, arrList);
feedLv.setAdapter(adapter);
lblWeb.setVisibility(View.VISIBLE);
}
});
}
@SuppressLint("NewApi")
private void playingStopped() {
if (sdkVersion < android.os.Build.VERSION_CODES.JELLY_BEAN) {
//- buttonPlay.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.logo_light));
} else {
//- buttonPlay.setBackground(c.getResources().getDrawable(R.drawable.logo_light));
}
//lblTop.setText(R.string.play_text);
}
// Get all categoryes
private void loadCategory() {
DefaultHttpClient httpclient = new DefaultHttpClient(new BasicHttpParams());
HttpGet get = new HttpGet(Config.API_ALL_CAT);
String myUA = "Mozilla/5.0 (Linux; U; Android 2.1; en-us; Eclair_SPR Build/30201) AppleWebKit/520.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/520.17";
get.setHeader("User-Agent", myUA);
httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, myUA);
// httppost.setHeader("Content-type", "application/json");
InputStream inputStream = null;
String result = null;
try {
HttpResponse response = httpclient.execute(get);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
sb.append(line + "\n");
result = sb.toString();
final String request = result;
// Looper.prepare();
//Log.e("TAG", "ALL CATEGORY RESULT: " + Config.API_ALL_CAT + request);
categoryNodes = new Vector<Category>();
/*JsonParser parser = new JsonParser();
JsonElement element = new JsonPrimitive(request);
JsonObject o = element.getAsJsonObject();
JsonArray elemArr = o.getAsJsonArray();
// Пробегаемся по массиву
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Category.class, new CategoryDeserializer());
//gsonBuilder.registerTypeAdapter(Category.class, new CategoryDeserializer());
final Gson gson = gsonBuilder.create();
for (JsonElement jsonElement : elemArr) {
final Category c = gson.fromJson(jsonElement, Category.class);
Println.v("FMT Station IN Categories :: Преобразовали в обьект []: " + gson.toJson(c));
categoryNodes.add(c);
}
*/
JSONArray temp_json_array = new JSONArray(request);
//Gson gson = new Gson();
//String json = gson.toJson(temp_json_array);
//DataObject obj = gson.fromJson(json, DataObject.class);
// Пробегаемся по массиву
for (int i = 0; i < temp_json_array.length(); i++) {
//Deserialize
JSONObject obj = temp_json_array.getJSONObject(i);
//-- String json = new Gson().toJson(obj);
//Println.v("json station 1" + json);
//Println.v("json station 2" + obj.toString());
// to class
// Gson gson = new Gson();
// gson.fromJson(json, Category.class);
// Println.v("Class: " + gson);
//First way to create a Gson object for faster coding
//Gson gson = new Gson();
//Second way to create a Gson object using GsonBuilder
// Configure GSON [1]
/* final GsonBuilder gsonBuilder = new GsonBuilder();
//gsonBuilder.registerTypeAdapter(Book.class, new BookSerialiser())
final Gson gson = gsonBuilder
.disableHtmlEscaping()
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.setPrettyPrinting()
.serializeNulls()
.create();*/
//Из JSONObject заполняем класс
Category category = new Category();
//category.setId(1);
//category.setAncestry("ancestry");
//category.setCreated_at("created at");
//category.setRoles(Arrays.asList("ADMIN", "MANAGER"));
CategorySerializer.fromJSONObject(category, obj); //Из JSONObject заполняем класс
//DwarvesBand dwarvesBand = new Gson().fromJson(json, DwarvesBand.class);
//= Gson gson = new Gson();
//Println.v("Gson obj: " + category.toString());
//System.out.println(gson.toJson(category));
//Println.v("Result category: " + category.toString());
categoryNodes.add(category);
}
// Выводим категории
categoryUpdateGUI();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (inputStream != null)
inputStream.close();
} catch (Exception squish) {
}
}
}
// Выводим категории
private void categoryUpdateGUI() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
int arr_size = categoryNodes.size();
ArrayList<HashMap<String, String>> arrList = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < arr_size; i++) {
HashMap<String, String> map = new HashMap<String, String>();
Category node = categoryNodes.get(i);
map.put("title", node.getTitle());
map.put("subtitle", node.getDescription());
// map.put("image", node[3]);
arrList.add(map);
}
// feedLv.addHeaderView(header1, "Some text", false);
LazyAdapter adapter = new LazyAdapter(a, arrList);
// Было:
// feedLv.setAdapter(adapter);
// lblWeb.setVisibility(View.VISIBLE);
setListAdapter(adapter);
}
});
}
// создание Header
View createHeader(String text) {
View v = root.getLayoutInflater().inflate(R.layout.lv_header, null);
((TextView) v.findViewById(R.id.tvText)).setText(text);
return v;
}
@Override
public void setEmptyText(CharSequence text) {
TextView tv = (TextView) getListView().getEmptyView();
tv.setText(text);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
//Toast.makeText(getActivity(), "position = " + position, Toast.LENGTH_SHORT).show();
Category node = categoryNodes.get(position);
String grName = node.getTitle();
int gid = node.getId();
root.getStations(grName, gid);
}
@Override
public void onPause(){
super.onPause();
Println.v("FMTAllCategory::onPause()");
paused = true;
}
@Override
public void onResume(){
Println.v("FMTAllCategory::onResume()");
super.onResume();
if(paused){
if(feedNodes.size()<=0){ Println.v("FMTAllCategory::onResume() - reload data");
loadCategory();
}
paused=false;
}
}
}
zipalign -v 4 PillIdentifier.apk PillIdentifier_signed.apk
Copy
D:\Android\AndroidSDK\build-tools\23.0.2\zipalign.exe too
D:\Android\AndroidSDK\platform-tools
d to User->PATH->"path to zipalign folder
http://habrahabr.ru/post/241479/
https://www.google.com/design/spec/style/color.html#color-color-palette
Failed to run aapt dump badging:
ERROR: dump failed because assets could not be loaded
https://play.google.com
Комментариев нет:
Отправить комментарий