2020-05-01 19:53:13.569 10984-10984/com.app.dramaup E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.dramaup, PID: 10984
java.lang.NumberFormatException: For input string: ""
at java.lang.Integer.parseInt(Integer.java:627)
at java.lang.Integer.parseInt(Integer.java:650)
at com.app.dramaup.activities.ActivityRelatedCategory.requestPostApi(ActivityRelatedCategory.java:187)
at com.app.dramaup.activities.ActivityRelatedCategory.access$700(ActivityRelatedCategory.java:40)
at com.app.dramaup.activities.ActivityRelatedCategory$5.run(ActivityRelatedCategory.java:230)
at android.os.Handler.handleCallback(Unknown Source:2)
at android.os.Handler.dispatchMessage(Unknown Source:4)
at android.os.Looper.loop(Unknown Source:207)
at android.app.ActivityThread.main(Unknown Source:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:274)
2020-05-01 19:53:14.213 10984-11020/com.app.dramaup E/FA: Task exception on worker thread: java.lang.NoSuchFieldError: No static field zzaqq of type [Ljava/lang/String; in class Lcom/google/android/gms/measurement/internal/zzcu; or its superclasses (declaration of 'com.google.android.gms.measurement.internal.zzcu' appears in base.apk): com.google.android.gms.measurement.internal.zzfy.zzcu(Unknown Source:161)
2020-05-01 19:53:14.323 10984-11020/com.app.dramaup E/FA: Task exception on worker thread: java.lang.NoSuchFieldError: No static field zzaqq of type [Ljava/lang/String; in class Lcom/google/android/gms/measurement/internal/zzcu; or its superclasses (declaration of 'com.google.android.gms.measurement.internal.zzcu' appears in base.apk): com.google.android.gms.measurement.internal.zzfy.zzcu(Unknown Source:161)
Привет, я пытаюсь создать страницу истории в приложении mov ie, поэтому я делаю обработчик базы данных, чтобы создать страницу истории списка, но некоторые функции не работают, когда я нажимаю «все категории» в Activitydetailvideo, но это прекрасно работает, если я нажимаю с недавней страницы не будет работать, если я нажму на страницу истории здесь мой код
Обработчик базы данных
public class DatabaseHandlerHistory extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "db_video_history";
private static final String TABLE_NAME = "tbl_video_history";
private static final String KEY_ID = "id";
//private static final String KEY_CAT_ID = "catid";
private static final String KEY_CAT_NAME = "category_name";
private static final String KEY_VID = "vid";
private static final String KEY_VIDEO_TITLE = "video_title";
private static final String KEY_VIDEO_URL = "video_url";
private static final String KEY_VIDEO_ID = "video_id";
private static final String KEY_VIDEO_THUMBNAIL = "video_thumbnail";
private static final String KEY_VIDEO_DURATION = "video_duration";
private static final String KEY_VIDEO_DESCRIPTION = "video_description";
private static final String KEY_VIDEO_TYPE = "video_type";
private static final String KEY_TOTAL_VIEWS = "total_views";
private static final String KEY_DATE_TIME = "date_time";
public DatabaseHandlerHistory(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_NAME + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_CAT_NAME + " TEXT,"
+ KEY_VID + " TEXT,"
+ KEY_VIDEO_TITLE + " TEXT,"
+ KEY_VIDEO_URL + " TEXT,"
+ KEY_VIDEO_ID + " TEXT,"
+ KEY_VIDEO_THUMBNAIL + " TEXT,"
+ KEY_VIDEO_DURATION + " TEXT,"
+ KEY_VIDEO_DESCRIPTION + " TEXT,"
+ KEY_VIDEO_TYPE + " TEXT,"
+ KEY_TOTAL_VIEWS + " INTEGER,"
+ KEY_DATE_TIME + " TEXT"
+ ")";
db.execSQL(CREATE_CONTACTS_TABLE);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
// Create tables again
onCreate(db);
}
//Adding Record in Database
public void AddtoHistory(Video pj) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_CAT_NAME, pj.getCategory_name());
values.put(KEY_VID, pj.getVid());
values.put(KEY_VIDEO_TITLE, pj.getVideo_title());
values.put(KEY_VIDEO_URL, pj.getVideo_url());
values.put(KEY_VIDEO_ID, pj.getVideo_id());
values.put(KEY_VIDEO_THUMBNAIL, pj.getVideo_thumbnail());
values.put(KEY_VIDEO_DURATION, pj.getVideo_duration());
values.put(KEY_VIDEO_DESCRIPTION, pj.getVideo_description());
values.put(KEY_VIDEO_TYPE, pj.getVideo_type());
values.put(KEY_TOTAL_VIEWS, pj.getTotal_views());
values.put(KEY_DATE_TIME, pj.getDate_time());
// Inserting Row
db.insert(TABLE_NAME, null, values);
db.close(); // Closing database connection
}
// Getting All Data
public List<Video> getAllData() {
List<Video> dataList = new ArrayList<Video>();
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_NAME + " ORDER BY id DESC";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Video contact = new Video();
contact.setId(Integer.parseInt(cursor.getString(0)));
contact.setCategory_name(cursor.getString(1));
contact.setVid(cursor.getString(2));
contact.setVideo_title(cursor.getString(3));
contact.setVideo_url(cursor.getString(4));
contact.setVideo_id(cursor.getString(5));
contact.setVideo_thumbnail(cursor.getString(6));
contact.setVideo_duration(cursor.getString(7));
contact.setVideo_description(cursor.getString(8));
contact.setVideo_type(cursor.getString(9));
contact.setTotal_views(cursor.getLong(10));
contact.setDate_time(cursor.getString(11));
// Adding contact to list
dataList.add(contact);
} while (cursor.moveToNext());
}
// return contact list
return dataList;
}
//getting single row
public List<Video> getHstrRow(String id) {
List<Video> dataList = new ArrayList<Video>();
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_NAME + " WHERE vid=" + id;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Video contact = new Video();
contact.setId(Integer.parseInt(cursor.getString(0)));
contact.setCategory_name(cursor.getString(1));
contact.setVid(cursor.getString(2));
contact.setVideo_title(cursor.getString(3));
contact.setVideo_url(cursor.getString(4));
contact.setVideo_id(cursor.getString(5));
contact.setVideo_thumbnail(cursor.getString(6));
contact.setVideo_duration(cursor.getString(7));
contact.setVideo_description(cursor.getString(8));
contact.setVideo_type(cursor.getString(9));
contact.setTotal_views(cursor.getLong(10));
contact.setDate_time(cursor.getString(11));
// Adding contact to list
dataList.add(contact);
} while (cursor.moveToNext());
}
// return contact list
return dataList;
}
//for remove history
public void RemoveHstr(Video contact) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_NAME, KEY_VID + " = ?",
new String[]{String.valueOf(contact.getVid())});
db.close();
}
public enum DatabaseManager {
INSTANCE;
private SQLiteDatabase db;
private boolean isDbClosed = true;
DatabaseHandlerHistory dbHelper;
public void init(Context context) {
dbHelper = new DatabaseHandlerHistory(context);
if (isDbClosed) {
isDbClosed = false;
this.db = dbHelper.getWritableDatabase();
}
}
public boolean isDatabaseClosed() {
return isDbClosed;
}
public void closeDatabase() {
if (!isDbClosed && db != null) {
isDbClosed = true;
db.close();
dbHelper.close();
}
}
}
}
ActivityRelatedCategory
public class ActivityRelatedCategory extends AppCompatActivity {
private RecyclerView recyclerView;
private AdapterRecent adapterRecent;
private SwipeRefreshLayout swipeRefreshLayout;
private Call<CallbackCategoryDetails> callbackCall = null;
private int post_total = 0;
private int failed_page = 0;
private AdView adView;
View view;
private InterstitialAd interstitialAd;
int counter = 1;
String str_category;
String str_cid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_category_details);
view = findViewById(android.R.id.content);
if (Config.ENABLE_RTL_MODE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
}
} else {
Log.d("Log", "Working in Normal Mode, RTL Mode is Disabled");
}
Intent intent = getIntent();
if (null != intent) {
str_cid = intent.getStringExtra(Constant.KEY_VIDEO_CATEGORY_ID);
str_category = intent.getStringExtra(Constant.KEY_VIDEO_CATEGORY_NAME);
}
initAds();
loadBannerAd();
loadInterstitialAd();
swipeRefreshLayout = findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setColorSchemeResources(R.color.colorOrange, R.color.colorGreen, R.color.colorBlue, R.color.colorRed);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
//set data and list adapter
adapterRecent = new AdapterRecent(this, recyclerView, new ArrayList<Video>());
recyclerView.setAdapter(adapterRecent);
// on item list clicked
adapterRecent.setOnItemClickListener(new AdapterRecent.OnItemClickListener() {
@Override
public void onItemClick(View v, Video obj, int position) {
Intent intent = new Intent(getApplicationContext(), ActivityDetailVideo.class);
intent.putExtra(Constant.KEY_VIDEO_CATEGORY_ID, obj.cat_id);
intent.putExtra(Constant.KEY_VIDEO_CATEGORY_NAME, obj.category_name);
intent.putExtra(Constant.KEY_VID, obj.vid);
intent.putExtra(Constant.KEY_VIDEO_TITLE, obj.video_title);
intent.putExtra(Constant.KEY_VIDEO_URL, obj.video_url);
intent.putExtra(Constant.KEY_VIDEO_ID, obj.video_id);
intent.putExtra(Constant.KEY_VIDEO_THUMBNAIL, obj.video_thumbnail);
intent.putExtra(Constant.KEY_VIDEO_DURATION, obj.video_duration);
intent.putExtra(Constant.KEY_VIDEO_DESCRIPTION, obj.video_description);
intent.putExtra(Constant.KEY_VIDEO_TYPE, obj.video_type);
startActivity(intent);
showInterstitialAd();
}
});
// detect when scroll reach bottom
adapterRecent.setOnLoadMoreListener(new AdapterRecent.OnLoadMoreListener() {
@Override
public void onLoadMore(int current_page) {
if (post_total > adapterRecent.getItemCount() && current_page != 0) {
int next_page = current_page + 1;
requestAction(next_page);
} else {
adapterRecent.setLoaded();
}
}
});
// on swipe list
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (callbackCall != null && callbackCall.isExecuted()) {
callbackCall.cancel();
}
adapterRecent.resetListData();
requestAction(1);
}
});
requestAction(1);
setupToolbar();
}
public void setupToolbar() {
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setTitle(str_category);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_category, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case R.id.search:
Intent intent = new Intent(getApplicationContext(), ActivitySearch.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(menuItem);
}
}
private void displayApiResult(final List<Video> videos) {
adapterRecent.insertData(videos);
swipeProgress(false);
if (videos.size() == 0) {
showNoItemView(true);
}
}
private void requestPostApi(final int page_no) {
ApiInterface apiInterface = RestAdapter.createAPI();
callbackCall = apiInterface.getCategoryDetailsByPage(Integer.parseInt(str_cid), page_no, Config.LOAD_MORE);
callbackCall.enqueue(new Callback<CallbackCategoryDetails>() {
@Override
public void onResponse(Call<CallbackCategoryDetails> call, Response<CallbackCategoryDetails> response) {
CallbackCategoryDetails resp = response.body();
if (resp != null && resp.status.equals("ok")) {
post_total = resp.count_total;
displayApiResult(resp.posts);
} else {
onFailRequest(page_no);
}
}
@Override
public void onFailure(Call<CallbackCategoryDetails> call, Throwable t) {
if (!call.isCanceled()) onFailRequest(page_no);
}
});
}
private void onFailRequest(int page_no) {
failed_page = page_no;
adapterRecent.setLoaded();
swipeProgress(false);
if (Tools.isConnect(getApplicationContext())) {
showFailedView(true, getString(R.string.failed_text));
} else {
showFailedView(true, getString(R.string.no_internet_text));
}
}